1 /* Copyright (C) 1999-2022 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3 
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8 
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13 
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, see
16    <https://www.gnu.org/licenses/>.  */
17 
18 #include <string/string-inlines.c>
19 
20 #if SHLIB_COMPAT (libc, GLIBC_2_1_1, GLIBC_2_26)
21 /* Additional compatibility shims for the former
22    sysdeps/x86/bits/string.h.  */
23 void *
__old_memcpy_c(void * d,const void * s,size_t n)24 __old_memcpy_c (void *d, const void *s, size_t n)
25 {
26   return memcpy (d, s, n);
27 }
28 strong_alias (__old_memcpy_c, __old_memcpy_g);
29 strong_alias (__old_memcpy_c, __old_memcpy_by4);
30 strong_alias (__old_memcpy_c, __old_memcpy_by2);
31 compat_symbol (libc, __old_memcpy_c, __memcpy_c, GLIBC_2_1_1);
32 compat_symbol (libc, __old_memcpy_g, __memcpy_g, GLIBC_2_1_1);
33 compat_symbol (libc, __old_memcpy_by4, __memcpy_by4, GLIBC_2_1_1);
34 compat_symbol (libc, __old_memcpy_by2, __memcpy_by2, GLIBC_2_1_1);
35 
36 void *
__old_memset_cc(void * s,unsigned long int pattern,size_t n)37 __old_memset_cc (void *s, unsigned long int pattern, size_t n)
38 {
39   return memset (s, pattern & 0xff, n);
40 }
41 strong_alias (__old_memset_cc, __old_memset_cg);
42 strong_alias (__old_memset_cc, __old_memset_ccn_by2);
43 strong_alias (__old_memset_cc, __old_memset_ccn_by4);
44 compat_symbol (libc, __old_memset_cc, __memset_cc, GLIBC_2_1_1);
45 compat_symbol (libc, __old_memset_cg, __memset_cg, GLIBC_2_1_1);
46 compat_symbol (libc, __old_memset_ccn_by4, __memset_ccn_by4, GLIBC_2_1_1);
47 compat_symbol (libc, __old_memset_ccn_by2, __memset_ccn_by2, GLIBC_2_1_1);
48 
49 void *
__old_memset_gg(void * s,char c,size_t n)50 __old_memset_gg (void *s, char c, size_t n)
51 {
52   return memset (s, c, n);
53 }
54 strong_alias (__old_memset_gg, __old_memset_gcn_by4);
55 strong_alias (__old_memset_gg, __old_memset_gcn_by2);
56 compat_symbol (libc, __old_memset_gg, __memset_gg, GLIBC_2_1_1);
57 compat_symbol (libc, __old_memset_gcn_by4, __memset_gcn_by4, GLIBC_2_1_1);
58 compat_symbol (libc, __old_memset_gcn_by2, __memset_gcn_by2, GLIBC_2_1_1);
59 
60 size_t
__old_strlen_g(const char * str)61 __old_strlen_g (const char *str)
62 {
63   return strlen (str);
64 }
65 compat_symbol (libc, __old_strlen_g, __strlen_g, GLIBC_2_1_1);
66 
67 char *
__old_strcpy_g(char * dest,const char * src)68 __old_strcpy_g (char *dest, const char *src)
69 {
70   return strcpy (dest, src);
71 }
72 compat_symbol (libc, __old_strcpy_g, __strcpy_g, GLIBC_2_1_1);
73 
74 void *
__old_mempcpy_byn(void * dest,const void * src,size_t len)75 __old_mempcpy_byn (void *dest, const void *src, size_t len)
76 {
77   return __mempcpy (dest, src, len);
78 }
79 strong_alias (__old_mempcpy_byn, __old_mempcpy_by4);
80 strong_alias (__old_mempcpy_byn, __old_mempcpy_by2);
81 compat_symbol (libc, __old_mempcpy_byn, __mempcpy_byn, GLIBC_2_1_1);
82 compat_symbol (libc, __old_mempcpy_by4, __mempcpy_by4, GLIBC_2_1_1);
83 compat_symbol (libc, __old_mempcpy_by2, __mempcpy_by2, GLIBC_2_1_1);
84 
85 char *
__old_stpcpy_g(char * dest,const char * src)86 __old_stpcpy_g (char *dest, const char *src)
87 {
88   return __stpcpy (dest, src);
89 }
90 compat_symbol (libc, __old_stpcpy_g, __stpcpy_g, GLIBC_2_1_1);
91 
92 char *
__old_strncpy_byn(char * dest,const char * src,size_t srclen,size_t n)93 __old_strncpy_byn (char *dest, const char *src, size_t srclen, size_t n)
94 {
95   return strncpy (dest, src, n);
96 }
97 strong_alias (__old_strncpy_byn, __old_strncpy_by4);
98 strong_alias (__old_strncpy_byn, __old_strncpy_by2);
99 compat_symbol (libc, __old_strncpy_byn, __strncpy_byn, GLIBC_2_1_1);
100 compat_symbol (libc, __old_strncpy_by4, __strncpy_by4, GLIBC_2_1_1);
101 compat_symbol (libc, __old_strncpy_by2, __strncpy_by2, GLIBC_2_1_1);
102 
103 char *
__old_strncpy_gg(char * dest,const char * src,size_t n)104 __old_strncpy_gg (char *dest, const char *src, size_t n)
105 {
106   return strncpy (dest, src, n);
107 }
108 compat_symbol (libc, __old_strncpy_gg, __strncpy_gg, GLIBC_2_1_1);
109 
110 /* __strcat_c took a third argument, which we ignore.  */
111 char *
__old_strcat_g(char * dest,const char * src)112 __old_strcat_g (char *dest, const char *src)
113 {
114   return strcat (dest, src);
115 }
116 strong_alias (__old_strcat_g, __old_strcat_c);
117 compat_symbol (libc, __old_strcat_g, __strcat_g, GLIBC_2_1_1);
118 compat_symbol (libc, __old_strcat_c, __strcat_c, GLIBC_2_1_1);
119 
120 char *
__old_strncat_g(char * dest,const char * src,size_t n)121 __old_strncat_g (char *dest, const char *src, size_t n)
122 {
123   return __strncat (dest, src, n);
124 }
125 compat_symbol (libc, __old_strncat_g, __strncat_g, GLIBC_2_1_1);
126 
127 int
__old_strcmp_gg(const char * s1,const char * s2)128 __old_strcmp_gg (const char *s1, const char *s2)
129 {
130   return strcmp (s1, s2);
131 }
132 compat_symbol (libc, __old_strcmp_gg, __strcmp_gg, GLIBC_2_1_1);
133 
134 int
__old_strncmp_g(const char * s1,const char * s2,size_t n)135 __old_strncmp_g (const char *s1, const char *s2, size_t n)
136 {
137   return strncmp (s1, s2, n);
138 }
139 compat_symbol (libc, __old_strncmp_g, __strncmp_g, GLIBC_2_1_1);
140 
141 char *
__old_strchr_g(const char * s,int c)142 __old_strchr_g (const char *s, int c)
143 {
144   return strchr (s, c);
145 }
146 strong_alias (__old_strchr_g, __old_strchr_c);
147 compat_symbol (libc, __old_strchr_g, __strchr_g, GLIBC_2_1_1);
148 compat_symbol (libc, __old_strchr_c, __strchr_c, GLIBC_2_1_1);
149 
150 char *
__old_strchrnul_g(const char * s,int c)151 __old_strchrnul_g (const char *s, int c)
152 {
153   return __strchrnul (s, c);
154 }
155 strong_alias (__old_strchrnul_g, __old_strchrnul_c);
156 compat_symbol (libc, __old_strchrnul_g, __strchrnul_g, GLIBC_2_1_1);
157 compat_symbol (libc, __old_strchrnul_c, __strchrnul_c, GLIBC_2_1_1);
158 
159 char *
__old_strrchr_g(const char * s,int c)160 __old_strrchr_g (const char *s, int c)
161 {
162   return strrchr (s, c);
163 }
164 strong_alias (__old_strrchr_g, __old_strrchr_c);
165 compat_symbol (libc, __old_strrchr_g, __strrchr_g, GLIBC_2_1_1);
166 compat_symbol (libc, __old_strrchr_c, __strrchr_c, GLIBC_2_1_1);
167 
168 /* __strcspn_cg took a third argument, which we ignore.  */
169 size_t
__old_strcspn_g(const char * s,const char * reject)170 __old_strcspn_g (const char *s, const char *reject)
171 {
172   return strcspn (s, reject);
173 }
174 strong_alias (__old_strcspn_g, __old_strcspn_cg);
175 compat_symbol (libc, __old_strcspn_g, __strcspn_g, GLIBC_2_1_1);
176 compat_symbol (libc, __old_strcspn_cg, __strcspn_cg, GLIBC_2_1_1);
177 
178 /* __strspn_cg took a third argument, which we ignore.  */
179 size_t
__old_strspn_g(const char * s,const char * accept)180 __old_strspn_g (const char *s, const char *accept)
181 {
182   return strspn (s, accept);
183 }
184 strong_alias (__old_strspn_g, __old_strspn_cg);
185 compat_symbol (libc, __old_strspn_g, __strspn_g, GLIBC_2_1_1);
186 compat_symbol (libc, __old_strspn_cg, __strspn_cg, GLIBC_2_1_1);
187 
188 /* __strpbrk_cg took a third argument, which we ignore.  */
189 const char *
__old_strpbrk_g(const char * s,const char * accept)190 __old_strpbrk_g (const char *s, const char *accept)
191 {
192   return strpbrk (s, accept);
193 }
194 strong_alias (__old_strpbrk_g, __old_strpbrk_cg);
195 compat_symbol (libc, __old_strpbrk_g, __strpbrk_g, GLIBC_2_1_1);
196 compat_symbol (libc, __old_strpbrk_cg, __strpbrk_cg, GLIBC_2_1_1);
197 
198 /* __strstr_cg took a third argument, which we ignore.  */
199 const char *
__old_strstr_g(const char * s,const char * accept)200 __old_strstr_g (const char *s, const char *accept)
201 {
202   return strstr (s, accept);
203 }
204 strong_alias (__old_strstr_g, __old_strstr_cg);
205 compat_symbol (libc, __old_strstr_g, __strstr_g, GLIBC_2_1_1);
206 compat_symbol (libc, __old_strstr_cg, __strstr_cg, GLIBC_2_1_1);
207 
208 #endif
209