Re: Cleaning up historical portability baggage

Поиск
Список
Период
Сортировка
От Thomas Munro
Тема Re: Cleaning up historical portability baggage
Дата
Msg-id CA+hUKGKZ_FjkBnjGADk+pa2g4oKDcG8=SE5V23sPTP0EELfyzQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Cleaning up historical portability baggage  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Cleaning up historical portability baggage  (Andrew Dunstan <andrew@dunslane.net>)
Список pgsql-hackers
On Sun, Jul 24, 2022 at 12:23 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> After looking through these briefly, I'm pretty concerned about
> whether this won't break our Cygwin build in significant ways.
> For example, lorikeet reports "HAVE_SETSID 1", a condition that
> you want to replace with !WIN32.  The question here is whether
> or not WIN32 is defined in a Cygwin build.  I see some places
> in our code that believe it is not, but others that believe that
> it is --- and the former ones are mostly like
>         #if defined(__CYGWIN__) || defined(WIN32)
> which means they wouldn't actually fail if they are wrong about that.

I spent a large chunk of today figuring out how to build PostgreSQL
under Cygwin/GCC on CI.  My method for answering this question was to
put the following on the end of 192 .c files that contain the pattern
/#if.*WIN32/:

+
+#if defined(WIN32) && defined(__CYGWIN__)
+#pragma message "contradiction"
+#endif

Only one of them printed that message: dirmod.c.  The reason is that
it goes out of its way to include Windows headers:

#if defined(WIN32) || defined(__CYGWIN__)
#ifndef __CYGWIN__
#include <winioctl.h>
#else
#include <windows.h>
#include <w32api/winioctl.h>
#endif
#endif

The chain <windows.h> -> <windef.h> -> <minwindef.h> leads to WIN32 here:

https://github.com/mirror/mingw-w64/blob/master/mingw-w64-headers/include/minwindef.h#L15

I'm left wondering if we should de-confuse matters by ripping out all
the checks and comments that assume that this problem is more
widespread, and then stick a big notice about it in dirmod.c, to
contain this Jekyll/Hide situation safely inside about 8 feet of
concrete.

I'll respond to your other complaints with new patches tomorrow.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Unprivileged user can induce crash by using an SUSET param in PGOPTIONS
Следующее
От: Martin Kalcher
Дата:
Сообщение: [Patch] Fix bounds check in trim_array()