| 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" |
| 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 |
| 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 |
| 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 |