diff options
-rw-r--r-- | lib/libc/rand.c | 2 | ||||
-rw-r--r-- | lib/libc/rules.mk | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/libc/rand.c b/lib/libc/rand.c index 5bc5d36c..74ab2c97 100644 --- a/lib/libc/rand.c +++ b/lib/libc/rand.c @@ -23,7 +23,7 @@ #include <rand.h> #include <sys/types.h> -static unsigned int randseed = 12345; +static unsigned int randseed = KERNEL_LIBC_RANDSEED; void srand(unsigned int seed) { diff --git a/lib/libc/rules.mk b/lib/libc/rules.mk index 41655714..ab2baad9 100644 --- a/lib/libc/rules.mk +++ b/lib/libc/rules.mk @@ -9,6 +9,15 @@ ifndef WITH_CUSTOM_MALLOC MODULE_DEPS += lib/heap endif +# Generate a random 32-bit seed for the RNG +KERNEL_LIBC_RANDSEED_HEX := $(shell xxd -l4 -g0 -p /dev/urandom) +KERNEL_LIBC_RANDSEED := 0x$(KERNEL_LIBC_RANDSEED_HEX)U + +MODULE_DEFINES += \ + KERNEL_LIBC_RANDSEED=$(KERNEL_LIBC_RANDSEED) \ + +$(info KERNEL_LIBC_RANDSEED = $(KERNEL_LIBC_RANDSEED)) + MODULE_SRCS += \ $(LOCAL_DIR)/atoi.c \ $(LOCAL_DIR)/bsearch.c \ |