12 #ifndef __CASCPORT_H__
13 #define __CASCPORT_H__
24 #if !defined(PLATFORM_DEFINED) && (defined(WIN32) || defined(WIN64))
28 #define _CRT_SECURE_NO_DEPRECATE
29 #define _CRT_NON_CONFORMING_SWPRINTFS
38 #include <sys/types.h>
39 #define PLATFORM_LITTLE_ENDIAN
42 #define PLATFORM_64BIT
44 #define PLATFORM_32BIT
47 #define PATH_SEPARATOR '\\'
48 #define CREATE_DIRECTORY(name) CreateDirectory(name, NULL);
50 #define PLATFORM_WINDOWS
51 #define PLATFORM_DEFINED // The platform is known now
58 #if !defined(PLATFORM_DEFINED) && defined(__APPLE__) // Mac BSD API
61 #include <sys/types.h>
72 #if (__ppc__ == 1) || (__POWERPC__ == 1) || (_ARCH_PPC == 1)
74 #include <CoreFoundation/CFByteOrder.h>
81 #ifndef __BIG_ENDIAN__
82 #define PLATFORM_LITTLE_ENDIAN
85 #define PATH_SEPARATOR '/'
86 #define CREATE_DIRECTORY(name) mkdir(name, 0755)
89 #define PLATFORM_DEFINED // The platform is known now
91 #define FIELD_OFFSET(t,f) offsetof(t,f)
97 #if !defined(PLATFORM_DEFINED)
99 #include <sys/types.h>
100 #include <sys/stat.h>
101 #include <sys/mman.h>
115 #define PATH_SEPARATOR '/'
116 #define CREATE_DIRECTORY(name) mkdir(name, 0755)
118 #define PLATFORM_LITTLE_ENDIAN
119 #define PLATFORM_LINUX
120 #define PLATFORM_DEFINED
122 #define FIELD_OFFSET(t,f) offsetof(t,f)
128 #ifndef PLATFORM_WINDOWS
130 #define PLATFORM_64BIT
132 #define PLATFORM_32BIT
154 #ifdef PLATFORM_32BIT
155 #define _LZMA_UINT32_IS_ULONG
160 #define MAX_PATH 1024
165 #define FILE_BEGIN SEEK_SET
166 #define FILE_CURRENT SEEK_CUR
167 #define FILE_END SEEK_END
169 #define INVALID_HANDLE_VALUE ((HANDLE)-1)
172 #define _tcslen strlen
173 #define _tcscpy strcpy
174 #define _tcscat strcat
175 #define _tcschr strchr
176 #define _tcsrchr strrchr
177 #define _tcsstr strstr
178 #define _tcsspn strspn
179 #define _tcsncmp strncmp
180 #define _tprintf printf
181 #define _stprintf sprintf
182 #define _tremove remove
183 #define _tmkdir mkdir
185 #define _stricmp strcasecmp
186 #define _strnicmp strncasecmp
187 #define _tcsicmp strcasecmp
188 #define _tcsnicmp strncasecmp
190 #endif // !PLATFORM_WINDOWS
193 #if defined(PLATFORM_MAC)
195 #define fstat64 fstat
196 #define lseek64 lseek
197 #define ftruncate64 ftruncate
198 #define off64_t off_t
199 #define O_LARGEFILE 0
203 #if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
204 #define ERROR_SUCCESS 0
205 #define ERROR_FILE_NOT_FOUND ENOENT
206 #define ERROR_ACCESS_DENIED EPERM
207 #define ERROR_INVALID_HANDLE EBADF
208 #define ERROR_NOT_ENOUGH_MEMORY ENOMEM
209 #define ERROR_NOT_SUPPORTED ENOTSUP
210 #define ERROR_INVALID_PARAMETER EINVAL
211 #define ERROR_DISK_FULL ENOSPC
212 #define ERROR_ALREADY_EXISTS EEXIST
213 #define ERROR_INSUFFICIENT_BUFFER ENOBUFS
214 #define ERROR_BAD_FORMAT 1000 // No such error code under Linux
215 #define ERROR_NO_MORE_FILES 1001 // No such error code under Linux
216 #define ERROR_HANDLE_EOF 1002 // No such error code under Linux
217 #define ERROR_CAN_NOT_COMPLETE 1003 // No such error code under Linux
218 #define ERROR_FILE_CORRUPT 1004 // No such error code under Linux
224 #ifdef PLATFORM_LITTLE_ENDIAN
225 #define BSWAP_INT16_UNSIGNED(a) (a)
226 #define BSWAP_INT16_SIGNED(a) (a)
227 #define BSWAP_INT32_UNSIGNED(a) (a)
228 #define BSWAP_INT32_SIGNED(a) (a)
229 #define BSWAP_INT64_SIGNED(a) (a)
230 #define BSWAP_INT64_UNSIGNED(a) (a)
231 #define BSWAP_ARRAY16_UNSIGNED(a,b) {}
232 #define BSWAP_ARRAY32_UNSIGNED(a,b) {}
233 #define BSWAP_ARRAY64_UNSIGNED(a,b) {}
245 void ConvertUInt16Buffer(
void * ptr,
size_t length);
246 void ConvertUInt32Buffer(
void * ptr,
size_t length);
247 void ConvertUInt64Buffer(
void * ptr,
size_t length);
251 #define BSWAP_INT16_SIGNED(a) SwapInt16((a))
252 #define BSWAP_INT16_UNSIGNED(a) SwapUInt16((a))
253 #define BSWAP_INT32_SIGNED(a) SwapInt32((a))
254 #define BSWAP_INT32_UNSIGNED(a) SwapUInt32((a))
255 #define BSWAP_INT64_SIGNED(a) SwapInt64((a))
256 #define BSWAP_INT64_UNSIGNED(a) SwapUInt64((a))
257 #define BSWAP_ARRAY16_UNSIGNED(a,b) ConvertUInt16Buffer((a),(b))
258 #define BSWAP_ARRAY32_UNSIGNED(a,b) ConvertUInt32Buffer((a),(b))
259 #define BSWAP_ARRAY64_UNSIGNED(a,b) ConvertUInt64Buffer((a),(b))
262 #endif // __CASCPORT_H__
void * HANDLE
Definition: CascPort.h:146
unsigned long long ULONGLONG
Definition: CascPort.h:144
DWORD * PDWORD
Definition: CascPort.h:151
signed short int16_t
Definition: stdint.h:76
void * LPOVERLAPPED
Definition: CascPort.h:147
char TCHAR
Definition: CascPort.h:148
int LONG
Definition: CascPort.h:138
signed __int64 int64_t
Definition: stdint.h:89
BYTE * LPBYTE
Definition: CascPort.h:152
LONG * PLONG
Definition: CascPort.h:150
unsigned short USHORT
Definition: CascPort.h:137
unsigned int uint32_t
Definition: stdint.h:80
unsigned long long * PULONGLONG
Definition: CascPort.h:145
unsigned __int64 uint64_t
Definition: stdint.h:90
unsigned long DWORD_PTR
Definition: CascPort.h:140
unsigned int LCID
Definition: CascPort.h:149
long LONG_PTR
Definition: CascPort.h:141
unsigned int DWORD
Definition: CascPort.h:139
float length(float v)
Definition: vectorMath.h:208
long long LONGLONG
Definition: CascPort.h:143
signed int int32_t
Definition: stdint.h:77
unsigned char BYTE
Definition: CascPort.h:136
unsigned short uint16_t
Definition: stdint.h:79
long INT_PTR
Definition: CascPort.h:142