comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: C time_t 2038 problem s-os_lib.ads
Date: Sat, 25 Sep 2021 12:23:53 +0100	[thread overview]
Message-ID: <ly4ka8x5iu.fsf@pushface.org> (raw)
In-Reply-To: 87ilyplh4d.fsf@nosuchdomain.example.com

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> There are several common data models in the C and C++ world:
>
> Name       ILP32  LP64  IL32P64
> ====       =====  ====  =======
> char       8      8     8
> short      16     16    16
> int        32     32    32
> long       32     64    32
> long long  64     64    64
> pointer    32     64    64
>
> 32-bit systems (which are becoming rarer for non-embedded systems)
> typically use ILP32, and 64-bit Linux/Unix systems typically use LP64.
> 64-bit Windows uses IL32P64 (and hardly anything else does).
>
> It's *seems* almost obvious that Ada's types
>     Character
>     Short_Integer
>     Integer
>     Long_Integer
>     Long_Long_Integer
> should correspond to the similarly named C types, but it's not required.
> (I don't know whether GNAT does so consistently or not.)

Package Standard in FSF GCC 11.2.0 on macOS (which you can see by
compiling something with -gnatS) has

   type Integer is range -(2 **31) .. +(2 **31 - 1);
   for Integer'Size use 32;

   subtype Natural  is Integer range 0 .. Integer'Last;
   subtype Positive is Integer range 1 .. Integer'Last;

   type Short_Short_Integer is range -(2 **7) .. +(2 **7 - 1);
   for Short_Short_Integer'Size use 8;

   type Short_Integer is range -(2 **15) .. +(2 **15 - 1);
   for Short_Integer'Size use 16;

   type Long_Integer is range -(2 **63) .. +(2 **63 - 1);
   for Long_Integer'Size use 64;

   type Long_Long_Integer is range -(2 **63) .. +(2 **63 - 1);
   for Long_Long_Integer'Size use 64;

   type Long_Long_Long_Integer is range -(2 **127) .. +(2 **127 - 1);
   for Long_Long_Long_Integer'Size use 128;

I didn't know about the last, which is new in FSF GCC 11/GNAT CE 2021
... I could build my Analytical Engine simulator with 40 digit wheels
(i.e. capable of 40 decimal digits) instead of 50 using
Long_Long_Long_Integer instead of GNATColl.GMP.Integer.

      parent reply	other threads:[~2021-09-25 11:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23 10:42 C time_t 2038 problem s-os_lib.ads Kevin Chadwick
2021-09-23 14:26 ` Jeffrey R. Carter
2021-09-23 15:01   ` Kevin Chadwick
2021-09-23 15:08     ` Joakim Strandberg
2021-09-23 15:39       ` Kevin Chadwick
2021-09-23 15:57         ` Kevin Chadwick
2021-09-23 19:52       ` Keith Thompson
2021-09-24  9:32         ` Joakim Strandberg
2021-09-24  9:44           ` Niklas Holsti
2021-09-24 22:54           ` Keith Thompson
2021-09-25 10:22             ` G.B.
2021-09-25 11:23             ` Simon Wright [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox