dinput: Move IDirectInput7 WtoA wrappers to ansi.c.
[wine.git] / include / wine / port.h
blob15d1ed6315c88b5fe7cb91304ca3b7c47a87feab
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 popen _popen
66 #define pclose _pclose
67 /* The UCRT headers in the Windows SDK #error out if we #define snprintf.
68 * The C headers that came with previous Visual Studio versions do not have
69 * snprintf. Check for VS 2015, which appears to be the first version to
70 * use the UCRT headers by default. */
71 #if _MSC_VER < 1900
72 # define snprintf _snprintf
73 #endif
74 #define strtoll _strtoi64
75 #define strtoull _strtoui64
76 #define strncasecmp _strnicmp
77 #define strcasecmp _stricmp
79 typedef long off_t;
80 typedef int pid_t;
81 typedef int ssize_t;
83 #endif /* _MSC_VER */
85 #else /* _WIN32 */
87 #ifndef __int64
88 # if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || defined(_WIN64)
89 # define __int64 long
90 # else
91 # define __int64 long long
92 # endif
93 #endif
95 /* Process creation flags */
96 #ifndef _P_WAIT
97 # define _P_WAIT 0
98 # define _P_NOWAIT 1
99 # define _P_OVERLAY 2
100 # define _P_NOWAITO 3
101 # define _P_DETACH 4
102 #endif
103 #ifndef HAVE__SPAWNVP
104 extern int _spawnvp(int mode, const char *cmdname, const char * const argv[]);
105 #endif
107 #endif /* _WIN32 */
109 /****************************************************************
110 * Macro definitions
113 #ifdef HAVE_DLFCN_H
114 #include <dlfcn.h>
115 #else
116 #define RTLD_LAZY 0x001
117 #define RTLD_NOW 0x002
118 #define RTLD_GLOBAL 0x100
119 #endif
121 #ifndef S_ISLNK
122 # define S_ISLNK(mod) (0)
123 #endif
125 #ifndef S_ISDIR
126 # define S_ISDIR(mod) (((mod) & _S_IFMT) == _S_IFDIR)
127 #endif
129 #ifndef S_ISCHR
130 # define S_ISCHR(mod) (((mod) & _S_IFMT) == _S_IFCHR)
131 #endif
133 #ifndef S_ISREG
134 # define S_ISREG(mod) (((mod) & _S_IFMT) == _S_IFREG)
135 #endif
137 /* So we open files in 64 bit access mode on Linux */
138 #ifndef O_LARGEFILE
139 # define O_LARGEFILE 0
140 #endif
142 #ifndef O_NONBLOCK
143 # define O_NONBLOCK 0
144 #endif
146 #ifndef O_BINARY
147 # define O_BINARY 0
148 #endif
151 /****************************************************************
152 * Constants
155 #ifndef M_PI
156 #define M_PI 3.14159265358979323846
157 #endif
159 #ifndef M_PI_2
160 #define M_PI_2 1.570796326794896619
161 #endif
164 /****************************************************************
165 * Function definitions (only when using libwine_port)
168 #ifndef HAVE_GETOPT_LONG_ONLY
169 extern char *optarg;
170 extern int optind;
171 extern int opterr;
172 extern int optopt;
173 struct option;
175 #ifndef HAVE_STRUCT_OPTION_NAME
176 struct option
178 const char *name;
179 int has_arg;
180 int *flag;
181 int val;
183 #endif
185 extern int getopt_long (int ___argc, char *const *___argv,
186 const char *__shortopts,
187 const struct option *__longopts, int *__longind);
188 extern int getopt_long_only (int ___argc, char *const *___argv,
189 const char *__shortopts,
190 const struct option *__longopts, int *__longind);
191 #endif /* HAVE_GETOPT_LONG_ONLY */
193 #ifndef HAVE_LSTAT
194 int lstat(const char *file_name, struct stat *buf);
195 #endif /* HAVE_LSTAT */
197 #ifndef HAVE_POLL
198 struct pollfd
200 int fd;
201 short events;
202 short revents;
204 #define POLLIN 0x01
205 #define POLLPRI 0x02
206 #define POLLOUT 0x04
207 #define POLLERR 0x08
208 #define POLLHUP 0x10
209 #define POLLNVAL 0x20
210 int poll( struct pollfd *fds, unsigned int count, int timeout );
211 #endif /* HAVE_POLL */
213 #ifndef HAVE_PREAD
214 ssize_t pread( int fd, void *buf, size_t count, off_t offset );
215 #endif /* HAVE_PREAD */
217 #ifndef HAVE_PWRITE
218 ssize_t pwrite( int fd, const void *buf, size_t count, off_t offset );
219 #endif /* HAVE_PWRITE */
221 #ifndef HAVE_READLINK
222 int readlink( const char *path, char *buf, size_t size );
223 #endif /* HAVE_READLINK */
225 #ifndef HAVE_SYMLINK
226 int symlink(const char *from, const char *to);
227 #endif
229 extern int mkstemps(char *template, int suffix_len);
231 #endif /* !defined(__WINE_WINE_PORT_H) */