blob: 5f883bfe773fe37899f361507131129e800059d8 [file] [log] [blame]
Al Viro8d0b9dc2005-05-05 16:15:23 -07001#include <stdio.h>
Jeff Dike16dd07b2007-05-06 14:51:48 -07002#include <stddef.h>
Al Viro8d0b9dc2005-05-05 16:15:23 -07003#include <signal.h>
Jeff Dike16dd07b2007-05-06 14:51:48 -07004#include <sys/poll.h>
Jeff Dike189872f2007-10-16 01:27:14 -07005#include <sys/user.h>
Jeff Dike16dd07b2007-05-06 14:51:48 -07006#include <sys/mman.h>
Al Viro8d0b9dc2005-05-05 16:15:23 -07007#include <asm/ptrace.h>
Al Viro8d0b9dc2005-05-05 16:15:23 -07008
9#define DEFINE(sym, val) \
Jeff Dike63ae2a92006-03-27 01:14:30 -080010 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
Al Viro8d0b9dc2005-05-05 16:15:23 -070011
Al Viroecba97d2005-09-28 22:27:23 +010012#define DEFINE_LONGS(sym, val) \
Jeff Dike63ae2a92006-03-27 01:14:30 -080013 asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
Al Viroecba97d2005-09-28 22:27:23 +010014
Al Viro8d0b9dc2005-05-05 16:15:23 -070015#define OFFSET(sym, str, mem) \
16 DEFINE(sym, offsetof(struct str, mem));
17
18void foo(void)
19{
Al Viroecba97d2005-09-28 22:27:23 +010020 OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
21 OFFSET(HOST_SC_ERR, sigcontext, err);
22 OFFSET(HOST_SC_CR2, sigcontext, cr2);
Al Viro8d0b9dc2005-05-05 16:15:23 -070023
Jeff Dike189872f2007-10-16 01:27:14 -070024 DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct));
Jeff Dike47906dd2008-05-12 14:01:50 -070025 DEFINE_LONGS(HOST_FPX_SIZE, sizeof(struct user_fpxregs_struct));
Al Viro8d0b9dc2005-05-05 16:15:23 -070026
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 Viroecba97d2005-09-28 22:27:23 +010043 DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
Jeff Dike63ae2a92006-03-27 01:14:30 -080044
45 /* XXX Duplicated between i386 and x86_64 */
46 DEFINE(UM_POLLIN, POLLIN);
47 DEFINE(UM_POLLPRI, POLLPRI);
48 DEFINE(UM_POLLOUT, POLLOUT);
Jeff Dike16dd07b2007-05-06 14:51:48 -070049
50 DEFINE(UM_PROT_READ, PROT_READ);
51 DEFINE(UM_PROT_WRITE, PROT_WRITE);
52 DEFINE(UM_PROT_EXEC, PROT_EXEC);
Al Viro8d0b9dc2005-05-05 16:15:23 -070053}