forked from Mirrorlandia_minetest/minetest
Clean up porting.h a bit
This commit is contained in:
parent
e7be135b78
commit
d4123a387c
@ -52,6 +52,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "porting_android.h"
|
#include "porting_android.h"
|
||||||
#endif
|
#endif
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
|
#include <mach-o/dyld.h>
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
// For _NSGetEnviron()
|
// For _NSGetEnviron()
|
||||||
// Related: https://gitlab.haskell.org/ghc/ghc/issues/2458
|
// Related: https://gitlab.haskell.org/ghc/ghc/issues/2458
|
||||||
#include <crt_externs.h>
|
#include <crt_externs.h>
|
||||||
|
@ -38,10 +38,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#define SWPRINTF_CHARSTRING L"%s"
|
#define SWPRINTF_CHARSTRING L"%s"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//currently not needed
|
|
||||||
//template<typename T> struct alignment_trick { char c; T member; };
|
|
||||||
//#define ALIGNOF(type) offsetof (alignment_trick<type>, member)
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
@ -49,12 +45,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#define sleep_us(x) Sleep((x)/1000)
|
#define sleep_us(x) Sleep((x)/1000)
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <cstdint> //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)
|
#if (defined(__linux__) || defined(__GNU__)) && !defined(_GNU_SOURCE)
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#endif
|
#endif
|
||||||
@ -64,18 +55,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define ALIGNOF(x) __alignof(x)
|
|
||||||
#define strtok_r(x, y, z) strtok_s(x, y, z)
|
#define strtok_r(x, y, z) strtok_s(x, y, z)
|
||||||
#define strtof(x, y) (float)strtod(x, y)
|
#define strtof(x, y) (float)strtod(x, y)
|
||||||
#define strtoll(x, y, z) _strtoi64(x, y, z)
|
#define strtoll(x, y, z) _strtoi64(x, y, z)
|
||||||
#define strtoull(x, y, z) _strtoui64(x, y, z)
|
#define strtoull(x, y, z) _strtoui64(x, y, z)
|
||||||
#define strcasecmp(x, y) stricmp(x, y)
|
#define strcasecmp(x, y) stricmp(x, y)
|
||||||
#define strncasecmp(x, y, n) strnicmp(x, y, n)
|
#define strncasecmp(x, y, n) strnicmp(x, y, n)
|
||||||
#else
|
|
||||||
#define ALIGNOF(x) __alignof__(x)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
// was broken in 2013, unclear if still needed
|
||||||
#define strtok_r(x, y, z) mystrtok_r(x, y, z)
|
#define strtok_r(x, y, z) mystrtok_r(x, y, z)
|
||||||
#endif
|
#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)
|
#define strlcpy(d, s, n) mystrlcpy(d, s, n)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PADDING(x, y) ((ALIGNOF(y) - ((uintptr_t)(x) & (ALIGNOF(y) - 1))) & (ALIGNOF(y) - 1))
|
#ifndef _WIN32 // POSIX
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
|
||||||
#include <mach-o/dyld.h>
|
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _WIN32 // Posix
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
#if defined(__MACH__) && defined(__APPLE__)
|
#if defined(__MACH__) && defined(__APPLE__)
|
||||||
#include <mach/clock.h>
|
#include <mach/clock.h>
|
||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
#endif
|
#endif
|
||||||
@ -178,7 +160,7 @@ void initializePaths();
|
|||||||
std::string get_sysinfo();
|
std::string get_sysinfo();
|
||||||
|
|
||||||
|
|
||||||
// Monotonic counter getters.
|
// Monotonic timer
|
||||||
|
|
||||||
#ifdef _WIN32 // Windows
|
#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 getTimeUs() { return os_get_time(1000*1000); }
|
||||||
inline u64 getTimeNs() { return os_get_time(1000*1000*1000); }
|
inline u64 getTimeNs() { return os_get_time(1000*1000*1000); }
|
||||||
|
|
||||||
#else // Posix
|
#else // POSIX
|
||||||
|
|
||||||
inline void os_get_clock(struct timespec *ts)
|
inline void os_get_clock(struct timespec *ts)
|
||||||
{
|
{
|
||||||
@ -314,7 +296,7 @@ inline const char *getPlatformName()
|
|||||||
"Cygwin"
|
"Cygwin"
|
||||||
#elif defined(__unix__) || defined(__unix)
|
#elif defined(__unix__) || defined(__unix)
|
||||||
#if defined(_POSIX_VERSION)
|
#if defined(_POSIX_VERSION)
|
||||||
"Posix"
|
"POSIX"
|
||||||
#else
|
#else
|
||||||
"Unix"
|
"Unix"
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user