[v11,26/29] string: Hook up the default implementation on test-stpcpy

Message ID 20230201170406.303978-27-adhemerval.zanella@linaro.org (mailing list archive)
State Superseded
Headers
Series Improve generic string routines |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Adhemerval Zanella Feb. 1, 2023, 5:04 p.m. UTC
  ---
 string/test-stpcpy.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)
  

Comments

Richard Henderson Feb. 1, 2023, 5:56 p.m. UTC | #1
On 2/1/23 07:04, Adhemerval Zanella wrote:
> ---
>   string/test-stpcpy.c | 32 +++++++++++++++++++++-----------
>   1 file changed, 21 insertions(+), 11 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

> 
> diff --git a/string/test-stpcpy.c b/string/test-stpcpy.c
> index c7a416f93a..5d344b6a23 100644
> --- a/string/test-stpcpy.c
> +++ b/string/test-stpcpy.c
> @@ -26,26 +26,36 @@
>   #include "test-string.h"
>   #ifndef WIDE
>   # define CHAR char
> -# define SIMPLE_STPCPY simple_stpcpy
>   # define STPCPY stpcpy
>   #else
>   # include <wchar.h>
>   # define CHAR wchar_t
> -# define SIMPLE_STPCPY simple_wcpcpy
>   # define STPCPY wcpcpy
>   #endif /* !WIDE */
>   
> -CHAR *SIMPLE_STPCPY (CHAR *, const CHAR *);
> -
> -IMPL (SIMPLE_STPCPY, 0)
>   IMPL (STPCPY, 1)
>   
> -CHAR *
> -SIMPLE_STPCPY (CHAR *dst, const CHAR *src)
> -{
> -  while ((*dst++ = *src++) != '\0');
> -  return dst - 1;
> -}
> +/* Also check the generic implementation.  */
> +#undef STPCPY
> +#undef weak_alias
> +#define weak_alias(a, b)
> +#undef libc_hidden_def
> +#define libc_hidden_def(a)
> +#undef libc_hidden_builtin_def
> +#define libc_hidden_builtin_def(a)
> +#undef attribute_hidden
> +#define attribute_hidden
> +#ifndef WIDE
> +# define STPCPY __stpcpy_default
> +# include "string/stpcpy.c"
> +IMPL (__stpcpy_default, 1)
> +#else
> +# define __wcslen wcslen
> +# define __wmemcpy wmemcpy
> +# define WCPCPY __wcpcpy_default
> +# include "wcsmbs/wcpcpy.c"
> +IMPL (__wcpcpy_default, 1)
> +#endif
>   
>   #undef CHAR
>   #include "test-strcpy.c"
  

Patch

diff --git a/string/test-stpcpy.c b/string/test-stpcpy.c
index c7a416f93a..5d344b6a23 100644
--- a/string/test-stpcpy.c
+++ b/string/test-stpcpy.c
@@ -26,26 +26,36 @@ 
 #include "test-string.h"
 #ifndef WIDE
 # define CHAR char
-# define SIMPLE_STPCPY simple_stpcpy
 # define STPCPY stpcpy
 #else
 # include <wchar.h>
 # define CHAR wchar_t
-# define SIMPLE_STPCPY simple_wcpcpy
 # define STPCPY wcpcpy
 #endif /* !WIDE */
 
-CHAR *SIMPLE_STPCPY (CHAR *, const CHAR *);
-
-IMPL (SIMPLE_STPCPY, 0)
 IMPL (STPCPY, 1)
 
-CHAR *
-SIMPLE_STPCPY (CHAR *dst, const CHAR *src)
-{
-  while ((*dst++ = *src++) != '\0');
-  return dst - 1;
-}
+/* Also check the generic implementation.  */
+#undef STPCPY
+#undef weak_alias
+#define weak_alias(a, b)
+#undef libc_hidden_def
+#define libc_hidden_def(a)
+#undef libc_hidden_builtin_def
+#define libc_hidden_builtin_def(a)
+#undef attribute_hidden
+#define attribute_hidden
+#ifndef WIDE
+# define STPCPY __stpcpy_default
+# include "string/stpcpy.c"
+IMPL (__stpcpy_default, 1)
+#else
+# define __wcslen wcslen
+# define __wmemcpy wmemcpy
+# define WCPCPY __wcpcpy_default
+# include "wcsmbs/wcpcpy.c"
+IMPL (__wcpcpy_default, 1)
+#endif
 
 #undef CHAR
 #include "test-strcpy.c"