[v12,22/31] string: Hook up the default implementation on test-strlen

Message ID 20230202181149.2181553-23-adhemerval.zanella@linaro.org
State Committed
Commit 52d9adc9e33819323eb971712c136bd618cdea1d
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 Netto Feb. 2, 2023, 6:11 p.m. UTC
  Also remove the simple_STRLEN and builtin_strlen, which are not used
anywhere.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 string/test-strlen.c | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)
  

Comments

Noah Goldstein Feb. 3, 2023, 11:30 p.m. UTC | #1
On Thu, Feb 2, 2023 at 12:12 PM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> Also remove the simple_STRLEN and builtin_strlen, which are not used
> anywhere.
Think I'm slightly opposed to removing the simple_* test implementations
as they can be useful to hook in when debugging.
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  string/test-strlen.c | 31 ++++++++++++++-----------------
>  1 file changed, 14 insertions(+), 17 deletions(-)
>
> diff --git a/string/test-strlen.c b/string/test-strlen.c
> index 81adf23737..0f98576f40 100644
> --- a/string/test-strlen.c
> +++ b/string/test-strlen.c
> @@ -37,27 +37,24 @@
>
>  typedef size_t (*proto_t) (const CHAR *);
>
> -/* Naive implementation to verify results.  */
> -size_t
> -simple_STRLEN (const CHAR *s)
> -{
> -  const CHAR *p;
> -
> -  for (p = s; *p; ++p);
> -  return p - s;
> -}
> +IMPL (STRLEN, 1)
>
> +/* Also check the generic implementation.  */
> +#undef STRLEN
> +#undef weak_alias
> +#define weak_alias(a, b)
> +#undef libc_hidden_builtin_def
> +#define libc_hidden_builtin_def(a)
>  #ifndef WIDE
> -size_t
> -builtin_strlen (const CHAR *p)
> -{
> -  return __builtin_strlen (p);
> -}
> -IMPL (builtin_strlen, 0)
> +# define STRLEN __strlen_default
> +# include "string/strlen.c"
> +IMPL (__strlen_default, 1)
> +#else
> +# define WCSLEN __wcslen_default
> +# include "wcsmbs/wcslen.c"
> +IMPL (__wcslen_default, 1)
>  #endif
>
> -IMPL (STRLEN, 1)
> -
>
>  static void
>  do_one_test (impl_t *impl, const CHAR *s, size_t exp_len)
> --
> 2.34.1
>
  
Adhemerval Zanella Netto Feb. 6, 2023, 5:36 p.m. UTC | #2
On 03/02/23 20:30, Noah Goldstein wrote:
> On Thu, Feb 2, 2023 at 12:12 PM Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>>
>> Also remove the simple_STRLEN and builtin_strlen, which are not used
>> anywhere.
> Think I'm slightly opposed to removing the simple_* test implementations
> as they can be useful to hook in when debugging.

I think the simple_* test are really easy to come by if you need to debug
a string/memory implementation; and they do consume CPU cycles on testing
with no apparent gain.

>>
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>  string/test-strlen.c | 31 ++++++++++++++-----------------
>>  1 file changed, 14 insertions(+), 17 deletions(-)
>>
>> diff --git a/string/test-strlen.c b/string/test-strlen.c
>> index 81adf23737..0f98576f40 100644
>> --- a/string/test-strlen.c
>> +++ b/string/test-strlen.c
>> @@ -37,27 +37,24 @@
>>
>>  typedef size_t (*proto_t) (const CHAR *);
>>
>> -/* Naive implementation to verify results.  */
>> -size_t
>> -simple_STRLEN (const CHAR *s)
>> -{
>> -  const CHAR *p;
>> -
>> -  for (p = s; *p; ++p);
>> -  return p - s;
>> -}
>> +IMPL (STRLEN, 1)
>>
>> +/* Also check the generic implementation.  */
>> +#undef STRLEN
>> +#undef weak_alias
>> +#define weak_alias(a, b)
>> +#undef libc_hidden_builtin_def
>> +#define libc_hidden_builtin_def(a)
>>  #ifndef WIDE
>> -size_t
>> -builtin_strlen (const CHAR *p)
>> -{
>> -  return __builtin_strlen (p);
>> -}
>> -IMPL (builtin_strlen, 0)
>> +# define STRLEN __strlen_default
>> +# include "string/strlen.c"
>> +IMPL (__strlen_default, 1)
>> +#else
>> +# define WCSLEN __wcslen_default
>> +# include "wcsmbs/wcslen.c"
>> +IMPL (__wcslen_default, 1)
>>  #endif
>>
>> -IMPL (STRLEN, 1)
>> -
>>
>>  static void
>>  do_one_test (impl_t *impl, const CHAR *s, size_t exp_len)
>> --
>> 2.34.1
>>
  

Patch

diff --git a/string/test-strlen.c b/string/test-strlen.c
index 81adf23737..0f98576f40 100644
--- a/string/test-strlen.c
+++ b/string/test-strlen.c
@@ -37,27 +37,24 @@ 
 
 typedef size_t (*proto_t) (const CHAR *);
 
-/* Naive implementation to verify results.  */
-size_t
-simple_STRLEN (const CHAR *s)
-{
-  const CHAR *p;
-
-  for (p = s; *p; ++p);
-  return p - s;
-}
+IMPL (STRLEN, 1)
 
+/* Also check the generic implementation.  */
+#undef STRLEN
+#undef weak_alias
+#define weak_alias(a, b)
+#undef libc_hidden_builtin_def
+#define libc_hidden_builtin_def(a)
 #ifndef WIDE
-size_t
-builtin_strlen (const CHAR *p)
-{
-  return __builtin_strlen (p);
-}
-IMPL (builtin_strlen, 0)
+# define STRLEN __strlen_default
+# include "string/strlen.c"
+IMPL (__strlen_default, 1)
+#else
+# define WCSLEN __wcslen_default
+# include "wcsmbs/wcslen.c"
+IMPL (__wcslen_default, 1)
 #endif
 
-IMPL (STRLEN, 1)
-
 
 static void
 do_one_test (impl_t *impl, const CHAR *s, size_t exp_len)