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 */
30 #include <sys/types.h>
37 #ifndef HAVE_GETRLIMIT
38 #define RLIMIT_STACK 3
45 int getrlimit (int resource, struct rlimit *rlim);
46 #endif /* HAVE_GETRLIMIT */
48 #if !defined(HAVE_GETNETBYADDR) && !defined(HAVE_GETNETBYNAME)
55 #endif /* !defined(HAVE_GETNETBYADDR) && !defined(HAVE_GETNETBYNAME) */
57 #if !defined(HAVE_GETPROTOBYNAME) && !defined(HAVE_GETPROTOBYNUMBER)
63 #endif /* !defined(HAVE_GETPROTOBYNAME) && !defined(HAVE_GETPROTOBYNUMBER) */
67 # define STATFS_HAS_BFREE
69 long f_bsize; /* block_size */
70 long f_blocks; /* total_blocks */
71 long f_bfree; /* free_blocks */
73 # else /* defined(__BEOS__) */
75 # endif /* defined(__BEOS__) */
76 #endif /* !defined(HAVE_STATFS) */
80 #if !defined(HAVE_CLONE) && defined(linux)
81 int clone(int (*fn)(void *arg), void *stack, int flags, void *arg);
82 #endif /* !defined(HAVE_CLONE) && defined(linux) */
84 #ifndef HAVE_GETNETBYADDR
85 struct netent *getnetbyaddr(unsigned long net, int type);
86 #endif /* defined(HAVE_GETNETBYNAME) */
88 #ifndef HAVE_GETNETBYNAME
89 struct netent *getnetbyname(const char *name);
90 #endif /* defined(HAVE_GETNETBYNAME) */
92 #ifndef HAVE_GETPROTOBYNAME
93 struct protoent *getprotobyname(const char *name);
94 #endif /* !defined(HAVE_GETPROTOBYNAME) */
96 #ifndef HAVE_GETPROTOBYNUMBER
97 struct protoent *getprotobynumber(int proto);
98 #endif /* !defined(HAVE_GETPROTOBYNUMBER) */
100 #ifndef HAVE_GETSERVBYPORT
101 struct servent *getservbyport(int port, const char *proto);
102 #endif /* !defined(HAVE_GETSERVBYPORT) */
104 #ifndef HAVE_GETSOCKOPT
105 int getsockopt(int socket, int level, int option_name, void *option_value, size_t *option_len);
106 #endif /* !defined(HAVE_GETSOCKOPT) */
109 void *memmove(void *dest, const void *src, unsigned int len);
110 #endif /* !defined(HAVE_MEMMOVE) */
112 #ifndef HAVE_GETPAGESIZE
113 size_t getpagesize(void);
114 #endif /* HAVE_GETPAGESIZE */
116 #ifndef HAVE_INET_NETWORK
117 unsigned long inet_network(const char *cp);
118 #endif /* !defined(HAVE_INET_NETWORK) */
120 #ifndef HAVE_SETTIMEOFDAY
121 int settimeofday(struct timeval *tp, void *reserved);
122 #endif /* !defined(HAVE_SETTIMEOFDAY) */
125 int statfs(const char *name, struct statfs *info);
126 #endif /* !defined(HAVE_STATFS) */
128 #ifndef HAVE_STRNCASECMP
129 int strncasecmp(const char *str1, const char *str2, size_t n);
130 #endif /* !defined(HAVE_STRNCASECMP) */
135 int openpty(int *master, int *slave, char *name, struct termios *term, struct winsize *winsize);
136 #endif /* HAVE_OPENPTY */
138 #ifndef HAVE_STRERROR
139 const char *strerror(int err);
140 #endif /* !defined(HAVE_STRERROR) */
142 #ifndef HAVE_STRCASECMP
143 int strcasecmp(const char *str1, const char *str2);
144 #endif /* !defined(HAVE_STRCASECMP) */
147 int usleep (unsigned int useconds);
148 #endif /* !defined(HAVE_USLEEP) */
151 int lstat(const char *file_name, struct stat *buf);
152 #endif /* HAVE_LSTAT */
155 ssize_t pread( int fd, void *buf, size_t count, off_t offset );
156 #endif /* HAVE_PREAD */
159 ssize_t pwrite( int fd, const void *buf, size_t count, off_t offset );
160 #endif /* HAVE_PWRITE */
163 #define S_ISLNK(mod) (0)
166 /* So we open files in 64 bit access mode on Linux */
168 # define O_LARGEFILE 0
171 extern void *wine_dlopen( const char *filename, int flag, char *error, int errorsize );
172 extern void *wine_dlsym( void *handle, const char *symbol, char *error, int errorsize );
173 extern int wine_dlclose( void *handle, char *error, int errorsize );
178 #define RTLD_LAZY 0x001
179 #define RTLD_NOW 0x002
180 #define RTLD_GLOBAL 0x100
184 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
186 #define PUT_WORD(ptr, w) (*(WORD *)(ptr) = (w))
187 #define GET_WORD(ptr) (*(WORD *)(ptr))
188 #define PUT_DWORD(ptr, d) (*(DWORD *)(ptr) = (d))
189 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
191 #define PUT_LE_WORD(ptr, w) \
192 do { ((BYTE *)(ptr))[0] = LOBYTE(w); \
193 ((BYTE *)(ptr))[1] = HIBYTE(w); } while (0)
194 #define GET_LE_WORD(ptr) \
195 MAKEWORD( ((BYTE *)(ptr))[0], \
197 #define PUT_LE_DWORD(ptr, d) \
198 do { PUT_LE_WORD(&((WORD *)(ptr))[0], LOWORD(d)); \
199 PUT_LE_WORD(&((WORD *)(ptr))[1], HIWORD(d)); } while (0)
200 #define GET_LE_DWORD(ptr) \
201 ((DWORD)MAKELONG( GET_LE_WORD(&((WORD *)(ptr))[0]), \
202 GET_LE_WORD(&((WORD *)(ptr))[1]) ))
204 #define PUT_BE_WORD(ptr, w) \
205 do { ((BYTE *)(ptr))[1] = LOBYTE(w); \
206 ((BYTE *)(ptr))[0] = HIBYTE(w); } while (0)
207 #define GET_BE_WORD(ptr) \
208 MAKEWORD( ((BYTE *)(ptr))[1], \
210 #define PUT_BE_DWORD(ptr, d) \
211 do { PUT_BE_WORD(&((WORD *)(ptr))[1], LOWORD(d)); \
212 PUT_BE_WORD(&((WORD *)(ptr))[0], HIWORD(d)); } while (0)
213 #define GET_BE_DWORD(ptr) \
214 ((DWORD)MAKELONG( GET_BE_WORD(&((WORD *)(ptr))[1]), \
215 GET_BE_WORD(&((WORD *)(ptr))[0]) ))
217 #if defined(ALLOW_UNALIGNED_ACCESS)
218 #define PUT_UA_WORD(ptr, w) PUT_WORD(ptr, w)
219 #define GET_UA_WORD(ptr) GET_WORD(ptr)
220 #define PUT_UA_DWORD(ptr, d) PUT_DWORD(ptr, d)
221 #define GET_UA_DWORD(ptr) GET_DWORD(ptr)
222 #elif defined(WORDS_BIGENDIAN)
223 #define PUT_UA_WORD(ptr, w) PUT_BE_WORD(ptr, w)
224 #define GET_UA_WORD(ptr) GET_BE_WORD(ptr)
225 #define PUT_UA_DWORD(ptr, d) PUT_BE_DWORD(ptr, d)
226 #define GET_UA_DWORD(ptr) GET_BE_DWORD(ptr)
228 #define PUT_UA_WORD(ptr, w) PUT_LE_WORD(ptr, w)
229 #define GET_UA_WORD(ptr) GET_LE_WORD(ptr)
230 #define PUT_UA_DWORD(ptr, d) PUT_LE_DWORD(ptr, d)
231 #define GET_UA_DWORD(ptr) GET_LE_DWORD(ptr)
234 #endif /* !defined(__WINE_WINE_PORT_H) */