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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 */
154 # define __ASM_GLOBAL_FUNC(name,code) \
155 __asm__( ".align 4\n\t" \
156 ".globl " __ASM_NAME(#name) "\n\t" \
157 __ASM_FUNC(#name) "\n" \
158 __ASM_NAME(#name) ":\n\t" \
161 # define __ASM_GLOBAL_FUNC(name,code) \
162 void __asm_dummy_##name(void) { \
163 asm( ".align 4\n\t" \
164 ".globl " __ASM_NAME(#name) "\n\t" \
165 __ASM_FUNC(#name) "\n" \
166 __ASM_NAME(#name) ":\n\t" \
169 #endif /* __GNUC__ */
172 /* Constructor functions */
175 # define DECL_GLOBAL_CONSTRUCTOR(func) \
176 static void func(void) __attribute__((constructor)); \
177 static void func(void)
178 #elif defined(__i386__)
179 # define DECL_GLOBAL_CONSTRUCTOR(func) \
180 static void __dummy_init_##func(void) { \
181 asm(".section .init,\"ax\"\n\t" \
182 "call " #func "\n\t" \
184 static void func(void)
185 #elif defined(__sparc__)
186 # define DECL_GLOBAL_CONSTRUCTOR(func) \
187 static void __dummy_init_##func(void) { \
188 asm("\t.section \".init\",#alloc,#execinstr\n" \
189 "\tcall " #func "\n" \
191 "\t.section \".text\",#alloc,#execinstr\n" ); } \
192 static void func(void)
194 # error You must define the DECL_GLOBAL_CONSTRUCTOR macro for your platform
198 /* Register functions */
201 #define DEFINE_REGS_ENTRYPOINT( name, fn, args, pop_args ) \
202 __ASM_GLOBAL_FUNC( name, \
203 "call " __ASM_NAME("__wine_call_from_32_regs") "\n\t" \
204 ".long " __ASM_NAME(#fn) "\n\t" \
205 ".byte " #args "," #pop_args )
206 /* FIXME: add support for other CPUs */
207 #endif /* __i386__ */
210 /****************************************************************
211 * Function definitions (only when using libwine_port)
214 #ifndef NO_LIBWINE_PORT
216 #ifndef HAVE_GETOPT_LONG
223 #ifndef HAVE_STRUCT_OPTION_NAME
233 extern int getopt_long (int ___argc
, char *const *___argv
,
234 const char *__shortopts
,
235 const struct option
*__longopts
, int *__longind
);
236 extern int getopt_long_only (int ___argc
, char *const *___argv
,
237 const char *__shortopts
,
238 const struct option
*__longopts
, int *__longind
);
239 #endif /* HAVE_GETOPT_LONG */
241 #ifndef HAVE_GETPAGESIZE
242 size_t getpagesize(void);
243 #endif /* HAVE_GETPAGESIZE */
247 #endif /* HAVE_GETTID */
250 int lstat(const char *file_name
, struct stat
*buf
);
251 #endif /* HAVE_LSTAT */
254 void *memmove(void *dest
, const void *src
, size_t len
);
255 #endif /* !defined(HAVE_MEMMOVE) */
259 ssize_t
pread( int fd
, void *buf
, size_t count
, off_t offset
);
260 #endif /* HAVE_PREAD */
263 ssize_t
pwrite( int fd
, const void *buf
, size_t count
, off_t offset
);
264 #endif /* HAVE_PWRITE */
265 #endif /* __REACTOS__ */
268 #ifndef HAVE_SIGSETJMP
270 typedef jmp_buf sigjmp_buf
;
271 int sigsetjmp( sigjmp_buf buf
, int savesigs
);
272 void siglongjmp( sigjmp_buf buf
, int val
);
273 #endif /* HAVE_SIGSETJMP */
277 int statfs(const char *name
, struct statfs
*info
);
278 #endif /* !defined(HAVE_STATFS) */
280 #ifndef HAVE_STRNCASECMP
281 # ifndef HAVE__STRNICMP
282 int strncasecmp(const char *str1
, const char *str2
, size_t n
);
284 # define strncasecmp _strnicmp
286 #endif /* !defined(HAVE_STRNCASECMP) */
288 #ifndef HAVE_STRERROR
289 const char *strerror(int err
);
290 #endif /* !defined(HAVE_STRERROR) */
292 #ifndef HAVE_STRCASECMP
293 # ifndef HAVE__STRICMP
294 int strcasecmp(const char *str1
, const char *str2
);
296 # define strcasecmp _stricmp
298 #endif /* !defined(HAVE_STRCASECMP) */
300 #if !defined(HAVE_USLEEP) && !defined(__CYGWIN__)
301 int usleep (unsigned int useconds
);
302 #endif /* !defined(HAVE_USLEEP) */
305 static inline void *memcpy_unaligned( void *dst
, const void *src
, size_t size
)
307 return memcpy( dst
, src
, size
);
310 extern void *memcpy_unaligned( void *dst
, const void *src
, size_t size
);
311 #endif /* __i386__ */
313 extern int mkstemps(char *template, int suffix_len
);
315 /* Process creation flags */
319 # define _P_OVERLAY 2
320 # define _P_NOWAITO 3
324 extern int spawnvp(int mode
, const char *cmdname
, const char * const argv
[]);
327 /* Interlocked functions */
329 #if defined(__i386__) && defined(__GNUC__) && !defined(WINE_PORT_NO_INTERLOCKED)
331 #define interlocked_cmpxchg InterlockedCompareExchange
332 #define interlocked_cmpxchg_ptr InterlockedCompareExchangePtr
333 #define interlocked_xchg InterlockedExchange
334 #define interlocked_xchg_ptr InterlockedExchangePtr
335 #define interlocked_xchg_add InterlockedExchangeAdd
338 #endif /* __i386___ && __GNUC__ */
340 #else /* NO_LIBWINE_PORT */
342 #define __WINE_NOT_PORTABLE(func) func##_is_not_portable func##_is_not_portable
344 #define getopt_long __WINE_NOT_PORTABLE(getopt_long)
345 #define getopt_long_only __WINE_NOT_PORTABLE(getopt_long_only)
346 #define getpagesize __WINE_NOT_PORTABLE(getpagesize)
347 #define lstat __WINE_NOT_PORTABLE(lstat)
348 #define memcpy_unaligned __WINE_NOT_PORTABLE(memcpy_unaligned)
349 #define memmove __WINE_NOT_PORTABLE(memmove)
350 #define pread __WINE_NOT_PORTABLE(pread)
351 #define pwrite __WINE_NOT_PORTABLE(pwrite)
352 #define spawnvp __WINE_NOT_PORTABLE(spawnvp)
353 #define statfs __WINE_NOT_PORTABLE(statfs)
354 #define strcasecmp __WINE_NOT_PORTABLE(strcasecmp)
355 #define strerror __WINE_NOT_PORTABLE(strerror)
356 #define strncasecmp __WINE_NOT_PORTABLE(strncasecmp)
357 #define usleep __WINE_NOT_PORTABLE(usleep)
359 #endif /* NO_LIBWINE_PORT */
361 #endif /* !defined(__WINE_WINE_PORT_H) */