Merge pull request #224 from jray272/run-windows-script
[platform/upstream/glog.git] / src / utilities.h
index 6ab7f5c..be2cff4 100644 (file)
 #elif defined(__CYGWIN__) || defined(__CYGWIN32__)
 # define OS_CYGWIN
 #elif defined(linux) || defined(__linux) || defined(__linux__)
-# define OS_LINUX
+# ifndef OS_LINUX
+#  define OS_LINUX
+# endif
 #elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
 # define OS_MACOSX
 #elif defined(__FreeBSD__)
 # define OS_FREEBSD
+#elif defined(__NetBSD__)
+# define OS_NETBSD
 #elif defined(__OpenBSD__)
 # define OS_OPENBSD
 #else
@@ -95,6 +99,8 @@
 //    malloc() from the unwinder.  This is a problem because we're
 //    trying to use the unwinder to instrument malloc().
 //
+// 4) The Windows API CaptureStackTrace.
+//
 // Note: if you add a new implementation here, make sure it works
 // correctly when GetStackTrace() is called with max_depth == 0.
 // Some code may do that.
 #elif !defined(NO_FRAME_POINTER)
 # if defined(__i386__) && __GNUC__ >= 2
 #  define STACKTRACE_H "stacktrace_x86-inl.h"
-# elif defined(__x86_64__) && __GNUC__ >= 2
+# elif defined(__x86_64__) && __GNUC__ >= 2 && HAVE_UNWIND_H
 #  define STACKTRACE_H "stacktrace_x86_64-inl.h"
 # elif (defined(__ppc__) || defined(__PPC__)) && __GNUC__ >= 2
 #  define STACKTRACE_H "stacktrace_powerpc-inl.h"
+# elif defined(OS_WINDOWS)
+#  define STACKTRACE_H "stacktrace_windows-inl.h"
 # endif
 #endif
 
 #elif defined(OS_MACOSX) && defined(HAVE_DLADDR)
 // Use dladdr to symbolize.
 # define HAVE_SYMBOLIZE
+#elif defined(OS_WINDOWS)
+// Use DbgHelp to symbolize
+# define HAVE_SYMBOLIZE
 #endif
 
 #ifndef ARRAYSIZE
@@ -139,6 +150,9 @@ namespace glog_internal_namespace_ {
 #ifdef HAVE___ATTRIBUTE__
 # define ATTRIBUTE_NOINLINE __attribute__ ((noinline))
 # define HAVE_ATTRIBUTE_NOINLINE
+#elif defined(OS_WINDOWS)
+# define ATTRIBUTE_NOINLINE __declspec(noinline)
+# define HAVE_ATTRIBUTE_NOINLINE
 #else
 # define ATTRIBUTE_NOINLINE
 #endif
@@ -157,6 +171,7 @@ typedef double WallTime;
 WallTime WallTime_Now();
 
 int32 GetMainThreadPid();
+bool PidHasChanged();
 
 pid_t GetTID();
 
@@ -211,6 +226,9 @@ struct CrashReason {
 
 void SetCrashReason(const CrashReason* r);
 
+void InitGoogleLoggingUtilities(const char* argv0);
+void ShutdownGoogleLoggingUtilities();
+
 }  // namespace glog_internal_namespace_
 
 _END_GOOGLE_NAMESPACE_