Эх сурвалжийг харах

Merge pull request #103 from benpicco/riot

random: add support for RIOT
Frank Denis 5 жил өмнө
parent
commit
a4de6e098b
2 өөрчлөгдсөн 12 нэмэгдсэн , 0 устгасан
  1. 2 0
      impl/random.h
  2. 10 0
      impl/random/riot.h

+ 2 - 0
impl/random.h

@@ -21,6 +21,8 @@ static TLS struct {
 # include "random/unix.h"
 #elif defined(TARGET_LIKE_MBED)
 # include "random/mbed.h"
+#elif defined(RIOT_VERSION)
+# include "random/riot.h"
 #else
 #error Unsupported platform
 #endif

+ 10 - 0
impl/random/riot.h

@@ -0,0 +1,10 @@
+#include <random.h>
+
+static int
+hydro_random_init(void)
+{
+    random_bytes(hydro_random_context.state, sizeof(hydro_random_context.state));
+    hydro_random_context.counter = ~LOAD64_LE(hydro_random_context.state);
+
+    return 0;
+}