pty_handle is a HANDLE, not an int.
[wine.git] / include / wine / port.h
blob6a1ae5f16082c253be5cd94c7110a4cd5b5d742c
1 /*
2 * Wine porting definitions
4 */
6 #ifndef __WINE_WINE_PORT_H
7 #define __WINE_WINE_PORT_H
9 #include "config.h"
11 #include <sys/types.h>
12 #include <sys/time.h>
13 #include <sys/stat.h>
14 #include <unistd.h>
16 /* Types */
18 #ifndef HAVE_GETRLIMIT
19 #define RLIMIT_STACK 3
20 typedef int rlim_t;
21 struct rlimit
23 rlim_t rlim_cur;
24 rlim_t rlim_max;
26 int getrlimit (int resource, struct rlimit *rlim);
27 #endif /* HAVE_GETRLIMIT */
29 #if !defined(HAVE_GETNETBYADDR) && !defined(HAVE_GETNETBYNAME)
30 struct netent {
31 char *n_name;
32 char **n_aliases;
33 int n_addrtype;
34 unsigned long n_net;
36 #endif /* !defined(HAVE_GETNETBYADDR) && !defined(HAVE_GETNETBYNAME) */
38 #if !defined(HAVE_GETPROTOBYNAME) && !defined(HAVE_GETPROTOBYNUMBER)
39 struct protoent {
40 char *p_name;
41 char **p_aliases;
42 int p_proto;
44 #endif /* !defined(HAVE_GETPROTOBYNAME) && !defined(HAVE_GETPROTOBYNUMBER) */
46 #ifndef HAVE_STATFS
47 # ifdef __BEOS__
48 # define STATFS_HAS_BFREE
49 struct statfs {
50 long f_bsize; /* block_size */
51 long f_blocks; /* total_blocks */
52 long f_bfree; /* free_blocks */
54 # else /* defined(__BEOS__) */
55 struct statfs;
56 # endif /* defined(__BEOS__) */
57 #endif /* !defined(HAVE_STATFS) */
59 /* Functions */
61 #if !defined(HAVE_CLONE) && defined(linux)
62 int clone(int (*fn)(void *arg), void *stack, int flags, void *arg);
63 #endif /* !defined(HAVE_CLONE) && defined(linux) */
65 #ifndef HAVE_GETNETBYADDR
66 struct netent *getnetbyaddr(unsigned long net, int type);
67 #endif /* defined(HAVE_GETNETBYNAME) */
69 #ifndef HAVE_GETNETBYNAME
70 struct netent *getnetbyname(const char *name);
71 #endif /* defined(HAVE_GETNETBYNAME) */
73 #ifndef HAVE_GETPROTOBYNAME
74 struct protoent *getprotobyname(const char *name);
75 #endif /* !defined(HAVE_GETPROTOBYNAME) */
77 #ifndef HAVE_GETPROTOBYNUMBER
78 struct protoent *getprotobynumber(int proto);
79 #endif /* !defined(HAVE_GETPROTOBYNUMBER) */
81 #ifndef HAVE_GETSERVBYPORT
82 struct servent *getservbyport(int port, const char *proto);
83 #endif /* !defined(HAVE_GETSERVBYPORT) */
85 #ifndef HAVE_GETSOCKOPT
86 int getsockopt(int socket, int level, int option_name, void *option_value, size_t *option_len);
87 #endif /* !defined(HAVE_GETSOCKOPT) */
89 #ifndef HAVE_MEMMOVE
90 void *memmove(void *dest, const void *src, unsigned int len);
91 #endif /* !defined(HAVE_MEMMOVE) */
93 #ifndef HAVE_GETPAGESIZE
94 size_t getpagesize(void);
95 #endif /* HAVE_GETPAGESIZE */
97 #ifndef HAVE_INET_NETWORK
98 unsigned long inet_network(const char *cp);
99 #endif /* !defined(HAVE_INET_NETWORK) */
101 #ifndef HAVE_SETTIMEOFDAY
102 int settimeofday(struct timeval *tp, void *reserved);
103 #endif /* !defined(HAVE_SETTIMEOFDAY) */
105 #ifndef HAVE_STATFS
106 int statfs(const char *name, struct statfs *info);
107 #endif /* !defined(HAVE_STATFS) */
109 #ifndef HAVE_STRNCASECMP
110 int strncasecmp(const char *str1, const char *str2, size_t n);
111 #endif /* !defined(HAVE_STRNCASECMP) */
113 #ifndef HAVE_STRERROR
114 const char *strerror(int err);
115 #endif /* !defined(HAVE_STRERROR) */
117 #ifndef HAVE_STRCASECMP
118 int strcasecmp(const char *str1, const char *str2);
119 #endif /* !defined(HAVE_STRCASECMP) */
121 #ifndef HAVE_USLEEP
122 int usleep (unsigned int useconds);
123 #endif /* !defined(HAVE_USLEEP) */
125 #ifndef HAVE_LSTAT
126 int lstat(const char *file_name, struct stat *buf);
127 #endif /* HAVE_LSTAT */
129 #ifndef S_ISLNK
130 #define S_ISLNK(mod) (0)
131 #endif /* S_ISLNK */
133 extern void *wine_dlopen( const char *filename, int flag, char *error, int errorsize );
134 extern void *wine_dlsym( void *handle, const char *symbol, char *error, int errorsize );
135 extern int wine_dlclose( void *handle, char *error, int errorsize );
137 #ifdef HAVE_DL_API
138 #include <dlfcn.h>
139 #else
140 #define RTLD_LAZY 0x001
141 #define RTLD_NOW 0x002
142 #define RTLD_GLOBAL 0x100
143 #endif
146 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
148 #define PUT_WORD(ptr, w) (*(WORD *)(ptr) = (w))
149 #define GET_WORD(ptr) (*(WORD *)(ptr))
150 #define PUT_DWORD(ptr, d) (*(DWORD *)(ptr) = (d))
151 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
153 #define PUT_LE_WORD(ptr, w) \
154 do { ((BYTE *)(ptr))[0] = LOBYTE(w); \
155 ((BYTE *)(ptr))[1] = HIBYTE(w); } while (0)
156 #define GET_LE_WORD(ptr) \
157 MAKEWORD( ((BYTE *)(ptr))[0], \
158 ((BYTE *)(ptr))[1] )
159 #define PUT_LE_DWORD(ptr, d) \
160 do { PUT_LE_WORD(&((WORD *)(ptr))[0], LOWORD(d)); \
161 PUT_LE_WORD(&((WORD *)(ptr))[1], HIWORD(d)); } while (0)
162 #define GET_LE_DWORD(ptr) \
163 ((DWORD)MAKELONG( GET_LE_WORD(&((WORD *)(ptr))[0]), \
164 GET_LE_WORD(&((WORD *)(ptr))[1]) ))
166 #define PUT_BE_WORD(ptr, w) \
167 do { ((BYTE *)(ptr))[1] = LOBYTE(w); \
168 ((BYTE *)(ptr))[0] = HIBYTE(w); } while (0)
169 #define GET_BE_WORD(ptr) \
170 MAKEWORD( ((BYTE *)(ptr))[1], \
171 ((BYTE *)(ptr))[0] )
172 #define PUT_BE_DWORD(ptr, d) \
173 do { PUT_BE_WORD(&((WORD *)(ptr))[1], LOWORD(d)); \
174 PUT_BE_WORD(&((WORD *)(ptr))[0], HIWORD(d)); } while (0)
175 #define GET_BE_DWORD(ptr) \
176 ((DWORD)MAKELONG( GET_BE_WORD(&((WORD *)(ptr))[1]), \
177 GET_BE_WORD(&((WORD *)(ptr))[0]) ))
179 #if defined(ALLOW_UNALIGNED_ACCESS)
180 #define PUT_UA_WORD(ptr, w) PUT_WORD(ptr, w)
181 #define GET_UA_WORD(ptr) GET_WORD(ptr)
182 #define PUT_UA_DWORD(ptr, d) PUT_DWORD(ptr, d)
183 #define GET_UA_DWORD(ptr) GET_DWORD(ptr)
184 #elif defined(WORDS_BIGENDIAN)
185 #define PUT_UA_WORD(ptr, w) PUT_BE_WORD(ptr, w)
186 #define GET_UA_WORD(ptr) GET_BE_WORD(ptr)
187 #define PUT_UA_DWORD(ptr, d) PUT_BE_DWORD(ptr, d)
188 #define GET_UA_DWORD(ptr) GET_BE_DWORD(ptr)
189 #else
190 #define PUT_UA_WORD(ptr, w) PUT_LE_WORD(ptr, w)
191 #define GET_UA_WORD(ptr) GET_LE_WORD(ptr)
192 #define PUT_UA_DWORD(ptr, d) PUT_LE_DWORD(ptr, d)
193 #define GET_UA_DWORD(ptr) GET_LE_DWORD(ptr)
194 #endif
196 #endif /* !defined(__WINE_WINE_PORT_H) */