OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.3 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../uclibc/uClibc-0.9.31-workaround-GCC-PR32219.patch
  5. # Copyright (C) 2010 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. From 2e53dd645d5348f207cec7f8595969dc566c5a55 Mon Sep 17 00:00:00 2001
  17. From: Denys Vlasenko <vda.linux@googlemail.com>
  18. Date: Mon, 17 May 2010 15:56:19 +0200
  19. Subject: [PATCH] workaround GCC PR32219
  20. we ended up calling 0
  21. Fixes bug #1033
  22. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
  23. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
  24. ---
  25. libc/misc/internals/__uClibc_main.c | 15 +++++++++++++--
  26. 1 files changed, 13 insertions(+), 2 deletions(-)
  27. diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
  28. index f9e1244..4ee4443 100644
  29. --- a/libc/misc/internals/__uClibc_main.c
  30. +++ b/libc/misc/internals/__uClibc_main.c
  31. @@ -105,6 +105,17 @@ _pthread_cleanup_pop_restore(struct _pthread_cleanup_buffer *__buffer,
  32. #endif /* !SHARED */
  33. +/* Defeat compiler optimization which assumes function addresses are never NULL */
  34. +static __always_inline int not_null_ptr(const void *p)
  35. +{
  36. + const void *q;
  37. + __asm__ (""
  38. + : "=r" (q) /* output */
  39. + : "0" (p) /* input */
  40. + );
  41. + return q != 0;
  42. +}
  43. +
  44. /*
  45. * Prototypes.
  46. */
  47. @@ -254,7 +265,7 @@ void __uClibc_init(void)
  48. #ifdef __UCLIBC_HAS_LOCALE__
  49. /* Initialize the global locale structure. */
  50. - if (likely(_locale_init!=NULL))
  51. + if (likely(not_null_ptr(_locale_init)))
  52. _locale_init();
  53. #endif
  54. @@ -264,7 +275,7 @@ void __uClibc_init(void)
  55. * Thus we get a nice size savings because the stdio functions
  56. * won't be pulled into the final static binary unless used.
  57. */
  58. - if (likely(_stdio_init != NULL))
  59. + if (likely(not_null_ptr(_stdio_init)))
  60. _stdio_init();
  61. }
  62. --
  63. 1.7.1