ieframe: Return S_FALSE in IWebBrowser2::get_Document when returning NULL.
[wine.git] / include / wine / port.h
blob928730a41d757bf544068be6817228ea86b7f2d0
1 /*
2 * Wine porting definitions
4 * Copyright 1996 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __WINE_WINE_PORT_H
22 #define __WINE_WINE_PORT_H
24 #ifndef __WINE_CONFIG_H
25 # error You must include config.h to use this header
26 #endif
28 #ifdef __WINE_BASETSD_H
29 # error You must include port.h before all other headers
30 #endif
32 #ifndef _GNU_SOURCE
33 # define _GNU_SOURCE /* for pread/pwrite, isfinite */
34 #endif
35 #include <fcntl.h>
36 #include <math.h>
37 #include <sys/types.h>
38 #include <sys/stat.h>
39 #include <string.h>
40 #include <stdlib.h>
41 #ifdef HAVE_UNISTD_H
42 # include <unistd.h>
43 #endif
46 /****************************************************************
47 * Hard-coded values for the Windows platform
50 #if defined(_WIN32) && !defined(__CYGWIN__)
52 #include <direct.h>
53 #include <io.h>
54 #include <process.h>
56 #define mkdir(path,mode) mkdir(path)
58 static inline void *dlopen(const char *name, int flags) { return NULL; }
59 static inline void *dlsym(void *handle, const char *name) { return NULL; }
60 static inline int dlclose(void *handle) { return 0; }
61 static inline const char *dlerror(void) { return "No dlopen support on Windows"; }
63 #ifdef _MSC_VER
65 #define ftruncate chsize
66 #ifndef isfinite
67 # define isfinite(x) _finite(x)
68 #endif
69 #ifndef isinf
70 # define isinf(x) (!(_finite(x) || _isnan(x)))
71 #endif
72 #ifndef isnan
73 # define isnan(x) _isnan(x)
74 #endif
75 #define popen _popen
76 #define pclose _pclose
77 /* The UCRT headers in the Windows SDK #error out if we #define snprintf.
78 * The C headers that came with previous Visual Studio versions do not have
79 * snprintf. Check for VS 2015, which appears to be the first version to
80 * use the UCRT headers by default. */
81 #if _MSC_VER < 1900
82 # define snprintf _snprintf
83 #endif
84 #define strtoll _strtoi64
85 #define strtoull _strtoui64
86 #define strncasecmp _strnicmp
87 #define strcasecmp _stricmp
89 typedef int mode_t;
90 typedef long off_t;
91 typedef int pid_t;
92 typedef int ssize_t;
94 #endif /* _MSC_VER */
96 #else /* _WIN32 */
98 #ifndef __int64
99 # if defined(__x86_64__) || defined(__aarch64__) || defined(_WIN64)
100 # define __int64 long
101 # else
102 # define __int64 long long
103 # endif
104 #endif
106 #ifndef HAVE_ISFINITE
107 int isfinite(double x);
108 #endif
110 #ifndef HAVE_ISINF
111 int isinf(double x);
112 #endif
114 #ifndef HAVE_ISNAN
115 int isnan(double x);
116 #endif
118 /* Process creation flags */
119 #ifndef _P_WAIT
120 # define _P_WAIT 0
121 # define _P_NOWAIT 1
122 # define _P_OVERLAY 2
123 # define _P_NOWAITO 3
124 # define _P_DETACH 4
125 #endif
126 #ifndef HAVE__SPAWNVP
127 extern int _spawnvp(int mode, const char *cmdname, const char * const argv[]);
128 #endif
130 #endif /* _WIN32 */
132 /****************************************************************
133 * Type definitions
136 #ifndef HAVE_FSBLKCNT_T
137 typedef unsigned long fsblkcnt_t;
138 #endif
139 #ifndef HAVE_FSFILCNT_T
140 typedef unsigned long fsfilcnt_t;
141 #endif
143 #ifndef HAVE_STRUCT_STATVFS_F_BLOCKS
144 struct statvfs
146 unsigned long f_bsize;
147 unsigned long f_frsize;
148 fsblkcnt_t f_blocks;
149 fsblkcnt_t f_bfree;
150 fsblkcnt_t f_bavail;
151 fsfilcnt_t f_files;
152 fsfilcnt_t f_ffree;
153 fsfilcnt_t f_favail;
154 unsigned long f_fsid;
155 unsigned long f_flag;
156 unsigned long f_namemax;
158 #endif /* HAVE_STRUCT_STATVFS_F_BLOCKS */
161 /****************************************************************
162 * Macro definitions
165 #ifdef HAVE_DLFCN_H
166 #include <dlfcn.h>
167 #else
168 #define RTLD_LAZY 0x001
169 #define RTLD_NOW 0x002
170 #define RTLD_GLOBAL 0x100
171 #endif
173 #ifndef S_ISLNK
174 # define S_ISLNK(mod) (0)
175 #endif
177 #ifndef S_ISSOCK
178 # define S_ISSOCK(mod) (0)
179 #endif
181 #ifndef S_ISDIR
182 # define S_ISDIR(mod) (((mod) & _S_IFMT) == _S_IFDIR)
183 #endif
185 #ifndef S_ISCHR
186 # define S_ISCHR(mod) (((mod) & _S_IFMT) == _S_IFCHR)
187 #endif
189 #ifndef S_ISFIFO
190 # define S_ISFIFO(mod) (((mod) & _S_IFMT) == _S_IFIFO)
191 #endif
193 #ifndef S_ISREG
194 # define S_ISREG(mod) (((mod) & _S_IFMT) == _S_IFREG)
195 #endif
197 /* So we open files in 64 bit access mode on Linux */
198 #ifndef O_LARGEFILE
199 # define O_LARGEFILE 0
200 #endif
202 #ifndef O_NONBLOCK
203 # define O_NONBLOCK 0
204 #endif
206 #ifndef O_BINARY
207 # define O_BINARY 0
208 #endif
211 /****************************************************************
212 * Constants
215 #ifndef M_PI
216 #define M_PI 3.14159265358979323846
217 #endif
219 #ifndef M_PI_2
220 #define M_PI_2 1.570796326794896619
221 #endif
223 #ifndef INFINITY
224 static inline float __port_infinity(void)
226 static const unsigned __inf_bytes = 0x7f800000;
227 return *(const float *)&__inf_bytes;
229 #define INFINITY __port_infinity()
230 #endif
232 #ifndef NAN
233 static inline float __port_nan(void)
235 static const unsigned __nan_bytes = 0x7fc00000;
236 return *(const float *)&__nan_bytes;
238 #define NAN __port_nan()
239 #endif
242 /****************************************************************
243 * Function definitions (only when using libwine_port)
246 #ifndef NO_LIBWINE_PORT
248 #ifndef HAVE_FSTATVFS
249 int fstatvfs( int fd, struct statvfs *buf );
250 #endif
252 #ifndef HAVE_GETOPT_LONG_ONLY
253 extern char *optarg;
254 extern int optind;
255 extern int opterr;
256 extern int optopt;
257 struct option;
259 #ifndef HAVE_STRUCT_OPTION_NAME
260 struct option
262 const char *name;
263 int has_arg;
264 int *flag;
265 int val;
267 #endif
269 extern int getopt_long (int ___argc, char *const *___argv,
270 const char *__shortopts,
271 const struct option *__longopts, int *__longind);
272 extern int getopt_long_only (int ___argc, char *const *___argv,
273 const char *__shortopts,
274 const struct option *__longopts, int *__longind);
275 #endif /* HAVE_GETOPT_LONG_ONLY */
277 #ifndef HAVE_FFS
278 int ffs( int x );
279 #endif
281 #ifndef HAVE_LLRINT
282 __int64 llrint(double x);
283 #endif
285 #ifndef HAVE_LLRINTF
286 __int64 llrintf(float x);
287 #endif
289 #ifndef HAVE_LRINT
290 long lrint(double x);
291 #endif
293 #ifndef HAVE_LRINTF
294 long lrintf(float x);
295 #endif
297 #ifndef HAVE_LSTAT
298 int lstat(const char *file_name, struct stat *buf);
299 #endif /* HAVE_LSTAT */
301 #ifndef HAVE_POLL
302 struct pollfd
304 int fd;
305 short events;
306 short revents;
308 #define POLLIN 0x01
309 #define POLLPRI 0x02
310 #define POLLOUT 0x04
311 #define POLLERR 0x08
312 #define POLLHUP 0x10
313 #define POLLNVAL 0x20
314 int poll( struct pollfd *fds, unsigned int count, int timeout );
315 #endif /* HAVE_POLL */
317 #ifndef HAVE_PREAD
318 ssize_t pread( int fd, void *buf, size_t count, off_t offset );
319 #endif /* HAVE_PREAD */
321 #ifndef HAVE_PWRITE
322 ssize_t pwrite( int fd, const void *buf, size_t count, off_t offset );
323 #endif /* HAVE_PWRITE */
325 #ifndef HAVE_READLINK
326 int readlink( const char *path, char *buf, size_t size );
327 #endif /* HAVE_READLINK */
329 #ifndef HAVE_RINT
330 double rint(double x);
331 #endif
333 #ifndef HAVE_RINTF
334 float rintf(float x);
335 #endif
337 #ifndef HAVE_STATVFS
338 int statvfs( const char *path, struct statvfs *buf );
339 #endif
341 #ifndef HAVE_STRNLEN
342 size_t strnlen( const char *str, size_t maxlen );
343 #endif /* !defined(HAVE_STRNLEN) */
345 #ifndef HAVE_SYMLINK
346 int symlink(const char *from, const char *to);
347 #endif
349 #ifndef HAVE_USLEEP
350 int usleep (unsigned int useconds);
351 #endif /* !defined(HAVE_USLEEP) */
353 extern int mkstemps(char *template, int suffix_len);
355 #else /* NO_LIBWINE_PORT */
357 #define __WINE_NOT_PORTABLE(func) func##_is_not_portable func##_is_not_portable
359 #define ffs __WINE_NOT_PORTABLE(ffs)
360 #define fstatvfs __WINE_NOT_PORTABLE(fstatvfs)
361 #define getopt_long __WINE_NOT_PORTABLE(getopt_long)
362 #define getopt_long_only __WINE_NOT_PORTABLE(getopt_long_only)
363 #define lstat __WINE_NOT_PORTABLE(lstat)
364 #define pread __WINE_NOT_PORTABLE(pread)
365 #define pwrite __WINE_NOT_PORTABLE(pwrite)
366 #define statvfs __WINE_NOT_PORTABLE(statvfs)
367 #define strnlen __WINE_NOT_PORTABLE(strnlen)
368 #define usleep __WINE_NOT_PORTABLE(usleep)
370 #endif /* NO_LIBWINE_PORT */
372 #endif /* !defined(__WINE_WINE_PORT_H) */