src/platform_windows.cpp
changeset 54 8f6b3a6b77a8
parent 8 26cc9f0228f4
child 55 0569864cb34e
     1.1 --- a/src/platform_windows.cpp	Sun Feb 08 13:42:23 2015 -0500
     1.2 +++ b/src/platform_windows.cpp	Sun Feb 08 14:51:02 2015 -0500
     1.3 @@ -7,6 +7,8 @@
     1.4  #define _WIN32_WINNT 0x0600
     1.5  
     1.6  #include <windows.h>
     1.7 +#define _CRT_RAND_S
     1.8 +#include <stdlib.h>
     1.9  #include <assert.h>
    1.10  #include <string>
    1.11  #include <stdexcept>
    1.12 @@ -186,4 +188,18 @@
    1.13      return path.c_str();
    1.14  }
    1.15  
    1.16 +long random(void)
    1.17 +{
    1.18 +    unsigned int r;
    1.19 +    errno_t e;
    1.20 +
    1.21 +    assert(sizeof(unsigned int) == sizeof(long)); // this is Windoze
    1.22 +
    1.23 +    do {
    1.24 +        e = rand_s(&r);
    1.25 +    } while (e);
    1.26 +
    1.27 +    return (long) (r & ((1<<31)-1));
    1.28 +}
    1.29 +
    1.30  } // "C"