Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ada > #49617

Re: C time_t 2038 problem s-os_lib.ads

From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.ada
Subject Re: C time_t 2038 problem s-os_lib.ads
Date 2021-09-24 15:54 -0700
Organization None to speak of
Message-ID <87ilyplh4d.fsf@nosuchdomain.example.com> (permalink)
References (1 earlier) <sii2q2$fcn$1@dont-email.me> <4431fad9-d297-4d68-8c0f-fa771c6710f6n@googlegroups.com> <cd4a94de-e8b9-4194-8d80-24a009a558ban@googlegroups.com> <874kabm5mp.fsf@nosuchdomain.example.com> <3c0272f8-4117-46a4-9051-5419d1edfdc6n@googlegroups.com>

Show all headers | View raw


Joakim Strandberg <joakimds@kth.se> writes:
>> In C and C++, int is required to be at least 16 bits (POSIX requires 
>> 32), long is at least 32 bits, and long long is at least 64 bits. On 
>> most 64-bit Linux-based systems, int is 32 bits, and long and long long 
>> are both 64 bits. On 64-bit MS Windows, int and long are both 32 bits, 
>> and long long is 64 bits. time_t is 64 bits on almost all 64-bit 
>> systems. I've never seen a 128-bit time_t; 64 bits with 1-second 
>> resolution is good for several hundred billion years. 
>
> Thanks for the summary of different types of integers on different
> platforms Keith. When I wrote above I had simply done a quick Google
> search and found
> https://www.tutorialspoint.com/what-is-long-long-in-c-cplusplus where
> it said "On Linux environment the long takes 64-bit (8-bytes) of
> space, and the long long takes 128-bits (16-bytes) of space." I have
> never seen 128-bit integers either but have seen on the development
> log on AdaCore's website that support for 128-bit integers have been
> added to the Interfaces package (Interfaces.Integer_128 and
> Interfaces.Unsigned_128). I believe they are part of the new Ada2022
> standard.

That web page is simply wrong about long long being 128 bits.  It
certainly can be (the C standard only says that it's at least 64 bits),
but it's exactly 64 bit on every implementation I've seen or heard of.

I'm not shocked that something on tutorialspoint.com is wrong.

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.)

Some C and C++ compilers support 128-bit integers on 64-bit systems.
gcc supports "__int128" and "unsigned __int128", but they don't quite
meet all the C requirements for integer types; for example, there are no
literals of those types.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Back to comp.lang.ada | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

C time_t 2038 problem s-os_lib.ads Kevin Chadwick <m8il1ists@gmail.com> - 2021-09-23 03:42 -0700
  Re: C time_t 2038 problem s-os_lib.ads "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> - 2021-09-23 16:26 +0200
    Re: C time_t 2038 problem s-os_lib.ads Kevin Chadwick <m8il1ists@gmail.com> - 2021-09-23 08:01 -0700
      Re: C time_t 2038 problem s-os_lib.ads Joakim Strandberg <joakimds@kth.se> - 2021-09-23 08:08 -0700
        Re: C time_t 2038 problem s-os_lib.ads Kevin Chadwick <m8il1ists@gmail.com> - 2021-09-23 08:39 -0700
          Re: C time_t 2038 problem s-os_lib.ads Kevin Chadwick <m8il1ists@gmail.com> - 2021-09-23 08:57 -0700
        Re: C time_t 2038 problem s-os_lib.ads Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-09-23 12:52 -0700
          Re: C time_t 2038 problem s-os_lib.ads Joakim Strandberg <joakimds@kth.se> - 2021-09-24 02:32 -0700
            Re: C time_t 2038 problem s-os_lib.ads Niklas Holsti <niklas.holsti@tidorum.invalid> - 2021-09-24 12:44 +0300
            Re: C time_t 2038 problem s-os_lib.ads Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-09-24 15:54 -0700
              Re: C time_t 2038 problem s-os_lib.ads "G.B." <bauhaus@notmyhomepage.invalid> - 2021-09-25 12:22 +0200
              Re: C time_t 2038 problem s-os_lib.ads Simon Wright <simon@pushface.org> - 2021-09-25 12:23 +0100

csiph-web