ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/platform.h
Revision: 3.18
Committed: Wed Jan 22 19:41:55 2025 UTC (3 months, 1 week ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 3.17: +5 -1 lines
Log Message:
feat: Added hopeful equivalents to ftello(), fseeko() for Windows

File Contents

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