summaryrefslogtreecommitdiffstats
path: root/main/libc0.9.32/0005-stdlib-fix-arc4random-return-type-to-u_int32_t.patch
blob: 91ff10a94b5aa893d699e5fc4bcb1cbbec572392 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
From 1337133b489f02e5cbde81a87051abaf6e1a2799 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Fri, 18 Mar 2011 10:57:31 +0200
Subject: [PATCH 5/8] stdlib: fix arc4random return type to u_int32_t
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It's documented to be u_int32_t and not uint32_t:
 http://www.manpagez.com/man/3/arc4random/

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 Teräs <timo.teras@iki.fi>
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
 include/stdlib.h         |    4 ++--
 libc/stdlib/arc4random.c |    3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/stdlib.h b/include/stdlib.h
index 352e58a..37e0248 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -910,8 +910,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 c7aed66..7b9b12d 100644
--- a/libc/stdlib/arc4random.c
+++ b/libc/stdlib/arc4random.c
@@ -30,6 +30,7 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <stdint.h>
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/time.h>
@@ -175,7 +176,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.8.4