Dead code in win32.h

Started by Tom Lanealmost 10 years ago3 messageshackers
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

src/include/port/win32.h contains (starting around line 270):

/*
* Supplement to <errno.h>.
*/
#undef EAGAIN
#undef EINTR
#define EINTR WSAEINTR
#define EAGAIN WSAEWOULDBLOCK
#undef EMSGSIZE
#define EMSGSIZE WSAEMSGSIZE
#undef EAFNOSUPPORT
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#undef EWOULDBLOCK
#define EWOULDBLOCK WSAEWOULDBLOCK
#undef ECONNRESET
#define ECONNRESET WSAECONNRESET
#undef EINPROGRESS
#define EINPROGRESS WSAEINPROGRESS
#undef ENOBUFS
#define ENOBUFS WSAENOBUFS
#undef EPROTONOSUPPORT
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
#undef ECONNREFUSED
#define ECONNREFUSED WSAECONNREFUSED
#undef EBADFD
#define EBADFD WSAENOTSOCK
#undef EOPNOTSUPP
#define EOPNOTSUPP WSAEOPNOTSUPP

/*
* 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

Perhaps I'm missing something, but if so, in what way is the
"#if _MSC_VER >= 1600" stanza not totally useless given the
immediately preceding macro redefinitions? And doesn't the
comment above it apply just as much to the preceding definitions
(other than the claim that it only happens in newer MSVC versions)?

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tom Lane (#1)
Re: Dead code in win32.h

I wrote:

Perhaps I'm missing something, but if so, in what way is the
"#if _MSC_VER >= 1600" stanza not totally useless given the
immediately preceding macro redefinitions?

Some rummaging in the git history says that that stanza did something
when it was added (in 63876d3ba), but the later commit 73838b52 made
it redundant by making the earlier set of definitions unconditional.
Now it's merely confusing, so I'm going to take it out and repurpose
the comment.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Michael Paquier
michael@paquier.xyz
In reply to: Tom Lane (#2)
Re: Dead code in win32.h

On Fri, Apr 22, 2016 at 4:52 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

I wrote:

Perhaps I'm missing something, but if so, in what way is the
"#if _MSC_VER >= 1600" stanza not totally useless given the
immediately preceding macro redefinitions?

Some rummaging in the git history says that that stanza did something
when it was added (in 63876d3ba), but the later commit 73838b52 made
it redundant by making the earlier set of definitions unconditional.
Now it's merely confusing, so I'm going to take it out and repurpose
the comment.

Going through that... That's indeed dead meat (found a bug on the way actually).
--
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers