From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!RKN7TKnHC01q0gdg6EhkbQ.user.46.165.242.75.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: C time_t 2038 problem s-os_lib.ads Date: Sat, 25 Sep 2021 12:23:53 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <8936f386-3fdb-43b3-b912-317906d59631n@googlegroups.com> <4431fad9-d297-4d68-8c0f-fa771c6710f6n@googlegroups.com> <874kabm5mp.fsf@nosuchdomain.example.com> <3c0272f8-4117-46a4-9051-5419d1edfdc6n@googlegroups.com> <87ilyplh4d.fsf@nosuchdomain.example.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: gioia.aioe.org; logging-data="433"; posting-host="RKN7TKnHC01q0gdg6EhkbQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin) X-Notice: Filtered by postfilter v. 0.9.2 Cancel-Lock: sha1:8PuOoNn9dbfBrjm9HQoBQ1HItak= Xref: reader02.eternal-september.org comp.lang.ada:62838 List-Id: Keith Thompson 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.