Changeset 188 for trunk

Show
Ignore:
Timestamp:
11/19/08 13:44:41 (17 years ago)
Author:
yumileroy
Message:

[svn] Merge define.h from mangos. Hope this will solve the lag problem.

Original author: megamage
Date: 2008-11-07 13:46:47-06:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/framework/Platform/Define.h

    r102 r188  
    11/*  
    2  * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> 
     2 * Copyright (C) 2005-2008 Mangos <http://www.mangosproject.org/> 
    33 * 
    44 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> 
     
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
    1919 */ 
    2020 
     
    2222#define TRINITY_DEFINE_H 
    2323 
    24 #include "Platform/CompilerDefs.h" 
    2524#include <sys/types.h> 
    2625 
    27 /* Endian detection code from sha2.c: 
    28 ------------------------------------------------------------------------- 
    29 Copyright (c) 2001, Dr Brian Gladman <brg@gladman.me.uk>, Worcester, UK. 
    30 All rights reserved. 
     26#include <ace/Basic_Types.h> 
     27#include <ace/ACE_export.h> 
    3128 
    32 TERMS 
    33  
    34 Redistribution and use in source and binary forms, with or without  
    35 modification, are permitted subject to the following conditions: 
    36  
    37 1. Redistributions of source code must retain the above copyright  
    38 notice, this list of conditions and the following disclaimer.  
    39  
    40 2. Redistributions in binary form must reproduce the above copyright 
    41 notice, this list of conditions and the following disclaimer in the  
    42 documentation and/or other materials provided with the distribution.  
    43  
    44 3. The copyright holder's name must not be used to endorse or promote  
    45 any products derived from this software without his specific prior  
    46 written permission.  
    47  
    48 This software is provided 'as is' with no express or implied warranties  
    49 of correctness or fitness for purpose. 
    50 ------------------------------------------------------------------------- 
    51 */ 
    52  
    53 /*  1. PLATFORM SPECIFIC INCLUDES */ 
    54  
    55 #if defined(__GNU_LIBRARY__) 
    56 #  include <endian.h> 
    57 #  include <byteswap.h> 
    58 #elif defined(__CRYPTLIB__) 
    59 #  if defined( INC_ALL ) 
    60 #    include "crypt.h" 
    61 #  elif defined( INC_CHILD ) 
    62 #    include "../crypt.h" 
    63 #  else 
    64 #    include "crypt.h" 
    65 #  endif 
    66 #  if defined(DATA_LITTLEENDIAN) 
    67 #    define PLATFORM_BYTE_ORDER SHA_LITTLE_ENDIAN 
    68 #  else 
    69 #    define PLATFORM_BYTE_ORDER SHA_BIG_ENDIAN 
    70 #  endif 
    71 #elif defined(_MSC_VER) 
    72 #  include <stdlib.h> 
    73 #elif !defined(WIN32) 
    74 #  include <stdlib.h> 
    75 #  if !defined (_ENDIAN_H) 
    76 #    include <sys/param.h> 
    77 #  else 
    78 #    include _ENDIAN_H 
    79 #  endif 
    80 #endif 
    81  
    82 /*  2. BYTE ORDER IN 32-BIT WORDS 
    83  
    84 To obtain the highest speed on processors with 32-bit words, this code  
    85 needs to determine the order in which bytes are packed into such words. 
    86 The following block of code is an attempt to capture the most obvious  
    87 ways in which various environemnts specify their endian definitions.  
    88 It may well fail, in which case the definitions will need to be set by  
    89 editing at the points marked **** EDIT HERE IF NECESSARY **** below. 
    90 */ 
     29#include "Platform/CompilerDefs.h" 
    9130 
    9231#define TRINITY_LITTLEENDIAN 0 
     
    9433 
    9534#if !defined(TRINITY_ENDIAN) 
    96 #  if defined(LITTLE_ENDIAN) || defined(BIG_ENDIAN) 
    97 #    if defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN) 
    98 #      if defined(BYTE_ORDER) 
    99 #        if   (BYTE_ORDER == LITTLE_ENDIAN) 
    100 #          define TRINITY_ENDIAN TRINITY_LITTLEENDIAN 
    101 #        elif (BYTE_ORDER == BIG_ENDIAN) 
    102 #          define TRINITY_ENDIAN TRINITY_BIGENDIAN 
    103 #        endif 
    104 #      endif 
    105 #    elif defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)  
    106 #      define TRINITY_ENDIAN TRINITY_LITTLEENDIAN 
    107 #    elif !defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN) 
    108 #      define TRINITY_ENDIAN TRINITY_BIGENDIAN 
    109 #    endif 
    110 #  elif defined(_LITTLE_ENDIAN) || defined(_BIG_ENDIAN) 
    111 #    if defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN) 
    112 #      if defined(_BYTE_ORDER) 
    113 #        if   (_BYTE_ORDER == _LITTLE_ENDIAN) 
    114 #          define TRINITY_ENDIAN TRINITY_LITTLEENDIAN 
    115 #        elif (_BYTE_ORDER == _BIG_ENDIAN) 
    116 #          define TRINITY_ENDIAN TRINITY_BIGENDIAN 
    117 #        endif 
    118 #      endif 
    119 #    elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)  
    120 #      define TRINITY_ENDIAN TRINITY_LITTLE_ENDIAN 
    121 #    elif !defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN) 
    122 #      define TRINITY_ENDIAN TRINITY_BIGENDIAN 
    123 #    endif 
    124 #  elif 0     /* **** EDIT HERE IF NECESSARY **** */ 
     35#  if defined (ACE_BIG_ENDIAN) 
     36#    define TRINITY_ENDIAN TRINITY_BIGENDIAN 
     37#  else //ACE_BYTE_ORDER != ACE_BIG_ENDIAN 
    12538#    define TRINITY_ENDIAN TRINITY_LITTLEENDIAN 
    126 #  elif 0     /* **** EDIT HERE IF NECESSARY **** */ 
    127 #    define TRINITY_ENDIAN TRINITY_BIGENDIAN 
    128 #  elif (('1234' >> 24) == '1') 
    129 #    define TRINITY_ENDIAN TRINITY_LITTLEENDIAN 
    130 #  elif (('4321' >> 24) == '1') 
    131 #    define TRINITY_ENDIAN TRINITY_BIGENDIAN 
    132 #  else 
    133 #    define TRINITY_ENDIAN TRINITY_LITTLEENDIAN 
    134 #  endif 
    135 #endif 
    136  
    137 /* End of Endian detection code from sha2.c: */ 
     39#  endif //ACE_BYTE_ORDER 
     40#endif //TRINITY_ENDIAN 
    13841 
    13942#if PLATFORM == PLATFORM_WINDOWS 
    140 #define TRINITY_EXPORT __declspec(dllexport) 
    141 #define TRINITY_LIBRARY_HANDLE HMODULE 
    142 #define TRINITY_LOAD_LIBRARY(a) LoadLibrary(a) 
    143 #define TRINITY_CLOSE_LIBRARY FreeLibrary 
    144 #define TRINITY_GET_PROC_ADDR GetProcAddress 
    145 #define TRINITY_IMPORT __cdecl 
    146 #define TRINITY_SCRIPT_EXT ".dll" 
    147 #define TRINITY_SCRIPT_NAME "TrinityScript" 
    148 #else 
    149 #define TRINITY_LIBRARY_HANDLE void* 
    150 #define TRINITY_EXPORT export 
    151 #define TRINITY_LOAD_LIBRARY(a) dlopen(a,RTLD_NOW) 
    152 #define TRINITY_CLOSE_LIBRARY dlclose 
    153 #define TRINITY_GET_PROC_ADDR dlsym 
     43#  define TRINITY_EXPORT __declspec(dllexport) 
     44#  define TRINITY_LIBRARY_HANDLE HMODULE 
     45#  define TRINITY_LOAD_LIBRARY(a) LoadLibrary(a) 
     46#  define TRINITY_CLOSE_LIBRARY FreeLibrary 
     47#  define TRINITY_GET_PROC_ADDR GetProcAddress 
     48#  define TRINITY_IMPORT __cdecl 
     49#  define TRINITY_SCRIPT_EXT ".dll" 
     50#  define TRINITY_SCRIPT_NAME "TrinityScript" 
     51#else //PLATFORM != PLATFORM_WINDOWS 
     52#  define TRINITY_LIBRARY_HANDLE void* 
     53#  define TRINITY_EXPORT export 
     54#  define TRINITY_LOAD_LIBRARY(a) dlopen(a,RTLD_NOW) 
     55#  define TRINITY_CLOSE_LIBRARY dlclose 
     56#  define TRINITY_GET_PROC_ADDR dlsym 
     57#  if defined(__APPLE_CC__) && defined(BIG_ENDIAN) 
     58#    define TRINITY_IMPORT __attribute__ ((longcall)) 
     59#  else 
     60#    define TRINITY_IMPORT __attribute__ ((cdecl)) 
     61#  endif //__APPLE_CC__ && BIG_ENDIAN 
     62#  define TRINITY_SCRIPT_EXT ".so" 
     63#  define TRINITY_SCRIPT_NAME "libtrinityscript" 
     64#endif //PLATFORM 
    15465 
    155 #if defined(__APPLE_CC__) && defined(BIG_ENDIAN) 
    156 #define TRINITY_IMPORT __attribute__ ((longcall)) 
    157 #else 
    158 #define TRINITY_IMPORT __attribute__ ((cdecl)) 
    159 #endif 
    160  
    161 #define TRINITY_SCRIPT_EXT ".so" 
    162 #define TRINITY_SCRIPT_NAME "libtrinityscript" 
    163 #endif 
    164  
    165 #ifdef WIN32 
    166 #ifdef TRINITY_WIN32_DLL_IMPORT 
    167  
    168 #define TRINITY_DLL_DECL __declspec(dllimport) 
    169 #else 
    170 #ifdef TRINITY_WIND_DLL_EXPORT 
    171 #define TRINITY_DLL_DECL __declspec(dllexport) 
    172 #else 
    173 #define TRINITY_DLL_DECL 
    174 #endif 
    175 #endif 
    176  
    177 #else 
    178 #define TRINITY_DLL_DECL 
    179 #endif 
    180  
    181 #ifndef DEBUG 
    182 #define TRINITY_INLINE inline 
    183 #else 
    184 #ifndef TRINITY_DEBUG 
    185 #define TRINITY_DEBUG 
    186 #endif 
    187 #define TRINITY_INLINE 
    188 #endif 
    189  
    190 #if COMPILER == COMPILER_MICROSOFT 
    191 typedef __int64            int64; 
    192 typedef __int32            int32; 
    193 typedef __int16            int16; 
    194 typedef __int8             int8; 
    195 typedef unsigned __int64   uint64; 
    196 typedef unsigned __int32   uint32; 
    197 typedef unsigned __int16   uint16; 
    198 typedef unsigned __int8    uint8; 
    199 #else 
    200 typedef __int64_t   int64; 
    201 typedef __int32_t   int32; 
    202 typedef __int16_t   int16; 
    203 typedef __int8_t    int8; 
    204 typedef __uint64_t  uint64; 
    205 typedef __uint32_t  uint32; 
    206 typedef __uint16_t  uint16; 
    207 typedef __uint8_t   uint8; 
    208 typedef uint16      WORD; 
    209 typedef uint32      DWORD; 
    210 #endif 
    211 typedef uint64      OBJECT_HANDLE; 
     66#if PLATFORM == PLATFORM_WINDOWS 
     67#  ifdef TRINITY_WIN32_DLL_IMPORT 
     68#    define TRINITY_DLL_DECL __declspec(dllimport) 
     69#  else //!TRINITY_WIN32_DLL_IMPORT 
     70#    ifdef TRINITY_WIND_DLL_EXPORT 
     71#      define TRINITY_DLL_DECL __declspec(dllexport) 
     72#    else //!TRINITY_WIND_DLL_EXPORT 
     73#      define TRINITY_DLL_DECL 
     74#    endif //TRINITY_WIND_DLL_EXPORT 
     75#  endif //TRINITY_WIN32_DLL_IMPORT 
     76#else //PLATFORM != PLATFORM_WINDOWS 
     77#  define TRINITY_DLL_DECL 
     78#endif //PLATFORM 
    21279 
    21380#if PLATFORM == PLATFORM_WINDOWS 
     
    21582#  ifndef DECLSPEC_NORETURN 
    21683#    define DECLSPEC_NORETURN __declspec(noreturn) 
    217 #  endif 
    218 #else 
     84#  endif //DECLSPEC_NORETURN 
     85#else //PLATFORM != PLATFORM_WINDOWS 
    21986#  define TRINITY_DLL_SPEC 
    22087#  define DECLSPEC_NORETURN 
    221 #endif 
     88#endif //PLATFORM 
     89 
     90#if !defined(DEBUG) 
     91#  define TRINITY_INLINE inline 
     92#else //DEBUG 
     93#  if !defined(TRINITY_DEBUG) 
     94#    define TRINITY_DEBUG 
     95#  endif //TRINITY_DEBUG 
     96#  define TRINITY_INLINE 
     97#endif //!DEBUG 
    22298 
    22399#if COMPILER == COMPILER_GNU 
    224100#  define ATTR_NORETURN __attribute__((noreturn)) 
    225101#  define ATTR_PRINTF(F,V) __attribute__ ((format (printf, F, V))) 
    226 #else 
     102#else //COMPILER != COMPILER_GNU 
    227103#  define ATTR_NORETURN 
    228104#  define ATTR_PRINTF(F,V) 
    229 #endif 
     105#endif //COMPILER == COMPILER_GNU 
    230106 
    231 #endif 
     107typedef ACE_INT64 int64; 
     108typedef ACE_INT32 int32; 
     109typedef ACE_INT16 int16; 
     110typedef ACE_INT8 int8; 
     111typedef ACE_UINT64 uint64; 
     112typedef ACE_UINT32 uint32; 
     113typedef ACE_UINT16 uint16; 
     114typedef ACE_UINT8 uint8; 
     115 
     116#if COMPILER != COMPILER_MICROSOFT 
     117typedef uint16      WORD; 
     118typedef uint32      DWORD; 
     119#endif //COMPILER 
     120 
     121typedef uint64 OBJECT_HANDLE; 
     122 
     123#endif //TRINITY_DEFINE_H