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, 2 weeks 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

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