summaryrefslogtreecommitdiff
path: root/random
diff options
context:
space:
mode:
Diffstat (limited to 'random')
-rw-r--r--random/jitterentropy-base-user.h15
-rw-r--r--random/rndjent.c11
2 files changed, 25 insertions, 1 deletions
diff --git a/random/jitterentropy-base-user.h b/random/jitterentropy-base-user.h
index 389106ff..3b4274af 100644
--- a/random/jitterentropy-base-user.h
+++ b/random/jitterentropy-base-user.h
@@ -141,7 +141,7 @@ static inline void jent_memset_secure(void *s, size_t n)
static inline long jent_ncpu(void)
{
-#ifdef _POSIX_SOURCE
+#if defined(_POSIX_SOURCE)
long ncpu = sysconf(_SC_NPROCESSORS_ONLN);
if (ncpu == -1)
@@ -151,6 +151,19 @@ static inline long jent_ncpu(void)
return -EFAULT;
return ncpu;
+#elif defined(HAVE_W32_SYSTEM)
+ SYSTEM_INFO sysinfo;
+ long ncpu;
+
+ GetNativeSystemInfo (&sysinfo);
+ ncpu = sysinfo.dwNumberOfProcessors;
+ if (ncpu <= 0) {
+ GetSystemInfo (&sysinfo);
+ ncpu = sysinfo.dwNumberOfProcessors;
+ }
+ if (ncpu <= 0)
+ ncpu = 1;
+ return ncpu;
#else
return 1;
#endif
diff --git a/random/rndjent.c b/random/rndjent.c
index 14d23794..0468c7cb 100644
--- a/random/rndjent.c
+++ b/random/rndjent.c
@@ -45,6 +45,17 @@
#endif
#include <unistd.h>
#include <errno.h>
+#ifndef EOPNOTSUPP
+# define EOPNOTSUPP ENOSYS
+#endif
+
+#ifdef HAVE_W32_SYSTEM
+# if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0501
+# undef _WIN32_WINNT
+# define _WIN32_WINNT 0x0501 /* for GetNativeSystemInfo */
+# endif
+# include <windows.h>
+#endif
#include "types.h"
#include "g10lib.h"