1 /* 2 * Copyright 2002-2017 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _INTTYPES_H_ 6 #define _INTTYPES_H_ 7 8 9 #include <stdint.h> 10 11 12 typedef struct { 13 intmax_t quot; /* quotient */ 14 intmax_t rem; /* remainder */ 15 } imaxdiv_t; 16 17 /* fprintf() macros for signed integers */ 18 # define PRId8 "d" 19 # define PRIdLEAST8 "d" 20 # define PRIdFAST8 "d" 21 # define PRIi8 "i" 22 # define PRIiLEAST8 "i" 23 # define PRIiFAST8 "i" 24 25 # define PRId16 "d" 26 # define PRIdLEAST16 "d" 27 # define PRIdFAST16 "d" 28 # define PRIi16 "i" 29 # define PRIiLEAST16 "i" 30 # define PRIiFAST16 "i" 31 32 # define PRId32 __HAIKU_STD_PRI_PREFIX_32 "d" 33 # define PRIdLEAST32 PRId32 34 # define PRIdFAST32 PRId32 35 # define PRIi32 __HAIKU_STD_PRI_PREFIX_32 "i" 36 # define PRIiLEAST32 PRIi32 37 # define PRIiFAST32 PRIi32 38 39 # define PRId64 __HAIKU_STD_PRI_PREFIX_64 "d" 40 # define PRIdLEAST64 PRId64 41 # define PRIdFAST64 PRId64 42 # define PRIi64 __HAIKU_STD_PRI_PREFIX_64 "i" 43 # define PRIiLEAST64 PRIi64 44 # define PRIiFAST64 PRIi64 45 46 # define PRIdMAX PRId64 47 # define PRIdPTR __HAIKU_PRI_PREFIX_ADDR "d" 48 # define PRIiMAX PRIi64 49 # define PRIiPTR __HAIKU_PRI_PREFIX_ADDR "i" 50 51 /* fprintf() macros for unsigned integers */ 52 # define PRIu8 "u" 53 # define PRIuLEAST8 "u" 54 # define PRIuFAST8 "u" 55 # define PRIo8 "o" 56 # define PRIoLEAST8 "o" 57 # define PRIoFAST8 "o" 58 # define PRIx8 "x" 59 # define PRIxLEAST8 "x" 60 # define PRIxFAST8 "x" 61 # define PRIX8 "X" 62 # define PRIXLEAST8 "X" 63 # define PRIXFAST8 "X" 64 65 # define PRIu16 "u" 66 # define PRIuLEAST16 "u" 67 # define PRIuFAST16 "u" 68 # define PRIo16 "o" 69 # define PRIoLEAST16 "o" 70 # define PRIoFAST16 "o" 71 # define PRIx16 "x" 72 # define PRIxLEAST16 "x" 73 # define PRIxFAST16 "x" 74 # define PRIX16 "X" 75 # define PRIXLEAST16 "X" 76 # define PRIXFAST16 "X" 77 78 # define PRIu32 __HAIKU_STD_PRI_PREFIX_32 "u" 79 # define PRIuLEAST32 PRIu32 80 # define PRIuFAST32 PRIu32 81 # define PRIo32 __HAIKU_STD_PRI_PREFIX_32 "o" 82 # define PRIoLEAST32 PRIo32 83 # define PRIoFAST32 PRIo32 84 # define PRIx32 __HAIKU_STD_PRI_PREFIX_32 "x" 85 # define PRIxLEAST32 PRIx32 86 # define PRIxFAST32 PRIx32 87 # define PRIX32 __HAIKU_STD_PRI_PREFIX_32 "X" 88 # define PRIXLEAST32 PRIX32 89 # define PRIXFAST32 PRIX32 90 91 # define PRIu64 __HAIKU_STD_PRI_PREFIX_64 "u" 92 # define PRIuLEAST64 PRIu64 93 # define PRIuFAST64 PRIu64 94 # define PRIo64 __HAIKU_STD_PRI_PREFIX_64 "o" 95 # define PRIoLEAST64 PRIo64 96 # define PRIoFAST64 PRIo64 97 # define PRIx64 __HAIKU_STD_PRI_PREFIX_64 "x" 98 # define PRIxLEAST64 PRIx64 99 # define PRIxFAST64 PRIx64 100 # define PRIX64 __HAIKU_STD_PRI_PREFIX_64 "X" 101 # define PRIXLEAST64 PRIX64 102 # define PRIXFAST64 PRIX64 103 104 # define PRIuMAX PRIu64 105 # define PRIuPTR __HAIKU_PRI_PREFIX_ADDR "u" 106 # define PRIoMAX PRIo64 107 # define PRIoPTR __HAIKU_PRI_PREFIX_ADDR "o" 108 # define PRIxMAX PRIx64 109 # define PRIxPTR __HAIKU_PRI_PREFIX_ADDR "x" 110 # define PRIXMAX PRIX64 111 # define PRIXPTR __HAIKU_PRI_PREFIX_ADDR "X" 112 113 /* fscanf() macros for signed integers */ 114 # define SCNd8 "hhd" 115 # define SCNdLEAST8 "hhd" 116 # define SCNdFAST8 "d" 117 # define SCNi8 "hhi" 118 # define SCNiLEAST8 "hhi" 119 # define SCNiFAST8 "i" 120 121 # define SCNd16 "hd" 122 # define SCNdLEAST16 "hd" 123 # define SCNdFAST16 "d" 124 # define SCNi16 "hi" 125 # define SCNiLEAST16 "hi" 126 # define SCNiFAST16 "i" 127 128 # define SCNd32 __HAIKU_STD_PRI_PREFIX_32 "d" 129 # define SCNdLEAST32 SCNd32 130 # define SCNdFAST32 SCNd32 131 # define SCNi32 __HAIKU_STD_PRI_PREFIX_32 "i" 132 # define SCNiLEAST32 SCNi32 133 # define SCNiFAST32 SCNi32 134 135 # define SCNd64 __HAIKU_STD_PRI_PREFIX_64 "d" 136 # define SCNdLEAST64 SCNd64 137 # define SCNdFAST64 SCNd64 138 # define SCNi64 __HAIKU_STD_PRI_PREFIX_64 "i" 139 # define SCNiLEAST64 SCNi64 140 # define SCNiFAST64 SCNi64 141 142 # define SCNdMAX SCNd64 143 # define SCNdPTR __HAIKU_PRI_PREFIX_ADDR "d" 144 # define SCNiMAX SCNi64 145 # define SCNiPTR __HAIKU_PRI_PREFIX_ADDR "i" 146 147 /* fscanf() macros for unsigned integers */ 148 # define SCNu8 "hhu" 149 # define SCNuLEAST8 "hhu" 150 # define SCNuFAST8 "u" 151 # define SCNo8 "hho" 152 # define SCNoLEAST8 "hho" 153 # define SCNoFAST8 "o" 154 # define SCNx8 "hhx" 155 # define SCNxLEAST8 "hhx" 156 # define SCNxFAST8 "x" 157 158 # define SCNu16 "hu" 159 # define SCNuLEAST16 "hu" 160 # define SCNuFAST16 "u" 161 # define SCNo16 "ho" 162 # define SCNoLEAST16 "ho" 163 # define SCNoFAST16 "o" 164 # define SCNx16 "hx" 165 # define SCNxLEAST16 "hx" 166 # define SCNxFAST16 "x" 167 168 # define SCNu32 __HAIKU_STD_PRI_PREFIX_32 "u" 169 # define SCNuLEAST32 SCNu32 170 # define SCNuFAST32 SCNu32 171 # define SCNo32 __HAIKU_STD_PRI_PREFIX_32 "o" 172 # define SCNoLEAST32 SCNo32 173 # define SCNoFAST32 SCNo32 174 # define SCNx32 __HAIKU_STD_PRI_PREFIX_32 "x" 175 # define SCNxLEAST32 SCNx32 176 # define SCNxFAST32 SCNx32 177 178 # define SCNu64 __HAIKU_STD_PRI_PREFIX_64 "u" 179 # define SCNuLEAST64 SCNu64 180 # define SCNuFAST64 SCNu64 181 # define SCNo64 __HAIKU_STD_PRI_PREFIX_64 "o" 182 # define SCNoLEAST64 SCNo64 183 # define SCNoFAST64 SCNo64 184 # define SCNx64 __HAIKU_STD_PRI_PREFIX_64 "x" 185 # define SCNxLEAST64 SCNx64 186 # define SCNxFAST64 SCNx64 187 188 # define SCNuMAX SCNu64 189 # define SCNuPTR __HAIKU_PRI_PREFIX_ADDR "u" 190 # define SCNoMAX SCNo64 191 # define SCNoPTR __HAIKU_PRI_PREFIX_ADDR "o" 192 # define SCNxMAX SCNx64 193 # define SCNxPTR __HAIKU_PRI_PREFIX_ADDR "x" 194 195 196 #ifdef __cplusplus 197 extern "C" { 198 #endif 199 200 extern intmax_t imaxabs(intmax_t num); 201 extern imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom); 202 203 extern intmax_t strtoimax(const char *string, char **_end, int base); 204 extern uintmax_t strtoumax(const char *string, char **_end, int base); 205 /* extern intmax_t wcstoimax(const __wchar_t *, __wchar_t **, int); */ 206 /* extern uintmax_t wcstoumax(const __wchar_t *, __wchar_t **, int); */ 207 208 #ifdef __cplusplus 209 } 210 #endif 211 212 213 #endif /* _INTTYPES_H_ */ 214