Libraries updates and cleanup
* Updating common/lib * Updating lib/csu * Updating lib/libc * Updating libexec/ld.elf_so * Corrected test on __minix in featuretest to actually follow the meaning of the comment. * Cleaned up _REENTRANT-related defintions. * Disabled -D_REENTRANT for libfetch * Removing some unneeded __NBSD_LIBC defines and tests Change-Id: Ic1394baef74d11b9f86b312f5ff4bbc3cbf72ce2
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
# $NetBSD: Makefile.inc,v 1.75 2010/11/14 18:11:43 tron Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.78 2011/09/14 23:33:51 christos Exp $
|
||||
# from: @(#)Makefile.inc 8.3 (Berkeley) 2/4/95
|
||||
|
||||
# stdlib sources
|
||||
.PATH: ${ARCHDIR}/stdlib ${.CURDIR}/stdlib
|
||||
|
||||
.if defined(__MINIX)
|
||||
# pty.c not compiled
|
||||
#LSC: MINIX: pty.c not compiled
|
||||
SRCS+= _env.c _rand48.c \
|
||||
a64l.c abort.c atexit.c atof.c atoi.c atol.c atoll.c \
|
||||
bsearch.c drand48.c exit.c \
|
||||
@@ -18,20 +17,6 @@ SRCS+= _env.c _rand48.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 \
|
||||
unsetenv.c strfmon.c
|
||||
.else
|
||||
SRCS+= _env.c _rand48.c \
|
||||
a64l.c abort.c atexit.c atof.c atoi.c atol.c atoll.c \
|
||||
bsearch.c drand48.c exit.c \
|
||||
getenv.c getopt.c getopt_long.c getsubopt.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 pty.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 \
|
||||
unsetenv.c strfmon.c
|
||||
.endif
|
||||
|
||||
# These are often replaced by MD .S versions
|
||||
SRCS+= abs.c labs.c llabs.c imaxabs.c
|
||||
@@ -42,7 +27,7 @@ SRCS+= erand48_ieee754.c
|
||||
|
||||
.if (${USE_JEMALLOC} != "no")
|
||||
SRCS+= jemalloc.c
|
||||
.elif (${USE_MINIXMALLOC} != "no")
|
||||
.elif (${USE_MINIXMALLOC:Uno} != "no")
|
||||
.include "../minix/Makefile.inc"
|
||||
.else
|
||||
SRCS+= malloc.c
|
||||
@@ -61,9 +46,9 @@ MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 atoll.3 \
|
||||
exit.3 \
|
||||
getenv.3 getopt.3 getopt_long.3 getsubopt.3 grantpt.3 \
|
||||
hcreate.3 \
|
||||
imaxabs.3 imaxdiv.3 insque.3 \
|
||||
insque.3 \
|
||||
jemalloc.3 \
|
||||
labs.3 ldiv.3 llabs.3 lldiv.3 lsearch.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 \
|
||||
@@ -74,9 +59,16 @@ MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 atoll.3 \
|
||||
|
||||
MLINKS+=a64l.3 l64a.3
|
||||
MLINKS+=a64l.3 l64a_r.3
|
||||
MLINKS+=abs.3 labs.3 \
|
||||
abs.3 llabs.3 \
|
||||
abs.3 imaxabs.3
|
||||
MLINKS+=div.3 ldiv.3 \
|
||||
div.3 lldiv.3 \
|
||||
div.3 imaxdiv.3
|
||||
MLINKS+=getenv.3 setenv.3 getenv.3 unsetenv.3 getenv.3 putenv.3
|
||||
MLINKS+=getenv.3 getenv_r.3
|
||||
MLINKS+=hcreate.3 hdestroy.3 hcreate.3 hsearch.3
|
||||
MLINKS+=hcreate.3 hcreate_r.3 hcreate.3 hdestroy_r.3 hcreate.3 hsearch_r.3
|
||||
MLINKS+=insque.3 remque.3
|
||||
MLINKS+=lsearch.3 lfind.3
|
||||
MLINKS+=malloc.3 calloc.3 malloc.3 realloc.3 malloc.3 free.3
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: _env.c,v 1.5 2010/11/17 13:25:53 tron Exp $ */
|
||||
/* $NetBSD: _env.c,v 1.6 2011/10/06 20:31:41 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 The NetBSD Foundation, Inc.
|
||||
@@ -29,11 +29,9 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
static int inited = 0;
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: _env.c,v 1.5 2010/11/17 13:25:53 tron Exp $");
|
||||
__RCSID("$NetBSD: _env.c,v 1.6 2011/10/06 20:31:41 christos Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
@@ -97,6 +95,8 @@ __warn_references(__findenv,
|
||||
/* Our initialization function. */
|
||||
void __libc_env_init(void);
|
||||
|
||||
char **environ;
|
||||
|
||||
/*ARGSUSED*/
|
||||
static signed int
|
||||
env_tree_compare_nodes(void *ctx, const void *node_a, const void *node_b)
|
||||
@@ -159,7 +159,6 @@ __freeenvvar(char *envvar)
|
||||
env_node_t *node;
|
||||
|
||||
_DIAGASSERT(envvar != NULL);
|
||||
assert(inited);
|
||||
node = rb_tree_find_node(&env_tree, envvar);
|
||||
if (node != NULL) {
|
||||
rb_tree_remove_node(&env_tree, node);
|
||||
@@ -176,7 +175,6 @@ __allocenvvar(size_t length)
|
||||
{
|
||||
env_node_t *node;
|
||||
|
||||
assert(inited);
|
||||
node = malloc(sizeof(*node) + length);
|
||||
if (node != NULL) {
|
||||
node->length = length;
|
||||
@@ -198,8 +196,6 @@ __canoverwriteenvvar(char *envvar, size_t length)
|
||||
{
|
||||
env_node_t *node;
|
||||
|
||||
assert(inited);
|
||||
|
||||
_DIAGASSERT(envvar != NULL);
|
||||
|
||||
node = rb_tree_find_node(&env_tree, envvar);
|
||||
@@ -214,7 +210,6 @@ __scrubenv(void)
|
||||
size_t num_entries;
|
||||
env_node_t *node, *next;
|
||||
|
||||
assert(inited);
|
||||
while (++marker == 0);
|
||||
|
||||
/* Mark all nodes which are currently used. */
|
||||
@@ -408,7 +403,5 @@ __unlockenv(void)
|
||||
void
|
||||
__libc_env_init(void)
|
||||
{
|
||||
assert(!inited);
|
||||
rb_tree_init(&env_tree, &env_tree_ops);
|
||||
inited = 1;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: a64l.c,v 1.9 2003/07/26 19:24:53 salo Exp $");
|
||||
__RCSID("$NetBSD: a64l.c,v 1.10 2012/06/08 11:15:26 abs Exp $");
|
||||
#endif
|
||||
|
||||
#include "namespace.h"
|
||||
@@ -18,8 +18,7 @@ __weak_alias(a64l,_a64l)
|
||||
#endif
|
||||
|
||||
long
|
||||
a64l(s)
|
||||
const char *s;
|
||||
a64l(const char *s)
|
||||
{
|
||||
long value, digit, shift;
|
||||
int i;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: abort.3,v 1.12 2003/08/07 16:43:37 agc Exp $
|
||||
.\" $NetBSD: abort.3,v 1.13 2012/06/12 21:16:17 jdf Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -59,7 +59,7 @@ function results in temporary files being removed.
|
||||
Any open streams are flushed and closed.
|
||||
.Sh RETURN VALUES
|
||||
The
|
||||
.Nm abort
|
||||
.Fn abort
|
||||
function
|
||||
never returns.
|
||||
.Sh SEE ALSO
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: abort.c,v 1.13 2009/01/30 23:21:03 ad Exp $ */
|
||||
/* $NetBSD: abort.c,v 1.15 2012/06/08 11:15:26 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)abort.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: abort.c,v 1.13 2009/01/30 23:21:03 ad Exp $");
|
||||
__RCSID("$NetBSD: abort.c,v 1.15 2012/06/08 11:15:26 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -43,11 +43,11 @@ __RCSID("$NetBSD: abort.c,v 1.13 2009/01/30 23:21:03 ad Exp $");
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern void (*__cleanup) __P((void));
|
||||
extern void (*__cleanup)(void);
|
||||
static int aborting = 0;
|
||||
|
||||
void
|
||||
abort()
|
||||
abort(void)
|
||||
{
|
||||
sigset_t mask;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: abs.3,v 1.13 2008/08/04 21:29:27 matt Exp $
|
||||
.\" $NetBSD: abs.3,v 1.14 2011/04/13 06:56:50 jruoho Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -33,44 +33,41 @@
|
||||
.\"
|
||||
.\" from: @(#)abs.3 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Dd June 4, 1993
|
||||
.Dd April 13, 2011
|
||||
.Dt ABS 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm abs
|
||||
.Nd integer absolute value function
|
||||
.Nm abs ,
|
||||
.Nm labs ,
|
||||
.Nm llabs ,
|
||||
.Nm imaxabs
|
||||
.Nd functions for integer absolute value
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In stdlib.h
|
||||
.Ft int
|
||||
.Fn abs "int j"
|
||||
.Fn abs "int x"
|
||||
.Ft long int
|
||||
.Fn labs "long int x"
|
||||
.Ft long long int
|
||||
.Fn llabs "long long int x"
|
||||
.In inttypes.h
|
||||
.Ft intmax_t
|
||||
.Fn imaxabs "intmax_t x"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn abs
|
||||
function
|
||||
computes
|
||||
the absolute value of the integer
|
||||
.Ar j .
|
||||
.Sh RETURN VALUES
|
||||
The
|
||||
.Fn abs
|
||||
function
|
||||
returns
|
||||
the absolute value.
|
||||
These functions return the absolute value of the integer
|
||||
.Fa x .
|
||||
The listed functions differ only with respect
|
||||
to the type of the return value and
|
||||
.Fa x .
|
||||
.Sh SEE ALSO
|
||||
.Xr cabs 3 ,
|
||||
.Xr fabs 3 ,
|
||||
.Xr floor 3 ,
|
||||
.Xr hypot 3 ,
|
||||
.Xr imaxabs 3 ,
|
||||
.Xr labs 3 ,
|
||||
.Xr llabs 3 ,
|
||||
.Xr math 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn abs
|
||||
function conforms to
|
||||
.St -ansiC .
|
||||
The described functions conform to
|
||||
.St -isoC-99 .
|
||||
.Sh BUGS
|
||||
The absolute value of the most negative integer remains negative.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: abs.c,v 1.7 2003/08/07 16:43:37 agc Exp $ */
|
||||
/* $NetBSD: abs.c,v 1.8 2012/06/08 11:15:26 abs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -34,15 +34,14 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)abs.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: abs.c,v 1.7 2003/08/07 16:43:37 agc Exp $");
|
||||
__RCSID("$NetBSD: abs.c,v 1.8 2012/06/08 11:15:26 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
abs(j)
|
||||
int j;
|
||||
abs(int j)
|
||||
{
|
||||
return(j < 0 ? -j : j);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: alloca.3,v 1.13 2010/05/03 06:11:38 jruoho Exp $
|
||||
.\" $NetBSD: alloca.3,v 1.14 2011/03/21 04:42:50 jruoho 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 May 3, 2010
|
||||
.Dd March 21, 2011
|
||||
.Dt ALLOCA 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -89,7 +89,7 @@ Since
|
||||
modifies the stack at runtime,
|
||||
it causes problems to certain security features.
|
||||
See
|
||||
.Xr security 8
|
||||
.Xr security 7
|
||||
for a discussion.
|
||||
.El
|
||||
.\" .Sh HISTORY
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: atof.c,v 1.12 2003/08/07 16:43:38 agc Exp $ */
|
||||
/* $NetBSD: atof.c,v 1.13 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)atof.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: atof.c,v 1.12 2003/08/07 16:43:38 agc Exp $");
|
||||
__RCSID("$NetBSD: atof.c,v 1.13 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -42,8 +42,7 @@ __RCSID("$NetBSD: atof.c,v 1.12 2003/08/07 16:43:38 agc Exp $");
|
||||
#include <stdlib.h>
|
||||
|
||||
double
|
||||
atof(ascii)
|
||||
const char *ascii;
|
||||
atof(const char *ascii)
|
||||
{
|
||||
_DIAGASSERT(ascii != NULL);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: atoi.c,v 1.11 2003/08/07 16:43:38 agc Exp $ */
|
||||
/* $NetBSD: atoi.c,v 1.12 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)atoi.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: atoi.c,v 1.11 2003/08/07 16:43:38 agc Exp $");
|
||||
__RCSID("$NetBSD: atoi.c,v 1.12 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -42,8 +42,7 @@ __RCSID("$NetBSD: atoi.c,v 1.11 2003/08/07 16:43:38 agc Exp $");
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
atoi(str)
|
||||
const char *str;
|
||||
atoi(const char *str)
|
||||
{
|
||||
_DIAGASSERT(str != NULL);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: atol.c,v 1.10 2003/08/07 16:43:38 agc Exp $ */
|
||||
/* $NetBSD: atol.c,v 1.11 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)atol.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: atol.c,v 1.10 2003/08/07 16:43:38 agc Exp $");
|
||||
__RCSID("$NetBSD: atol.c,v 1.11 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -42,8 +42,7 @@ __RCSID("$NetBSD: atol.c,v 1.10 2003/08/07 16:43:38 agc Exp $");
|
||||
#include <stdlib.h>
|
||||
|
||||
long
|
||||
atol(str)
|
||||
const char *str;
|
||||
atol(const char *str)
|
||||
{
|
||||
_DIAGASSERT(str != NULL);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: atoll.c,v 1.5 2003/10/27 00:12:42 lukem Exp $ */
|
||||
/* $NetBSD: atoll.c,v 1.6 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1993
|
||||
@@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)atol.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: atoll.c,v 1.5 2003/10/27 00:12:42 lukem Exp $");
|
||||
__RCSID("$NetBSD: atoll.c,v 1.6 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -57,8 +57,7 @@ __weak_alias(atoll, _atoll)
|
||||
#if !HAVE_ATOLL
|
||||
/* LONGLONG */
|
||||
long long int
|
||||
atoll(str)
|
||||
const char *str;
|
||||
atoll(const char *str)
|
||||
{
|
||||
return (strtoll(str, (char **)NULL, 10));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bsearch.c,v 1.14 2010/11/27 18:33:54 christos Exp $ */
|
||||
/* $NetBSD: bsearch.c,v 1.15 2012/03/04 20:01:45 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)bsearch.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: bsearch.c,v 1.14 2010/11/27 18:33:54 christos Exp $");
|
||||
__RCSID("$NetBSD: bsearch.c,v 1.15 2012/03/04 20:01:45 christos Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -68,7 +68,7 @@ bsearch(const void *key, const void *base0, size_t nmemb, size_t size,
|
||||
const void *p;
|
||||
|
||||
_DIAGASSERT(key != NULL);
|
||||
_DIAGASSERT(base0 != NULL);
|
||||
_DIAGASSERT(base0 != NULL || nmemb == 0);
|
||||
_DIAGASSERT(compar != NULL);
|
||||
|
||||
for (lim = nmemb; lim != 0; lim >>= 1) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: div.3,v 1.12 2008/08/04 21:29:27 matt Exp $
|
||||
.\" $NetBSD: div.3,v 1.14 2011/05/03 09:36:24 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -31,41 +31,57 @@
|
||||
.\"
|
||||
.\" from: @(#)div.3 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Dd June 4, 1993
|
||||
.Dd April 13, 2011
|
||||
.Dt DIV 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm div
|
||||
.Nd return quotient and remainder from division
|
||||
.Nm div ,
|
||||
.Nm ldiv ,
|
||||
.Nm lldiv ,
|
||||
.Nm imaxdiv
|
||||
.Nd quotient and remainder from division
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In stdlib.h
|
||||
.Ft div_t
|
||||
.Fn div "int num" "int denom"
|
||||
.Ft ldiv_t
|
||||
.Fn ldiv "long int num" "long int denom"
|
||||
.Ft lldiv_t
|
||||
.Fn lldiv "long long int num" "long long int denom"
|
||||
.In inttypes.h
|
||||
.Ft imaxdiv_t
|
||||
.Fn imaxdiv "intmax_t num" "intmax_t denom"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn div
|
||||
function
|
||||
computes the value
|
||||
.Fa num/denom
|
||||
and returns the quotient and remainder in a structure named
|
||||
.Fa div_t
|
||||
that contains two
|
||||
.Em int
|
||||
members named
|
||||
.Fa quot
|
||||
These functions compute the value of
|
||||
.Fa num / denom
|
||||
and return the quotient and remainder in a specific divison structure.
|
||||
The functions differ only with respect to the type of the return value and
|
||||
the parameters.
|
||||
.Pp
|
||||
The returned structure always contains two members named
|
||||
.Vt quot
|
||||
and
|
||||
.Fa rem .
|
||||
.Vt rem ,
|
||||
denoting the quotient and the remainder.
|
||||
The type of these correspond with the underlying type of the function.
|
||||
.Sh EXAMPLES
|
||||
The following example demonstrate the basic usage of the functions.
|
||||
.Bd -literal -offset indent
|
||||
div_t d;
|
||||
|
||||
int a = 4321;
|
||||
int b = 1234;
|
||||
|
||||
d = div(a, b);
|
||||
|
||||
(void)printf("%d %d\en", d.quot, d.rem);
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr imaxdiv 3 ,
|
||||
.Xr ldiv 3 ,
|
||||
.Xr lldiv 3 ,
|
||||
.Xr fast_divide32 3 ,
|
||||
.Xr math 3 ,
|
||||
.Xr qdiv 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn div
|
||||
function
|
||||
conforms to
|
||||
.St -ansiC .
|
||||
All described functions conform to
|
||||
.St -isoC-99 .
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: div.c,v 1.7 2003/08/07 16:43:39 agc Exp $ */
|
||||
/* $NetBSD: div.c,v 1.8 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -37,15 +37,14 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)div.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: div.c,v 1.7 2003/08/07 16:43:39 agc Exp $");
|
||||
__RCSID("$NetBSD: div.c,v 1.8 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdlib.h> /* div_t */
|
||||
|
||||
div_t
|
||||
div(num, denom)
|
||||
int num, denom;
|
||||
div(int num, int denom)
|
||||
{
|
||||
div_t r;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: exit.3,v 1.14 2003/08/07 16:43:39 agc Exp $
|
||||
.\" $NetBSD: exit.3,v 1.15 2012/01/02 15:55:29 dholland Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -33,7 +33,7 @@
|
||||
.\"
|
||||
.\" from: @(#)exit.3 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Dd August 11, 2002
|
||||
.Dd January 2, 2012
|
||||
.Dt EXIT 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -78,11 +78,19 @@ Following this,
|
||||
.Fn exit
|
||||
calls
|
||||
.Xr _exit 2 .
|
||||
Note that typically
|
||||
.Xr _exit 2
|
||||
only passes the lower 8 bits of
|
||||
.Sh RESTRICTIONS
|
||||
Standard C guarantees only that the values zero,
|
||||
.Dv EXIT_SUCCESS ,
|
||||
and
|
||||
.Dv EXIT_FAILURE
|
||||
produce meaningful results.
|
||||
POSIX extends this to guarantee that the
|
||||
least significant 8 bits of
|
||||
.Fa status
|
||||
on to the parent, thus negative values have less meaning.
|
||||
are preserved and returned to the parent via
|
||||
.Xr wait 2 .
|
||||
Values outside the supported range 0-255 are bitwise-truncated; therefore,
|
||||
negative values should not be used.
|
||||
.Sh RETURN VALUES
|
||||
The
|
||||
.Fn exit
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: exit.c,v 1.13 2010/09/09 10:19:31 skrll Exp $ */
|
||||
/* $NetBSD: exit.c,v 1.15 2011/05/18 19:36:36 dsl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)exit.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: exit.c,v 1.13 2010/09/09 10:19:31 skrll Exp $");
|
||||
__RCSID("$NetBSD: exit.c,v 1.15 2011/05/18 19:36:36 dsl Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -45,14 +45,7 @@ __RCSID("$NetBSD: exit.c,v 1.13 2010/09/09 10:19:31 skrll Exp $");
|
||||
#include "atexit.h"
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
extern void __libc_init(void);
|
||||
#ifndef __lint
|
||||
static void (*force_ref)(void) __used = __libc_init;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void (*__cleanup) __P((void));
|
||||
void (*__cleanup)(void);
|
||||
|
||||
/*
|
||||
* Exit, flushing stdio buffers if necessary.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: getsubopt.c,v 1.8 2004/05/09 19:34:11 kleink Exp $ */
|
||||
/* $NetBSD: getsubopt.c,v 1.9 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)getsubopt.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: getsubopt.c,v 1.8 2004/05/09 19:34:11 kleink Exp $");
|
||||
__RCSID("$NetBSD: getsubopt.c,v 1.9 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -58,9 +58,7 @@ __weak_alias(getsubopt,_getsubopt)
|
||||
char *suboptarg;
|
||||
|
||||
int
|
||||
getsubopt(optionp, tokens, valuep)
|
||||
char **optionp, **valuep;
|
||||
char * const *tokens;
|
||||
getsubopt(char **optionp, char * const *tokens, char **valuep)
|
||||
{
|
||||
int cnt;
|
||||
char *p;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: hcreate.3,v 1.8 2010/05/01 06:18:03 jruoho Exp $
|
||||
.\" $NetBSD: hcreate.3,v 1.10 2011/09/15 09:14:54 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
@@ -27,13 +27,16 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd May 1, 2010
|
||||
.Dd September 14, 2011
|
||||
.Dt HCREATE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm hcreate ,
|
||||
.Nm hcreate_r ,
|
||||
.Nm hdestroy ,
|
||||
.Nm hsearch
|
||||
.Nm hdestroy_r ,
|
||||
.Nm hsearch ,
|
||||
.Nm hsearch_r
|
||||
.Nd manage hash search table
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
@@ -41,16 +44,25 @@
|
||||
.In search.h
|
||||
.Ft int
|
||||
.Fn hcreate "size_t nel"
|
||||
.Ft int
|
||||
.Fn hcreate_r "size_t nel" "struct hsearch_data *table"
|
||||
.Ft void
|
||||
.Fn hdestroy "void"
|
||||
.Ft void
|
||||
.Fn hdestroy_r "struct hsearch_data *table"
|
||||
.Ft ENTRY *
|
||||
.Fn hsearch "ENTRY item" "ACTION action"
|
||||
.Ft int
|
||||
.Fn hsearch_r "ENTRY item" "ACTION action" "ENTRY ** itemp" "struct hsearch_data *table"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn hcreate ,
|
||||
.Fn hdestroy
|
||||
.Fn hcreate_r ,
|
||||
.Fn hdestroy ,
|
||||
.Fn hdestroy_r
|
||||
.Fn hsearch ,
|
||||
and
|
||||
.Fn hsearch
|
||||
.Fn hsearch_r
|
||||
functions manage hash search tables.
|
||||
.Pp
|
||||
The
|
||||
@@ -152,18 +164,46 @@ Typically the comparison
|
||||
.Fa key
|
||||
is allocated by using
|
||||
.Xr strdup 3 .
|
||||
.Pp
|
||||
The
|
||||
.Fn hcreate_r ,
|
||||
.Fn hdestroy_r ,
|
||||
and
|
||||
.Fn hsearch_r
|
||||
functions are re-entrant versions of the above functions that can
|
||||
operate on a table supplied by the user.
|
||||
The
|
||||
.Fn hsearch_r
|
||||
function returns
|
||||
.Dv 0
|
||||
if the action is
|
||||
.Dv ENTER
|
||||
and the element cannot be created,
|
||||
.Dv 1
|
||||
otherwise.
|
||||
If the element exists or can be created, it will be placed in
|
||||
.Fa itemp ,
|
||||
otherwise
|
||||
.Fa itemp
|
||||
will be set to
|
||||
.Dv NULL .
|
||||
.Sh RETURN VALUES
|
||||
If successful, the
|
||||
.Fn hcreate
|
||||
function returns a non-zero value.
|
||||
Otherwise, a value of 0 is returned and
|
||||
and
|
||||
.Fn hcreate_r
|
||||
functions return a non-zero value.
|
||||
Otherwise, a value of
|
||||
.Dv 0
|
||||
is returned and
|
||||
.Va errno
|
||||
is set to indicate the error.
|
||||
.Pp
|
||||
The
|
||||
.Fn hdestroy
|
||||
functions
|
||||
returns no value.
|
||||
and
|
||||
.Fn hdestroy_r
|
||||
functions return no value.
|
||||
.Pp
|
||||
If successful, the
|
||||
.Fn hsearch
|
||||
@@ -182,16 +222,46 @@ If the action is
|
||||
.Dv ENTER
|
||||
and an entry already existed in the table matching the given
|
||||
key, the existing entry is returned and is not replaced.
|
||||
.Pp
|
||||
The
|
||||
.Fn hsearch_r
|
||||
function returns
|
||||
.Dv 1
|
||||
unless the table is full, when it returns
|
||||
.Dv 0 .
|
||||
If
|
||||
.Fn hsearch
|
||||
returns
|
||||
.Dv 0
|
||||
or the element is not found,
|
||||
.Va errno
|
||||
is set to indicate the error.
|
||||
.Sh ERRORS
|
||||
The
|
||||
.Fn hcreate
|
||||
and
|
||||
.Fn hcreate ,
|
||||
.Fn hcreate_r ,
|
||||
.Fn hsearch
|
||||
and
|
||||
.Fn hsearch_r
|
||||
functions will fail if:
|
||||
.Bl -tag -width Er
|
||||
.It Bq Er ENOMEM
|
||||
Insufficient memory is available.
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
.Fn hsearch
|
||||
and
|
||||
.Fn hsearch_r
|
||||
functions will also fail if the action is
|
||||
.Dv SEARCH
|
||||
and the element is not found:
|
||||
.Bl -tag -width Er
|
||||
.It Bq Er ESRCH
|
||||
The
|
||||
.Fa item
|
||||
given is not found.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr bsearch 3 ,
|
||||
.Xr lsearch 3 ,
|
||||
@@ -213,11 +283,21 @@ and
|
||||
.Fn hsearch
|
||||
functions first appeared in
|
||||
.At V .
|
||||
The
|
||||
.Fn hcreate_r ,
|
||||
.Fn hdestroy_r
|
||||
and
|
||||
.Fn hsearch_r
|
||||
functions are
|
||||
.Tn GNU
|
||||
extensions.
|
||||
.Sh CAVEATS
|
||||
At least the following limitations can be mentioned:
|
||||
.Bl -bullet
|
||||
.It
|
||||
The interface permits the use of only one hash table at a time.
|
||||
The original,
|
||||
.Pf non- Tn GNU
|
||||
interface permits the use of only one hash table at a time.
|
||||
.It
|
||||
Individual hash table entries can be added, but not deleted.
|
||||
.It
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: hcreate.c,v 1.6 2008/07/21 12:05:43 lukem Exp $ */
|
||||
/* $NetBSD: hcreate.c,v 1.8 2011/09/17 16:54:39 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Christopher G. Demetriou
|
||||
@@ -12,12 +12,7 @@
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed for the
|
||||
* NetBSD Project. See http://www.NetBSD.org/ for
|
||||
* information about NetBSD.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
@@ -48,7 +43,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: hcreate.c,v 1.6 2008/07/21 12:05:43 lukem Exp $");
|
||||
__RCSID("$NetBSD: hcreate.c,v 1.8 2011/09/17 16:54:39 christos Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#if !defined(lint)
|
||||
@@ -88,21 +83,28 @@ SLIST_HEAD(internal_head, internal_entry);
|
||||
/* Default hash function, from db/hash/hash_func.c */
|
||||
extern u_int32_t (*__default_hash)(const void *, size_t);
|
||||
|
||||
static struct internal_head *htable;
|
||||
static size_t htablesize;
|
||||
static struct hsearch_data htable;
|
||||
|
||||
int
|
||||
hcreate(size_t nel)
|
||||
{
|
||||
size_t idx;
|
||||
unsigned int p2;
|
||||
_DIAGASSERT(htable.table == NULL);
|
||||
|
||||
/* Make sure this isn't called when a table already exists. */
|
||||
_DIAGASSERT(htable == NULL);
|
||||
if (htable != NULL) {
|
||||
if (htable.table != NULL) {
|
||||
errno = EINVAL;
|
||||
return 0;
|
||||
}
|
||||
return hcreate_r(nel, &htable);
|
||||
}
|
||||
|
||||
int
|
||||
hcreate_r(size_t nel, struct hsearch_data *head)
|
||||
{
|
||||
struct internal_head *table;
|
||||
size_t idx;
|
||||
unsigned int p2;
|
||||
void *p;
|
||||
|
||||
/* If nel is too small, make it min sized. */
|
||||
if (nel < MIN_BUCKETS)
|
||||
@@ -121,76 +123,108 @@ hcreate(size_t nel)
|
||||
}
|
||||
|
||||
/* Allocate the table. */
|
||||
htablesize = nel;
|
||||
htable = malloc(htablesize * sizeof htable[0]);
|
||||
if (htable == NULL) {
|
||||
head->size = nel;
|
||||
head->filled = 0;
|
||||
p = malloc(nel * sizeof table[0]);
|
||||
if (p == NULL) {
|
||||
errno = ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
head->table = p;
|
||||
table = p;
|
||||
|
||||
/* Initialize it. */
|
||||
for (idx = 0; idx < htablesize; idx++)
|
||||
SLIST_INIT(&htable[idx]);
|
||||
for (idx = 0; idx < nel; idx++)
|
||||
SLIST_INIT(&table[idx]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
hdestroy(void)
|
||||
{
|
||||
_DIAGASSERT(htable.table != NULL);
|
||||
hdestroy_r(&htable);
|
||||
}
|
||||
|
||||
void
|
||||
hdestroy_r(struct hsearch_data *head)
|
||||
{
|
||||
struct internal_entry *ie;
|
||||
size_t idx;
|
||||
void *p;
|
||||
struct internal_head *table;
|
||||
|
||||
_DIAGASSERT(htable != NULL);
|
||||
if (htable == NULL)
|
||||
if (head == NULL)
|
||||
return;
|
||||
|
||||
for (idx = 0; idx < htablesize; idx++) {
|
||||
while (!SLIST_EMPTY(&htable[idx])) {
|
||||
ie = SLIST_FIRST(&htable[idx]);
|
||||
SLIST_REMOVE_HEAD(&htable[idx], link);
|
||||
p = head->table;
|
||||
head->table = NULL;
|
||||
table = p;
|
||||
|
||||
for (idx = 0; idx < head->size; idx++) {
|
||||
while (!SLIST_EMPTY(&table[idx])) {
|
||||
ie = SLIST_FIRST(&table[idx]);
|
||||
SLIST_REMOVE_HEAD(&table[idx], link);
|
||||
free(ie->ent.key);
|
||||
free(ie);
|
||||
}
|
||||
}
|
||||
free(htable);
|
||||
htable = NULL;
|
||||
free(table);
|
||||
}
|
||||
|
||||
ENTRY *
|
||||
hsearch(ENTRY item, ACTION action)
|
||||
{
|
||||
struct internal_head *head;
|
||||
ENTRY *ep;
|
||||
_DIAGASSERT(htable.table != NULL);
|
||||
(void)hsearch_r(item, action, &ep, &htable);
|
||||
return ep;
|
||||
}
|
||||
|
||||
int
|
||||
hsearch_r(ENTRY item, ACTION action, ENTRY **itemp, struct hsearch_data *head)
|
||||
{
|
||||
struct internal_head *table, *chain;
|
||||
struct internal_entry *ie;
|
||||
uint32_t hashval;
|
||||
size_t len;
|
||||
void *p;
|
||||
|
||||
_DIAGASSERT(htable != NULL);
|
||||
_DIAGASSERT(item.key != NULL);
|
||||
_DIAGASSERT(action == ENTER || action == FIND);
|
||||
|
||||
p = head->table;
|
||||
table = p;
|
||||
|
||||
len = strlen(item.key);
|
||||
hashval = (*__default_hash)(item.key, len);
|
||||
|
||||
head = &htable[hashval & (htablesize - 1)];
|
||||
ie = SLIST_FIRST(head);
|
||||
chain = &table[hashval & (head->size - 1)];
|
||||
ie = SLIST_FIRST(chain);
|
||||
while (ie != NULL) {
|
||||
if (strcmp(ie->ent.key, item.key) == 0)
|
||||
break;
|
||||
ie = SLIST_NEXT(ie, link);
|
||||
}
|
||||
|
||||
if (ie != NULL)
|
||||
return &ie->ent;
|
||||
else if (action == FIND)
|
||||
return NULL;
|
||||
if (ie != NULL) {
|
||||
*itemp = &ie->ent;
|
||||
return 1;
|
||||
} else if (action == FIND) {
|
||||
*itemp = NULL;
|
||||
errno = ESRCH;
|
||||
return 1;
|
||||
}
|
||||
|
||||
ie = malloc(sizeof *ie);
|
||||
if (ie == NULL)
|
||||
return NULL;
|
||||
return 0;
|
||||
ie->ent.key = item.key;
|
||||
ie->ent.data = item.data;
|
||||
|
||||
SLIST_INSERT_HEAD(head, ie, link);
|
||||
return &ie->ent;
|
||||
SLIST_INSERT_HEAD(chain, ie, link);
|
||||
*itemp = &ie->ent;
|
||||
head->filled++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
.\" $NetBSD: imaxabs.3,v 1.2 2010/03/21 13:39:51 jruoho Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to Berkeley by
|
||||
.\" the American National Standards Committee X3, on Information
|
||||
.\" Processing Systems.
|
||||
.\"
|
||||
.\" 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.
|
||||
.\" 3. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
.\"
|
||||
.\" from: @(#)labs.3 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Dd March 6, 2000
|
||||
.Dt IMAXABS 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm imaxabs
|
||||
.Nd return the absolute value of a imaxint_t
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In inttypes.h
|
||||
.Ft intmax_t
|
||||
.Fn imaxabs "intmax_t i"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn imaxabs
|
||||
function
|
||||
returns the absolute value of the
|
||||
.Vt imaxint_t
|
||||
integer
|
||||
.Ar j .
|
||||
.Sh SEE ALSO
|
||||
.Xr abs 3 ,
|
||||
.Xr cabs 3 ,
|
||||
.Xr floor 3 ,
|
||||
.Xr labs 3 ,
|
||||
.Xr llabs 3 ,
|
||||
.Xr math 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn imaxabs
|
||||
function
|
||||
conforms to
|
||||
.St -isoC-99 .
|
||||
.Sh BUGS
|
||||
The absolute value of the most negative integer remains negative.
|
||||
@@ -1,75 +0,0 @@
|
||||
.\" $NetBSD: imaxdiv.3,v 1.1 2008/08/04 21:29:27 matt Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to Berkeley by
|
||||
.\" Chris Torek and the American National Standards Committee X3,
|
||||
.\" on Information Processing Systems.
|
||||
.\"
|
||||
.\" 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.
|
||||
.\" 3. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
.\"
|
||||
.\" from: @(#)ldiv.3 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Dd March 6, 2000
|
||||
.Dt IMAXDIV 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm imaxdiv
|
||||
.Nd return quotient and remainder from division
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In inttypes.h
|
||||
.Ft imaxdiv_t
|
||||
.Fn imaxdiv "intmax_t num" "intmax_t denom"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn imaxdiv
|
||||
function
|
||||
divides
|
||||
.Ar num
|
||||
by
|
||||
.Ar denom
|
||||
and returns the resulting quotient and remainder in a structure named
|
||||
.Ar imaxdiv_t
|
||||
that contains two
|
||||
.Em imaxint_t
|
||||
members named
|
||||
.Ar quot
|
||||
and
|
||||
.Ar rem .
|
||||
.Sh SEE ALSO
|
||||
.Xr div 3 ,
|
||||
.Xr ldiv 3 ,
|
||||
.Xr lldiv 3 ,
|
||||
.Xr math 3 ,
|
||||
.Xr qdiv 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn imaxdiv
|
||||
function
|
||||
conforms to
|
||||
.St -isoC-99 .
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: insque.c,v 1.2 2005/07/06 17:17:15 drochner Exp $");
|
||||
__RCSID("$NetBSD: insque.c,v 1.3 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <assert.h>
|
||||
@@ -40,9 +40,7 @@ struct qelem {
|
||||
};
|
||||
|
||||
void
|
||||
insque(entry, pred)
|
||||
void *entry;
|
||||
void *pred;
|
||||
insque(void *entry, void *pred)
|
||||
{
|
||||
struct qelem *e = (struct qelem *) entry;
|
||||
struct qelem *p = (struct qelem *) pred;
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
.\" @(#)malloc.3 8.1 (Berkeley) 6/4/93
|
||||
.\" $FreeBSD: src/lib/libc/stdlib/malloc.3,v 1.73 2007/06/15 22:32:33 jasone Exp $
|
||||
.\"
|
||||
.Dd May 14, 2010
|
||||
.Os
|
||||
.Dd June 21, 2011
|
||||
.Dt JEMALLOC 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm jemalloc
|
||||
.Nd the default system allocator
|
||||
@@ -172,8 +172,11 @@ does not zero memory that was previously allocated.
|
||||
This is intended for debugging and will impact performance negatively.
|
||||
.El
|
||||
.Pp
|
||||
Extra care should be taken when enabling
|
||||
any of the options in production environments.
|
||||
The
|
||||
.Em J
|
||||
.Em A ,
|
||||
.Em J ,
|
||||
and
|
||||
.Em Z
|
||||
options are intended for testing and debugging.
|
||||
@@ -291,6 +294,28 @@ the performance impact for storing such information would be prohibitive.
|
||||
There are a number of allocator implementations available on the Internet
|
||||
which focus on detecting and pinpointing problems by trading performance for
|
||||
extra sanity checks and detailed diagnostics.
|
||||
.Sh ENVIRONMENT
|
||||
The following environment variables affect the execution of the allocation
|
||||
functions:
|
||||
.Bl -tag -width ".Ev MALLOC_OPTIONS"
|
||||
.It Ev MALLOC_OPTIONS
|
||||
If the environment variable
|
||||
.Ev MALLOC_OPTIONS
|
||||
is set, the characters it contains will be interpreted as flags to the
|
||||
allocation functions.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
To dump core whenever a problem occurs:
|
||||
.Pp
|
||||
.Bd -literal -offset indent
|
||||
ln -s 'A' /etc/malloc.conf
|
||||
.Ed
|
||||
.Pp
|
||||
To specify in the source that a program does no return value checking
|
||||
on calls to these functions:
|
||||
.Bd -literal -offset indent
|
||||
_malloc_options = "X";
|
||||
.Ed
|
||||
.Sh DIAGNOSTICS
|
||||
If any of the memory allocation/deallocation functions detect an error or
|
||||
warning condition, a message will be printed to file descriptor
|
||||
@@ -316,28 +341,6 @@ this function is likely to result in a crash or deadlock.
|
||||
.Pp
|
||||
All messages are prefixed by
|
||||
.Dq Ao Ar progname Ac Ns Li \&: Pq malloc .
|
||||
.Sh ENVIRONMENT
|
||||
The following environment variables affect the execution of the allocation
|
||||
functions:
|
||||
.Bl -tag -width ".Ev MALLOC_OPTIONS"
|
||||
.It Ev MALLOC_OPTIONS
|
||||
If the environment variable
|
||||
.Ev MALLOC_OPTIONS
|
||||
is set, the characters it contains will be interpreted as flags to the
|
||||
allocation functions.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
To dump core whenever a problem occurs:
|
||||
.Pp
|
||||
.Bd -literal -offset indent
|
||||
ln -s 'A' /etc/malloc.conf
|
||||
.Ed
|
||||
.Pp
|
||||
To specify in the source that a program does no return value checking
|
||||
on calls to these functions:
|
||||
.Bd -literal -offset indent
|
||||
_malloc_options = "X";
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr emalloc 3 ,
|
||||
.Xr malloc 3 ,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: jemalloc.c,v 1.21 2010/03/04 22:48:31 enami Exp $ */
|
||||
/* $NetBSD: jemalloc.c,v 1.28 2012/03/21 14:32:22 christos 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.21 2010/03/04 22:48:31 enami Exp $");
|
||||
__RCSID("$NetBSD: jemalloc.c,v 1.28 2012/03/21 14:32:22 christos Exp $");
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include "libc_private.h"
|
||||
@@ -319,20 +319,25 @@ __strerror_r(int e, char *s, size_t l)
|
||||
#define SMALL_MAX_DEFAULT (1 << SMALL_MAX_2POW_DEFAULT)
|
||||
|
||||
/*
|
||||
* Maximum desired run header overhead. Runs are sized as small as possible
|
||||
* such that this setting is still honored, without violating other constraints.
|
||||
* The goal is to make runs as small as possible without exceeding a per run
|
||||
* external fragmentation threshold.
|
||||
* RUN_MAX_OVRHD indicates maximum desired run header overhead. Runs are sized
|
||||
* as small as possible such that this setting is still honored, without
|
||||
* violating other constraints. The goal is to make runs as small as possible
|
||||
* without exceeding a per run external fragmentation threshold.
|
||||
*
|
||||
* Note that it is possible to set this low enough that it cannot be honored
|
||||
* for some/all object sizes, since there is one bit of header overhead per
|
||||
* object (plus a constant). In such cases, this constraint is relaxed.
|
||||
* We use binary fixed point math for overhead computations, where the binary
|
||||
* point is implicitly RUN_BFP bits to the left.
|
||||
*
|
||||
* RUN_MAX_OVRHD_RELAX specifies the maximum number of bits per region of
|
||||
* overhead for which RUN_MAX_OVRHD is relaxed.
|
||||
* Note that it is possible to set RUN_MAX_OVRHD low enough that it cannot be
|
||||
* honored for some/all object sizes, since there is one bit of header overhead
|
||||
* per object (plus a constant). This constraint is relaxed (ignored) for runs
|
||||
* that are so small that the per-region overhead is greater than:
|
||||
*
|
||||
* (RUN_MAX_OVRHD / (reg_size << (3+RUN_BFP))
|
||||
*/
|
||||
#define RUN_MAX_OVRHD 0.015
|
||||
#define RUN_MAX_OVRHD_RELAX 1.5
|
||||
#define RUN_BFP 12
|
||||
/* \/ Implicit binary fixed point. */
|
||||
#define RUN_MAX_OVRHD 0x0000003dU
|
||||
#define RUN_MAX_OVRHD_RELAX 0x00001800U
|
||||
|
||||
/* Put a cap on small object run size. This overrides RUN_MAX_OVRHD. */
|
||||
#define RUN_MAX_SMALL_2POW 15
|
||||
@@ -811,7 +816,7 @@ static void wrtmessage(const char *p1, const char *p2, const char *p3,
|
||||
#ifdef MALLOC_STATS
|
||||
static void malloc_printf(const char *format, ...);
|
||||
#endif
|
||||
static char *umax2s(uintmax_t x, char *s);
|
||||
static char *size_t2s(size_t x, char *s);
|
||||
static bool base_pages_alloc(size_t minsize);
|
||||
static void *base_alloc(size_t size);
|
||||
static chunk_node_t *base_chunk_node_alloc(void);
|
||||
@@ -973,19 +978,19 @@ malloc_printf(const char *format, ...)
|
||||
|
||||
/*
|
||||
* We don't want to depend on vsnprintf() for production builds, since that can
|
||||
* cause unnecessary bloat for static binaries. umax2s() provides minimal
|
||||
* cause unnecessary bloat for static binaries. size_t2s() provides minimal
|
||||
* integer printing functionality, so that malloc_printf() use can be limited to
|
||||
* MALLOC_STATS code.
|
||||
*/
|
||||
#define UMAX2S_BUFSIZE 21
|
||||
static char *
|
||||
umax2s(uintmax_t x, char *s)
|
||||
size_t2s(size_t x, char *s)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
/* Make sure UMAX2S_BUFSIZE is large enough. */
|
||||
/* LINTED */
|
||||
assert(sizeof(uintmax_t) <= 8);
|
||||
assert(sizeof(size_t) <= 8);
|
||||
|
||||
i = UMAX2S_BUFSIZE - 1;
|
||||
s[i] = '\0';
|
||||
@@ -2143,7 +2148,6 @@ arena_bin_run_size_calc(arena_bin_t *bin, size_t min_run_size)
|
||||
size_t try_run_size, good_run_size;
|
||||
unsigned good_nregs, good_mask_nelms, good_reg0_offset;
|
||||
unsigned try_nregs, try_mask_nelms, try_reg0_offset;
|
||||
float max_ovrhd = RUN_MAX_OVRHD;
|
||||
|
||||
assert(min_run_size >= pagesize);
|
||||
assert(min_run_size <= arena_maxclass);
|
||||
@@ -2161,7 +2165,7 @@ arena_bin_run_size_calc(arena_bin_t *bin, size_t min_run_size)
|
||||
*/
|
||||
try_run_size = min_run_size;
|
||||
try_nregs = (unsigned)(((try_run_size - sizeof(arena_run_t)) /
|
||||
bin->reg_size) + 1); /* Counter-act the first line of the loop. */
|
||||
bin->reg_size) + 1); /* Counter-act try_nregs-- in loop. */
|
||||
do {
|
||||
try_nregs--;
|
||||
try_mask_nelms = (try_nregs >> (SIZEOF_INT_2POW + 3)) +
|
||||
@@ -2195,9 +2199,8 @@ arena_bin_run_size_calc(arena_bin_t *bin, size_t min_run_size)
|
||||
} while (sizeof(arena_run_t) + (sizeof(unsigned) *
|
||||
(try_mask_nelms - 1)) > try_reg0_offset);
|
||||
} while (try_run_size <= arena_maxclass && try_run_size <= RUN_MAX_SMALL
|
||||
&& max_ovrhd > RUN_MAX_OVRHD_RELAX / ((float)(bin->reg_size << 3))
|
||||
&& ((float)(try_reg0_offset)) / ((float)(try_run_size)) >
|
||||
max_ovrhd);
|
||||
&& RUN_MAX_OVRHD * (bin->reg_size << 3) > RUN_MAX_OVRHD_RELAX
|
||||
&& (try_reg0_offset << RUN_BFP) > RUN_MAX_OVRHD * try_run_size);
|
||||
|
||||
assert(sizeof(arena_run_t) + (sizeof(unsigned) * (good_mask_nelms - 1))
|
||||
<= good_reg0_offset);
|
||||
@@ -3215,16 +3218,17 @@ malloc_print_stats(void)
|
||||
opt_xmalloc ? "X" : "x",
|
||||
opt_zero ? "Z\n" : "z\n");
|
||||
|
||||
_malloc_message("CPUs: ", umax2s(ncpus, s), "\n", "");
|
||||
_malloc_message("Max arenas: ", umax2s(narenas, s), "\n", "");
|
||||
_malloc_message("Pointer size: ", umax2s(sizeof(void *), s),
|
||||
_malloc_message("CPUs: ", size_t2s(ncpus, s), "\n", "");
|
||||
_malloc_message("Max arenas: ", size_t2s(narenas, s), "\n", "");
|
||||
_malloc_message("Pointer size: ", size_t2s(sizeof(void *), s),
|
||||
"\n", "");
|
||||
_malloc_message("Quantum size: ", umax2s(quantum, s), "\n", "");
|
||||
_malloc_message("Max small size: ", umax2s(small_max, s), "\n",
|
||||
_malloc_message("Quantum size: ", size_t2s(quantum, s), "\n", "");
|
||||
_malloc_message("Max small size: ", size_t2s(small_max, s), "\n",
|
||||
"");
|
||||
|
||||
_malloc_message("Chunk size: ", umax2s(chunksize, s), "", "");
|
||||
_malloc_message(" (2^", umax2s(opt_chunk_2pow, s), ")\n", "");
|
||||
_malloc_message("Chunk size: ", size_t2s(chunksize, s), "", "");
|
||||
_malloc_message(" (2^", size_t2s((size_t)opt_chunk_2pow, s),
|
||||
")\n", "");
|
||||
|
||||
#ifdef MALLOC_STATS
|
||||
{
|
||||
@@ -3322,6 +3326,7 @@ malloc_init_hard(void)
|
||||
ssize_t linklen;
|
||||
char buf[PATH_MAX + 1];
|
||||
const char *opts = "";
|
||||
int serrno;
|
||||
|
||||
malloc_mutex_lock(&init_lock);
|
||||
if (malloc_initialized) {
|
||||
@@ -3333,6 +3338,7 @@ malloc_init_hard(void)
|
||||
return (false);
|
||||
}
|
||||
|
||||
serrno = errno;
|
||||
/* Get number of CPUs. */
|
||||
{
|
||||
int mib[2];
|
||||
@@ -3512,6 +3518,7 @@ malloc_init_hard(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
errno = serrno;
|
||||
|
||||
/* Take care to call atexit() only once. */
|
||||
if (opt_print_stats) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: l64a.c,v 1.13 2003/07/26 19:24:54 salo Exp $ */
|
||||
/* $NetBSD: l64a.c,v 1.14 2012/03/13 21:13:48 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: l64a.c,v 1.13 2003/07/26 19:24:54 salo Exp $");
|
||||
__RCSID("$NetBSD: l64a.c,v 1.14 2012/03/13 21:13:48 christos Exp $");
|
||||
#endif
|
||||
|
||||
#include "namespace.h"
|
||||
@@ -22,20 +22,16 @@ __weak_alias(l64a_r,_l64a_r)
|
||||
#endif
|
||||
|
||||
char *
|
||||
l64a (value)
|
||||
long value;
|
||||
l64a(long value)
|
||||
{
|
||||
static char buf[8];
|
||||
|
||||
(void)l64a_r(value, buf, sizeof (buf));
|
||||
(void)l64a_r(value, buf, (int)sizeof (buf));
|
||||
return buf;
|
||||
}
|
||||
|
||||
int
|
||||
l64a_r (value, buffer, buflen)
|
||||
long value;
|
||||
char *buffer;
|
||||
int buflen;
|
||||
l64a_r(long value, char *buffer, int buflen)
|
||||
{
|
||||
char *s = buffer;
|
||||
int digit;
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
.\" $NetBSD: labs.3,v 1.11 2008/08/04 21:29:27 matt Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to Berkeley by
|
||||
.\" the American National Standards Committee X3, on Information
|
||||
.\" Processing Systems.
|
||||
.\"
|
||||
.\" 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.
|
||||
.\" 3. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
.\"
|
||||
.\" from: @(#)labs.3 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Dd June 4, 1993
|
||||
.Dt LABS 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm labs
|
||||
.Nd return the absolute value of a long integer
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In stdlib.h
|
||||
.Ft long int
|
||||
.Fn labs "long int j"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn labs
|
||||
function
|
||||
returns the absolute value of the long integer
|
||||
.Ar j .
|
||||
.Sh SEE ALSO
|
||||
.Xr abs 3 ,
|
||||
.Xr cabs 3 ,
|
||||
.Xr floor 3 ,
|
||||
.Xr imaxabs 3 ,
|
||||
.Xr llabs 3 ,
|
||||
.Xr math 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn labs
|
||||
function
|
||||
conforms to
|
||||
.St -ansiC .
|
||||
.Sh BUGS
|
||||
The absolute value of the most negative integer remains negative.
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: labs.c,v 1.7 2003/08/07 16:43:41 agc Exp $ */
|
||||
/* $NetBSD: labs.c,v 1.8 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -34,15 +34,14 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)labs.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: labs.c,v 1.7 2003/08/07 16:43:41 agc Exp $");
|
||||
__RCSID("$NetBSD: labs.c,v 1.8 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
long
|
||||
labs(j)
|
||||
long j;
|
||||
labs(long j)
|
||||
{
|
||||
return(j < 0 ? -j : j);
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
.\" $NetBSD: ldiv.3,v 1.13 2008/08/04 21:29:27 matt Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to Berkeley by
|
||||
.\" Chris Torek and the American National Standards Committee X3,
|
||||
.\" on Information Processing Systems.
|
||||
.\"
|
||||
.\" 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.
|
||||
.\" 3. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
.\"
|
||||
.\" from: @(#)ldiv.3 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Dd June 4, 1993
|
||||
.Dt LDIV 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm ldiv
|
||||
.Nd return quotient and remainder from division
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In stdlib.h
|
||||
.Ft ldiv_t
|
||||
.Fn ldiv "long int num" "long int denom"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn ldiv
|
||||
function
|
||||
computes the value
|
||||
.Ar num/denom
|
||||
and returns the quotient and remainder in a structure named
|
||||
.Ar ldiv_t
|
||||
that contains two
|
||||
.Em long integer
|
||||
members named
|
||||
.Ar quot
|
||||
and
|
||||
.Ar rem .
|
||||
.Sh SEE ALSO
|
||||
.Xr div 3 ,
|
||||
.Xr imaxdiv 3 ,
|
||||
.Xr lldiv 3 ,
|
||||
.Xr math 3 ,
|
||||
.Xr qdiv 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn ldiv
|
||||
function
|
||||
conforms to
|
||||
.St -ansiC .
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ldiv.c,v 1.7 2003/08/07 16:43:41 agc Exp $ */
|
||||
/* $NetBSD: ldiv.c,v 1.8 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -37,15 +37,14 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)ldiv.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: ldiv.c,v 1.7 2003/08/07 16:43:41 agc Exp $");
|
||||
__RCSID("$NetBSD: ldiv.c,v 1.8 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdlib.h> /* ldiv_t */
|
||||
|
||||
ldiv_t
|
||||
ldiv(num, denom)
|
||||
long num, denom;
|
||||
ldiv(long num, long denom)
|
||||
{
|
||||
ldiv_t r;
|
||||
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
.\" $NetBSD: llabs.3,v 1.7 2008/08/04 21:29:27 matt Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to Berkeley by
|
||||
.\" the American National Standards Committee X3, on Information
|
||||
.\" Processing Systems.
|
||||
.\"
|
||||
.\" 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.
|
||||
.\" 3. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
.\"
|
||||
.\" from: @(#)labs.3 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Dd March 6, 2000
|
||||
.Dt LLABS 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm llabs
|
||||
.Nd return the absolute value of a long long integer
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In stdlib.h
|
||||
.Ft long long int
|
||||
.Fn llabs "long long int j"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn llabs
|
||||
function
|
||||
returns the absolute value of the long long integer
|
||||
.Ar j .
|
||||
.Sh SEE ALSO
|
||||
.Xr abs 3 ,
|
||||
.Xr cabs 3 ,
|
||||
.Xr floor 3 ,
|
||||
.Xr imaxabs 3 ,
|
||||
.Xr labs 3 ,
|
||||
.Xr math 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn llabs
|
||||
function
|
||||
conforms to
|
||||
.St -isoC-99 .
|
||||
.Sh BUGS
|
||||
The absolute value of the most negative integer remains negative.
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: llabs.c,v 1.3 2003/08/07 16:43:41 agc Exp $ */
|
||||
/* $NetBSD: llabs.c,v 1.4 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)labs.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: llabs.c,v 1.3 2003/08/07 16:43:41 agc Exp $");
|
||||
__RCSID("$NetBSD: llabs.c,v 1.4 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -47,8 +47,7 @@ __weak_alias(llabs, _llabs)
|
||||
|
||||
/* LONGLONG */
|
||||
long long int
|
||||
llabs(j)
|
||||
long long int j;
|
||||
llabs(long long int j)
|
||||
{
|
||||
return (j < 0 ? -j : j);
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
.\" $NetBSD: lldiv.3,v 1.7 2008/08/04 21:29:27 matt Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to Berkeley by
|
||||
.\" Chris Torek and the American National Standards Committee X3,
|
||||
.\" on Information Processing Systems.
|
||||
.\"
|
||||
.\" 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.
|
||||
.\" 3. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
.\"
|
||||
.\" from: @(#)ldiv.3 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Dd March 6, 2000
|
||||
.Dt LLDIV 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm lldiv
|
||||
.Nd return quotient and remainder from division
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In stdlib.h
|
||||
.Ft lldiv_t
|
||||
.Fn lldiv "long long int num" "long long int denom"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn lldiv
|
||||
function
|
||||
computes the value
|
||||
.Ar num/denom
|
||||
and returns the quotient and remainder in a structure named
|
||||
.Ar lldiv_t
|
||||
that contains two
|
||||
.Em long long integer
|
||||
members named
|
||||
.Ar quot
|
||||
and
|
||||
.Ar rem .
|
||||
.Sh SEE ALSO
|
||||
.Xr div 3 ,
|
||||
.Xr imaxdiv 3 ,
|
||||
.Xr ldiv 3 ,
|
||||
.Xr math 3 ,
|
||||
.Xr qdiv 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn lldiv
|
||||
function
|
||||
conforms to
|
||||
.St -isoC-99 .
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lldiv.c,v 1.3 2003/08/07 16:43:41 agc Exp $ */
|
||||
/* $NetBSD: lldiv.c,v 1.4 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)ldiv.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lldiv.c,v 1.3 2003/08/07 16:43:41 agc Exp $");
|
||||
__RCSID("$NetBSD: lldiv.c,v 1.4 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -50,8 +50,7 @@ __weak_alias(lldiv, _lldiv)
|
||||
|
||||
/* LONGLONG */
|
||||
lldiv_t
|
||||
lldiv(num, denom)
|
||||
long long int num, denom;
|
||||
lldiv(long long int num, long long int denom)
|
||||
{
|
||||
lldiv_t r;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lsearch.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lsearch.c,v 1.4 2005/07/16 17:32:09 christos Exp $");
|
||||
__RCSID("$NetBSD: lsearch.c,v 1.7 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -46,16 +46,13 @@ __RCSID("$NetBSD: lsearch.c,v 1.4 2005/07/16 17:32:09 christos Exp $");
|
||||
#include <string.h>
|
||||
#include <search.h>
|
||||
|
||||
typedef int (*cmp_fn_t) __P((const void *, const void *));
|
||||
static void *linear_base __P((const void *, void *, size_t *, size_t,
|
||||
cmp_fn_t, int));
|
||||
typedef int (*cmp_fn_t)(const void *, const void *);
|
||||
static void *linear_base(const void *, void *, size_t *, size_t,
|
||||
cmp_fn_t, int);
|
||||
|
||||
void *
|
||||
lsearch(key, base, nelp, width, compar)
|
||||
const void *key;
|
||||
void *base;
|
||||
size_t *nelp, width;
|
||||
cmp_fn_t compar;
|
||||
lsearch(const void *key, void *base, size_t *nelp, size_t width,
|
||||
cmp_fn_t compar)
|
||||
{
|
||||
|
||||
_DIAGASSERT(key != NULL);
|
||||
@@ -66,10 +63,8 @@ lsearch(key, base, nelp, width, compar)
|
||||
}
|
||||
|
||||
void *
|
||||
lfind(key, base, nelp, width, compar)
|
||||
const void *key, *base;
|
||||
size_t *nelp, width;
|
||||
cmp_fn_t compar;
|
||||
lfind(const void *key, const void *base, size_t *nelp, size_t width,
|
||||
cmp_fn_t compar)
|
||||
{
|
||||
|
||||
_DIAGASSERT(key != NULL);
|
||||
@@ -80,12 +75,8 @@ lfind(key, base, nelp, width, compar)
|
||||
}
|
||||
|
||||
static void *
|
||||
linear_base(key, base, nelp, width, compar, add_flag)
|
||||
const void *key;
|
||||
void *base;
|
||||
size_t *nelp, width;
|
||||
cmp_fn_t compar;
|
||||
int add_flag;
|
||||
linear_base(const void *key, void *base, size_t *nelp, size_t width,
|
||||
cmp_fn_t compar, int add_flag)
|
||||
{
|
||||
char *element, *end;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: malloc.c,v 1.52 2008/02/03 22:56:53 christos Exp $ */
|
||||
/* $NetBSD: malloc.c,v 1.54 2011/05/18 01:59:39 christos Exp $ */
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
@@ -76,10 +76,8 @@
|
||||
# define malloc_pageshift 12U
|
||||
# define malloc_minsize 16U
|
||||
# endif
|
||||
#ifndef __minix
|
||||
# define HAS_UTRACE
|
||||
# define UTRACE_LABEL
|
||||
#endif /* __minix */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
void utrace(struct ut *, int);
|
||||
@@ -102,8 +100,6 @@ void utrace(struct ut *, int);
|
||||
#undef minix_mmap
|
||||
#undef minix_munmap
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#if defined(__NetBSD__)
|
||||
# define malloc_minsize 16U
|
||||
@@ -112,7 +108,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.52 2008/02/03 22:56:53 christos Exp $");
|
||||
__RCSID("$NetBSD: malloc.c,v 1.54 2011/05/18 01:59:39 christos Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
int utrace(const char *, void *, size_t);
|
||||
|
||||
@@ -469,12 +465,14 @@ extend_pgdir(size_t idx)
|
||||
static void
|
||||
malloc_init(void)
|
||||
{
|
||||
int save_errno = errno;
|
||||
#ifndef MALLOC_NO_SYSCALLS
|
||||
const char *p;
|
||||
char b[64];
|
||||
size_t i;
|
||||
ssize_t j;
|
||||
#endif
|
||||
int serrno = errno;
|
||||
#ifndef MALLOC_NO_SYSCALLS
|
||||
|
||||
/*
|
||||
* Compute page-size related variables.
|
||||
@@ -499,7 +497,7 @@ malloc_init(void)
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (i == 0) {
|
||||
j = readlink("/etc/malloc.conf", b, sizeof b - 1);
|
||||
if (j <= 0)
|
||||
if (j == -1)
|
||||
continue;
|
||||
b[j] = '\0';
|
||||
p = b;
|
||||
@@ -581,7 +579,7 @@ malloc_init(void)
|
||||
*/
|
||||
px = imalloc(sizeof *px);
|
||||
|
||||
errno = save_errno;
|
||||
errno = serrno;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1039,7 +1037,7 @@ free_pages(void *ptr, size_t idx, struct pginfo *info)
|
||||
pf->size > malloc_cache && /* ..and the cache is full, */
|
||||
pf->end == malloc_brk && /* ..and none behind us, */
|
||||
malloc_brk == sbrk((intptr_t)0)) { /* ..and it's OK to do... */
|
||||
int r;
|
||||
|
||||
/*
|
||||
* Keep the cache intact. Notice that the '>' above guarantees that
|
||||
* the pf will always have at least one page afterwards.
|
||||
@@ -1047,8 +1045,7 @@ free_pages(void *ptr, size_t idx, struct pginfo *info)
|
||||
pf->end = (char *)pf->page + malloc_cache;
|
||||
pf->size = malloc_cache;
|
||||
|
||||
r = brk(pf->end);
|
||||
assert(r >= 0);
|
||||
brk(pf->end);
|
||||
malloc_brk = pf->end;
|
||||
|
||||
idx = ptr2idx(pf->end);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: memory.3,v 1.10 2003/08/07 16:43:42 agc Exp $
|
||||
.\" $NetBSD: memory.3,v 1.11 2011/09/11 10:05:23 jruoho Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" from: @(#)memory.3 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Dd June 4, 1993
|
||||
.Dd September 11, 2011
|
||||
.Dt MEMORY 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -57,6 +57,8 @@
|
||||
These functions allocate and free memory for the calling process.
|
||||
They are described in the
|
||||
individual manual pages.
|
||||
The memory allocators used in the kernel are described in
|
||||
.Xr memoryallocators 9 .
|
||||
.Sh SEE ALSO
|
||||
.Xr alloca 3 ,
|
||||
.Xr calloc 3 ,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: merge.c,v 1.12 2009/02/12 03:12:36 lukem Exp $ */
|
||||
/* $NetBSD: merge.c,v 1.14 2012/03/13 21:13:48 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)merge.c 8.2 (Berkeley) 2/14/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: merge.c,v 1.12 2009/02/12 03:12:36 lukem Exp $");
|
||||
__RCSID("$NetBSD: merge.c,v 1.14 2012/03/13 21:13:48 christos Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -67,10 +67,10 @@ __RCSID("$NetBSD: merge.c,v 1.12 2009/02/12 03:12:36 lukem Exp $");
|
||||
__weak_alias(mergesort,_mergesort)
|
||||
#endif
|
||||
|
||||
static void setup __P((u_char *, u_char *, size_t, size_t,
|
||||
int (*)(const void *, const void *)));
|
||||
static void insertionsort __P((u_char *, size_t, size_t,
|
||||
int (*)(const void *, const void *)));
|
||||
static void setup(u_char *, u_char *, size_t, size_t,
|
||||
int (*)(const void *, const void *));
|
||||
static void insertionsort(u_char *, size_t, size_t,
|
||||
int (*)(const void *, const void *));
|
||||
|
||||
#define ISIZE sizeof(int)
|
||||
#define PSIZE sizeof(u_char *)
|
||||
@@ -108,11 +108,8 @@ static void insertionsort __P((u_char *, size_t, size_t,
|
||||
* Arguments are as for qsort.
|
||||
*/
|
||||
int
|
||||
mergesort(base, nmemb, size, cmp)
|
||||
void *base;
|
||||
size_t nmemb;
|
||||
size_t size;
|
||||
int (*cmp) __P((const void *, const void *));
|
||||
mergesort(void *base, size_t nmemb, size_t size,
|
||||
int (*cmp)(const void *, const void *))
|
||||
{
|
||||
size_t i;
|
||||
int sense;
|
||||
@@ -281,13 +278,12 @@ COPY: b = t;
|
||||
|
||||
/* XXX: shouldn't this function be static? - lukem 990810 */
|
||||
void
|
||||
setup(list1, list2, n, size, cmp)
|
||||
size_t n, size;
|
||||
int (*cmp) __P((const void *, const void *));
|
||||
u_char *list1, *list2;
|
||||
setup(u_char *list1, u_char *list2, size_t n, size_t size,
|
||||
int (*cmp)(const void *, const void *))
|
||||
{
|
||||
int i, length, size2, tmp, sense;
|
||||
int length, tmp, sense;
|
||||
u_char *f1, *f2, *s, *l2, *last, *p2;
|
||||
size_t size2, i;
|
||||
|
||||
_DIAGASSERT(cmp != NULL);
|
||||
_DIAGASSERT(list1 != NULL);
|
||||
@@ -304,7 +300,7 @@ setup(list1, list2, n, size, cmp)
|
||||
* for simplicity.
|
||||
*/
|
||||
i = 4 + (n & 1);
|
||||
insertionsort(list1 + (n - i) * size, (size_t)i, size, cmp);
|
||||
insertionsort(list1 + (n - i) * size, i, size, cmp);
|
||||
last = list1 + size * (n - i);
|
||||
*EVAL(list2 + (last - list1)) = list2 + n * size;
|
||||
|
||||
@@ -332,12 +328,12 @@ setup(list1, list2, n, size, cmp)
|
||||
if ((cmp(f2-size, f2) > 0) != sense) {
|
||||
p2 = *EVAL(p2) = f2 - list1 + list2;
|
||||
if (sense > 0)
|
||||
reverse(f1, f2-size);
|
||||
reverse(f1, f2 - size);
|
||||
f1 = f2;
|
||||
}
|
||||
}
|
||||
if (sense > 0)
|
||||
reverse (f1, f2-size);
|
||||
reverse(f1, f2 - size);
|
||||
f1 = f2;
|
||||
if (f2 < last || cmp(f2 - size, f2) > 0)
|
||||
p2 = *EVAL(p2) = f2 - list1 + list2;
|
||||
@@ -359,13 +355,11 @@ setup(list1, list2, n, size, cmp)
|
||||
* last 4 elements.
|
||||
*/
|
||||
static void
|
||||
insertionsort(a, n, size, cmp)
|
||||
u_char *a;
|
||||
size_t n, size;
|
||||
int (*cmp) __P((const void *, const void *));
|
||||
insertionsort(u_char *a, size_t n, size_t size,
|
||||
int (*cmp)(const void *, const void *))
|
||||
{
|
||||
u_char *ai, *s, *t, *u, tmp;
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
_DIAGASSERT(a != NULL);
|
||||
_DIAGASSERT(cmp != NULL);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mi_vector_hash.c,v 1.3 2010/03/19 18:11:30 joerg Exp $ */
|
||||
/* $NetBSD: mi_vector_hash.c,v 1.4 2011/10/21 23:45:56 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
@@ -43,11 +43,13 @@
|
||||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: mi_vector_hash.c,v 1.3 2010/03/19 18:11:30 joerg Exp $");
|
||||
__RCSID("$NetBSD: mi_vector_hash.c,v 1.4 2011/10/21 23:45:56 joerg Exp $");
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#if !HAVE_NBTOOL_CONFIG_H || HAVE_SYS_ENDIAN_H
|
||||
#include <sys/endian.h>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: posix_openpt.3,v 1.4 2008/04/30 13:10:51 martin Exp $
|
||||
.\" $NetBSD: posix_openpt.3,v 1.6 2011/05/05 07:36:44 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
@@ -41,9 +41,11 @@
|
||||
.Ft int
|
||||
.Fn posix_openpt "int oflag"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn posix_openpt
|
||||
Searches for an unused master pseudo-terminal device, opens it, and returns
|
||||
a file descriptor associated the now used pseudo-terminal device.
|
||||
function searches for an unused master pseudo-terminal device,
|
||||
opens it, and returns a file descriptor associated with the now
|
||||
used pseudo-terminal device.
|
||||
The
|
||||
.Fa oflag
|
||||
argument has the same meaning as in the
|
||||
|
||||
@@ -51,6 +51,9 @@ __RCSID("$NetBSD: putenv.c,v 1.19 2010/11/14 18:11:43 tron Exp $");
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(putenv,_putenv)
|
||||
#if defined(__minix)
|
||||
__weak_alias(__putenv50,_putenv)
|
||||
#endif /* defined(__minix) */
|
||||
#endif
|
||||
|
||||
int
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: qabs.c,v 1.6 2003/08/07 16:43:42 agc Exp $ */
|
||||
/* $NetBSD: qabs.c,v 1.7 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char *sccsid = "from: @(#)labs.c 5.2 (Berkeley) 5/17/90";
|
||||
#else
|
||||
__RCSID("$NetBSD: qabs.c,v 1.6 2003/08/07 16:43:42 agc Exp $");
|
||||
__RCSID("$NetBSD: qabs.c,v 1.7 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -46,8 +46,7 @@ __weak_alias(qabs,_qabs)
|
||||
#endif
|
||||
|
||||
quad_t
|
||||
qabs(j)
|
||||
quad_t j;
|
||||
qabs(quad_t j)
|
||||
{
|
||||
return(j < 0 ? -j : j);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: qdiv.c,v 1.6 2003/08/07 16:43:42 agc Exp $ */
|
||||
/* $NetBSD: qdiv.c,v 1.7 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990 Regents of the University of California.
|
||||
@@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char *sccsid = "from: @(#)ldiv.c 5.2 (Berkeley) 4/16/91";
|
||||
#else
|
||||
__RCSID("$NetBSD: qdiv.c,v 1.6 2003/08/07 16:43:42 agc Exp $");
|
||||
__RCSID("$NetBSD: qdiv.c,v 1.7 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -49,8 +49,7 @@ __weak_alias(qdiv,_qdiv)
|
||||
#endif
|
||||
|
||||
qdiv_t
|
||||
qdiv(num, denom)
|
||||
quad_t num, denom;
|
||||
qdiv(quad_t num, quad_t denom)
|
||||
{
|
||||
qdiv_t r;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: qsort.c,v 1.20 2009/06/01 06:37:40 yamt Exp $ */
|
||||
/* $NetBSD: qsort.c,v 1.22 2012/05/26 21:47:05 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)qsort.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: qsort.c,v 1.20 2009/06/01 06:37:40 yamt Exp $");
|
||||
__RCSID("$NetBSD: qsort.c,v 1.22 2012/05/26 21:47:05 christos Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -44,9 +44,9 @@ __RCSID("$NetBSD: qsort.c,v 1.20 2009/06/01 06:37:40 yamt Exp $");
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static inline char *med3 __P((char *, char *, char *,
|
||||
int (*)(const void *, const void *)));
|
||||
static inline void swapfunc __P((char *, char *, size_t, int));
|
||||
static inline char *med3(char *, char *, char *,
|
||||
int (*)(const void *, const void *));
|
||||
static inline void swapfunc(char *, char *, size_t, int);
|
||||
|
||||
#define min(a, b) (a) < (b) ? a : b
|
||||
|
||||
@@ -89,7 +89,7 @@ swapfunc(char *a, char *b, size_t n, int swaptype)
|
||||
|
||||
static inline char *
|
||||
med3(char *a, char *b, char *c,
|
||||
int (*cmp) __P((const void *, const void *)))
|
||||
int (*cmp)(const void *, const void *))
|
||||
{
|
||||
|
||||
return cmp(a, b) < 0 ?
|
||||
@@ -99,13 +99,13 @@ med3(char *a, char *b, char *c,
|
||||
|
||||
void
|
||||
qsort(void *a, size_t n, size_t es,
|
||||
int (*cmp) __P((const void *, const void *)))
|
||||
int (*cmp)(const void *, const void *))
|
||||
{
|
||||
char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
|
||||
size_t d, r;
|
||||
int swaptype, cmp_result;
|
||||
|
||||
_DIAGASSERT(a != NULL);
|
||||
_DIAGASSERT(a != NULL || n == 0 || es == 0);
|
||||
_DIAGASSERT(cmp != NULL);
|
||||
|
||||
loop: SWAPINIT(a, es);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rand.c,v 1.10 2003/08/07 16:43:43 agc Exp $ */
|
||||
/* $NetBSD: rand.c,v 1.12 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)rand.c 8.1 (Berkeley) 6/14/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: rand.c,v 1.10 2003/08/07 16:43:43 agc Exp $");
|
||||
__RCSID("$NetBSD: rand.c,v 1.12 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -44,15 +44,14 @@ __RCSID("$NetBSD: rand.c,v 1.10 2003/08/07 16:43:43 agc Exp $");
|
||||
static u_long next = 1;
|
||||
|
||||
int
|
||||
rand()
|
||||
rand(void)
|
||||
{
|
||||
/* LINTED integer overflow */
|
||||
return (int)((next = next * 1103515245 + 12345) % ((u_long)RAND_MAX + 1));
|
||||
}
|
||||
|
||||
void
|
||||
srand(seed)
|
||||
u_int seed;
|
||||
srand(u_int seed)
|
||||
{
|
||||
next = seed;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rand48.h,v 1.5 2006/03/22 20:52:16 drochner Exp $ */
|
||||
/* $NetBSD: rand48.h,v 1.6 2011/05/18 19:36:36 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Martin Birgmeier
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
extern void __dorand48 __P((unsigned short[3]));
|
||||
extern void __dorand48(unsigned short[3]);
|
||||
extern unsigned short __rand48_seed[3];
|
||||
extern unsigned short __rand48_mult[3];
|
||||
extern unsigned short __rand48_add;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rand_r.c,v 1.5 2003/08/07 16:43:43 agc Exp $ */
|
||||
/* $NetBSD: rand_r.c,v 1.6 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char *sccsid = "from: @(#)rand.c 5.6 (Berkeley) 6/24/91";
|
||||
#else
|
||||
__RCSID("$NetBSD: rand_r.c,v 1.5 2003/08/07 16:43:43 agc Exp $");
|
||||
__RCSID("$NetBSD: rand_r.c,v 1.6 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -43,8 +43,7 @@ __RCSID("$NetBSD: rand_r.c,v 1.5 2003/08/07 16:43:43 agc Exp $");
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
rand_r(seed)
|
||||
unsigned int *seed;
|
||||
rand_r(unsigned int *seed)
|
||||
{
|
||||
_DIAGASSERT(seed != NULL);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: random.3,v 1.19 2008/02/28 16:16:35 christos Exp $
|
||||
.\" $NetBSD: random.3,v 1.20 2011/10/15 21:35:49 rmind Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1983, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" from: @(#)random.3 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Dd February 28, 2008
|
||||
.Dd October 15, 2011
|
||||
.Dt RANDOM 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -171,6 +171,15 @@ messages are printed on the standard error output.
|
||||
.Xr srand 3 ,
|
||||
.Xr rnd 4 ,
|
||||
.Xr rnd 9
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn random ,
|
||||
.Fn srandom ,
|
||||
.Fn initstate
|
||||
and
|
||||
.Fn setstate
|
||||
functions conform to
|
||||
.St -p1003.1-2008 .
|
||||
.Sh HISTORY
|
||||
These
|
||||
functions appeared in
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: remque.c,v 1.2 2005/07/06 17:17:15 drochner Exp $");
|
||||
__RCSID("$NetBSD: remque.c,v 1.3 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <assert.h>
|
||||
@@ -40,8 +40,7 @@ struct qelem {
|
||||
};
|
||||
|
||||
void
|
||||
remque(element)
|
||||
void *element;
|
||||
remque(void *element)
|
||||
{
|
||||
struct qelem *e = (struct qelem *) element;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: strfmon.c,v 1.7 2009/01/30 23:46:03 lukem Exp $ */
|
||||
/* $NetBSD: strfmon.c,v 1.10 2012/03/21 14:19:15 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
|
||||
@@ -32,7 +32,7 @@
|
||||
#if 0
|
||||
__FBSDID("$FreeBSD: src/lib/libc/stdlib/strfmon.c,v 1.14 2003/03/20 08:18:55 ache Exp $");
|
||||
#else
|
||||
__RCSID("$NetBSD: strfmon.c,v 1.7 2009/01/30 23:46:03 lukem Exp $");
|
||||
__RCSID("$NetBSD: strfmon.c,v 1.10 2012/03/21 14:19:15 christos Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -42,6 +42,7 @@ __RCSID("$NetBSD: strfmon.c,v 1.7 2009/01/30 23:46:03 lukem Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
@@ -62,6 +63,10 @@ __RCSID("$NetBSD: strfmon.c,v 1.7 2009/01/30 23:46:03 lukem Exp $");
|
||||
#define USE_INTL_CURRENCY 0x40 /* use international currency symbol */
|
||||
#define IS_NEGATIVE 0x80 /* is argument value negative ? */
|
||||
|
||||
#ifndef NBCHAR_MAX
|
||||
#define NBCHAR_MAX ((unsigned char)CHAR_MAX)
|
||||
#endif
|
||||
|
||||
/* internal macros */
|
||||
#define PRINT(CH) do { \
|
||||
if (dst >= s + maxsize) \
|
||||
@@ -376,7 +381,8 @@ strfmon(char * __restrict s, size_t maxsize, const char * __restrict format,
|
||||
while (dst - tmpptr < width)
|
||||
PRINT(' ');
|
||||
} else {
|
||||
pad_size = dst-tmpptr;
|
||||
_DIAGASSERT(__type_fit(int, dst - tmpptr));
|
||||
pad_size = dst - tmpptr;
|
||||
memmove(tmpptr + width-pad_size, tmpptr,
|
||||
(size_t) pad_size);
|
||||
memset(tmpptr, ' ', (size_t) width-pad_size);
|
||||
@@ -441,9 +447,9 @@ __setup_vars(int flags, char *cs_precedes, char *sep_by_space,
|
||||
/* Set defult values for unspecified information. */
|
||||
if (*cs_precedes != 0)
|
||||
*cs_precedes = 1;
|
||||
if (*sep_by_space == CHAR_MAX)
|
||||
if ((unsigned char)*sep_by_space == NBCHAR_MAX)
|
||||
*sep_by_space = 0;
|
||||
if (*sign_posn == CHAR_MAX)
|
||||
if ((unsigned char)*sign_posn == NBCHAR_MAX)
|
||||
*sign_posn = 0;
|
||||
}
|
||||
|
||||
@@ -452,7 +458,7 @@ __calc_left_pad(int flags, char *cur_symb) {
|
||||
|
||||
char cs_precedes, sep_by_space, sign_posn;
|
||||
const char *signstr;
|
||||
int left_chars = 0;
|
||||
size_t left_chars = 0;
|
||||
|
||||
__setup_vars(flags, &cs_precedes, &sep_by_space, &sign_posn, &signstr);
|
||||
|
||||
@@ -471,7 +477,8 @@ __calc_left_pad(int flags, char *cur_symb) {
|
||||
if (cs_precedes != 0)
|
||||
left_chars += strlen(signstr);
|
||||
}
|
||||
return (left_chars);
|
||||
_DIAGASSERT(__type_fit(int, left_chars));
|
||||
return (int)left_chars;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -479,14 +486,14 @@ get_groups(int size, char *grouping) {
|
||||
|
||||
int chars = 0;
|
||||
|
||||
if (*grouping == CHAR_MAX || *grouping <= 0) /* no grouping ? */
|
||||
if ((unsigned char)*grouping == NBCHAR_MAX || *grouping <= 0) /* no grouping ? */
|
||||
return (0);
|
||||
|
||||
while (size > (int)*grouping) {
|
||||
chars++;
|
||||
size -= (int)*grouping++;
|
||||
/* no more grouping ? */
|
||||
if (*grouping == CHAR_MAX)
|
||||
if ((unsigned char)*grouping == NBCHAR_MAX)
|
||||
break;
|
||||
/* rest grouping with same value ? */
|
||||
if (*grouping == 0) {
|
||||
@@ -505,7 +512,6 @@ __format_grouped_double(double value, int *flags,
|
||||
char *rslt;
|
||||
char *avalue;
|
||||
int avalue_size;
|
||||
char fmt[32];
|
||||
|
||||
size_t bufsize;
|
||||
char *bufend;
|
||||
@@ -546,14 +552,13 @@ __format_grouped_double(double value, int *flags,
|
||||
left_prec += get_groups(left_prec, grouping);
|
||||
|
||||
/* convert to string */
|
||||
snprintf(fmt, sizeof(fmt), "%%%d.%df", left_prec + right_prec + 1,
|
||||
right_prec);
|
||||
avalue_size = asprintf(&avalue, fmt, value);
|
||||
avalue_size = asprintf(&avalue, "%*.*f", left_prec + right_prec + 1,
|
||||
right_prec, value);
|
||||
if (avalue_size < 0)
|
||||
return (NULL);
|
||||
|
||||
/* make sure that we've enough space for result string */
|
||||
bufsize = strlen(avalue)*2+1;
|
||||
bufsize = avalue_size * 2 + 1;
|
||||
rslt = malloc(bufsize);
|
||||
if (rslt == NULL) {
|
||||
free(avalue);
|
||||
@@ -577,9 +582,10 @@ __format_grouped_double(double value, int *flags,
|
||||
avalue_size -= (right_prec + 1);
|
||||
}
|
||||
|
||||
/* XXX: Why not use %' instead? */
|
||||
if ((*flags & NEED_GROUPING) &&
|
||||
thousands_sep != '\0' && /* XXX: need investigation */
|
||||
*grouping != CHAR_MAX &&
|
||||
(unsigned char)*grouping != NBCHAR_MAX &&
|
||||
*grouping > 0) {
|
||||
while (avalue_size > (int)*grouping) {
|
||||
GRPCPY(*grouping);
|
||||
@@ -587,7 +593,7 @@ __format_grouped_double(double value, int *flags,
|
||||
grouping++;
|
||||
|
||||
/* no more grouping ? */
|
||||
if (*grouping == CHAR_MAX)
|
||||
if ((unsigned char)*grouping == NBCHAR_MAX)
|
||||
break;
|
||||
|
||||
/* rest grouping with same value ? */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: strsuftoll.c,v 1.8 2008/04/28 20:23:00 martin Exp $ */
|
||||
/* $NetBSD: strsuftoll.c,v 1.9 2011/10/22 22:08:47 christos Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2001-2002,2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
@@ -67,7 +67,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: strsuftoll.c,v 1.8 2008/04/28 20:23:00 martin Exp $");
|
||||
__RCSID("$NetBSD: strsuftoll.c,v 1.9 2011/10/22 22:08:47 christos Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef _LIBC
|
||||
@@ -121,8 +121,8 @@ strsuftoll(const char *desc, const char *val,
|
||||
|
||||
result = strsuftollx(desc, val, min, max, errbuf, sizeof(errbuf));
|
||||
if (*errbuf != '\0')
|
||||
errx(1, "%s", errbuf);
|
||||
return (result);
|
||||
errx(EXIT_FAILURE, "%s", errbuf);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -130,9 +130,9 @@ strsuftoll(const char *desc, const char *val,
|
||||
* rather than exiting with it.
|
||||
*/
|
||||
/* LONGLONG */
|
||||
long long
|
||||
strsuftollx(const char *desc, const char *val,
|
||||
long long min, long long max, char *ebuf, size_t ebuflen)
|
||||
static long long
|
||||
__strsuftollx(const char *desc, const char *val,
|
||||
long long min, long long max, char *ebuf, size_t ebuflen, size_t depth)
|
||||
{
|
||||
long long num, t;
|
||||
char *expr;
|
||||
@@ -141,12 +141,15 @@ strsuftollx(const char *desc, const char *val,
|
||||
_DIAGASSERT(val != NULL);
|
||||
_DIAGASSERT(ebuf != NULL);
|
||||
|
||||
errno = 0;
|
||||
ebuf[0] = '\0';
|
||||
if (depth > 16) {
|
||||
snprintf(ebuf, ebuflen, "%s: Recursion limit exceeded", desc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (isspace((unsigned char)*val)) /* Skip leading space */
|
||||
val++;
|
||||
|
||||
errno = 0;
|
||||
num = strtoll(val, &expr, 10);
|
||||
if (errno == ERANGE)
|
||||
goto erange; /* Overflow */
|
||||
@@ -205,36 +208,42 @@ strsuftollx(const char *desc, const char *val,
|
||||
case '*': /* Backward compatible */
|
||||
case 'x':
|
||||
t = num;
|
||||
num *= strsuftollx(desc, expr + 1, min, max, ebuf, ebuflen);
|
||||
num *= __strsuftollx(desc, expr + 1, min, max, ebuf, ebuflen,
|
||||
depth + 1);
|
||||
if (*ebuf != '\0')
|
||||
return (0);
|
||||
return 0;
|
||||
if (t > num) {
|
||||
erange:
|
||||
snprintf(ebuf, ebuflen,
|
||||
"%s: %s", desc, strerror(ERANGE));
|
||||
return (0);
|
||||
errno = ERANGE;
|
||||
snprintf(ebuf, ebuflen, "%s: %s", desc, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
badnum: snprintf(ebuf, ebuflen,
|
||||
"%s `%s': illegal number", desc, val);
|
||||
return (0);
|
||||
badnum:
|
||||
snprintf(ebuf, ebuflen, "%s `%s': illegal number", desc, val);
|
||||
return 0;
|
||||
}
|
||||
if (num < min) {
|
||||
/* LONGLONG */
|
||||
/* LONGLONG */
|
||||
snprintf(ebuf, ebuflen, "%s %lld is less than %lld.",
|
||||
desc, (long long)num, (long long)min);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
if (num > max) {
|
||||
/* LONGLONG */
|
||||
snprintf(ebuf, ebuflen,
|
||||
"%s %lld is greater than %lld.",
|
||||
/* LONGLONG */
|
||||
snprintf(ebuf, ebuflen, "%s %lld is greater than %lld.",
|
||||
desc, (long long)num, (long long)max);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
*ebuf = '\0';
|
||||
return (num);
|
||||
return num;
|
||||
}
|
||||
|
||||
long long
|
||||
strsuftollx(const char *desc, const char *val,
|
||||
long long min, long long max, char *ebuf, size_t ebuflen)
|
||||
{
|
||||
return __strsuftollx(desc, val, min, max, ebuf, ebuflen, 0);
|
||||
}
|
||||
#endif /* !HAVE_STRSUFTOLL */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: system.c,v 1.23 2010/11/14 18:11:43 tron Exp $ */
|
||||
/* $NetBSD: system.c,v 1.24 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)system.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: system.c,v 1.23 2010/11/14 18:11:43 tron Exp $");
|
||||
__RCSID("$NetBSD: system.c,v 1.24 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@@ -51,8 +51,7 @@ __RCSID("$NetBSD: system.c,v 1.23 2010/11/14 18:11:43 tron Exp $");
|
||||
#include "reentrant.h"
|
||||
|
||||
int
|
||||
system(command)
|
||||
const char *command;
|
||||
system(const char *command)
|
||||
{
|
||||
pid_t pid;
|
||||
struct sigaction intsa, quitsa, sa;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tdelete.c,v 1.4 2006/03/19 01:12:08 christos Exp $ */
|
||||
/* $NetBSD: tdelete.c,v 1.6 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Tree search generalized from Knuth (6.2.2) Algorithm T just like
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: tdelete.c,v 1.4 2006/03/19 01:12:08 christos Exp $");
|
||||
__RCSID("$NetBSD: tdelete.c,v 1.6 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <assert.h>
|
||||
@@ -22,12 +22,10 @@ __RCSID("$NetBSD: tdelete.c,v 1.4 2006/03/19 01:12:08 christos Exp $");
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/* delete node with given key */
|
||||
/* find a node with key "vkey" in tree "vrootp" */
|
||||
void *
|
||||
tdelete(vkey, vrootp, compar)
|
||||
const void *vkey; /* key to be deleted */
|
||||
void **vrootp; /* address of the root of tree */
|
||||
int (*compar) __P((const void *, const void *));
|
||||
tdelete(const void *vkey, void **vrootp,
|
||||
int (*compar)(const void *, const void *))
|
||||
{
|
||||
node_t **rootp = (node_t **)vrootp;
|
||||
node_t *p, *q, *r;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tfind.c,v 1.5 2005/03/23 08:16:53 kleink Exp $ */
|
||||
/* $NetBSD: tfind.c,v 1.7 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Tree search generalized from Knuth (6.2.2) Algorithm T just like
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: tfind.c,v 1.5 2005/03/23 08:16:53 kleink Exp $");
|
||||
__RCSID("$NetBSD: tfind.c,v 1.7 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <assert.h>
|
||||
@@ -21,12 +21,10 @@ __RCSID("$NetBSD: tfind.c,v 1.5 2005/03/23 08:16:53 kleink Exp $");
|
||||
#include <stdlib.h>
|
||||
#include <search.h>
|
||||
|
||||
/* find a node, or return 0 */
|
||||
/* find a node by key "vkey" in tree "vrootp", or return 0 */
|
||||
void *
|
||||
tfind(vkey, vrootp, compar)
|
||||
const void *vkey; /* key to be found */
|
||||
void * const *vrootp; /* address of the tree root */
|
||||
int (*compar) __P((const void *, const void *));
|
||||
tfind(const void *vkey, void * const *vrootp,
|
||||
int (*compar)(const void *, const void *))
|
||||
{
|
||||
node_t * const *rootp = (node_t * const*)vrootp;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tsearch.c,v 1.5 2005/11/29 03:12:00 christos Exp $ */
|
||||
/* $NetBSD: tsearch.c,v 1.7 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*
|
||||
* Tree search generalized from Knuth (6.2.2) Algorithm T just like
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: tsearch.c,v 1.5 2005/11/29 03:12:00 christos Exp $");
|
||||
__RCSID("$NetBSD: tsearch.c,v 1.7 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <assert.h>
|
||||
@@ -23,10 +23,8 @@ __RCSID("$NetBSD: tsearch.c,v 1.5 2005/11/29 03:12:00 christos Exp $");
|
||||
|
||||
/* find or insert datum into search tree */
|
||||
void *
|
||||
tsearch(vkey, vrootp, compar)
|
||||
const void *vkey; /* key to be located */
|
||||
void **vrootp; /* address of tree root */
|
||||
int (*compar) __P((const void *, const void *));
|
||||
tsearch(const void *vkey, void **vrootp,
|
||||
int (*compar)(const void *, const void *))
|
||||
{
|
||||
node_t *q;
|
||||
node_t **rootp = (node_t **)vrootp;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: twalk.c,v 1.2 1999/09/16 11:45:37 lukem Exp $ */
|
||||
/* $NetBSD: twalk.c,v 1.4 2012/03/20 16:38:45 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Tree search generalized from Knuth (6.2.2) Algorithm T just like
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: twalk.c,v 1.2 1999/09/16 11:45:37 lukem Exp $");
|
||||
__RCSID("$NetBSD: twalk.c,v 1.4 2012/03/20 16:38:45 matt Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <assert.h>
|
||||
@@ -21,15 +21,12 @@ __RCSID("$NetBSD: twalk.c,v 1.2 1999/09/16 11:45:37 lukem Exp $");
|
||||
#include <search.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void trecurse __P((const node_t *,
|
||||
void (*action)(const void *, VISIT, int), int level));
|
||||
typedef void (*cmp_fn_t)(const void *, VISIT, int);
|
||||
|
||||
/* Walk the nodes of a tree */
|
||||
static void
|
||||
trecurse(root, action, level)
|
||||
const node_t *root; /* Root of the tree to be walked */
|
||||
void (*action) __P((const void *, VISIT, int));
|
||||
int level;
|
||||
trecurse(const node_t *root, /* Root of the tree to be walked */
|
||||
cmp_fn_t action, int level)
|
||||
{
|
||||
_DIAGASSERT(root != NULL);
|
||||
_DIAGASSERT(action != NULL);
|
||||
@@ -49,9 +46,7 @@ trecurse(root, action, level)
|
||||
|
||||
/* Walk the nodes of a tree */
|
||||
void
|
||||
twalk(vroot, action)
|
||||
const void *vroot; /* Root of the tree to be walked */
|
||||
void (*action) __P((const void *, VISIT, int));
|
||||
twalk(const void *vroot, cmp_fn_t action) /* Root of the tree to be walked */
|
||||
{
|
||||
if (vroot != NULL && action != NULL)
|
||||
trecurse(vroot, action, 0);
|
||||
|
||||
Reference in New Issue
Block a user