libport: Remove the isfinite/isinf/isnan function replacements.
[wine.git] / include / wine / port.h
blobfec72120ec6df0a99dd4ed8898303d5e559601db
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 #define popen _popen
67 #define pclose _pclose
68 /* The UCRT headers in the Windows SDK #error out if we #define snprintf.
69 * The C headers that came with previous Visual Studio versions do not have
70 * snprintf. Check for VS 2015, which appears to be the first version to
71 * use the UCRT headers by default. */
72 #if _MSC_VER < 1900
73 # define snprintf _snprintf
74 #endif
75 #define strtoll _strtoi64
76 #define strtoull _strtoui64
77 #define strncasecmp _strnicmp
78 #define strcasecmp _stricmp
80 typedef int mode_t;
81 typedef long off_t;
82 typedef int pid_t;
83 typedef int ssize_t;
85 #endif /* _MSC_VER */
87 #else /* _WIN32 */
89 #ifndef __int64
90 # if defined(__x86_64__) || defined(__aarch64__) || defined(_WIN64)
91 # define __int64 long
92 # else
93 # define __int64 long long
94 # endif
95 #endif
97 /* Process creation flags */
98 #ifndef _P_WAIT
99 # define _P_WAIT 0
100 # define _P_NOWAIT 1
101 # define _P_OVERLAY 2
102 # define _P_NOWAITO 3
103 # define _P_DETACH 4
104 #endif
105 #ifndef HAVE__SPAWNVP
106 extern int _spawnvp(int mode, const char *cmdname, const char * const argv[]);
107 #endif
109 #endif /* _WIN32 */
111 /****************************************************************
112 * Macro definitions
115 #ifdef HAVE_DLFCN_H
116 #include <dlfcn.h>
117 #else
118 #define RTLD_LAZY 0x001
119 #define RTLD_NOW 0x002
120 #define RTLD_GLOBAL 0x100
121 #endif
123 #ifndef S_ISLNK
124 # define S_ISLNK(mod) (0)
125 #endif
127 #ifndef S_ISSOCK
128 # define S_ISSOCK(mod) (0)
129 #endif
131 #ifndef S_ISDIR
132 # define S_ISDIR(mod) (((mod) & _S_IFMT) == _S_IFDIR)
133 #endif
135 #ifndef S_ISCHR
136 # define S_ISCHR(mod) (((mod) & _S_IFMT) == _S_IFCHR)
137 #endif
139 #ifndef S_ISFIFO
140 # define S_ISFIFO(mod) (((mod) & _S_IFMT) == _S_IFIFO)
141 #endif
143 #ifndef S_ISREG
144 # define S_ISREG(mod) (((mod) & _S_IFMT) == _S_IFREG)
145 #endif
147 /* So we open files in 64 bit access mode on Linux */
148 #ifndef O_LARGEFILE
149 # define O_LARGEFILE 0
150 #endif
152 #ifndef O_NONBLOCK
153 # define O_NONBLOCK 0
154 #endif
156 #ifndef O_BINARY
157 # define O_BINARY 0
158 #endif
161 /****************************************************************
162 * Constants
165 #ifndef M_PI
166 #define M_PI 3.14159265358979323846
167 #endif
169 #ifndef M_PI_2
170 #define M_PI_2 1.570796326794896619
171 #endif
174 /****************************************************************
175 * Function definitions (only when using libwine_port)
178 #ifndef NO_LIBWINE_PORT
180 #ifndef HAVE_GETOPT_LONG_ONLY
181 extern char *optarg;
182 extern int optind;
183 extern int opterr;
184 extern int optopt;
185 struct option;
187 #ifndef HAVE_STRUCT_OPTION_NAME
188 struct option
190 const char *name;
191 int has_arg;
192 int *flag;
193 int val;
195 #endif
197 extern int getopt_long (int ___argc, char *const *___argv,
198 const char *__shortopts,
199 const struct option *__longopts, int *__longind);
200 extern int getopt_long_only (int ___argc, char *const *___argv,
201 const char *__shortopts,
202 const struct option *__longopts, int *__longind);
203 #endif /* HAVE_GETOPT_LONG_ONLY */
205 #ifndef HAVE_LSTAT
206 int lstat(const char *file_name, struct stat *buf);
207 #endif /* HAVE_LSTAT */
209 #ifndef HAVE_POLL
210 struct pollfd
212 int fd;
213 short events;
214 short revents;
216 #define POLLIN 0x01
217 #define POLLPRI 0x02
218 #define POLLOUT 0x04
219 #define POLLERR 0x08
220 #define POLLHUP 0x10
221 #define POLLNVAL 0x20
222 int poll( struct pollfd *fds, unsigned int count, int timeout );
223 #endif /* HAVE_POLL */
225 #ifndef HAVE_PREAD
226 ssize_t pread( int fd, void *buf, size_t count, off_t offset );
227 #endif /* HAVE_PREAD */
229 #ifndef HAVE_PWRITE
230 ssize_t pwrite( int fd, const void *buf, size_t count, off_t offset );
231 #endif /* HAVE_PWRITE */
233 #ifndef HAVE_READLINK
234 int readlink( const char *path, char *buf, size_t size );
235 #endif /* HAVE_READLINK */
237 #ifndef HAVE_SYMLINK
238 int symlink(const char *from, const char *to);
239 #endif
241 extern int mkstemps(char *template, int suffix_len);
243 #else /* NO_LIBWINE_PORT */
245 #define __WINE_NOT_PORTABLE(func) func##_is_not_portable func##_is_not_portable
247 #define getopt_long __WINE_NOT_PORTABLE(getopt_long)
248 #define getopt_long_only __WINE_NOT_PORTABLE(getopt_long_only)
249 #define lstat __WINE_NOT_PORTABLE(lstat)
250 #define pread __WINE_NOT_PORTABLE(pread)
251 #define pwrite __WINE_NOT_PORTABLE(pwrite)
253 #endif /* NO_LIBWINE_PORT */
255 #endif /* !defined(__WINE_WINE_PORT_H) */