Re: [HACKERS] Problem with ControlFileData structure being ABI depe ndent

Поиск
Список
Период
Сортировка
Искать

Re: [HACKERS] Problem with ControlFileData structure being ABI depe ndent

От:
Dave Page <dpage@postgresql.org>
Дата:
Dave Page wrote:
> Tom Lane wrote:
>> Dave Page  writes:
>>> Gregory Stark wrote:
>>>> An alternative is leaving it in the project file but putting
>>>> something like
>>>> this in c.h:
>>
>> Put it in win32.h, please.  c.h shouldn't get cluttered with
>> platform-specific kluges when there's no need for it.
>>
>> Is there a good reason not to just #define _USE_32BIT_TIME_T in win32.h?
> 
> Yeah, the fact that addons may then end up partially compiled with and
> partially without it being defined. It we just have it error as Greg
> suggested, then it will force the authors to define it themselves, and
> if they get that wrong it's their fault not ours.

Patch attached.

/D
Index: src/include/port/win32.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/port/win32.h,v
retrieving revision 1.81
diff -c -r1.81 win32.h
*** src/include/port/win32.h	24 Nov 2007 01:55:26 -0000	1.81
--- src/include/port/win32.h	10 Dec 2007 09:42:44 -0000
***************
*** 45,50 ****
--- 45,61 ----

  #define USES_WINSOCK

+ /*
+  * Ensure that anyone building an extension is using a 32 bit time_t.
+  * On Mingw/Msys, that should always be the case, but MSVC++ defaults
+  * to 64 bits. We set that for our own build in the project files
+  */
+ #ifdef WIN32
+ #ifndef _USE_32BIT_TIME_T
+ #error "Postgres uses 32 bit time_t - add #define _USE_32BIT_TIME_T on Windows
+ #endif
+ #endif
+
  /* defines for dynamic linking on Win32 platform */
  #if defined(WIN32) || defined(__CYGWIN__)

Index: src/tools/msvc/Project.pm
===================================================================
RCS file: /projects/cvsroot/pgsql/src/tools/msvc/Project.pm,v
retrieving revision 1.14
diff -c -r1.14 Project.pm
*** src/tools/msvc/Project.pm	21 Aug 2007 15:10:41 -0000	1.14
--- src/tools/msvc/Project.pm	7 Dec 2007 11:14:29 -0000
***************
*** 489,495 ****
  	ConfigurationType="$cfgtype" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="2" WholeProgramOptimization="$p->{wholeopt}">
  	
  	

Re: [HACKERS] Problem with ControlFileData structure being ABI depe ndent

От:
Magnus Hagander <magnus@hagander.net>
Дата:
On Mon, Dec 10, 2007 at 09:56:39AM +0000, Dave Page wrote:
> Dave Page wrote:
> > Tom Lane wrote:
> >> Dave Page  writes:
> >>> Gregory Stark wrote:
> >>>> An alternative is leaving it in the project file but putting
> >>>> something like
> >>>> this in c.h:
> >>
> >> Put it in win32.h, please.  c.h shouldn't get cluttered with
> >> platform-specific kluges when there's no need for it.
> >>
> >> Is there a good reason not to just #define _USE_32BIT_TIME_T in win32.h?
> > 
> > Yeah, the fact that addons may then end up partially compiled with and
> > partially without it being defined. It we just have it error as Greg
> > suggested, then it will force the authors to define it themselves, and
> > if they get that wrong it's their fault not ours.
> 
> Patch attached.

Applide with two tiny modifications - the missing quote taht you mentioned,
and changed the #ifdef to only affect MSVC and not mingw.

//Magnus
FAQ