]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - benchtests/bench-strcpy.c
support: Expose sbindir as support_sbindir_prefix
[thirdparty/glibc.git] / benchtests / bench-strcpy.c
index df23616ac2ed6384447ea3c5c940dbfd4816f62a..7a7cf4abb2873a555c5d8c3eb9d55d2f5c44df4e 100644 (file)
@@ -1,5 +1,5 @@
 /* Measure strcpy functions.
-   Copyright (C) 2013-2017 Free Software Foundation, Inc.
+   Copyright (C) 2013-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#define BIG_CHAR MAX_CHAR
+
 #ifdef WIDE
-# include <wchar.h>
-# define CHAR wchar_t
-# define UCHAR wchar_t
 # define sfmt "ls"
-# define BIG_CHAR WCHAR_MAX
 # define SMALL_CHAR 1273
-# define STRCMP wcscmp
-# define MEMCMP wmemcmp
-# define MEMSET wmemset
 #else
-# define CHAR char
-# define UCHAR unsigned char
 # define sfmt "s"
-# define BIG_CHAR CHAR_MAX
 # define SMALL_CHAR 127
-# define STRCMP strcmp
-# define MEMCMP memcmp
-# define MEMSET memset
 #endif
 
 #ifndef STRCPY_RESULT
 #  define TEST_NAME "strcpy"
 # else
 #  define TEST_NAME "wcscpy"
+#  define generic_strcpy generic_wcscpy
 # endif
-# include "bench-string.h"
-# ifndef WIDE
-#  define SIMPLE_STRCPY simple_strcpy
-#  define STRCPY strcpy
-# else
-#  define SIMPLE_STRCPY simple_wcscpy
-#  define STRCPY wcscpy
-# endif
-
-CHAR *SIMPLE_STRCPY (CHAR *, const CHAR *);
-
-IMPL (SIMPLE_STRCPY, 0)
-IMPL (STRCPY, 1)
+#include "bench-string.h"
 
 CHAR *
-SIMPLE_STRCPY (CHAR *dst, const CHAR *src)
+generic_strcpy (CHAR *dst, const CHAR *src)
 {
-  CHAR *ret = dst;
-  while ((*dst++ = *src++) != '\0');
-  return ret;
+  return MEMCPY (dst, src, STRLEN (src) + 1);
 }
+
+IMPL (STRCPY, 1)
+IMPL (generic_strcpy, 0)
+
 #endif
 
 typedef CHAR *(*proto_t) (CHAR *, const CHAR *);
@@ -115,11 +95,11 @@ do_test (size_t align1, size_t align2, size_t len, int max_char)
    but in wchar_ts, in bytes it will equal to align * (sizeof (wchar_t))
    len for wcschr here isn't in bytes but it's number of wchar_t symbols.  */
   align1 &= 7;
-  if ((align1 + len) * sizeof(CHAR) >= page_size)
+  if ((align1 + len) * sizeof (CHAR) >= page_size)
     return;
 
   align2 &= 7;
-  if ((align2 + len) * sizeof(CHAR) >= page_size)
+  if ((align2 + len) * sizeof (CHAR) >= page_size)
     return;
 
   s1 = (CHAR *) (buf1) + align1;
@@ -129,7 +109,8 @@ do_test (size_t align1, size_t align2, size_t len, int max_char)
     s1[i] = 32 + 23 * i % (max_char - 32);
   s1[len] = 0;
 
-  printf ("Length %4zd, alignments in bytes %2zd/%2zd:", len, align1 * sizeof(CHAR), align2 * sizeof(CHAR));
+  printf ("Length %4zd, alignments in bytes %2zd/%2zd:", len,
+         align1 * sizeof (CHAR), align2 * sizeof (CHAR));
 
   FOR_EACH_IMPL (impl, 0)
     do_one_test (impl, s2, s1, len);