diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-01 09:43:37 +0000 | 
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-01 09:43:37 +0000 | 
| commit | 94ecebc42368bd20dc671baaf397c136c530d09d (patch) | |
| tree | 0ff49d2dab95a69bdcd8891be2df5caaab09018d /libc | |
| parent | 3b1b9d4638f0b92c161453f2896355183296803f (diff) | |
random: use smaller data fields where appropriate
    text           data     bss     dec     hex filename
-    130            156       0     286     11e libc/stdlib/random.o
+    130            148       0     278     116 libc/stdlib/random.o
-    586              0       0     586     24a libc/stdlib/random_r.o
+    570              0       0     570     23a libc/stdlib/random_r.o
Diffstat (limited to 'libc')
| -rw-r--r-- | libc/inet/resolv.c | 1 | ||||
| -rw-r--r-- | libc/misc/sysvipc/sem.c | 2 | ||||
| -rw-r--r-- | libc/stdlib/rand.c | 5 | ||||
| -rw-r--r-- | libc/stdlib/random.c | 11 | ||||
| -rw-r--r-- | libc/stdlib/random_r.c | 8 | 
5 files changed, 8 insertions, 19 deletions
| diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c index 08246e85f..e377c3883 100644 --- a/libc/inet/resolv.c +++ b/libc/inet/resolv.c @@ -2783,6 +2783,7 @@ int res_init(void)  #ifdef __UCLIBC_HAS_COMPAT_RES_STATE__  	rp->retrans = RES_TIMEOUT;  	rp->retry = 4; +//TODO: pulls in largish static buffers... use simpler one?  	rp->id = random();  #endif  	rp->ndots = 1; diff --git a/libc/misc/sysvipc/sem.c b/libc/misc/sysvipc/sem.c index 96d6a6ee5..e340216e9 100644 --- a/libc/misc/sysvipc/sem.c +++ b/libc/misc/sysvipc/sem.c @@ -99,7 +99,7 @@ _syscall4(int, semtimedop, int, semid, struct sembuf *, sops, size_t, nsops, con  int semtimedop(int semid, struct sembuf *sops, size_t nsops,  	       const struct timespec *timeout)  { -    return __syscall_ipc(IPCOP_semtimedop, semid, nsops, 0, sops, timeout); +    return __syscall_ipc(IPCOP_semtimedop, semid, nsops, 0, sops, (void *) timeout);  }  #endif  #endif 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 | 
