aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernel.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r--include/linux/kernel.h70
1 files changed, 66 insertions, 4 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2fe6e84894a4..00cec4dc0ae2 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -187,14 +187,76 @@ NORET_TYPE void do_exit(long error_code)
187 ATTRIB_NORET; 187 ATTRIB_NORET;
188NORET_TYPE void complete_and_exit(struct completion *, long) 188NORET_TYPE void complete_and_exit(struct completion *, long)
189 ATTRIB_NORET; 189 ATTRIB_NORET;
190
191/* Internal, do not use. */
192int __must_check _kstrtoul(const char *s, unsigned int base, unsigned long *res);
193int __must_check _kstrtol(const char *s, unsigned int base, long *res);
194
195int __must_check kstrtoull(const char *s, unsigned int base, unsigned long long *res);
196int __must_check kstrtoll(const char *s, unsigned int base, long long *res);
197static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res)
198{
199 /*
200 * We want to shortcut function call, but
201 * __builtin_types_compatible_p(unsigned long, unsigned long long) = 0.
202 */
203 if (sizeof(unsigned long) == sizeof(unsigned long long) &&
204 __alignof__(unsigned long) == __alignof__(unsigned long long))
205 return kstrtoull(s, base, (unsigned long long *)res);
206 else
207 return _kstrtoul(s, base, res);
208}
209
210static inline int __must_check kstrtol(const char *s, unsigned int base, long *res)
211{
212 /*
213 * We want to shortcut function call, but
214 * __builtin_types_compatible_p(long, long long) = 0.
215 */
216 if (sizeof(long) == sizeof(long long) &&
217 __alignof__(long) == __alignof__(long long))
218 return kstrtoll(s, base, (long long *)res);
219 else
220 return _kstrtol(s, base, res);
221}
222
223int __must_check kstrtouint(const char *s, unsigned int base, unsigned int *res);
224int __must_check kstrtoint(const char *s, unsigned int base, int *res);
225
226static inline int __must_check kstrtou64(const char *s, unsigned int base, u64 *res)
227{
228 return kstrtoull(s, base, res);
229}
230
231static inline int __must_check kstrtos64(const char *s, unsigned int base, s64 *res)
232{
233 return kstrtoll(s, base, res);
234}
235
236static inline int __must_check kstrtou32(const char *s, unsigned int base, u32 *res)
237{
238 return kstrtouint(s, base, res);
239}
240
241static inline int __must_check kstrtos32(const char *s, unsigned int base, s32 *res)
242{
243 return kstrtoint(s, base, res);
244}
245
246int __must_check kstrtou16(const char *s, unsigned int base, u16 *res);
247int __must_check kstrtos16(const char *s, unsigned int base, s16 *res);
248int __must_check kstrtou8(const char *s, unsigned int base, u8 *res);
249int __must_check kstrtos8(const char *s, unsigned int base, s8 *res);
250
190extern unsigned long simple_strtoul(const char *,char **,unsigned int); 251extern unsigned long simple_strtoul(const char *,char **,unsigned int);
191extern long simple_strtol(const char *,char **,unsigned int); 252extern long simple_strtol(const char *,char **,unsigned int);
192extern unsigned long long simple_strtoull(const char *,char **,unsigned int); 253extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
193extern long long simple_strtoll(const char *,char **,unsigned int); 254extern long long simple_strtoll(const char *,char **,unsigned int);
194extern int __must_check strict_strtoul(const char *, unsigned int, unsigned long *); 255#define strict_strtoul kstrtoul
195extern int __must_check strict_strtol(const char *, unsigned int, long *); 256#define strict_strtol kstrtol
196extern int __must_check strict_strtoull(const char *, unsigned int, unsigned long long *); 257#define strict_strtoull kstrtoull
197extern int __must_check strict_strtoll(const char *, unsigned int, long long *); 258#define strict_strtoll kstrtoll
259
198extern int sprintf(char * buf, const char * fmt, ...) 260extern int sprintf(char * buf, const char * fmt, ...)
199 __attribute__ ((format (printf, 2, 3))); 261 __attribute__ ((format (printf, 2, 3)));
200extern int vsprintf(char *buf, const char *, va_list) 262extern int vsprintf(char *buf, const char *, va_list)