string.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (C) 2011 Andes Technology Corporation
  3. * Copyright (C) 2010 Shawn Lin (nobuhiro@andestech.com)
  4. * Copyright (C) 2011 Macpaul Lin (macpaul@andestech.com)
  5. * Copyright (C) 2017 Rick Chen (rick@andestech.com)
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file "COPYING" in the main directory of this archive
  9. * for more details.
  10. */
  11. #ifndef __ASM_RISCV_STRING_H
  12. #define __ASM_RISCV_STRING_H
  13. /*
  14. * We don't do inline string functions, since the
  15. * optimised inline asm versions are not small.
  16. */
  17. #undef __HAVE_ARCH_STRRCHR
  18. #undef __HAVE_ARCH_STRCHR
  19. #undef __HAVE_ARCH_MEMCPY
  20. #undef __HAVE_ARCH_MEMMOVE
  21. #undef __HAVE_ARCH_MEMCHR
  22. #undef __HAVE_ARCH_MEMZERO
  23. #undef __HAVE_ARCH_MEMSET
  24. #ifdef CONFIG_MARCO_MEMSET
  25. #define memset(_p, _v, _n) \
  26. (typeof(_p) (p) = (_p); \
  27. typeof(_v) (v) = (_v); \
  28. typeof(_n) (n) = (_n); \
  29. { \
  30. if ((n) != 0) { \
  31. if (__builtin_constant_p((v)) && (v) == 0) \
  32. __memzero((p), (n)); \
  33. else \
  34. memset((p), (v), (n)); \
  35. } \
  36. (p); \
  37. })
  38. #define memzero(_p, _n) \
  39. (typeof(_p) (p) = (_p); \
  40. typeof(_n) (n) = (_n); \
  41. { if ((n) != 0) __memzero((p), (n)); (p); })
  42. #endif
  43. #endif /* __ASM_RISCV_STRING_H */