This is a maintenance fork
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

395 lines
17 KiB

1 year ago
  1. #ifndef COSMOPOLITAN_LIBC_INTTYPES_H_
  2. #define COSMOPOLITAN_LIBC_INTTYPES_H_
  3. typedef __INT_LEAST8_TYPE__ int_least8_t;
  4. typedef __UINT_LEAST8_TYPE__ uint_least8_t;
  5. typedef __INT_LEAST16_TYPE__ int_least16_t;
  6. typedef __UINT_LEAST16_TYPE__ uint_least16_t;
  7. typedef __INT_LEAST32_TYPE__ int_least32_t;
  8. typedef __UINT_LEAST32_TYPE__ uint_least32_t;
  9. typedef __INT_LEAST64_TYPE__ int_least64_t;
  10. typedef __UINT_LEAST64_TYPE__ uint_least64_t;
  11. /*───────────────────────────────────────────────────────────────────────────│─╗
  12. cosmopolitan § dismal format notation
  13. */
  14. #define __PRI8 "hh"
  15. #if __SIZEOF_INT__ == 2
  16. #define __PRI16 ""
  17. #elif __SIZEOF_SHORT__ == 2
  18. #define __PRI16 "h"
  19. #elif __SIZEOF_LONG__ == 2
  20. #define __PRI16 "l"
  21. #endif
  22. #if __SIZEOF_INT__ == 4
  23. #define __PRI32 ""
  24. #elif __SIZEOF_LONG__ == 4
  25. #define __PRI32 "l"
  26. #elif __SIZEOF_LONG_LONG__ == 4
  27. #define __PRI32 "ll"
  28. #endif
  29. #if __SIZEOF_INT__ == 8
  30. #define __PRI64 ""
  31. #elif __SIZEOF_LONG__ == 8
  32. #define __PRI64 "l"
  33. #elif __SIZEOF_LONG_LONG__ == 8
  34. #define __PRI64 "ll"
  35. #endif
  36. #if __SIZEOF_INT__ == 16
  37. #define __PRI128 ""
  38. #elif __SIZEOF_LONG__ == 16
  39. #define __PRI128 "l"
  40. #elif __SIZEOF_LONG_LONG__ == 16
  41. #define __PRI128 "ll"
  42. #elif __SIZEOF_INTMAX__ == 16
  43. #define __PRI128 "j"
  44. #endif
  45. #if __SIZEOF_POINTER__ == __SIZEOF_INT__
  46. #define __PRIPTR ""
  47. #elif __SIZEOF_POINTER__ == __SIZEOF_LONG__
  48. #define __PRIPTR "l"
  49. #elif __SIZEOF_POINTER__ == __SIZEOF_LONG_LONG__
  50. #define __PRIPTR "ll"
  51. #endif
  52. /*───────────────────────────────────────────────────────────────────────────│─╗
  53. cosmopolitan § dismal format notation » printf » decimal
  54. */
  55. #define PRId8 __PRI8 "d"
  56. #define PRId16 __PRI16 "d"
  57. #define PRId32 __PRI32 "d"
  58. #define PRId64 __PRI64 "d"
  59. #define PRId128 __PRI128 "d"
  60. #define PRIdLEAST8 __PRI8 "d"
  61. #define PRIdLEAST16 __PRI16 "d"
  62. #define PRIdLEAST32 __PRI32 "d"
  63. #define PRIdLEAST64 __PRI64 "d"
  64. #define PRIdLEAST128 __PRI128 "d"
  65. #define PRIdFAST8 __PRI8 "d"
  66. #define PRIdFAST16 __PRI16 "d"
  67. #define PRIdFAST32 __PRI32 "d"
  68. #define PRIdFAST64 __PRI64 "d"
  69. #define PRIdFAST128 __PRI128 "d"
  70. /*───────────────────────────────────────────────────────────────────────────│─╗
  71. cosmopolitan § dismal format notation » printf » unsigned decimal
  72. */
  73. #define PRIu8 __PRI8 "u"
  74. #define PRIu16 __PRI16 "u"
  75. #define PRIu32 __PRI32 "u"
  76. #define PRIu64 __PRI64 "u"
  77. #define PRIu128 __PRI128 "u"
  78. #define PRIuLEAST8 __PRI8 "u"
  79. #define PRIuLEAST16 __PRI16 "u"
  80. #define PRIuLEAST32 __PRI32 "u"
  81. #define PRIuLEAST64 __PRI64 "u"
  82. #define PRIuLEAST128 __PRI128 "u"
  83. #define PRIuFAST8 __PRI8 "u"
  84. #define PRIuFAST16 __PRI16 "u"
  85. #define PRIuFAST32 __PRI32 "u"
  86. #define PRIuFAST64 __PRI64 "u"
  87. #define PRIuFAST128 __PRI128 "u"
  88. /*───────────────────────────────────────────────────────────────────────────│─╗
  89. cosmopolitan § dismal format notation » printf » wut
  90. */
  91. #define PRIi8 __PRI8 "i"
  92. #define PRIi16 __PRI16 "i"
  93. #define PRIi32 __PRI32 "i"
  94. #define PRIi64 __PRI64 "i"
  95. #define PRIi128 __PRI128 "i"
  96. #define PRIiLEAST8 __PRI8 "i"
  97. #define PRIiLEAST16 __PRI16 "i"
  98. #define PRIiLEAST32 __PRI32 "i"
  99. #define PRIiLEAST64 __PRI64 "i"
  100. #define PRIiLEAST128 __PRI128 "i"
  101. #define PRIiFAST8 __PRI8 "i"
  102. #define PRIiFAST16 __PRI16 "i"
  103. #define PRIiFAST32 __PRI32 "i"
  104. #define PRIiFAST64 __PRI64 "i"
  105. #define PRIiFAST128 __PRI128 "i"
  106. /*───────────────────────────────────────────────────────────────────────────│─╗
  107. cosmopolitan § dismal format notation » printf » octal
  108. */
  109. #define PRIo8 __PRI8 "o"
  110. #define PRIo16 __PRI16 "o"
  111. #define PRIo32 __PRI32 "o"
  112. #define PRIo64 __PRI64 "o"
  113. #define PRIo128 __PRI128 "o"
  114. #define PRIoLEAST8 __PRI8 "o"
  115. #define PRIoLEAST16 __PRI16 "o"
  116. #define PRIoLEAST32 __PRI32 "o"
  117. #define PRIoLEAST64 __PRI64 "o"
  118. #define PRIoLEAST128 __PRI128 "o"
  119. #define PRIoFAST8 __PRI8 "o"
  120. #define PRIoFAST16 __PRI16 "o"
  121. #define PRIoFAST32 __PRI32 "o"
  122. #define PRIoFAST64 __PRI64 "o"
  123. #define PRIoFAST128 __PRI128 "o"
  124. /*───────────────────────────────────────────────────────────────────────────│─╗
  125. cosmopolitan § dismal format notation » printf » hexadecimal
  126. */
  127. #define PRIx8 __PRI8 "x"
  128. #define PRIx16 __PRI16 "x"
  129. #define PRIx32 __PRI32 "x"
  130. #define PRIx64 __PRI64 "x"
  131. #define PRIx128 __PRI128 "x"
  132. #define PRIxLEAST8 __PRI8 "x"
  133. #define PRIxLEAST16 __PRI16 "x"
  134. #define PRIxLEAST32 __PRI32 "x"
  135. #define PRIxLEAST64 __PRI64 "x"
  136. #define PRIxLEAST128 __PRI128 "x"
  137. #define PRIxFAST8 __PRI8 "x"
  138. #define PRIxFAST16 __PRI16 "x"
  139. #define PRIxFAST32 __PRI32 "x"
  140. #define PRIxFAST64 __PRI64 "x"
  141. #define PRIxFAST128 __PRI128 "x"
  142. #define PRIX8 __PRI8 "X"
  143. #define PRIX16 __PRI16 "X"
  144. #define PRIX32 __PRI32 "X"
  145. #define PRIX64 __PRI64 "X"
  146. #define PRIX128 __PRI128 "X"
  147. #define PRIXLEAST8 __PRI8 "X"
  148. #define PRIXLEAST16 __PRI16 "X"
  149. #define PRIXLEAST32 __PRI32 "X"
  150. #define PRIXLEAST64 __PRI64 "X"
  151. #define PRIXLEAST128 __PRI128 "X"
  152. #define PRIXFAST8 __PRI8 "X"
  153. #define PRIXFAST16 __PRI16 "X"
  154. #define PRIXFAST32 __PRI32 "X"
  155. #define PRIXFAST64 __PRI64 "X"
  156. #define PRIXFAST128 __PRI128 "X"
  157. /*───────────────────────────────────────────────────────────────────────────│─╗
  158. cosmopolitan § dismal format notation » printf » binary
  159. */
  160. #define PRIb8 __PRI8 "b"
  161. #define PRIb16 __PRI16 "b"
  162. #define PRIb32 __PRI32 "b"
  163. #define PRIb64 __PRI64 "b"
  164. #define PRIb128 __PRI128 "b"
  165. #define PRIbLEAST8 __PRI8 "b"
  166. #define PRIbLEAST16 __PRI16 "b"
  167. #define PRIbLEAST32 __PRI32 "b"
  168. #define PRIbLEAST64 __PRI64 "b"
  169. #define PRIbLEAST128 __PRI128 "b"
  170. #define PRIbFAST8 __PRI8 "b"
  171. #define PRIbFAST16 __PRI16 "b"
  172. #define PRIbFAST32 __PRI32 "b"
  173. #define PRIbFAST64 __PRI64 "b"
  174. #define PRIbFAST128 __PRI128 "b"
  175. #define PRIB8 __PRI8 "B"
  176. #define PRIB16 __PRI16 "B"
  177. #define PRIB32 __PRI32 "B"
  178. #define PRIB64 __PRI64 "B"
  179. #define PRIB128 __PRI128 "B"
  180. #define PRIBLEAST8 __PRI8 "B"
  181. #define PRIBLEAST16 __PRI16 "B"
  182. #define PRIBLEAST32 __PRI32 "B"
  183. #define PRIBLEAST64 __PRI64 "B"
  184. #define PRIBLEAST128 __PRI128 "B"
  185. #define PRIBFAST8 __PRI8 "B"
  186. #define PRIBFAST16 __PRI16 "B"
  187. #define PRIBFAST32 __PRI32 "B"
  188. #define PRIBFAST64 __PRI64 "B"
  189. #define PRIBFAST128 __PRI128 "B"
  190. /*───────────────────────────────────────────────────────────────────────────│─╗
  191. cosmopolitan § dismal format notation » printf » miscellaneous
  192. */
  193. #define PRIdMAX "jd"
  194. #define PRIiMAX "ji"
  195. #define PRIoMAX "jo"
  196. #define PRIuMAX "ju"
  197. #define PRIxMAX "jx"
  198. #define PRIXMAX "jX"
  199. #define PRIdPTR __PRIPTR "d"
  200. #define PRIiPTR __PRIPTR "i"
  201. #define PRIoPTR __PRIPTR "o"
  202. #define PRIuPTR __PRIPTR "u"
  203. #define PRIxPTR __PRIPTR "x"
  204. #define PRIXPTR __PRIPTR "X"
  205. /*───────────────────────────────────────────────────────────────────────────│─╗
  206. cosmopolitan § dismal format notation » scanf » decimal
  207. */
  208. #define SCNd8 __PRI8 "d"
  209. #define SCNd16 __PRI16 "d"
  210. #define SCNd32 __PRI32 "d"
  211. #define SCNd64 __PRI64 "d"
  212. #define SCNd128 __PRI128 "d"
  213. #define SCNdLEAST8 __PRI8 "d"
  214. #define SCNdLEAST16 __PRI16 "d"
  215. #define SCNdLEAST32 __PRI32 "d"
  216. #define SCNdLEAST64 __PRI64 "d"
  217. #define SCNdLEAST128 __PRI128 "d"
  218. #define SCNdFAST8 __PRI8 "d"
  219. #define SCNdFAST16 __PRI16 "d"
  220. #define SCNdFAST32 __PRI32 "d"
  221. #define SCNdFAST64 __PRI64 "d"
  222. #define SCNdFAST128 __PRI128 "d"
  223. /*───────────────────────────────────────────────────────────────────────────│─╗
  224. cosmopolitan § dismal format notation » scanf » flexidecimal
  225. */
  226. #define SCNi8 __PRI8 "i"
  227. #define SCNi16 __PRI16 "i"
  228. #define SCNi32 __PRI32 "i"
  229. #define SCNi64 __PRI64 "i"
  230. #define SCNi128 __PRI128 "i"
  231. #define SCNiLEAST8 __PRI8 "i"
  232. #define SCNiLEAST16 __PRI16 "i"
  233. #define SCNiLEAST32 __PRI32 "i"
  234. #define SCNiLEAST64 __PRI64 "i"
  235. #define SCNiLEAST128 __PRI128 "i"
  236. #define SCNiFAST8 __PRI8 "i"
  237. #define SCNiFAST16 __PRI16 "i"
  238. #define SCNiFAST32 __PRI32 "i"
  239. #define SCNiFAST64 __PRI64 "i"
  240. #define SCNiFAST128 __PRI128 "i"
  241. /*───────────────────────────────────────────────────────────────────────────│─╗
  242. cosmopolitan § dismal format notation » scanf » unsigned decimal
  243. */
  244. #define SCNu8 __PRI8 "u"
  245. #define SCNu16 __PRI16 "u"
  246. #define SCNu32 __PRI32 "u"
  247. #define SCNu64 __PRI64 "u"
  248. #define SCNu128 __PRI128 "u"
  249. #define SCNuLEAST8 __PRI8 "u"
  250. #define SCNuLEAST16 __PRI16 "u"
  251. #define SCNuLEAST32 __PRI32 "u"
  252. #define SCNuLEAST64 __PRI64 "u"
  253. #define SCNuLEAST128 __PRI128 "u"
  254. #define SCNuFAST8 __PRI8 "u"
  255. #define SCNuFAST16 __PRI16 "u"
  256. #define SCNuFAST32 __PRI32 "u"
  257. #define SCNuFAST64 __PRI64 "u"
  258. #define SCNuFAST128 __PRI128 "u"
  259. /*───────────────────────────────────────────────────────────────────────────│─╗
  260. cosmopolitan § dismal format notation » scanf » octal
  261. */
  262. #define SCNo8 __PRI8 "o"
  263. #define SCNo16 __PRI16 "o"
  264. #define SCNo32 __PRI32 "o"
  265. #define SCNo64 __PRI64 "o"
  266. #define SCNo128 __PRI128 "o"
  267. #define SCNoLEAST8 __PRI8 "o"
  268. #define SCNoLEAST16 __PRI16 "o"
  269. #define SCNoLEAST32 __PRI32 "o"
  270. #define SCNoLEAST64 __PRI64 "o"
  271. #define SCNoLEAST128 __PRI128 "o"
  272. #define SCNoFAST8 __PRI8 "o"
  273. #define SCNoFAST16 __PRI16 "o"
  274. #define SCNoFAST32 __PRI32 "o"
  275. #define SCNoFAST64 __PRI64 "o"
  276. #define SCNoFAST128 __PRI128 "o"
  277. /*───────────────────────────────────────────────────────────────────────────│─╗
  278. cosmopolitan § dismal format notation » scanf » hexadecimal
  279. */
  280. #define SCNx8 __PRI8 "x"
  281. #define SCNx16 __PRI16 "x"
  282. #define SCNx32 __PRI32 "x"
  283. #define SCNx64 __PRI64 "x"
  284. #define SCNx128 __PRI128 "x"
  285. #define SCNxLEAST8 __PRI8 "x"
  286. #define SCNxLEAST16 __PRI16 "x"
  287. #define SCNxLEAST32 __PRI32 "x"
  288. #define SCNxLEAST64 __PRI64 "x"
  289. #define SCNxLEAST128 __PRI128 "x"
  290. #define SCNxFAST8 __PRI8 "x"
  291. #define SCNxFAST16 __PRI16 "x"
  292. #define SCNxFAST32 __PRI32 "x"
  293. #define SCNxFAST64 __PRI64 "x"
  294. #define SCNxFAST128 __PRI128 "x"
  295. /*───────────────────────────────────────────────────────────────────────────│─╗
  296. cosmopolitan § dismal format notation » scanf » binary
  297. */
  298. #define SCNb8 __PRI8 "b"
  299. #define SCNb16 __PRI16 "b"
  300. #define SCNb32 __PRI32 "b"
  301. #define SCNb64 __PRI64 "b"
  302. #define SCNb128 __PRI128 "b"
  303. #define SCNbLEAST8 __PRI8 "b"
  304. #define SCNbLEAST16 __PRI16 "b"
  305. #define SCNbLEAST32 __PRI32 "b"
  306. #define SCNbLEAST64 __PRI64 "b"
  307. #define SCNbLEAST128 __PRI128 "b"
  308. #define SCNbFAST8 __PRI8 "b"
  309. #define SCNbFAST16 __PRI16 "b"
  310. #define SCNbFAST32 __PRI32 "b"
  311. #define SCNbFAST64 __PRI64 "b"
  312. #define SCNbFAST128 __PRI128 "b"
  313. /*───────────────────────────────────────────────────────────────────────────│─╗
  314. cosmopolitan § dismal format notation » scanf » miscellaneous
  315. */
  316. #define SCNdMAX "jd"
  317. #define SCNiMAX "ji"
  318. #define SCNoMAX "jo"
  319. #define SCNuMAX "ju"
  320. #define SCNxMAX "jx"
  321. #define SCNdPTR __PRIPTR "d"
  322. #define SCNiPTR __PRIPTR "i"
  323. #define SCNoPTR __PRIPTR "o"
  324. #define SCNuPTR __PRIPTR "u"
  325. #define SCNxPTR __PRIPTR "x"
  326. #endif /* COSMOPOLITAN_LIBC_INTTYPES_H_ */