public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] string: Hook up the default implementation on test-strchr
@ 2023-02-06 20:15 Adhemerval Zanella
0 siblings, 0 replies; only message in thread
From: Adhemerval Zanella @ 2023-02-06 20:15 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c19e3394a2a85cabc9a1a02551ec1c2d8085b148
commit c19e3394a2a85cabc9a1a02551ec1c2d8085b148
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Tue Jan 17 10:12:40 2023 -0300
string: Hook up the default implementation on test-strchr
Also remove the simple_STRCHR, which can be easily replaced.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Diff:
---
string/test-strchr.c | 53 +++++++++++++++++++++++++++++++++++++---------------
1 file changed, 38 insertions(+), 15 deletions(-)
diff --git a/string/test-strchr.c b/string/test-strchr.c
index 323c844d21..933fc0bbba 100644
--- a/string/test-strchr.c
+++ b/string/test-strchr.c
@@ -35,7 +35,6 @@
#ifndef WIDE
# ifdef USE_FOR_STRCHRNUL
# define STRCHR strchrnul
-# define simple_STRCHR simple_STRCHRNUL
# else
# define STRCHR strchr
# endif /* !USE_FOR_STRCHRNUL */
@@ -50,7 +49,6 @@
# include <wchar.h>
# ifdef USE_FOR_STRCHRNUL
# define STRCHR wcschrnul
-# define simple_STRCHR simple_WCSCHRNUL
# else
# define STRCHR wcschr
# endif /* !USE_FOR_STRCHRNUL */
@@ -72,20 +70,41 @@
typedef CHAR *(*proto_t) (const CHAR *, int);
-/* Naive implementation to verify results. */
-CHAR *
-simple_STRCHR (const CHAR *s, int c)
-{
- size_t n = STRLEN (s) + 1;
-
- while (n--)
- if (*s++ == (CHAR) c)
- return (CHAR *) s - 1;
- return NULLRET ((CHAR *) s - 1);
-}
-
IMPL (STRCHR, 1)
+/* Also check the generic implementation. */
+#undef STRCHR
+#undef weak_alias
+#define weak_alias(a, b)
+#undef libc_hidden_builtin_def
+#define libc_hidden_builtin_def(a)
+#undef libc_hidden_def
+#define libc_hidden_def(a)
+#undef libc_hidden_weak
+#define libc_hidden_weak(a)
+#ifndef WIDE
+# define STRCHRNUL __strchrnul_default
+# include "string/strchrnul.c"
+# ifndef USE_FOR_STRCHRNUL
+# define STRCHR __strchr_default
+# include "string/strchr.c"
+# define STRCHR_DEFAULT STRCHR
+# else
+# define STRCHR_DEFAULT STRCHRNUL
+# endif
+#else
+# ifndef USE_FOR_STRCHRNUL
+# define WCSCHR __wcschr_default
+# include "wcsmbs/wcschr.c"
+# define STRCHR_DEFAULT WCSCHR
+# else
+# define WCSCHRNUL __wcschrnul_default
+# include "wcsmbs/wcschrnul.c"
+# define STRCHR_DEFAULT WCSCHRNUL
+# endif
+#endif
+IMPL (STRCHR_DEFAULT, 1)
+
static int
check_result (impl_t *impl, const CHAR *s, int c, const CHAR *exp_res)
{
@@ -219,7 +238,11 @@ check1 (void)
{
CHAR s[] __attribute__((aligned(16))) = L ("\xff");
CHAR c = L ('\xfe');
- CHAR *exp_result = simple_STRCHR (s, c);
+#ifndef USE_FOR_STRCHRNUL
+ CHAR *exp_result = NULL;
+#else
+ CHAR *exp_result = s + STRLEN (s);
+#endif
FOR_EACH_IMPL (impl, 0)
check_result (impl, s, c, exp_result);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-06 20:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-06 20:15 [glibc] string: Hook up the default implementation on test-strchr Adhemerval Zanella
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).