On Thursday, September 23, 2021 at 2:26:11 PM UTC, Jeffrey R. Carter wrote:
On 9/23/21 12:42 PM, Kevin Chadwick wrote:
I have noticed that C time_t appears to be Long_integer in Gnat s-os_lib.ads.
Just wondering if it should be 64bit long long as OpenBSD has already moved to long long?GNAT defines
type Long_Integer is range -(2 **63) .. +(2 **63 - 1);
for Long_Integer'Size use 64;
I see, thank you.
GPS doesn't seem to jump to declaration for Long_Integer and grep hasn't turned it up,
so I will just take your word for it.
I have noticed that C time_t appears to be Long_integer in Gnat s-os_lib.ads.
Just wondering if it should be 64bit long long as OpenBSD has already moved to long long?
On 9/23/21 12:42 PM, Kevin Chadwick wrote:
I have noticed that C time_t appears to be Long_integer in Gnat s-os_lib.ads.
Just wondering if it should be 64bit long long as OpenBSD has already moved to long long?GNAT defines
type Long_Integer is range -(2 **63) .. +(2 **63 - 1);
for Long_Integer'Size use 64;
All packages in Ada has "with Standard; use Standard;" which brings Integer etc. into scope. Long_Integer should be defined in the Standard package. Under help in GPS it should be possible to find the Standard package.Thank You. I have found it.
Well, yes Long_Integer is 64-bits, but long long in cpp is 128 bits which sounds like a discrepancy to me. On OpenBSD it indicates C time_t should be changed from Long_Integer to somethinge else that is 128-bits.
All packages in Ada has "with Standard; use Standard;" which brings Integer etc. into scope. Long_Integer should be defined in the Standard package. Under help in GPS it should be possible to find the Standard package.
torsdag 23 september 2021 kl. 17:01:04 UTC+2 skrev m8il...@gmail.com:
On Thursday, September 23, 2021 at 2:26:11 PM UTC, Jeffrey R. Carter wrote: >> > On 9/23/21 12:42 PM, Kevin Chadwick wrote:
I have noticed that C time_t appears to be Long_integer in Gnat s-os_lib.ads.GNAT defines
Just wondering if it should be 64bit long long as OpenBSD has already moved to long long?
type Long_Integer is range -(2 **63) .. +(2 **63 - 1);
for Long_Integer'Size use 64;
I see, thank you.
GPS doesn't seem to jump to declaration for Long_Integer and grep hasn't turned it up,
so I will just take your word for it.
Well, yes Long_Integer is 64-bits, but long long in cpp is 128 bits
which sounds like a discrepancy to me. On OpenBSD it indicates C
time_t should be changed from Long_Integer to somethinge else that is 128-bits. All packages in Ada has "with Standard; use Standard;"
which brings Integer etc. into scope. Long_Integer should be defined
in the Standard package. Under help in GPS it should be possible to
find the Standard package.
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.
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.
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.
It's *seems* almost obvious that Ada's typesIt might turn out as an advantage if Ada programs don't to use
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.)
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.)
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 399 |
Nodes: | 16 (3 / 13) |
Uptime: | 64:52:40 |
Calls: | 8,355 |
Calls today: | 15 |
Files: | 13,159 |
Messages: | 5,893,946 |
Posted today: | 1 |