Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/include/linux/kernel.h
Context not available. | |||||
#define BUILD_BUG() do { CTASSERT(0); } while (0) | #define BUILD_BUG() do { CTASSERT(0); } while (0) | ||||
#define BUILD_BUG_ON(x) CTASSERT(!(x)) | #define BUILD_BUG_ON(x) CTASSERT(!(x)) | ||||
#ifndef BUILD_BUG_ON_MSG | |||||
#define BUILD_BUG_ON_MSG(x, msg) BUILD_BUG_ON(x) | #define BUILD_BUG_ON_MSG(x, msg) BUILD_BUG_ON(x) | ||||
#endif | |||||
#define BUILD_BUG_ON_NOT_POWER_OF_2(x) BUILD_BUG_ON(!powerof2(x)) | #define BUILD_BUG_ON_NOT_POWER_OF_2(x) BUILD_BUG_ON(!powerof2(x)) | ||||
#define BUILD_BUG_ON_INVALID(expr) while (0) { (void)(expr); } | #define BUILD_BUG_ON_INVALID(expr) while (0) { (void)(expr); } | ||||
Context not available. | |||||
return (0); | return (0); | ||||
} | } | ||||
static inline int | |||||
kstrtobool(const char *s, bool *res) | |||||
{ | |||||
if (!s) | |||||
return -EINVAL; | |||||
switch (s[0]) { | |||||
case 'y': | |||||
case 'Y': | |||||
case '1': | |||||
*res = true; | |||||
return 0; | |||||
case 'n': | |||||
case 'N': | |||||
case '0': | |||||
*res = false; | |||||
return 0; | |||||
case 'o': | |||||
case 'O': | |||||
switch (s[1]) { | |||||
case 'n': | |||||
case 'N': | |||||
*res = true; | |||||
return 0; | |||||
case 'f': | |||||
case 'F': | |||||
*res = false; | |||||
return 0; | |||||
default: | |||||
break; | |||||
} | |||||
default: | |||||
break; | |||||
} | |||||
return -EINVAL; | |||||
} | |||||
static inline int | |||||
kstrtobool_from_user(const char __user *s, size_t count, bool *res) | |||||
{ | |||||
char buf[4]; | |||||
count = min(count, sizeof(buf) - 1); | |||||
if (copy_from_user(buf, s, count)) | |||||
return -EFAULT; | |||||
buf[count] = '\0'; | |||||
return kstrtobool(buf, res); | |||||
} | |||||
#define min(x, y) ((x) < (y) ? (x) : (y)) | #define min(x, y) ((x) < (y) ? (x) : (y)) | ||||
#define max(x, y) ((x) > (y) ? (x) : (y)) | #define max(x, y) ((x) > (y) ? (x) : (y)) | ||||
Context not available. |