core/metamod_oslink.h
author Nicholas Hastings <skamonkey@gmail.com>
Wed May 21 17:26:09 2014 -0400 (2014-05-21)
changeset 917 95639ee45d3d
parent 780 35f2a207badf
permissions -rw-r--r--
Trigger build for hl2sdk-l4d changes.
     1 /**
     2  * vim: set ts=4 sw=4 tw=99 noet :
     3  * ======================================================
     4  * Metamod:Source
     5  * Copyright (C) 2004-2009 AlliedModders LLC and authors.
     6  * All rights reserved.
     7  * ======================================================
     8  *
     9  * This software is provided 'as-is', without any express or implied warranty.
    10  * In no event will the authors be held liable for any damages arising from 
    11  * the use of this software.
    12  * 
    13  * Permission is granted to anyone to use this software for any purpose, 
    14  * including commercial applications, and to alter it and redistribute it 
    15  * freely, subject to the following restrictions:
    16  *
    17  * 1. The origin of this software must not be misrepresented; you must not 
    18  * claim that you wrote the original software. If you use this software in a 
    19  * product, an acknowledgment in the product documentation would be 
    20  * appreciated but is not required.
    21  * 2. Altered source versions must be plainly marked as such, and must not be
    22  * misrepresented as being the original software.
    23  * 3. This notice may not be removed or altered from any source distribution.
    24  */
    25 
    26 #ifndef _INCLUDE_OSLINK_H
    27 #define _INCLUDE_OSLINK_H
    28 
    29 /**
    30  * @brief Defines OS-independent information
    31  * @file oslink.h
    32  */
    33 
    34 #if defined __WIN32__ || defined _WIN32 || defined WIN32
    35 	#define WIN32_LEAN_AND_MEAN
    36 	#define OS_WIN32
    37 	#if defined _MSC_VER && _MSC_VER >= 1400
    38 		#undef ARRAYSIZE
    39 	#else
    40 		#define mkdir(a) _mkdir(a)
    41 	#endif
    42 	#include <windows.h>
    43 	#include <io.h>
    44 	#include <direct.h>
    45 	#define		dlmount(x)		LoadLibrary(x)
    46 	#define		dlsym(x, s)		GetProcAddress(x, s)
    47 	#define		dlclose(x)		FreeLibrary(x)
    48 	const char*	dlerror();
    49 	#define		abspath(x, s)	_fullpath(x, s, sizeof(x))
    50 	#define	PATH_SEP_STR		"\\"
    51 	#define PATH_SEP_CHAR		'\\'
    52 	#define ALT_SEP_CHAR		'/'
    53 	#define PATH_SIZE			MAX_PATH
    54 	#define strcasecmp			stricmp
    55 	inline bool _IsPathSepChar(char c) { return (c == '/' || c == '\\'); }
    56 #elif defined __linux__ || defined __APPLE__
    57 	#if defined __linux__
    58 		#define OS_LINUX
    59 	#elif defined __APPLE__
    60 		#define OS_DARWIN
    61 		#include <sys/syslimits.h>
    62 	#endif
    63 	#include <dlfcn.h>
    64 	#include <unistd.h>
    65 	#include <sys/types.h>
    66 	#include <dirent.h>
    67 	typedef		void*			HINSTANCE;
    68 	#define		dlmount(x)		dlopen(x,RTLD_NOW)
    69 	#define		abspath(x, s)	realpath(s, x)
    70 	#define	PATH_SEP_STR		"/"
    71 	#define PATH_SEP_CHAR		'/'
    72 	#define ALT_SEP_CHAR		'\\'
    73 	#define PATH_SIZE			PATH_MAX
    74 	#ifndef stricmp
    75 		#define	stricmp			strcasecmp
    76 	#endif
    77 	#ifndef strnicmp
    78 		#define strnicmp		strncasecmp
    79 	#endif
    80 	inline bool _IsPathSepChar(char c) { return (c == '/'); }
    81 #endif
    82 
    83 #if defined __linux__ || defined __APPLE__
    84 	#include <errno.h>
    85 	int GetLastError();
    86 #endif
    87 
    88 bool GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength);
    89 
    90 #if defined __WIN32__ || defined _WIN32 || defined WIN32
    91 	#define SMM_API extern "C" __declspec(dllexport)
    92 #elif defined __GNUC__
    93 	#if (__GNUC__ == 4)
    94 		#define SMM_API extern "C" __attribute__ ((visibility("default")))	
    95 	#else
    96 		#define SMM_API	extern "C" 
    97 	#endif	
    98 #endif
    99 
   100 #if defined __WIN32__ || defined _WIN32 || defined WIN32
   101 	typedef __int64				int64_t;
   102 	typedef unsigned __int64	uint64_t;
   103 	typedef __int32				int32_t;
   104 	typedef unsigned __int32	uint32_t;
   105 #elif defined __GNUC__
   106 #include <stdint.h>
   107 #if !__GLIBC_HAVE_LONG_LONG
   108 	typedef long long			int64_t;
   109 	typedef unsigned long long	uint64_t;
   110 #endif
   111 #endif
   112 
   113 #if !defined __linux__ && !defined __APPLE__
   114 	#define snprintf	_snprintf
   115 	#if defined _MSC_VER && _MSC_VER < 1500
   116 		#define vsnprintf	_vsnprintf
   117 	#endif
   118 #endif
   119 
   120 #endif //_INCLUDE_OSLINK_H