aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/sys-x86/user-offsets.c
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2011-08-18 15:03:19 -0400
committerRichard Weinberger <richard@nod.at>2011-11-02 09:14:51 -0400
commit6582b7f7743da6ce3e3714e9e8b18e0e073d4acd (patch)
tree649346d2333865ccd4bb4d560ceb50c39139c5c2 /arch/um/sys-x86/user-offsets.c
parent858ba94499b4f48e9eb0be7cf0092f1ea9460fef (diff)
um: merge arch/um/sys-{i386,x86_64}
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um/sys-x86/user-offsets.c')
-rw-r--r--arch/um/sys-x86/user-offsets.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/arch/um/sys-x86/user-offsets.c b/arch/um/sys-x86/user-offsets.c
new file mode 100644
index 000000000000..718f0c0f0b0c
--- /dev/null
+++ b/arch/um/sys-x86/user-offsets.c
@@ -0,0 +1,86 @@
1#include <stdio.h>
2#include <stddef.h>
3#include <signal.h>
4#include <sys/poll.h>
5#include <sys/mman.h>
6#include <sys/user.h>
7#define __FRAME_OFFSETS
8#include <asm/ptrace.h>
9#include <asm/types.h>
10
11#define DEFINE(sym, val) \
12 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
13
14#define DEFINE_LONGS(sym, val) \
15 asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
16
17#define OFFSET(sym, str, mem) \
18 DEFINE(sym, offsetof(struct str, mem));
19
20void foo(void)
21{
22 OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
23 OFFSET(HOST_SC_ERR, sigcontext, err);
24 OFFSET(HOST_SC_CR2, sigcontext, cr2);
25
26#ifdef __i386__
27 DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct));
28 DEFINE_LONGS(HOST_FPX_SIZE, sizeof(struct user_fpxregs_struct));
29
30 DEFINE(HOST_IP, EIP);
31 DEFINE(HOST_SP, UESP);
32 DEFINE(HOST_EFLAGS, EFL);
33 DEFINE(HOST_EAX, EAX);
34 DEFINE(HOST_EBX, EBX);
35 DEFINE(HOST_ECX, ECX);
36 DEFINE(HOST_EDX, EDX);
37 DEFINE(HOST_ESI, ESI);
38 DEFINE(HOST_EDI, EDI);
39 DEFINE(HOST_EBP, EBP);
40 DEFINE(HOST_CS, CS);
41 DEFINE(HOST_SS, SS);
42 DEFINE(HOST_DS, DS);
43 DEFINE(HOST_FS, FS);
44 DEFINE(HOST_ES, ES);
45 DEFINE(HOST_GS, GS);
46#else
47 DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
48 DEFINE_LONGS(HOST_RBX, RBX);
49 DEFINE_LONGS(HOST_RCX, RCX);
50 DEFINE_LONGS(HOST_RDI, RDI);
51 DEFINE_LONGS(HOST_RSI, RSI);
52 DEFINE_LONGS(HOST_RDX, RDX);
53 DEFINE_LONGS(HOST_RBP, RBP);
54 DEFINE_LONGS(HOST_RAX, RAX);
55 DEFINE_LONGS(HOST_R8, R8);
56 DEFINE_LONGS(HOST_R9, R9);
57 DEFINE_LONGS(HOST_R10, R10);
58 DEFINE_LONGS(HOST_R11, R11);
59 DEFINE_LONGS(HOST_R12, R12);
60 DEFINE_LONGS(HOST_R13, R13);
61 DEFINE_LONGS(HOST_R14, R14);
62 DEFINE_LONGS(HOST_R15, R15);
63 DEFINE_LONGS(HOST_ORIG_RAX, ORIG_RAX);
64 DEFINE_LONGS(HOST_CS, CS);
65 DEFINE_LONGS(HOST_SS, SS);
66 DEFINE_LONGS(HOST_EFLAGS, EFLAGS);
67#if 0
68 DEFINE_LONGS(HOST_FS, FS);
69 DEFINE_LONGS(HOST_GS, GS);
70 DEFINE_LONGS(HOST_DS, DS);
71 DEFINE_LONGS(HOST_ES, ES);
72#endif
73
74 DEFINE_LONGS(HOST_IP, RIP);
75 DEFINE_LONGS(HOST_SP, RSP);
76#endif
77
78 DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
79 DEFINE(UM_POLLIN, POLLIN);
80 DEFINE(UM_POLLPRI, POLLPRI);
81 DEFINE(UM_POLLOUT, POLLOUT);
82
83 DEFINE(UM_PROT_READ, PROT_READ);
84 DEFINE(UM_PROT_WRITE, PROT_WRITE);
85 DEFINE(UM_PROT_EXEC, PROT_EXEC);
86}