Skip to content

nimble/ll: Use jrand48 for pseudo random generator#883

Merged
sjanc merged 1 commit intoapache:masterfrom
sjanc:ll_rand
Nov 17, 2020
Merged

nimble/ll: Use jrand48 for pseudo random generator#883
sjanc merged 1 commit intoapache:masterfrom
sjanc:ll_rand

Conversation

@sjanc
Copy link
Copy Markdown
Contributor

@sjanc sjanc commented Nov 13, 2020

Don't use rand() for for pseudo random generation as this shares global
state. Use jrand48 instead and provide wrapper for late initialization.
This is to avoid seeding on init beacouse trng might not be accessible
yet.

This also means LL code will no longer seed stdlib srand() on init as
this should be application responsibility anyway.

@@ -20,6 +20,7 @@
#include <stdint.h>
Copy link
Copy Markdown

@benpicco benpicco Nov 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <stdint.h>
#define _XOPEN_SOURCE
#include <stdint.h>

to make jrand48() available.

Don't use rand() for for pseudo random generation as this shares global
state. Use jrand48 instead and provide wrapper for late initialization.
This is to avoid seeding on init beacouse trng might not be accessible
yet.

This also means LL code will no longer seed stdlib srand() on init as
this should be application responsibility anyway.
@apache-mynewt-bot
Copy link
Copy Markdown

Style check summary

No suggestions at this time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants