svn commit: trunk/uClibc: include libc/inet libc/misc/sysvipc libc etc...

vda at uclibc.org vda at uclibc.org
Mon Dec 1 09:43:37 UTC 2008


Author: vda
Date: 2008-12-01 01:43:37 -0800 (Mon, 01 Dec 2008)
New Revision: 24202

Log:
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



Modified:
   trunk/uClibc/include/stdlib.h
   trunk/uClibc/libc/inet/resolv.c
   trunk/uClibc/libc/misc/sysvipc/sem.c
   trunk/uClibc/libc/stdlib/rand.c
   trunk/uClibc/libc/stdlib/random.c
   trunk/uClibc/libc/stdlib/random_r.c


Changeset:
Modified: trunk/uClibc/include/stdlib.h
===================================================================
--- trunk/uClibc/include/stdlib.h	2008-12-01 09:41:41 UTC (rev 24201)
+++ trunk/uClibc/include/stdlib.h	2008-12-01 09:43:37 UTC (rev 24202)
@@ -347,9 +347,10 @@
     int32_t *fptr;		/* Front pointer.  */
     int32_t *rptr;		/* Rear pointer.  */
     int32_t *state;		/* Array of state values.  */
-    int rand_type;		/* Type of random number generator.  */
-    int rand_deg;		/* Degree of random number generator.  */
-    int rand_sep;		/* Distance between front and rear.  */
+    /* random_r.c, TYPE_x, DEG_x, SEP_x - small enough for int8_t */
+    int8_t rand_type;		/* Type of random number generator.  */
+    int8_t rand_deg;		/* Degree of random number generator.  */
+    int8_t rand_sep;		/* Distance between front and rear.  */
     int32_t *end_ptr;		/* Pointer behind state table.  */
   };
 

Modified: trunk/uClibc/libc/inet/resolv.c
===================================================================
--- trunk/uClibc/libc/inet/resolv.c	2008-12-01 09:41:41 UTC (rev 24201)
+++ trunk/uClibc/libc/inet/resolv.c	2008-12-01 09:43:37 UTC (rev 24202)
@@ -2783,6 +2783,7 @@
 #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;

Modified: trunk/uClibc/libc/misc/sysvipc/sem.c
===================================================================
--- trunk/uClibc/libc/misc/sysvipc/sem.c	2008-12-01 09:41:41 UTC (rev 24201)
+++ trunk/uClibc/libc/misc/sysvipc/sem.c	2008-12-01 09:43:37 UTC (rev 24202)
@@ -99,7 +99,7 @@
 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

Modified: trunk/uClibc/libc/stdlib/rand.c
===================================================================
--- trunk/uClibc/libc/stdlib/rand.c	2008-12-01 09:41:41 UTC (rev 24201)
+++ trunk/uClibc/libc/stdlib/rand.c	2008-12-01 09:43:37 UTC (rev 24202)
@@ -9,8 +9,7 @@
 
 /* libc_hidden_proto(random) */
 
-int rand (void)
+int rand(void)
 {
-	return((int)random());
+	return (int)random();
 }
-

Modified: trunk/uClibc/libc/stdlib/random.c
===================================================================
--- trunk/uClibc/libc/stdlib/random.c	2008-12-01 09:41:41 UTC (rev 24201)
+++ trunk/uClibc/libc/stdlib/random.c	2008-12-01 09:43:37 UTC (rev 24202)
@@ -74,11 +74,7 @@
 
 
 
-/* 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 @@
 #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

Modified: trunk/uClibc/libc/stdlib/random_r.c
===================================================================
--- trunk/uClibc/libc/stdlib/random_r.c	2008-12-01 09:41:41 UTC (rev 24201)
+++ trunk/uClibc/libc/stdlib/random_r.c	2008-12-01 09:43:37 UTC (rev 24202)
@@ -27,9 +27,8 @@
 #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
    interface.  The initstate() routine is called with a seed, an array of
@@ -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 @@
 
 
 
-
 /* 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




More information about the uClibc-cvs mailing list