Re: WIN32 errno patch

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian - CVS <momjian(at)hub(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: WIN32 errno patch
Date: 2001-07-21 21:35:45
Message-ID: 200107212135.f6LLZjI08295@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers pgsql-patches

> Upon review, I don't think these patches are very good at all.
> #defining errno as WSAGetLastError() is a fairly blunt instrument,
> and it breaks all the places that do actually need to use errno,
> such as PQoidValue, lo_import, lo_export. I'm also concerned that
> PQrequestCancel may need to save/restore both errno and
> WSAGetLastError() in order to be safe for use in a signal handler.
>
> Is errno a plain variable on WIN32, or is it a macro? If the former,
> we could hack around this problem by doing
>
> #if WIN32
> #undef errno
> #endif
>
> ...
>
> #if WIN32
> #define errno WSAGetLastError()
> #endif
>
> around the routines that need to access the real errno. While ugly,
> this probably beats the alternative of ifdef'ing all the places that
> do need to access the WSA error code.

At this point, I am just happy we have this WIN32 errno thing working.
We can now have people improve upon the implementation.

I see the code in win32 you are complaining about:

/*
* assumes that errno is used for sockets only
*
*/

#undef errno
#undef EINTR
#undef EAGAIN /* doesn't apply on sockets */

#define errno WSAGetLastError()

What we really need is for someone with Win32 access to figure out which
errno tests are WSAGetLastError() calls and which are real errno calls.

My guess is that we should have two errno's. One the normal errno that
is the same on Win32 and Unix and a sockerrno that is conditionally
defined:

#ifndef WIN32
#define sockerrno errno
#else
#define sockerrno WSAGetLastError()

How does that work for folks? Can someone do the legwork?

See a later message on patches that reports problems with multibyte and
Win32 in libpq.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2001-07-21 22:09:28 Re: WIN32 errno patch
Previous Message Bruce Momjian - CVS 2001-07-21 21:27:41 pgsql/src/interfaces/jdbc/org/postgresql/test ...

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-07-21 22:03:45 Incomplete idea about views and INSERT...RETURNING
Previous Message Tom Lane 2001-07-21 20:45:54 WIN32 errno patch

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2001-07-21 22:09:28 Re: WIN32 errno patch
Previous Message Bruce Momjian 2001-07-21 21:27:58 Re: [PATCHES] Re: [PATCH] Cleanup of JDBC character encoding