2010-08-09 13:28:56 +00:00
|
|
|
#ifndef NALL_PLATFORM_HPP
|
|
|
|
#define NALL_PLATFORM_HPP
|
|
|
|
|
2011-06-05 03:45:04 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
//minimum version needed for _wstat64, etc
|
|
|
|
#undef __MSVCRT_VERSION__
|
|
|
|
#define __MSVCRT_VERSION__ 0x0601
|
2011-08-06 14:03:52 +00:00
|
|
|
#include <nall/windows/utf8.hpp>
|
2011-06-05 03:45:04 +00:00
|
|
|
#endif
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
//=========================
|
|
|
|
//standard platform headers
|
|
|
|
//=========================
|
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2011-06-05 03:45:04 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
#include <io.h>
|
|
|
|
#include <direct.h>
|
|
|
|
#include <shlobj.h>
|
2011-06-05 03:45:04 +00:00
|
|
|
#include <wchar.h>
|
2010-08-09 13:28:56 +00:00
|
|
|
#undef interface
|
|
|
|
#define dllexport __declspec(dllexport)
|
|
|
|
#else
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#define dllexport
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//==================
|
|
|
|
//warning supression
|
|
|
|
//==================
|
|
|
|
|
|
|
|
//Visual C++
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
//disable libc "deprecation" warnings
|
|
|
|
#pragma warning(disable:4996)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//================
|
|
|
|
//POSIX compliance
|
|
|
|
//================
|
|
|
|
|
|
|
|
#if defined(_MSC_VER)
|
2013-04-09 13:31:46 +00:00
|
|
|
#define PATH_MAX _MAX_PATH
|
|
|
|
#define va_copy(dest, src) ((dest) = (src))
|
2010-08-09 13:28:56 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_WIN32)
|
2012-06-18 10:13:51 +00:00
|
|
|
#define getcwd _getcwd
|
|
|
|
#define putenv _putenv
|
|
|
|
#define vsnprintf _vsnprintf
|
2012-02-29 12:59:48 +00:00
|
|
|
inline void usleep(unsigned milliseconds) { Sleep(milliseconds / 1000); }
|
2010-08-09 13:28:56 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//================
|
|
|
|
//inline expansion
|
|
|
|
//================
|
|
|
|
|
2013-04-09 13:31:46 +00:00
|
|
|
#if defined(__clang__) || defined(__GNUC__)
|
2010-08-09 13:28:56 +00:00
|
|
|
#define noinline __attribute__((noinline))
|
|
|
|
#define inline inline
|
|
|
|
#define alwaysinline inline __attribute__((always_inline))
|
|
|
|
#elif defined(_MSC_VER)
|
|
|
|
#define noinline __declspec(noinline)
|
|
|
|
#define inline inline
|
|
|
|
#define alwaysinline inline __forceinline
|
|
|
|
#else
|
|
|
|
#define noinline
|
|
|
|
#define inline inline
|
|
|
|
#define alwaysinline inline
|
|
|
|
#endif
|
|
|
|
|
2013-04-09 13:31:46 +00:00
|
|
|
//===========
|
|
|
|
//unreachable
|
|
|
|
//===========
|
|
|
|
|
|
|
|
#if defined(__clang__) || defined(__GNUC__)
|
|
|
|
#define unreachable __builtin_unreachable()
|
|
|
|
#else
|
|
|
|
#define unreachable throw
|
|
|
|
#endif
|
|
|
|
|
2010-09-22 12:51:52 +00:00
|
|
|
#endif
|