Changeset View
Changeset View
Standalone View
Standalone View
lib/sanitizer_common/sanitizer_win.cc
Show All 16 Lines | |||||
#define WIN32_LEAN_AND_MEAN | #define WIN32_LEAN_AND_MEAN | ||||
#define NOGDI | #define NOGDI | ||||
#include <windows.h> | #include <windows.h> | ||||
#include <io.h> | #include <io.h> | ||||
#include <psapi.h> | #include <psapi.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
// #define needed to link in RtlGenRandom(), a.k.a. SystemFunction036. See the | |||||
// "Community Additions" comment on MSDN here: | |||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx | |||||
#define SystemFunction036 NTAPI SystemFunction036 | |||||
#include <NTSecAPI.h> | |||||
#undef SystemFunction036 | |||||
#include "sanitizer_common.h" | #include "sanitizer_common.h" | ||||
#include "sanitizer_dbghelp.h" | #include "sanitizer_dbghelp.h" | ||||
#include "sanitizer_file.h" | #include "sanitizer_file.h" | ||||
#include "sanitizer_libc.h" | #include "sanitizer_libc.h" | ||||
#include "sanitizer_mutex.h" | #include "sanitizer_mutex.h" | ||||
#include "sanitizer_placement_new.h" | #include "sanitizer_placement_new.h" | ||||
#include "sanitizer_stacktrace.h" | #include "sanitizer_stacktrace.h" | ||||
#include "sanitizer_symbolizer.h" | #include "sanitizer_symbolizer.h" | ||||
▲ Show 20 Lines • Show All 725 Lines • ▼ Show 20 Lines | void internal__exit(int exitcode) { | ||||
BUILTIN_UNREACHABLE(); | BUILTIN_UNREACHABLE(); | ||||
} | } | ||||
uptr internal_ftruncate(fd_t fd, uptr size) { | uptr internal_ftruncate(fd_t fd, uptr size) { | ||||
UNIMPLEMENTED(); | UNIMPLEMENTED(); | ||||
} | } | ||||
uptr GetRSS() { | uptr GetRSS() { | ||||
PROCESS_MEMORY_COUNTERS counters; | |||||
if (!GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters))) | |||||
return 0; | return 0; | ||||
return counters.WorkingSetSize; | |||||
} | } | ||||
void *internal_start_thread(void (*func)(void *arg), void *arg) { return 0; } | void *internal_start_thread(void (*func)(void *arg), void *arg) { return 0; } | ||||
void internal_join_thread(void *th) { } | void internal_join_thread(void *th) { } | ||||
// ---------------------- BlockingMutex ---------------- {{{1 | // ---------------------- BlockingMutex ---------------- {{{1 | ||||
const uptr LOCK_UNINITIALIZED = 0; | const uptr LOCK_UNINITIALIZED = 0; | ||||
const uptr LOCK_READY = (uptr)-1; | const uptr LOCK_READY = (uptr)-1; | ||||
▲ Show 20 Lines • Show All 328 Lines • ▼ Show 20 Lines | |||||
// FIXME implement on this platform. | // FIXME implement on this platform. | ||||
void GetMemoryProfile(fill_profile_f cb, uptr *stats, uptr stats_size) { } | void GetMemoryProfile(fill_profile_f cb, uptr *stats, uptr stats_size) { } | ||||
void CheckNoDeepBind(const char *filename, int flag) { | void CheckNoDeepBind(const char *filename, int flag) { | ||||
// Do nothing. | // Do nothing. | ||||
} | } | ||||
// FIXME: implement on this platform. | # pragma comment(lib, "advapi32.lib") | ||||
bool GetRandom(void *buffer, uptr length, bool blocking) { | bool GetRandom(void *buffer, uptr length, bool blocking) { | ||||
UNIMPLEMENTED(); | if (!buffer || !length || length > 256) | ||||
return false; | |||||
return RtlGenRandom(buffer, length) != FALSE; | |||||
} | } | ||||
u32 GetNumberOfCPUs() { | u32 GetNumberOfCPUs() { | ||||
SYSTEM_INFO sysinfo = {0}; | SYSTEM_INFO sysinfo = {0}; | ||||
GetNativeSystemInfo(&sysinfo); | GetNativeSystemInfo(&sysinfo); | ||||
return sysinfo.dwNumberOfProcessors; | return sysinfo.dwNumberOfProcessors; | ||||
} | } | ||||
} // namespace __sanitizer | } // namespace __sanitizer | ||||
#endif // _WIN32 | #endif // _WIN32 |