| 1 |
// ---------------------------------------------------------------------------- |
| 2 |
// Copyright (C) 2014 |
| 3 |
// David Freese, W1HKJ |
| 4 |
// |
| 5 |
// This file is part of fldigi |
| 6 |
// |
| 7 |
// fldigi 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 |
// fldigi 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 "config.h" |
| 25 |
|
| 26 |
#include <sys/types.h> |
| 27 |
#include <pthread.h> |
| 28 |
|
| 29 |
#include <winsock2.h> |
| 30 |
|
| 31 |
#undef EADDRINUSE |
| 32 |
#define EADDRINUSE WSAEADDRINUSE |
| 33 |
|
| 34 |
#undef EISCONN |
| 35 |
#define EISCONN WSAEISCONN |
| 36 |
|
| 37 |
#undef EWOULDBLOCK |
| 38 |
#define EWOULDBLOCK WSAEWOULDBLOCK |
| 39 |
|
| 40 |
#undef EINPROGRESS |
| 41 |
#define EINPROGRESS WSAEINPROGRESS |
| 42 |
|
| 43 |
#undef EALREADY |
| 44 |
#define EALREADY WSAEALREADY |
| 45 |
|
| 46 |
//====================================================================== |
| 47 |
|
| 48 |
#ifdef __cplusplus |
| 49 |
extern "C" { |
| 50 |
#endif |
| 51 |
|
| 52 |
typedef int pid_t; |
| 53 |
typedef long suseconds_t; |
| 54 |
#define hstrerror strerror |
| 55 |
|
| 56 |
#ifndef SIGUSR2 |
| 57 |
# define SIGUSR2 100 |
| 58 |
#endif |
| 59 |
|
| 60 |
extern void was_init(void); |
| 61 |
extern int was_init_state(void); |
| 62 |
extern WSADATA * was_data(void); |
| 63 |
|
| 64 |
/* |
| 65 |
* simple adaptors |
| 66 |
*/ |
| 67 |
|
| 68 |
static inline int mingw_mkdir(const char *path, int mode) |
| 69 |
{ |
| 70 |
return mkdir(path); |
| 71 |
} |
| 72 |
#define mkdir mingw_mkdir |
| 73 |
|
| 74 |
static inline int mingw_unlink(const char *pathname) |
| 75 |
{ |
| 76 |
/* read-only files cannot be removed */ |
| 77 |
chmod(pathname, 0666); |
| 78 |
return unlink(pathname); |
| 79 |
} |
| 80 |
#define unlink mingw_unlink |
| 81 |
|
| 82 |
/* |
| 83 |
* implementations of missing functions |
| 84 |
*/ |
| 85 |
|
| 86 |
unsigned int sleep (unsigned int seconds); |
| 87 |
char *mingw_getcwd(char *pointer, int len); |
| 88 |
#define getcwd mingw_getcwd |
| 89 |
char *mingw_getenv(const char *name); |
| 90 |
#define getenv mingw_getenv |
| 91 |
int mingw_rename(const char*, const char*); |
| 92 |
#define rename mingw_rename |
| 93 |
|
| 94 |
#ifndef SHUT_WR |
| 95 |
# define SHUT_WR SD_SEND |
| 96 |
#endif |
| 97 |
#ifndef SHUT_RD |
| 98 |
# define SHUT_RD SD_RECEIVE |
| 99 |
#endif |
| 100 |
#ifndef SHUT_RDWR |
| 101 |
# define SHUT_RDWR SD_BOTH |
| 102 |
#endif |
| 103 |
|
| 104 |
int nanosleep (const struct timespec *req, struct timespec *rem); |
| 105 |
int socketpair(int family, int type, int protocol, int *sv); |
| 106 |
|
| 107 |
/* uname */ |
| 108 |
#define UTSNAME_MAX_ 257 |
| 109 |
struct utsname |
| 110 |
{ |
| 111 |
char sysname[UTSNAME_MAX_]; |
| 112 |
char nodename[UTSNAME_MAX_]; |
| 113 |
char release[UTSNAME_MAX_]; |
| 114 |
char version[UTSNAME_MAX_]; |
| 115 |
char machine[UTSNAME_MAX_]; |
| 116 |
}; |
| 117 |
int uname(struct utsname *name); |
| 118 |
|
| 119 |
/* getrusage */ |
| 120 |
#define RUSAGE_SELF 0 |
| 121 |
#define RUSAGE_CHILDREN (-1) |
| 122 |
struct rusage |
| 123 |
{ |
| 124 |
struct timeval ru_utime; |
| 125 |
struct timeval ru_stime; |
| 126 |
}; |
| 127 |
int getrusage(int who, struct rusage *usage); |
| 128 |
|
| 129 |
/* fsync, fdatasync */ |
| 130 |
#include <io.h> |
| 131 |
#define fsync _commit |
| 132 |
#define fdatasync fsync |
| 133 |
|
| 134 |
#ifdef __cplusplus |
| 135 |
} |
| 136 |
#endif |
| 137 |
|
| 138 |
#endif |