diff options
author | Ron Yorston <rmy@pobox.com> | 2020-01-08 12:30:49 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2020-01-08 12:30:49 +0000 |
commit | a9271a8e97e6e7be5285330d5f19352decabf807 (patch) | |
tree | bf3c4464c369a15a46454792dac167505f74769f /include | |
parent | b0b7ab792bc1f45963f4b84b94faaf05054e1613 (diff) | |
parent | 9ec836c033fc6e55e80f3309b3e05acdf09bb297 (diff) | |
download | busybox-w32-a9271a8e97e6e7be5285330d5f19352decabf807.tar.gz busybox-w32-a9271a8e97e6e7be5285330d5f19352decabf807.tar.bz2 busybox-w32-a9271a8e97e6e7be5285330d5f19352decabf807.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'include')
-rw-r--r-- | include/libbb.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/include/libbb.h b/include/libbb.h index 84811c4f2..0aa44eb37 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -2218,12 +2218,32 @@ struct globals; | |||
2218 | * Magic prevents ptr_to_globals from going into rodata. | 2218 | * Magic prevents ptr_to_globals from going into rodata. |
2219 | * If you want to assign a value, use SET_PTR_TO_GLOBALS(x) */ | 2219 | * If you want to assign a value, use SET_PTR_TO_GLOBALS(x) */ |
2220 | extern struct globals *const ptr_to_globals; | 2220 | extern struct globals *const ptr_to_globals; |
2221 | |||
2222 | #if defined(__clang_major__) && __clang_major__ >= 9 | ||
2223 | /* Clang/llvm drops assignment to "constant" storage. Silently. | ||
2224 | * Needs serious convincing to not eliminate the store. | ||
2225 | */ | ||
2226 | static ALWAYS_INLINE void* not_const_pp(const void *p) | ||
2227 | { | ||
2228 | void *pp; | ||
2229 | __asm__ __volatile__( | ||
2230 | "# forget that p points to const" | ||
2231 | : /*outputs*/ "=r" (pp) | ||
2232 | : /*inputs*/ "0" (p) | ||
2233 | ); | ||
2234 | return pp; | ||
2235 | } | ||
2236 | #else | ||
2237 | static ALWAYS_INLINE void* not_const_pp(const void *p) { return (void*)p; } | ||
2238 | #endif | ||
2239 | |||
2221 | /* At least gcc 3.4.6 on mipsel system needs optimization barrier */ | 2240 | /* At least gcc 3.4.6 on mipsel system needs optimization barrier */ |
2222 | #define barrier() __asm__ __volatile__("":::"memory") | 2241 | #define barrier() __asm__ __volatile__("":::"memory") |
2223 | #define SET_PTR_TO_GLOBALS(x) do { \ | 2242 | #define SET_PTR_TO_GLOBALS(x) do { \ |
2224 | (*(struct globals**)&ptr_to_globals) = (void*)(x); \ | 2243 | (*(struct globals**)not_const_pp(&ptr_to_globals)) = (void*)(x); \ |
2225 | barrier(); \ | 2244 | barrier(); \ |
2226 | } while (0) | 2245 | } while (0) |
2246 | |||
2227 | #define FREE_PTR_TO_GLOBALS() do { \ | 2247 | #define FREE_PTR_TO_GLOBALS() do { \ |
2228 | if (ENABLE_FEATURE_CLEAN_UP) { \ | 2248 | if (ENABLE_FEATURE_CLEAN_UP) { \ |
2229 | free(ptr_to_globals); \ | 2249 | free(ptr_to_globals); \ |