summaryrefslogtreecommitdiff
path: root/core/fxcrt/fx_random.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-09-26 16:24:49 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-27 01:04:13 +0000
commit698aed79d6ad6e8e3a0c7a500c108d69f944b82d (patch)
treefbf7e66e0a2ec096561cd0ba5d3c4d577cd64667 /core/fxcrt/fx_random.cpp
parent3070e94f608f36e7312fad2d471e3d7546f82ca2 (diff)
downloadpdfium-698aed79d6ad6e8e3a0c7a500c108d69f944b82d.tar.xz
Cleanup FX macros
This CL renames the FX_OS defines to have _OS_ in their names and drops the _DESKTOP suffix. The FXM defines have been changed to just FX. Change-Id: Iab172fba541713b5f6d14fb8098baf68e3364c74 Reviewed-on: https://pdfium-review.googlesource.com/14833 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/fx_random.cpp')
-rw-r--r--core/fxcrt/fx_random.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/core/fxcrt/fx_random.cpp b/core/fxcrt/fx_random.cpp
index 483a56bbf4..56f84d59b3 100644
--- a/core/fxcrt/fx_random.cpp
+++ b/core/fxcrt/fx_random.cpp
@@ -16,12 +16,12 @@
#define MT_Upper_Mask 0x80000000
#define MT_Lower_Mask 0x7fffffff
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
#include <wincrypt.h>
-#else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#else // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
#include <sys/time.h>
#include <unistd.h>
-#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#endif // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
namespace {
@@ -33,7 +33,7 @@ struct MTContext {
bool g_bHaveGlobalSeed = false;
uint32_t g_nGlobalSeed = 0;
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
bool GenerateSeedFromCryptoRandom(uint32_t* pSeed) {
HCRYPTPROV hCP = 0;
if (!::CryptAcquireContext(&hCP, nullptr, nullptr, PROV_RSA_FULL, 0) ||
@@ -50,30 +50,30 @@ uint32_t GenerateSeedFromEnvironment() {
char c;
uintptr_t p = reinterpret_cast<uintptr_t>(&c);
uint32_t seed = ~static_cast<uint32_t>(p >> 3);
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
SYSTEMTIME st;
GetSystemTime(&st);
seed ^= static_cast<uint32_t>(st.wSecond) * 1000000;
seed ^= static_cast<uint32_t>(st.wMilliseconds) * 1000;
seed ^= GetCurrentProcessId();
-#else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#else // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
struct timeval tv;
gettimeofday(&tv, 0);
seed ^= static_cast<uint32_t>(tv.tv_sec) * 1000000;
seed ^= static_cast<uint32_t>(tv.tv_usec);
seed ^= static_cast<uint32_t>(getpid());
-#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#endif // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
return seed;
}
void* ContextFromNextGlobalSeed() {
if (!g_bHaveGlobalSeed) {
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
if (!GenerateSeedFromCryptoRandom(&g_nGlobalSeed))
g_nGlobalSeed = GenerateSeedFromEnvironment();
-#else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#else // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
g_nGlobalSeed = GenerateSeedFromEnvironment();
-#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#endif // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
g_bHaveGlobalSeed = true;
}
return FX_Random_MT_Start(++g_nGlobalSeed);