1#ifndef __LINUX_KSTRTOX_H__
2#define __LINUX_KSTRTOX_H__
34static inline int kstrtou8(
const char* s,
unsigned int base,
u8* res)
39 if (!s || !res || (
base != 0 &&
base != 10 &&
base != 16))
42 while (*s ==
' ' || *s ==
'\t')
46 if ((
base == 0 ||
base == 16) && s[0] ==
'0' && (s[1] ==
'x' || s[1] ==
'X')) {
49 }
else if (
base == 0) {
56 if (*s >=
'0' && *s <=
'9')
57 d = (
unsigned int)(*s -
'0');
58 else if (
base == 16 && *s >=
'a' && *s <=
'f')
59 d = (
unsigned int)(*s -
'a') + 10;
60 else if (
base == 16 && *s >=
'A' && *s <=
'F')
61 d = (
unsigned int)(*s -
'A') + 10;
75 while (*s ==
' ' || *s ==
'\t')
79 if (*s !=
'\0' || !any)
104static inline int kstrtobool(
const char* s,
bool* res)
114 case 'y':
case 'Y':
case '1':
118 case 'n':
case 'N':
case '0':
130 if (*p ==
'n' || *p ==
'N')
135 else if ((*p ==
'f' || *p ==
'F') &&
136 (p[1] ==
'f' || p[1] ==
'F'))
231static inline unsigned long long simple_strtoull(
const char* cp,
char** endp,
235 unsigned long long result = 0;
239 if ((s[1] ==
'x' || s[1] ==
'X') &&
isxdigit(s[2]))
247 if (
base == 16 && s[0] ==
'0' && (s[1] ==
'x' || s[1] ==
'X'))
251 unsigned int c = (
unsigned char)*s;
254 if (
'0' <= c && c <=
'9')
256 else if (
'a' <= c && c <=
'f')
258 else if (
'A' <= c && c <=
'F')
274 if (result & (~0
ULL << 60)) {
279 result = result *
base + val;
281 result = result *
base + val;
291static inline unsigned long simple_strtoul(
const char* cp,
char** endp,
294 return (
unsigned long)simple_strtoull(cp, endp,
base);
321static inline long simple_strtol(
const char* cp,
char** endp,
325 return -simple_strtoul(cp + 1, endp,
base);
326 return simple_strtoul(cp, endp,
base);
#define EINVAL
Definition acclib.h:198
#define isxdigit(c)
Definition acclib.h:178
#define ERANGE
Definition acclib.h:200
struct i915_user_extension base
Definition i915_drm.h:0
#define d
Definition libunicode.c:1833
uint8_t u8
Definition kernel.h:14
#define ULL(x)
Definition const.h:79