ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

port.h
Go to the documentation of this file.
00001 /*
00002  * Wine porting definitions
00003  *
00004  * Copyright 1996 Alexandre Julliard
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #ifndef __WINE_WINE_PORT_H
00022 #define __WINE_WINE_PORT_H
00023 
00024 #ifndef __WINE_CONFIG_H
00025 # error You must include config.h to use this header
00026 #endif
00027 
00028 #define _GNU_SOURCE  /* for pread/pwrite */
00029 #include <fcntl.h>
00030 #include <math.h>
00031 #include <sys/types.h>
00032 #include <sys/stat.h>
00033 #ifdef HAVE_DIRECT_H
00034 # include <direct.h>
00035 #endif
00036 #ifdef HAVE_IO_H
00037 # include <io.h>
00038 #endif
00039 #ifdef HAVE_PROCESS_H
00040 # include <process.h>
00041 #endif
00042 #include <string.h>
00043 #ifdef HAVE_UNISTD_H
00044 # include <unistd.h>
00045 #endif
00046 
00047 
00048 /****************************************************************
00049  * Type definitions
00050  */
00051 
00052 #if !defined(_MSC_VER) && !defined(__int64)
00053 #  if defined(__x86_64__) || defined(_WIN64)
00054 #    define __int64 long
00055 #  else
00056 #    define __int64 long long
00057 #  endif
00058 #endif
00059 
00060 #if !defined(HAVE_MODE_T) && !defined(_MODE_T)
00061 typedef int mode_t;
00062 #endif
00063 #if !defined(HAVE_OFF_T) && !defined(_OFF_T)
00064 typedef long off_t;
00065 #endif
00066 #if !defined(HAVE_PID_T) && !defined(_PID_T)
00067 typedef int pid_t;
00068 #endif
00069 #if !defined(HAVE_SIZE_T) && !defined(_SIZE_T)
00070 typedef unsigned int size_t;
00071 #endif
00072 #if !defined(HAVE_SSIZE_T) && !defined(_SSIZE_T)
00073 typedef int ssize_t;
00074 #endif
00075 //#ifndef HAVE_SOCKLEN_T
00076 //typedef unsigned int socklen_t;
00077 //#endif
00078 
00079 #ifndef HAVE_STATFS
00080 # ifdef __BEOS__
00081 #  define HAVE_STRUCT_STATFS_F_BFREE
00082 struct statfs {
00083   long   f_bsize;  /* block_size */
00084   long   f_blocks; /* total_blocks */
00085   long   f_bfree;  /* free_blocks */
00086 };
00087 # else /* defined(__BEOS__) */
00088 struct statfs;
00089 # endif /* defined(__BEOS__) */
00090 #endif /* !defined(HAVE_STATFS) */
00091 
00092 
00093 /****************************************************************
00094  * Macro definitions
00095  */
00096 
00097 #ifdef HAVE_DLFCN_H
00098 #include <dlfcn.h>
00099 #else
00100 #define RTLD_LAZY    0x001
00101 #define RTLD_NOW     0x002
00102 #define RTLD_GLOBAL  0x100
00103 #endif
00104 
00105 #if !defined(HAVE_FTRUNCATE) && defined(HAVE_CHSIZE)
00106 #define ftruncate chsize
00107 #endif
00108 
00109 #if !defined(HAVE_POPEN) && defined(HAVE__POPEN)
00110 #define popen _popen
00111 #endif
00112 
00113 #if !defined(HAVE_PCLOSE) && defined(HAVE__PCLOSE)
00114 #define pclose _pclose
00115 #endif
00116 
00117 #if !defined(HAVE_SNPRINTF) && defined(HAVE__SNPRINTF)
00118 #define snprintf _snprintf
00119 #endif
00120 
00121 #if !defined(HAVE_VSNPRINTF) && defined(HAVE__VSNPRINTF)
00122 #define vsnprintf _vsnprintf
00123 #endif
00124 
00125 #ifndef S_ISLNK
00126 # define S_ISLNK(mod) (0)
00127 #endif /* S_ISLNK */
00128 
00129 /* So we open files in 64 bit access mode on Linux */
00130 #ifndef O_LARGEFILE
00131 # define O_LARGEFILE 0
00132 #endif
00133 
00134 #ifndef O_BINARY
00135 # define O_BINARY 0
00136 #endif
00137 
00138 /****************************************************************
00139  * Constants
00140  */
00141 
00142 #ifndef M_PI
00143 #define M_PI 3.14159265358979323846
00144 #endif
00145 
00146 #ifndef M_PI_2
00147 #define M_PI_2 1.570796326794896619
00148 #endif
00149 
00150 #ifndef M_PI_4
00151 #define M_PI_4 0.785398163397448309616
00152 #endif
00153 
00154 /* Constructor functions */
00155 
00156 #ifdef __GNUC__
00157 # define DECL_GLOBAL_CONSTRUCTOR(func) \
00158     static void func(void) __attribute__((constructor)); \
00159     static void func(void)
00160 #elif defined(__i386__)
00161 # define DECL_GLOBAL_CONSTRUCTOR(func) \
00162     static void __dummy_init_##func(void) { \
00163         asm(".section .init,\"ax\"\n\t" \
00164             "call " #func "\n\t" \
00165             ".previous"); } \
00166     static void func(void)
00167 #elif defined(__sparc__)
00168 # define DECL_GLOBAL_CONSTRUCTOR(func) \
00169     static void __dummy_init_##func(void) { \
00170         asm("\t.section \".init\",#alloc,#execinstr\n" \
00171             "\tcall " #func "\n" \
00172             "\tnop\n" \
00173             "\t.section \".text\",#alloc,#execinstr\n" ); } \
00174     static void func(void)
00175 #elif defined(_M_AMD64)
00176 #pragma message("You must define the DECL_GLOBAL_CONSTRUCTOR macro for amd64")
00177 #else
00178 # error You must define the DECL_GLOBAL_CONSTRUCTOR macro for your platform
00179 #endif
00180 
00181 
00182 /* Register functions */
00183 
00184 #ifdef __i386__
00185 #define DEFINE_REGS_ENTRYPOINT( name, fn, args, pop_args ) \
00186     __ASM_GLOBAL_FUNC( name, \
00187                        "call " __ASM_NAME("__wine_call_from_32_regs") "\n\t" \
00188                        ".long " __ASM_NAME(#fn) "\n\t" \
00189                        ".byte " #args "," #pop_args )
00190 /* FIXME: add support for other CPUs */
00191 #endif  /* __i386__ */
00192 
00193 
00194 /****************************************************************
00195  * Function definitions (only when using libwine_port)
00196  */
00197 
00198 #ifndef NO_LIBWINE_PORT
00199 
00200 #ifndef HAVE_GETOPT_LONG
00201 extern char *optarg;
00202 extern int optind;
00203 extern int opterr;
00204 extern int optopt;
00205 struct option;
00206 
00207 #ifndef HAVE_STRUCT_OPTION_NAME
00208 struct option
00209 {
00210     const char *name;
00211     int has_arg;
00212     int *flag;
00213     int val;
00214 };
00215 #endif
00216 
00217 extern int getopt_long (int ___argc, char *const *___argv,
00218                         const char *__shortopts,
00219                         const struct option *__longopts, int *__longind);
00220 extern int getopt_long_only (int ___argc, char *const *___argv,
00221                              const char *__shortopts,
00222                              const struct option *__longopts, int *__longind);
00223 #endif  /* HAVE_GETOPT_LONG */
00224 
00225 #ifndef HAVE_GETPAGESIZE
00226 size_t getpagesize(void);
00227 #endif  /* HAVE_GETPAGESIZE */
00228 
00229 #if !defined(HAVE_ISINF) && !defined(_ISINF) && !defined(isinf)
00230 int isinf(double x);
00231 #endif
00232 
00233 #if !defined(HAVE_ISNAN) && !defined(_ISNAN) && !defined(isnan)
00234 int isnan(double x);
00235 #endif
00236 
00237 #ifndef HAVE_LSTAT
00238 int lstat(const char *file_name, struct stat *buf);
00239 #endif /* HAVE_LSTAT */
00240 
00241 #ifndef HAVE_MEMMOVE
00242 void *memmove(void *dest, const void *src, size_t len);
00243 #endif /* !defined(HAVE_MEMMOVE) */
00244 
00245 #ifndef __REACTOS__
00246 #ifndef HAVE_PREAD
00247 ssize_t pread( int fd, void *buf, size_t count, off_t offset );
00248 #endif /* HAVE_PREAD */
00249 
00250 #ifndef HAVE_PWRITE
00251 ssize_t pwrite( int fd, const void *buf, size_t count, off_t offset );
00252 #endif /* HAVE_PWRITE */
00253 #endif /* __REACTOS__ */
00254 
00255 #ifdef WIN32
00256 #ifndef HAVE_SIGSETJMP
00257 # include <setjmp.h>
00258 typedef jmp_buf sigjmp_buf;
00259 int sigsetjmp( sigjmp_buf buf, int savesigs );
00260 void siglongjmp( sigjmp_buf buf, int val );
00261 #endif /* HAVE_SIGSETJMP */
00262 #endif
00263 
00264 #ifndef HAVE_STATFS
00265 int statfs(const char *name, struct statfs *info);
00266 #endif /* !defined(HAVE_STATFS) */
00267 
00268 #ifndef HAVE_STRNCASECMP
00269 # ifndef HAVE__STRNICMP
00270 int strncasecmp(const char *str1, const char *str2, size_t n);
00271 # else
00272 # define strncasecmp _strnicmp
00273 # endif
00274 #endif /* !defined(HAVE_STRNCASECMP) */
00275 
00276 #ifndef HAVE_STRERROR
00277 const char *strerror(int err);
00278 #endif /* !defined(HAVE_STRERROR) */
00279 
00280 #ifndef HAVE_STRCASECMP
00281 # ifndef HAVE__STRICMP
00282 int strcasecmp(const char *str1, const char *str2);
00283 # else
00284 # define strcasecmp _stricmp
00285 # endif
00286 #endif /* !defined(HAVE_STRCASECMP) */
00287 
00288 #if !defined(HAVE_USLEEP) && !defined(__CYGWIN__)
00289 int usleep (unsigned int useconds);
00290 #endif /* !defined(HAVE_USLEEP) */
00291 
00292 #ifdef __i386__
00293 static inline void *memcpy_unaligned( void *dst, const void *src, size_t size )
00294 {
00295     return memcpy( dst, src, size );
00296 }
00297 #else
00298 extern void *memcpy_unaligned( void *dst, const void *src, size_t size );
00299 #endif /* __i386__ */
00300 
00301 extern int mkstemps(char *template, int suffix_len);
00302 
00303 /* Process creation flags */
00304 #ifndef _P_WAIT
00305 # define _P_WAIT    0
00306 # define _P_NOWAIT  1
00307 # define _P_OVERLAY 2
00308 # define _P_NOWAITO 3
00309 # define _P_DETACH  4
00310 #endif
00311 #ifndef HAVE_SPAWNVP
00312 extern int spawnvp(int mode, const char *cmdname, const char * const argv[]);
00313 #endif
00314 
00315 /* Interlocked functions */
00316 
00317 #if defined(_MSC_VER) || (defined(__i386__) && defined(__GNUC__) && !defined(WINE_PORT_NO_INTERLOCKED))
00318 
00319 #define interlocked_cmpxchg InterlockedCompareExchange
00320 #define interlocked_cmpxchg_ptr InterlockedCompareExchangePtr
00321 #define interlocked_xchg InterlockedExchange
00322 #define interlocked_xchg_ptr InterlockedExchangePtr
00323 #define interlocked_xchg_add InterlockedExchangeAdd
00324 
00325 
00326 #endif  /* __i386___ && __GNUC__ */
00327 
00328 #if defined(_MSC_VER)
00329 __forceinline
00330 int
00331 ffs(int mask)
00332 {
00333     long index;
00334     if (_BitScanForward(&index, mask) == 0) return 0;
00335     return index;
00336 }
00337 #endif
00338 
00339 #else /* NO_LIBWINE_PORT */
00340 
00341 #define __WINE_NOT_PORTABLE(func) func##_is_not_portable func##_is_not_portable
00342 
00343 #define getopt_long             __WINE_NOT_PORTABLE(getopt_long)
00344 #define getopt_long_only        __WINE_NOT_PORTABLE(getopt_long_only)
00345 #define getpagesize             __WINE_NOT_PORTABLE(getpagesize)
00346 #define lstat                   __WINE_NOT_PORTABLE(lstat)
00347 #define memcpy_unaligned        __WINE_NOT_PORTABLE(memcpy_unaligned)
00348 #define memmove                 __WINE_NOT_PORTABLE(memmove)
00349 #define pread                   __WINE_NOT_PORTABLE(pread)
00350 #define pwrite                  __WINE_NOT_PORTABLE(pwrite)
00351 #define spawnvp                 __WINE_NOT_PORTABLE(spawnvp)
00352 #define statfs                  __WINE_NOT_PORTABLE(statfs)
00353 #define strcasecmp              __WINE_NOT_PORTABLE(strcasecmp)
00354 #define strerror                __WINE_NOT_PORTABLE(strerror)
00355 #define strncasecmp             __WINE_NOT_PORTABLE(strncasecmp)
00356 #define usleep                  __WINE_NOT_PORTABLE(usleep)
00357 
00358 #endif /* NO_LIBWINE_PORT */
00359 
00360 #endif /* !defined(__WINE_WINE_PORT_H) */

Generated on Sat May 26 2012 04:29:25 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.