Patch for glibc2 date problems

Started by Oliver Elphickalmost 28 years ago6 messages
#1Oliver Elphick
olly@lfix.co.uk
1 attachment(s)

The Hermit Hacker wrote:

On Thu, 15 Jan 1998, Oliver Elphick wrote:

I have a potential patch for the glibc2 date problem; however I can't
test it because the snapshot won't build.

remove src/backend/parser/scan.c...that should fix your problem

Thanks, it did.

The patch for glibc2 dates is attached. With this applied, a Linux system
with libc6 (glibc2) passes all the date and time related regression tests.

Attachments:

patch.dt.ctext/plain; charset=us-ascii; name=patch.dt.cDownload
diff -cr pgsql-orig/src/backend/utils/adt/dt.c pgsql/src/backend/utils/adt/dt.c
*** pgsql-orig/src/backend/utils/adt/dt.c	Fri Jan  9 08:01:37 1998
--- pgsql/src/backend/utils/adt/dt.c	Thu Jan 15 17:13:26 1998
***************
*** 66,73 ****
--- 66,77 ----
  /* TMODULO()
   * Macro to replace modf(), which is broken on some platforms.
   */
+ #if __GLIBC__ < 2
  #define TMODULO(t,q,u) {q = ((t < 0)? ceil(t / u): floor(t / u)); \
  						if (q != 0) t -= rint(q * u);}
+ #else
+ #define TMODULO(t,q,u) {double d; (void) modf(t/u, &d); q = d; t -= (q * u);}
+ #endif
  
  static void GetEpochTime(struct tm * tm);
  
***************
*** 4163,4169 ****
  	sec = (tm->tm_sec + fsec);
  
  	sprintf(str, "%02d:%02d:", tm->tm_hour, tm->tm_min);
! 	sprintf((str + 6), ((fsec != 0) ? "%05.2f" : "%02.0f"), sec);
  
  #ifdef DATEDEBUG
  	printf("EncodeTimeOnly- time result is %s\n", str);
--- 4167,4173 ----
  	sec = (tm->tm_sec + fsec);
  
  	sprintf(str, "%02d:%02d:", tm->tm_hour, tm->tm_min);
! 	sprintf((str + 6), ((fsec != rint(fsec)) ? "%05.2f" : "%02.0f"), sec);
  
  #ifdef DATEDEBUG
  	printf("EncodeTimeOnly- time result is %s\n", str);
