fix compilation on freebsd (#34671)
authorTomas Weinfurt <tweinfurt@yahoo.com>
Wed, 8 Apr 2020 17:21:02 +0000 (10:21 -0700)
committerGitHub <noreply@github.com>
Wed, 8 Apr 2020 17:21:02 +0000 (10:21 -0700)
* fix compilation on freebsd

* fix test build on freebsd

src/coreclr/src/gc/unix/cgroup.cpp
src/coreclr/src/pal/src/misc/cgroup.cpp
src/coreclr/tests/src/profiler/native/profilerstring.h

index be3af90..5d8ea53 100644 (file)
@@ -23,7 +23,7 @@ Abstract:
 #include <stdio.h>
 #include <string.h>
 #include <sys/resource.h>
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__FreeBSD__)
 #include <sys/param.h>
 #include <sys/mount.h>
 #else
index e6c114e..df6d59f 100644 (file)
@@ -20,7 +20,7 @@ SET_DEFAULT_DEBUG_CHANNEL(MISC);
 #include "pal/virtual.h"
 #include "pal/cgroup.h"
 #include <algorithm>
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__FreeBSD__)
 #include <sys/param.h>
 #include <sys/mount.h>
 #else
index c337af1..386c4c6 100644 (file)
@@ -8,7 +8,7 @@
 #include <assert.h>
 #include <cstring>
 
-#if defined(__linux__) || defined(__APPLE__)
+#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
 // On linux the runtime uses 16 bit strings but the native platform wchar_t is 32 bit.
 // This means there aren't c runtime functions like wcslen for 16 bit strings. The idea
 // here is to provide the easy ones to avoid all the copying and transforming. If more complex
@@ -50,9 +50,9 @@ inline int wcscmp(const char16_t *lhs, const char16_t *rhs)
     return lhs[i] - rhs[i];
 }
 
-#else // defined(__linux__) || defined(__APPLE__)
+#else // defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
 #define WCHAR(str) L##str
-#endif // defined(__linux__) || defined(__APPLE__)
+#endif // defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
 
 // 16 bit string type that works cross plat and doesn't require changing widths
 // on non-windows platforms
@@ -202,12 +202,12 @@ inline std::wostream& operator<<(std::wostream& os, const String& obj)
             break;
         }
 
-#if defined(__linux__) || defined(__APPLE__)
+#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
         os << static_cast<wchar_t>(obj.buffer[i]);
-#else // defined(__linux__) || defined(__APPLE__)
+#else // defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
         os << obj.buffer[i];
-#endif // defined(__linux__) || defined(__APPLE__)
+#endif // defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
     }
 
     return os;
-}
\ No newline at end of file
+}