aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-01-03 14:29:11 +0000
committerRon Yorston <rmy@pobox.com>2024-01-03 14:29:11 +0000
commit306601c86fa1cc6c210b7f18d597b8c0821ab19a (patch)
tree94177968ffcce05238e97847a5f4ae6481a73fb6 /include
parentcca8c8e806db11810e25c8fa9446e86431aa2a53 (diff)
downloadbusybox-w32-306601c86fa1cc6c210b7f18d597b8c0821ab19a.tar.gz
busybox-w32-306601c86fa1cc6c210b7f18d597b8c0821ab19a.tar.bz2
busybox-w32-306601c86fa1cc6c210b7f18d597b8c0821ab19a.zip
win32: make the clang build less crashy
busybox-w32 binaries built using clang crashed so frequently that they were pretty much unusable. The main issue seems to be with assignments to the structures containing global variables which are used in most applets. Upstream commit 5156b2455 (Make const ptr assign as function call in clang) addresses this, but is insufficient for the build on Windows. Extend the idea to the ASSIGN_CONST_PTR() macro too. Costs 32-80 bytes in the gcc build.
Diffstat (limited to 'include')
-rw-r--r--include/libbb.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/libbb.h b/include/libbb.h
index a7b19b1c9..a469bfe03 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -2439,10 +2439,15 @@ static ALWAYS_INLINE void* not_const_pp(const void *p)
2439 ); 2439 );
2440 return pp; 2440 return pp;
2441} 2441}
2442# if !ENABLE_PLATFORM_MINGW32
2442# define ASSIGN_CONST_PTR(pptr, v) do { \ 2443# define ASSIGN_CONST_PTR(pptr, v) do { \
2443 *(void**)not_const_pp(pptr) = (void*)(v); \ 2444 *(void**)not_const_pp(pptr) = (void*)(v); \
2444 barrier(); \ 2445 barrier(); \
2445} while (0) 2446} while (0)
2447#else
2448/* On Windows it seems necessary for this to be a function too. */
2449void ASSIGN_CONST_PTR(const void *pptr, const void *ptr) FAST_FUNC;
2450#endif
2446/* XZALLOC_CONST_PTR() is an out-of-line function to prevent 2451/* XZALLOC_CONST_PTR() is an out-of-line function to prevent
2447 * clang from reading pointer before it is assigned. 2452 * clang from reading pointer before it is assigned.
2448 */ 2453 */