diff --git a/src/porting.cpp b/src/porting.cpp index 16e14631d4b0..54c9ee2c9819 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -52,6 +52,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "porting_android.h" #endif #if defined(__APPLE__) + #include + #include // For _NSGetEnviron() // Related: https://gitlab.haskell.org/ghc/ghc/issues/2458 #include diff --git a/src/porting.h b/src/porting.h index da9f83eab3e7..6657d7bba22d 100644 --- a/src/porting.h +++ b/src/porting.h @@ -38,10 +38,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #define SWPRINTF_CHARSTRING L"%s" #endif -//currently not needed -//template struct alignment_trick { char c; T member; }; -//#define ALIGNOF(type) offsetof (alignment_trick, member) - #ifdef _WIN32 #include @@ -49,12 +45,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define sleep_us(x) Sleep((x)/1000) #else #include - #include //for uintptr_t - // Use standard Posix macro for Linux - #if (defined(linux) || defined(__linux)) && !defined(__linux__) - #define __linux__ - #endif #if (defined(__linux__) || defined(__GNU__)) && !defined(_GNU_SOURCE) #define _GNU_SOURCE #endif @@ -64,18 +55,16 @@ with this program; if not, write to the Free Software Foundation, Inc., #endif #ifdef _MSC_VER - #define ALIGNOF(x) __alignof(x) #define strtok_r(x, y, z) strtok_s(x, y, z) #define strtof(x, y) (float)strtod(x, y) #define strtoll(x, y, z) _strtoi64(x, y, z) #define strtoull(x, y, z) _strtoui64(x, y, z) #define strcasecmp(x, y) stricmp(x, y) #define strncasecmp(x, y, n) strnicmp(x, y, n) -#else - #define ALIGNOF(x) __alignof__(x) #endif #ifdef __MINGW32__ + // was broken in 2013, unclear if still needed #define strtok_r(x, y, z) mystrtok_r(x, y, z) #endif @@ -97,18 +86,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #define strlcpy(d, s, n) mystrlcpy(d, s, n) #endif -#define PADDING(x, y) ((ALIGNOF(y) - ((uintptr_t)(x) & (ALIGNOF(y) - 1))) & (ALIGNOF(y) - 1)) - -#if defined(__APPLE__) - #include - #include -#endif - -#ifndef _WIN32 // Posix +#ifndef _WIN32 // POSIX #include #include -#if defined(__MACH__) && defined(__APPLE__) + #if defined(__MACH__) && defined(__APPLE__) #include #include #endif @@ -178,7 +160,7 @@ void initializePaths(); std::string get_sysinfo(); -// Monotonic counter getters. +// Monotonic timer #ifdef _WIN32 // Windows @@ -197,7 +179,7 @@ inline u64 getTimeMs() { return os_get_time(1000); } inline u64 getTimeUs() { return os_get_time(1000*1000); } inline u64 getTimeNs() { return os_get_time(1000*1000*1000); } -#else // Posix +#else // POSIX inline void os_get_clock(struct timespec *ts) { @@ -314,7 +296,7 @@ inline const char *getPlatformName() "Cygwin" #elif defined(__unix__) || defined(__unix) #if defined(_POSIX_VERSION) - "Posix" + "POSIX" #else "Unix" #endif