NetBSD Problem Report #42180

From www@NetBSD.org  Wed Oct 14 07:31:22 2009
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 326C163BC1C
	for <gnats-bugs@gnats.netbsd.org>; Wed, 14 Oct 2009 07:31:22 +0000 (UTC)
Message-Id: <20091014073121.F395663B8B6@www.NetBSD.org>
Date: Wed, 14 Oct 2009 07:31:21 +0000 (UTC)
From: hsuenaga@iij.ad.jp
Reply-To: hsuenaga@iij.ad.jp
To: gnats-bugs@NetBSD.org
Subject: Makefile of libbsdmalloc overwrites CPPFLAGS
X-Send-Pr-Version: www-1.0

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

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.