public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: newlib@sourceware.org
Subject: [PATCH 1/8] newlib: internalize HAVE_INITFINI_ARRAY
Date: Mon, 17 Jan 2022 23:47:34 -0500	[thread overview]
Message-ID: <20220118044741.21027-2-vapier@gentoo.org> (raw)
In-Reply-To: <20220118044741.21027-1-vapier@gentoo.org>

This define is only used by newlib internally, so stop exporting it
as HAVE_INITFINI_ARRAY since this can conflict with defines packages
use themselves.

We don't really need to add _ to HAVE_INIT_FINI too since it isn't
exported in newlib.h, but might as well be consistent here.

We can't (easily) add this to newlib_cflags like HAVE_INIT_FINI is
because this is based on a compile-time test in the top configure,
not on plain shell code in configure.host.  We'd have to replicate
the test in every subdir in order to have it passed down.
---
 newlib/configure                   | 2 +-
 newlib/configure.ac                | 2 +-
 newlib/configure.host              | 2 +-
 newlib/libc/misc/fini.c            | 6 +++---
 newlib/libc/misc/init.c            | 6 +++---
 newlib/libc/stdlib/__call_atexit.c | 2 +-
 newlib/libc/sys/arm/crt0.S         | 2 +-
 newlib/newlib.hin                  | 2 +-
 8 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/newlib/configure.ac b/newlib/configure.ac
index 6d89c3a328fe..4dbed8e029ac 100644
--- a/newlib/configure.ac
+++ b/newlib/configure.ac
@@ -650,7 +650,7 @@ fi
 rm -f conftest*])
 AC_SUBST(libc_cv_initfinit_array)
 if test $libc_cv_initfinit_array = yes; then
-  AC_DEFINE_UNQUOTED(HAVE_INITFINI_ARRAY)
+  AC_DEFINE_UNQUOTED(_HAVE_INITFINI_ARRAY)
 fi
 
 AC_CACHE_CHECK(if $CC accepts -fno-tree-loop-distribute-patterns with \
diff --git a/newlib/configure.host b/newlib/configure.host
index c429dde1c3d1..ca6b46f03e09 100644
--- a/newlib/configure.host
+++ b/newlib/configure.host
@@ -992,7 +992,7 @@ fi
 
 # Have init/finit if not explicitly specified otherwise
 if [ "x${have_init_fini}" != "xno" ]; then
-	newlib_cflags="${newlib_cflags} -DHAVE_INIT_FINI"
+	newlib_cflags="${newlib_cflags} -D_HAVE_INIT_FINI"
 fi
 
 if test -z "${have_crt0}" && test -n "${sys_dir}"; then
diff --git a/newlib/libc/misc/fini.c b/newlib/libc/misc/fini.c
index 56eed6cb3b7f..5f2016070615 100644
--- a/newlib/libc/misc/fini.c
+++ b/newlib/libc/misc/fini.c
@@ -13,11 +13,11 @@
 /* Handle ELF .{pre_init,init,fini}_array sections.  */
 #include <sys/types.h>
 
-#ifdef HAVE_INITFINI_ARRAY
+#ifdef _HAVE_INITFINI_ARRAY
 extern void (*__fini_array_start []) (void) __attribute__((weak));
 extern void (*__fini_array_end []) (void) __attribute__((weak));
 
-#ifdef HAVE_INIT_FINI
+#ifdef _HAVE_INIT_FINI
 extern void _fini (void);
 #endif
 
@@ -32,7 +32,7 @@ __libc_fini_array (void)
   for (i = count; i > 0; i--)
     __fini_array_start[i-1] ();
 
-#ifdef HAVE_INIT_FINI
+#ifdef _HAVE_INIT_FINI
   _fini ();
 #endif
 }
diff --git a/newlib/libc/misc/init.c b/newlib/libc/misc/init.c
index 95f1a742292a..3aef7ad069da 100644
--- a/newlib/libc/misc/init.c
+++ b/newlib/libc/misc/init.c
@@ -13,7 +13,7 @@
 /* Handle ELF .{pre_init,init,fini}_array sections.  */
 #include <sys/types.h>
 
-#ifdef HAVE_INITFINI_ARRAY
+#ifdef _HAVE_INITFINI_ARRAY
 
 /* These magic symbols are provided by the linker.  */
 extern void (*__preinit_array_start []) (void) __attribute__((weak));
