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 Street, 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
28 #define _GNU_SOURCE /* for pread/pwrite */
31 #include <sys/types.h>
48 /****************************************************************
52 #if !defined(_MSC_VER) && !defined(__int64)
53 # if defined(__x86_64__) || defined(_WIN64)
56 # define __int64 long long
70 typedef unsigned int size_t;
75 //#ifndef HAVE_SOCKLEN_T
76 //typedef unsigned int socklen_t;
81 # define HAVE_STRUCT_STATFS_F_BFREE
83 long f_bsize
; /* block_size */
84 long f_blocks
; /* total_blocks */
85 long f_bfree
; /* free_blocks */
87 # else /* defined(__BEOS__) */
89 # endif /* defined(__BEOS__) */
90 #endif /* !defined(HAVE_STATFS) */
93 /****************************************************************
100 #define RTLD_LAZY 0x001
101 #define RTLD_NOW 0x002
102 #define RTLD_GLOBAL 0x100
105 #if !defined(HAVE_FTRUNCATE) && defined(HAVE_CHSIZE)
106 #define ftruncate chsize
109 #if !defined(HAVE_POPEN) && defined(HAVE__POPEN)
113 #if !defined(HAVE_PCLOSE) && defined(HAVE__PCLOSE)
114 #define pclose _pclose
117 #if !defined(HAVE_SNPRINTF) && defined(HAVE__SNPRINTF)
118 #define snprintf _snprintf
121 #if !defined(HAVE_VSNPRINTF) && defined(HAVE__VSNPRINTF)
122 #define vsnprintf _vsnprintf
126 # define S_ISLNK(mod) (0)
129 /* So we open files in 64 bit access mode on Linux */
131 # define O_LARGEFILE 0
138 /****************************************************************
143 #define M_PI 3.14159265358979323846
147 #define M_PI_2 1.570796326794896619
151 /* Macros to define assembler functions somewhat portably */
153 #if defined(__GNUC__) && !defined(__INTERIX) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__APPLE__)
154 # define __ASM_GLOBAL_FUNC(name,code) \
155 __asm__( ".text\n\t" \
157 ".globl " __ASM_NAME(#name) "\n\t" \
158 __ASM_FUNC(#name) "\n" \
159 __ASM_NAME(#name) ":\n\t" \
162 #else /* defined(__GNUC__) && !defined(__MINGW32__) && !defined(__APPLE__) */
163 # define __ASM_GLOBAL_FUNC(name,code) \
164 void __asm_dummy_##name(void) { \
165 asm( ".align 4\n\t" \
166 ".globl " __ASM_NAME(#name) "\n\t" \
167 __ASM_FUNC(#name) "\n" \
168 __ASM_NAME(#name) ":\n\t" \
171 #endif /* __GNUC__ */
174 /* Constructor functions */
177 # define DECL_GLOBAL_CONSTRUCTOR(func) \
178 static void func(void) __attribute__((constructor)); \
179 static void func(void)
180 #elif defined(__i386__)
181 # define DECL_GLOBAL_CONSTRUCTOR(func) \
182 static void __dummy_init_##func(void) { \
183 asm(".section .init,\"ax\"\n\t" \
184 "call " #func "\n\t" \
186 static void func(void)
187 #elif defined(__sparc__)
188 # define DECL_GLOBAL_CONSTRUCTOR(func) \
189 static void __dummy_init_##func(void) { \
190 asm("\t.section \".init\",#alloc,#execinstr\n" \
191 "\tcall " #func "\n" \
193 "\t.section \".text\",#alloc,#execinstr\n" ); } \
194 static void func(void)
196 # error You must define the DECL_GLOBAL_CONSTRUCTOR macro for your platform
200 /* Register functions */
203 #define DEFINE_REGS_ENTRYPOINT( name, fn, args, pop_args ) \
204 __ASM_GLOBAL_FUNC( name, \
205 "call " __ASM_NAME("__wine_call_from_32_regs") "\n\t" \
206 ".long " __ASM_NAME(#fn) "\n\t" \
207 ".byte " #args "," #pop_args )
208 /* FIXME: add support for other CPUs */
209 #endif /* __i386__ */
212 /****************************************************************
213 * Function definitions (only when using libwine_port)
216 #ifndef NO_LIBWINE_PORT
218 #ifndef HAVE_GETOPT_LONG
225 #ifndef HAVE_STRUCT_OPTION_NAME
235 extern int getopt_long (int ___argc
, char *const *___argv
,
236 const char *__shortopts
,
237 const struct option
*__longopts
, int *__longind
);
238 extern int getopt_long_only (int ___argc
, char *const *___argv
,
239 const char *__shortopts
,
240 const struct option
*__longopts
, int *__longind
);
241 #endif /* HAVE_GETOPT_LONG */
243 #ifndef HAVE_GETPAGESIZE
244 size_t getpagesize(void);
245 #endif /* HAVE_GETPAGESIZE */
248 int lstat(const char *file_name
, struct stat
*buf
);
249 #endif /* HAVE_LSTAT */
252 void *memmove(void *dest
, const void *src
, size_t len
);
253 #endif /* !defined(HAVE_MEMMOVE) */
257 ssize_t
pread( int fd
, void *buf
, size_t count
, off_t offset
);
258 #endif /* HAVE_PREAD */
261 ssize_t
pwrite( int fd
, const void *buf
, size_t count
, off_t offset
);
262 #endif /* HAVE_PWRITE */
263 #endif /* __REACTOS__ */
266 #ifndef HAVE_SIGSETJMP
268 typedef jmp_buf sigjmp_buf
;
269 int sigsetjmp( sigjmp_buf buf
, int savesigs
);
270 void siglongjmp( sigjmp_buf buf
, int val
);
271 #endif /* HAVE_SIGSETJMP */
275 int statfs(const char *name
, struct statfs
*info
);
276 #endif /* !defined(HAVE_STATFS) */
278 #ifndef HAVE_STRNCASECMP
279 # ifndef HAVE__STRNICMP
280 int strncasecmp(const char *str1
, const char *str2
, size_t n
);
282 # define strncasecmp _strnicmp
284 #endif /* !defined(HAVE_STRNCASECMP) */
286 #ifndef HAVE_STRERROR
287 const char *strerror(int err
);
288 #endif /* !defined(HAVE_STRERROR) */
290 #ifndef HAVE_STRCASECMP
291 # ifndef HAVE__STRICMP
292 int strcasecmp(const char *str1
, const char *str2
);
294 # define strcasecmp _stricmp
296 #endif /* !defined(HAVE_STRCASECMP) */
298 #if !defined(HAVE_USLEEP) && !defined(__CYGWIN__)
299 int usleep (unsigned int useconds
);
300 #endif /* !defined(HAVE_USLEEP) */
303 static inline void *memcpy_unaligned( void *dst
, const void *src
, size_t size
)
305 return memcpy( dst
, src
, size
);
308 extern void *memcpy_unaligned( void *dst
, const void *src
, size_t size
);
309 #endif /* __i386__ */
311 extern int mkstemps(char *template, int suffix_len
);
313 /* Process creation flags */
317 # define _P_OVERLAY 2
318 # define _P_NOWAITO 3
322 extern int spawnvp(int mode
, const char *cmdname
, const char * const argv
[]);
325 /* Interlocked functions */
327 #if defined(_MSC_VER) || (defined(__i386__) && defined(__GNUC__) && !defined(WINE_PORT_NO_INTERLOCKED))
329 #define interlocked_cmpxchg InterlockedCompareExchange
330 #define interlocked_cmpxchg_ptr InterlockedCompareExchangePtr
331 #define interlocked_xchg InterlockedExchange
332 #define interlocked_xchg_ptr InterlockedExchangePtr
333 #define interlocked_xchg_add InterlockedExchangeAdd
336 #endif /* __i386___ && __GNUC__ */
338 #else /* NO_LIBWINE_PORT */
340 #define __WINE_NOT_PORTABLE(func) func##_is_not_portable func##_is_not_portable
342 #define getopt_long __WINE_NOT_PORTABLE(getopt_long)
343 #define getopt_long_only __WINE_NOT_PORTABLE(getopt_long_only)
344 #define getpagesize __WINE_NOT_PORTABLE(getpagesize)
345 #define lstat __WINE_NOT_PORTABLE(lstat)
346 #define memcpy_unaligned __WINE_NOT_PORTABLE(memcpy_unaligned)
347 #define memmove __WINE_NOT_PORTABLE(memmove)
348 #define pread __WINE_NOT_PORTABLE(pread)
349 #define pwrite __WINE_NOT_PORTABLE(pwrite)
350 #define spawnvp __WINE_NOT_PORTABLE(spawnvp)
351 #define statfs __WINE_NOT_PORTABLE(statfs)
352 #define strcasecmp __WINE_NOT_PORTABLE(strcasecmp)
353 #define strerror __WINE_NOT_PORTABLE(strerror)
354 #define strncasecmp __WINE_NOT_PORTABLE(strncasecmp)
355 #define usleep __WINE_NOT_PORTABLE(usleep)
357 #endif /* NO_LIBWINE_PORT */
359 #endif /* !defined(__WINE_WINE_PORT_H) */