summaryrefslogtreecommitdiff
path: root/libc/misc/internals
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-05-17 15:56:19 +0200
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2010-05-17 16:00:15 +0200
commit2e53dd645d5348f207cec7f8595969dc566c5a55 (patch)
treed30dd0248604e25aa2f155e8d6693f2491f9dd70 /libc/misc/internals
parentff5e74a838c53fa350df2bb5f173fbed814db84c (diff)
workaround GCC PR32219
we ended up calling 0 Fixes bug #1033 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc/misc/internals')
-rw-r--r--libc/misc/internals/__uClibc_main.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index f9e12446b..4ee44439f 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -105,6 +105,17 @@ _pthread_cleanup_pop_restore(struct _pthread_cleanup_buffer *__buffer,
#endif /* !SHARED */
+/* Defeat compiler optimization which assumes function addresses are never NULL */
+static __always_inline int not_null_ptr(const void *p)
+{
+ const void *q;
+ asm (""
+ : "=r" (q) /* output */
+ : "0" (p) /* input */
+ );
+ return q != 0;
+}
+
/*
* Prototypes.
*/
@@ -254,7 +265,7 @@ void __uClibc_init(void)
#ifdef __UCLIBC_HAS_LOCALE__
/* Initialize the global locale structure. */
- if (likely(_locale_init!=NULL))
+ if (likely(not_null_ptr(_locale_init)))
_locale_init();
#endif
@@ -264,7 +275,7 @@ void __uClibc_init(void)
* Thus we get a nice size savings because the stdio functions
* won't be pulled into the final static binary unless used.
*/
- if (likely(_stdio_init != NULL))
+ if (likely(not_null_ptr(_stdio_init)))
_stdio_init();
}