Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <signal.h> |
| 3 | #include <asm/ptrace.h> |
| 4 | #include <asm/user.h> |
| 5 | #include <linux/stddef.h> |
Jeff Dike | 63ae2a9 | 2006-03-27 01:14:30 -0800 | [diff] [blame] | 6 | #include <sys/poll.h> |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 7 | |
| 8 | #define DEFINE(sym, val) \ |
Jeff Dike | 63ae2a9 | 2006-03-27 01:14:30 -0800 | [diff] [blame] | 9 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 10 | |
Al Viro | ecba97d | 2005-09-28 22:27:23 +0100 | [diff] [blame] | 11 | #define DEFINE_LONGS(sym, val) \ |
Jeff Dike | 63ae2a9 | 2006-03-27 01:14:30 -0800 | [diff] [blame] | 12 | asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long))) |
Al Viro | ecba97d | 2005-09-28 22:27:23 +0100 | [diff] [blame] | 13 | |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 14 | #define OFFSET(sym, str, mem) \ |
| 15 | DEFINE(sym, offsetof(struct str, mem)); |
| 16 | |
| 17 | void foo(void) |
| 18 | { |
Al Viro | ecba97d | 2005-09-28 22:27:23 +0100 | [diff] [blame] | 19 | OFFSET(HOST_SC_IP, sigcontext, eip); |
| 20 | OFFSET(HOST_SC_SP, sigcontext, esp); |
| 21 | OFFSET(HOST_SC_FS, sigcontext, fs); |
| 22 | OFFSET(HOST_SC_GS, sigcontext, gs); |
| 23 | OFFSET(HOST_SC_DS, sigcontext, ds); |
| 24 | OFFSET(HOST_SC_ES, sigcontext, es); |
| 25 | OFFSET(HOST_SC_SS, sigcontext, ss); |
| 26 | OFFSET(HOST_SC_CS, sigcontext, cs); |
| 27 | OFFSET(HOST_SC_EFLAGS, sigcontext, eflags); |
| 28 | OFFSET(HOST_SC_EAX, sigcontext, eax); |
| 29 | OFFSET(HOST_SC_EBX, sigcontext, ebx); |
| 30 | OFFSET(HOST_SC_ECX, sigcontext, ecx); |
| 31 | OFFSET(HOST_SC_EDX, sigcontext, edx); |
| 32 | OFFSET(HOST_SC_EDI, sigcontext, edi); |
| 33 | OFFSET(HOST_SC_ESI, sigcontext, esi); |
| 34 | OFFSET(HOST_SC_EBP, sigcontext, ebp); |
| 35 | OFFSET(HOST_SC_TRAPNO, sigcontext, trapno); |
| 36 | OFFSET(HOST_SC_ERR, sigcontext, err); |
| 37 | OFFSET(HOST_SC_CR2, sigcontext, cr2); |
| 38 | OFFSET(HOST_SC_FPSTATE, sigcontext, fpstate); |
| 39 | OFFSET(HOST_SC_SIGMASK, sigcontext, oldmask); |
| 40 | OFFSET(HOST_SC_FP_CW, _fpstate, cw); |
| 41 | OFFSET(HOST_SC_FP_SW, _fpstate, sw); |
| 42 | OFFSET(HOST_SC_FP_TAG, _fpstate, tag); |
| 43 | OFFSET(HOST_SC_FP_IPOFF, _fpstate, ipoff); |
| 44 | OFFSET(HOST_SC_FP_CSSEL, _fpstate, cssel); |
| 45 | OFFSET(HOST_SC_FP_DATAOFF, _fpstate, dataoff); |
| 46 | OFFSET(HOST_SC_FP_DATASEL, _fpstate, datasel); |
| 47 | OFFSET(HOST_SC_FP_ST, _fpstate, _st); |
| 48 | OFFSET(HOST_SC_FXSR_ENV, _fpstate, _fxsr_env); |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 49 | |
Jeff Dike | 71dc036 | 2005-10-04 14:53:49 -0400 | [diff] [blame] | 50 | DEFINE(HOST_FRAME_SIZE, FRAME_SIZE); |
Al Viro | ecba97d | 2005-09-28 22:27:23 +0100 | [diff] [blame] | 51 | DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_i387_struct)); |
| 52 | DEFINE_LONGS(HOST_XFP_SIZE, sizeof(struct user_fxsr_struct)); |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 53 | |
| 54 | DEFINE(HOST_IP, EIP); |
| 55 | DEFINE(HOST_SP, UESP); |
| 56 | DEFINE(HOST_EFLAGS, EFL); |
| 57 | DEFINE(HOST_EAX, EAX); |
| 58 | DEFINE(HOST_EBX, EBX); |
| 59 | DEFINE(HOST_ECX, ECX); |
| 60 | DEFINE(HOST_EDX, EDX); |
| 61 | DEFINE(HOST_ESI, ESI); |
| 62 | DEFINE(HOST_EDI, EDI); |
| 63 | DEFINE(HOST_EBP, EBP); |
| 64 | DEFINE(HOST_CS, CS); |
| 65 | DEFINE(HOST_SS, SS); |
| 66 | DEFINE(HOST_DS, DS); |
| 67 | DEFINE(HOST_FS, FS); |
| 68 | DEFINE(HOST_ES, ES); |
| 69 | DEFINE(HOST_GS, GS); |
Al Viro | ecba97d | 2005-09-28 22:27:23 +0100 | [diff] [blame] | 70 | DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct)); |
Jeff Dike | 63ae2a9 | 2006-03-27 01:14:30 -0800 | [diff] [blame] | 71 | |
| 72 | /* XXX Duplicated between i386 and x86_64 */ |
| 73 | DEFINE(UM_POLLIN, POLLIN); |
| 74 | DEFINE(UM_POLLPRI, POLLPRI); |
| 75 | DEFINE(UM_POLLOUT, POLLOUT); |
Al Viro | 8d0b9dc | 2005-05-05 16:15:23 -0700 | [diff] [blame] | 76 | } |