Sizeof int_fastN_t vs uint_fastN_t data types
Sad Clouds <[email protected]> Mon, 18 Nov 2024 09:00:59 +0000
| Newsgroups | gmane.os.netbsd.ports.sparc64 |
|---|---|
| Message-ID | <[email protected]> |
Hi, on NetBSD sparc64 I think /usr/include/sparc/int_mwgwtypes.h typedefs various integer sizes. My test program with sizeof() for each data type reports this: int_fast8_t = 8 bytes uint_fast8_t = 1 byte int_fast16_t = 8 bytes uint_fast16_t = 2 bytes int_fast32_t = 8 bytes uint_fast32_t = 4 bytes int_fast64_t = 8 bytes uint_fast64_t = 8 bytes The way I read this: For all signed integers the best performance can be achieved when they are exactly 8 bytes (64 bits) in size. Strangely, for all unsigned integers the best performance can be achieved when they are at their natural sizes. Is this a bug? If not, then what is the reason for such discrepancy between signed and unsigned integers? I would expect discrepancy between OSes, e.g. Linux aarch64 defines fast versions for 16 and 32 bit integers at 8 bytes, NetBSD aarch64 defines fast versions for 16 and 32 bit integers at 4 bytes. However, the same OS defining different sizes for signed and unsigned fast integers seems a bit strange. Is there really that much overhead for signed integer arithmetic on sparc64? Thanks.