110-compat_macros.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --- a/include/string.h
  2. +++ b/include/string.h
  3. @@ -355,18 +355,40 @@ extern char *index (__const char *__s, i
  4. /* Find the last occurrence of C in S (same as strrchr). */
  5. extern char *rindex (__const char *__s, int __c)
  6. __THROW __attribute_pure__ __nonnull ((1));
  7. -# else
  8. -# ifdef __UCLIBC_SUSV3_LEGACY_MACROS__
  9. +# elif defined(__UCLIBC_SUSV3_LEGACY_MACROS__) && !defined(_STRINGS_H)
  10. /* bcopy/bzero/bcmp/index/rindex are marked LEGACY in SuSv3.
  11. * They are replaced as proposed by SuSv3. Don't sync this part
  12. * with glibc and keep it in sync with strings.h. */
  13. -# define bcopy(src,dest,n) (memmove((dest), (src), (n)), (void) 0)
  14. -# define bzero(s,n) (memset((s), '\0', (n)), (void) 0)
  15. -# define bcmp(s1,s2,n) memcmp((s1), (s2), (size_t)(n))
  16. -# define index(s,c) strchr((s), (c))
  17. -# define rindex(s,c) strrchr((s), (c))
  18. -# endif
  19. +/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
  20. +static __inline__ void bcopy (__const void *__src, void *__dest, size_t __n)
  21. +{
  22. + memmove(__dest, __src, __n);
  23. +}
  24. +
  25. +/* Set N bytes of S to 0. */
  26. +static __inline__ void bzero (void *__s, size_t __n)
  27. +{
  28. + memset(__s, 0, __n);
  29. +}
  30. +
  31. +/* Compare N bytes of S1 and S2 (same as memcmp). */
  32. +static __inline__ int bcmp (__const void *__s1, __const void *__s2, size_t __n)
  33. +{
  34. + return memcmp(__s1, __s2, __n);
  35. +}
  36. +
  37. +/* Find the first occurrence of C in S (same as strchr). */
  38. +static __inline__ char *index (__const char *__s, int __c)
  39. +{
  40. + return strchr(__s, __c);
  41. +}
  42. +
  43. +/* Find the last occurrence of C in S (same as strrchr). */
  44. +static __inline__ char *rindex (__const char *__s, int __c)
  45. +{
  46. + return strrchr(__s, __c);
  47. +}
  48. # endif
  49. /* Return the position of the first bit set in I, or 0 if none are set.