***************
*** 4221,4227 ****
  			{
  				sprintf(str, "%04d-%02d-%02d %02d:%02d:",
  					tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min);
! 				sprintf((str + 17), ((fsec != 0) ? "%05.2f" : "%02.0f"), sec);
  
  				if ((*tzn != NULL) && (tm->tm_isdst >= 0))
  				{
--- 4225,4231 ----
  			{
  				sprintf(str, "%04d-%02d-%02d %02d:%02d:",
  					tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min);
! 				sprintf((str + 17), ((fsec != rint(fsec)) ? "%05.2f" : "%02.0f"), sec);
  
  				if ((*tzn != NULL) && (tm->tm_isdst >= 0))
  				{
***************
*** 4314,4320 ****
  			if (tm->tm_year > 0)
  			{
  				sprintf((str + 10), " %02d:%02d", tm->tm_hour, tm->tm_min);
! 				if (fsec != 0)
  				{
  					sprintf((str + 16), ":%05.2f %04d", sec, tm->tm_year);
  					if ((*tzn != NULL) && (tm->tm_isdst >= 0))
--- 4318,4324 ----
  			if (tm->tm_year > 0)
  			{
  				sprintf((str + 10), " %02d:%02d", tm->tm_hour, tm->tm_min);
! 				if (fsec != rint(fsec))
  				{
  					sprintf((str + 16), ":%05.2f %04d", sec, tm->tm_year);
  					if ((*tzn != NULL) && (tm->tm_isdst >= 0))
diff -cr pgsql-orig/src/include/config.h.in pgsql/src/include/config.h.in
*** pgsql-orig/src/include/config.h.in	Sat Dec 20 04:26:27 1997
--- pgsql/src/include/config.h.in	Thu Jan 15 17:01:59 1998
***************
*** 62,69 ****
--- 62,71 ----
  extern int  gethostname(char *name, int namelen);
  #endif
  
+ #if __GLIBC__ < 2
  /* Set to 1 if you have int timezone */
  #undef HAVE_INT_TIMEZONE
+ #endif
  
  /* Set to 1 if you have cbrt() */
  #undef HAVE_CBRT
#2Thomas G. Lockhart
lockhart@alumni.caltech.edu
In reply to: Oliver Elphick (#1)
Re: [HACKERS] Patch for glibc2 date problems

The patch for glibc2 dates is attached. With this applied, a Linux system
with libc6 (glibc2) passes all the date and time related regression tests.

It looks as though this patch is a bit Linux-specific (or specific to some version of glibc which has only been tested on
Linux).

Can we wait until glibc2 settles down, or provide this as an add-on patch rather than merging it into the main tree? I hate
adding machine-specific code into otherwise general code...

Another possibility would be to add a new #define variable like HAVE_FUNNY_LIBRARY in config.h or in linux.h so we can
possibly use this with other ports if necessary in the future.

I'm planning on installing RH5.0 sometime soon (I have a clean disk so can fall back to RH4.2). I'm sure I'll sound more
sympathetic by then :)

- Tom

#3Oliver Elphick
olly@lfix.co.uk
In reply to: Thomas G. Lockhart (#2)
Re: [HACKERS] Patch for glibc2 date problems

"Thomas G. Lockhart" wrote:

The patch for glibc2 dates is attached. With this applied, a Linux system
with libc6 (glibc2) passes all the date and time related regression tests.

It looks as though this patch is a bit Linux-specific (or specific to some v
ersion of glibc which has only been tested on
Linux).

I don't have experience of using glibc2 on any other type of machine.

However, isn't part of the point of it to remove inter-machine differences?

Can we wait until glibc2 settles down, or provide this as an add-on patch ra
ther than merging it into the main tree? I hate
adding machine-specific code into otherwise general code...

I guess that's up to you.

Another possibility would be to add a new #define variable like HAVE_FUNNY_L
IBRARY in config.h or in linux.h so we can

Why isn't
#if __GLIBC__ < 2
enough for this?

possibly use this with other ports if necessary in the future.

I don't have experience of using glibc2 on any other type of machine.
However, isn't part of the point of it to remove inter-machine differences?

I'm planning on installing RH5.0 sometime soon (I have a clean disk so can f
all back to RH4.2). I'm sure I'll sound more
sympathetic by then :)

- Tom

My assumption was that any system using glibc2 would not have a broken
rint() function; so the general change to TMODULO would be justified.

The change of the test of `var != 0' to `var != rint(var)' should not break
anything, even if var is non-zero. It is merely saying, don't use
decimal points if there's no decimal part.

The remaining part of the patch is to force the undefinition of
HAVE_INT_TIMEZONE; again this is glibc2-specific, but I don't know
any reason to suppose it wouldn't be needed on any machine with glibc2.

It would really be helpful to have someone on a non-Linux machine test
it; but is there anyone?

--
Oliver Elphick Oliver.Elphick@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver

PGP key from public servers; key ID 32B8FAA1

Unsolicited email advertisements are not welcome; any person sending
such will be invoiced for telephone time used in downloading together
with a £25 administration charge.

#4Maarten Boekhold
maartenb@dutepp0.et.tudelft.nl
In reply to: Thomas G. Lockhart (#2)
Re: [HACKERS] Patch for glibc2 date problems

On Fri, 16 Jan 1998, Thomas G. Lockhart wrote:

The patch for glibc2 dates is attached. With this applied, a Linux system
with libc6 (glibc2) passes all the date and time related regression tests.

It looks as though this patch is a bit Linux-specific (or specific to

some version of glibc which has only been tested on Linux).

Can we wait until glibc2 settles down, or provide this as an add-on

patch rather than merging it into the main tree? I hate adding
machine-specific code into otherwise general code...

Another possibility would be to add a new #define variable like

HAVE_FUNNY_LIBRARY in config.h or in linux.h so we can possibly use this
with other ports if necessary in the future.

How about making this #define 'HAVE_GLIBC' ???

Maarten

_____________________________________________________________________________
| Maarten Boekhold, Faculty of Electrical Engineering TU Delft, NL |
| Computer Architecture and Digital Technique section |
| M.Boekhold@et.tudelft.nl |
-----------------------------------------------------------------------------

#5Bruce Momjian
maillist@candle.pha.pa.us
In reply to: Oliver Elphick (#3)
Re: [HACKERS] Patch for glibc2 date problems

"Thomas G. Lockhart" wrote:

The patch for glibc2 dates is attached. With this applied, a Linux system
with libc6 (glibc2) passes all the date and time related regression tests.

It looks as though this patch is a bit Linux-specific (or specific to some v
ersion of glibc which has only been tested on
Linux).

I don't have experience of using glibc2 on any other type of machine.

However, isn't part of the point of it to remove inter-machine differences?

Can we wait until glibc2 settles down, or provide this as an add-on patch ra
ther than merging it into the main tree? I hate
adding machine-specific code into otherwise general code...

I guess that's up to you.

Another possibility would be to add a new #define variable like HAVE_FUNNY_L
IBRARY in config.h or in linux.h so we can

Why isn't
#if __GLIBC__ < 2
enough for this?

possibly use this with other ports if necessary in the future.

I don't have experience of using glibc2 on any other type of machine.
However, isn't part of the point of it to remove inter-machine differences?

I'm planning on installing RH5.0 sometime soon (I have a clean disk so can f
all back to RH4.2). I'm sure I'll sound more
sympathetic by then :)

- Tom

My assumption was that any system using glibc2 would not have a broken
rint() function; so the general change to TMODULO would be justified.

The change of the test of `var != 0' to `var != rint(var)' should not break
anything, even if var is non-zero. It is merely saying, don't use
decimal points if there's no decimal part.

The remaining part of the patch is to force the undefinition of
HAVE_INT_TIMEZONE; again this is glibc2-specific, but I don't know
any reason to suppose it wouldn't be needed on any machine with glibc2.

It would really be helpful to have someone on a non-Linux machine test
it; but is there anyone?

Our code is complicated enough without adding patches for OS bugs. A
good place for the patch is the Linux FAQ. If it really becomes a
problem, we can put the patch as a separate file in the distribution,
and mention it in the INSTALL instructions. If you really want to get
fancy, as I did with the flex bug, you can run a test at compile time to
see if the bug exists.

--
Bruce Momjian
maillist@candle.pha.pa.us

#6Andrew Martin
martin@biochemistry.ucl.ac.uk
In reply to: Bruce Momjian (#5)
Re: [HACKERS] Patch for glibc2 date problems

The remaining part of the patch is to force the undefinition of
HAVE_INT_TIMEZONE; again this is glibc2-specific, but I don't know
any reason to suppose it wouldn't be needed on any machine with glibc2.

It would really be helpful to have someone on a non-Linux machine test
it; but is there anyone?

Our code is complicated enough without adding patches for OS bugs. A
good place for the patch is the Linux FAQ. If it really becomes a
problem, we can put the patch as a separate file in the distribution,
and mention it in the INSTALL instructions. If you really want to get
fancy, as I did with the flex bug, you can run a test at compile time to
see if the bug exists.

--
Bruce Momjian
maillist@candle.pha.pa.us

If someone can mail me an exact description of the problem with info on
the setup which shows it AND the patch info, then I'll add it to the
Linux-specific FAQ. (Much like the ld bug in Irix-6 has a patch
description in the Irix-FAQ).

Bets wishes,

Andrew

----------------------------------------------------------------------------
Dr. Andrew C.R. Martin University College London
EMAIL: (Work) martin@biochem.ucl.ac.uk (Home) andrew@stagleys.demon.co.uk
URL: http://www.biochem.ucl.ac.uk/~martin
Tel: (Work) +44(0)171 419 3890 (Home) +44(0)1372 275775