Skip to content

Commit efbe87f

Browse files
committed
bits: namespace REG_* macros to avoid colliding with sys/ucontext.h
The public bits.h on x86 and x86_64 unconditionally defined REG_R8 (and friends) as macros. Including <sys/ucontext.h> alongside <libucontext/libucontext.h> then breaks because glibc declares the same names as enum members, which the preprocessor rewrites into invalid syntax. Rename the public macros to LIBUCONTEXT_REG_* so libucontext stops shadowing libc symbols.
1 parent 2bf9ccb commit efbe87f

2 files changed

Lines changed: 36 additions & 37 deletions

File tree

  • arch
    • x86_64/include/libucontext
    • x86/include/libucontext

arch/x86/include/libucontext/bits.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
#ifndef LIBUCONTEXT_BITS_H
22
#define LIBUCONTEXT_BITS_H
33

4-
#define REG_GS (0)
5-
#define REG_FS (1)
6-
#define REG_ES (2)
7-
#define REG_DS (3)
8-
#define REG_EDI (4)
9-
#define REG_ESI (5)
10-
#define REG_EBP (6)
11-
#define REG_ESP (7)
12-
#define REG_EBX (8)
13-
#define REG_EDX (9)
14-
#define REG_ECX (10)
15-
#define REG_EAX (11)
16-
#define REG_EIP (14)
4+
#define LIBUCONTEXT_REG_GS (0)
5+
#define LIBUCONTEXT_REG_FS (1)
6+
#define LIBUCONTEXT_REG_ES (2)
7+
#define LIBUCONTEXT_REG_DS (3)
8+
#define LIBUCONTEXT_REG_EDI (4)
9+
#define LIBUCONTEXT_REG_ESI (5)
10+
#define LIBUCONTEXT_REG_EBP (6)
11+
#define LIBUCONTEXT_REG_ESP (7)
12+
#define LIBUCONTEXT_REG_EBX (8)
13+
#define LIBUCONTEXT_REG_EDX (9)
14+
#define LIBUCONTEXT_REG_ECX (10)
15+
#define LIBUCONTEXT_REG_EAX (11)
16+
#define LIBUCONTEXT_REG_EIP (14)
1717

1818
typedef int libucontext_greg_t, libucontext_gregset_t[19];
1919

@@ -47,4 +47,3 @@ typedef struct libucontext_ucontext {
4747
} libucontext_ucontext_t;
4848

4949
#endif
50-

arch/x86_64/include/libucontext/bits.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@
33
#ifndef LIBUCONTEXT_BITS_H
44
#define LIBUCONTEXT_BITS_H
55

6-
#define REG_R8 (0)
7-
#define REG_R9 (1)
8-
#define REG_R10 (2)
9-
#define REG_R11 (3)
10-
#define REG_R12 (4)
11-
#define REG_R13 (5)
12-
#define REG_R14 (6)
13-
#define REG_R15 (7)
14-
#define REG_RDI (8)
15-
#define REG_RSI (9)
16-
#define REG_RBP (10)
17-
#define REG_RBX (11)
18-
#define REG_RDX (12)
19-
#define REG_RAX (13)
20-
#define REG_RCX (14)
21-
#define REG_RSP (15)
22-
#define REG_RIP (16)
23-
#define REG_EFL (17)
24-
#define REG_CSGSFS (18)
25-
#define REG_ERR (19)
26-
#define REG_TRAPNO (20)
27-
#define REG_OLDMASK (21)
28-
#define REG_CR2 (22)
6+
#define LIBUCONTEXT_REG_R8 (0)
7+
#define LIBUCONTEXT_REG_R9 (1)
8+
#define LIBUCONTEXT_REG_R10 (2)
9+
#define LIBUCONTEXT_REG_R11 (3)
10+
#define LIBUCONTEXT_REG_R12 (4)
11+
#define LIBUCONTEXT_REG_R13 (5)
12+
#define LIBUCONTEXT_REG_R14 (6)
13+
#define LIBUCONTEXT_REG_R15 (7)
14+
#define LIBUCONTEXT_REG_RDI (8)
15+
#define LIBUCONTEXT_REG_RSI (9)
16+
#define LIBUCONTEXT_REG_RBP (10)
17+
#define LIBUCONTEXT_REG_RBX (11)
18+
#define LIBUCONTEXT_REG_RDX (12)
19+
#define LIBUCONTEXT_REG_RAX (13)
20+
#define LIBUCONTEXT_REG_RCX (14)
21+
#define LIBUCONTEXT_REG_RSP (15)
22+
#define LIBUCONTEXT_REG_RIP (16)
23+
#define LIBUCONTEXT_REG_EFL (17)
24+
#define LIBUCONTEXT_REG_CSGSFS (18)
25+
#define LIBUCONTEXT_REG_ERR (19)
26+
#define LIBUCONTEXT_REG_TRAPNO (20)
27+
#define LIBUCONTEXT_REG_OLDMASK (21)
28+
#define LIBUCONTEXT_REG_CR2 (22)
2929

3030
typedef long long libucontext_greg_t, libucontext_gregset_t[23];
3131

0 commit comments

Comments
 (0)