@@ -21,7 +21,7 @@ extern void (*__preinit_array_end []) (void) __attribute__((weak));
 extern void (*__init_array_start []) (void) __attribute__((weak));
 extern void (*__init_array_end []) (void) __attribute__((weak));
 
-#ifdef HAVE_INIT_FINI
+#ifdef _HAVE_INIT_FINI
 extern void _init (void);
 #endif
 
@@ -36,7 +36,7 @@ __libc_init_array (void)
   for (i = 0; i < count; i++)
     __preinit_array_start[i] ();
 
-#ifdef HAVE_INIT_FINI
+#ifdef _HAVE_INIT_FINI
   _init ();
 #endif
 
diff --git a/newlib/libc/stdlib/__call_atexit.c b/newlib/libc/stdlib/__call_atexit.c
index 3eec11214c1f..c29a03c8eee1 100644
--- a/newlib/libc/stdlib/__call_atexit.c
+++ b/newlib/libc/stdlib/__call_atexit.c
@@ -49,7 +49,7 @@ static void
 register_fini(void)
 {
   if (&__libc_fini) {
-#ifdef HAVE_INITFINI_ARRAY
+#ifdef _HAVE_INITFINI_ARRAY
     extern void __libc_fini_array (void);
     atexit (__libc_fini_array);
 #else
diff --git a/newlib/libc/sys/arm/crt0.S b/newlib/libc/sys/arm/crt0.S
index 5e677a23cfe2..6b01d8a88b77 100644
--- a/newlib/libc/sys/arm/crt0.S
+++ b/newlib/libc/sys/arm/crt0.S
@@ -12,7 +12,7 @@
 #error __USER_LABEL_PREFIX is not defined
 #endif
 
-#ifdef HAVE_INITFINI_ARRAY
+#ifdef _HAVE_INITFINI_ARRAY
 #define _init	__libc_init_array
 #define _fini	__libc_fini_array
 #endif
diff --git a/newlib/newlib.hin b/newlib/newlib.hin
index a0999512cc4f..37ed88e9784c 100644
--- a/newlib/newlib.hin
+++ b/newlib/newlib.hin
@@ -49,7 +49,7 @@
 
 /* Define if the linker supports .preinit_array/.init_array/.fini_array
  * sections.  */
-#undef  HAVE_INITFINI_ARRAY
+#undef _HAVE_INITFINI_ARRAY
 
 /* True if atexit() may dynamically allocate space for cleanup
    functions.  */
-- 
2.33.0


  reply	other threads:[~2022-01-18  4:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18  4:47 [PATCH 0/8] newlib: convert newlib.h to autoheader Mike Frysinger
2022-01-18  4:47 ` Mike Frysinger [this message]
     [not found]   ` <DM3P110MB0522248DFEE102BB37B43A8F9A589@DM3P110MB0522.NAMP110.PROD.OUTLOOK.COM>
2022-01-18 16:10     ` Fw: [PATCH 1/8] newlib: internalize HAVE_INITFINI_ARRAY C Howland
2022-01-19  0:53       ` Mike Frysinger
2022-01-19  2:39         ` C Howland
2022-01-19  3:44           ` Mike Frysinger
2022-01-19 23:50           ` Mike Frysinger
2022-01-18  4:47 ` [PATCH 2/8] newlib: merge acconfig.h changes into newlib.hin Mike Frysinger
2022-01-18  4:47 ` [PATCH 3/8] newlib: clean up autoheader templates Mike Frysinger
2022-01-18  4:47 ` [PATCH 4/8] newlib: sort newlib.h output Mike Frysinger
2022-01-18  4:47 ` [PATCH 5/8] newlib: move version defines out of the config headers Mike Frysinger
2022-01-18  4:47 ` [PATCH 6/8] newlib: add missing _NANO_MALLOC to newlib.hin Mike Frysinger
2022-01-18  4:47 ` [PATCH 7/8] newlib: iconv: autogenerate iconv define list Mike Frysinger
2022-01-18  4:47 ` [PATCH 8/8] newlib: switch newlib.h to autoheader Mike Frysinger
2022-01-19 14:51 ` [PATCH 0/8] newlib: convert " Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220118044741.21027-2-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).