~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/include/wine/port.h

Version: ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Wine porting definitions
  3  *
  4  * Copyright 1996 Alexandre Julliard
  5  *
  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.
 10  *
 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.
 15  *
 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
 19  */
 20 
 21 #ifndef __WINE_WINE_PORT_H
 22 #define __WINE_WINE_PORT_H
 23 
 24 #ifndef __WINE_CONFIG_H
 25 # error You must include config.h to use this header
 26 #endif
 27 
 28 #ifdef __WINE_BASETSD_H
 29 # error You must include port.h before all other headers
 30 #endif
 31 
 32 #define _FILE_OFFSET_BITS 64
 33 #define _GNU_SOURCE  /* for pread/pwrite */
 34 #include <fcntl.h>
 35 #include <math.h>
 36 #include <sys/types.h>
 37 #include <sys/stat.h>
 38 #ifdef HAVE_DIRECT_H
 39 # include <direct.h>
 40 #endif
 41 #ifdef HAVE_IO_H
 42 # include <io.h>
 43 #endif
 44 #ifdef HAVE_PROCESS_H
 45 # include <process.h>
 46 #endif
 47 #include <string.h>
 48 #ifdef HAVE_UNISTD_H
 49 # include <unistd.h>
 50 #endif
 51 
 52 
 53 /****************************************************************
 54  * Type definitions
 55  */
 56 
 57 #if !defined(_MSC_VER) && !defined(__int64)
 58 #  if defined(__x86_64__) || defined(_WIN64)
 59 #    define __int64 long
 60 #  else
 61 #    define __int64 long long
 62 #  endif
 63 #endif
 64 
 65 #ifndef HAVE_MODE_T
 66 typedef int mode_t;
 67 #endif
 68 #ifndef HAVE_OFF_T
 69 typedef long off_t;
 70 #endif
 71 #ifndef HAVE_PID_T
 72 typedef int pid_t;
 73 #endif
 74 #ifndef HAVE_SIZE_T
 75 typedef unsigned int size_t;
 76 #endif
 77 #ifndef HAVE_SSIZE_T
 78 typedef int ssize_t;
 79 #endif
 80 #ifndef HAVE_FSBLKCNT_T
 81 typedef unsigned long fsblkcnt_t;
 82 #endif
 83 #ifndef HAVE_FSFILCNT_T
 84 typedef unsigned long fsfilcnt_t;
 85 #endif
 86 
 87 #ifndef HAVE_STRUCT_STATVFS_F_BLOCKS
 88 struct statvfs
 89 {
 90     unsigned long f_bsize;
 91     unsigned long f_frsize;
 92     fsblkcnt_t    f_blocks;
 93     fsblkcnt_t    f_bfree;
 94     fsblkcnt_t    f_bavail;
 95     fsfilcnt_t    f_files;
 96     fsfilcnt_t    f_ffree;
 97     fsfilcnt_t    f_favail;
 98     unsigned long f_fsid;
 99     unsigned long f_flag;
100     unsigned long f_namemax;
101 };
102 #endif /* HAVE_STRUCT_STATVFS_F_BLOCKS */
103 
104 
105 /****************************************************************
106  * Macro definitions
107  */
108 
109 #ifdef HAVE_DLFCN_H
110 #include <dlfcn.h>
111 #else
112 #define RTLD_LAZY    0x001
113 #define RTLD_NOW     0x002
114 #define RTLD_GLOBAL  0x100
115 #endif
116 
117 #if !defined(HAVE_FTRUNCATE) && defined(HAVE_CHSIZE)
118 #define ftruncate chsize
119 #endif
120 
121 #if !defined(HAVE_POPEN) && defined(HAVE__POPEN)
122 #define popen _popen
123 #endif
124 
125 #if !defined(HAVE_PCLOSE) && defined(HAVE__PCLOSE)
126 #define pclose _pclose
127 #endif
128 
129 #if !defined(HAVE_STRDUP) && defined(HAVE__STRDUP)
130 #define strdup _strdup
131 #endif
132 
133 #if !defined(HAVE_SNPRINTF) && defined(HAVE__SNPRINTF)
134 #define snprintf _snprintf
135 #endif
136 
137 #if !defined(HAVE_VSNPRINTF) && defined(HAVE__VSNPRINTF)
138 #define vsnprintf _vsnprintf
139 #endif
140 
141 #if !defined(HAVE_STRTOLL) && defined(HAVE__STRTOI64)
142 #define strtoll _strtoi64
143 #endif
144 
145 #if !defined(HAVE_STRTOULL) && defined(HAVE__STRTOUI64)
146 #define strtoull _strtoui64
147 #endif
148 
149 #ifndef S_ISLNK
150 # define S_ISLNK(mod) (0)
151 #endif
152 
153 #ifndef S_ISSOCK
154 # define S_ISSOCK(mod) (0)
155 #endif
156 
157 #ifndef S_ISDIR
158 # define S_ISDIR(mod) (((mod) & _S_IFMT) == _S_IFDIR)
159 #endif
160 
161 #ifndef S_ISCHR
162 # define S_ISCHR(mod) (((mod) & _S_IFMT) == _S_IFCHR)
163 #endif
164 
165 #ifndef S_ISFIFO
166 # define S_ISFIFO(mod) (((mod) & _S_IFMT) == _S_IFIFO)
167 #endif
168 
169 #ifndef S_ISREG
170 # define S_ISREG(mod) (((mod) & _S_IFMT) == _S_IFREG)
171 #endif
172 
173 #ifndef S_IWUSR
174 # define S_IWUSR 0
175 #endif
176 
177 /* So we open files in 64 bit access mode on Linux */
178 #ifndef O_LARGEFILE
179 # define O_LARGEFILE 0
180 #endif
181 
182 #ifndef O_NONBLOCK
183 # define O_NONBLOCK 0
184 #endif
185 
186 #ifndef O_BINARY
187 # define O_BINARY 0
188 #endif
189 
190 #if !defined(S_IXUSR) && defined(S_IEXEC)
191 # define S_IXUSR S_IEXEC
192 #endif
193 #if !defined(S_IXGRP) && defined(S_IEXEC)
194 # define S_IXGRP S_IEXEC
195 #endif
196 #if !defined(S_IXOTH) && defined(S_IEXEC)
197 # define S_IXOTH S_IEXEC
198 #endif
199 
200 
201 /****************************************************************
202  * Constants
203  */
204 
205 #ifndef M_PI
206 #define M_PI 3.14159265358979323846
207 #endif
208 
209 #ifndef M_PI_2
210 #define M_PI_2 1.570796326794896619
211 #endif
212 
213 
214 /* Macros to define assembler functions somewhat portably */
215 
216 #if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__APPLE__)
217 # define __ASM_GLOBAL_FUNC(name,code) \
218       __asm__( ".text\n\t" \
219                ".align 4\n\t" \
220                ".globl " __ASM_NAME(#name) "\n\t" \
221                __ASM_FUNC(#name) "\n" \
222                __ASM_NAME(#name) ":\n\t" \
223                code \
224                "\n\t.previous" );
225 #else  /* defined(__GNUC__) && !defined(__MINGW32__) && !defined(__APPLE__)  */
226 # define __ASM_GLOBAL_FUNC(name,code) \
227       void __asm_dummy_##name(void) { \
228           asm( ".align 4\n\t" \
229                ".globl " __ASM_NAME(#name) "\n\t" \
230                __ASM_FUNC(#name) "\n" \
231                __ASM_NAME(#name) ":\n\t" \
232                code ); \
233       }
234 #endif  /* __GNUC__ */
235 
236 
237 /* Register functions */
238 
239 #ifdef __i386__
240 #define DEFINE_REGS_ENTRYPOINT( name, args, pop_args ) \
241     __ASM_GLOBAL_FUNC( name, \
242                        "pushl %eax\n\t" \
243                        "call " __ASM_NAME("__wine_call_from_32_regs") "\n\t" \
244                        ".long " __ASM_NAME("__regs_") #name "-.\n\t" \
245                        ".byte " #args "," #pop_args )
246 /* FIXME: add support for other CPUs */
247 #endif  /* __i386__ */
248 
249 
250 /****************************************************************
251  * Function definitions (only when using libwine_port)
252  */
253 
254 #ifndef NO_LIBWINE_PORT
255 
256 #ifndef HAVE_FSTATVFS
257 int fstatvfs( int fd, struct statvfs *buf );
258 #endif
259 
260 #ifndef HAVE_GETOPT_LONG
261 extern char *optarg;
262 extern int optind;
263 extern int opterr;
264 extern int optopt;
265 struct option;
266 
267 #ifndef HAVE_STRUCT_OPTION_NAME
268 struct option
269 {
270     const char *name;
271     int has_arg;
272     int *flag;
273     int val;
274 };
275 #endif
276 
277 extern int getopt_long (int ___argc, char *const *___argv,
278                         const char *__shortopts,
279                         const struct option *__longopts, int *__longind);
280 extern int getopt_long_only (int ___argc, char *const *___argv,
281                              const char *__shortopts,
282                              const struct option *__longopts, int *__longind);
283 #endif  /* HAVE_GETOPT_LONG */
284 
285 #ifndef HAVE_FFS
286 int ffs( int x );
287 #endif
288 
289 #ifndef HAVE_FUTIMES
290 struct timeval;
291 int futimes(int fd, const struct timeval *tv);
292 #endif
293 
294 #ifndef HAVE_GETPAGESIZE
295 size_t getpagesize(void);
296 #endif  /* HAVE_GETPAGESIZE */
297 
298 #ifndef HAVE_GETTID
299 pid_t gettid(void);
300 #endif /* HAVE_GETTID */
301 
302 #ifndef HAVE_ISINF
303 int isinf(double x);
304 #endif
305 
306 #ifndef HAVE_LSTAT
307 int lstat(const char *file_name, struct stat *buf);
308 #endif /* HAVE_LSTAT */
309 
310 #ifndef HAVE_MEMMOVE
311 void *memmove(void *dest, const void *src, size_t len);
312 #endif /* !defined(HAVE_MEMMOVE) */
313 
314 #ifndef HAVE_PREAD
315 ssize_t pread( int fd, void *buf, size_t count, off_t offset );
316 #endif /* HAVE_PREAD */
317 
318 #ifndef HAVE_PWRITE
319 ssize_t pwrite( int fd, const void *buf, size_t count, off_t offset );
320 #endif /* HAVE_PWRITE */
321 
322 #ifndef HAVE_READLINK
323 int readlink( const char *path, char *buf, size_t size );
324 #endif /* HAVE_READLINK */
325 
326 #ifndef HAVE_STATVFS
327 int statvfs( const char *path, struct statvfs *buf );
328 #endif
329 
330 #ifndef HAVE_STRNCASECMP
331 # ifndef HAVE__STRNICMP
332 int strncasecmp(const char *str1, const char *str2, size_t n);
333 # else
334 # define strncasecmp _strnicmp
335 # endif
336 #endif /* !defined(HAVE_STRNCASECMP) */
337 
338 #ifndef HAVE_STRERROR
339 const char *strerror(int err);
340 #endif /* !defined(HAVE_STRERROR) */
341 
342 #ifndef HAVE_STRCASECMP
343 # ifndef HAVE__STRICMP
344 int strcasecmp(const char *str1, const char *str2);
345 # else
346 # define strcasecmp _stricmp
347 # endif
348 #endif /* !defined(HAVE_STRCASECMP) */
349 
350 #ifndef HAVE_USLEEP
351 int usleep (unsigned int useconds);
352 #endif /* !defined(HAVE_USLEEP) */
353 
354 #ifdef __i386__
355 static inline void *memcpy_unaligned( void *dst, const void *src, size_t size )
356 {
357     return memcpy( dst, src, size );
358 }
359 #else
360 extern void *memcpy_unaligned( void *dst, const void *src, size_t size );
361 #endif /* __i386__ */
362 
363 extern int mkstemps(char *template, int suffix_len);
364 
365 /* Process creation flags */
366 #ifndef _P_WAIT
367 # define _P_WAIT    0
368 # define _P_NOWAIT  1
369 # define _P_OVERLAY 2
370 # define _P_NOWAITO 3
371 # define _P_DETACH  4
372 #endif
373 #ifndef HAVE_SPAWNVP
374 extern int spawnvp(int mode, const char *cmdname, const char * const argv[]);
375 #endif
376 
377 /* Interlocked functions */
378 
379 #if defined(__i386__) && defined(__GNUC__)
380 
381 extern inline int interlocked_cmpxchg( int *dest, int xchg, int compare );
382 extern inline void *interlocked_cmpxchg_ptr( void **dest, void *xchg, void *compare );
383 extern __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int64 compare );
384 extern inline int interlocked_xchg( int *dest, int val );
385 extern inline void *interlocked_xchg_ptr( void **dest, void *val );
386 extern inline int interlocked_xchg_add( int *dest, int incr );
387 
388 extern inline int interlocked_cmpxchg( int *dest, int xchg, int compare )
389 {
390     int ret;
391     __asm__ __volatile__( "lock; cmpxchgl %2,(%1)"
392                           : "=a" (ret) : "r" (dest), "r" (xchg), "" (compare) : "memory" );
393     return ret;
394 }
395 
396 extern inline void *interlocked_cmpxchg_ptr( void **dest, void *xchg, void *compare )
397 {
398     void *ret;
399     __asm__ __volatile__( "lock; cmpxchgl %2,(%1)"
400                           : "=a" (ret) : "r" (dest), "r" (xchg), "" (compare) : "memory" );
401     return ret;
402 }
403 
404 extern inline int interlocked_xchg( int *dest, int val )
405 {
406     int ret;
407     __asm__ __volatile__( "lock; xchgl %0,(%1)"
408                           : "=r" (ret) : "r" (dest), "" (val) : "memory" );
409     return ret;
410 }
411 
412 extern inline void *interlocked_xchg_ptr( void **dest, void *val )
413 {
414     void *ret;
415     __asm__ __volatile__( "lock; xchgl %0,(%1)"
416                           : "=r" (ret) : "r" (dest), "" (val) : "memory" );
417     return ret;
418 }
419 
420 extern inline int interlocked_xchg_add( int *dest, int incr )
421 {
422     int ret;
423     __asm__ __volatile__( "lock; xaddl %0,(%1)"
424                           : "=r" (ret) : "r" (dest), "" (incr) : "memory" );
425     return ret;
426 }
427 
428 #else  /* __i386___ && __GNUC__ */
429 
430 extern int interlocked_cmpxchg( int *dest, int xchg, int compare );
431 extern void *interlocked_cmpxchg_ptr( void **dest, void *xchg, void *compare );
432 extern __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int64 compare );
433 extern int interlocked_xchg( int *dest, int val );
434 extern void *interlocked_xchg_ptr( void **dest, void *val );
435 extern int interlocked_xchg_add( int *dest, int incr );
436 
437 #endif  /* __i386___ && __GNUC__ */
438 
439 #else /* NO_LIBWINE_PORT */
440 
441 #define __WINE_NOT_PORTABLE(func) func##_is_not_portable func##_is_not_portable
442 
443 #define ffs                     __WINE_NOT_PORTABLE(ffs)
444 #define fstatvfs                __WINE_NOT_PORTABLE(fstatvfs)
445 #define futimes                 __WINE_NOT_PORTABLE(futimes)
446 #define getopt_long             __WINE_NOT_PORTABLE(getopt_long)
447 #define getopt_long_only        __WINE_NOT_PORTABLE(getopt_long_only)
448 #define getpagesize             __WINE_NOT_PORTABLE(getpagesize)
449 #define interlocked_cmpxchg     __WINE_NOT_PORTABLE(interlocked_cmpxchg)
450 #define interlocked_cmpxchg_ptr __WINE_NOT_PORTABLE(interlocked_cmpxchg_ptr)
451 #define interlocked_xchg        __WINE_NOT_PORTABLE(interlocked_xchg)
452 #define interlocked_xchg_ptr    __WINE_NOT_PORTABLE(interlocked_xchg_ptr)
453 #define interlocked_xchg_add    __WINE_NOT_PORTABLE(interlocked_xchg_add)
454 #define lstat                   __WINE_NOT_PORTABLE(lstat)
455 #define memcpy_unaligned        __WINE_NOT_PORTABLE(memcpy_unaligned)
456 #undef memmove
457 #define memmove                 __WINE_NOT_PORTABLE(memmove)
458 #define pread                   __WINE_NOT_PORTABLE(pread)
459 #define pwrite                  __WINE_NOT_PORTABLE(pwrite)
460 #define spawnvp                 __WINE_NOT_PORTABLE(spawnvp)
461 #define statvfs                 __WINE_NOT_PORTABLE(statvfs)
462 #define strcasecmp              __WINE_NOT_PORTABLE(strcasecmp)
463 #define strerror                __WINE_NOT_PORTABLE(strerror)
464 #define strncasecmp             __WINE_NOT_PORTABLE(strncasecmp)
465 #define usleep                  __WINE_NOT_PORTABLE(usleep)
466 
467 #endif /* NO_LIBWINE_PORT */
468 
469 #endif /* !defined(__WINE_WINE_PORT_H) */
470 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.