ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/platform.h
Revision: 3.19
Committed: Sat Jun 7 05:09:45 2025 UTC (2 weeks, 2 days ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 3.18: +3 -5 lines
Log Message:
refactor: Put some declarations into "paths.h" and included in "platform.h"

File Contents

# Content
1 /* RCSid $Id: platform.h,v 3.18 2025/01/22 19:41:55 greg Exp $ */
2 /*
3 * platform.h - header file for platform specific definitions
4 */
5 #ifndef _RAD_PLATFORM_H_
6 #define _RAD_PLATFORM_H_
7
8 #include "paths.h"
9
10 #if defined(_WIN32) || defined(_WIN64)
11
12 #include <io.h> /* _setmode() and stuff from unistd.h */
13 typedef long off_t;
14 #undef ftello
15 #define ftello _ftelli64
16 #undef fseeko
17 #define fseeko _fseeki64
18 #undef fdopen
19 #define fdopen _fdopen
20 #undef read
21 #define read _read
22 #undef open
23 #define open _open
24 #undef close
25 #define close _close
26 #undef write
27 #define write _write
28 #undef ftruncate
29 #define ftruncate _chsize_s
30 #undef unlink
31 #define unlink _unlink
32 #undef fileno
33 #define fileno _fileno
34 #undef snprintf
35 #define snprintf _snprintf
36 #undef vsnprintf
37 #define vsnprintf _vsnprintf
38 /* XXX should we check first if size_t is 32 bit? */
39 #undef fseeko
40 #define fseeko _fseeki64
41 #undef lseek
42 #define lseek _lseek
43 #undef access
44 #define access _access
45 #undef mktemp
46 #define mktemp _mktemp
47 #define fpurge(s)
48
49 #undef strcasecmp
50 #define strcasecmp _stricmp
51 #undef strncasecmp
52 #define strncasecmp _strnicmp
53 #undef strdup
54 #define strdup _strdup
55
56 #include <windows.h>
57 /* 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 #define sleep(s) Sleep((DWORD)((s)*1000))
71
72 #define NON_POSIX
73
74 #define RHAS_STAT
75 #define S_IFREG _S_IFREG
76 #define W_IFDIR _S_IFDIR
77
78 #include <fcntl.h> /* _O_BINARY, _O_TEXT */
79 #include <stdlib.h> /* _fmode */
80 #define SET_DEFAULT_BINARY() (_fmode = _O_BINARY)
81 #define SET_DEFAULT_TEXT() (_fmode = _O_TEXT)
82 #define SET_FILE_BINARY(fp) _setmode(_fileno(fp),_O_BINARY)
83 #define SET_FILE_TEXT(fp) _setmode(_fileno(fp),_O_TEXT)
84 #define SET_FD_BINARY(fd) _setmode(fd,_O_BINARY)
85 #define SET_FD_TEXT(fd) _setmode(fd,_O_TEXT)
86 #define putenv _putenv
87
88 #else /* ! (_WIN32 || _WIN64) */
89
90 #ifdef AMIGA
91 #define NON_POSIX
92 #else
93 /* assumedly posix systems */
94 #include <unistd.h>
95 #define RHAS_STAT
96 #define RHAS_FORK_EXEC
97 #endif
98
99 #ifdef __linux__
100 #include <stdio_ext.h>
101 #define fpurge __fpurge
102 #endif
103 /* everybody except Windows */
104
105 /* NOPs */
106 #define SET_DEFAULT_BINARY()
107 #define SET_FILE_BINARY(fp)
108 #define SET_FD_BINARY(fd)
109 #define SET_DEFAULT_TEXT()
110 #define SET_FILE_TEXT(fp)
111 #define SET_FD_TEXT(fd)
112
113 #endif /* _WIN32 || _WIN64 */
114
115 #ifdef __cplusplus
116 extern "C" {
117 #endif
118
119 #if defined(_WIN32) || defined(_WIN64)
120
121 extern int usleep(__int64 usec);
122
123 #endif /* _WIN32 || _WIN64 */
124
125 #ifdef __cplusplus
126 }
127 #endif
128 #endif /* _RAD_PLATFORM_H_ */
129