11#if (defined(__linux__) || defined(__GNU__)) && !defined(_GNU_SOURCE)
24 #define SWPRINTF_CHARSTRING L"%S"
26 #define SWPRINTF_CHARSTRING L"%s"
32 #define sleep_ms(x) Sleep(x)
33 #define sleep_us(x) Sleep((x)/1000)
35 #define setenv(n,v,o) _putenv_s(n,v)
36 #define unsetenv(n) _putenv_s(n,"")
41 #define sleep_ms(x) usleep((x)*1000)
42 #define sleep_us(x) usleep(x)
46 #define strtok_r(x, y, z) strtok_s(x, y, z)
47 #define strtof(x, y) (float)strtod(x, y)
48 #define strtoll(x, y, z) _strtoi64(x, y, z)
49 #define strtoull(x, y, z) _strtoui64(x, y, z)
50 #define strcasecmp(x, y) stricmp(x, y)
51 #define strncasecmp(x, y, n) strnicmp(x, y, n)
56 #define strtok_r(x, y, z) mystrtok_r(x, y, z)
60 #define strlcpy(d, s, n) mystrlcpy(d, s, n)
66 #if defined(__MACH__) && defined(__APPLE__)
67 #include <TargetConditionals.h>
133extern double perf_freq;
135inline u64 os_get_time(
double mult)
138 QueryPerformanceCounter(&t);
139 return static_cast<double>(t.QuadPart) / (perf_freq / mult);
143inline u64
getTimeS() {
return os_get_time(1); }
144inline u64
getTimeMs() {
return os_get_time(1000); }
145inline u64
getTimeUs() {
return os_get_time(1000*1000); }
146inline u64
getTimeNs() {
return os_get_time(1000*1000*1000); }
152#if defined(CLOCK_MONOTONIC_RAW)
153 clock_gettime(CLOCK_MONOTONIC_RAW, ts);
154#elif defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK > 0
155 clock_gettime(CLOCK_MONOTONIC, ts);
157# if defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK == 0
159 if (clock_gettime(CLOCK_MONOTONIC, ts) == 0)
163 gettimeofday(&tv, NULL);
164 TIMEVAL_TO_TIMESPEC(&tv, ts);
179 return ((u64) ts.tv_sec) * 1000LL + ((u64) ts.tv_nsec) / 1000000LL;
186 return ((u64) ts.tv_sec) * 1000000LL + ((u64) ts.tv_nsec) / 1000LL;
193 return ((u64) ts.tv_sec) * 1000000000LL + ((u64) ts.tv_nsec);
206 FATAL_ERROR(
"Called getTime with invalid time precision");
217 if (new_time_ms >= old_time_ms) {
218 return (new_time_ms - old_time_ms);
221 return (old_time_ms - new_time_ms);
229#elif defined(__linux__)
231#elif defined(_WIN32) || defined(_WIN64)
233#elif defined(__DragonFly__) || defined(__FreeBSD__) || \
234 defined(__NetBSD__) || defined(__OpenBSD__)
236#elif defined(__APPLE__) && defined(__MACH__)
239 #elif TARGET_OS_IPHONE
248#elif defined(__sun) || defined(sun)
254#elif defined(__HAIKU__)
256#elif defined(__CYGWIN__)
258#elif defined(__unix__) || defined(__unix)
259 #if defined(_POSIX_VERSION)
298std::string QuoteArgv(
const std::string &arg);
301std::string ConvertError(DWORD error_code);
305int mt_snprintf(
char *buf,
const size_t buf_size,
const char *fmt, ...);
315bool open_url(
const std::string &url);
#define FATAL_ERROR(msg)
Definition debug.h:33
Definition porting.cpp:78
u64 getDeltaMs(u64 old_time_ms, u64 new_time_ms)
Delta calculation function arguments.
Definition porting.h:215
std::string path_locale
Definition porting.cpp:161
bool secure_rand_fill_buf(void *buf, size_t len)
Definition porting.cpp:745
std::string path_share
Definition porting.cpp:159
int mt_snprintf(char *buf, const size_t buf_size, const char *fmt,...)
Definition porting.cpp:841
void os_get_clock(struct timespec *ts)
Definition porting.h:150
void signal_handler_init(void)
Definition porting.cpp:115
void osSpecificInit()
Definition porting.cpp:766
static void TrackFreedMemory(size_t amount)
Definition porting.h:292
bool open_directory(const std::string &path)
Opens a directory in the default file manager.
Definition porting.cpp:900
u64 getTimeS()
Definition porting.h:168
std::string path_cache
Definition porting.cpp:162
std::string path_user
Definition porting.cpp:160
u64 getTime(TimePrecision prec)
Definition porting.h:198
bool * signal_handler_killstatus()
Definition porting.cpp:86
u64 getTimeMs()
Definition porting.h:175
bool open_url(const std::string &url)
Opens URL in default web browser.
Definition porting.cpp:890
u64 getTimeNs()
Definition porting.h:189
const char * getPlatformName()
Definition porting.h:224
bool getCurrentExecPath(char *buf, size_t len)
Definition porting.cpp:405
std::string getDataPath(const char *subpath)
Definition porting.cpp:165
void initializePaths()
Definition porting.cpp:614
void attachOrCreateConsole()
Definition porting.cpp:779
static void TriggerMemoryTrim()
Definition porting.h:293
u64 getTimeUs()
Definition porting.h:182
const std::string & get_sysinfo()
Definition porting.cpp:266