manupa-arm commented on a change in pull request #7266:
URL: https://github.com/apache/tvm/pull/7266#discussion_r561233084



##########
File path: src/runtime/crt/host/main.cc
##########
@@ -93,6 +94,20 @@ tvm_crt_error_t TVMPlatformTimerStop(double* 
elapsed_time_seconds) {
   g_utvm_timer_running = 0;
   return kTvmErrorNoError;
 }
+
+static_assert(RAND_MAX >= (1 << 8), "RAND_MAX is smaller than acceptable");
+unsigned int random_seed = 0;
+tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer, size_t num_bytes) {
+  if (random_seed == 0) {
+    random_seed = (unsigned int)time(NULL);
+  }
+  for (size_t i = 0; i < num_bytes; ++i) {
+    int random = rand_r(&random_seed);
+    buffer[i] = (uint8_t)random;

Review comment:
       My concern is to keep the crt flow upto the standard as zephyr example 
you are showing here :). 
   If its not too much trouble, I would think the zephyr implementation is 
superior (might be a delta difference though) and would like to have it on the 
crt as well since you have the code already and I think the only change is 
usage of rand_r, which is fine for now..




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to