mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-07 17:50:05 +00:00
controller: use OS specific PRNG for RIOT builds
Currently the controller is using jrand48() to generate pseudo random numbers. For RIOT builds this commit switches to the RIOT build-in PRNG API, as this has two benefits: i) it saves 500bytes of flash and ii) jrand48() internally uses malloc, which has been source to runtime failures in the past.
This commit is contained in:
committed by
Hauke Petersen
parent
719bd3c435
commit
80b6f20f98
@@ -33,6 +33,10 @@
|
||||
#include "trng/trng.h"
|
||||
#endif
|
||||
|
||||
#ifdef RIOT_VERSION
|
||||
#include "random.h"
|
||||
#endif
|
||||
|
||||
#if BABBLESIM
|
||||
extern void tm_tick(void);
|
||||
#endif
|
||||
@@ -134,6 +138,7 @@ ble_ll_rand_data_get(uint8_t *buf, uint8_t len)
|
||||
uint32_t
|
||||
ble_ll_rand(void)
|
||||
{
|
||||
#ifndef RIOT_VERSION
|
||||
static unsigned short xsubi[3];
|
||||
static bool init = true;
|
||||
|
||||
@@ -143,6 +148,9 @@ ble_ll_rand(void)
|
||||
}
|
||||
|
||||
return (uint32_t) jrand48(xsubi);
|
||||
#else
|
||||
return random_uint32();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user