47#include <sys/random.h>
65 struct timespec mrqtp;
66 mrqtp.tv_sec = iTimeVal;
69 return nanosleep(&mrqtp, NULL);
71 return sleep(iTimeVal);
83 struct timespec mrqtp;
84 mrqtp.tv_sec = iTimeVal/1000000;
85 mrqtp.tv_nsec = (iTimeVal - (mrqtp.tv_sec * 1000000)) * 1000;
87 return nanosleep(&mrqtp, NULL);
90 tv.tv_sec = iTimeVal/1000000;
91 tv.tv_usec = iTimeVal - (tv.tv_sec * 1000000);
92 return select(0, NULL, NULL, NULL, &tv);
112 unsigned char c[
sizeof ui] = {0};
116 ret = getrandom(c,
sizeof c, 0);
120 Log2(PCSC_LOG_ERROR,
"getrandom() failed: %s", strerror(errno));
125 for(i = 0; i <
sizeof ui; i++) {
130 return (
int)(ui & (
unsigned int)INT_MAX);
132 int r = (int)lrand48();
142#ifndef HAVE_GETRANDOM
147 tz.tz_minuteswest = 0;
149 if (gettimeofday(&tv, &tz) == 0)
154 myseed = (long) time(NULL);
170#ifdef HAVE_SECURE_GETENV
171 return secure_getenv(name);
This handles abstract system level calls.
INTERNAL const char * SYS_GetEnv(const char *name)
(More) secure version of getenv(3)
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.