119 #if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE))
121 #include <sys/types.h>
122 #include <sys/time.h>
123 #include <sys/times.h>
124 #include <sys/stat.h>
128 #if defined(OPENSSL_SYS_LINUX)
133 # define FD_SETSIZE (8*sizeof(fd_set))
136 #if defined(OPENSSL_SYS_VOS)
163 #ifdef OPENSSL_SYS_VOS_HPPA
165 extern void s$sleep (
long *_duration,
short int *_code);
167 #ifdef OPENSSL_SYS_VOS_IA32
169 extern void s$sleep2 (
long long *_duration,
short int *_code);
171 #error "Unsupported Platform."
179 RAND_add (&curr_gid,
sizeof curr_gid, 1);
183 RAND_add (&curr_pid,
sizeof curr_pid, 1);
187 RAND_add (&curr_uid,
sizeof curr_uid, 1);
195 ts.tv_nsec = random ();
197 #ifdef OPENSSL_SYS_VOS_HPPA
200 s$sleep (&duration, &code);
202 #ifdef OPENSSL_SYS_VOS_IA32
205 s$sleep2 (&duration, &code);
210 clock_gettime (CLOCK_REALTIME, &ts);
213 v = (
unsigned char) (ts.tv_nsec % 256);
219 #elif defined __OpenBSD__
222 u_int32_t rnd = 0, i;
225 for (i = 0; i <
sizeof(buf); i++) {
232 memset(buf, 0,
sizeof(buf));
240 pid_t curr_pid = getpid();
241 #if defined(DEVRANDOM) || defined(DEVRANDOM_EGD)
246 static const char *randomfiles[] = {
DEVRANDOM };
247 struct stat randomstats[sizeof(randomfiles)/sizeof(randomfiles[0])];
253 const char **egdsocket = NULL;
257 memset(randomstats,0,
sizeof(randomstats));
262 for (i = 0; (i <
sizeof(randomfiles)/
sizeof(randomfiles[0])) &&
265 if ((fd = open(randomfiles[i], O_RDONLY
281 struct stat *st=&randomstats[i];
285 if (fstat(fd,st) != 0) { close(fd);
continue; }
288 if (randomstats[j].st_ino==st->st_ino &&
289 randomstats[j].st_dev==st->st_dev)
292 if (j<i) { close(fd);
continue; }
298 #if defined(OPENSSL_SYS_BEOS_R5)
303 #elif defined(OPENSSL_SYS_LINUX)
308 pset.events = POLLIN;
311 if (poll(&pset, 1, usec / 1000) < 0)
314 try_read = (pset.revents & POLLIN) != 0;
334 if (select(fd+1,&fset,NULL,NULL,&t) >= 0)
337 if (FD_ISSET(fd, &fset))
350 #if defined(OPENSSL_SYS_BEOS_R5)
379 for (egdsocket = egdsockets; *egdsocket && n <
ENTROPY_NEEDED; egdsocket++)
390 #if defined(DEVRANDOM) || defined(DEVRANDOM_EGD)
393 RAND_add(tmpbuf,
sizeof tmpbuf,(
double)n);
407 #if defined(OPENSSL_SYS_BEOS)
410 get_system_info(&sysInfo);
411 RAND_add(&sysInfo,
sizeof(sysInfo),0);
415 #if defined(DEVRANDOM) || defined(DEVRANDOM_EGD)
426 #if defined(OPENSSL_SYS_VXWORKS)