Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 1 | #include <stdio.h> |
Jeff Dike | 16dd07b | 2007-05-06 14:51:48 -0700 | [diff] [blame] | 2 | #include <stddef.h> |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 3 | #include <signal.h> |
Jeff Dike | 16dd07b | 2007-05-06 14:51:48 -0700 | [diff] [blame] | 4 | #include <sys/poll.h> |
Jeff Dike | 189872f | 2007-10-16 01:27:14 -0700 | [diff] [blame] | 5 | #include <sys/user.h> |
Jeff Dike | 16dd07b | 2007-05-06 14:51:48 -0700 | [diff] [blame] | 6 | #include <sys/mman.h> |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 7 | #include <asm/ptrace.h> |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 8 | |
| 9 | #define DEFINE(sym, val) \ |
Jeff Dike | 63ae2a9 | 2006-03-27 01:14:30 -0800 | [diff] [blame] | 10 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 11 | |
Al Viro | ecba97d | 2005-09-28 22:27:23 +0100 | [diff] [blame] | 12 | #define DEFINE_LONGS(sym, val) \ |
Jeff Dike | 63ae2a9 | 2006-03-27 01:14:30 -0800 | [diff] [blame] | 13 | asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long))) |
Al Viro | ecba97d | 2005-09-28 22:27:23 +0100 | [diff] [blame] | 14 | |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 15 | #define OFFSET(sym, str, mem) \ |
| 16 | DEFINE(sym, offsetof(struct str, mem)); |
| 17 | |
| 18 | void foo(void) |
| 19 | { |
Al Viro | ecba97d | 2005-09-28 22:27:23 +0100 | [diff] [blame] | 20 | OFFSET(HOST_SC_TRAPNO, sigcontext, trapno); |
| 21 | OFFSET(HOST_SC_ERR, sigcontext, err); |
| 22 | OFFSET(HOST_SC_CR2, sigcontext, cr2); |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 23 | |
Jeff Dike | 189872f | 2007-10-16 01:27:14 -0700 | [diff] [blame] | 24 | DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct)); |
Jeff Dike | 47906dd | 2008-05-12 14:01:50 -0700 | [diff] [blame] | 25 | DEFINE_LONGS(HOST_FPX_SIZE, sizeof(struct user_fpxregs_struct)); |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 26 | |
| 27 | DEFINE(HOST_IP, EIP); |
| 28 | DEFINE(HOST_SP, UESP); |
| 29 | DEFINE(HOST_EFLAGS, EFL); |
| 30 | DEFINE(HOST_EAX, EAX); |
| 31 | DEFINE(HOST_EBX, EBX); |
| 32 | DEFINE(HOST_ECX, ECX); |
| 33 | DEFINE(HOST_EDX, EDX); |
| 34 | DEFINE(HOST_ESI, ESI); |
| 35 | DEFINE(HOST_EDI, EDI); |
| 36 | DEFINE(HOST_EBP, EBP); |
| 37 | DEFINE(HOST_CS, CS); |
| 38 | DEFINE(HOST_SS, SS); |
| 39 | DEFINE(HOST_DS, DS); |
| 40 | DEFINE(HOST_FS, FS); |
| 41 | DEFINE(HOST_ES, ES); |
| 42 | DEFINE(HOST_GS, GS); |
Al Viro | ecba97d | 2005-09-28 22:27:23 +0100 | [diff] [blame] | 43 | DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct)); |
Jeff Dike | 63ae2a9 | 2006-03-27 01:14:30 -0800 | [diff] [blame] | 44 | |
| 45 | /* XXX Duplicated between i386 and x86_64 */ |
| 46 | DEFINE(UM_POLLIN, POLLIN); |
| 47 | DEFINE(UM_POLLPRI, POLLPRI); |
| 48 | DEFINE(UM_POLLOUT, POLLOUT); |
Jeff Dike | 16dd07b | 2007-05-06 14:51:48 -0700 | [diff] [blame] | 49 | |
| 50 | DEFINE(UM_PROT_READ, PROT_READ); |
| 51 | DEFINE(UM_PROT_WRITE, PROT_WRITE); |
| 52 | DEFINE(UM_PROT_EXEC, PROT_EXEC); |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 53 | } |