blob: 2f3443c6e859f4d890ef8b4e8c21c03c2e7bb152 [file] [log] [blame]
Al Viro8d0b9dc2005-05-05 16:15:23 -07001#include <stdio.h>
2#include <stddef.h>
3#include <signal.h>
Jeff Dike63ae2a92006-03-27 01:14:30 -08004#include <sys/poll.h>
Jeff Dike16dd07b2007-05-06 14:51:48 -07005#include <sys/mman.h>
Jeff Dike189872f2007-10-16 01:27:14 -07006#include <sys/user.h>
Al Viro8d0b9dc2005-05-05 16:15:23 -07007#define __FRAME_OFFSETS
8#include <asm/ptrace.h>
Jeff Dikeba9950c2005-05-20 13:59:07 -07009#include <asm/types.h>
Al Viro8d0b9dc2005-05-05 16:15:23 -070010
11#define DEFINE(sym, val) \
12 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
13
Al Viroecba97d2005-09-28 22:27:23 +010014#define DEFINE_LONGS(sym, val) \
15 asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
16
Al Viro8d0b9dc2005-05-05 16:15:23 -070017#define OFFSET(sym, str, mem) \
18 DEFINE(sym, offsetof(struct str, mem));
19
20void foo(void)
21{
Al Viroecba97d2005-09-28 22:27:23 +010022 OFFSET(HOST_SC_CR2, sigcontext, cr2);
23 OFFSET(HOST_SC_ERR, sigcontext, err);
24 OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
Al Viro8d0b9dc2005-05-05 16:15:23 -070025
Jeff Dikee2216fe2006-02-07 12:58:43 -080026 DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
Al Viroecba97d2005-09-28 22:27:23 +010027 DEFINE(HOST_XFP_SIZE, 0);
28 DEFINE_LONGS(HOST_RBX, RBX);
29 DEFINE_LONGS(HOST_RCX, RCX);
30 DEFINE_LONGS(HOST_RDI, RDI);
31 DEFINE_LONGS(HOST_RSI, RSI);
32 DEFINE_LONGS(HOST_RDX, RDX);
33 DEFINE_LONGS(HOST_RBP, RBP);
34 DEFINE_LONGS(HOST_RAX, RAX);
35 DEFINE_LONGS(HOST_R8, R8);
36 DEFINE_LONGS(HOST_R9, R9);
37 DEFINE_LONGS(HOST_R10, R10);
38 DEFINE_LONGS(HOST_R11, R11);
39 DEFINE_LONGS(HOST_R12, R12);
40 DEFINE_LONGS(HOST_R13, R13);
41 DEFINE_LONGS(HOST_R14, R14);
42 DEFINE_LONGS(HOST_R15, R15);
43 DEFINE_LONGS(HOST_ORIG_RAX, ORIG_RAX);
44 DEFINE_LONGS(HOST_CS, CS);
45 DEFINE_LONGS(HOST_SS, SS);
46 DEFINE_LONGS(HOST_EFLAGS, EFLAGS);
Al Viro8d0b9dc2005-05-05 16:15:23 -070047#if 0
Al Viroecba97d2005-09-28 22:27:23 +010048 DEFINE_LONGS(HOST_FS, FS);
49 DEFINE_LONGS(HOST_GS, GS);
50 DEFINE_LONGS(HOST_DS, DS);
51 DEFINE_LONGS(HOST_ES, ES);
Al Viro8d0b9dc2005-05-05 16:15:23 -070052#endif
53
Al Viroecba97d2005-09-28 22:27:23 +010054 DEFINE_LONGS(HOST_IP, RIP);
55 DEFINE_LONGS(HOST_SP, RSP);
56 DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
Jeff Dike63ae2a92006-03-27 01:14:30 -080057
58 /* XXX Duplicated between i386 and x86_64 */
59 DEFINE(UM_POLLIN, POLLIN);
60 DEFINE(UM_POLLPRI, POLLPRI);
61 DEFINE(UM_POLLOUT, POLLOUT);
Jeff Dike16dd07b2007-05-06 14:51:48 -070062
63 DEFINE(UM_PROT_READ, PROT_READ);
64 DEFINE(UM_PROT_WRITE, PROT_WRITE);
65 DEFINE(UM_PROT_EXEC, PROT_EXEC);
Al Viro8d0b9dc2005-05-05 16:15:23 -070066}