46#include <sys/random.h>
63 struct timespec mrqtp;
64 mrqtp.tv_sec = iTimeVal;
67 return nanosleep(&mrqtp, NULL);
69 return sleep(iTimeVal);
81 struct timespec mrqtp;
82 mrqtp.tv_sec = iTimeVal/1000000;
83 mrqtp.tv_nsec = (iTimeVal - (mrqtp.tv_sec * 1000000)) * 1000;
85 return nanosleep(&mrqtp, NULL);
88 tv.tv_sec = iTimeVal/1000000;
89 tv.tv_usec = iTimeVal - (tv.tv_sec * 1000000);
90 return select(0, NULL, NULL, NULL, &tv);
110 unsigned char c[
sizeof ui] = {0};
114 ret = getrandom(c,
sizeof c, 0);
117 Log2(PCSC_LOG_ERROR,
"getrandom() failed: %s", strerror(errno));
121 for(i = 0; i <
sizeof ui; i++) {
126 return (
int)(ui & (
unsigned int)INT_MAX);
138#ifndef HAVE_GETRANDOM
143 tz.tz_minuteswest = 0;
145 if (gettimeofday(&tv, &tz) == 0)
150 myseed = (long) time(NULL);
This handles abstract system level calls.
INTERNAL int SYS_RandomInt(void)
Generate a pseudo random number.
INTERNAL int SYS_Sleep(int iTimeVal)
Makes the current process sleep for some seconds.
INTERNAL int SYS_USleep(int iTimeVal)
Makes the current process sleep for some microseconds.
INTERNAL void SYS_InitRandom(void)
Initialize the random generator.