]> git.lyx.org Git - lyx.git/blob - src/support/os_win32.h
Consistent use of preprocessor guards;
[lyx.git] / src / support / os_win32.h
1 // os_win32.h copyright "Ruurd A. Reitsma" <R.A.Reitsma@wbmt.tudelft.nl>
2
3 #ifndef _OS_WIN32_H_
4 #define _OS_WIN32_H_
5
6 //Avoid zillions of windows includes
7 #ifndef WIN32_LEAN_AND_MEAN
8 #define WIN32_LEAN_AND_MEAN
9 #endif
10
11 #include <windows.h>
12
13 // Avoid some very annoying macros from MFC 
14 #  undef max
15 #  undef min
16
17 #if defined( __SGI_STL_PORT )
18
19   namespace std {
20     // These overloads prevent ambiguity errors when signed and unsigned integers are compared.
21     inline long min(long x, long y) {return std::min(x, y);}  
22     inline long max(long x, long y) {return std::max(x, y);}
23   }
24
25 #else // defined( __SGI_STL_PORT )
26   namespace std {
27     // These overloads prevent ambiguity errors when int, long and unsigned int and int are compared.
28         
29         inline int min(int x, int y) { return x < y ? x : y; }  
30         inline int max(int x, int y) { return x > y ? x : y; }
31
32         inline unsigned int min(unsigned int x, unsigned int y) { return x < y ? x : y; }  
33         inline unsigned int max(unsigned int x, unsigned int y) { return x > y ? x : y; }
34
35         inline long min(long x, long y) { return x < y ? x : y; }  
36         inline long max(long x, long y) { return x > y ? x : y; }
37
38         inline long min(int x, long y) { return x < y ? x : y; }  
39         inline long max(int x, long y) { return x > y ? x : y; }
40
41         inline long min(long x, int y) { return x < y ? x : y; }  
42         inline long max(long x, int y) { return x > y ? x : y; }
43
44         inline unsigned long min(unsigned long x, unsigned long y) { return x < y ? x : y; }  
45         inline unsigned long max(unsigned long x, unsigned long y) { return x > y ? x : y; }
46
47         inline double min(double x, double y) { return x < y ? x : y; }  
48         inline double max(double x, double y) { return x > y ? x : y; }
49   }
50
51 #endif // defined( __SGI_STL_PORT )
52
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56
57
58 //fcntl.h
59 #define FD_CLOEXEC      1       /* posix */
60 #define F_DUPFD         0       /* Duplicate fildes */
61 #define F_GETFD         1       /* Get fildes flags (close on exec) */
62 #define F_SETFD         2       /* Set fildes flags (close on exec) */
63 #define F_GETFL         3       /* Get file flags */
64 #define F_SETFL         4       /* Set file flags */
65 #define O_NONBLOCK      0x4000
66 inline int fcntl (int, int, ...) {return -1;}
67
68 //unistd.h
69 inline int fork () {return -1;}
70 #define pipe(a) _pipe(a,0,0)
71
72
73 //sys/wait.h
74 #define waitpid(a,b,c) cwait(b,a,c)
75 #define WNOHANG 1
76 #define WUNTRACED 2
77 #define WIFEXITED(a) 0
78 #define WEXITSTATUS(a) 0
79 #define WIFSIGNALED(a) 0
80 #define WTERMSIG(a) 0
81 #define WIFSTOPPED(a) 0
82 #define WSTOPSIG(a) 0
83
84 //sys/types.h
85 #define fd_set int
86
87 //sys/select.h
88 //#define select(a,b,c,d,e) -1
89 #define FD_ZERO(a)
90 #define FD_SET(a,b)
91 #define FD_ISSET(fd, set) 0
92
93 #ifndef __MINGW32__ //already defined in mingw headers
94
95 #define _S_IFBLK        0x3000
96 #define S_IFIFO         _S_IFIFO
97 #define S_IFBLK         _S_IFBLK
98 #define S_ISFIFO(m)     (((m) & S_IFMT) == S_IFIFO)
99 #define S_ISBLK(m)      (((m) & S_IFMT) == S_IFBLK)
100 #define popen(a,b) _popen(a,b)
101 #define pclose(a) _pclose(a)
102
103 #endif //!__MINGW32
104
105 #ifdef __cplusplus
106 }
107 #endif
108
109 #endif //_OS_WIN32_H_