Root/toolchain/uClibc/patches-0.9.33/110-compat_macros.patch

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 
14-# define bcopy(src,dest,n) (memmove((dest), (src), (n)), (void) 0)
15-# define bzero(s,n) (memset((s), '\0', (n)), (void) 0)
16-# define bcmp(s1,s2,n) memcmp((s1), (s2), (size_t)(n))
17-# define index(s,c) strchr((s), (c))
18-# define rindex(s,c) strrchr((s), (c))
19-# endif
20+/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
21+static __inline__ void bcopy (__const void *__src, void *__dest, size_t __n)
22+{
23+ memmove(__dest, __src, __n);
24+}
25+
26+/* Set N bytes of S to 0. */
27+static __inline__ void bzero (void *__s, size_t __n)
28+{
29+ memset(__s, 0, __n);
30+}
31+
32+/* Compare N bytes of S1 and S2 (same as memcmp). */
33+static __inline__ int bcmp (__const void *__s1, __const void *__s2, size_t __n)
34+{
35+ return memcmp(__s1, __s2, __n);
36+}
37+
38+/* Find the first occurrence of C in S (same as strchr). */
39+static __inline__ char *index (__const char *__s, int __c)
40+{
41+ return strchr(__s, __c);
42+}
43+
44+/* Find the last occurrence of C in S (same as strrchr). */
45+static __inline__ char *rindex (__const char *__s, int __c)
46+{
47+ return strrchr(__s, __c);
48+}
49 # endif
50 
51 /* Return the position of the first bit set in I, or 0 if none are set.
52

Archive Download this file



interactive