]> icculus.org git repositories - taylor/freespace2.git/blob - include/unix.h
Various 64-bit platform fixes
[taylor/freespace2.git] / include / unix.h
1 // unix.h - duplicates some MS defines
2
3 #ifndef _UNIX_H
4 #define _UNIX_H
5
6 #include <stdio.h>
7 #include <sys/types.h>
8 #include <unistd.h>
9 #include "SDL.h"
10
11 #define TRUE 1
12 #define FALSE 0
13 #define _MAX_FNAME 255
14 #define _MAX_PATH 255
15 #define MAX_PATH 255
16 #define _MAX_DIR 256
17 #define MAX_FILENAME_LENGTH 64
18 #define _cdecl
19 #define __cdecl
20 #define __int64 long long
21 #define LARGE_INTEGER long long
22 #define stricmp strcasecmp
23 #define strnicmp strncasecmp
24 #define _strnicmp strncasecmp
25 #define _isnan isnan
26 #define HANDLE int
27 #define HINSTANCE int
28 #define _getcwd getcwd
29 #define _chdir chdir
30 #define _strlwr strlwr
31 #define _unlink unlink
32 #define _mkdir mkdir
33 #define _hypot hypot
34 #define _access access
35 #define byte unsigned char
36 #define __try try
37 #define __except catch
38 #define LPSTR char *
39 #define PASCAL
40 #define CALLBACK
41
42 #if ( defined(__x86_64__) || defined(_WIN64) )
43 typedef unsigned int DWORD;
44 #else
45 typedef unsigned long DWORD;
46 #endif
47 typedef unsigned short WORD;
48
49 extern void strlwr (char *str);
50 extern int filelength (int fd);
51 extern int MulDiv (int, int, int);
52
53 extern void Sleep (int miliseconds);
54 extern unsigned long _beginthread (void (*pfuncStart)(void *), unsigned unStackSize, void* pArgList);
55 extern void OutputDebugString (const char *);
56 extern int WSAGetLastError ();
57 extern void _splitpath (const char *path, char *drive, char *dir, char *fname, char *ext);
58
59 typedef struct FILETIME_s {
60             DWORD dwLowDateTime;
61             DWORD dwHighDateTime;
62 } FILETIME, *PFILETIME;
63
64 #define WAVE_FORMAT_PCM         1
65 #define WAVE_FORMAT_ADPCM       2
66
67 // these structures are packed on WIN32 so do it here too
68 #pragma pack(push, 1)
69 typedef struct {
70         WORD wFormatTag;
71         WORD nChannels;
72         DWORD nSamplesPerSec;
73         DWORD nAvgBytesPerSec;
74         WORD nBlockAlign;
75 } WAVEFORMAT;
76                     
77 typedef struct {
78         WAVEFORMAT wf;
79         WORD wBitsPerSample;
80 } PCMWAVEFORMAT;
81
82 typedef struct {
83         WORD  wFormatTag;
84         WORD  nChannels;
85         DWORD nSamplesPerSec;
86         DWORD nAvgBytesPerSec;
87         WORD  nBlockAlign;
88         WORD  wBitsPerSample;
89         WORD  cbSize;
90 } WAVEFORMATEX;
91 #pragma pack(pop)
92
93 #define CRITICAL_SECTION SDL_mutex*
94
95 #define closesocket(A) close(A)
96 #define CopyMemory(A,B,C) memcpy(A,B,C)
97 #define UINT unsigned int
98 #define SOCKET int
99 #define SOCKADDR_IN struct sockaddr_in
100 #define SOCKADDR struct sockaddr
101 #define LPSOCKADDR struct sockaddr*
102 #define LPHOSTENT struct hostent*
103 #define HOSTENT struct hostent
104 #define LPINADDR struct in_addr*
105 #define LPIN_ADDR struct in_addr*
106 #define SOCKET_ERROR -1
107 #define INVALID_SOCKET -1
108 #define TIMEVAL struct timeval
109 #define SERVENT struct servent
110 #define BOOL int
111
112 #define WSAEALREADY EALREADY
113 #define WSAEINVAL EINVAL
114 #define WSAEWOULDBLOCK EAGAIN
115 #define WSAEISCONN EISCONN
116 #define WSAECONNRESET ECONNRESET
117 #define WSAECONNABORTED ECONNABORTED
118 #define WSAESHUTDOWN ESHUTDOWN
119 #define WSAENOTSOCK ENOTSOCK
120
121 #endif