[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mktime() hangs for dates before 1970

From: Ralf Wildenhues
Subject: Re: mktime() hangs for dates before 1970
Date: Sun, 30 Jan 2011 10:17:35 +0100
User-agent: Mutt/1.5.20 (2010-08-04)

Hello Paul,

* Paul Eggert wrote on Sun, Jan 30, 2011 at 12:51:47AM CET:
> --- a/lib/mktime.c
> +++ b/lib/mktime.c

> @@ -45,6 +63,13 @@
>  # define mktime my_mktime
>  #endif /* DEBUG */
> +/* A signed type that is at least one bit wider than int.  */
> +#if INT_MAX <= LONG_MAX / 2
> +typedef long int long_int;
> +#else
> +typedef long long int long_int;
> +#endif

That code doesn't guarantee that long_int is wider than int.  It might
be valid for all production systems, but it's not valid for the Cray
T3E, for example (I'm not sure it had a long long type, but the sizeof
of all smaller integer types was 8).  Now, I don't want to advocate
adding support for museum systems, but just to avoid surprises on new
systems, why not use this:

  #elif defined(LLONG_MAX) && INT_MAX <= LLONG_MAX / 2
  typedef long long int long_int;
  # error "need a type that is wider than int"


reply via email to

[Prev in Thread] Current Thread [Next in Thread]