diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/compat.h | 8 | ||||
-rw-r--r-- | include/linux/string.h | 28 |
2 files changed, 34 insertions, 2 deletions
diff --git a/include/linux/compat.h b/include/linux/compat.h index a43e4d6698..2336b56cf5 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -106,8 +106,12 @@ static inline void kmem_cache_destroy(struct kmem_cache *cachep) #define BUG_ON(condition) do { if (condition) BUG(); } while(0) #endif /* BUG */ -#define WARN_ON(x) if (x) {printf("WARNING in %s line %d\n" \ - , __FILE__, __LINE__); } +#define WARN_ON(condition) ({ \ + int __ret_warn_on = !!(condition); \ + if (unlikely(__ret_warn_on)) \ + printf("WARNING in %s line %d\n", __FILE__, __LINE__); \ + unlikely(__ret_warn_on); \ +}) #define PAGE_SIZE 4096 diff --git a/include/linux/string.h b/include/linux/string.h index 091ccab395..3606620739 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -50,6 +50,19 @@ extern int strncasecmp(const char *s1, const char *s2, __kernel_size_t len); #ifndef __HAVE_ARCH_STRCHR extern char * strchr(const char *,int); #endif + +/** + * strchrnul() - return position of a character in the string, or end of string + * + * The strchrnul() function is like strchr() except that if c is not found + * in s, then it returns a pointer to the nul byte at the end of s, rather than + * NULL + * @s: string to search + * @c: character to search for + * @return position of @c in @s, or end of @s if not found + */ +const char *strchrnul(const char *s, int c); + #ifndef __HAVE_ARCH_STRRCHR extern char * strrchr(const char *,int); #endif @@ -63,6 +76,21 @@ extern __kernel_size_t strlen(const char *); #ifndef __HAVE_ARCH_STRNLEN extern __kernel_size_t strnlen(const char *,__kernel_size_t); #endif + +#ifndef __HAVE_ARCH_STRCSPN +/** + * strcspn() - find span of string without given characters + * + * Calculates the length of the initial segment of @s which consists entirely + * of bsytes not in reject. + * + * @s: string to search + * @reject: strings which cause the search to halt + * @return number of characters at the start of @s which are not in @reject + */ +size_t strcspn(const char *s, const char *reject); +#endif + #ifndef __HAVE_ARCH_STRDUP extern char * strdup(const char *); #endif |