NetBSD re-synchronization of the source tree

This brings our tree to NetBSD 7.0, as found on -current on the
10-10-2015.

This updates:
 - LLVM to 3.6.1
 - GCC to GCC 5.1
 - Replace minix/commands/zdump with usr.bin/zdump
 - external/bsd/libelf has moved to /external/bsd/elftoolchain/
 - Import ctwm
 - Drop sprintf from libminc

Change-Id: I149836ac18e9326be9353958bab9b266efb056f0
This commit is contained in:
2016-01-13 20:32:14 +01:00
parent 8933525b85
commit 0a6a1f1d05
32425 changed files with 2998492 additions and 1342217 deletions
+87 -5
View File
@@ -1,4 +1,4 @@
.\" $NetBSD: malloc.3,v 1.38 2010/05/03 08:23:20 jruoho Exp $
.\" $NetBSD: malloc.3,v 1.44 2015/07/26 22:32:03 wiz Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -34,7 +34,7 @@
.\" @(#)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 3, 2010
.Dd July 26, 2015
.Dt MALLOC 3
.Os
.Sh NAME
@@ -90,6 +90,7 @@ the value of the newly allocated portion of the memory is undefined.
Upon success, the memory referenced by
.Fa ptr
is freed and a pointer to the newly allocated memory is returned.
.Pp
Note that
.Fn realloc
may move the memory allocation, resulting in a different return value than
@@ -158,7 +159,7 @@ if ((p = malloc(number * size)) == NULL)
.Pp
The multiplication may lead to an integer overflow.
To avoid this,
.Fn calloc
.Xr reallocarr 3
is recommended.
.Pp
If
@@ -171,10 +172,46 @@ if (size && number > SIZE_MAX / size) {
}
.Ed
.Pp
The above test is not sufficient in all cases.
For example, multiplying ints requires a different set of checks:
.Bd -literal -offset indent
int num, size;
\&.\&.\&.
/* Avoid invalid requests */
if (size < 0 || num < 0)
errc(1, EOVERFLOW, "overflow");
/* Check for signed int overflow */
if (size && num > INT_MAX / size)
errc(1, EOVERFLOW, "overflow");
if ((p = malloc(size * num)) == NULL)
err(1, "malloc");
.Ed
.Pp
Assuming the implementation checks for integer overflow as
.Nx
does, it is much easier to use
.Fn calloc
or
.Xr reallocarr 3 .
.Pp
The above examples could be simplified to:
.Bd -literal -offset indent
ptr = NULL;
if ((e = reallocarr(&ptr, num, size)))
errx(1, "reallocarr", strerror(e));
.Ed
.Bd -literal -offset indent
or at the cost of initialization:
if ((p = calloc(num, size)) == NULL)
err(1, "calloc");
.Ed
.Pp
When using
.Fn realloc ,
one must be careful to avoid the following idiom:
.Pp
.Bd -literal -offset indent
nsize += 50;
@@ -214,7 +251,8 @@ size = newsize;
.Xr atexit 3 ,
.Xr getpagesize 3 ,
.Xr memory 3 ,
.Xr posix_memalign 3
.Xr posix_memalign 3 ,
.Xr reallocarr 3
.Pp
For the implementation details, see
.Xr jemalloc 3 .
@@ -227,3 +265,47 @@ and
.Fn free
functions conform to
.St -isoC .
.Sh HISTORY
A
.Fn free
internal kernel function and a predecessor to
.Fn malloc ,
.Fn alloc ,
first appeared in
.At v1 .
The C Library functions
.Fn alloc
and
.Fn free
appeared in
.At v6 .
The functions
.Fn malloc ,
.Fn calloc ,
and
.Fn realloc
first appeared in
.At v7 .
.Pp
A new implementation by Chris Kingsley was introduced in
.Bx 4.2 ,
followed by a complete rewrite by Poul-Henning Kamp
.Dq ( phk's malloc
or
.Dq new malloc )
which appeared in
.Fx 2.2
and was included in
.Nx 1.5
and
.Ox 2.0 .
These implementations were all
.Xr sbrk 2
based.
.Pp
The
.Xr jemalloc 3
allocator became the default system allocator first in
.Fx 7.0
and then in
.Nx 5.0 .