|
1 | 1 | // Copyright (c) Meta Platforms, Inc. and affiliates. |
2 | 2 |
|
| 3 | +#ifndef _GNU_SOURCE |
| 4 | +#define _GNU_SOURCE |
| 5 | +#endif |
3 | 6 | #include "cinderx/Jit/perf_jitdump.h" |
4 | 7 |
|
5 | 8 | #include "cinderx/python.h" |
@@ -61,16 +64,14 @@ const size_t kJitdumpMmapSize = 1; |
61 | 64 | // C++-friendly wrapper around strerror_r(). |
62 | 65 | std::string string_error(int errnum) { |
63 | 66 | char buf[1024]; |
64 | | - // This template trick detects the return type of strerror_r at compile time. |
65 | | - // If it returns char*, we're using GNU version. If it returns int, POSIX. |
66 | | - if constexpr (std::is_same_v<decltype(strerror_r(0, buf, 0)), char*>) { |
67 | | - // GNU version: returns char* (possibly pointing to a static string) |
68 | | - return strerror_r(errnum, buf, sizeof(buf)); |
69 | | - } else { |
70 | | - // POSIX version: returns int, writes to buffer |
71 | | - strerror_r(errnum, buf, sizeof(buf)); |
72 | | - return std::string{buf}; |
73 | | - } |
| 67 | + // There's two forms of strerror_r(), one that returns a string and one that |
| 68 | + // returns an int. |
| 69 | +#if __APPLE__ |
| 70 | + strerror_r(errnum, buf, sizeof(buf)); |
| 71 | + return std::string{buf}; |
| 72 | +#else |
| 73 | + return strerror_r(errnum, buf, sizeof(buf)); |
| 74 | +#endif |
74 | 75 | } |
75 | 76 |
|
76 | 77 | class FileLock { |
|
0 commit comments