[git commit future 1/1] stdlib.h, arc4random.c: fix arc4random return type to u_int32_t

Peter S. Mazinger ps.m at gmx.net
Wed Mar 16 19:20:32 UTC 2011


commit: http://git.uclibc.org/uClibc/commit/?id=404f0f3763cec3f218c6fdc61f037df61b760b8c
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/future

Change uint32_t to u_int32_t and uint8_t to u_int8_t, removing
completely the dependency on stdint.h.

Based on patch by Timo Teraes <timo.teras at iki.fi>. His comment:
This also fixes a major bug that stdlib.h includes stdint.h. Things
might go very wrong because stdint.h has conditional defines and
if stdlib.h is included before #define's for stdint.h we end up
missing things and breaking builds (e.g. openjdk).

Signed-off-by: Timo Teraes <timo.teras at iki.fi>
Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
---
 include/stdlib.h         |    4 ++--
 libc/stdlib/arc4random.c |   18 +++++++++---------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/stdlib.h b/include/stdlib.h
index e9a8b84..7b35840 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -902,8 +902,8 @@ extern int getloadavg (double __loadavg[], int __nelem)
 #endif
 
 #ifdef __UCLIBC_HAS_ARC4RANDOM__
-#include <stdint.h>
-extern uint32_t arc4random(void);
+# include <sys/types.h>
+extern u_int32_t arc4random(void);
 extern void arc4random_stir(void);
 extern void arc4random_addrandom(unsigned char *, int);
 #endif
diff --git a/libc/stdlib/arc4random.c b/libc/stdlib/arc4random.c
index 7a8359a..55ea7e2 100644
--- a/libc/stdlib/arc4random.c
+++ b/libc/stdlib/arc4random.c
@@ -39,9 +39,9 @@
 
 
 struct arc4_stream {
-	uint8_t i;
-	uint8_t j;
-	uint8_t s[256];
+	u_int8_t i;
+	u_int8_t j;
+	u_int8_t s[256];
 };
 
 static smallint rs_initialized;
@@ -58,10 +58,10 @@ arc4_init(struct arc4_stream *as)
 	as->j = 0;
 }
 
-static __inline__ uint8_t
+static __inline__ u_int8_t
 arc4_getbyte(struct arc4_stream *as)
 {
-	uint8_t si, sj;
+	u_int8_t si, sj;
 
 	as->i = (as->i + 1);
 	si = as->s[as->i];
@@ -76,7 +76,7 @@ static __inline__ void
 arc4_addrandom(struct arc4_stream *as, u_char *dat, int datlen)
 {
 	int     n;
-	uint8_t si;
+	u_int8_t si;
 
 	as->i--;
 	for (n = 0; n < 256; n++) {
@@ -139,10 +139,10 @@ arc4_stir(struct arc4_stream *as)
 		arc4_getbyte(as);
 }
 
-static __inline__ uint32_t
+static __inline__ u_int32_t
 arc4_getword(struct arc4_stream *as)
 {
-	uint32_t val;
+	u_int32_t val;
 	val = arc4_getbyte(as) << 24;
 	val |= arc4_getbyte(as) << 16;
 	val |= arc4_getbyte(as) << 8;
@@ -169,7 +169,7 @@ arc4random_addrandom(u_char *dat, int datlen)
 	arc4_addrandom(&rs, dat, datlen);
 }
 
-uint32_t
+u_int32_t
 arc4random(void)
 {
 	if (!rs_initialized)
-- 
1.7.3.4



More information about the uClibc-cvs mailing list