Debian Codegraph @

src/include/compat-mingw.h

raw
1 // ----------------------------------------------------------------------------
2 // Copyright (C) 2014
3 // David Freese, W1HKJ
4 //
5 // This file is part of flmsg
6 //
7 // flrig is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // flrig is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 // ----------------------------------------------------------------------------
20
21 #ifndef MINGW_H_
22 #define MINGW_H_
23
24 #include <winsock2.h>
25 #include <windows.h>
26 #include <sys/types.h>
27 #include <pthread.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 //typedef int pid_t;
34 typedef long suseconds_t;
35 #define hstrerror strerror
36
37 #ifndef SIGUSR2
38 # define SIGUSR2 100
39 #endif
40
41 /*
42 * simple adaptors
43 */
44
45 static inline int mingw_mkdir(const char *path, int mode)
46 {
47 return mkdir(path);
48 }
49 #define mkdir mingw_mkdir
50
51 static inline int mingw_unlink(const char *pathname)
52 {
53 /* read-only files cannot be removed */
54 chmod(pathname, 0666);
55 return unlink(pathname);
56 }
57 #define unlink mingw_unlink
58
59 /*
60 * implementations of missing functions
61 */
62
63 unsigned int sleep (unsigned int seconds);
64 char *mingw_getcwd(char *pointer, int len);
65 #define getcwd mingw_getcwd
66 char *mingw_getenv(const char *name);
67 #define getenv mingw_getenv
68 int mingw_rename(const char*, const char*);
69 #define rename mingw_rename
70
71 #ifndef SHUT_WR
72 # define SHUT_WR SD_SEND
73 #endif
74 #ifndef SHUT_RD
75 # define SHUT_RD SD_RECEIVE
76 #endif
77 #ifndef SHUT_RDWR
78 # define SHUT_RDWR SD_BOTH
79 #endif
80 #ifndef EADDRINUSE
81 # define EADDRINUSE WSAEADDRINUSE
82 #endif
83
84 int nanosleep (const struct timespec *req, struct timespec *rem);
85 int socketpair(int family, int type, int protocol, int *sv);
86
87 /* uname */
88 #define UTSNAME_MAX_ 257
89 struct utsname
90 {
91 char sysname[UTSNAME_MAX_];
92 char nodename[UTSNAME_MAX_];
93 char release[UTSNAME_MAX_];
94 char version[UTSNAME_MAX_];
95 char machine[UTSNAME_MAX_];
96 };
97 int uname(struct utsname *name);
98
99 /* getrusage */
100 #define RUSAGE_SELF 0
101 #define RUSAGE_CHILDREN (-1)
102 struct rusage
103 {
104 struct timeval ru_utime;
105 struct timeval ru_stime;
106 };
107 int getrusage(int who, struct rusage *usage);
108
109 /* fsync, fdatasync */
110 #include <io.h>
111 #define fsync _commit
112 #define fdatasync fsync
113
114 #ifdef __cplusplus
115 }
116 #endif
117
118 #endif