Commit d397abbdbe68715ec86b4392e4e6384db64d029d

Authored by blueswir1
1 parent d39bb24a

BSD user: add support for OpenBSD/amd64 host

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7066 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 19 additions and 11 deletions
cpu-exec.c
... ... @@ -1207,14 +1207,20 @@ int cpu_signal_handler(int host_signum, void *pinfo,
1207 1207 #elif defined(__x86_64__)
1208 1208  
1209 1209 #ifdef __NetBSD__
1210   -#define REG_ERR _REG_ERR
1211   -#define REG_TRAPNO _REG_TRAPNO
1212   -
1213   -#define QEMU_UC_MCONTEXT_GREGS(uc, reg) (uc)->uc_mcontext.__gregs[(reg)]
1214   -#define QEMU_UC_MACHINE_PC(uc) _UC_MACHINE_PC(uc)
  1210 +#define PC_sig(context) _UC_MACHINE_PC(context)
  1211 +#define TRAP_sig(context) ((context)->uc_mcontext.__gregs[_REG_TRAPNO])
  1212 +#define ERROR_sig(context) ((context)->uc_mcontext.__gregs[_REG_ERR])
  1213 +#define MASK_sig(context) ((context)->uc_sigmask)
  1214 +#elif defined(__OpenBSD__)
  1215 +#define PC_sig(context) ((context)->sc_rip)
  1216 +#define TRAP_sig(context) ((context)->sc_trapno)
  1217 +#define ERROR_sig(context) ((context)->sc_err)
  1218 +#define MASK_sig(context) ((context)->sc_mask)
1215 1219 #else
1216   -#define QEMU_UC_MCONTEXT_GREGS(uc, reg) (uc)->uc_mcontext.gregs[(reg)]
1217   -#define QEMU_UC_MACHINE_PC(uc) QEMU_UC_MCONTEXT_GREGS(uc, REG_RIP)
  1220 +#define PC_sig(context) ((context)->uc_mcontext.gregs[REG_RIP])
  1221 +#define TRAP_sig(context) ((context)->uc_mcontext.gregs[REG_TRAPNO])
  1222 +#define ERROR_sig(context) ((context)->uc_mcontext.gregs[REG_ERR])
  1223 +#define MASK_sig(context) ((context)->uc_sigmask)
1218 1224 #endif
1219 1225  
1220 1226 int cpu_signal_handler(int host_signum, void *pinfo,
... ... @@ -1224,15 +1230,17 @@ int cpu_signal_handler(int host_signum, void *pinfo,
1224 1230 unsigned long pc;
1225 1231 #ifdef __NetBSD__
1226 1232 ucontext_t *uc = puc;
  1233 +#elif defined(__OpenBSD__)
  1234 + struct sigcontext *uc = puc;
1227 1235 #else
1228 1236 struct ucontext *uc = puc;
1229 1237 #endif
1230 1238  
1231   - pc = QEMU_UC_MACHINE_PC(uc);
  1239 + pc = PC_sig(uc);
1232 1240 return handle_cpu_signal(pc, (unsigned long)info->si_addr,
1233   - QEMU_UC_MCONTEXT_GREGS(uc, REG_TRAPNO) == 0xe ?
1234   - (QEMU_UC_MCONTEXT_GREGS(uc, REG_ERR) >> 1) & 1 : 0,
1235   - &uc->uc_sigmask, puc);
  1241 + TRAP_sig(uc) == 0xe ?
  1242 + (ERROR_sig(uc) >> 1) & 1 : 0,
  1243 + &MASK_sig(uc), puc);
1236 1244 }
1237 1245  
1238 1246 #elif defined(_ARCH_PPC)
... ...