]> granicus.if.org Git - postgresql/blobdiff - src/include/port/win32.h
Remove dead code in win32.h.
[postgresql] / src / include / port / win32.h
index 7d059133124fd257e227d8894afe093ee793bcad..c9390d11247096598b2dbc36fb3c0d38348fe754 100644 (file)
@@ -71,7 +71,7 @@
  *     http://msdn.microsoft.com/en-us/library/8fskxacy(v=vs.80).aspx
  *     http://msdn.microsoft.com/en-us/library/a90k134d(v=vs.80).aspx
  */
+
 #if defined(WIN32) || defined(__CYGWIN__)
 
 #ifdef BUILDING_DLL
  *     Signal stuff
  *
  *     For WIN32, there is no wait() call so there are no wait() macros
- *     to interpret the return value of system().      Instead, system()
+ *     to interpret the return value of system().  Instead, system()
  *     return values < 0x100 are used for exit() termination, and higher
  *     values are used to indicated non-exit() termination, which is
  *     similar to a unix-style signal exit (think SIGSEGV ==
  *             NTSTATUS.H from the Windows NT DDK.
  *
  *     Some day we might want to print descriptions for the most common
- *     exceptions, rather than printing an include file name.  We could use
+ *     exceptions, rather than printing an include file name.  We could use
  *     RtlNtStatusToDosError() and pass to FormatMessage(), which can print
  *     the text of error values, but MinGW does not support
  *     RtlNtStatusToDosError().
@@ -267,61 +267,38 @@ typedef int pid_t;
 
 /*
  * Supplement to <errno.h>.
+ *
+ * We redefine network-related Berkeley error symbols as the corresponding WSA
+ * constants.  This allows elog.c to recognize them as being in the Winsock
+ * error code range and pass them off to pgwin32_socket_strerror(), since
+ * Windows' version of plain strerror() won't cope.  Note that this will break
+ * if these names are used for anything else besides Windows Sockets errors.
+ * See TranslateSocketError() when changing this list.
  */
 #undef EAGAIN
+#define EAGAIN WSAEWOULDBLOCK
 #undef EINTR
 #define EINTR WSAEINTR
-#define EAGAIN WSAEWOULDBLOCK
-#ifndef EMSGSIZE
+#undef EMSGSIZE
 #define EMSGSIZE WSAEMSGSIZE
-#endif
-#ifndef EAFNOSUPPORT
+#undef EAFNOSUPPORT
 #define EAFNOSUPPORT WSAEAFNOSUPPORT
-#endif
-#ifndef EWOULDBLOCK
+#undef EWOULDBLOCK
 #define EWOULDBLOCK WSAEWOULDBLOCK
-#endif
-#ifndef ECONNRESET
+#undef ECONNRESET
 #define ECONNRESET WSAECONNRESET
-#endif
-#ifndef EINPROGRESS
+#undef EINPROGRESS
 #define EINPROGRESS WSAEINPROGRESS
-#endif
-#ifndef ENOBUFS
+#undef ENOBUFS
 #define ENOBUFS WSAENOBUFS
-#endif
-#ifndef EPROTONOSUPPORT
+#undef EPROTONOSUPPORT
 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
-#endif
-#ifndef ECONNREFUSED
+#undef ECONNREFUSED
 #define ECONNREFUSED WSAECONNREFUSED
-#endif
-#ifndef EBADFD
+#undef EBADFD
 #define EBADFD WSAENOTSOCK
-#endif
-#ifndef EOPNOTSUPP
+#undef EOPNOTSUPP
 #define EOPNOTSUPP WSAEOPNOTSUPP
-#endif
-
-/*
- * For Microsoft Visual Studio 2010 and above we intentionally redefine
- * the regular Berkeley error constants and set them to the WSA constants.
- * Note that this will break if those constants are used for anything else
- * than Windows Sockets errors.
- */
-#if _MSC_VER >= 1600
-#pragma warning(disable:4005)
-#define EMSGSIZE WSAEMSGSIZE
-#define EAFNOSUPPORT WSAEAFNOSUPPORT
-#define EWOULDBLOCK WSAEWOULDBLOCK
-#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
-#define ECONNRESET WSAECONNRESET
-#define EINPROGRESS WSAEINPROGRESS
-#define ENOBUFS WSAENOBUFS
-#define ECONNREFUSED WSAECONNREFUSED
-#define EOPNOTSUPP WSAEOPNOTSUPP
-#pragma warning(default:4005)
-#endif
 
 /*
  * Extended locale functions with gratuitous underscore prefixes.
@@ -351,6 +328,7 @@ typedef int pid_t;
 #define isspace_l _isspace_l
 #define iswspace_l _iswspace_l
 #define strcoll_l _strcoll_l
+#define strxfrm_l _strxfrm_l
 #define wcscoll_l _wcscoll_l
 #define wcstombs_l _wcstombs_l
 #define mbstowcs_l _mbstowcs_l
@@ -373,6 +351,8 @@ void                pg_queue_signal(int signum);
 /* In backend/port/win32/socket.c */
 #ifndef FRONTEND
 #define socket(af, type, protocol) pgwin32_socket(af, type, protocol)
+#define bind(s, addr, addrlen) pgwin32_bind(s, addr, addrlen)
+#define listen(s, backlog) pgwin32_listen(s, backlog)
 #define accept(s, addr, addrlen) pgwin32_accept(s, addr, addrlen)
 #define connect(s, name, namelen) pgwin32_connect(s, name, namelen)
 #define select(n, r, w, e, timeout) pgwin32_select(n, r, w, e, timeout)
@@ -380,6 +360,8 @@ void                pg_queue_signal(int signum);
 #define send(s, buf, len, flags) pgwin32_send(s, buf, len, flags)
 
 SOCKET         pgwin32_socket(int af, int type, int protocol);
+int                    pgwin32_bind(SOCKET s, struct sockaddr * addr, int addrlen);
+int                    pgwin32_listen(SOCKET s, int backlog);
 SOCKET         pgwin32_accept(SOCKET s, struct sockaddr * addr, int *addrlen);
 int                    pgwin32_connect(SOCKET s, const struct sockaddr * name, int namelen);
 int                    pgwin32_select(int nfds, fd_set *readfs, fd_set *writefds, fd_set *exceptfds, const struct timeval * timeout);
@@ -391,9 +373,6 @@ int                 pgwin32_waitforsinglesocket(SOCKET s, int what, int timeout);
 
 extern int     pgwin32_noblock;
 
-/* in backend/port/win32/security.c */
-extern int     pgwin32_is_admin(void);
-extern int     pgwin32_is_service(void);
 #endif
 
 /* in backend/port/win32_shmem.c */
@@ -409,6 +388,10 @@ extern void _dosmaperr(unsigned long);
 extern int     pgwin32_putenv(const char *);
 extern void pgwin32_unsetenv(const char *);
 
+/* in port/win32security.c */
+extern int     pgwin32_is_service(void);
+extern int     pgwin32_is_admin(void);
+
 #define putenv(x) pgwin32_putenv(x)
 #define unsetenv(x) pgwin32_unsetenv(x)
 
@@ -437,8 +420,10 @@ typedef unsigned short mode_t;
 #define W_OK 2
 #define R_OK 4
 
+#if (_MSC_VER < 1800)
 #define isinf(x) ((_fpclass(x) == _FPCLASS_PINF) || (_fpclass(x) == _FPCLASS_NINF))
 #define isnan(x) _isnan(x)
+#endif
 
 /* Pulled from Makefile.port in mingw */
 #define DLSUFFIX ".dll"