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