mirror of git://git.musl-libc.org/musl
fix a couple issues in the inttypes.h PRI/SCN macros
most importantly, the format/scan macros for the [u]int_fast16_t and [u]int_fast32_t types were defined incorrectly assuming these types would match the native word/pointer size. this is incorrect on any 64-bit system; the "fast" types for 16- and 32-bit integers are simply int. another issue which was "only a warning" (despite being UB) is that the choice of "l" versus "ll" was incorrect for 64-bit types on 64-bit machines. while it would "work" to always use "long long" for 64-bit types, we use "long" on 64-bit machines to match what glibc does and what the ABI documents recommend. the macro definitions were probably right in very old versions of musl, but became wrong when we aligned most closely with the 'standard' ABI. checking UINTPTR_MAX is an easy way to get the system wordsize without pulling in new headers. finally, the useless __PRIPTR macro to allow the underlying type of [u]intptr_t to vary has been removed. we are using "long" on all targets, and thankfully this matches what glibc does, so I do not envision ever needing to change it. thus, the "l" has just been incorporated directly in the strings.
This commit is contained in:
parent
7dcb640da3
commit
216b706548
|
@ -24,8 +24,11 @@ uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
|
|||
|
||||
#if !defined __cplusplus || defined __STDC_FORMAT_MACROS
|
||||
|
||||
#if UINTPTR_MAX == UINT64_MAX
|
||||
#define __PRI64 "l"
|
||||
#else
|
||||
#define __PRI64 "ll"
|
||||
#define __PRIPTR "l"
|
||||
#endif
|
||||
|
||||
#define PRId8 "d"
|
||||
#define PRId16 "d"
|
||||
|
@ -124,12 +127,12 @@ uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
|
|||
#define PRIxMAX __PRI64 "x"
|
||||
#define PRIXMAX __PRI64 "X"
|
||||
|
||||
#define PRIdPTR __PRIPTR "d"
|
||||
#define PRIiPTR __PRIPTR "i"
|
||||
#define PRIoPTR __PRIPTR "o"
|
||||
#define PRIuPTR __PRIPTR "u"
|
||||
#define PRIxPTR __PRIPTR "x"
|
||||
#define PRIXPTR __PRIPTR "X"
|
||||
#define PRIdPTR "ld"
|
||||
#define PRIiPTR "li"
|
||||
#define PRIoPTR "lo"
|
||||
#define PRIuPTR "lu"
|
||||
#define PRIxPTR "lx"
|
||||
#define PRIXPTR "lX"
|
||||
|
||||
#define SCNd8 "hhd"
|
||||
#define SCNd16 "hd"
|
||||
|
@ -142,8 +145,8 @@ uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
|
|||
#define SCNdLEAST64 __PRI64 "d"
|
||||
|
||||
#define SCNdFAST8 "hhd"
|
||||
#define SCNdFAST16 __PRIPTR "d"
|
||||
#define SCNdFAST32 __PRIPTR "d"
|
||||
#define SCNdFAST16 "d"
|
||||
#define SCNdFAST32 "d"
|
||||
#define SCNdFAST64 __PRI64 "d"
|
||||
|
||||
#define SCNi8 "hhi"
|
||||
|
@ -157,8 +160,8 @@ uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
|
|||
#define SCNiLEAST64 __PRI64 "i"
|
||||
|
||||
#define SCNiFAST8 "hhi"
|
||||
#define SCNiFAST16 __PRIPTR "i"
|
||||
#define SCNiFAST32 __PRIPTR "i"
|
||||
#define SCNiFAST16 "i"
|
||||
#define SCNiFAST32 "i"
|
||||
#define SCNiFAST64 __PRI64 "i"
|
||||
|
||||
#define SCNu8 "hhu"
|
||||
|
@ -172,8 +175,8 @@ uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
|
|||
#define SCNuLEAST64 __PRI64 "u"
|
||||
|
||||
#define SCNuFAST8 "hhu"
|
||||
#define SCNuFAST16 __PRIPTR "u"
|
||||
#define SCNuFAST32 __PRIPTR "u"
|
||||
#define SCNuFAST16 "u"
|
||||
#define SCNuFAST32 "u"
|
||||
#define SCNuFAST64 __PRI64 "u"
|
||||
|
||||
#define SCNo8 "hho"
|
||||
|
@ -187,8 +190,8 @@ uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
|
|||
#define SCNoLEAST64 __PRI64 "o"
|
||||
|
||||
#define SCNoFAST8 "hho"
|
||||
#define SCNoFAST16 __PRIPTR "o"
|
||||
#define SCNoFAST32 __PRIPTR "o"
|
||||
#define SCNoFAST16 "o"
|
||||
#define SCNoFAST32 "o"
|
||||
#define SCNoFAST64 __PRI64 "o"
|
||||
|
||||
#define SCNx8 "hhx"
|
||||
|
@ -202,8 +205,8 @@ uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
|
|||
#define SCNxLEAST64 __PRI64 "x"
|
||||
|
||||
#define SCNxFAST8 "hhx"
|
||||
#define SCNxFAST16 __PRIPTR "x"
|
||||
#define SCNxFAST32 __PRIPTR "x"
|
||||
#define SCNxFAST16 "x"
|
||||
#define SCNxFAST32 "x"
|
||||
#define SCNxFAST64 __PRI64 "x"
|
||||
|
||||
#define SCNdMAX __PRI64 "d"
|
||||
|
@ -212,11 +215,11 @@ uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
|
|||
#define SCNuMAX __PRI64 "u"
|
||||
#define SCNxMAX __PRI64 "x"
|
||||
|
||||
#define SCNdPTR __PRIPTR "d"
|
||||
#define SCNiPTR __PRIPTR "i"
|
||||
#define SCNoPTR __PRIPTR "o"
|
||||
#define SCNuPTR __PRIPTR "u"
|
||||
#define SCNxPTR __PRIPTR "x"
|
||||
#define SCNdPTR "ld"
|
||||
#define SCNiPTR "li"
|
||||
#define SCNoPTR "lo"
|
||||
#define SCNuPTR "lu"
|
||||
#define SCNxPTR "lx"
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue