public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] newlib: convert INTERNAL_NEWLIB to _LIBC
@ 2022-03-01  1:21 Mike Frysinger
  2022-03-01 11:17 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Frysinger @ 2022-03-01  1:21 UTC (permalink / raw)
  To: newlib

Since we already set up _LIBC to indicate source files are building
for newlib, we don't need this malloc-specific symbol.  Convert it
over to simplify the build a bit.
---
 newlib/libc/stdlib/Makefile.am    | 26 ++++++++++++--------------
 newlib/libc/stdlib/Makefile.in    | 25 ++++++++++++-------------
 newlib/libc/stdlib/mallocr.c      | 22 +++++++++++-----------
 newlib/libc/stdlib/nano-mallocr.c |  6 +++---
 4 files changed, 38 insertions(+), 41 deletions(-)

diff --git a/newlib/libc/stdlib/Makefile.am b/newlib/libc/stdlib/Makefile.am
index 771ce7c7fe27..50e22d90c0e0 100644
--- a/newlib/libc/stdlib/Makefile.am
+++ b/newlib/libc/stdlib/Makefile.am
@@ -208,43 +208,41 @@ lib_a_CFLAGS = $(AM_CFLAGS)
 lib_a_DEPENDENCIES = $(LIBADD_OBJS) $(ELIX_OBJS)
 LIB_COMPILE = $(AM_V_CC)$(COMPILE)
 
-MALLOC_COMPILE = $(LIB_COMPILE) -DINTERNAL_NEWLIB
-
 $(lpfx)$(MALLOCR).o: $(MALLOCR).c
-	$(MALLOC_COMPILE) -DDEFINE_MALLOC -c $(srcdir)/$(MALLOCR).c -o $@
+	$(LIB_COMPILE) -DDEFINE_MALLOC -c $(srcdir)/$(MALLOCR).c -o $@
 
 $(lpfx)$(FREER).o: $(MALLOCR).c
-	$(MALLOC_COMPILE) -DDEFINE_FREE -c $(srcdir)/$(MALLOCR).c -o $@
+	$(LIB_COMPILE) -DDEFINE_FREE -c $(srcdir)/$(MALLOCR).c -o $@
 
 $(lpfx)$(REALLOCR).o: $(MALLOCR).c
-	$(MALLOC_COMPILE) -DDEFINE_REALLOC -c $(srcdir)/$(MALLOCR).c -o $@
+	$(LIB_COMPILE) -DDEFINE_REALLOC -c $(srcdir)/$(MALLOCR).c -o $@
 
 $(lpfx)$(CALLOCR).o: $(MALLOCR).c
-	$(MALLOC_COMPILE) -DDEFINE_CALLOC -c $(srcdir)/$(MALLOCR).c -o $@
+	$(LIB_COMPILE) -DDEFINE_CALLOC -c $(srcdir)/$(MALLOCR).c -o $@
 
 $(lpfx)$(CFREER).o: $(MALLOCR).c
-	$(MALLOC_COMPILE) -DDEFINE_CFREE -c $(srcdir)/$(MALLOCR).c -o $@
+	$(LIB_COMPILE) -DDEFINE_CFREE -c $(srcdir)/$(MALLOCR).c -o $@
 
 $(lpfx)$(MALIGNR).o: $(MALLOCR).c
-	$(MALLOC_COMPILE) -DDEFINE_MEMALIGN -c $(srcdir)/$(MALLOCR).c -o $@
+	$(LIB_COMPILE) -DDEFINE_MEMALIGN -c $(srcdir)/$(MALLOCR).c -o $@
 
 $(lpfx)$(VALLOCR).o: $(MALLOCR).c
-	$(MALLOC_COMPILE) -DDEFINE_VALLOC -c $(srcdir)/$(MALLOCR).c -o $@
+	$(LIB_COMPILE) -DDEFINE_VALLOC -c $(srcdir)/$(MALLOCR).c -o $@
 
 $(lpfx)$(PVALLOCR).o: $(MALLOCR).c
