diff options
Diffstat (limited to 'include/xatonum.h')
-rw-r--r-- | include/xatonum.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/include/xatonum.h b/include/xatonum.h index 46e49b0eb..585d84623 100644 --- a/include/xatonum.h +++ b/include/xatonum.h | |||
@@ -104,3 +104,54 @@ extern inline uint32_t xatou32(const char *numstr) | |||
104 | return xatoul(numstr); | 104 | return xatoul(numstr); |
105 | return BUG_xatou32_unimplemented(); | 105 | return BUG_xatou32_unimplemented(); |
106 | } | 106 | } |
107 | |||
108 | /* Non-aborting kind of convertors */ | ||
109 | |||
110 | unsigned long long bb_strtoull(const char *arg, char **endp, int base); | ||
111 | long long bb_strtoll(const char *arg, char **endp, int base); | ||
112 | |||
113 | #if ULONG_MAX == ULLONG_MAX | ||
114 | extern inline | ||
115 | unsigned long bb_strtoul(const char *arg, char **endp, int base) | ||
116 | { return bb_strtoull(arg, endp, base); } | ||
117 | extern inline | ||
118 | unsigned long bb_strtol(const char *arg, char **endp, int base) | ||
119 | { return bb_strtoll(arg, endp, base); } | ||
120 | #else | ||
121 | unsigned long bb_strtoul(const char *arg, char **endp, int base); | ||
122 | long bb_strtol(const char *arg, char **endp, int base); | ||
123 | #endif | ||
124 | |||
125 | #if UINT_MAX == ULLONG_MAX | ||
126 | extern inline | ||
127 | unsigned long bb_strtou(const char *arg, char **endp, int base) | ||
128 | { return bb_strtoull(arg, endp, base); } | ||
129 | extern inline | ||
130 | unsigned long bb_strtoi(const char *arg, char **endp, int base) | ||
131 | { return bb_strtoll(arg, endp, base); } | ||
132 | #elif UINT_MAX == ULONG_MAX | ||
133 | extern inline | ||
134 | unsigned long bb_strtou(const char *arg, char **endp, int base) | ||
135 | { return bb_strtoul(arg, endp, base); } | ||
136 | extern inline | ||
137 | unsigned long bb_strtoi(const char *arg, char **endp, int base) | ||
138 | { return bb_strtol(arg, endp, base); } | ||
139 | #else | ||
140 | unsigned long bb_strtou(const char *arg, char **endp, int base); | ||
141 | long bb_strtoi(const char *arg, char **endp, int base); | ||
142 | #endif | ||
143 | |||
144 | int BUG_bb_strtou32_unimplemented(void); | ||
145 | extern inline | ||
146 | uint32_t bb_strtou32(const char *arg, char **endp, int base) | ||
147 | { | ||
148 | if (sizeof(uint32_t) == sizeof(unsigned)) | ||
149 | return bb_strtou(arg, endp, base); | ||
150 | if (sizeof(uint32_t) == sizeof(unsigned long)) | ||
151 | return bb_strtoul(arg, endp, base); | ||
152 | return BUG_bb_strtou32_unimplemented(); | ||
153 | } | ||
154 | |||
155 | /* Floating point */ | ||
156 | |||
157 | /* double bb_strtod(const char *arg, char **endp); */ | ||