diff options
Diffstat (limited to '')
-rw-r--r-- | gen/bits/intconf.c | 1 | ||||
-rw-r--r-- | gen/bits/intconf.h | 1 | ||||
-rw-r--r-- | include/inttypes.h | 15 | ||||
-rw-r--r-- | include/stdint.h | 12 |
4 files changed, 25 insertions, 4 deletions
diff --git a/gen/bits/intconf.c b/gen/bits/intconf.c index b5d05be..5955d38 100644 --- a/gen/bits/intconf.c +++ b/gen/bits/intconf.c @@ -26,6 +26,7 @@ int main(void) printf("INT_BIT %zu\n", 8 * sizeof(int)); printf("LONG_BIT %zu\n", 8 * sizeof(long int)); printf("LONG_LONG_BIT %zu\n", 8 * sizeof(long long int)); + printf("PTR_BIT %zu\n", 8 * sizeof(void*)); printf("INT%zu %s\n", 8 * sizeof(char), "char"); printf("INT%zu %s\n", 8 * sizeof(short int), "short int"); diff --git a/gen/bits/intconf.h b/gen/bits/intconf.h index 84989e9..2dca3b5 100644 --- a/gen/bits/intconf.h +++ b/gen/bits/intconf.h @@ -26,6 +26,7 @@ #define __INT_BIT //(bin/gen/bits/intconf | grep ^INT_BIT | sed "s/^[^ ]* //") #define __LONG_BIT //(bin/gen/bits/intconf | grep ^LONG_BIT | sed "s/^[^ ]* //") #define __LONG_LONG_BIT //(bin/gen/bits/intconf | grep ^LONG_LONG_BIT | sed "s/^[^ ]* //") +#define __PTR_BIT //(bin/gen/bits/intconf | grep ^PTR_BIT | sed "s/^[^ ]* //") #define __INT8 //(bin/gen/bits/intconf | grep ^INT8 | sed "s/^[^ ]* //" | sed 1q) #define __INT16 //(bin/gen/bits/intconf | grep ^INT16 | sed "s/^[^ ]* //" | sed 1q) #define __INT32 //(bin/gen/bits/intconf | grep ^INT32 | sed "s/^[^ ]* //" | sed 1q) diff --git a/include/inttypes.h b/include/inttypes.h index d9e40e9..4dffb86 100644 --- a/include/inttypes.h +++ b/include/inttypes.h @@ -88,8 +88,19 @@ intmax_t imaxabs(intmax_t) #define __PRIMAX "j" #define __SCNMAX "j" -#define __PRIPTR "l" -#define __SCNPTR "l" +#if __PTR_BIT == 8 +# define __PRIPTR __PRI8 +# define __SCNPTR __SCN8 +#elif __PTR_BIT == 16 +# define __PRIPTR __PRI16 +# define __SCNPTR __SCN16 +#elif __PTR_BIT == 32 +# define __PRIPTR __PRI32 +# define __SCNPTR __SCN32 +#elif __PTR_BIT == 64 +# define __PRIPTR __PRI64 +# define __SCNPTR __SCN64 +#endif diff --git a/include/stdint.h b/include/stdint.h index 50af12a..038521f 100644 --- a/include/stdint.h +++ b/include/stdint.h @@ -342,7 +342,11 @@ /** * Maximum value of `uintptr_t`. */ -# if __LONG_BIT == 32 +# if __PTR_BIT == 8 +# define UINTPTR_MAX UINT8_MAX +# elif __PTR_BIT == 16 +# define UINTPTR_MAX UINT16_MAX +# elif __PTR_BIT == 32 # define UINTPTR_MAX UINT32_MAX # else # define UINTPTR_MAX UINT64_MAX @@ -351,7 +355,11 @@ /** * Maximum value of `intptr_t`. */ -# if __LONG_BIT == 32 +# if __PTR_BIT == 8 +# define INTPTR_MAX INT8_MAX +# elif __PTR_BIT == 16 +# define INTPTR_MAX INT16_MAX +# elif __PTR_BIT == 32 # define INTPTR_MAX INT32_MAX # else # define INTPTR_MAX INT64_MAX |