Fix getpid() usage on Windows
authorNick Mathewson <nickm@torproject.org>
Thu, 18 Feb 2010 05:54:44 +0000 (00:54 -0500)
committerNick Mathewson <nickm@torproject.org>
Thu, 18 Feb 2010 05:54:44 +0000 (00:54 -0500)
On Windows, getpid() is _getpid(), and requires that we first include
<process.h>.  arc4random.c previously didn't know that.

Actually, I question whether arc4random needs to do its getpid() tricks
on Windows.  They exist only so that we remember to re-seed the ARC4
cipher whenever we fork... but Windows has no fork(), so I think we're
in the clear.

arc4random.c

index b14b723d128b62df0dd6f14b844672d12b985f78..c14fc536205727966ac6247af7da1f3f20f6da97 100644 (file)
@@ -50,6 +50,7 @@
 #ifndef ARC4RANDOM_NO_INCLUDES
 #ifdef WIN32
 #include <wincrypt.h>
+#include <process.h>
 #else
 #include <fcntl.h>
 #include <unistd.h>
@@ -216,6 +217,10 @@ arc4_stir(void)
        arc4_count = BYTES_BEFORE_RESEED;
 }
 
+#ifdef WIN32
+#define getpid _getpid
+#endif
+
 static void
 arc4_stir_if_needed(void)
 {