-	$(MALLOC_COMPILE) -DDEFINE_PVALLOC -c $(srcdir)/$(MALLOCR).c -o $@
+	$(LIB_COMPILE) -DDEFINE_PVALLOC -c $(srcdir)/$(MALLOCR).c -o $@
 
 $(lpfx)$(MALLINFOR).o: $(MALLOCR).c
-	$(MALLOC_COMPILE) -DDEFINE_MALLINFO -c $(srcdir)/$(MALLOCR).c -o $@
+	$(LIB_COMPILE) -DDEFINE_MALLINFO -c $(srcdir)/$(MALLOCR).c -o $@
 
 $(lpfx)$(MALLSTATSR).o: $(MALLOCR).c
-	$(MALLOC_COMPILE) -DDEFINE_MALLOC_STATS -c $(srcdir)/$(MALLOCR).c -o $@
+	$(LIB_COMPILE) -DDEFINE_MALLOC_STATS -c $(srcdir)/$(MALLOCR).c -o $@
 
 $(lpfx)$(MSIZER).o: $(MALLOCR).c
-	$(MALLOC_COMPILE) -DDEFINE_MALLOC_USABLE_SIZE -c $(srcdir)/$(MALLOCR).c -o $@
+	$(LIB_COMPILE) -DDEFINE_MALLOC_USABLE_SIZE -c $(srcdir)/$(MALLOCR).c -o $@
 
 $(lpfx)$(MALLOPTR).o: $(MALLOCR).c
-	$(MALLOC_COMPILE) -DDEFINE_MALLOPT -c $(srcdir)/$(MALLOCR).c -o $@
+	$(LIB_COMPILE) -DDEFINE_MALLOPT -c $(srcdir)/$(MALLOCR).c -o $@
 
 $(lpfx)dtoa.o: dtoa.c mprec.h
 $(lpfx)ldtoa.o: ldtoa.c mprec.h gdtoa.h
diff --git a/newlib/libc/stdlib/mallocr.c b/newlib/libc/stdlib/mallocr.c
index 13d014cc8e62..6167433c8e2c 100644
--- a/newlib/libc/stdlib/mallocr.c
+++ b/newlib/libc/stdlib/mallocr.c
@@ -209,7 +209,7 @@ int _dummy_mallocr = 1;
      (for example, internally, `malloc' is named `mALLOc') needed
      when compiling in this case. These look funny but don't otherwise
      affect anything.
-  INTERNAL_NEWLIB	    (default: NOT defined)
+  _LIBC                     (default: NOT defined)
      Defined only when compiled as part of the Cygnus newlib
      distribution.
   WIN32                     (default: undefined)
@@ -291,7 +291,7 @@ extern "C" {
 
  */
 
-#ifdef INTERNAL_NEWLIB
+#ifdef _LIBC
 
 #include <sys/config.h>
 
@@ -345,7 +345,7 @@ extern void __malloc_unlock();
 #define RCALL reent_ptr,
 #define RONECALL reent_ptr
 
-#else /* ! INTERNAL_NEWLIB */
+#else /* ! _LIBC */
 
 #define POINTER_UINT unsigned long
 #define RARG
@@ -355,7 +355,7 @@ extern void __malloc_unlock();
 #define RCALL
 #define RONECALL
 
-#endif /* ! INTERNAL_NEWLIB */
+#endif /* ! _LIBC */
 
 /*
     Debugging:
@@ -953,7 +953,7 @@ Void_t *(*__morecore)() = __default_morecore_init;
 
 #else /* INTERNAL_LINUX_C_LIB */
 
-#ifndef INTERNAL_NEWLIB
+#ifndef _LIBC
 #if __STD_C
 extern Void_t*     sbrk(ptrdiff_t);
 #else
@@ -1000,7 +1000,7 @@ extern Void_t*     sbrk();
 
 #else
 
-#ifdef INTERNAL_NEWLIB
+#ifdef _LIBC
 
 #define cALLOc		_calloc_r
 #define fREe		_free_r
@@ -1026,7 +1026,7 @@ extern Void_t*     sbrk();
 #define malloc_top_pad			__malloc_top_pad
 #define malloc_trim_threshold		__malloc_trim_threshold
 
-#else /* ! INTERNAL_NEWLIB */
+#else /* ! _LIBC */
 
 #define cALLOc		calloc
 #define fREe		free
@@ -1038,7 +1038,7 @@ extern Void_t*     sbrk();
 #define mALLINFo	mallinfo
 #define mALLOPt		mallopt
 
-#endif /* ! INTERNAL_NEWLIB */
+#endif /* ! _LIBC */
 #endif
 
 /* Public routines */
@@ -3274,14 +3274,14 @@ Void_t* cALLOc(RARG n, elem_size) RDECL size_t n; size_t elem_size;
 */
 
 #if !defined(INTERNAL_LINUX_C_LIB) || !defined(__ELF__)
-#if !defined(INTERNAL_NEWLIB) || !defined(_REENT_ONLY)
+#if !defined(_LIBC) || !defined(_REENT_ONLY)
 #if __STD_C
 void cfree(Void_t *mem)
 #else
 void cfree(mem) Void_t *mem;
 #endif
 {
-#ifdef INTERNAL_NEWLIB
+#ifdef _LIBC
   fREe(_REENT, mem);
 #else
   fREe(mem);
@@ -3522,7 +3522,7 @@ void malloc_stats(RONEARG) RDECL
 #endif
   MALLOC_UNLOCK;
 
-#ifdef INTERNAL_NEWLIB
+#ifdef _LIBC
   _REENT_SMALL_CHECK_INIT(reent_ptr);
   fp = _stderr_r(reent_ptr);
 #define fprintf fiprintf
diff --git a/newlib/libc/stdlib/nano-mallocr.c b/newlib/libc/stdlib/nano-mallocr.c
index 0c5fb2885278..7ba1c0abc865 100644
--- a/newlib/libc/stdlib/nano-mallocr.c
+++ b/newlib/libc/stdlib/nano-mallocr.c
@@ -50,7 +50,7 @@
 
 #define _SBRK_R(X) _sbrk_r(X)
 
-#ifdef INTERNAL_NEWLIB
+#ifdef _LIBC
 
 #include <sys/config.h>
 #include <reent.h>
@@ -78,7 +78,7 @@
 #define nano_mallinfo		_mallinfo_r
 #define nano_mallopt		_mallopt_r
 
-#else /* ! INTERNAL_NEWLIB */
+#else /* ! _LIBC */
 
 #define RARG
 #define RONEARG
@@ -100,7 +100,7 @@
 #define nano_malloc_stats	malloc_stats
 #define nano_mallinfo		mallinfo
 #define nano_mallopt		mallopt
-#endif /* ! INTERNAL_NEWLIB */
+#endif /* ! _LIBC */
 
 /* Redefine names to avoid conflict with user names */
 #define free_list __malloc_free_list
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] newlib: convert INTERNAL_NEWLIB to _LIBC
  2022-03-01  1:21 [PATCH] newlib: convert INTERNAL_NEWLIB to _LIBC Mike Frysinger
@ 2022-03-01 11:17 ` Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2022-03-01 11:17 UTC (permalink / raw)
  To: newlib

On Feb 28 20:21, Mike Frysinger wrote:
> Since we already set up _LIBC to indicate source files are building
> for newlib, we don't need this malloc-specific symbol.  Convert it
> over to simplify the build a bit.
> ---
>  newlib/libc/stdlib/Makefile.am    | 26 ++++++++++++--------------
>  newlib/libc/stdlib/Makefile.in    | 25 ++++++++++++-------------
>  newlib/libc/stdlib/mallocr.c      | 22 +++++++++++-----------
>  newlib/libc/stdlib/nano-mallocr.c |  6 +++---
>  4 files changed, 38 insertions(+), 41 deletions(-)

LGTM.

Thx,
Corinna


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-01 11:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01  1:21 [PATCH] newlib: convert INTERNAL_NEWLIB to _LIBC Mike Frysinger
2022-03-01 11:17 ` Corinna Vinschen

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).