1 //===-- Definition of macros from inttypes.h ------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 #ifndef LLVM_LIBC_MACROS_INTTYPES_MACROS_H 9 #define LLVM_LIBC_MACROS_INTTYPES_MACROS_H 10 11 // fprintf/scanf format macros. 12 #define __STDC_VERSION_INTTYPES_H__ 202311L 13 14 // clang provides these macros, so we don't need to define them. 15 #ifndef __clang__ 16 #if __UINTPTR_MAX__ == __UINT64_MAX__ 17 #define __PRI64 "l" 18 #define __PRIPTR "l" 19 #elif __UINTPTR_MAX__ == __UINT32_MAX__ 20 #define __PRI64 "ll" 21 #define __PRIPTR "" 22 #else 23 // CHERI achitecture for example, has 128-bit pointers that use special "P" 24 // format. 25 #error "Unsupported pointer format" 26 #endif 27 #define __INT8_FMTd__ "hhd" 28 #define __INT16_FMTd__ "hd" 29 #define __INT32_FMTd__ "d" 30 #define __INT64_FMTd__ __PRI64 "d" 31 #define __INT_LEAST8_FMTd__ "hhd" 32 #define __INT_LEAST16_FMTd__ "hd" 33 #define __INT_LEAST32_FMTd__ "d" 34 #define __INT_LEAST64_FMTd__ __PRI64 "d" 35 #define __INT_FAST8_FMTd__ "hhd" 36 #define __INT_FAST16_FMTd__ "hd" 37 #define __INT_FAST32_FMTd__ "d" 38 #define __INT_FAST64_FMTd__ __PRI64 "d" 39 #define __INTMAX_FMTd__ __PRI64 "d" 40 #define __INTPTR_FMTd__ __PRIPTR "d" 41 42 #define __INT8_FMTi__ "hhi" 43 #define __INT16_FMTi__ "hi" 44 #define __INT32_FMTi__ "i" 45 #define __INT64_FMTi__ __PRI64 "i" 46 #define __INT_LEAST8_FMTi__ "hhi" 47 #define __INT_LEAST16_FMTi__ "hi" 48 #define __INT_LEAST32_FMTi__ "i" 49 #define __INT_LEAST64_FMTi__ __PRI64 "i" 50 #define __INT_FAST8_FMTi__ "hhi" 51 #define __INT_FAST16_FMTi__ "hi" 52 #define __INT_FAST32_FMTi__ "i" 53 #define __INT_FAST64_FMTi__ __PRI64 "i" 54 #define __INTMAX_FMTi__ __PRI64 "i" 55 #define __INTPTR_FMTi__ __PRIPTR "i" 56 57 #define __UINT8_FMTo__ "hho" 58 #define __UINT16_FMTo__ "ho" 59 #define __UINT32_FMTo__ "o" 60 #define __UINT64_FMTo__ __PRI64 "o" 61 #define __UINT_LEAST8_FMTo__ "hho" 62 #define __UINT_LEAST16_FMTo__ "ho" 63 #define __UINT_LEAST32_FMTo__ "o" 64 #define __UINT_LEAST64_FMTo__ __PRI64 "o" 65 #define __UINT_FAST8_FMTo__ "hho" 66 #define __UINT_FAST16_FMTo__ "ho" 67 #define __UINT_FAST32_FMTo__ "o" 68 #define __UINT_FAST64_FMTo__ __PRI64 "o" 69 #define __UINTMAX_FMTo__ __PRI64 "o" 70 #define __UINTPTR_FMTo__ __PRIPTR "o" 71 72 #define __UINT8_FMTu__ "hhu" 73 #define __UINT16_FMTu__ "hu" 74 #define __UINT32_FMTu__ "u" 75 #define __UINT64_FMTu__ __PRI64 "u" 76 #define __UINT_LEAST8_FMTu__ "hhu" 77 #define __UINT_LEAST16_FMTu__ "hu" 78 #define __UINT_LEAST32_FMTu__ "u" 79 #define __UINT_LEAST64_FMTu__ __PRI64 "u" 80 #define __UINT_FAST8_FMTu__ "hhu" 81 #define __UINT_FAST16_FMTu__ "hu" 82 #define __UINT_FAST32_FMTu__ "u" 83 #define __UINT_FAST64_FMTu__ __PRI64 "u" 84 #define __UINTMAX_FMTu__ __PRI64 "u" 85 #define __UINTPTR_FMTu__ __PRIPTR "u" 86 87 #define __UINT8_FMTx__ "hhx" 88 #define __UINT16_FMTx__ "hx" 89 #define __UINT32_FMTx__ "x" 90 #define __UINT64_FMTx__ __PRI64 "x" 91 #define __UINT_LEAST8_FMTx__ "hhx" 92 #define __UINT_LEAST16_FMTx__ "hx" 93 #define __UINT_LEAST32_FMTx__ "x" 94 #define __UINT_LEAST64_FMTx__ __PRI64 "x" 95 #define __UINT_FAST8_FMTx__ "hhx" 96 #define __UINT_FAST16_FMTx__ "hx" 97 #define __UINT_FAST32_FMTx__ "x" 98 #define __UINT_FAST64_FMTx__ __PRI64 "x" 99 #define __UINTMAX_FMTx__ __PRI64 "x" 100 #define __UINTPTR_FMTx__ __PRIPTR "x" 101 102 #define __UINT8_FMTX__ "hhX" 103 #define __UINT16_FMTX__ "hX" 104 #define __UINT32_FMTX__ "X" 105 #define __UINT64_FMTX__ __PRI64 "X" 106 #define __UINT_LEAST8_FMTX__ "hhX" 107 #define __UINT_LEAST16_FMTX__ "hX" 108 #define __UINT_LEAST32_FMTX__ "X" 109 #define __UINT_LEAST64_FMTX__ __PRI64 "X" 110 #define __UINT_FAST8_FMTX__ "hhX" 111 #define __UINT_FAST16_FMTX__ "hX" 112 #define __UINT_FAST32_FMTX__ "X" 113 #define __UINT_FAST64_FMTX__ __PRI64 "X" 114 #define __UINTMAX_FMTX__ __PRI64 "X" 115 #define __UINTPTR_FMTX__ __PRIPTR "X" 116 #endif 117 118 // only recent clang provides these macros, so we need to check if they are 119 // available. 120 #ifndef __UINT8_FMTb__ 121 #define __UINT8_FMTb__ "hhb" 122 #endif 123 #ifndef __UINT16_FMTb__ 124 #define __UINT16_FMTb__ "hb" 125 #endif 126 #ifndef __UINT32_FMTb__ 127 #define __UINT32_FMTb__ "b" 128 #endif 129 #ifndef __UINT64_FMTb__ 130 #define __UINT64_FMTb__ __PRI64 "b" 131 #endif 132 #ifndef __UINT_LEAST8_FMTb__ 133 #define __UINT_LEAST8_FMTb__ "hhb" 134 #endif 135 #ifndef __UINT_LEAST16_FMTb__ 136 #define __UINT_LEAST16_FMTb__ "hb" 137 #endif 138 #ifndef __UINT_LEAST32_FMTb__ 139 #define __UINT_LEAST32_FMTb__ "b" 140 #endif 141 #ifndef __UINT_LEAST64_FMTb__ 142 #define __UINT_LEAST64_FMTb__ __PRI64 "b" 143 #endif 144 #ifndef __UINT_FAST8_FMTb__ 145 #define __UINT_FAST8_FMTb__ "hhb" 146 #endif 147 #ifndef __UINT_FAST16_FMTb__ 148 #define __UINT_FAST16_FMTb__ "hb" 149 #endif 150 #ifndef __UINT_FAST32_FMTb__ 151 #define __UINT_FAST32_FMTb__ "b" 152 #endif 153 #ifndef __UINT_FAST64_FMTb__ 154 #define __UINT_FAST64_FMTb__ __PRI64 "b" 155 #endif 156 #ifndef __UINTMAX_FMTb__ 157 #define __UINTMAX_FMTb__ __PRI64 "b" 158 #endif 159 #ifndef __UINTPTR_FMTb__ 160 #define __UINTPTR_FMTb__ __PRIPTR "b" 161 #endif 162 163 #ifndef __UINT8_FMTB__ 164 #define __UINT8_FMTB__ "hhB" 165 #endif 166 #ifndef __UINT16_FMTB__ 167 #define __UINT16_FMTB__ "hB" 168 #endif 169 #ifndef __UINT32_FMTB__ 170 #define __UINT32_FMTB__ "B" 171 #endif 172 #ifndef __UINT64_FMTB__ 173 #define __UINT64_FMTB__ __PRI64 "B" 174 #endif 175 #ifndef __UINT_LEAST8_FMTB__ 176 #define __UINT_LEAST8_FMTB__ "hhB" 177 #endif 178 #ifndef __UINT_LEAST16_FMTB__ 179 #define __UINT_LEAST16_FMTB__ "hB" 180 #endif 181 #ifndef __UINT_LEAST32_FMTB__ 182 #define __UINT_LEAST32_FMTB__ "B" 183 #endif 184 #ifndef __UINT_LEAST64_FMTB__ 185 #define __UINT_LEAST64_FMTB__ __PRI64 "B" 186 #endif 187 #ifndef __UINT_FAST8_FMTB__ 188 #define __UINT_FAST8_FMTB__ "hhB" 189 #endif 190 #ifndef __UINT_FAST16_FMTB__ 191 #define __UINT_FAST16_FMTB__ "hB" 192 #endif 193 #ifndef __UINT_FAST32_FMTB__ 194 #define __UINT_FAST32_FMTB__ "B" 195 #endif 196 #ifndef __UINT_FAST64_FMTB__ 197 #define __UINT_FAST64_FMTB__ __PRI64 "B" 198 #endif 199 #ifndef __UINTMAX_FMTB__ 200 #define __UINTMAX_FMTB__ __PRI64 "B" 201 #endif 202 #ifndef __UINTPTR_FMTB__ 203 #define __UINTPTR_FMTB__ __PRIPTR "B" 204 #endif 205 206 // The fprintf() macros for signed integers. 207 #define PRId8 __INT8_FMTd__ 208 #define PRId16 __INT16_FMTd__ 209 #define PRId32 __INT32_FMTd__ 210 #define PRId64 __INT64_FMTd__ 211 #define PRIdLEAST8 __INT_LEAST8_FMTd__ 212 #define PRIdLEAST16 __INT_LEAST16_FMTd__ 213 #define PRIdLEAST32 __INT_LEAST32_FMTd__ 214 #define PRIdLEAST64 __INT_LEAST64_FMTd__ 215 #define PRIdFAST8 __INT_FAST8_FMTd__ 216 #define PRIdFAST16 __INT_FAST16_FMTd__ 217 #define PRIdFAST32 __INT_FAST32_FMTd__ 218 #define PRIdFAST64 __INT_FAST64_FMTd__ 219 #define PRIdMAX __INTMAX_FMTd__ 220 #define PRIdPTR __INTPTR_FMTd__ 221 222 #define PRIi8 __INT8_FMTi__ 223 #define PRIi16 __INT16_FMTi__ 224 #define PRIi32 __INT32_FMTi__ 225 #define PRIi64 __INT64_FMTi__ 226 #define PRIiLEAST8 __INT_LEAST8_FMTi__ 227 #define PRIiLEAST16 __INT_LEAST16_FMTi__ 228 #define PRIiLEAST32 __INT_LEAST32_FMTi__ 229 #define PRIiLEAST64 __INT_LEAST64_FMTi__ 230 #define PRIiFAST8 __INT_FAST8_FMTi__ 231 #define PRIiFAST16 __INT_FAST16_FMTi__ 232 #define PRIiFAST32 __INT_FAST32_FMTi__ 233 #define PRIiFAST64 __INT_FAST64_FMTi__ 234 #define PRIiMAX __INTMAX_FMTi__ 235 #define PRIiPTR __INTPTR_FMTi__ 236 237 // The fprintf() macros for unsigned integers. 238 #define PRIo8 __UINT8_FMTo__ 239 #define PRIo16 __UINT16_FMTo__ 240 #define PRIo32 __UINT32_FMTo__ 241 #define PRIo64 __UINT64_FMTo__ 242 #define PRIoLEAST8 __UINT_LEAST8_FMTo__ 243 #define PRIoLEAST16 __UINT_LEAST16_FMTo__ 244 #define PRIoLEAST32 __UINT_LEAST32_FMTo__ 245 #define PRIoLEAST64 __UINT_LEAST64_FMTo__ 246 #define PRIoFAST8 __UINT_FAST8_FMTo__ 247 #define PRIoFAST16 __UINT_FAST16_FMTo__ 248 #define PRIoFAST32 __UINT_FAST32_FMTo__ 249 #define PRIoFAST64 __UINT_FAST64_FMTo__ 250 #define PRIoMAX __UINTMAX_FMTo__ 251 #define PRIoPTR __UINTPTR_FMTo__ 252 253 #define PRIu8 __UINT8_FMTu__ 254 #define PRIu16 __UINT16_FMTu__ 255 #define PRIu32 __UINT32_FMTu__ 256 #define PRIu64 __UINT64_FMTu__ 257 #define PRIuLEAST8 __UINT_LEAST8_FMTu__ 258 #define PRIuLEAST16 __UINT_LEAST16_FMTu__ 259 #define PRIuLEAST32 __UINT_LEAST32_FMTu__ 260 #define PRIuLEAST64 __UINT_LEAST64_FMTu__ 261 #define PRIuFAST8 __UINT_FAST8_FMTu__ 262 #define PRIuFAST16 __UINT_FAST16_FMTu__ 263 #define PRIuFAST32 __UINT_FAST32_FMTu__ 264 #define PRIuFAST64 __UINT_FAST64_FMTu__ 265 #define PRIuMAX __UINTMAX_FMTu__ 266 #define PRIuPTR __UINTPTR_FMTu__ 267 268 #define PRIx8 __UINT8_FMTx__ 269 #define PRIx16 __UINT16_FMTx__ 270 #define PRIx32 __UINT32_FMTx__ 271 #define PRIx64 __UINT64_FMTx__ 272 #define PRIxLEAST8 __UINT_LEAST8_FMTx__ 273 #define PRIxLEAST16 __UINT_LEAST16_FMTx__ 274 #define PRIxLEAST32 __UINT_LEAST32_FMTx__ 275 #define PRIxLEAST64 __UINT_LEAST64_FMTx__ 276 #define PRIxFAST8 __UINT_FAST8_FMTx__ 277 #define PRIxFAST16 __UINT_FAST16_FMTx__ 278 #define PRIxFAST32 __UINT_FAST32_FMTx__ 279 #define PRIxFAST64 __UINT_FAST64_FMTx__ 280 #define PRIxMAX __UINTMAX_FMTx__ 281 #define PRIxPTR __UINTPTR_FMTx__ 282 283 #define PRIX8 __UINT8_FMTX__ 284 #define PRIX16 __UINT16_FMTX__ 285 #define PRIX32 __UINT32_FMTX__ 286 #define PRIX64 __UINT64_FMTX__ 287 #define PRIXLEAST8 __UINT_LEAST8_FMTX__ 288 #define PRIXLEAST16 __UINT_LEAST16_FMTX__ 289 #define PRIXLEAST32 __UINT_LEAST32_FMTX__ 290 #define PRIXLEAST64 __UINT_LEAST64_FMTX__ 291 #define PRIXFAST8 __UINT_FAST8_FMTX__ 292 #define PRIXFAST16 __UINT_FAST16_FMTX__ 293 #define PRIXFAST32 __UINT_FAST32_FMTX__ 294 #define PRIXFAST64 __UINT_FAST64_FMTX__ 295 #define PRIXMAX __UINTMAX_FMTX__ 296 #define PRIXPTR __UINTPTR_FMTX__ 297 298 #define PRIb8 __UINT8_FMTb__ 299 #define PRIb16 __UINT16_FMTb__ 300 #define PRIb32 __UINT32_FMTb__ 301 #define PRIb64 __UINT64_FMTb__ 302 #define PRIbLEAST8 __UINT_LEAST8_FMTb__ 303 #define PRIbLEAST16 __UINT_LEAST16_FMTb__ 304 #define PRIbLEAST32 __UINT_LEAST32_FMTb__ 305 #define PRIbLEAST64 __UINT_LEAST64_FMTb__ 306 #define PRIbFAST8 __UINT_FAST8_FMTb__ 307 #define PRIbFAST16 __UINT_FAST16_FMTb__ 308 #define PRIbFAST32 __UINT_FAST32_FMTb__ 309 #define PRIbFAST64 __UINT_FAST64_FMTb__ 310 #define PRIbMAX __UINTMAX_FMTb__ 311 #define PRIbPTR __UINTPTR_FMTb__ 312 313 #define PRIB8 __UINT8_FMTB__ 314 #define PRIB16 __UINT16_FMTB__ 315 #define PRIB32 __UINT32_FMTB__ 316 #define PRIB64 __UINT64_FMTB__ 317 #define PRIBLEAST8 __UINT_LEAST8_FMTB__ 318 #define PRIBLEAST16 __UINT_LEAST16_FMTB__ 319 #define PRIBLEAST32 __UINT_LEAST32_FMTB__ 320 #define PRIBLEAST64 __UINT_LEAST64_FMTB__ 321 #define PRIBFAST8 __UINT_FAST8_FMTB__ 322 #define PRIBFAST16 __UINT_FAST16_FMTB__ 323 #define PRIBFAST32 __UINT_FAST32_FMTB__ 324 #define PRIBFAST64 __UINT_FAST64_FMTB__ 325 #define PRIBMAX __UINTMAX_FMTB__ 326 #define PRIBPTR __UINTPTR_FMTB__ 327 328 // The fscanf() macros for signed integers. 329 #define SCNd8 __INT8_FMTd__ 330 #define SCNd16 __INT16_FMTd__ 331 #define SCNd32 __INT32_FMTd__ 332 #define SCNd64 __INT64_FMTd__ 333 #define SCNdLEAST8 __INT_LEAST8_FMTd__ 334 #define SCNdLEAST16 __INT_LEAST16_FMTd__ 335 #define SCNdLEAST32 __INT_LEAST32_FMTd__ 336 #define SCNdLEAST64 __INT_LEAST64_FMTd__ 337 #define SCNdFAST8 __INT_FAST8_FMTd__ 338 #define SCNdFAST16 __INT_FAST16_FMTd__ 339 #define SCNdFAST32 __INT_FAST32_FMTd__ 340 #define SCNdFAST64 __INT_FAST64_FMTd__ 341 #define SCNdMAX __INTMAX_FMTd__ 342 #define SCNdPTR __INTPTR_FMTd__ 343 344 #define SCNi8 __INT8_FMTi__ 345 #define SCNi16 __INT16_FMTi__ 346 #define SCNi32 __INT32_FMTi__ 347 #define SCNi64 __INT64_FMTi__ 348 #define SCNiLEAST8 __INT_LEAST8_FMTi__ 349 #define SCNiLEAST16 __INT_LEAST16_FMTi__ 350 #define SCNiLEAST32 __INT_LEAST32_FMTi__ 351 #define SCNiLEAST64 __INT_LEAST64_FMTi__ 352 #define SCNiFAST8 __INT_FAST8_FMTi__ 353 #define SCNiFAST16 __INT_FAST16_FMTi__ 354 #define SCNiFAST32 __INT_FAST32_FMTi__ 355 #define SCNiFAST64 __INT_FAST64_FMTi__ 356 #define SCNiMAX __INTMAX_FMTi__ 357 #define SCNiPTR __INTPTR_FMTi__ 358 359 // The fscanf() macros for unsigned integers. 360 #define SCNo8 __UINT8_FMTo__ 361 #define SCNo16 __UINT16_FMTo__ 362 #define SCNo32 __UINT32_FMTo__ 363 #define SCNo64 __UINT64_FMTo__ 364 #define SCNoLEAST8 __UINT_LEAST8_FMTo__ 365 #define SCNoLEAST16 __UINT_LEAST16_FMTo__ 366 #define SCNoLEAST32 __UINT_LEAST32_FMTo__ 367 #define SCNoLEAST64 __UINT_LEAST64_FMTo__ 368 #define SCNoFAST8 __UINT_FAST8_FMTo__ 369 #define SCNoFAST16 __UINT_FAST16_FMTo__ 370 #define SCNoFAST32 __UINT_FAST32_FMTo__ 371 #define SCNoFAST64 __UINT_FAST64_FMTo__ 372 #define SCNoMAX __UINTMAX_FMTo__ 373 #define SCNoPTR __UINTPTR_FMTo__ 374 375 #define SCNu8 __UINT8_FMTu__ 376 #define SCNu16 __UINT16_FMTu__ 377 #define SCNu32 __UINT32_FMTu__ 378 #define SCNu64 __UINT64_FMTu__ 379 #define SCNuLEAST8 __UINT_LEAST8_FMTu__ 380 #define SCNuLEAST16 __UINT_LEAST16_FMTu__ 381 #define SCNuLEAST32 __UINT_LEAST32_FMTu__ 382 #define SCNuLEAST64 __UINT_LEAST64_FMTu__ 383 #define SCNuFAST8 __UINT_FAST8_FMTu__ 384 #define SCNuFAST16 __UINT_FAST16_FMTu__ 385 #define SCNuFAST32 __UINT_FAST32_FMTu__ 386 #define SCNuFAST64 __UINT_FAST64_FMTu__ 387 #define SCNuMAX __UINTMAX_FMTu__ 388 #define SCNuPTR __UINTPTR_FMTu__ 389 390 #define SCNx8 __UINT8_FMTx__ 391 #define SCNx16 __UINT16_FMTx__ 392 #define SCNx32 __UINT32_FMTx__ 393 #define SCNx64 __UINT64_FMTx__ 394 #define SCNxLEAST8 __UINT_LEAST8_FMTx__ 395 #define SCNxLEAST16 __UINT_LEAST16_FMTx__ 396 #define SCNxLEAST32 __UINT_LEAST32_FMTx__ 397 #define SCNxLEAST64 __UINT_LEAST64_FMTx__ 398 #define SCNxFAST8 __UINT_FAST8_FMTx__ 399 #define SCNxFAST16 __UINT_FAST16_FMTx__ 400 #define SCNxFAST32 __UINT_FAST32_FMTx__ 401 #define SCNxFAST64 __UINT_FAST64_FMTx__ 402 #define SCNxMAX __UINTMAX_FMTx__ 403 #define SCNxPTR __UINTPTR_FMTx__ 404 405 #define SCNb8 __UINT8_FMTb__ 406 #define SCNb16 __UINT16_FMTb__ 407 #define SCNb32 __UINT32_FMTb__ 408 #define SCNb64 __UINT64_FMTb__ 409 #define SCNbLEAST8 __UINT_LEAST8_FMTb__ 410 #define SCNbLEAST16 __UINT_LEAST16_FMTb__ 411 #define SCNbLEAST32 __UINT_LEAST32_FMTb__ 412 #define SCNbLEAST64 __UINT_LEAST64_FMTb__ 413 #define SCNbFAST8 __UINT_FAST8_FMTb__ 414 #define SCNbFAST16 __UINT_FAST16_FMTb__ 415 #define SCNbFAST32 __UINT_FAST32_FMTb__ 416 #define SCNbFAST64 __UINT_FAST64_FMTb__ 417 #define SCNbMAX __UINTMAX_FMTb__ 418 #define SCNbPTR __UINTPTR_FMTb__ 419 420 #endif // LLVM_LIBC_MACROS_INTTYPES_MACROS_H 421