File:  [DVB] / dietlibc / lib / rand_i.c
Revision 1.1: download - view: text, annotated - select for diffs
Tue Jan 29 15:23:50 2019 UTC (5 years, 4 months ago) by leitner
Branches: MAIN
CVS tags: HEAD
introduce rand_i() (libc can't change rand's seed by calling it internally)

#include <stdlib.h>
#include <sys/auxv.h>
#include "rand_i.h"

static unsigned int seed;

int rand_i(void) {
  if (seed==0) {
    const int* tmp=(const int*)getauxval(AT_RANDOM);
    if (tmp)
      seed=tmp[3];
    else
      seed=(uintptr_t)&seed;		// really old crappy kernel
  }
  return rand_r(&seed);
}


LinuxTV legacy CVS <linuxtv.org/cvs>