diff options
author | Rich Felker <dalias@aerifal.cx> | 2017-01-04 17:08:19 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2017-01-04 17:08:19 -0500 |
commit | 150747b41e1ecefe82aa45d68c84b9e957b03e29 (patch) | |
tree | 90ac2d2b54a61343c926b02d1bce8f5ca84d2c3e /arch/i386/bits/signal.h | |
parent | 769f53598e781ffc89191520f3f8a93cb58db91f (diff) | |
download | musl-150747b41e1ecefe82aa45d68c84b9e957b03e29.tar.gz musl-150747b41e1ecefe82aa45d68c84b9e957b03e29.tar.bz2 musl-150747b41e1ecefe82aa45d68c84b9e957b03e29.tar.xz musl-150747b41e1ecefe82aa45d68c84b9e957b03e29.zip |
reduce impact of REG_* namespace pollution in x86[_64] signal.h
when _GNU_SOURCE is defined, which is always the case when compiling
c++ with gcc, these macros for the the indices in gregset_t are
exposed and likely to clash with applications. by using enum constants
rather than macros defined with integer literals, we can make the
clash slightly less likely to break software. the macros are still
defined in case anything checks for them with #ifdef, but they're
defined to expand to themselves so that non-file-scope (e.g.
namespaced) identifiers by the same names still work.
for the sake of avoiding mistakes, the changes were generated with sed
via the command:
sed -i -e 's/#define *\(REG_[A-Z_0-9]\{1,\}\) *\([0-9]\{1,\}\)'\
'/enum { \1 = \2 };\n#define \1 \1/' \
arch/i386/bits/signal.h arch/x86_64/bits/signal.h arch/x32/bits/signal.h
Diffstat (limited to 'arch/i386/bits/signal.h')
-rw-r--r-- | arch/i386/bits/signal.h | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/arch/i386/bits/signal.h b/arch/i386/bits/signal.h index 1f9085a5..9931ee93 100644 --- a/arch/i386/bits/signal.h +++ b/arch/i386/bits/signal.h @@ -7,25 +7,44 @@ #endif #ifdef _GNU_SOURCE -#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_TRAPNO 12 -#define REG_ERR 13 -#define REG_EIP 14 -#define REG_CS 15 -#define REG_EFL 16 -#define REG_UESP 17 -#define REG_SS 18 +enum { REG_GS = 0 }; +#define REG_GS REG_GS +enum { REG_FS = 1 }; +#define REG_FS REG_FS +enum { REG_ES = 2 }; +#define REG_ES REG_ES +enum { REG_DS = 3 }; +#define REG_DS REG_DS +enum { REG_EDI = 4 }; +#define REG_EDI REG_EDI +enum { REG_ESI = 5 }; +#define REG_ESI REG_ESI +enum { REG_EBP = 6 }; +#define REG_EBP REG_EBP +enum { REG_ESP = 7 }; +#define REG_ESP REG_ESP +enum { REG_EBX = 8 }; +#define REG_EBX REG_EBX +enum { REG_EDX = 9 }; +#define REG_EDX REG_EDX +enum { REG_ECX = 10 }; +#define REG_ECX REG_ECX +enum { REG_EAX = 11 }; +#define REG_EAX REG_EAX +enum { REG_TRAPNO = 12 }; +#define REG_TRAPNO REG_TRAPNO +enum { REG_ERR = 13 }; +#define REG_ERR REG_ERR +enum { REG_EIP = 14 }; +#define REG_EIP REG_EIP +enum { REG_CS = 15 }; +#define REG_CS REG_CS +enum { REG_EFL = 16 }; +#define REG_EFL REG_EFL +enum { REG_UESP = 17 }; +#define REG_UESP REG_UESP +enum { REG_SS = 18 }; +#define REG_SS REG_SS #endif #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |