NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/42180: Makefile of libbsdmalloc overwrites CPPFLAGS



>Number:         42180
>Category:       lib
>Synopsis:       Makefile of libbsdmalloc overwrites CPPFLAGS
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 14 07:35:00 +0000 2009
>Originator:     Hiroki Suenaga
>Release:        4.0 and Current(Oct. 14, 2009)
>Organization:
Internet Initiative Japan Inc.
>Environment:
NetBSD sue-dev.iij.ad.jp 4.0 NetBSD 4.0 (GENERIC) #0: Sun Dec 16 00:20:10 PST 
2007  
builds@wb34:/home/builds/ab/netbsd-4-0-RELEASE/i386/200712160005Z-obj/home/builds/ab/netbsd-4-0-RELEASE/src/sys/arch/i386/compile/GENERIC
 i386

>Description:
src/lib/libbsdmalloc/Makefile overwrites CPPFLAGS, and settings in share/mk is 
ignored.

   10 CPPFLAGS= -D_REENTRANT
   11 CPPFLAGS= -I${.CURDIR}/../libc/include/

This should be following:

   10 CPPFLAGS+= -D_REENTRANT -D_REENT
   11 CPPFLAGS+= -I${.CURDIR}/../libc/include/

"-D_REENT" may be needed because malloc.c refers _REENT instead of _REENTRANT.
(Or fix malloc.c to refer _REENTRANT)

I don't know -D_REENT is really same as -D_REENTRANT.

>How-To-Repeat:
build lib/libbsdmalloc.

>Fix:
apply one of following patchs.

(1) use _REENT

Index: Makefile
===================================================================
--- Makefile    (revision 36408)
+++ Makefile    (working copy)
@@ -7,7 +7,7 @@
 LIB=   bsdmalloc
 SRCS=  malloc.c
 
-CPPFLAGS= -D_REENTRANT
-CPPFLAGS= -I${.CURDIR}/../libc/include/
+CPPFLAGS+= -D_REENTRANT -D_REENT
+CPPFLAGS+= -I${.CURDIR}/../libc/include/
 
 .include <bsd.lib.mk>

(2) use _REENTRANT

Index: malloc.c
===================================================================
--- malloc.c    (revision 36408)
+++ malloc.c    (working copy)
@@ -118,7 +118,7 @@
 static u_int nmalloc[NBUCKETS];
 #endif
 
-#ifdef _REENT
+#ifdef _REENTRANT
 static mutex_t malloc_mutex = MUTEX_INITIALIZER;
 #endif
 
@@ -414,19 +414,19 @@
                        return (cp);
                        
                }
-#ifndef _REENT
+#ifndef _REENTRANT
                else
                        free(cp);
 #endif
        }
        mutex_unlock(&malloc_mutex);
        if ((res = malloc(nbytes)) == NULL) {
-#ifdef _REENT
+#ifdef _REENTRANT
                free(cp);
 #endif
                return (NULL);
        }
-#ifndef _REENT
+#ifndef _REENTRANT
        if (cp != res)          /* common optimization if "compacting" */
                (void)memmove(res, cp, (size_t)((nbytes < onb) ? nbytes : onb));
 #else
Index: Makefile
===================================================================
--- Makefile    (revision 36408)
+++ Makefile    (working copy)
@@ -7,7 +7,7 @@
 LIB=   bsdmalloc
 SRCS=  malloc.c
 
-CPPFLAGS= -D_REENTRANT
-CPPFLAGS= -I${.CURDIR}/../libc/include/
+CPPFLAGS+= -D_REENTRANT
+CPPFLAGS+= -I${.CURDIR}/../libc/include/
 
 .include <bsd.lib.mk>



Home | Main Index | Thread Index | Old Index