Re:Apple starting to alert users that it will end 32-bit app...
by derefr on Thursday April 12, 2018 @02:29AM
(#16818487)
I've always been confused by this: why aren't ints 64 bits on x86_64? They're 16 bits on 16-bit architectures, and 32 bits on 32-bit architectures, and that distinction was originally rather the point of using "int" as your type rather than short/long/etc., so... what happened?
[ Parent
| on HN ]
Re:Apple starting to alert users that it will end 32-bit app...
by comex on Thursday April 12, 2018 @02:42AM
(#16818533)
"Word" only means 16 bits on x86; on 32-bit ARM, for example, it means 32 bits, and the architecture manual uses "doubleword" to refer to 64 bits. [edit: the parent's post was edited but originally asked about this]
Having int be 64-bits is known as ILP64 (int, long, and pointers 64-bit); some obscure systems handled the 64-bit transition that way (Cray), but Unix went with LP64 (long and pointers 64-bit), and Windows went with LLP64 (long long and pointers 64-bit). Here's an interesting document from 1997 comparing the approaches:
http://www.unix.org/version2/whatsnew/lp64_wp.html
Basically a matter of tradeoffs around compatibility, performance, and consistency.
Re:Apple starting to alert users that it will end 32-bit app...
by api on Thursday April 12, 2018 @08:15AM
(#16820043)
Use "stdint.h" in all new code. I only use 'int' and 'long' for counters I know won't be that big, etc. I use stdint types for anything where I might care about the size.
Re:Apple starting to alert users that it will end 32-bit app...
by Someone on Thursday April 12, 2018 @07:11AM
(#16819636)
When x86_64 was introduced, other 64-bits systems had made that choice, too. It was natural to follow that.
See http://www.unix.org/version2/whatsnew/lp64_wp.html and http://www.unix.org/version2/whatsnew/login_64bit.html.
Re:Apple starting to alert users that it will end 32-bit app...
by adrianmsmith on Thursday April 12, 2018 @08:13AM
(#16820019)
A counter-example (the only one I’m aware of) is tru64 UNIX from Digital (later Compaq, later HP), now EOL. If you used “int” in C on that platform, it was 64-bit.
Re:Apple starting to alert users that it will end 32-bit app...
by TorKlingberg on Thursday April 12, 2018 @08:46AM
(#16820279)
In C, you only have char, short, int, long and long long (signed and unsigned). Other integer types like uint32_t and size_t are typedefs to those. If int is 64 bits and char is 8 bits, you have to choose if short is 16 or 32 bits, and other one won't exist at all.
long really should be 64 bits of 64-bit systems, and it is on Linux. Windows kept it at 32 bits to make porting existing code easier.