[ion] Correct random() implementation in simulator, blackbox and

emscripten
This commit is contained in:
Émilie Feral
2018-01-18 11:06:42 +01:00
committed by EmilieNumworks
parent 84b52fa090
commit 7aca44812e
3 changed files with 9 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ objs += $(addprefix ion/src/shared/, \
crc32.o \
events.o \
power.o \
random.o \
dummy/backlight.o \
dummy/battery.o \
dummy/events_modifier.o \
@@ -24,7 +25,6 @@ objs += $(addprefix ion/src/shared/, \
ion/src/shared/log_printf.o: SFLAGS=-Iion/include
ion/src/shared/console_stdio.o: SFLAGS=-Iion/include
ion/src/shared/events_stdin.o: SFLAGS=-Iion/include
ion/src/shared/random.o: SFLAGS=-Iion/include
SFLAGS += `libpng-config --cflags`
LDFLAGS += `libpng-config --ldflags`

View File

@@ -9,6 +9,7 @@ objs += $(addprefix ion/src/shared/, \
events.o \
events_modifier.o \
power.o \
random.o \
dummy/backlight.o \
dummy/battery.o \
dummy/fcc_id.o \

View File

@@ -2,5 +2,11 @@
#include <stdlib.h>
uint32_t Ion::random() {
return rand();
/* rand() returns a pseudo-random integral number in the range between 0 and
* RAND_MAX which is garantueed to be at least 32767.*/
uint32_t result = 0;
for (int i = 0; i < 131077; i++) {
result += rand();
}
return result;
}