Skip to content

Commit

Permalink
change func from mingw_* to win32_*
Browse files Browse the repository at this point in the history
  • Loading branch information
honglei authored and Juliusz Chroboczek committed Jan 12, 2011
1 parent 78f227b commit 53d7c69
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion io.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ int
setNonblocking(int fd, int nonblocking)
{
#ifdef WIN32 /*MINGW*/
return mingw_setnonblocking(fd, nonblocking);
return win32_setnonblocking(fd, nonblocking);
#else
int rc;
rc = fcntl(fd, F_GETFL, 0);
Expand Down
30 changes: 15 additions & 15 deletions mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static int dummy ATTRIBUTE((unused));
* (with trivial modifications) from the OpenBSD project.
*/
int
mingw_inet_aton(const char *cp, struct in_addr *addr)
win32_inet_aton(const char *cp, struct in_addr *addr)
{
register unsigned int val;
register int base, n;
Expand Down Expand Up @@ -148,14 +148,14 @@ mingw_inet_aton(const char *cp, struct in_addr *addr)
}

unsigned int
mingw_sleep(unsigned int seconds)
win32_sleep(unsigned int seconds)
{
Sleep(seconds * 1000);
return 0;
}

int
mingw_gettimeofday(struct timeval *tv, char *tz)
win32_gettimeofday(struct timeval *tv, char *tz)
{
const long long EPOCHFILETIME = (116444736000000000LL);
FILETIME ft;
Expand Down Expand Up @@ -183,7 +183,7 @@ mingw_gettimeofday(struct timeval *tv, char *tz)
return 0;
}

int mingw_poll(struct pollfd *fds, unsigned int nfds, int timo)
int win32_poll(struct pollfd *fds, unsigned int nfds, int timo)
{
struct timeval timeout, *toptr;
fd_set ifds, ofds, efds, *ip, *op;
Expand Down Expand Up @@ -248,7 +248,7 @@ int mingw_poll(struct pollfd *fds, unsigned int nfds, int timo)
return rc;
}

int mingw_close_socket(SOCKET fd) {
int win32_close_socket(SOCKET fd) {
int rc;

rc = closesocket(fd);
Expand All @@ -268,7 +268,7 @@ set_errno(int winsock_err)
}
}

int mingw_write_socket(SOCKET fd, void *buf, int n)
int win32_write_socket(SOCKET fd, void *buf, int n)
{
int rc = send(fd, buf, n, 0);
if(rc == SOCKET_ERROR) {
Expand All @@ -277,7 +277,7 @@ int mingw_write_socket(SOCKET fd, void *buf, int n)
return rc;
}

int mingw_read_socket(SOCKET fd, void *buf, int n)
int win32_read_socket(SOCKET fd, void *buf, int n)
{
int rc = recv(fd, buf, n, 0);
if(rc == SOCKET_ERROR) {
Expand All @@ -294,7 +294,7 @@ int mingw_read_socket(SOCKET fd, void *buf, int n)
* is successful, other -1.
*/
int
mingw_setnonblocking(SOCKET fd, int nonblocking)
win32_setnonblocking(SOCKET fd, int nonblocking)
{
int rc;

Expand All @@ -312,7 +312,7 @@ mingw_setnonblocking(SOCKET fd, int nonblocking)
* even if we are using winsock.
*/
SOCKET
mingw_socket(int domain, int type, int protocol)
win32_socket(int domain, int type, int protocol)
{
SOCKET fd = socket(domain, type, protocol);
if(fd == INVALID_SOCKET) {
Expand Down Expand Up @@ -342,7 +342,7 @@ set_connect_errno(int winsock_err)
* even if we are using winsock.
*/
int
mingw_connect(SOCKET fd, struct sockaddr *addr, socklen_t addr_len)
win32_connect(SOCKET fd, struct sockaddr *addr, socklen_t addr_len)
{
int rc = connect(fd, addr, addr_len);
assert(rc == 0 || rc == SOCKET_ERROR);
Expand All @@ -358,7 +358,7 @@ mingw_connect(SOCKET fd, struct sockaddr *addr, socklen_t addr_len)
* even if we are using winsock.
*/
SOCKET
mingw_accept(SOCKET fd, struct sockaddr *addr, socklen_t *addr_len)
win32_accept(SOCKET fd, struct sockaddr *addr, socklen_t *addr_len)
{
SOCKET newfd = accept(fd, addr, addr_len);
if(newfd == INVALID_SOCKET) {
Expand All @@ -374,7 +374,7 @@ mingw_accept(SOCKET fd, struct sockaddr *addr, socklen_t *addr_len)
* even if we are using winsock.
*/
int
mingw_shutdown(SOCKET fd, int mode)
win32_shutdown(SOCKET fd, int mode)
{
int rc = shutdown(fd, mode);
assert(rc == 0 || rc == SOCKET_ERROR);
Expand All @@ -390,7 +390,7 @@ mingw_shutdown(SOCKET fd, int mode)
* even if we are using winsock.
*/
int
mingw_getpeername(SOCKET fd, struct sockaddr *name, socklen_t *namelen)
win32_getpeername(SOCKET fd, struct sockaddr *name, socklen_t *namelen)
{
int rc = getpeername(fd, name, namelen);
assert(rc == 0 || rc == SOCKET_ERROR);
Expand All @@ -403,7 +403,7 @@ mingw_getpeername(SOCKET fd, struct sockaddr *name, socklen_t *namelen)
/* Stat doesn't work on directories if the name ends in a slash. */

int
mingw_stat(const char *filename, struct stat *ss)
win32_stat(const char *filename, struct stat *ss)
{
int len, rc, saved_errno;
char *noslash;
Expand All @@ -425,7 +425,7 @@ mingw_stat(const char *filename, struct stat *ss)
errno = saved_errno;
return rc;
}
#endif /* #ifdef MINGW */
#endif /* #ifdef WIN32 MINGW */

#ifndef HAVE_READV_WRITEV

Expand Down
54 changes: 27 additions & 27 deletions mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,53 +74,53 @@ struct pollfd {
short events; /* requested events */
short revents; /* returned events */
};
#define poll(x, y, z) mingw_poll(x, y, z)
#define poll(x, y, z) win32_poll(x, y, z)

/* These wrappers do nothing special except set the global errno variable if
* an error occurs (winsock doesn't do this by default). They set errno
* to unix-like values (i.e. WSAEWOULDBLOCK is mapped to EAGAIN), so code
* outside of this file "shouldn't" have to worry about winsock specific error
* handling.
*/
#define socket(x, y, z) mingw_socket(x, y, z)
#define connect(x, y, z) mingw_connect(x, y, z)
#define accept(x, y, z) mingw_accept(x, y, z)
#define shutdown(x, y) mingw_shutdown(x, y)
#define getpeername(x, y, z) mingw_getpeername(x, y, z)
#define socket(x, y, z) win32_socket(x, y, z)
#define connect(x, y, z) win32_connect(x, y, z)
#define accept(x, y, z) win32_accept(x, y, z)
#define shutdown(x, y) win32_shutdown(x, y)
#define getpeername(x, y, z) win32_getpeername(x, y, z)

/* Wrapper macros to call misc. functions mingw is missing */
#define sleep(x) mingw_sleep(x)
#define inet_aton(x, y) mingw_inet_aton(x, y)
#define gettimeofday(x, y) mingw_gettimeofday(x, y)
#define stat(x, y) mingw_stat(x, y)
#define sleep(x) win32_sleep(x)
#define inet_aton(x, y) win32_inet_aton(x, y)
#define gettimeofday(x, y) win32_gettimeofday(x, y)
#define stat(x, y) win32_stat(x, y)

#define mkdir(x, y) mkdir(x)

/* Winsock uses int instead of the usual socklen_t */
typedef int socklen_t;

/* Function prototypes for functions in mingw.c */
unsigned int mingw_sleep(unsigned int);
int mingw_inet_aton(const char *, struct in_addr *);
int mingw_gettimeofday(struct timeval *, char *);
int mingw_poll(struct pollfd *, unsigned int, int);
SOCKET mingw_socket(int, int, int);
int mingw_connect(SOCKET, struct sockaddr*, socklen_t);
SOCKET mingw_accept(SOCKET, struct sockaddr*, socklen_t *);
int mingw_shutdown(SOCKET, int);
int mingw_getpeername(SOCKET, struct sockaddr*, socklen_t *);
unsigned int win32_sleep(unsigned int);
int win32_inet_aton(const char *, struct in_addr *);
int win32_gettimeofday(struct timeval *, char *);
int win32_poll(struct pollfd *, unsigned int, int);
SOCKET win32_socket(int, int, int);
int win32_connect(SOCKET, struct sockaddr*, socklen_t);
SOCKET win32_accept(SOCKET, struct sockaddr*, socklen_t *);
int win32_shutdown(SOCKET, int);
int win32_getpeername(SOCKET, struct sockaddr*, socklen_t *);

/* Three socket specific macros */
#define READ(x, y, z) mingw_read_socket(x, y, z)
#define WRITE(x, y, z) mingw_write_socket(x, y, z)
#define CLOSE(x) mingw_close_socket(x)
#define READ(x, y, z) win32_read_socket(x, y, z)
#define WRITE(x, y, z) win32_write_socket(x, y, z)
#define CLOSE(x) win32_close_socket(x)

int mingw_read_socket(SOCKET, void *, int);
int mingw_write_socket(SOCKET, void *, int);
int mingw_close_socket(SOCKET);
int win32_read_socket(SOCKET, void *, int);
int win32_write_socket(SOCKET, void *, int);
int win32_close_socket(SOCKET);

int mingw_setnonblocking(SOCKET, int);
int mingw_stat(const char*, struct stat*);
int win32_setnonblocking(SOCKET, int);
int win32_stat(const char*, struct stat*);
#endif

#ifndef HAVE_READV_WRITEV
Expand Down

0 comments on commit 53d7c69

Please sign in to comment.