diff options
author | bapt <bapt@FreeBSD.org> | 2015-10-13 19:44:36 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2015-10-13 19:44:36 +0000 |
commit | c8d6d4a78596005d50c30c7ab4f623a601ef0b39 (patch) | |
tree | e5218cae2f48913719be46210d8d92085cb2511f /lib/libc/stdlib | |
parent | 2a77c3b71d27973d4ffac086902715be69266202 (diff) | |
parent | 384c892651c52e57063356328dfcd28914bc4b15 (diff) | |
download | FreeBSD-src-c8d6d4a78596005d50c30c7ab4f623a601ef0b39.zip FreeBSD-src-c8d6d4a78596005d50c30c7ab4f623a601ef0b39.tar.gz |
Merge from head
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r-- | lib/libc/stdlib/abort.c | 8 | ||||
-rw-r--r-- | lib/libc/stdlib/abs.c | 3 | ||||
-rw-r--r-- | lib/libc/stdlib/atexit.c | 3 | ||||
-rw-r--r-- | lib/libc/stdlib/atof.c | 7 | ||||
-rw-r--r-- | lib/libc/stdlib/atoi.c | 7 | ||||
-rw-r--r-- | lib/libc/stdlib/atol.c | 7 | ||||
-rw-r--r-- | lib/libc/stdlib/atoll.c | 7 | ||||
-rw-r--r-- | lib/libc/stdlib/bsearch.c | 16 | ||||
-rw-r--r-- | lib/libc/stdlib/exit.c | 3 | ||||
-rw-r--r-- | lib/libc/stdlib/heapsort.c | 17 | ||||
-rw-r--r-- | lib/libc/stdlib/labs.c | 3 | ||||
-rw-r--r-- | lib/libc/stdlib/merge.c | 24 | ||||
-rw-r--r-- | lib/libc/stdlib/qsort.c | 4 | ||||
-rw-r--r-- | lib/libc/stdlib/radixsort.c | 30 | ||||
-rw-r--r-- | lib/libc/stdlib/rand.c | 7 | ||||
-rw-r--r-- | lib/libc/stdlib/system.c | 22 | ||||
-rw-r--r-- | lib/libc/stdlib/tfind.c | 13 |
17 files changed, 73 insertions, 108 deletions
diff --git a/lib/libc/stdlib/abort.c b/lib/libc/stdlib/abort.c index b137e49..2335c40 100644 --- a/lib/libc/stdlib/abort.c +++ b/lib/libc/stdlib/abort.c @@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" void -abort() +abort(void) { struct sigaction act; @@ -61,7 +61,7 @@ abort() * any errors -- ISO C doesn't allow abort to return anyway. */ sigdelset(&act.sa_mask, SIGABRT); - (void)_sigprocmask(SIG_SETMASK, &act.sa_mask, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &act.sa_mask, NULL); (void)raise(SIGABRT); /* @@ -71,9 +71,9 @@ abort() act.sa_handler = SIG_DFL; act.sa_flags = 0; sigfillset(&act.sa_mask); - (void)_sigaction(SIGABRT, &act, NULL); + (void)__libc_sigaction(SIGABRT, &act, NULL); sigdelset(&act.sa_mask, SIGABRT); - (void)_sigprocmask(SIG_SETMASK, &act.sa_mask, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &act.sa_mask, NULL); (void)raise(SIGABRT); exit(1); } diff --git a/lib/libc/stdlib/abs.c b/lib/libc/stdlib/abs.c index 8758947..367b114 100644 --- a/lib/libc/stdlib/abs.c +++ b/lib/libc/stdlib/abs.c @@ -36,8 +36,7 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> int -abs(j) - int j; +abs(int j) { return(j < 0 ? -j : j); } diff --git a/lib/libc/stdlib/atexit.c b/lib/libc/stdlib/atexit.c index 0a5048a..eda5703 100644 --- a/lib/libc/stdlib/atexit.c +++ b/lib/libc/stdlib/atexit.c @@ -82,6 +82,9 @@ struct atexit { static struct atexit *__atexit; /* points to head of LIFO stack */ typedef DECLARE_BLOCK(void, atexit_block, void); +int atexit_b(atexit_block); +int __cxa_atexit(void (*)(void *), void *, void *); + /* * Register the function described by 'fptr' to be called at application * exit or owning shared object unload time. This is a helper function diff --git a/lib/libc/stdlib/atof.c b/lib/libc/stdlib/atof.c index 3514ae3..0458eb9 100644 --- a/lib/libc/stdlib/atof.c +++ b/lib/libc/stdlib/atof.c @@ -42,16 +42,13 @@ __FBSDID("$FreeBSD$"); #include <xlocale.h> double -atof(ascii) - const char *ascii; +atof(const char *ascii) { return strtod(ascii, (char **)NULL); } double -atof_l(ascii, locale) - const char *ascii; - locale_t locale; +atof_l(const char *ascii, locale_t locale) { return strtod_l(ascii, (char **)NULL, locale); } diff --git a/lib/libc/stdlib/atoi.c b/lib/libc/stdlib/atoi.c index 564273e..9f92fcd 100644 --- a/lib/libc/stdlib/atoi.c +++ b/lib/libc/stdlib/atoi.c @@ -42,16 +42,13 @@ __FBSDID("$FreeBSD$"); #include <xlocale.h> int -atoi(str) - const char *str; +atoi(const char *str) { return (int)strtol(str, (char **)NULL, 10); } int -atoi_l(str, locale) - const char *str; - locale_t locale; +atoi_l(const char *str, locale_t locale) { return (int)strtol_l(str, (char **)NULL, 10, locale); } diff --git a/lib/libc/stdlib/atol.c b/lib/libc/stdlib/atol.c index d30aa18..bd8ef07 100644 --- a/lib/libc/stdlib/atol.c +++ b/lib/libc/stdlib/atol.c @@ -42,16 +42,13 @@ __FBSDID("$FreeBSD$"); #include <xlocale.h> long -atol(str) - const char *str; +atol(const char *str) { return strtol(str, (char **)NULL, 10); } long -atol_l(str, locale) - const char *str; - locale_t locale; +atol_l(const char *str, locale_t locale) { return strtol_l(str, (char **)NULL, 10, locale); } diff --git a/lib/libc/stdlib/atoll.c b/lib/libc/stdlib/atoll.c index af52838..093fde5 100644 --- a/lib/libc/stdlib/atoll.c +++ b/lib/libc/stdlib/atoll.c @@ -39,16 +39,13 @@ __FBSDID("$FreeBSD$"); #include <xlocale.h> long long -atoll(str) - const char *str; +atoll(const char *str) { return strtoll(str, (char **)NULL, 10); } long long -atoll_l(str, locale) - const char *str; - locale_t locale; +atoll_l(const char *str, locale_t locale) { return strtoll_l(str, (char **)NULL, 10, locale); } diff --git a/lib/libc/stdlib/bsearch.c b/lib/libc/stdlib/bsearch.c index 4a1dd52..8303f97 100644 --- a/lib/libc/stdlib/bsearch.c +++ b/lib/libc/stdlib/bsearch.c @@ -61,20 +61,12 @@ __FBSDID("$FreeBSD$"); */ #ifdef I_AM_BSEARCH_B void * -bsearch_b(key, base0, nmemb, size, compar) - const void *key; - const void *base0; - size_t nmemb; - size_t size; - DECLARE_BLOCK(int, compar, const void *, const void *); +bsearch_b(const void *key, const void *base0, size_t nmemb, size_t size, + DECLARE_BLOCK(int, compar, const void *, const void *)) #else void * -bsearch(key, base0, nmemb, size, compar) - const void *key; - const void *base0; - size_t nmemb; - size_t size; - int (*compar)(const void *, const void *); +bsearch(const void *key, const void *base0, size_t nmemb, size_t size, + int (*compar)(const void *, const void *)) #endif { const char *base = base0; diff --git a/lib/libc/stdlib/exit.c b/lib/libc/stdlib/exit.c index 145eb9d..a656e04 100644 --- a/lib/libc/stdlib/exit.c +++ b/lib/libc/stdlib/exit.c @@ -56,8 +56,7 @@ int __isthreaded = 0; * Exit, flushing stdio buffers if necessary. */ void -exit(status) - int status; +exit(int status) { /* Ensure that the auto-initialization routine is linked in: */ extern int _thread_autoinit_dummy_decl; diff --git a/lib/libc/stdlib/heapsort.c b/lib/libc/stdlib/heapsort.c index 673a6a1..a7a4a26 100644 --- a/lib/libc/stdlib/heapsort.c +++ b/lib/libc/stdlib/heapsort.c @@ -138,6 +138,12 @@ typedef DECLARE_BLOCK(int, heapsort_block, const void *, const void *); } \ } +#ifdef I_AM_HEAPSORT_B +int heapsort_b(void *, size_t, size_t, heapsort_block); +#else +int heapsort(void *, size_t, size_t, + int (*)(const void *, const void *)); +#endif /* * Heapsort -- Knuth, Vol. 3, page 145. Runs in O (N lg N), both average * and worst. While heapsort is faster than the worst case of quicksort, @@ -147,16 +153,11 @@ typedef DECLARE_BLOCK(int, heapsort_block, const void *, const void *); */ #ifdef I_AM_HEAPSORT_B int -heapsort_b(vbase, nmemb, size, compar) - void *vbase; - size_t nmemb, size; - heapsort_block compar; +heapsort_b(void *vbase, size_t nmemb, size_t size, heapsort_block compar) #else int -heapsort(vbase, nmemb, size, compar) - void *vbase; - size_t nmemb, size; - int (*compar)(const void *, const void *); +heapsort(void *vbase, size_t nmemb, size_t size, + int (*compar)(const void *, const void *)) #endif { size_t cnt, i, j, l; diff --git a/lib/libc/stdlib/labs.c b/lib/libc/stdlib/labs.c index 816370e..ef06882 100644 --- a/lib/libc/stdlib/labs.c +++ b/lib/libc/stdlib/labs.c @@ -36,8 +36,7 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> long -labs(j) - long j; +labs(long j) { return(j < 0 ? -j : j); } diff --git a/lib/libc/stdlib/merge.c b/lib/libc/stdlib/merge.c index 6b368c3..55b3a0c 100644 --- a/lib/libc/stdlib/merge.c +++ b/lib/libc/stdlib/merge.c @@ -99,19 +99,21 @@ static void insertionsort(u_char *, size_t, size_t, cmp_t); ((u_char *)0 + \ (((u_char *)p + PSIZE - 1 - (u_char *) 0) & ~(PSIZE - 1))) +#ifdef I_AM_MERGESORT_B +int mergesort_b(void *, size_t, size_t, cmp_t); +#else +int mergesort(void *, size_t, size_t, cmp_t); +#endif + /* * Arguments are as for qsort. */ int #ifdef I_AM_MERGESORT_B -mergesort_b(base, nmemb, size, cmp) +mergesort_b(void *base, size_t nmemb, size_t size, cmp_t cmp) #else -mergesort(base, nmemb, size, cmp) +mergesort(void *base, size_t nmemb, size_t size, cmp_t cmp) #endif - void *base; - size_t nmemb; - size_t size; - cmp_t cmp; { size_t i; int sense; @@ -271,10 +273,7 @@ COPY: b = t; * is defined. Otherwise simple pairwise merging is used.) */ void -setup(list1, list2, n, size, cmp) - size_t n, size; - u_char *list1, *list2; - cmp_t cmp; +setup(u_char *list1, u_char *list2, size_t n, size_t size, cmp_t cmp) { int i, length, size2, tmp, sense; u_char *f1, *f2, *s, *l2, *last, *p2; @@ -345,10 +344,7 @@ setup(list1, list2, n, size, cmp) * last 4 elements. */ static void -insertionsort(a, n, size, cmp) - u_char *a; - size_t n, size; - cmp_t cmp; +insertionsort(u_char *a, size_t n, size_t size, cmp_t cmp) { u_char *ai, *s, *t, *u, tmp; int i; diff --git a/lib/libc/stdlib/qsort.c b/lib/libc/stdlib/qsort.c index e97ea92..0881688 100644 --- a/lib/libc/stdlib/qsort.c +++ b/lib/libc/stdlib/qsort.c @@ -64,9 +64,7 @@ static inline void swapfunc(char *, char *, int, int, int); es % sizeof(TYPE) ? 2 : es == sizeof(TYPE) ? 0 : 1; static inline void -swapfunc(a, b, n, swaptype_long, swaptype_int) - char *a, *b; - int n, swaptype_long, swaptype_int; +swapfunc( char *a, char *b, int n, int swaptype_long, int swaptype_int) { if (swaptype_long <= 1) swapcode(long, a, b, n) diff --git a/lib/libc/stdlib/radixsort.c b/lib/libc/stdlib/radixsort.c index 8310e6d..205f776 100644 --- a/lib/libc/stdlib/radixsort.c +++ b/lib/libc/stdlib/radixsort.c @@ -88,10 +88,7 @@ static void r_sort_b(const u_char **, const u_char **, int, int, } int -radixsort(a, n, tab, endch) - const u_char **a, *tab; - int n; - u_int endch; +radixsort(const u_char **a, int n, const u_char *tab, u_int endch) { const u_char *tr; int c; @@ -103,10 +100,7 @@ radixsort(a, n, tab, endch) } int -sradixsort(a, n, tab, endch) - const u_char **a, *tab; - int n; - u_int endch; +sradixsort(const u_char **a, int n, const u_char *tab, u_int endch) { const u_char *tr, **ta; int c; @@ -131,11 +125,7 @@ sradixsort(a, n, tab, endch) /* Unstable, in-place sort. */ static void -r_sort_a(a, n, i, tr, endch) - const u_char **a; - int n, i; - const u_char *tr; - u_int endch; +r_sort_a(const u_char **a, int n, int i, const u_char *tr, u_int endch) { static int count[256], nc, bmin; int c; @@ -233,11 +223,8 @@ r_sort_a(a, n, i, tr, endch) /* Stable sort, requiring additional memory. */ static void -r_sort_b(a, ta, n, i, tr, endch) - const u_char **a, **ta; - int n, i; - const u_char *tr; - u_int endch; +r_sort_b(const u_char **a, const u_char **ta, int n, int i, const u_char *tr, + u_int endch) { static int count[256], nc, bmin; int c; @@ -304,12 +291,9 @@ r_sort_b(a, ta, n, i, tr, endch) } } +/* insertion sort */ static inline void -simplesort(a, n, b, tr, endch) /* insertion sort */ - const u_char **a; - int n, b; - const u_char *tr; - u_int endch; +simplesort(const u_char **a, int n, int b, const u_char *tr, u_int endch) { u_char ch; const u_char **ak, **ai, *s, *t; diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c index 4f4aa8d..b8871a2 100644 --- a/lib/libc/stdlib/rand.c +++ b/lib/libc/stdlib/rand.c @@ -111,14 +111,13 @@ static u_long next = #endif int -rand() +rand(void) { return (do_rand(&next)); } void -srand(seed) -u_int seed; +srand(u_int seed) { next = seed; #ifndef USE_WEAK_SEEDING @@ -136,7 +135,7 @@ u_int seed; * data from the kernel. */ void -sranddev() +sranddev(void) { int mib[2]; size_t len; diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c index bd9ea5a..2b298e4 100644 --- a/lib/libc/stdlib/system.c +++ b/lib/libc/stdlib/system.c @@ -70,16 +70,20 @@ __libc_system(const char *command) (void)sigaddset(&newsigblock, SIGCHLD); (void)sigaddset(&newsigblock, SIGINT); (void)sigaddset(&newsigblock, SIGQUIT); - (void)_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock); + (void)__libc_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock); switch(pid = vfork()) { + /* + * In the child, use unwrapped syscalls. libthr is in + * undefined state after vfork(). + */ case -1: /* error */ - (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); return (-1); case 0: /* child */ /* * Restore original signal dispositions and exec the command. */ - (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); + (void)__sys_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); execl(_PATH_BSHELL, "sh", "-c", command, (char *)NULL); _exit(127); } @@ -92,16 +96,16 @@ __libc_system(const char *command) memset(&ign, 0, sizeof(ign)); ign.sa_handler = SIG_IGN; (void)sigemptyset(&ign.sa_mask); - (void)_sigaction(SIGINT, &ign, &intact); - (void)_sigaction(SIGQUIT, &ign, &quitact); + (void)__libc_sigaction(SIGINT, &ign, &intact); + (void)__libc_sigaction(SIGQUIT, &ign, &quitact); savedpid = pid; do { pid = _wait4(savedpid, &pstat, 0, (struct rusage *)0); } while (pid == -1 && errno == EINTR); - (void)_sigaction(SIGINT, &intact, NULL); - (void)_sigaction(SIGQUIT, &quitact, NULL); - (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); - return(pid == -1 ? -1 : pstat); + (void)__libc_sigaction(SIGINT, &intact, NULL); + (void)__libc_sigaction(SIGQUIT, &quitact, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); + return (pid == -1 ? -1 : pstat); } __weak_reference(__libc_system, __system); diff --git a/lib/libc/stdlib/tfind.c b/lib/libc/stdlib/tfind.c index c5d66cf..0ad391e 100644 --- a/lib/libc/stdlib/tfind.c +++ b/lib/libc/stdlib/tfind.c @@ -23,12 +23,15 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> #include <search.h> -/* find a node, or return 0 */ +/* + * find a node, or return 0 + * + * vkey - key to be found + * vrootp - address of the tree root + */ void * -tfind(vkey, vrootp, compar) - const void *vkey; /* key to be found */ - void * const *vrootp; /* address of the tree root */ - int (*compar)(const void *, const void *); +tfind(const void *vkey, void * const *vrootp, + int (*compar)(const void *, const void *)) { node_t **rootp = (node_t **)vrootp; |