|
| 1 | +#include <stdint.h> |
| 2 | +#include <wchar.h> |
| 3 | +#include <sys/types.h> |
| 4 | +#ifndef _POSIX |
| 5 | +typedef _sigset_t sigset_t; |
| 6 | +#endif |
1 | 7 | #include <winsock2.h> |
2 | 8 | #include <ws2tcpip.h> |
3 | | - |
4 | 9 | /* |
5 | 10 | * things that are not available in header files |
6 | 11 | */ |
7 | 12 |
|
8 | | -typedef int pid_t; |
9 | 13 | typedef int uid_t; |
10 | 14 | typedef int socklen_t; |
11 | | -#define hstrerror strerror |
12 | 15 |
|
13 | 16 | #define S_IFLNK 0120000 /* Symbolic link */ |
14 | 17 | #define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK) |
15 | 18 | #define S_ISSOCK(x) 0 |
16 | 19 |
|
| 20 | +#ifndef S_IRWXG |
17 | 21 | #define S_IRGRP 0 |
18 | 22 | #define S_IWGRP 0 |
19 | 23 | #define S_IXGRP 0 |
20 | 24 | #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) |
| 25 | +#endif |
| 26 | +#ifndef S_IRWXO |
21 | 27 | #define S_IROTH 0 |
22 | 28 | #define S_IWOTH 0 |
23 | 29 | #define S_IXOTH 0 |
24 | 30 | #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) |
| 31 | +#endif |
25 | 32 |
|
26 | 33 | #define S_ISUID 0004000 |
27 | 34 | #define S_ISGID 0002000 |
@@ -92,8 +99,10 @@ static inline int symlink(const char *oldpath, const char *newpath) |
92 | 99 | { errno = ENOSYS; return -1; } |
93 | 100 | static inline int fchmod(int fildes, mode_t mode) |
94 | 101 | { errno = ENOSYS; return -1; } |
| 102 | +#ifndef __MINGW64_VERSION_MAJOR |
95 | 103 | static inline pid_t fork(void) |
96 | 104 | { errno = ENOSYS; return -1; } |
| 105 | +#endif |
97 | 106 | static inline unsigned int alarm(unsigned int seconds) |
98 | 107 | { return 0; } |
99 | 108 | static inline int fsync(int fd) |
@@ -164,8 +173,10 @@ int pipe(int filedes[2]); |
164 | 173 | unsigned int sleep (unsigned int seconds); |
165 | 174 | int mkstemp(char *template); |
166 | 175 | int gettimeofday(struct timeval *tv, void *tz); |
| 176 | +#ifndef __MINGW64_VERSION_MAJOR |
167 | 177 | struct tm *gmtime_r(const time_t *timep, struct tm *result); |
168 | 178 | struct tm *localtime_r(const time_t *timep, struct tm *result); |
| 179 | +#endif |
169 | 180 | int getpagesize(void); /* defined in MinGW's libgcc.a */ |
170 | 181 | struct passwd *getpwuid(uid_t uid); |
171 | 182 | int setitimer(int type, struct itimerval *in, struct itimerval *out); |
@@ -213,6 +224,10 @@ char *mingw_mktemp(char *template); |
213 | 224 | char *mingw_getcwd(char *pointer, int len); |
214 | 225 | #define getcwd mingw_getcwd |
215 | 226 |
|
| 227 | +#ifdef NO_UNSETENV |
| 228 | +#error "NO_UNSETENV is incompatible with the MinGW startup code!" |
| 229 | +#endif |
| 230 | + |
216 | 231 | char *mingw_getenv(const char *name); |
217 | 232 | #define getenv mingw_getenv |
218 | 233 | int mingw_putenv(const char *namevalue); |
@@ -285,8 +300,10 @@ static inline int getrlimit(int resource, struct rlimit *rlp) |
285 | 300 | /* |
286 | 301 | * Use mingw specific stat()/lstat()/fstat() implementations on Windows. |
287 | 302 | */ |
| 303 | +#ifndef __MINGW64_VERSION_MAJOR |
288 | 304 | #define off_t off64_t |
289 | 305 | #define lseek _lseeki64 |
| 306 | +#endif |
290 | 307 |
|
291 | 308 | /* use struct stat with 64 bit st_size */ |
292 | 309 | #ifdef stat |
@@ -359,8 +376,12 @@ static inline char *mingw_find_last_dir_sep(const char *path) |
359 | 376 | int mingw_offset_1st_component(const char *path); |
360 | 377 | #define offset_1st_component mingw_offset_1st_component |
361 | 378 | #define PATH_SEP ';' |
| 379 | +#ifndef __MINGW64_VERSION_MAJOR |
362 | 380 | #define PRIuMAX "I64u" |
363 | 381 | #define PRId64 "I64d" |
| 382 | +#else |
| 383 | +#include <inttypes.h> |
| 384 | +#endif |
364 | 385 |
|
365 | 386 | void mingw_open_html(const char *path); |
366 | 387 | #define open_html mingw_open_html |
|
0 commit comments