summaryrefslogtreecommitdiff
path: root/googletest/src/gtest-port.cc
diff options
context:
space:
mode:
Diffstat (limited to 'googletest/src/gtest-port.cc')
-rw-r--r--googletest/src/gtest-port.cc54
1 files changed, 28 insertions, 26 deletions
diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc
index 105a3ec8..da4d12d8 100644
--- a/googletest/src/gtest-port.cc
+++ b/googletest/src/gtest-port.cc
@@ -38,7 +38,7 @@
#include <fstream>
#include <memory>
-#if GTEST_OS_WINDOWS
+#ifdef GTEST_OS_WINDOWS
#include <io.h>
#include <sys/stat.h>
#include <windows.h>
@@ -51,32 +51,34 @@
#include <unistd.h>
#endif // GTEST_OS_WINDOWS
-#if GTEST_OS_MAC
+#ifdef GTEST_OS_MAC
#include <mach/mach_init.h>
#include <mach/task.h>
#include <mach/vm_map.h>
#endif // GTEST_OS_MAC
-#if GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \
- GTEST_OS_NETBSD || GTEST_OS_OPENBSD
+#if defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_FREEBSD) || \
+ defined(GTEST_OS_GNU_KFREEBSD) || defined(GTEST_OS_NETBSD) || \
+ defined(GTEST_OS_OPENBSD)
#include <sys/sysctl.h>
-#if GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD
+#if defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_FREEBSD) || \
+ defined(GTEST_OS_GNU_KFREEBSD)
#include <sys/user.h>
#endif
#endif
-#if GTEST_OS_QNX
+#ifdef GTEST_OS_QNX
#include <devctl.h>
#include <fcntl.h>
#include <sys/procfs.h>
#endif // GTEST_OS_QNX
-#if GTEST_OS_AIX
+#ifdef GTEST_OS_AIX
#include <procinfo.h>
#include <sys/types.h>
#endif // GTEST_OS_AIX
-#if GTEST_OS_FUCHSIA
+#ifdef GTEST_OS_FUCHSIA
#include <zircon/process.h>
#include <zircon/syscalls.h>
#endif // GTEST_OS_FUCHSIA
@@ -90,7 +92,7 @@
namespace testing {
namespace internal {
-#if GTEST_OS_LINUX || GTEST_OS_GNU_HURD
+#if defined(GTEST_OS_LINUX) || defined(GTEST_OS_GNU_HURD)
namespace {
template <typename T>
@@ -113,7 +115,7 @@ size_t GetThreadCount() {
return ReadProcFileField<size_t>(filename, 19);
}
-#elif GTEST_OS_MAC
+#elif defined(GTEST_OS_MAC)
size_t GetThreadCount() {
const task_t task = mach_task_self();
@@ -131,20 +133,20 @@ size_t GetThreadCount() {
}
}
-#elif GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \
- GTEST_OS_NETBSD
+#elif defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_FREEBSD) || \
+ defined(GTEST_OS_GNU_KFREEBSD) || defined(GTEST_OS_NETBSD)
-#if GTEST_OS_NETBSD
+#ifdef GTEST_OS_NETBSD
#undef KERN_PROC
#define KERN_PROC KERN_PROC2
#define kinfo_proc kinfo_proc2
#endif
-#if GTEST_OS_DRAGONFLY
+#ifdef GTEST_OS_DRAGONFLY
#define KP_NLWP(kp) (kp.kp_nthreads)
-#elif GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD
+#elif defined(GTEST_OS_FREEBSD) || defined(GTEST_OS_GNU_KFREEBSD)
#define KP_NLWP(kp) (kp.ki_numthreads)
-#elif GTEST_OS_NETBSD
+#elif defined(GTEST_OS_NETBSD)
#define KP_NLWP(kp) (kp.p_nlwps)
#endif
@@ -156,7 +158,7 @@ size_t GetThreadCount() {
KERN_PROC,
KERN_PROC_PID,
getpid(),
-#if GTEST_OS_NETBSD
+#ifdef GTEST_OS_NETBSD
sizeof(struct kinfo_proc),
1,
#endif
@@ -169,7 +171,7 @@ size_t GetThreadCount() {
}
return static_cast<size_t>(KP_NLWP(info));
}
-#elif GTEST_OS_OPENBSD
+#elif defined(GTEST_OS_OPENBSD)
// Returns the number of threads running in the process, or 0 to indicate that
// we cannot detect it.
@@ -206,7 +208,7 @@ size_t GetThreadCount() {
return nthreads;
}
-#elif GTEST_OS_QNX
+#elif defined(GTEST_OS_QNX)
// Returns the number of threads running in the process, or 0 to indicate that
// we cannot detect it.
@@ -226,7 +228,7 @@ size_t GetThreadCount() {
}
}
-#elif GTEST_OS_AIX
+#elif defined(GTEST_OS_AIX)
size_t GetThreadCount() {
struct procentry64 entry;
@@ -239,7 +241,7 @@ size_t GetThreadCount() {
}
}
-#elif GTEST_OS_FUCHSIA
+#elif defined(GTEST_OS_FUCHSIA)
size_t GetThreadCount() {
int dummy_buffer;
@@ -264,7 +266,7 @@ size_t GetThreadCount() {
#endif // GTEST_OS_LINUX
-#if GTEST_IS_THREADSAFE && GTEST_OS_WINDOWS
+#if defined(GTEST_IS_THREADSAFE) && defined(GTEST_OS_WINDOWS)
AutoHandle::AutoHandle() : handle_(INVALID_HANDLE_VALUE) {}
@@ -1027,7 +1029,7 @@ class CapturedStream {
public:
// The ctor redirects the stream to a temporary file.
explicit CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) {
-#if GTEST_OS_WINDOWS
+#ifdef GTEST_OS_WINDOWS
char temp_dir_path[MAX_PATH + 1] = {'\0'}; // NOLINT
char temp_file_path[MAX_PATH + 1] = {'\0'}; // NOLINT
@@ -1046,7 +1048,7 @@ class CapturedStream {
// directory, so we create the temporary file in a temporary directory.
std::string name_template;
-#if GTEST_OS_LINUX_ANDROID
+#ifdef GTEST_OS_LINUX_ANDROID
// Note: Android applications are expected to call the framework's
// Context.getExternalStorageDirectory() method through JNI to get
// the location of the world-writable SD Card directory. However,
@@ -1059,7 +1061,7 @@ class CapturedStream {
// '/sdcard' and other variants cannot be relied on, as they are not
// guaranteed to be mounted, or may have a delay in mounting.
name_template = "/data/local/tmp/";
-#elif GTEST_OS_IOS
+#elif defined(GTEST_OS_IOS)
char user_temp_dir[PATH_MAX + 1];
// Documented alternative to NSTemporaryDirectory() (for obtaining creating
@@ -1246,7 +1248,7 @@ void ClearInjectableArgvs() {
}
#endif // GTEST_HAS_DEATH_TEST
-#if GTEST_OS_WINDOWS_MOBILE
+#ifdef GTEST_OS_WINDOWS_MOBILE
namespace posix {
void Abort() {
DebugBreak();