summaryrefslogtreecommitdiffstats
path: root/libc/stdlib
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2008-12-03 14:04:03 +0000
committerCarmelo Amoroso <carmelo.amoroso@st.com>2008-12-03 14:04:03 +0000
commitd5c32667ad11ff38dc46be527266297b38a341d1 (patch)
treeb3ce68f179d97e6e25e5c8e7ace845c4a561322b /libc/stdlib
parent329ef3196b396a70eecd5a4789845d368b488ab7 (diff)
downloaduClibc-alpine-d5c32667ad11ff38dc46be527266297b38a341d1.tar.bz2
uClibc-alpine-d5c32667ad11ff38dc46be527266297b38a341d1.tar.xz
Synch with trunk @ 24242
Step 18: some more synch: hidden_proto, size reduction and signal handling changes.
Diffstat (limited to 'libc/stdlib')
-rw-r--r--libc/stdlib/abort.c10
-rw-r--r--libc/stdlib/l64a.c20
-rw-r--r--libc/stdlib/rand.c5
-rw-r--r--libc/stdlib/random.c11
-rw-r--r--libc/stdlib/random_r.c8
5 files changed, 21 insertions, 33 deletions
diff --git a/libc/stdlib/abort.c b/libc/stdlib/abort.c
index 7291d0ea4..fcf90187c 100644
--- a/libc/stdlib/abort.c
+++ b/libc/stdlib/abort.c
@@ -60,9 +60,9 @@ void abort(void)
__UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(mylock);
/* Unmask SIGABRT to be sure we can get it */
- if (__sigemptyset(&sigs) == 0 && __sigaddset(&sigs, SIGABRT) == 0) {
- sigprocmask(SIG_UNBLOCK, &sigs, (sigset_t *) NULL);
- }
+ __sigemptyset(&sigs);
+ __sigaddset(&sigs, SIGABRT);
+ sigprocmask(SIG_UNBLOCK, &sigs, NULL);
while (1) {
/* Try to suicide with a SIGABRT */
@@ -91,9 +91,9 @@ abort_it:
been_there_done_that++;
memset(&act, '\0', sizeof(struct sigaction));
- act.sa_handler = SIG_DFL;
+ if (SIG_DFL) /* if it's constant zero, already done */
+ act.sa_handler = SIG_DFL;
__sigfillset(&act.sa_mask);
- act.sa_flags = 0;
sigaction(SIGABRT, &act, NULL);
goto abort_it;
diff --git a/libc/stdlib/l64a.c b/libc/stdlib/l64a.c
index a8b2d551e..5a1dc13a6 100644
--- a/libc/stdlib/l64a.c
+++ b/libc/stdlib/l64a.c
@@ -36,21 +36,21 @@ char * l64a (long int n)
{
unsigned long int m = (unsigned long int) n;
static char result[7];
- int cnt;
+ char *p;
/* The standard says that only 32 bits are used. */
- m &= 0xffffffff;
+ if (sizeof(m) != 4)
+ m &= 0xffffffff;
- if (m == 0ul)
- /* The value for N == 0 is defined to be the empty string. */
- return (char *) "";
-
- for (cnt = 0; m > 0ul; ++cnt)
+ /* The value for N == 0 is defined to be the empty string,
+ * this code provides that as well. */
+ p = result;
+ while (m)
{
- result[cnt] = conv_table[m & 0x3f];
+ *p++ = conv_table[m & 0x3f];
m >>= 6;
}
- result[cnt] = '\0';
+ *p = '\0';
- return result;
+ return p;
}
diff --git a/libc/stdlib/rand.c b/libc/stdlib/rand.c
index 61aaa9105..93fc01483 100644
--- a/libc/stdlib/rand.c
+++ b/libc/stdlib/rand.c
@@ -9,8 +9,7 @@
/* libc_hidden_proto(random) */
-int rand (void)
+int rand(void)
{
- return((int)random());
+ return (int)random();
}
-
diff --git a/libc/stdlib/random.c b/libc/stdlib/random.c
index 6d5d06e09..967a1e52a 100644
--- a/libc/stdlib/random.c
+++ b/libc/stdlib/random.c
@@ -74,11 +74,7 @@ __UCLIBC_MUTEX_STATIC(mylock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
-/* For each of the currently supported random number generators, we have a
- break value on the amount of state information (you need at least this many
- bytes of state info to support this random number generator), a degree for
- the polynomial (actually a trinomial) that the R.N.G. is based on, and
- separation between the two lower order coefficients of the trinomial. */
+/* Keep constants in sync with random_r.c */
/* Linear congruential. */
#define TYPE_0 0
@@ -110,13 +106,8 @@ __UCLIBC_MUTEX_STATIC(mylock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
#define DEG_4 63
#define SEP_4 1
-
-/* Array versions of the above information to make code run faster.
- Relies on fact that TYPE_i == i. */
-
#define MAX_TYPES 5 /* Max number of types above. */
-
/* Initially, everything is set up as if from:
initstate(1, randtbl, 128);
Note that this initialization takes advantage of the fact that srandom
diff --git a/libc/stdlib/random_r.c b/libc/stdlib/random_r.c
index b6ff6afd2..cb70b7dc4 100644
--- a/libc/stdlib/random_r.c
+++ b/libc/stdlib/random_r.c
@@ -27,8 +27,7 @@
#include <limits.h>
#include <stddef.h>
#include <stdlib.h>
-
-
+#include <unistd.h>
/* An improved random number generation package. In addition to the standard
rand()/srand() like interface, this package also has a special state info
@@ -109,8 +108,8 @@
struct random_poly_info
{
- int seps[MAX_TYPES];
- int degrees[MAX_TYPES];
+ smallint seps[MAX_TYPES];
+ smallint degrees[MAX_TYPES];
};
static const struct random_poly_info random_poly_info =
@@ -121,7 +120,6 @@ static const struct random_poly_info random_poly_info =
-
/* If we are using the trivial TYPE_0 R.N.G., just do the old linear
congruential bit. Otherwise, we do our fancy trinomial stuff, which is the
same in all the other cases due to all the global variables that have been