From 49e111a21fcf8e0b21cd6328dbe39715707aff2b Mon Sep 17 00:00:00 2001 From: christos Date: Wed, 13 Jan 2016 21:56:38 +0000 Subject: [PATCH] merge changes, add build glue. --- external/gpl2/libmalloc/Makefile | 3 + external/gpl2/libmalloc/Makefile.inc | 3 + external/gpl2/libmalloc/dist/getpagesize.h | 3 +- external/gpl2/libmalloc/dist/malloc.h | 6 +- external/gpl2/libmalloc/dist/mcheck.c | 3 +- external/gpl2/libmalloc/dist/mem-limits.h | 7 +- external/gpl2/libmalloc/dist/morecore.c | 3 +- external/gpl2/libmalloc/dist/mtrace.c | 9 +- external/gpl2/libmalloc/dist/ralloc.c | 5 +- external/gpl2/libmalloc/dist/valloc.c | 3 +- external/gpl2/libmalloc/lib/Makefile | 19 +++ external/gpl2/libmalloc/lib/combined.c | 12 ++ external/gpl2/libmalloc/lib/shlib_version | 5 + external/gpl2/libmalloc/libmalloc2netbsd | 134 +++++++++++++++++++++ 14 files changed, 199 insertions(+), 16 deletions(-) create mode 100644 external/gpl2/libmalloc/Makefile create mode 100644 external/gpl2/libmalloc/Makefile.inc create mode 100644 external/gpl2/libmalloc/lib/Makefile create mode 100644 external/gpl2/libmalloc/lib/combined.c create mode 100644 external/gpl2/libmalloc/lib/shlib_version create mode 100755 external/gpl2/libmalloc/libmalloc2netbsd diff --git a/external/gpl2/libmalloc/Makefile b/external/gpl2/libmalloc/Makefile new file mode 100644 index 000000000000..8ca6b97b43b8 --- /dev/null +++ b/external/gpl2/libmalloc/Makefile @@ -0,0 +1,3 @@ +# $NetBSD: Makefile,v 1.1 2016/01/13 21:56:38 christos Exp $ +SUBDIR = lib +.include diff --git a/external/gpl2/libmalloc/Makefile.inc b/external/gpl2/libmalloc/Makefile.inc new file mode 100644 index 000000000000..93c3df4b16cd --- /dev/null +++ b/external/gpl2/libmalloc/Makefile.inc @@ -0,0 +1,3 @@ +# $NetBSD: Makefile.inc,v 1.1 2016/01/13 21:56:38 christos Exp $ + +DIST=${NETBSDSRCDIR}/external/gpl2/libmalloc/dist diff --git a/external/gpl2/libmalloc/dist/getpagesize.h b/external/gpl2/libmalloc/dist/getpagesize.h index 4970ab7c1d28..5478b2168312 100644 --- a/external/gpl2/libmalloc/dist/getpagesize.h +++ b/external/gpl2/libmalloc/dist/getpagesize.h @@ -1,4 +1,5 @@ -/* $NetBSD: getpagesize.h,v 1.1.1.1 2016/01/13 21:42:18 christos Exp $ */ +#include +/* $NetBSD: getpagesize.h,v 1.2 2016/01/13 21:56:38 christos Exp $ */ /* Emulate getpagesize on systems that lack it. */ diff --git a/external/gpl2/libmalloc/dist/malloc.h b/external/gpl2/libmalloc/dist/malloc.h index 07a113ef90a9..4a668f0f4a64 100644 --- a/external/gpl2/libmalloc/dist/malloc.h +++ b/external/gpl2/libmalloc/dist/malloc.h @@ -1,4 +1,4 @@ -/* $NetBSD: malloc.h,v 1.1.1.1 2016/01/13 21:42:18 christos Exp $ */ +/* $NetBSD: malloc.h,v 1.2 2016/01/13 21:56:38 christos Exp $ */ /* Declarations for `malloc' and friends. Copyright 1990, 1991, 1992, 1993, 1995 Free Software Foundation, Inc. @@ -64,8 +64,12 @@ extern "C" #endif #if defined (__cplusplus) || (defined (__STDC__) && __STDC__) +#ifndef __NetBSD__ #undef __P #define __P(args) args +#else +#include +#endif #undef __ptr_t #define __ptr_t void * #else /* Not C++ or ANSI C. */ diff --git a/external/gpl2/libmalloc/dist/mcheck.c b/external/gpl2/libmalloc/dist/mcheck.c index 36e5cfb1fd18..9a1cd82b38f0 100644 --- a/external/gpl2/libmalloc/dist/mcheck.c +++ b/external/gpl2/libmalloc/dist/mcheck.c @@ -1,4 +1,4 @@ -/* $NetBSD: mcheck.c,v 1.1.1.1 2016/01/13 21:42:18 christos Exp $ */ +/* $NetBSD: mcheck.c,v 1.2 2016/01/13 21:56:38 christos Exp $ */ /* Standard debugging hooks for `malloc'. Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. @@ -25,6 +25,7 @@ Cambridge, MA 02139, USA. #ifndef _MALLOC_INTERNAL #define _MALLOC_INTERNAL #include +#include #include #endif diff --git a/external/gpl2/libmalloc/dist/mem-limits.h b/external/gpl2/libmalloc/dist/mem-limits.h index fc48f2c282a3..16c4a115a561 100644 --- a/external/gpl2/libmalloc/dist/mem-limits.h +++ b/external/gpl2/libmalloc/dist/mem-limits.h @@ -1,4 +1,4 @@ -/* $NetBSD: mem-limits.h,v 1.1.1.1 2016/01/13 21:42:18 christos Exp $ */ +/* $NetBSD: mem-limits.h,v 1.2 2016/01/13 21:56:38 christos Exp $ */ /* Includes for memory limit warnings. Copyright (C) 1990, 1993, 1994 Free Software Foundation, Inc. @@ -41,7 +41,7 @@ Cambridge, MA 02139, USA. */ #include #endif -#ifdef __bsdi__ +#if defined(__bsdi__) || defined(__NetBSD__) #define BSD4_2 #endif @@ -173,7 +173,8 @@ get_lim_data () { struct rlimit XXrlimit; - getrlimit (RLIMIT_DATA, &XXrlimit); + if (getrlimit (RLIMIT_DATA, &XXrlimit) == -1) + XXrlimit.rlim_cur = -1; #ifdef RLIM_INFINITY lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */ #else diff --git a/external/gpl2/libmalloc/dist/morecore.c b/external/gpl2/libmalloc/dist/morecore.c index e7dd33ea5ddf..b96219b2142e 100644 --- a/external/gpl2/libmalloc/dist/morecore.c +++ b/external/gpl2/libmalloc/dist/morecore.c @@ -1,4 +1,4 @@ -/* $NetBSD: morecore.c,v 1.1.1.1 2016/01/13 21:42:18 christos Exp $ */ +/* $NetBSD: morecore.c,v 1.2 2016/01/13 21:56:38 christos Exp $ */ /* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -20,6 +20,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _MALLOC_INTERNAL #define _MALLOC_INTERNAL #include +#include #endif #ifndef __GNU_LIBRARY__ diff --git a/external/gpl2/libmalloc/dist/mtrace.c b/external/gpl2/libmalloc/dist/mtrace.c index 92901364953c..cbe4a63d5009 100644 --- a/external/gpl2/libmalloc/dist/mtrace.c +++ b/external/gpl2/libmalloc/dist/mtrace.c @@ -1,4 +1,4 @@ -/* $NetBSD: mtrace.c,v 1.1.1.1 2016/01/13 21:42:18 christos Exp $ */ +/* $NetBSD: mtrace.c,v 1.2 2016/01/13 21:56:38 christos Exp $ */ /* More debugging hooks for `malloc'. Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. @@ -91,8 +91,7 @@ tr_freehook (ptr) static __ptr_t tr_mallochook __P ((__malloc_size_t)); static __ptr_t -tr_mallochook (size) - __malloc_size_t size; +tr_mallochook (__malloc_size_t size) { __ptr_t hdr; @@ -112,9 +111,7 @@ tr_mallochook (size) static __ptr_t tr_reallochook __P ((__ptr_t, __malloc_size_t)); static __ptr_t -tr_reallochook (ptr, size) - __ptr_t ptr; - __malloc_size_t size; +tr_reallochook (__ptr_t ptr, __malloc_size_t size) { __ptr_t hdr; diff --git a/external/gpl2/libmalloc/dist/ralloc.c b/external/gpl2/libmalloc/dist/ralloc.c index 0b6bbcb57ca6..9c51dc2318e3 100644 --- a/external/gpl2/libmalloc/dist/ralloc.c +++ b/external/gpl2/libmalloc/dist/ralloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: ralloc.c,v 1.1.1.1 2016/01/13 21:42:18 christos Exp $ */ +/* $NetBSD: ralloc.c,v 1.2 2016/01/13 21:56:38 christos Exp $ */ /* Block-relocating memory allocator. Copyright (C) 1993, 1995 Free Software Foundation, Inc. @@ -71,6 +71,7 @@ typedef size_t SIZE; typedef void *POINTER; #include +#include #include #include @@ -1002,7 +1003,7 @@ r_alloc_init () #ifdef DEBUG #include -int +void r_alloc_check () { int found = 0; diff --git a/external/gpl2/libmalloc/dist/valloc.c b/external/gpl2/libmalloc/dist/valloc.c index 48f977c389c8..2fe986706c33 100644 --- a/external/gpl2/libmalloc/dist/valloc.c +++ b/external/gpl2/libmalloc/dist/valloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: valloc.c,v 1.1.1.1 2016/01/13 21:42:18 christos Exp $ */ +/* $NetBSD: valloc.c,v 1.2 2016/01/13 21:56:38 christos Exp $ */ /* Allocate memory on a page boundary. Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. @@ -23,6 +23,7 @@ Cambridge, MA 02139, USA. #if defined (__GNU_LIBRARY__) || defined (_LIBC) #include +#include #include extern size_t __getpagesize __P ((void)); #else diff --git a/external/gpl2/libmalloc/lib/Makefile b/external/gpl2/libmalloc/lib/Makefile new file mode 100644 index 000000000000..4d457aee0dc5 --- /dev/null +++ b/external/gpl2/libmalloc/lib/Makefile @@ -0,0 +1,19 @@ +# $NetBSD: Makefile,v 1.1 2016/01/13 21:56:38 christos Exp $ + +NOLINT= +NOMAN= # defined +.include + +LIB= gnumalloc +SRCS+= combined.c +#SRCS+= malloc.c free.c realloc.c +SRCS+= cfree.c calloc.c morecore.c +SRCS+= memalign.c valloc.c mcheck.c mtrace.c mstats.c vm-limit.c +SRCS+= ralloc.c + + +CPPFLAGS+= -I${DIST} -I${.CURDIR} -DSTDC_HEADERS -DHAVE_STDLIB_H + +.PATH: ${DIST} + +.include diff --git a/external/gpl2/libmalloc/lib/combined.c b/external/gpl2/libmalloc/lib/combined.c new file mode 100644 index 000000000000..21e14358dec6 --- /dev/null +++ b/external/gpl2/libmalloc/lib/combined.c @@ -0,0 +1,12 @@ +/* + * this file (combined.c) is malloc.c, free.c, and realloc.c, combined into + * one file, because the malloc.o in libc defined malloc, realloc, and free, + * and libc sometimes invokes realloc, which can greatly confuse things + * in the linking process... + * + * $Id: combined.c,v 1.1 2016/01/13 21:56:38 christos Exp $ + */ + +#include "malloc.c" +#include "free.c" +#include "realloc.c" diff --git a/external/gpl2/libmalloc/lib/shlib_version b/external/gpl2/libmalloc/lib/shlib_version new file mode 100644 index 000000000000..5dd783060852 --- /dev/null +++ b/external/gpl2/libmalloc/lib/shlib_version @@ -0,0 +1,5 @@ +# $NetBSD: shlib_version,v 1.1 2016/01/13 21:56:38 christos Exp $ +# Remember to update distrib/sets/lists/base/shl.* when changing +# +major=1 +minor=0 diff --git a/external/gpl2/libmalloc/libmalloc2netbsd b/external/gpl2/libmalloc/libmalloc2netbsd new file mode 100755 index 000000000000..8e0977bfd144 --- /dev/null +++ b/external/gpl2/libmalloc/libmalloc2netbsd @@ -0,0 +1,134 @@ +#! /bin/sh +# +# $NetBSD: libmalloc2netbsd,v 1.1 2016/01/13 21:56:38 christos Exp $ +# +# Copyright (c) 2016 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# libmalloc2netbsd: convert an glibc source tree into a +# netbsd libmalloc source tree, +# +# Rough instructions for importing new libmalloc release: +# +# $ cd /some/where/temporary +# $ tar xpfz /malloc/release/tar/file +# $ sh /usr/src/external/gpl2/libmalloc/libmalloc2netbsd malloc `pwd` +# $ cd `pwd`/src/external/gpl2/libmalloc/dist +# $ cvs import -m "Import libmalloc YYYY-MM-DD" src/external/gpl2/libmalloc/dist FSF malloc-YYYY-MM-DD +# merge sources according to instructions given +# e.g. cvs -d cvs.netbsd.org:/cvsroot checkout -jlibmalloc-1-19 -jlibmalloc-1-19-1 src/gnu/dist/libmalloc + +if [ $# -ne 2 ]; then echo "libmalloc2netbsd src dest"; exit 1; fi + +r=$1 +d=$2/src/external/gpl2/libmalloc/dist + +case "$d" in + /*) + ;; + *) + d=`/bin/pwd`/$d + ;; +esac + +case "$r" in + /*) + ;; + *) + r=`/bin/pwd`/$r + ;; +esac + +echo preparing directory $d +rm -rf $d +mkdir -p $d + +### Copy the files and directories +echo copying $r to $d +cd $r +pax -rw * $d +chmod -x $d/* + +# cd to import directory +cd $d + +# + +### Remove the $'s around RCS tags +cleantags $d + +### Add our NetBSD RCS Id +find $d -type f -name '*.[chly]' -print | while read c; do + sed 1q < $c | grep -q '\$NetBSD' || ( +echo "/* \$NetBSD\$ */" >/tmp/libmalloc3n$$ +echo "" >>/tmp/libmalloc3n$$ +cat $c >> /tmp/libmalloc3n$$ +mv /tmp/libmalloc3n$$ $c && echo added NetBSD RCS tag to $c + ) +done + +find $d -type f -name '*.cpp' -print | while read c; do + sed 1q < $c | grep -q '\$NetBSD' || ( +echo "/* \$NetBSD\$ */" >/tmp/libmalloc3n$$ +echo "" >>/tmp/libmalloc3n$$ +cat $c >> /tmp/libmalloc3n$$ +mv /tmp/libmalloc3n$$ $c && echo added NetBSD RCS tag to $c + ) +done + +find $d -type f -name '*.[0-9]' -print | while read m; do + sed 1q < $m | grep -q '\$NetBSD' || ( +echo ".\\\" \$NetBSD\$" >/tmp/libmalloc2m$$ +echo ".\\\"" >>/tmp/libmalloc2m$$ +cat $m >> /tmp/libmalloc2m$$ +mv /tmp/libmalloc2m$$ $m && echo added NetBSD RCS tag to $m + ) +done + +find $d -type f -name '*.texi' -print | while read t; do + sed "2 s/^/@c \$NetBSD\$\\ +/" < $t > /tmp/libmalloc4t$$ + mv /tmp/libmalloc4t$$ $t && echo added NetBSD RCS tag to $t +done + +echo done + +### Clean up any CVS directories that might be around. +echo "cleaning up CVS residue." +( + cd $d + find . -type d -name "CVS" -print | xargs rm -r +) +echo done + +### Fixing file and directory permissions. +echo "Fixing file/directory permissions." +( + cd $d + find . -type f -print | xargs chmod u+rw,go+r + find . -type d -print | xargs chmod u+rwx,go+rx +) +echo done + +exit 0