Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)
- Fix for possible unset uid/gid in toproto
- Fix for default mtree style
- Update libelf
- Importing libexecinfo
- Resynchronize GCC, mpc, gmp, mpfr
- build.sh: Replace params with show-params.
This has been done as the make target has been renamed in the same
way, while a new target named params has been added. This new
target generates a file containing all the parameters, instead of
printing it on the console.
- Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
get getservbyport() out of the inner loop
Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile.inc,v 1.78 2011/09/14 23:33:51 christos Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.79 2013/04/26 18:29:55 christos Exp $
|
||||
# from: @(#)Makefile.inc 8.3 (Berkeley) 2/4/95
|
||||
|
||||
# stdlib sources
|
||||
@@ -12,7 +12,7 @@ SRCS+= _env.c _rand48.c \
|
||||
hcreate.c heapsort.c imaxdiv.c insque.c jrand48.c l64a.c lldiv.c \
|
||||
lcong48.c lrand48.c lsearch.c merge.c mi_vector_hash.c mrand48.c \
|
||||
nrand48.c putenv.c qabs.c qdiv.c qsort.c posix_openpt.c \
|
||||
radixsort.c rand.c rand_r.c random.c remque.c \
|
||||
quick_exit.c radixsort.c rand.c rand_r.c random.c remque.c \
|
||||
seed48.c setenv.c srand48.c strsuftoll.c \
|
||||
strtoimax.c strtol.c strtoll.c strtoq.c strtoul.c strtoull.c \
|
||||
strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c \
|
||||
@@ -41,6 +41,7 @@ CPPFLAGS.strtouq.c+= -I${LIBCDIR}/../../common/lib/libc/stdlib
|
||||
.include "${ARCHDIR}/stdlib/Makefile.inc"
|
||||
|
||||
MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 atoll.3 \
|
||||
at_quick_exit.3 \
|
||||
bsearch.3 \
|
||||
div.3 \
|
||||
exit.3 \
|
||||
@@ -51,7 +52,7 @@ MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 atoll.3 \
|
||||
lsearch.3 \
|
||||
malloc.3 memory.3 mi_vector_hash.3 \
|
||||
posix_memalign.3 posix_openpt.3 ptsname.3 \
|
||||
qabs.3 qdiv.3 qsort.3 \
|
||||
qabs.3 qdiv.3 quick_exit.3 qsort.3 \
|
||||
radixsort.3 rand48.3 rand.3 random.3 \
|
||||
strfmon.3 strsuftoll.3 strtod.3 strtol.3 strtoul.3 system.3 \
|
||||
tsearch.3 \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: _env.c,v 1.6 2011/10/06 20:31:41 christos Exp $ */
|
||||
/* $NetBSD: _env.c,v 1.8 2013/09/09 10:21:28 tron Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 The NetBSD Foundation, Inc.
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: _env.c,v 1.6 2011/10/06 20:31:41 christos Exp $");
|
||||
__RCSID("$NetBSD: _env.c,v 1.8 2013/09/09 10:21:28 tron Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
@@ -256,10 +256,6 @@ __getenvslot(const char *name, size_t l_name, bool allocate)
|
||||
size_t new_size, num_entries, required_size;
|
||||
char **new_environ;
|
||||
|
||||
/* Does the environ need scrubbing? */
|
||||
if (environ != allocated_environ && allocated_environ != NULL)
|
||||
__scrubenv();
|
||||
|
||||
/* Search for an existing environment variable of the given name. */
|
||||
num_entries = 0;
|
||||
while (environ[num_entries] != NULL) {
|
||||
@@ -275,6 +271,10 @@ __getenvslot(const char *name, size_t l_name, bool allocate)
|
||||
if (!allocate)
|
||||
return -1;
|
||||
|
||||
/* Does the environ need scrubbing? */
|
||||
if (environ != allocated_environ && allocated_environ != NULL)
|
||||
__scrubenv();
|
||||
|
||||
/* Create a new slot in the environment. */
|
||||
required_size = num_entries + 1;
|
||||
if (environ == allocated_environ &&
|
||||
@@ -400,7 +400,7 @@ __unlockenv(void)
|
||||
#endif
|
||||
|
||||
/* Initialize environment memory RB tree. */
|
||||
void
|
||||
void __section(".text.startup")
|
||||
__libc_env_init(void)
|
||||
{
|
||||
rb_tree_init(&env_tree, &env_tree_ops);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: alloca.3,v 1.14 2011/03/21 04:42:50 jruoho Exp $
|
||||
.\" $NetBSD: alloca.3,v 1.16 2012/10/24 22:56:27 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1980, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" from: @(#)alloca.3 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Dd March 21, 2011
|
||||
.Dd October 24, 2012
|
||||
.Dt ALLOCA 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -58,36 +58,54 @@ If the allocation failed, a
|
||||
.Dv NULL
|
||||
pointer is returned.
|
||||
.Sh SEE ALSO
|
||||
.Xr cc 1 ,
|
||||
.Xr brk 2 ,
|
||||
.Xr calloc 3 ,
|
||||
.Xr getpagesize 3 ,
|
||||
.Xr malloc 3 ,
|
||||
.Xr realloc 3
|
||||
.Xr realloc 3 ,
|
||||
.Xr security 7
|
||||
.Sh CAVEATS
|
||||
Few limitations can be mentioned:
|
||||
.Bl -bullet
|
||||
.It
|
||||
The
|
||||
.Fn alloca
|
||||
function
|
||||
is machine dependent; its use is discouraged.
|
||||
function is not part of any C standard and its use is not portable.
|
||||
.It
|
||||
The
|
||||
.Fn alloca
|
||||
function is slightly unsafe because it cannot ensure that the pointer
|
||||
function should be supplied by the compiler because the compiler is allowed to
|
||||
make assumptions about the stack and frame pointers.
|
||||
The libc
|
||||
.Fn alloca
|
||||
implementation cannot account for those assumptions.
|
||||
While there is a
|
||||
machine dependent implementation of
|
||||
.Fn alloca
|
||||
in libc, its use is discouraged and in most cases it will not work.
|
||||
Using this implementation will produce linker warnings.
|
||||
.It
|
||||
The
|
||||
.Fn alloca
|
||||
function is unsafe because it cannot ensure that the pointer
|
||||
returned points to a valid and usable block of memory.
|
||||
The allocation made may exceed the bounds of the stack, or even go
|
||||
further into other objects in memory, and
|
||||
.Fn alloca
|
||||
cannot determine such an error.
|
||||
Avoid
|
||||
For that all
|
||||
.Fn alloca
|
||||
with large unbounded allocations.
|
||||
allocations should be bounded and limited to a small size.
|
||||
.It
|
||||
Since
|
||||
.Fn alloca
|
||||
modifies the stack at runtime,
|
||||
it causes problems to certain security features.
|
||||
modifies the stack at runtime and the stack usage of each function frame
|
||||
cannot be predicted, it makes many compiler security features
|
||||
(such as
|
||||
.Xr cc 1
|
||||
.Fl fstack-protector )
|
||||
useless for the calling function.
|
||||
See
|
||||
.Xr security 7
|
||||
for a discussion.
|
||||
|
||||
63
lib/libc/stdlib/at_quick_exit.3
Normal file
63
lib/libc/stdlib/at_quick_exit.3
Normal file
@@ -0,0 +1,63 @@
|
||||
.\" $NetBSD: at_quick_exit.3,v 1.2 2013/04/26 19:37:18 wiz Exp $
|
||||
.\" Copyright (c) 2011 David Chisnall
|
||||
.\" 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 AUTHOR 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 AUTHOR 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.
|
||||
.\"
|
||||
.\" $FreeBSD: src/lib/libc/stdlib/at_quick_exit.3,v 1.5 2012/11/17 01:49:41 svnexp Exp $
|
||||
.\"
|
||||
.Dd April 26, 2013
|
||||
.Dt AT_QUICK_EXIT 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm at_quick_exit
|
||||
.Nd registers a cleanup function to run on quick exit
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In stdlib.h
|
||||
.Ft int
|
||||
.Fn at_quick_exit "void (*func)(void)"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn at_quick_exit
|
||||
function registers a cleanup function to be called when the program exits as a
|
||||
result of calling
|
||||
.Xr quick_exit 3 .
|
||||
The cleanup functions are called in the reverse order and will not be called if
|
||||
the program exits by calling
|
||||
.Xr exit 3 ,
|
||||
.Xr _Exit 2 ,
|
||||
or
|
||||
.Xr abort 3 .
|
||||
.Sh RETURN VALUES
|
||||
The
|
||||
.Fn at_quick_exit
|
||||
function returns the value 0 if successful and a non-zero value on failure.
|
||||
.Sh SEE ALSO
|
||||
.Xr exit 3 ,
|
||||
.Xr quick_exit 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn at_quick_exit
|
||||
function conforms to
|
||||
.St -isoC-2011 .
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: atexit.3,v 1.9 2003/08/07 16:43:38 agc Exp $
|
||||
.\" $NetBSD: atexit.3,v 1.11 2013/04/26 19:37:04 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -68,7 +68,9 @@ No memory was available to add the function to the list.
|
||||
The existing list of functions is unmodified.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr exit 3
|
||||
.Xr at_quick_exit 3 ,
|
||||
.Xr exit 3 ,
|
||||
.Xr quick_exit 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn atexit
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: atexit.c,v 1.24 2009/10/08 16:33:45 pooka Exp $ */
|
||||
/* $NetBSD: atexit.c,v 1.26 2013/08/19 22:14:37 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: atexit.c,v 1.24 2009/10/08 16:33:45 pooka Exp $");
|
||||
__RCSID("$NetBSD: atexit.c,v 1.26 2013/08/19 22:14:37 matt Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "reentrant.h"
|
||||
@@ -74,7 +74,7 @@ static struct atexit_handler *atexit_handler_stack;
|
||||
|
||||
#ifdef _REENTRANT
|
||||
/* ..and a mutex to protect it all. */
|
||||
static mutex_t atexit_mutex;
|
||||
mutex_t __atexit_mutex;
|
||||
#endif /* _REENTRANT */
|
||||
|
||||
void __libc_atexit_init(void) __attribute__ ((visibility("hidden")));
|
||||
@@ -85,7 +85,7 @@ void __libc_atexit_init(void) __attribute__ ((visibility("hidden")));
|
||||
* if possible. cxa_atexit handlers are never allocated from the static
|
||||
* pool.
|
||||
*
|
||||
* atexit_mutex must be held.
|
||||
* __atexit_mutex must be held.
|
||||
*/
|
||||
static struct atexit_handler *
|
||||
atexit_handler_alloc(void *dso)
|
||||
@@ -105,7 +105,7 @@ atexit_handler_alloc(void *dso)
|
||||
|
||||
/*
|
||||
* Either no static slot was free, or this is a cxa_atexit
|
||||
* handler. Allocate a new one. We keep the atexit_mutex
|
||||
* handler. Allocate a new one. We keep the __atexit_mutex
|
||||
* held to prevent handlers from being run while we (potentially)
|
||||
* block in malloc().
|
||||
*/
|
||||
@@ -114,17 +114,17 @@ atexit_handler_alloc(void *dso)
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize atexit_mutex with the PTHREAD_MUTEX_RECURSIVE attribute.
|
||||
* Initialize __atexit_mutex with the PTHREAD_MUTEX_RECURSIVE attribute.
|
||||
* Note that __cxa_finalize may generate calls to __cxa_atexit.
|
||||
*/
|
||||
void
|
||||
void __section(".text.startup")
|
||||
__libc_atexit_init(void)
|
||||
{
|
||||
#ifdef _REENTRANT /* !__minix */
|
||||
mutexattr_t atexit_mutex_attr;
|
||||
mutexattr_init(&atexit_mutex_attr);
|
||||
mutexattr_settype(&atexit_mutex_attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
mutex_init(&atexit_mutex, &atexit_mutex_attr);
|
||||
mutex_init(&__atexit_mutex, &atexit_mutex_attr);
|
||||
#endif /* _REENTRANT */
|
||||
}
|
||||
|
||||
@@ -142,11 +142,11 @@ __cxa_atexit(void (*func)(void *), void *arg, void *dso)
|
||||
|
||||
_DIAGASSERT(func != NULL);
|
||||
|
||||
mutex_lock(&atexit_mutex);
|
||||
mutex_lock(&__atexit_mutex);
|
||||
|
||||
ah = atexit_handler_alloc(dso);
|
||||
if (ah == NULL) {
|
||||
mutex_unlock(&atexit_mutex);
|
||||
mutex_unlock(&__atexit_mutex);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ __cxa_atexit(void (*func)(void *), void *arg, void *dso)
|
||||
ah->ah_next = atexit_handler_stack;
|
||||
atexit_handler_stack = ah;
|
||||
|
||||
mutex_unlock(&atexit_mutex);
|
||||
mutex_unlock(&__atexit_mutex);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ __cxa_finalize(void *dso)
|
||||
void (*cxa_func)(void *);
|
||||
void (*atexit_func)(void);
|
||||
|
||||
mutex_lock(&atexit_mutex);
|
||||
mutex_lock(&__atexit_mutex);
|
||||
call_depth++;
|
||||
|
||||
/*
|
||||
@@ -222,7 +222,7 @@ again:
|
||||
prevp = &ah->ah_next;
|
||||
}
|
||||
call_depth--;
|
||||
mutex_unlock(&atexit_mutex);
|
||||
mutex_unlock(&__atexit_mutex);
|
||||
|
||||
if (call_depth > 0)
|
||||
return;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: exit.3,v 1.15 2012/01/02 15:55:29 dholland Exp $
|
||||
.\" $NetBSD: exit.3,v 1.16 2013/04/26 18:29:55 christos Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -98,8 +98,10 @@ function
|
||||
never returns.
|
||||
.Sh SEE ALSO
|
||||
.Xr _exit 2 ,
|
||||
.Xr at_quick_exit 3 ,
|
||||
.Xr atexit 3 ,
|
||||
.Xr intro 3 ,
|
||||
.Xr quick_exit 3 ,
|
||||
.Xr tmpfile 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
|
||||
@@ -385,4 +385,4 @@ In both systems it replaced the older so-called
|
||||
.Dq phkmalloc
|
||||
implementation.
|
||||
.Sh AUTHORS
|
||||
.An Jason Evans Aq jasone@canonware.com
|
||||
.An Jason Evans Aq Mt jasone@canonware.com
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: jemalloc.c,v 1.28 2012/03/21 14:32:22 christos Exp $ */
|
||||
/* $NetBSD: jemalloc.c,v 1.29 2013/09/12 15:35:15 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 2006,2007 Jason Evans <jasone@FreeBSD.org>.
|
||||
@@ -118,7 +118,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
/* __FBSDID("$FreeBSD: src/lib/libc/stdlib/malloc.c,v 1.147 2007/06/15 22:00:16 jasone Exp $"); */
|
||||
__RCSID("$NetBSD: jemalloc.c,v 1.28 2012/03/21 14:32:22 christos Exp $");
|
||||
__RCSID("$NetBSD: jemalloc.c,v 1.29 2013/09/12 15:35:15 joerg Exp $");
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include "libc_private.h"
|
||||
@@ -289,7 +289,7 @@ __strerror_r(int e, char *s, size_t l)
|
||||
#endif
|
||||
|
||||
/* We can't use TLS in non-PIC programs, since TLS relies on loader magic. */
|
||||
#if (!defined(PIC) && !defined(NO_TLS))
|
||||
#if (!defined(PIC) && !defined(NO_TLS)) && defined(__minix)
|
||||
# define NO_TLS
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: jrand48.c,v 1.8 2005/06/12 05:21:28 lukem Exp $ */
|
||||
/* $NetBSD: jrand48.c,v 1.9 2013/10/22 08:08:51 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Martin Birgmeier
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: jrand48.c,v 1.8 2005/06/12 05:21:28 lukem Exp $");
|
||||
__RCSID("$NetBSD: jrand48.c,v 1.9 2013/10/22 08:08:51 matt Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
@@ -35,5 +35,5 @@ jrand48(unsigned short xseed[3])
|
||||
_DIAGASSERT(xseed != NULL);
|
||||
|
||||
__dorand48(xseed);
|
||||
return ((long) xseed[2] << 16) + (long) xseed[1];
|
||||
return (int16_t)xseed[2] * 65536 + xseed[1];
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lrand48.c,v 1.8 2005/06/12 05:21:28 lukem Exp $ */
|
||||
/* $NetBSD: lrand48.c,v 1.9 2013/10/22 08:08:51 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Martin Birgmeier
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: lrand48.c,v 1.8 2005/06/12 05:21:28 lukem Exp $");
|
||||
__RCSID("$NetBSD: lrand48.c,v 1.9 2013/10/22 08:08:51 matt Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
@@ -29,6 +29,5 @@ long
|
||||
lrand48(void)
|
||||
{
|
||||
__dorand48(__rand48_seed);
|
||||
return (long)((unsigned long) __rand48_seed[2] << 15) +
|
||||
((unsigned long) __rand48_seed[1] >> 1);
|
||||
return __rand48_seed[2] * 32768 + (__rand48_seed[1] >> 1);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: malloc.c,v 1.54 2011/05/18 01:59:39 christos Exp $ */
|
||||
/* $NetBSD: malloc.c,v 1.55 2012/12/30 21:23:20 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
@@ -13,8 +13,10 @@
|
||||
*/
|
||||
|
||||
#ifdef __minix
|
||||
#include "extern.h"
|
||||
#ifdef _LIBSYS
|
||||
#include <minix/sysutil.h>
|
||||
#include <machine/param.h>
|
||||
#include <machine/vmparam.h>
|
||||
#define MALLOC_NO_SYSCALLS
|
||||
#define wrtwarning(w) printf("libminc malloc warning: %s\n", w)
|
||||
@@ -107,7 +109,7 @@ void utrace(struct ut *, int);
|
||||
#include <sys/cdefs.h>
|
||||
#include "extern.h"
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: malloc.c,v 1.54 2011/05/18 01:59:39 christos Exp $");
|
||||
__RCSID("$NetBSD: malloc.c,v 1.55 2012/12/30 21:23:20 dholland Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
int utrace(const char *, void *, size_t);
|
||||
|
||||
@@ -227,11 +229,13 @@ static size_t malloc_pagemask;
|
||||
#define INIT_MMAP()
|
||||
#endif
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
#ifndef MADV_FREE
|
||||
#define MADV_FREE MADV_DONTNEED
|
||||
#endif
|
||||
#endif /* !__minix */
|
||||
#else
|
||||
#undef MADV_FREE
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
/* Number of free pages we cache */
|
||||
static size_t malloc_cache = 16;
|
||||
@@ -513,10 +517,10 @@ malloc_init(void)
|
||||
case '<': malloc_cache >>= 1; break;
|
||||
case 'a': malloc_abort = 0; break;
|
||||
case 'A': malloc_abort = 1; break;
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
case 'h': malloc_hint = 0; break;
|
||||
case 'H': malloc_hint = 1; break;
|
||||
#endif /* !__minix */
|
||||
#endif /* !defined(__minix) */
|
||||
case 'r': malloc_realloc = 0; break;
|
||||
case 'R': malloc_realloc = 1; break;
|
||||
case 'j': malloc_junk = 0; break;
|
||||
@@ -963,10 +967,10 @@ free_pages(void *ptr, size_t idx, struct pginfo *info)
|
||||
if (malloc_junk)
|
||||
memset(ptr, SOME_JUNK, l);
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if (malloc_hint)
|
||||
madvise(ptr, l, MADV_FREE);
|
||||
#endif /* !__minix */
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
tail = (char *)ptr+l;
|
||||
|
||||
@@ -1161,7 +1165,7 @@ ifree(void *ptr)
|
||||
return;
|
||||
}
|
||||
|
||||
static int malloc_active; /* Recusion flag for public interface. */
|
||||
static int malloc_active; /* Recursion flag for public interface. */
|
||||
static unsigned malloc_started; /* Set when initialization has been done */
|
||||
|
||||
static void *
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mrand48.c,v 1.7 2005/06/12 05:21:28 lukem Exp $ */
|
||||
/* $NetBSD: mrand48.c,v 1.8 2013/10/22 08:08:51 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Martin Birgmeier
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: mrand48.c,v 1.7 2005/06/12 05:21:28 lukem Exp $");
|
||||
__RCSID("$NetBSD: mrand48.c,v 1.8 2013/10/22 08:08:51 matt Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
@@ -29,5 +29,5 @@ long
|
||||
mrand48(void)
|
||||
{
|
||||
__dorand48(__rand48_seed);
|
||||
return ((long) __rand48_seed[2] << 16) + (long) __rand48_seed[1];
|
||||
return (int16_t)__rand48_seed[2] * 65536 + __rand48_seed[1];
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nrand48.c,v 1.9 2005/06/12 05:21:28 lukem Exp $ */
|
||||
/* $NetBSD: nrand48.c,v 1.10 2013/10/22 08:08:51 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Martin Birgmeier
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: nrand48.c,v 1.9 2005/06/12 05:21:28 lukem Exp $");
|
||||
__RCSID("$NetBSD: nrand48.c,v 1.10 2013/10/22 08:08:51 matt Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
@@ -34,6 +34,5 @@ nrand48(unsigned short xseed[3])
|
||||
_DIAGASSERT(xseed != NULL);
|
||||
|
||||
__dorand48(xseed);
|
||||
return (long)((unsigned long) xseed[2] << 15) +
|
||||
((unsigned long) xseed[1] >> 1);
|
||||
return xseed[2] * 32768 + (xseed[1] >> 1);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: ptsname.3,v 1.5 2008/04/30 13:10:51 martin Exp $
|
||||
.\" $NetBSD: ptsname.3,v 1.6 2012/10/19 10:44:34 apb Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
@@ -85,7 +85,7 @@ The
|
||||
function is equivalent to:
|
||||
.Bd -literal
|
||||
struct ptmget pm;
|
||||
return ioctl(masterfd, TIOCPTSNAME, \*[Am]pm) == -1 ? NULL : pm.ps;
|
||||
return ioctl(masterfd, TIOCPTSNAME, \*[Am]pm) == -1 ? NULL : pm.sn;
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr ioctl 2 ,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: putenv.c,v 1.19 2010/11/14 18:11:43 tron Exp $ */
|
||||
/* $NetBSD: putenv.c,v 1.20 2013/04/25 07:08:56 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1988, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)putenv.c 8.2 (Berkeley) 3/27/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: putenv.c,v 1.19 2010/11/14 18:11:43 tron Exp $");
|
||||
__RCSID("$NetBSD: putenv.c,v 1.20 2013/04/25 07:08:56 matt Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -49,10 +49,6 @@ __RCSID("$NetBSD: putenv.c,v 1.19 2010/11/14 18:11:43 tron Exp $");
|
||||
#include "reentrant.h"
|
||||
#include "local.h"
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(putenv,_putenv)
|
||||
#endif
|
||||
|
||||
int
|
||||
putenv(char *str)
|
||||
{
|
||||
|
||||
59
lib/libc/stdlib/quick_exit.3
Normal file
59
lib/libc/stdlib/quick_exit.3
Normal file
@@ -0,0 +1,59 @@
|
||||
.\" $NetBSD: quick_exit.3,v 1.2 2013/04/26 19:36:47 wiz Exp $
|
||||
.\" Copyright (c) 2011 David Chisnall
|
||||
.\" 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 AUTHOR 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 AUTHOR 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.
|
||||
.\"
|
||||
.\" $FreeBSD: src/lib/libc/stdlib/quick_exit.3,v 1.4 2012/11/17 01:49:41 svnexp Exp $
|
||||
.\"
|
||||
.Dd April 26, 2013
|
||||
.Dt QUICK_EXIT 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm quick_exit
|
||||
.Nd exits a program quickly, running minimal cleanup
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In stdlib.h
|
||||
.Ft _Noreturn void
|
||||
.Fn quick_exit "void"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn quick_exit
|
||||
function exits the program quickly calling any cleanup functions registered
|
||||
with
|
||||
.Xr at_quick_exit 3
|
||||
but not any C++ destructors or cleanup code registered with
|
||||
.Xr atexit 3 .
|
||||
.Sh RETURN VALUES
|
||||
The
|
||||
.Fn quick_exit
|
||||
function does not return.
|
||||
.Sh SEE ALSO
|
||||
.Xr at_quick_exit 3 ,
|
||||
.Xr exit 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn quick_exit
|
||||
function conforms to
|
||||
.St -isoC-2011 .
|
||||
93
lib/libc/stdlib/quick_exit.c
Normal file
93
lib/libc/stdlib/quick_exit.c
Normal file
@@ -0,0 +1,93 @@
|
||||
/* $NetBSD: quick_exit.c,v 1.1 2013/04/26 18:29:55 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2011 David Chisnall
|
||||
* 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 AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/lib/libc/stdlib/quick_exit.c,v 1.4 2012/11/17 01:49:41 svnexp Exp $
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: quick_exit.c,v 1.1 2013/04/26 18:29:55 christos Exp $");
|
||||
|
||||
#include "namespace.h"
|
||||
#include "reentrant.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* Linked list of quick exit handlers. This is simpler than the atexit()
|
||||
* version, because it is not required to support C++ destructors or
|
||||
* DSO-specific cleanups.
|
||||
*/
|
||||
struct quick_exit_handler {
|
||||
struct quick_exit_handler *next;
|
||||
void (*cleanup)(void);
|
||||
};
|
||||
|
||||
/**
|
||||
* Lock protecting the handlers list.
|
||||
*/
|
||||
#ifdef _REENTRANT
|
||||
extern mutex_t __atexit_mutex;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Stack of cleanup handlers. These will be invoked in reverse order when
|
||||
*/
|
||||
static struct quick_exit_handler *handlers;
|
||||
|
||||
int
|
||||
at_quick_exit(void (*func)(void))
|
||||
{
|
||||
struct quick_exit_handler *h;
|
||||
|
||||
h = malloc(sizeof(*h));
|
||||
|
||||
if (NULL == h)
|
||||
return 1;
|
||||
h->cleanup = func;
|
||||
#ifdef _REENTRANT
|
||||
mutex_lock(&__atexit_mutex);
|
||||
#endif
|
||||
h->next = handlers;
|
||||
handlers = h;
|
||||
#ifdef _REENTRANT
|
||||
mutex_unlock(&__atexit_mutex);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
quick_exit(int status)
|
||||
{
|
||||
struct quick_exit_handler *h;
|
||||
|
||||
/*
|
||||
* XXX: The C++ spec requires us to call std::terminate if there is an
|
||||
* exception here.
|
||||
*/
|
||||
for (h = handlers; NULL != h; h = h->next)
|
||||
(*h->cleanup)();
|
||||
_Exit(status);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: strfmon.3,v 1.3 2005/04/04 08:19:00 wiz Exp $
|
||||
.\" $NetBSD: strfmon.3,v 1.4 2013/07/20 21:39:57 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2001 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org>
|
||||
.\" All rights reserved.
|
||||
@@ -156,10 +156,10 @@ conforms to
|
||||
The
|
||||
.Fn strfmon
|
||||
function was implemented by
|
||||
.An Alexey Zelkin Aq phantom@FreeBSD.org .
|
||||
.An Alexey Zelkin Aq Mt phantom@FreeBSD.org .
|
||||
.Pp
|
||||
This manual page was written by
|
||||
.An Jeroen Ruigrok van der Werven Aq asmodai@FreeBSD.org
|
||||
.An Jeroen Ruigrok van der Werven Aq Mt asmodai@FreeBSD.org
|
||||
based on the standard's text.
|
||||
.Sh BUGS
|
||||
The
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: strtoimax.c,v 1.7 2008/09/10 18:08:58 joerg Exp $");
|
||||
__RCSID("$NetBSD: strtoimax.c,v 1.8 2013/04/16 21:44:08 joerg Exp $");
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
@@ -50,3 +50,4 @@ __RCSID("$NetBSD: strtoimax.c,v 1.7 2008/09/10 18:08:58 joerg Exp $");
|
||||
#include "_strtol.h"
|
||||
|
||||
__strong_alias(_strtoimax, strtoimax)
|
||||
__strong_alias(_strtoimax_l, strtoimax_l)
|
||||
|
||||
@@ -104,7 +104,3 @@ unsetenv(const char *name)
|
||||
(void)__unlockenv();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(__minix) && defined(__weak_alias)
|
||||
__weak_alias(unsetenv, __unsetenv13)
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user