[PATCH] mingw: redefine the wrapper macro after the corresponding function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



mingw.c defines several wrapper functionsi, like mingw_unlink().
These wrappers are deployed by macros like this:
	#define unlink mingw_unlink
The function itself is preceded by #undef, leaving the wrapper out
of the game for the rest of mingw.c.

This was not probably intentional; for example, there are three
calls to open() below the definition mingw_open() that probably
have no reason to circumvent the wrapper.
OTOH, there is one call to gethostbyname() before it was undefined;
probably happy that it actually calls mingw_gethostbyname().

This patch adds back the #define after each wrapper definition.

Signed-off-by: Stepan Kasal <kasal@xxxxxx>
---
 compat/mingw.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/compat/mingw.c b/compat/mingw.c
index a0e13bc..e7193c0 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -224,6 +224,7 @@ int mingw_unlink(const char *pathname)
 	       ret = unlink(pathname);
 	return ret;
 }
+#define unlink mingw_unlink
 
 static int is_dir_empty(const char *path)
 {
@@ -279,6 +280,7 @@ int mingw_rmdir(const char *pathname)
 	       ret = rmdir(pathname);
 	return ret;
 }
+#define rmdir mingw_rmdir
 
 #undef open
 int mingw_open (const char *filename, int oflags, ...)
@@ -303,6 +305,7 @@ int mingw_open (const char *filename, int oflags, ...)
 	}
 	return fd;
 }
+#define open mingw_open
 
 static BOOL WINAPI ctrl_ignore(DWORD type)
 {
@@ -328,6 +331,7 @@ int mingw_fgetc(FILE *stream)
 	SetConsoleCtrlHandler(ctrl_ignore, FALSE);
 	return ch;
 }
+#define fgetc mingw_fgetc
 
 #undef fopen
 FILE *mingw_fopen (const char *filename, const char *otype)
@@ -336,6 +340,7 @@ FILE *mingw_fopen (const char *filename, const char *otype)
 		filename = "nul";
 	return fopen(filename, otype);
 }
+#define fopen mingw_fopen
 
 #undef freopen
 FILE *mingw_freopen (const char *filename, const char *otype, FILE *stream)
@@ -344,6 +349,7 @@ FILE *mingw_freopen (const char *filename, const char *otype, FILE *stream)
 		filename = "nul";
 	return freopen(filename, otype, stream);
 }
+#define freopen mingw_freopen
 
 #undef fflush
 int mingw_fflush(FILE *stream)
@@ -366,6 +372,7 @@ int mingw_fflush(FILE *stream)
 
 	return ret;
 }
+#define fflush mingw_fflush
 
 /*
  * The unit of FILETIME is 100-nanoseconds since January 1, 1601, UTC.
@@ -629,6 +636,7 @@ char *mingw_getcwd(char *pointer, int len)
 			pointer[i] = '/';
 	return ret;
 }
+#define getcwd mingw_getcwd
 
 /*
  * See http://msdn2.microsoft.com/en-us/library/17w5ykft(vs.71).aspx
@@ -1183,6 +1191,7 @@ char *mingw_getenv(const char *name)
 	}
 	return result;
 }
+#define getenv mingw_getenv
 
 /*
  * Note, this isn't a complete replacement for getaddrinfo. It assumes
@@ -1366,6 +1375,7 @@ int mingw_gethostname(char *name, int namelen)
     ensure_socket_initialization();
     return gethostname(name, namelen);
 }
+#define gethostname mingw_gethostname
 
 #undef gethostbyname
 struct hostent *mingw_gethostbyname(const char *host)
@@ -1373,6 +1383,7 @@ struct hostent *mingw_gethostbyname(const char *host)
 	ensure_socket_initialization();
 	return gethostbyname(host);
 }
+#define gethostbyname mingw_gethostbyname
 
 void mingw_freeaddrinfo(struct addrinfo *res)
 {
@@ -1429,6 +1440,7 @@ int mingw_connect(int sockfd, struct sockaddr *sa, size_t sz)
 	SOCKET s = (SOCKET)_get_osfhandle(sockfd);
 	return connect(s, sa, sz);
 }
+#define connect mingw_connect
 
 #undef bind
 int mingw_bind(int sockfd, struct sockaddr *sa, size_t sz)
@@ -1436,6 +1448,7 @@ int mingw_bind(int sockfd, struct sockaddr *sa, size_t sz)
 	SOCKET s = (SOCKET)_get_osfhandle(sockfd);
 	return bind(s, sa, sz);
 }
+#define bind mingw_bind
 
 #undef setsockopt
 int mingw_setsockopt(int sockfd, int lvl, int optname, void *optval, int optlen)
@@ -1443,6 +1456,7 @@ int mingw_setsockopt(int sockfd, int lvl, int optname, void *optval, int optlen)
 	SOCKET s = (SOCKET)_get_osfhandle(sockfd);
 	return setsockopt(s, lvl, optname, (const char*)optval, optlen);
 }
+#define setsockopt mingw_setsockopt
 
 #undef shutdown
 int mingw_shutdown(int sockfd, int how)
@@ -1450,6 +1464,7 @@ int mingw_shutdown(int sockfd, int how)
 	SOCKET s = (SOCKET)_get_osfhandle(sockfd);
 	return shutdown(s, how);
 }
+#define shutdown mingw_shutdown
 
 #undef listen
 int mingw_listen(int sockfd, int backlog)
@@ -1457,6 +1472,7 @@ int mingw_listen(int sockfd, int backlog)
 	SOCKET s = (SOCKET)_get_osfhandle(sockfd);
 	return listen(s, backlog);
 }
+#define listen mingw_listen
 
 #undef accept
 int mingw_accept(int sockfd1, struct sockaddr *sa, socklen_t *sz)
@@ -1475,6 +1491,7 @@ int mingw_accept(int sockfd1, struct sockaddr *sa, socklen_t *sz)
 	}
 	return sockfd2;
 }
+#define accept mingw_accept
 
 #undef rename
 int mingw_rename(const char *pold, const char *pnew)
@@ -1530,6 +1547,7 @@ repeat:
 	errno = EACCES;
 	return -1;
 }
+#define rename mingw_rename
 
 /*
  * Note that this doesn't return the actual pagesize, but
@@ -1684,6 +1702,7 @@ sig_handler_t mingw_signal(int sig, sig_handler_t handler)
 
 	return old;
 }
+#define signal mingw_signal
 
 #undef raise
 int mingw_raise(int sig)
@@ -1709,6 +1728,7 @@ int mingw_raise(int sig)
 		return raise(sig);
 	}
 }
+#define raise mingw_raise
 
 
 static const char *make_backslash_path(const char *path)
-- 
2.0.0.9635.g0be03cb

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]