2 |
|
/* |
3 |
|
* platform.h - header file for platform specific definitions |
4 |
|
*/ |
5 |
– |
|
6 |
– |
#include "copyright.h" |
7 |
– |
|
8 |
– |
|
5 |
|
#ifndef _RAD_PLATFORM_H_ |
6 |
|
#define _RAD_PLATFORM_H_ |
7 |
|
|
8 |
+ |
#if defined(_WIN32) || defined(_WIN64) |
9 |
|
|
10 |
< |
#ifdef _WIN32 |
10 |
> |
#include <io.h> /* _setmode() and stuff from unistd.h */ |
11 |
> |
#include <stdio.h> |
12 |
> |
typedef long off_t; |
13 |
> |
#undef fdopen |
14 |
> |
#define fdopen _fdopen |
15 |
> |
#undef read |
16 |
> |
#define read _read |
17 |
> |
#undef open |
18 |
> |
#define open _open |
19 |
> |
#undef close |
20 |
> |
#define close _close |
21 |
> |
#undef write |
22 |
> |
#define write _write |
23 |
> |
#undef ftruncate |
24 |
> |
#define ftruncate _chsize_s |
25 |
> |
#undef unlink |
26 |
> |
#define unlink _unlink |
27 |
> |
#undef fileno |
28 |
> |
#define fileno _fileno |
29 |
> |
#undef snprintf |
30 |
> |
#define snprintf _snprintf |
31 |
> |
#undef vsnprintf |
32 |
> |
#define vsnprintf _vsnprintf |
33 |
> |
/* XXX should we check first if size_t is 32 bit? */ |
34 |
> |
#undef fseeko |
35 |
> |
#define fseeko _fseeki64 |
36 |
> |
#undef lseek |
37 |
> |
#define lseek _lseek |
38 |
> |
#undef access |
39 |
> |
#define access _access |
40 |
> |
#undef mktemp |
41 |
> |
#define mktemp _mktemp |
42 |
|
|
43 |
< |
#include <stdio.h> /* fileno() */ |
44 |
< |
#include <fcntl.h> /* _O_BINARY, _O_TEXT */ |
45 |
< |
#include <io.h> /* _setmode() */ |
46 |
< |
#include <stdlib.h> /* _fmode */ |
43 |
> |
#include <string.h> |
44 |
> |
#undef strcasecmp |
45 |
> |
#define strcasecmp _stricmp |
46 |
> |
#undef strncasecmp |
47 |
> |
#define strncasecmp _strnicmp |
48 |
> |
#undef strdup |
49 |
> |
#define strdup _strdup |
50 |
|
|
51 |
< |
#define SET_DEFAULT_BINARY() _fmode = _O_BINARY |
52 |
< |
#define SET_FILE_BINARY(fp) _setmode(fileno(fp),_O_BINARY) |
53 |
< |
#define SET_FD_BINARY(fd) _setmode(fd,_O_BINARY) |
51 |
> |
#include <windows.h> |
52 |
> |
/* really weird defines by Microsoft in <resource.h> |
53 |
> |
generating lots of name collisions in Radiance. */ |
54 |
> |
#if defined(rad1) |
55 |
> |
#undef rad1 |
56 |
> |
#undef rad2 |
57 |
> |
#undef rad3 |
58 |
> |
#undef rad4 |
59 |
> |
#undef rad5 |
60 |
> |
#undef rad6 |
61 |
> |
#undef rad7 |
62 |
> |
#undef rad8 |
63 |
> |
#undef rad9 |
64 |
> |
#endif |
65 |
> |
#define sleep(s) Sleep((DWORD)((s)*1000)) |
66 |
|
|
67 |
+ |
#define NON_POSIX |
68 |
|
|
69 |
+ |
#include <sys/types.h> |
70 |
+ |
#include <sys/stat.h> |
71 |
+ |
#define RHAS_STAT |
72 |
+ |
#define S_IFREG _S_IFREG |
73 |
+ |
#define W_IFDIR _S_IFDIR |
74 |
|
|
75 |
+ |
#include <fcntl.h> /* _O_BINARY, _O_TEXT */ |
76 |
+ |
#include <stdlib.h> /* _fmode */ |
77 |
+ |
#define SET_DEFAULT_BINARY() (_fmode = _O_BINARY) |
78 |
+ |
#define SET_DEFAULT_TEXT() (_fmode = _O_TEXT) |
79 |
+ |
#define SET_FILE_BINARY(fp) _setmode(_fileno(fp),_O_BINARY) |
80 |
+ |
#define SET_FILE_TEXT(fp) _setmode(_fileno(fp),_O_TEXT) |
81 |
+ |
#define SET_FD_BINARY(fd) _setmode(fd,_O_BINARY) |
82 |
+ |
#define SET_FD_TEXT(fd) _setmode(fd,_O_TEXT) |
83 |
+ |
#define putenv _putenv |
84 |
|
|
85 |
+ |
#else /* _WIN32 || _WIN64 */ |
86 |
|
|
87 |
+ |
#ifdef AMIGA |
88 |
+ |
#define NON_POSIX |
89 |
+ |
#else |
90 |
+ |
/* assumedly posix systems */ |
91 |
+ |
#include <unistd.h> |
92 |
+ |
#define RHAS_STAT |
93 |
+ |
#define RHAS_FORK_EXEC |
94 |
+ |
#endif |
95 |
|
|
96 |
+ |
/* everybody except Windows */ |
97 |
|
|
98 |
< |
#else /* _WIN32 */ |
98 |
> |
/* NOPs */ |
99 |
> |
#define SET_DEFAULT_BINARY() |
100 |
> |
#define SET_FILE_BINARY(fp) |
101 |
> |
#define SET_FD_BINARY(fd) |
102 |
> |
#define SET_DEFAULT_TEXT() |
103 |
> |
#define SET_FILE_TEXT(fp) |
104 |
> |
#define SET_FD_TEXT(fd) |
105 |
|
|
106 |
< |
/* NOPs on unix */ |
33 |
< |
#define SET_DEFAULT_BINARY() |
34 |
< |
#define SET_FILE_BINARY(fp) |
35 |
< |
#define SET_FD_BINARY(fd) |
106 |
> |
#endif /* _WIN32 || _WIN64 */ |
107 |
|
|
108 |
+ |
#ifdef __cplusplus |
109 |
+ |
extern "C" { |
110 |
+ |
#endif |
111 |
|
|
112 |
+ |
#if defined(_WIN32) || defined(_WIN64) |
113 |
|
|
114 |
+ |
extern int usleep(__int64 usec); |
115 |
|
|
116 |
+ |
#endif /* _WIN32 || _WIN64 */ |
117 |
|
|
118 |
< |
|
119 |
< |
|
120 |
< |
#endif /* _WIN32 */ |
44 |
< |
|
118 |
> |
#ifdef __cplusplus |
119 |
> |
} |
120 |
> |
#endif |
121 |
|
#endif /* _RAD_PLATFORM_H_ */ |
122 |
|
|