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