string.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. extern void * memset(void *, int, size_t);
  22. /* For gcc 3.x, we cannot have the inline function named "memset" because
  23. the __builtin_memset will attempt to resolve to the inline as well,
  24. leading to a "sorry" about unimplemented recursive inlining. */
  25. extern inline void *__memset(void *s, int c, size_t n)
  26. {
  27. if (__builtin_constant_p(c)) {
  28. if (__builtin_constant_p(n)) {
  29. return __builtin_memset(s, c, n);
  30. } else {
  31. unsigned long c8 = (c & 0xff) * 0x0101010101010101UL;
  32. return __constant_c_memset(s, c8, n);
  33. }
  34. }
  35. return ___memset(s, c, n);
  36. }
  37. #define memset __memset
  38. #define __HAVE_ARCH_STRCPY
  39. extern char * strcpy(char *,const char *);
  40. #define __HAVE_ARCH_STRNCPY
  41. extern char * strncpy(char *, const char *, size_t);
  42. #define __HAVE_ARCH_STRCAT
  43. extern char * strcat(char *, const char *);
  44. #define __HAVE_ARCH_STRNCAT
  45. extern char * strncat(char *, const char *, size_t);
  46. #define __HAVE_ARCH_STRCHR
  47. extern char * strchr(const char *,int);
  48. #define __HAVE_ARCH_STRRCHR
  49. extern char * strrchr(const char *,int);
  50. #define __HAVE_ARCH_STRLEN
  51. extern size_t strlen(const char *);
  52. #define __HAVE_ARCH_MEMCHR
  53. extern void * memchr(const void *, int, size_t);
  54. /* The following routine is like memset except that it writes 16-bit
  55. aligned values. The DEST and COUNT parameters must be even for
  56. correct operation. */
  57. #define __HAVE_ARCH_MEMSETW
  58. extern void * __memsetw(void *dest, unsigned short, size_t count);
  59. #define memsetw(s, c, n) \
  60. (__builtin_constant_p(c) \
  61. ? __constant_c_memset((s),0x0001000100010001UL*(unsigned short)(c),(n)) \
  62. : __memsetw((s),(c),(n)))
  63. #endif /* __KERNEL__ */
  64. #endif /* __ALPHA_STRING_H__ */