Browse Source

fix rng_get_bytes() when compiling with mingw-gcc

Steffen Jaeckel 12 years ago
parent
commit
b1b15910ed
1 changed files with 7 additions and 3 deletions
  1. 7 3
      src/prngs/rng_get_bytes.c

+ 7 - 3
src/prngs/rng_get_bytes.c

@@ -87,12 +87,16 @@ static unsigned long rng_ansic(unsigned char *buf, unsigned long len,
 #endif 
 #endif 
 
 
 /* Try the Microsoft CSP */
 /* Try the Microsoft CSP */
-#if defined(WIN32) || defined(WINCE)
-#define _WIN32_WINNT 0x0400
+#if defined(WIN32) || defined(_WIN32) || defined(WINCE)
+#ifndef _WIN32_WINNT
+  #define _WIN32_WINNT 0x0400
+#endif
 #ifdef WINCE
 #ifdef WINCE
    #define UNDER_CE
    #define UNDER_CE
    #define ARM
    #define ARM
 #endif
 #endif
+
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <windows.h>
 #include <wincrypt.h>
 #include <wincrypt.h>
 
 
@@ -134,7 +138,7 @@ unsigned long rng_get_bytes(unsigned char *out, unsigned long outlen,
 #if defined(LTC_DEVRANDOM)
 #if defined(LTC_DEVRANDOM)
    x = rng_nix(out, outlen, callback);   if (x != 0) { return x; }
    x = rng_nix(out, outlen, callback);   if (x != 0) { return x; }
 #endif
 #endif
-#ifdef WIN32
+#if defined(_WIN32) || defined(_WIN32) || defined(WINCE)
    x = rng_win32(out, outlen, callback); if (x != 0) { return x; }
    x = rng_win32(out, outlen, callback); if (x != 0) { return x; }
 #endif
 #endif
 #ifdef ANSI_RNG
 #ifdef ANSI_RNG