2018-04-13 18:56:43 +02:00
|
|
|
/*
|
|
|
|
port.h -- Portability Layer for Windows types
|
|
|
|
Copyright (C) 2015 Alibek Omarov
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#ifndef PORT_H
|
|
|
|
#define PORT_H
|
|
|
|
|
2019-07-01 04:50:54 +02:00
|
|
|
#include "build.h"
|
2018-04-17 02:46:08 +02:00
|
|
|
|
2019-11-24 01:52:08 +01:00
|
|
|
#if !XASH_WIN32
|
2018-04-13 18:56:43 +02:00
|
|
|
|
2019-07-01 04:50:54 +02:00
|
|
|
|
2019-11-24 01:52:08 +01:00
|
|
|
#if XASH_APPLE
|
2018-04-13 18:56:43 +02:00
|
|
|
#include <sys/syslimits.h>
|
|
|
|
#define OS_LIB_EXT "dylib"
|
2019-05-01 18:21:47 +02:00
|
|
|
#define OPEN_COMMAND "open"
|
2018-04-13 18:56:43 +02:00
|
|
|
#else
|
|
|
|
#define OS_LIB_EXT "so"
|
2019-05-01 18:21:47 +02:00
|
|
|
#define OPEN_COMMAND "xdg-open"
|
2018-04-13 18:56:43 +02:00
|
|
|
#endif
|
|
|
|
|
2019-03-15 19:23:59 +01:00
|
|
|
#define OS_LIB_PREFIX "lib"
|
|
|
|
|
2019-11-24 01:52:08 +01:00
|
|
|
#if XASH_ANDROID
|
2019-05-12 02:00:50 +02:00
|
|
|
//#if defined(LOAD_HARDFP)
|
|
|
|
// #define POSTFIX "_hardfp"
|
|
|
|
//#else
|
2018-04-13 18:56:43 +02:00
|
|
|
#define POSTFIX
|
2019-05-12 02:00:50 +02:00
|
|
|
//#endif
|
2018-04-13 18:56:43 +02:00
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define VGUI_SUPPORT_DLL "libvgui_support." OS_LIB_EXT
|
|
|
|
|
|
|
|
// Windows-specific
|
|
|
|
#define __cdecl
|
2018-05-28 22:44:52 +02:00
|
|
|
#define __stdcall
|
2018-07-12 22:13:30 +02:00
|
|
|
|
2018-04-13 18:56:43 +02:00
|
|
|
#define _inline static inline
|
2019-02-24 16:45:27 +01:00
|
|
|
#define FORCEINLINE inline __attribute__((always_inline))
|
2020-02-08 17:07:56 +01:00
|
|
|
|
|
|
|
#if XASH_POSIX
|
|
|
|
#define PATH_SPLITTER "/"
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <dlfcn.h>
|
2018-04-13 18:56:43 +02:00
|
|
|
#define O_BINARY 0 // O_BINARY is Windows extension
|
|
|
|
#define O_TEXT 0 // O_TEXT is Windows extension
|
2020-02-08 17:07:56 +01:00
|
|
|
// Windows functions to posix equivalent
|
2018-04-13 18:56:43 +02:00
|
|
|
#define _mkdir( x ) mkdir( x, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH )
|
|
|
|
#define LoadLibrary( x ) dlopen( x, RTLD_NOW )
|
|
|
|
#define GetProcAddress( x, y ) dlsym( x, y )
|
|
|
|
#define SetCurrentDirectory( x ) (!chdir( x ))
|
|
|
|
#define FreeLibrary( x ) dlclose( x )
|
2020-02-08 17:07:56 +01:00
|
|
|
#define tell( a ) lseek(a, 0, SEEK_CUR)
|
|
|
|
#define HAVE_DUP
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if XASH_DOS4GW
|
|
|
|
#define PATH_SPLITTER "\\"
|
|
|
|
#define LoadLibrary( x ) (0)
|
|
|
|
#define GetProcAddress( x, y ) (0)
|
|
|
|
#define FreeLibrary( x ) (0)
|
|
|
|
#define SetCurrentDirectory( x ) (!chdir( x ))
|
|
|
|
#endif
|
2018-04-13 18:56:43 +02:00
|
|
|
//#define MAKEWORD( a, b ) ((short int)(((unsigned char)(a))|(((short int)((unsigned char)(b)))<<8)))
|
|
|
|
#define max( a, b ) (((a) > (b)) ? (a) : (b))
|
|
|
|
#define min( a, b ) (((a) < (b)) ? (a) : (b))
|
|
|
|
|
2020-02-08 17:07:56 +01:00
|
|
|
/// TODO: check if we may clean this defines, it should not appear in non-platform code!
|
2018-04-13 18:56:43 +02:00
|
|
|
typedef unsigned char BYTE;
|
|
|
|
typedef short int WORD;
|
|
|
|
typedef unsigned int DWORD;
|
|
|
|
typedef int LONG;
|
|
|
|
typedef unsigned int ULONG;
|
|
|
|
typedef int WPARAM;
|
|
|
|
typedef unsigned int LPARAM;
|
|
|
|
|
|
|
|
typedef void* HANDLE;
|
|
|
|
typedef void* HMODULE;
|
|
|
|
typedef void* HINSTANCE;
|
|
|
|
|
|
|
|
typedef char* LPSTR;
|
|
|
|
|
|
|
|
typedef struct tagPOINT
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
} POINT;
|
|
|
|
#else // WIN32
|
2019-07-01 04:50:54 +02:00
|
|
|
#define PATH_SPLITTER "\\"
|
2018-04-13 18:56:43 +02:00
|
|
|
#ifdef __MINGW32__
|
|
|
|
#define _inline static inline
|
2019-02-24 16:45:27 +01:00
|
|
|
#define FORCEINLINE inline __attribute__((always_inline))
|
|
|
|
#else
|
|
|
|
#define FORCEINLINE __forceinline
|
2018-04-13 18:56:43 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define open _open
|
|
|
|
#define read _read
|
2018-06-14 19:32:31 +02:00
|
|
|
#define alloca _alloca
|
2018-04-13 18:56:43 +02:00
|
|
|
|
|
|
|
// shut-up compiler warnings
|
|
|
|
#pragma warning(disable : 4244) // MIPS
|
|
|
|
#pragma warning(disable : 4018) // signed/unsigned mismatch
|
|
|
|
#pragma warning(disable : 4305) // truncation from const double to float
|
|
|
|
#pragma warning(disable : 4115) // named type definition in parentheses
|
|
|
|
#pragma warning(disable : 4100) // unreferenced formal parameter
|
|
|
|
#pragma warning(disable : 4127) // conditional expression is constant
|
|
|
|
#pragma warning(disable : 4057) // differs in indirection to slightly different base types
|
|
|
|
#pragma warning(disable : 4201) // nonstandard extension used
|
|
|
|
#pragma warning(disable : 4706) // assignment within conditional expression
|
|
|
|
#pragma warning(disable : 4054) // type cast' : from function pointer
|
|
|
|
#pragma warning(disable : 4310) // cast truncates constant value
|
|
|
|
|
|
|
|
#define HSPRITE WINAPI_HSPRITE
|
2019-08-09 01:28:28 +02:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <winsock2.h>
|
2018-04-13 18:56:43 +02:00
|
|
|
#include <windows.h>
|
|
|
|
#undef HSPRITE
|
|
|
|
|
2019-06-29 22:56:50 +02:00
|
|
|
#define OS_LIB_PREFIX ""
|
2018-04-13 18:56:43 +02:00
|
|
|
#define OS_LIB_EXT "dll"
|
|
|
|
#define VGUI_SUPPORT_DLL "../vgui_support." OS_LIB_EXT
|
2019-08-09 01:46:29 +02:00
|
|
|
#ifdef XASH_64BIT
|
|
|
|
// windows NameForFunction not implemented yet
|
|
|
|
#define XASH_ALLOW_SAVERESTORE_OFFSETS
|
|
|
|
#endif
|
2020-02-08 17:07:56 +01:00
|
|
|
#define HAVE_DUP
|
|
|
|
|
2018-04-13 18:56:43 +02:00
|
|
|
#endif //WIN32
|
2019-10-26 02:06:26 +02:00
|
|
|
#ifndef XASH_LOW_MEMORY
|
|
|
|
#define XASH_LOW_MEMORY 0
|
|
|
|
#endif
|
2018-04-13 18:56:43 +02:00
|
|
|
|
2019-08-09 01:46:29 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <limits.h>
|
2018-04-13 18:56:43 +02:00
|
|
|
|
2019-03-30 01:06:23 +01:00
|
|
|
#if defined XASH_SDL && !defined REF_DLL
|
2019-03-16 05:15:06 +01:00
|
|
|
#include <SDL.h>
|
|
|
|
#endif
|
|
|
|
|
2018-04-13 18:56:43 +02:00
|
|
|
#endif // PORT_H
|