Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions arch/x86/include/libucontext/bits.h
Original file line number Diff line number Diff line change
@@ -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];

Expand Down Expand Up @@ -47,4 +47,3 @@ typedef struct libucontext_ucontext {
} libucontext_ucontext_t;

#endif

46 changes: 23 additions & 23 deletions arch/x86_64/include/libucontext/bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
10 changes: 10 additions & 0 deletions test_libucontext.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
#include <string.h>
#include <libucontext/libucontext.h>

/* Verify libucontext's public headers do not shadow libc's REG_* enum
* members from <sys/ucontext.h>. 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(<sys/ucontext.h>)
# include <sys/ucontext.h>
# endif
#endif

#define handle_error(msg) \
do { perror(msg); exit(EXIT_FAILURE); } while (0)

Expand Down
Loading