306-mips_mem_functions_performance.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. --- a/arch/mips/include/asm/string.h
  2. +++ b/arch/mips/include/asm/string.h
  3. @@ -133,11 +133,44 @@ strncmp(__const__ char *__cs, __const__
  4. #define __HAVE_ARCH_MEMSET
  5. extern void *memset(void *__s, int __c, size_t __count);
  6. +#define memset(__s, __c, len) \
  7. +({ \
  8. + size_t __len = (len); \
  9. + void *__ret; \
  10. + if (__builtin_constant_p(len) && __len >= 64) \
  11. + __ret = memset((__s), (__c), __len); \
  12. + else \
  13. + __ret = __builtin_memset((__s), (__c), __len); \
  14. + __ret; \
  15. +})
  16. #define __HAVE_ARCH_MEMCPY
  17. extern void *memcpy(void *__to, __const__ void *__from, size_t __n);
  18. +#define memcpy(dst, src, len) \
  19. +({ \
  20. + size_t __len = (len); \
  21. + void *__ret; \
  22. + if (__builtin_constant_p(len) && __len >= 64) \
  23. + __ret = memcpy((dst), (src), __len); \
  24. + else \
  25. + __ret = __builtin_memcpy((dst), (src), __len); \
  26. + __ret; \
  27. +})
  28. #define __HAVE_ARCH_MEMMOVE
  29. extern void *memmove(void *__dest, __const__ void *__src, size_t __n);
  30. +#define memmove(dst, src, len) \
  31. +({ \
  32. + size_t __len = (len); \
  33. + void *__ret; \
  34. + if (__builtin_constant_p(len) && __len >= 64) \
  35. + __ret = memmove((dst), (src), __len); \
  36. + else \
  37. + __ret = __builtin_memmove((dst), (src), __len); \
  38. + __ret; \
  39. +})
  40. +
  41. +#define __HAVE_ARCH_MEMCMP
  42. +#define memcmp(src1, src2, len) __builtin_memcmp((src1), (src2), (len))
  43. #endif /* _ASM_STRING_H */
  44. --- a/arch/mips/lib/Makefile
  45. +++ b/arch/mips/lib/Makefile
  46. @@ -4,7 +4,7 @@
  47. lib-y += bitops.o csum_partial.o delay.o memcpy.o memset.o \
  48. mips-atomic.o strlen_user.o strncpy_user.o \
  49. - strnlen_user.o uncached.o
  50. + strnlen_user.o uncached.o memcmp.o
  51. obj-y += iomap.o
  52. obj-$(CONFIG_PCI) += iomap-pci.o
  53. --- /dev/null
  54. +++ b/arch/mips/lib/memcmp.c
  55. @@ -0,0 +1,22 @@
  56. +/*
  57. + * copied from linux/lib/string.c
  58. + *
  59. + * Copyright (C) 1991, 1992 Linus Torvalds
  60. + */
  61. +
  62. +#include <linux/module.h>
  63. +#include <linux/string.h>
  64. +
  65. +#undef memcmp
  66. +int memcmp(const void *cs, const void *ct, size_t count)
  67. +{
  68. + const unsigned char *su1, *su2;
  69. + int res = 0;
  70. +
  71. + for (su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
  72. + if ((res = *su1 - *su2) != 0)
  73. + break;
  74. + return res;
  75. +}
  76. +EXPORT_SYMBOL(memcmp);
  77. +