string.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef __ALPHA_STRING_H__
  2. #define __ALPHA_STRING_H__
  3. #ifdef __KERNEL__
  4. /*
  5. * GCC of any recent vintage doesn't do stupid things with bcopy.
  6. * EGCS 1.1 knows all about expanding memcpy inline, others don't.
  7. *
  8. * Similarly for a memset with data = 0.
  9. */
  10. #define __HAVE_ARCH_MEMCPY
  11. extern void * memcpy(void *, const void *, size_t);
  12. #define __HAVE_ARCH_MEMMOVE
  13. extern void * memmove(void *, const void *, size_t);
  14. /* For backward compatibility with modules. Unused otherwise. */
  15. extern void * __memcpy(void *, const void *, size_t);
  16. #define memcpy __builtin_memcpy
  17. #define __HAVE_ARCH_MEMSET
  18. extern void * __constant_c_memset(void *, unsigned long, size_t);
  19. extern void * __memset(void *, int, size_t);
  20. extern void * memset(void *, int, size_t);
  21. #define memset(s, c, n) \
  22. (__builtin_constant_p(c) \
  23. ? (__builtin_constant_p(n) && (c) == 0 \
  24. ? __builtin_memset((s),0,(n)) \
  25. : __constant_c_memset((s),0x0101010101010101UL*(unsigned char)(c),(n))) \
  26. : __memset((s),(c),(n)))
  27. #define __HAVE_ARCH_STRCPY
  28. extern char * strcpy(char *,const char *);
  29. #define __HAVE_ARCH_STRNCPY
  30. extern char * strncpy(char *, const char *, size_t);
  31. #define __HAVE_ARCH_STRCAT
  32. extern char * strcat(char *, const char *);
  33. #define __HAVE_ARCH_STRNCAT
  34. extern char * strncat(char *, const char *, size_t);
  35. #define __HAVE_ARCH_STRCHR
  36. extern char * strchr(const char *,int);
  37. #define __HAVE_ARCH_STRRCHR
  38. extern char * strrchr(const char *,int);
  39. #define __HAVE_ARCH_STRLEN
  40. extern size_t strlen(const char *);
  41. #define __HAVE_ARCH_MEMCHR
  42. extern void * memchr(const void *, int, size_t);
  43. /* The following routine is like memset except that it writes 16-bit
  44. aligned values. The DEST and COUNT parameters must be even for
  45. correct operation. */
  46. #define __HAVE_ARCH_MEMSETW
  47. extern void * __memsetw(void *dest, unsigned short, size_t count);
  48. #define memsetw(s, c, n) \
  49. (__builtin_constant_p(c) \
  50. ? __constant_c_memset((s),0x0001000100010001UL*(unsigned short)(c),(n)) \
  51. : __memsetw((s),(c),(n)))
  52. #endif /* __KERNEL__ */
  53. #endif /* __ALPHA_STRING_H__ */