1 /* 2 $Id: inttypes.h 2547 2021-03-19 23:40:46Z soci $ 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License along 15 with this program; if not, write to the Free Software Foundation, Inc., 16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 18 */ 19 #ifndef INTTYPES_H 20 #define INTTYPES_H 21 22 #ifndef _MSC_VER 23 #include <unistd.h> 24 #elif _MSC_VER >= 1200 25 #include <basetsd.h> 26 typedef SSIZE_T ssize_t; 27 #endif 28 #include <inttypes.h> 29 #include <stdint.h> 30 #include <stdlib.h> 31 #include <limits.h> 32 33 #ifndef PRId32 34 #define PRId32 "d" 35 #endif 36 #ifndef PRIu32 37 #define PRIu32 "u" 38 #endif 39 #ifndef PRIx32 40 #define PRIx32 "x" 41 #endif 42 #ifndef PRIX32 43 #define PRIX32 "X" 44 #endif 45 #ifndef PRIxPTR 46 #define PRIxPTR "lx" 47 #endif 48 49 #ifndef PRIxSIZE 50 #if __STDC_VERSION__ >= 199901L && !defined _WIN32 && !defined __VBCC__ 51 #define PRIxSIZE "zx" 52 #elif defined USHRT_MAX && SIZE_MAX == USHRT_MAX && !defined __VBCC__ && !defined __DJGPP__ 53 #define PRIxSIZE "hx" 54 #elif defined UINT_MAX && SIZE_MAX == UINT_MAX && !defined __VBCC__ && !defined __DJGPP__ 55 #define PRIxSIZE "x" 56 #elif defined ULONG_MAX && SIZE_MAX == ULONG_MAX 57 #define PRIxSIZE "lx" 58 #elif defined ULLONG_MAX && SIZE_MAX == ULLONG_MAX 59 #define PRIxSIZE "llx" 60 #else 61 #define PRIxSIZE "x" 62 #endif 63 #endif 64 65 #ifndef PRIuSIZE 66 #if __STDC_VERSION__ >= 199901L && !defined _WIN32 && !defined __VBCC__ 67 #define PRIuSIZE "zu" 68 #elif defined _WIN64 && defined PRIu64 69 #define PRIuSIZE PRIu64 70 #elif defined USHRT_MAX && SIZE_MAX == USHRT_MAX && !defined __VBCC__ && !defined __DJGPP__ 71 #define PRIuSIZE "hu" 72 #elif defined UINT_MAX && SIZE_MAX == UINT_MAX && !defined __VBCC__ && !defined __DJGPP__ 73 #define PRIuSIZE "u" 74 #elif defined ULONG_MAX && SIZE_MAX == ULONG_MAX 75 #define PRIuSIZE "lu" 76 #elif defined ULLONG_MAX && SIZE_MAX == ULLONG_MAX 77 #define PRIuSIZE "llu" 78 #else 79 #define PRIuSIZE "u" 80 #endif 81 #endif 82 83 typedef uint32_t argcount_t; 84 #define PRIuargcount PRIu32 85 typedef uint32_t uchar_t; 86 typedef uint32_t linenum_t; 87 #define PRIuline PRIu32 88 #define PRIxline PRIx32 89 typedef uint32_t address_t; 90 #define PRIaddress PRIx32 91 typedef uint32_t linecpos_t; 92 struct linepos_s {linenum_t line;linecpos_t pos;}; 93 #define PRIlinepos PRIu32 94 typedef const struct linepos_s *linepos_t; 95 typedef int32_t ival_t; 96 #define PRIdval PRId32 97 typedef uint32_t uval_t; 98 #define PRIxval PRIx32 99 #define PRIuval PRIu32 100 #define PRIXval PRIX32 101 102 #ifndef ARGCOUNT_MAX 103 #define ARGCOUNT_MAX (~(argcount_t)0) 104 #endif 105 106 #ifndef SIZE_MAX 107 #define SIZE_MAX (~(size_t)0) 108 #endif 109 110 #ifndef SSIZE_MAX 111 #define SSIZE_MAX ((ssize_t)(SIZE_MAX / 2)) 112 #endif 113 114 #define SIZE_MSB ((size_t)1 << (sizeof(size_t) * 8 - 1)) 115 116 #define lenof(a) (sizeof(a) / sizeof (a)[0]) 117 118 #endif 119