debuggers.hg

view xen/include/xen/string.h @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children
line source
1 #ifndef _LINUX_STRING_H_
2 #define _LINUX_STRING_H_
4 #include <xen/types.h> /* for size_t */
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
10 #define __kernel_size_t size_t
12 extern char * strpbrk(const char *,const char *);
13 extern char * strsep(char **,const char *);
14 extern __kernel_size_t strspn(const char *,const char *);
17 /*
18 * Include machine specific inline routines
19 */
20 #include <asm/string.h>
22 /*
23 * These string functions are considered too dangerous for normal use.
24 * Use safe_strcpy(), safe_strcat(), strlcpy(), strlcat() as appropriate.
25 */
26 #define strcpy __xen_has_no_strcpy__
27 #define strcat __xen_has_no_strcat__
28 #define strncpy __xen_has_no_strncpy__
29 #define strncat __xen_has_no_strncat__
31 #ifndef __HAVE_ARCH_STRLCPY
32 extern size_t strlcpy(char *,const char *, __kernel_size_t);
33 #endif
34 #ifndef __HAVE_ARCH_STRLCAT
35 extern size_t strlcat(char *,const char *, __kernel_size_t);
36 #endif
37 #ifndef __HAVE_ARCH_STRCMP
38 extern int strcmp(const char *,const char *);
39 #endif
40 #ifndef __HAVE_ARCH_STRNCMP
41 extern int strncmp(const char *,const char *,__kernel_size_t);
42 #endif
43 #ifndef __HAVE_ARCH_STRNICMP
44 extern int strnicmp(const char *, const char *, __kernel_size_t);
45 #endif
46 #ifndef __HAVE_ARCH_STRCHR
47 extern char * strchr(const char *,int);
48 #endif
49 #ifndef __HAVE_ARCH_STRRCHR
50 extern char * strrchr(const char *,int);
51 #endif
52 #ifndef __HAVE_ARCH_STRSTR
53 extern char * strstr(const char *,const char *);
54 #endif
55 #ifndef __HAVE_ARCH_STRLEN
56 extern __kernel_size_t strlen(const char *);
57 #endif
58 #ifndef __HAVE_ARCH_STRNLEN
59 extern __kernel_size_t strnlen(const char *,__kernel_size_t);
60 #endif
62 #ifndef __HAVE_ARCH_MEMSET
63 extern void * memset(void *,int,__kernel_size_t);
64 #endif
65 #ifndef __HAVE_ARCH_MEMCPY
66 extern void * memcpy(void *,const void *,__kernel_size_t);
67 #endif
68 #ifndef __HAVE_ARCH_MEMMOVE
69 extern void * memmove(void *,const void *,__kernel_size_t);
70 #endif
71 #ifndef __HAVE_ARCH_MEMSCAN
72 extern void * memscan(void *,int,__kernel_size_t);
73 #endif
74 #ifndef __HAVE_ARCH_MEMCMP
75 extern int memcmp(const void *,const void *,__kernel_size_t);
76 #endif
77 #ifndef __HAVE_ARCH_MEMCHR
78 extern void * memchr(const void *,int,__kernel_size_t);
79 #endif
81 #ifdef __cplusplus
82 }
83 #endif
85 #define is_char_array(x) __builtin_types_compatible_p(typeof(x), char[])
87 /* safe_xxx always NUL-terminates and returns !=0 if result is truncated. */
88 #define safe_strcpy(d, s) ({ \
89 BUILD_BUG_ON(!is_char_array(d)); \
90 (strlcpy(d, s, sizeof(d)) >= sizeof(d)); \
91 })
92 #define safe_strcat(d, s) ({ \
93 BUILD_BUG_ON(!is_char_array(d)); \
94 (strlcat(d, s, sizeof(d)) >= sizeof(d)); \
95 })
97 #endif /* _LINUX_STRING_H_ */