Correct check for ACE_BIG_ENDIAN. Warning fixed and code cleanups.
[auctionmangos.git] / src / framework / Platform / Define.h
blobadd74f347ce145a1cf0fd9f0ad2643720f11fb37
1 /*
2 * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef MANGOS_DEFINE_H
20 #define MANGOS_DEFINE_H
22 #include <sys/types.h>
24 #include <ace/Basic_Types.h>
25 #include <ace/ACE_export.h>
27 #include "Platform/CompilerDefs.h"
29 #define MANGOS_LITTLEENDIAN 0
30 #define MANGOS_BIGENDIAN 1
32 #if !defined(MANGOS_ENDIAN)
33 # if defined (ACE_BIG_ENDIAN)
34 # define MANGOS_ENDIAN MANGOS_BIGENDIAN
35 # else //ACE_BYTE_ORDER != ACE_BIG_ENDIAN
36 # define MANGOS_ENDIAN MANGOS_LITTLEENDIAN
37 # endif //ACE_BYTE_ORDER
38 #endif //MANGOS_ENDIAN
40 #if PLATFORM == PLATFORM_WINDOWS
41 # define MANGOS_EXPORT __declspec(dllexport)
42 # define MANGOS_LIBRARY_HANDLE HMODULE
43 # define MANGOS_LOAD_LIBRARY(a) LoadLibrary(a)
44 # define MANGOS_CLOSE_LIBRARY FreeLibrary
45 # define MANGOS_GET_PROC_ADDR GetProcAddress
46 # define MANGOS_IMPORT __cdecl
47 # define MANGOS_SCRIPT_EXT ".dll"
48 # define MANGOS_SCRIPT_NAME "MaNGOSScript"
49 #else //PLATFORM != PLATFORM_WINDOWS
50 # define MANGOS_LIBRARY_HANDLE void*
51 # define MANGOS_EXPORT export
52 # define MANGOS_LOAD_LIBRARY(a) dlopen(a,RTLD_NOW)
53 # define MANGOS_CLOSE_LIBRARY dlclose
54 # define MANGOS_GET_PROC_ADDR dlsym
55 # if defined(__APPLE_CC__) && defined(BIG_ENDIAN)
56 # define MANGOS_IMPORT __attribute__ ((longcall))
57 # else
58 # define MANGOS_IMPORT __attribute__ ((cdecl))
59 # endif //__APPLE_CC__ && BIG_ENDIAN
60 # define MANGOS_SCRIPT_EXT ".so"
61 # define MANGOS_SCRIPT_NAME "libmangosscript"
62 #endif //PLATFORM
64 #if PLATFORM == PLATFORM_WINDOWS
65 # ifdef MANGOS_WIN32_DLL_IMPORT
66 # define MANGOS_DLL_DECL __declspec(dllimport)
67 # else //!MANGOS_WIN32_DLL_IMPORT
68 # ifdef MANGOS_WIND_DLL_EXPORT
69 # define MANGOS_DLL_DECL __declspec(dllexport)
70 # else //!MANGOS_WIND_DLL_EXPORT
71 # define MANGOS_DLL_DECL
72 # endif //MANGOS_WIND_DLL_EXPORT
73 # endif //MANGOS_WIN32_DLL_IMPORT
74 #else //PLATFORM != PLATFORM_WINDOWS
75 # define MANGOS_DLL_DECL
76 #endif //PLATFORM
78 #if PLATFORM == PLATFORM_WINDOWS
79 # define MANGOS_DLL_SPEC __declspec(dllexport)
80 # ifndef DECLSPEC_NORETURN
81 # define DECLSPEC_NORETURN __declspec(noreturn)
82 # endif //DECLSPEC_NORETURN
83 #else //PLATFORM != PLATFORM_WINDOWS
84 # define MANGOS_DLL_SPEC
85 # define DECLSPEC_NORETURN
86 #endif //PLATFORM
88 #if !defined(DEBUG)
89 # define MANGOS_INLINE inline
90 #else //DEBUG
91 # if !defined(MANGOS_DEBUG)
92 # define MANGOS_DEBUG
93 # endif //MANGOS_DEBUG
94 # define MANGOS_INLINE
95 #endif //!DEBUG
97 #if COMPILER == COMPILER_GNU
98 # define ATTR_NORETURN __attribute__((noreturn))
99 # define ATTR_PRINTF(F,V) __attribute__ ((format (printf, F, V)))
100 #else //COMPILER != COMPILER_GNU
101 # define ATTR_NORETURN
102 # define ATTR_PRINTF(F,V)
103 #endif //COMPILER == COMPILER_GNU
105 typedef ACE_INT64 int64;
106 typedef ACE_INT32 int32;
107 typedef ACE_INT16 int16;
108 typedef ACE_INT8 int8;
109 typedef ACE_UINT64 uint64;
110 typedef ACE_UINT32 uint32;
111 typedef ACE_UINT16 uint16;
112 typedef ACE_UINT8 uint8;
114 #if COMPILER != COMPILER_MICROSOFT
115 typedef uint16 WORD;
116 typedef uint32 DWORD;
117 #endif //COMPILER
119 typedef uint64 OBJECT_HANDLE;
121 #endif //MANGOS_DEFINE_H