Sync libc/stdlib with FreeBSD (ignoring jemalloc, pts, and gdtoa):
authorPeter Avalos <pavalos@theshell.com>
Mon, 19 Jan 2009 02:51:47 +0000 (21:51 -0500)
committerPeter Avalos <pavalos@theshell.com>
Tue, 7 Apr 2009 07:08:56 +0000 (21:08 -1000)
commit5d0641a49aa3545f73b6fdefb388923018512597
tree4a4bd010bda108cb2f82c97b2007c9fe231042dd
parent390e5ad7ecd7e3e572158322353dd42c8c0e2691
Sync libc/stdlib with FreeBSD (ignoring jemalloc, pts, and gdtoa):

-Add a64l(), l64a(), and l64a_r() XSI extentions.  These functions
convert between a 32-bit integer and a radix-64 ASCII string.

-Replace some syscalls with libc version.

-Remove advertising clause.

-alloca() cannot check if the allocation is valid; mention the
consequences.

-Include some verbage about not calling exit() from functions registered
by atexit().

-Use pthread mutexes where possible instead of libc spinlocks.

-Significantly reduce the memory leak as noted in the BUGS section of
setenv(3) by tracking the size of the memory allocated instead of using
strlen() on the current value.

-Prefer setenv() instead of putenv().

-Convert *env() calls to POSIX:
-unsetenv returns an int.
-putenv takes a char * instead of const char *.
-putenv no longer makes a copy of the input string.
-errno is set appropriately.  Exceptions involve bad environ
variable and internal initialization code.  These both set errno
to EFAULT.

-Make getopt_long() more GNU compatible and sync up with OpenBSD's
version.

-POSIX clearly states that getsubopt() should be declared in <stdlib.h>
not in <unistd.h>

-Use size_t to avoid overflow when sorting arrays larger than 2 GB in
heapsort() and qsort().

-Add new implementations of insque() and remque() which conform to
IEEE Std 1003.1-2001.

-Add qsort_r() for functions that need to be reentrant.

-Improve radixsort()'s preformance when sorting strings with common
prefixes.

-Use 'uint32_t' instead of 'long' when a 32-bit integer is intended in
random(3).

-Rearrange <stdlib.h> in a more logical order based on visibility.

-Move getsubopt()'s prototype to <stdlib.h> (standards).

-Make an internal _getprogname() that is used only inside
libc. For libc, getprogname(3) is a weak symbol in case a
function of the same name is defined in userland.
82 files changed:
bin/df/df.c
bin/sh/var.c
include/search.h
include/stdlib.h
include/unistd.h
lib/libc/gen/getprogname.c
lib/libc/include/libc_private.h
lib/libc/stdlib/Makefile.inc
lib/libc/stdlib/a64l.3 [new file with mode: 0644]
lib/libc/stdlib/a64l.c [new file with mode: 0644]
lib/libc/stdlib/abort.3
lib/libc/stdlib/abort.c
lib/libc/stdlib/abs.3
lib/libc/stdlib/abs.c
lib/libc/stdlib/alloca.3
lib/libc/stdlib/atexit.3
lib/libc/stdlib/atexit.c
lib/libc/stdlib/atexit.h
lib/libc/stdlib/atof.3
lib/libc/stdlib/atof.c
lib/libc/stdlib/atoi.3
lib/libc/stdlib/atoi.c
lib/libc/stdlib/atol.3
lib/libc/stdlib/atol.c
lib/libc/stdlib/bsearch.3
lib/libc/stdlib/bsearch.c
lib/libc/stdlib/div.3
lib/libc/stdlib/div.c
lib/libc/stdlib/exit.3
lib/libc/stdlib/exit.c
lib/libc/stdlib/getenv.3
lib/libc/stdlib/getenv.c
lib/libc/stdlib/getopt.3
lib/libc/stdlib/getopt.c
lib/libc/stdlib/getopt_long.3
lib/libc/stdlib/getopt_long.c
lib/libc/stdlib/getsubopt.3
lib/libc/stdlib/getsubopt.c
lib/libc/stdlib/hcreate.3
lib/libc/stdlib/hcreate.c
lib/libc/stdlib/heapsort.c
lib/libc/stdlib/insque.3 [new file with mode: 0644]
lib/libc/stdlib/insque.c [new file with mode: 0644]
lib/libc/stdlib/l64a.c [new file with mode: 0644]
lib/libc/stdlib/labs.3
lib/libc/stdlib/labs.c
lib/libc/stdlib/ldiv.3
lib/libc/stdlib/ldiv.c
lib/libc/stdlib/lsearch.c
lib/libc/stdlib/malloc.c
lib/libc/stdlib/memory.3
lib/libc/stdlib/merge.c
lib/libc/stdlib/putenv.c [deleted file]
lib/libc/stdlib/qsort.3
lib/libc/stdlib/qsort.c
lib/libc/stdlib/qsort_r.c [new file with mode: 0644]
lib/libc/stdlib/radixsort.3
lib/libc/stdlib/radixsort.c
lib/libc/stdlib/rand.3
lib/libc/stdlib/rand.c
lib/libc/stdlib/random.3
lib/libc/stdlib/random.c
lib/libc/stdlib/realpath.3
lib/libc/stdlib/realpath.c
lib/libc/stdlib/remque.c [new file with mode: 0644]
lib/libc/stdlib/setenv.c [deleted file]
lib/libc/stdlib/strtol.3
lib/libc/stdlib/strtoq.c
lib/libc/stdlib/strtoul.3
lib/libc/stdlib/strtouq.c
lib/libc/stdlib/system.3
lib/libc/stdlib/system.c
lib/libc/stdlib/tdelete.c
lib/libc/stdlib/tfind.c
lib/libc/stdlib/tsearch.3
lib/libc/stdlib/tsearch.c
lib/libc/stdlib/twalk.c
libexec/pppoed/pppoed.c
usr.bin/du/du.c
usr.bin/env/env.c
usr.bin/limits/limits.c
usr.sbin/pstat/pstat.c