Re: win32 socket definition

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: win32 socket definition
Date: 2010-01-01 19:55:42
Message-ID: 9837222c1001011155w46efb021v5c2adf74d52b1b69@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jan 1, 2010 at 20:41, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>> The win64 port has showed that we have two sockets declared
>> incorrectly. They are supposed to be declared as SOCKET on win32, but
>> they are declared as int. See attached patch.
>
>> Given that SOCKET is actually defined as int on win32 (no warnings or
>> anything there, just on win64), I'm inclined to apply this patch just
>> to HEAD and not bother with backpatching.
>
> This looks pretty bletcherous --- plastering #ifdef WIN32 all over the
> code is exactly not the way to be fixing this sort of thing.  Maybe we
> should go the other direction of "typedef int SOCKET" on Unix then use
> SOCKET everywhere.

Yeah, we can do that - I figured since it was only two places, this
was easier...

In keeping with how we usually name things though, shouldn't it be
pg_socket, and then have it typdef'ed to two different things
depending on which platform you're on?

> BTW, isn't this porting project showing the shortsightedness of using
> WIN32 as the its-Windows platform symbol?  The case that you're
> worried about here is certainly not "WIN32".

Well, the API is actually called "Win32 for 64-bit Windows" these
days. And the vast majority of the APIs are exactly the same. With the
patch that I'm working off now, there are exactly 4 "#ifdef _WIN64"
sections, two of which are in pg_config.h.win32 (which is intended to
deal with such things). The other one is spinlock and shared memory.
Everything else is exactly the same code.

The socket thing specifically, is already wrong on 32-bit win32. It's
just that it didn't throw a warning then.

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2010-01-01 20:12:54 Re: Serializable Isolation without blocking
Previous Message Peter Eisentraut 2010-01-01 19:54:16 Re: IntArray in c.h