Check for getpid(2) presence instead of checking for Visual Studio

This commit is contained in:
Frank Denis 2015-09-13 15:04:14 +02:00
parent 7fa840e486
commit 46f71fba9e
2 changed files with 4 additions and 4 deletions

View File

@ -429,7 +429,7 @@ AS_IF([test "x$EMSCRIPTEN" = "x"],[
AC_CHECK_FUNCS([arc4random arc4random_buf]) AC_CHECK_FUNCS([arc4random arc4random_buf])
AC_CHECK_FUNCS([mmap mlock madvise mprotect explicit_bzero]) AC_CHECK_FUNCS([mmap mlock madvise mprotect explicit_bzero])
]) ])
AC_CHECK_FUNCS([posix_memalign]) AC_CHECK_FUNCS([posix_memalign getpid])
AC_SUBST([LIBTOOL_EXTRA_FLAGS]) AC_SUBST([LIBTOOL_EXTRA_FLAGS])

View File

@ -47,7 +47,7 @@ typedef struct Salsa20Random_ {
unsigned char rnd32[16U * SALSA20_RANDOM_BLOCK_SIZE]; unsigned char rnd32[16U * SALSA20_RANDOM_BLOCK_SIZE];
uint64_t nonce; uint64_t nonce;
size_t rnd32_outleft; size_t rnd32_outleft;
#ifndef _MSC_VER #ifdef HAVE_GETPID
pid_t pid; pid_t pid;
#endif #endif
int random_data_source_fd; int random_data_source_fd;
@ -279,7 +279,7 @@ randombytes_salsa20_random_stir(void)
COMPILER_ASSERT(sizeof stream.key <= sizeof m0); COMPILER_ASSERT(sizeof stream.key <= sizeof m0);
randombytes_salsa20_random_rekey(m0); randombytes_salsa20_random_rekey(m0);
sodium_memzero(m0, sizeof m0); sodium_memzero(m0, sizeof m0);
#ifndef _MSC_VER #ifdef HAVE_GETPID
stream.pid = getpid(); stream.pid = getpid();
#endif #endif
} }
@ -287,7 +287,7 @@ randombytes_salsa20_random_stir(void)
static void static void
randombytes_salsa20_random_stir_if_needed(void) randombytes_salsa20_random_stir_if_needed(void)
{ {
#ifdef _MSC_VER #ifdef HAVE_GETPID
if (stream.initialized == 0) { if (stream.initialized == 0) {
randombytes_salsa20_random_stir(); randombytes_salsa20_random_stir();
} }