diff --git a/arch/x86/include/libucontext/bits.h b/arch/x86/include/libucontext/bits.h index 9fd1bf0..07a9c59 100644 --- a/arch/x86/include/libucontext/bits.h +++ b/arch/x86/include/libucontext/bits.h @@ -1,19 +1,19 @@ #ifndef LIBUCONTEXT_BITS_H #define LIBUCONTEXT_BITS_H -#define REG_GS (0) -#define REG_FS (1) -#define REG_ES (2) -#define REG_DS (3) -#define REG_EDI (4) -#define REG_ESI (5) -#define REG_EBP (6) -#define REG_ESP (7) -#define REG_EBX (8) -#define REG_EDX (9) -#define REG_ECX (10) -#define REG_EAX (11) -#define REG_EIP (14) +#define LIBUCONTEXT_REG_GS (0) +#define LIBUCONTEXT_REG_FS (1) +#define LIBUCONTEXT_REG_ES (2) +#define LIBUCONTEXT_REG_DS (3) +#define LIBUCONTEXT_REG_EDI (4) +#define LIBUCONTEXT_REG_ESI (5) +#define LIBUCONTEXT_REG_EBP (6) +#define LIBUCONTEXT_REG_ESP (7) +#define LIBUCONTEXT_REG_EBX (8) +#define LIBUCONTEXT_REG_EDX (9) +#define LIBUCONTEXT_REG_ECX (10) +#define LIBUCONTEXT_REG_EAX (11) +#define LIBUCONTEXT_REG_EIP (14) typedef int libucontext_greg_t, libucontext_gregset_t[19]; @@ -47,4 +47,3 @@ typedef struct libucontext_ucontext { } libucontext_ucontext_t; #endif - diff --git a/arch/x86_64/include/libucontext/bits.h b/arch/x86_64/include/libucontext/bits.h index 87de408..b8f1deb 100644 --- a/arch/x86_64/include/libucontext/bits.h +++ b/arch/x86_64/include/libucontext/bits.h @@ -3,29 +3,29 @@ #ifndef LIBUCONTEXT_BITS_H #define LIBUCONTEXT_BITS_H -#define REG_R8 (0) -#define REG_R9 (1) -#define REG_R10 (2) -#define REG_R11 (3) -#define REG_R12 (4) -#define REG_R13 (5) -#define REG_R14 (6) -#define REG_R15 (7) -#define REG_RDI (8) -#define REG_RSI (9) -#define REG_RBP (10) -#define REG_RBX (11) -#define REG_RDX (12) -#define REG_RAX (13) -#define REG_RCX (14) -#define REG_RSP (15) -#define REG_RIP (16) -#define REG_EFL (17) -#define REG_CSGSFS (18) -#define REG_ERR (19) -#define REG_TRAPNO (20) -#define REG_OLDMASK (21) -#define REG_CR2 (22) +#define LIBUCONTEXT_REG_R8 (0) +#define LIBUCONTEXT_REG_R9 (1) +#define LIBUCONTEXT_REG_R10 (2) +#define LIBUCONTEXT_REG_R11 (3) +#define LIBUCONTEXT_REG_R12 (4) +#define LIBUCONTEXT_REG_R13 (5) +#define LIBUCONTEXT_REG_R14 (6) +#define LIBUCONTEXT_REG_R15 (7) +#define LIBUCONTEXT_REG_RDI (8) +#define LIBUCONTEXT_REG_RSI (9) +#define LIBUCONTEXT_REG_RBP (10) +#define LIBUCONTEXT_REG_RBX (11) +#define LIBUCONTEXT_REG_RDX (12) +#define LIBUCONTEXT_REG_RAX (13) +#define LIBUCONTEXT_REG_RCX (14) +#define LIBUCONTEXT_REG_RSP (15) +#define LIBUCONTEXT_REG_RIP (16) +#define LIBUCONTEXT_REG_EFL (17) +#define LIBUCONTEXT_REG_CSGSFS (18) +#define LIBUCONTEXT_REG_ERR (19) +#define LIBUCONTEXT_REG_TRAPNO (20) +#define LIBUCONTEXT_REG_OLDMASK (21) +#define LIBUCONTEXT_REG_CR2 (22) typedef long long libucontext_greg_t, libucontext_gregset_t[23]; diff --git a/test_libucontext.c b/test_libucontext.c index 3e40f3a..33bad1a 100644 --- a/test_libucontext.c +++ b/test_libucontext.c @@ -9,6 +9,16 @@ #include #include +/* Verify libucontext's public headers do not shadow libc's REG_* enum + * members from . Including it after libucontext.h is + * the order that used to produce a hard syntax error on x86/x86_64 in + * freestanding mode. */ +#if defined(__has_include) +# if __has_include() +# include +# endif +#endif + #define handle_error(msg) \ do { perror(msg); exit(EXIT_FAILURE); } while (0)