[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commits] r23269 - in /fsf/trunk/libc: ./ benchtests/ debug/ iconvdata/ iconvdata/testdata/ include/ include/sys/ libidn/ locale/ loca...
- To: commits@xxxxxxxxxx
- Subject: [Commits] r23269 - in /fsf/trunk/libc: ./ benchtests/ debug/ iconvdata/ iconvdata/testdata/ include/ include/sys/ libidn/ locale/ loca...
- From: eglibc@xxxxxxxxxx
- Date: Wed, 12 Jun 2013 00:02:23 -0000
Author: eglibc
Date: Wed Jun 12 00:02:20 2013
New Revision: 23269
Log:
Import glibc-mainline for 2013-06-12
Added:
fsf/trunk/libc/benchtests/bench-bcopy-ifunc.c
fsf/trunk/libc/benchtests/bench-bcopy.c
fsf/trunk/libc/benchtests/bench-bzero-ifunc.c
fsf/trunk/libc/benchtests/bench-bzero.c
fsf/trunk/libc/benchtests/bench-memccpy-ifunc.c
fsf/trunk/libc/benchtests/bench-memccpy.c
fsf/trunk/libc/benchtests/bench-memchr-ifunc.c
fsf/trunk/libc/benchtests/bench-memchr.c
fsf/trunk/libc/benchtests/bench-memcmp-ifunc.c
fsf/trunk/libc/benchtests/bench-memcmp.c
fsf/trunk/libc/benchtests/bench-memcpy-ifunc.c
fsf/trunk/libc/benchtests/bench-memcpy.c
fsf/trunk/libc/benchtests/bench-memmem-ifunc.c
fsf/trunk/libc/benchtests/bench-memmem.c
fsf/trunk/libc/benchtests/bench-memmove-ifunc.c
fsf/trunk/libc/benchtests/bench-memmove.c
fsf/trunk/libc/benchtests/bench-mempcpy-ifunc.c
fsf/trunk/libc/benchtests/bench-mempcpy.c
fsf/trunk/libc/benchtests/bench-memset-ifunc.c
fsf/trunk/libc/benchtests/bench-memset.c
fsf/trunk/libc/benchtests/bench-rawmemchr-ifunc.c
fsf/trunk/libc/benchtests/bench-rawmemchr.c
fsf/trunk/libc/benchtests/bench-stpcpy-ifunc.c
fsf/trunk/libc/benchtests/bench-stpcpy.c
fsf/trunk/libc/benchtests/bench-stpcpy_chk-ifunc.c
fsf/trunk/libc/benchtests/bench-stpcpy_chk.c
fsf/trunk/libc/benchtests/bench-stpncpy-ifunc.c
fsf/trunk/libc/benchtests/bench-stpncpy.c
fsf/trunk/libc/benchtests/bench-strcasecmp-ifunc.c
fsf/trunk/libc/benchtests/bench-strcasecmp.c
fsf/trunk/libc/benchtests/bench-strcasestr-ifunc.c
fsf/trunk/libc/benchtests/bench-strcasestr.c
fsf/trunk/libc/benchtests/bench-strcat-ifunc.c
fsf/trunk/libc/benchtests/bench-strcat.c
fsf/trunk/libc/benchtests/bench-strchr-ifunc.c
fsf/trunk/libc/benchtests/bench-strchr.c
fsf/trunk/libc/benchtests/bench-strchrnul-ifunc.c
fsf/trunk/libc/benchtests/bench-strchrnul.c
fsf/trunk/libc/benchtests/bench-strcmp-ifunc.c
fsf/trunk/libc/benchtests/bench-strcmp.c
fsf/trunk/libc/benchtests/bench-strcpy-ifunc.c
fsf/trunk/libc/benchtests/bench-strcpy.c
fsf/trunk/libc/benchtests/bench-strcpy_chk-ifunc.c
fsf/trunk/libc/benchtests/bench-strcpy_chk.c
fsf/trunk/libc/benchtests/bench-strcspn-ifunc.c
fsf/trunk/libc/benchtests/bench-strcspn.c
fsf/trunk/libc/benchtests/bench-string.h
fsf/trunk/libc/benchtests/bench-strlen-ifunc.c
fsf/trunk/libc/benchtests/bench-strlen.c
fsf/trunk/libc/benchtests/bench-strncasecmp-ifunc.c
fsf/trunk/libc/benchtests/bench-strncasecmp.c
fsf/trunk/libc/benchtests/bench-strncat-ifunc.c
fsf/trunk/libc/benchtests/bench-strncat.c
fsf/trunk/libc/benchtests/bench-strncmp-ifunc.c
fsf/trunk/libc/benchtests/bench-strncmp.c
fsf/trunk/libc/benchtests/bench-strncpy-ifunc.c
fsf/trunk/libc/benchtests/bench-strncpy.c
fsf/trunk/libc/benchtests/bench-strnlen-ifunc.c
fsf/trunk/libc/benchtests/bench-strnlen.c
fsf/trunk/libc/benchtests/bench-strpbrk-ifunc.c
fsf/trunk/libc/benchtests/bench-strpbrk.c
fsf/trunk/libc/benchtests/bench-strrchr-ifunc.c
fsf/trunk/libc/benchtests/bench-strrchr.c
fsf/trunk/libc/benchtests/bench-strspn-ifunc.c
fsf/trunk/libc/benchtests/bench-strspn.c
fsf/trunk/libc/benchtests/bench-strstr-ifunc.c
fsf/trunk/libc/benchtests/bench-strstr.c
fsf/trunk/libc/iconvdata/BIG5HKSCS.precomposed
Removed:
fsf/trunk/libc/ports/sysdeps/powerpc/dl-procinfo.c
fsf/trunk/libc/ports/sysdeps/powerpc/dl-procinfo.h
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/NEWS
fsf/trunk/libc/benchtests/Makefile
fsf/trunk/libc/benchtests/README
fsf/trunk/libc/debug/test-strcpy_chk.c
fsf/trunk/libc/iconvdata/BIG5HKSCS.irreversible
fsf/trunk/libc/iconvdata/big5hkscs.c
fsf/trunk/libc/iconvdata/testdata/BIG5HKSCS
fsf/trunk/libc/iconvdata/testdata/BIG5HKSCS..UTF8
fsf/trunk/libc/include/sys/time.h
fsf/trunk/libc/include/time.h
fsf/trunk/libc/libidn/ChangeLog
fsf/trunk/libc/libidn/gunicomp.h
fsf/trunk/libc/libidn/gunidecomp.h
fsf/trunk/libc/libidn/nfkc.c
fsf/trunk/libc/libidn/rfc3454.c
fsf/trunk/libc/locale/iso-639.def
fsf/trunk/libc/localedata/ChangeLog
fsf/trunk/libc/localedata/charmaps/BIG5-HKSCS
fsf/trunk/libc/math/libm-test.inc
fsf/trunk/libc/nscd/connections.c
fsf/trunk/libc/nscd/netgroupcache.c
fsf/trunk/libc/nscd/nscd_netgroup.c
fsf/trunk/libc/po/zh_TW.po
fsf/trunk/libc/ports/ChangeLog.arm
fsf/trunk/libc/ports/ChangeLog.powerpc
fsf/trunk/libc/ports/sysdeps/arm/math-tests.h
fsf/trunk/libc/rt/clock_getcpuclockid.c
fsf/trunk/libc/rt/clock_getres.c
fsf/trunk/libc/rt/clock_gettime.c
fsf/trunk/libc/rt/clock_nanosleep.c
fsf/trunk/libc/rt/clock_settime.c
fsf/trunk/libc/string/test-memccpy.c
fsf/trunk/libc/string/test-memchr.c
fsf/trunk/libc/string/test-memcmp.c
fsf/trunk/libc/string/test-memcpy.c
fsf/trunk/libc/string/test-memmem.c
fsf/trunk/libc/string/test-memmove.c
fsf/trunk/libc/string/test-memset.c
fsf/trunk/libc/string/test-rawmemchr.c
fsf/trunk/libc/string/test-strcasecmp.c
fsf/trunk/libc/string/test-strcasestr.c
fsf/trunk/libc/string/test-strcat.c
fsf/trunk/libc/string/test-strchr.c
fsf/trunk/libc/string/test-strcmp.c
fsf/trunk/libc/string/test-strcpy.c
fsf/trunk/libc/string/test-string.h
fsf/trunk/libc/string/test-strlen.c
fsf/trunk/libc/string/test-strncasecmp.c
fsf/trunk/libc/string/test-strncat.c
fsf/trunk/libc/string/test-strncmp.c
fsf/trunk/libc/string/test-strncpy.c
fsf/trunk/libc/string/test-strnlen.c
fsf/trunk/libc/string/test-strpbrk.c
fsf/trunk/libc/string/test-strrchr.c
fsf/trunk/libc/string/test-strspn.c
fsf/trunk/libc/string/test-strstr.c
fsf/trunk/libc/sysdeps/generic/math-tests.h
fsf/trunk/libc/sysdeps/posix/clock_getres.c
fsf/trunk/libc/sysdeps/powerpc/dl-procinfo.c
fsf/trunk/libc/sysdeps/powerpc/dl-procinfo.h
fsf/trunk/libc/sysdeps/unix/clock_gettime.c
fsf/trunk/libc/sysdeps/unix/clock_nanosleep.c
fsf/trunk/libc/sysdeps/unix/clock_settime.c
fsf/trunk/libc/sysdeps/unix/sysv/linux/clock_getcpuclockid.c
fsf/trunk/libc/sysdeps/unix/sysv/linux/clock_nanosleep.c
Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Wed Jun 12 00:02:20 2013
@@ -1,3 +1,230 @@
+2013-06-11 Siddhesh Poyarekar <siddhesh@xxxxxxxxxx>
+
+ * locale/iso-639.def: Convert to UTF-8.
+
+2013-06-11 Joseph Myers <joseph@xxxxxxxxxxxxxxxx>
+
+ * sysdeps/generic/math-tests.h (EXCEPTION_TESTS_float): New macro.
+ (EXCEPTION_TESTS_double): Likewise.
+ (EXCEPTION_TESTS_long_double): Likewise.
+ (EXCEPTION_TESTS): Likewise.
+ * math/libm-test.inc (test_exceptions): Only test exceptions if
+ EXCEPTION_TESTS (FLOAT).
+
+2013-06-11 Siddhesh Poyarekar <siddhesh@xxxxxxxxxx>
+
+ * benchtests/Makefile (string-bench): Add strcpy_chk and
+ stpcpy_chk.
+ * benchtests/bench-stpcpy_chk-ifunc.c: New file.
+ * benchtests/bench-stpcpy_chk.c: New file.
+ * benchtests/bench-strcpy_chk-ifunc.c: New file.
+ * benchtests/bench-strcpy_chk.c: New file.
+ * debug/test-strcpy_chk.c (do_one_test): Remove HP_TIMING
+ code.
+ (do_test): Likewise.
+
+2013-06-11 Ryan S. Arnold <rsa@xxxxxxxxxxxxxxxxxx>
+
+ * sysdeps/powerpc/dl-procinfo.c (_dl_powerpc_platforms): Add ppc405,
+ ppc440, ppc464, and ppc476, merging from ports/ dl-procinfo.c.
+ * sysdeps/powerpc/dl-procinfo.h: Fix whitespace by correcting spaces
+ with tabs where appropriate.
+ [PPC_PLATFORM_PPC405]: Define new platform merging from ports/
+ dl-procinfo.h.
+ [PPC_PLATFORM_PPC440]: Likewise.
+ [PPC_PLATFORM_PPC464]: Likewise.
+ [PPC_PLATFORM_PPC476]: Likewise.
+ (_dl_string_platform): Add support for detecting ppc405, ppc440,
+ ppc464, and ppc476 platform strings merging from ports/
+ dl-procinfo.h.
+
+2013-06-11 Andreas Schwab <schwab@xxxxxxx>
+
+ [BZ #14991]
+ * iconvdata/big5hkscs.c (big5hkscs_to_ucs, from_ucs4)
+ (from_ucs4_idx): Regenerate.
+ (MIN_NEEDED_FROM, MAX_NEEDED_FROM, MIN_NEEDED_TO): Remove macros.
+ (FROM_LOOP_MIN_NEEDED_FROM, FROM_LOOP_MAX_NEEDED_FROM)
+ (FROM_LOOP_MIN_NEEDED_TO, FROM_LOOP_MAX_NEEDED_TO)
+ (TO_LOOP_MIN_NEEDED_FROM, TO_LOOP_MAX_NEEDED_FROM)
+ (TO_LOOP_MIN_NEEDED_TO, TO_LOOP_MAX_NEEDED_TO, PREPARE_LOOP)
+ (EXTRA_LOOP_ARGS, SAVE_RESET_STATE, EMIT_SHIFT_TO_INIT)
+ (EXTRA_LOOP_DECLS, MAX_NEEDED_OUTPUT): New macros.
+ (MIN_NEEDED_INPUT, MAX_NEEDED_INPUT, MIN_NEEDED_OUTPUT): Define
+ from FROM_LOOP and TO_LOOP specific macros.
+ (BODY): Handle combining characters.
+ * iconvdata/BIG5HKSCS.irreversible: Update.
+ * iconvdata/BIG5HKSCS.precomposed: New file.
+ * iconvdata/testdata/BIG5HKSCS: Regenerate to cover all assigned
+ characters.
+ * iconvdata/testdata/BIG5HKSCS..UTF8: Update.
+
+2013-06-11 Siddhesh Poyarekar <siddhesh@xxxxxxxxxx>
+
+ * include/sys/time.h: Fix indentation and add copyright header.
+
+ * string/test-memccpy.c (do_one_test): Remove HP_TIMING code.
+ (do_test): Likewise.
+ * string/test-memchr.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-memcmp.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-memcpy.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-memmem.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ (do_random_tests): Likewise.
+ * string/test-memmove.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-memset.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-rawmemchr.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-strcasecmp.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-strcasestr.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-strcat.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-strchr.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-strcmp.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-strcpy.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-string.h: Likewise.
+ (test_init): Likewise.
+ * string/test-strlen.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-strncasecmp.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-strncat.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-strncmp.c (do_one_test): Likewise.
+ (do_test_limit): Likewise.
+ (do_test): Likewise.
+ * string/test-strncpy.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-strnlen.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-strpbrk.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-strrchr.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-strspn.c (do_one_test): Likewise.
+ (do_test): Likewise.
+ * string/test-strstr.c (do_one_test): Likewise.
+ (do_test): Likewise.
+
+ * benchtests/Makefile (string-bench): Add string benchmarks.
+ * benchtests/bench-bcopy-ifunc.c: New file.
+ * benchtests/bench-bcopy.c: New file.
+ * benchtests/bench-bzero-ifunc.c: New file.
+ * benchtests/bench-bzero.c: New file.
+ * benchtests/bench-memccpy-ifunc.c: New file.
+ * benchtests/bench-memccpy.c: New file.
+ * benchtests/bench-memchr-ifunc.c: New file.
+ * benchtests/bench-memchr.c: New file.
+ * benchtests/bench-memcmp-ifunc.c: New file.
+ * benchtests/bench-memcmp.c: New file.
+ * benchtests/bench-memmem-ifunc.c: New file.
+ * benchtests/bench-memmem.c: New file.
+ * benchtests/bench-memmove-ifunc.c: New file.
+ * benchtests/bench-memmove.c: New file.
+ * benchtests/bench-mempcpy-ifunc.c: New file.
+ * benchtests/bench-mempcpy.c: New file.
+ * benchtests/bench-memset-ifunc.c: New file.
+ * benchtests/bench-memset.c: New file.
+ * benchtests/bench-rawmemchr-ifunc.c: New file.
+ * benchtests/bench-rawmemchr.c: New file.
+ * benchtests/bench-stpcpy-ifunc.c: New file.
+ * benchtests/bench-stpcpy.c: New file.
+ * benchtests/bench-stpncpy-ifunc.c: New file.
+ * benchtests/bench-stpncpy.c: New file.
+ * benchtests/bench-strcasecmp-ifunc.c: New file.
+ * benchtests/bench-strcasecmp.c: New file.
+ * benchtests/bench-strcasestr-ifunc.c: New file.
+ * benchtests/bench-strcasestr.c: New file.
+ * benchtests/bench-strcat-ifunc.c: New file.
+ * benchtests/bench-strcat.c: New file.
+ * benchtests/bench-strchr-ifunc.c: New file.
+ * benchtests/bench-strchr.c: New file.
+ * benchtests/bench-strchrnul-ifunc.c: New file.
+ * benchtests/bench-strchrnul.c: New file.
+ * benchtests/bench-strcmp-ifunc.c: New file.
+ * benchtests/bench-strcmp.c: New file.
+ * benchtests/bench-strcpy-ifunc.c: New file.
+ * benchtests/bench-strcpy.c: New file.
+ * benchtests/bench-strcspn-ifunc.c: New file.
+ * benchtests/bench-strcspn.c: New file.
+ * benchtests/bench-strlen-ifunc.c: New file.
+ * benchtests/bench-strlen.c: New file.
+ * benchtests/bench-strncasecmp-ifunc.c: New file.
+ * benchtests/bench-strncasecmp.c: New file.
+ * benchtests/bench-strncat-ifunc.c: New file.
+ * benchtests/bench-strncat.c: New file.
+ * benchtests/bench-strncmp-ifunc.c: New file.
+ * benchtests/bench-strncmp.c: New file.
+ * benchtests/bench-strncpy-ifunc.c: New file.
+ * benchtests/bench-strncpy.c: New file.
+ * benchtests/bench-strnlen-ifunc.c: New file.
+ * benchtests/bench-strnlen.c: New file.
+ * benchtests/bench-strpbrk-ifunc.c: New file.
+ * benchtests/bench-strpbrk.c: New file.
+ * benchtests/bench-strrchr-ifunc.c: New file.
+ * benchtests/bench-strrchr.c: New file.
+ * benchtests/bench-strspn-ifunc.c: New file.
+ * benchtests/bench-strspn.c: New file.
+ * benchtests/bench-strstr-ifunc.c: New file.
+ * benchtests/bench-strstr.c: New file.
+
+ * benchtests/Makefile: Disable parallel execution of targets.
+ (string-bench): Add memcpy.
+ (benchset): New variable to store a list of benchmark sets.
+ (bench-func): Renamed from bench.
+ (bench-set): New target.
+ (bench): Depend on bench-func and bench-set.
+ * benchtests/README: Add section on benchmark sets.
+ * benchtests/bench-memcpy-ifunc.c: New file.
+ * benchtests/bench-memcpy.c: New file.
+ * benchtests/bench-string.h: New file.
+
+2013-06-11 Andreas Schwab <schwab@xxxxxxx>
+
+ [BZ #15577]
+ * nscd/connections.c (nscd_run_worker): Always zero-terminate key.
+ * nscd/netgroupcache.c (addgetnetgrentX): Properly handle absent
+ values in the triple.
+ * nscd/nscd_netgroup.c (__nscd_setnetgrent): Include zero
+ terminator in the group key.
+
+2013-06-11 Andreas Jaeger <aj@xxxxxxx>
+
+ * po/zh_TW.po: Update Chinese (traditional) translation from
+ translation project.
+
+2013-06-11 Siddhesh Poyarekar <siddhesh@xxxxxxxxxx>
+
+ * include/time.h (__clock_gettime): Add libc_hidden_proto.
+ * rt/clock_getcpuclockid.c (clock_getcpuclockid): Rename to
+ __clock_getcpuclockid. Add weak_alias and libc_hidden_def.
+ * sysdeps/unix/sysv/linux/clock_getcpuclockid.c
+ (clock_getcpuclockid): Likewise.
+ * rt/clock_getres.c (clock_getres): Rename to __clock_getres.
+ Add weak_alias and libc_hidden_def.
+ * sysdeps/posix/clock_getres.c (clock_getres): Likewise.
+ * rt/clock_gettime.c (clock_gettime): Rename to
+ __clock_gettime. Add weak_alias and libc_hidden_def.
+ * sysdeps/unix/clock_gettime.c (clock_gettime): Likewise.
+ * rt/clock_nanosleep.c (clock_nanosleep): Rename to
+ __clock_nanosleep. Add weak_alias and libc_hidden_def.
+ * sysdeps/unix/clock_nanosleep.c (clock_nanosleep): Likewise.
+ * sysdeps/unix/sysv/linux/clock_nanosleep.c (clock_nanosleep):
+ Likewise.
+ * rt/clock_settime.c (clock_settime): Rename to
+ __clock_settime. Add weak_alias and libc_hidden_def.
+ * sysdeps/unix/clock_settime.c (clock_settime): Likewise.
+
2013-06-10 Joseph Myers <joseph@xxxxxxxxxxxxxxxx>
* mach/err_boot.sub: Remove trailing whitespace.
Modified: fsf/trunk/libc/NEWS
==============================================================================
--- fsf/trunk/libc/NEWS (original)
+++ fsf/trunk/libc/NEWS Wed Jun 12 00:02:20 2013
@@ -12,14 +12,14 @@
2546, 2560, 5159, 6809, 10060, 10062, 10357, 10686, 11120, 11561, 12387,
12723, 13550, 13889, 13951, 13988, 14142, 14176, 14200, 14256, 14280,
14293, 14317, 14327, 14478, 14496, 14582, 14686, 14812, 14888, 14894,
- 14908, 14920, 14952, 14964, 14981, 14982, 14985, 14994, 14996, 15000,
- 15003, 15006, 15007, 15014, 15020, 15023, 15036, 15054, 15055, 15062,
- 15078, 15084, 15085, 15086, 15100, 15160, 15214, 15221, 15232, 15234,
- 15283, 15285, 15287, 15304, 15305, 15307, 15309, 15327, 15330, 15335,
- 15336, 15337, 15339, 15342, 15346, 15359, 15361, 15366, 15380, 15381,
- 15394, 15395, 15405, 15406, 15409, 15416, 15418, 15419, 15423, 15424,
- 15426, 15429, 15441, 15442, 15448, 15465, 15480, 15485, 15488, 15490,
- 15493, 15497, 15506, 15529, 15536, 15553, 15583.
+ 14908, 14920, 14952, 14964, 14981, 14982, 14985, 14991, 14994, 14996,
+ 15000, 15003, 15006, 15007, 15014, 15020, 15023, 15036, 15054, 15055,
+ 15062, 15078, 15084, 15085, 15086, 15100, 15160, 15214, 15221, 15232,
+ 15234, 15283, 15285, 15287, 15304, 15305, 15307, 15309, 15327, 15330,
+ 15335, 15336, 15337, 15339, 15342, 15346, 15359, 15361, 15366, 15380,
+ 15381, 15394, 15395, 15405, 15406, 15409, 15416, 15418, 15419, 15423,
+ 15424, 15426, 15429, 15441, 15442, 15448, 15465, 15480, 15485, 15488,
+ 15490, 15493, 15497, 15506, 15529, 15536, 15553, 15577, 15583.
* CVE-2013-0242 Buffer overrun in regexp matcher has been fixed (Bugzilla
#15078).
Modified: fsf/trunk/libc/benchtests/Makefile
==============================================================================
--- fsf/trunk/libc/benchtests/Makefile (original)
+++ fsf/trunk/libc/benchtests/Makefile Wed Jun 12 00:02:20 2013
@@ -22,6 +22,17 @@
subdir := benchtests
bench := acos acosh asin asinh atan atanh cos cosh exp log modf pow rint sin \
sinh tan tanh
+
+# String function benchmarks.
+string-bench := bcopy bzero memccpy memchr memcmp memmem memmove mempcpy \
+ memset rawmemchr stpcpy stpncpy strcasecmp strcasestr strcat \
+ strchr strchrnul strcmp strcpy strcspn strlen strncasecmp \
+ strncat strncmp strncpy strnlen strpbrk strrchr strspn strstr \
+ strcpy_chk stpcpy_chk
+string-bench-ifunc := $(addsuffix -ifunc, $(string-bench))
+string-bench-all := $(string-bench) $(string-bench-ifunc)
+
+benchset := $(string-bench-all)
acos-ARGLIST = double
acos-RET = double
@@ -92,10 +103,15 @@
# Rules to build and execute the benchmarks. Do not put any benchmark
# parameters beyond this point.
+# We don't want the benchmark programs to run in parallel since that could
+# affect their performance.
+.NOTPARALLEL:
+
include ../Makeconfig
include ../Rules
binaries-bench := $(addprefix $(objpfx)bench-,$(bench))
+binaries-benchset := $(addprefix $(objpfx)bench-,$(benchset))
# The default duration: 10 seconds.
ifndef BENCH_DURATION
@@ -112,7 +128,7 @@
# This makes sure CPPFLAGS-nonlib and CFLAGS-nonlib are passed
# for all these modules.
-cpp-srcs-left := $(binaries-bench:=.c)
+cpp-srcs-left := $(binaries-benchset:=.c) $(binaries-bench:=.c)
lib := nonlib
include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
@@ -124,8 +140,17 @@
bench-clean:
rm -f $(binaries-bench) $(addsuffix .o,$(binaries-bench))
+ rm -f $(binaries-benchset) $(addsuffix .o,$(binaries-benchset))
-bench: $(binaries-bench)
+bench: bench-set bench-func
+
+bench-set: $(binaries-benchset)
+ for run in $^; do \
+ echo "Running $${run}"; \
+ $(run-bench) > $${run}.out; \
+ done
+
+bench-func: $(binaries-bench)
{ for run in $^; do \
echo "Running $${run}" >&2; \
$(run-bench); \
@@ -135,7 +160,7 @@
fi; \
mv -f $(objpfx)bench.out-tmp $(objpfx)bench.out
-$(binaries-bench): %: %.o \
+$(binaries-bench) $(binaries-benchset): %: %.o \
$(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
$(+link)
Modified: fsf/trunk/libc/benchtests/README
==============================================================================
--- fsf/trunk/libc/benchtests/README (original)
+++ fsf/trunk/libc/benchtests/README Wed Jun 12 00:02:20 2013
@@ -72,3 +72,18 @@
See the pow-inputs file for an example of what such a partitioned input file
would look like.
+
+Benchmark Sets:
+==============
+
+In addition to standard benchmarking of functions, one may also generate
+custom outputs for a set of functions. This is currently used by string
+function benchmarks where the aim is to compare performance between
+implementations at various alignments and for various sizes.
+
+To add a benchset for `foo':
+
+- Add `foo' to the benchset variable.
+- Write your bench-foo.c that prints out the measurements to stdout.
+- On execution, a bench-foo.out is created in $(objpfx) with the contents of
+ stdout.
Added: fsf/trunk/libc/benchtests/bench-bcopy-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-bcopy-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-bcopy-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of bcopy function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-bcopy.c"
Added: fsf/trunk/libc/benchtests/bench-bcopy.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-bcopy.c (added)
+++ fsf/trunk/libc/benchtests/bench-bcopy.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure bcopy functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_BCOPY
+#include "bench-memmove.c"
Added: fsf/trunk/libc/benchtests/bench-bzero-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-bzero-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-bzero-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of bzero function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-bzero.c"
Added: fsf/trunk/libc/benchtests/bench-bzero.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-bzero.c (added)
+++ fsf/trunk/libc/benchtests/bench-bzero.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,19 @@
+/* Measure bzero functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+#define TEST_BZERO
+#include "bench-memset.c"
Added: fsf/trunk/libc/benchtests/bench-memccpy-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-memccpy-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-memccpy-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of memccpy function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-memccpy.c"
Added: fsf/trunk/libc/benchtests/bench-memccpy.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-memccpy.c (added)
+++ fsf/trunk/libc/benchtests/bench-memccpy.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,169 @@
+/* Measure memccpy functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_MAIN
+#define TEST_NAME "memccpy"
+#include "bench-string.h"
+
+void *simple_memccpy (void *, const void *, int, size_t);
+void *stupid_memccpy (void *, const void *, int, size_t);
+
+IMPL (stupid_memccpy, 0)
+IMPL (simple_memccpy, 0)
+IMPL (memccpy, 1)
+
+void *
+simple_memccpy (void *dst, const void *src, int c, size_t n)
+{
+ const char *s = src;
+ char *d = dst;
+
+ while (n-- > 0)
+ if ((*d++ = *s++) == (char) c)
+ return d;
+
+ return NULL;
+}
+
+void *
+stupid_memccpy (void *dst, const void *src, int c, size_t n)
+{
+ void *p = memchr (src, c, n);
+
+ if (p != NULL)
+ return mempcpy (dst, src, p - src + 1);
+
+ memcpy (dst, src, n);
+ return NULL;
+}
+
+typedef void *(*proto_t) (void *, const void *, int c, size_t);
+
+static void
+do_one_test (impl_t *impl, void *dst, const void *src, int c, size_t len,
+ size_t n)
+{
+ void *expect = len > n ? NULL : (char *) dst + len;
+ if (CALL (impl, dst, src, c, n) != expect)
+ {
+ error (0, 0, "Wrong result in function %s %p %p", impl->name,
+ CALL (impl, dst, src, c, n), expect);
+ ret = 1;
+ return;
+ }
+
+ if (memcmp (dst, src, len > n ? n : len) != 0)
+ {
+ error (0, 0, "Wrong result in function %s", impl->name);
+ ret = 1;
+ return;
+ }
+
+ if (HP_TIMING_AVAIL)
+ {
+ hp_timing_t start __attribute__ ((unused));
+ hp_timing_t stop __attribute__ ((unused));
+ hp_timing_t best_time = ~ (hp_timing_t) 0;
+ size_t i;
+
+ for (i = 0; i < 32; ++i)
+ {
+ HP_TIMING_NOW (start);
+ CALL (impl, dst, src, c, n);
+ HP_TIMING_NOW (stop);
+ HP_TIMING_BEST (best_time, start, stop);
+ }
+
+ printf ("\t%zd", (size_t) best_time);
+ }
+}
+
+static void
+do_test (size_t align1, size_t align2, int c, size_t len, size_t n,
+ int max_char)
+{
+ size_t i;
+ char *s1, *s2;
+
+ align1 &= 7;
+ if (align1 + len >= page_size)
+ return;
+
+ align2 &= 7;
+ if (align2 + len >= page_size)
+ return;
+
+ s1 = (char *) (buf1 + align1);
+ s2 = (char *) (buf2 + align2);
+
+ for (i = 0; i < len - 1; ++i)
+ {
+ s1[i] = 32 + 23 * i % (max_char - 32);
+ if (s1[i] == (char) c)
+ --s1[i];
+ }
+ s1[len - 1] = c;
+ for (i = len; i + align1 < page_size && i < len + 64; ++i)
+ s1[i] = 32 + 32 * i % (max_char - 32);
+
+ if (HP_TIMING_AVAIL)
+ printf ("Length %4zd, n %4zd, char %d, alignment %2zd/%2zd:", len, n, c, align1, align2);
+
+ FOR_EACH_IMPL (impl, 0)
+ do_one_test (impl, s2, s1, c, len, n);
+
+ if (HP_TIMING_AVAIL)
+ putchar ('\n');
+}
+
+int
+test_main (void)
+{
+ size_t i;
+
+ test_init ();
+
+ printf ("%28s", "");
+ FOR_EACH_IMPL (impl, 0)
+ printf ("\t%s", impl->name);
+ putchar ('\n');
+
+ for (i = 1; i < 8; ++i)
+ {
+ do_test (i, i, 12, 16, 16, 127);
+ do_test (i, i, 23, 16, 16, 255);
+ do_test (i, 2 * i, 28, 16, 16, 127);
+ do_test (2 * i, i, 31, 16, 16, 255);
+ do_test (8 - i, 2 * i, 1, 1 << i, 2 << i, 127);
+ do_test (2 * i, 8 - i, 17, 2 << i, 1 << i, 127);
+ do_test (8 - i, 2 * i, 0, 1 << i, 2 << i, 255);
+ do_test (2 * i, 8 - i, i, 2 << i, 1 << i, 255);
+ }
+
+ for (i = 1; i < 8; ++i)
+ {
+ do_test (0, 0, i, 4 << i, 8 << i, 127);
+ do_test (0, 0, i, 16 << i, 8 << i, 127);
+ do_test (8 - i, 2 * i, i, 4 << i, 8 << i, 127);
+ do_test (8 - i, 2 * i, i, 16 << i, 8 << i, 127);
+ }
+
+ return ret;
+}
+
+#include "../test-skeleton.c"
Added: fsf/trunk/libc/benchtests/bench-memchr-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-memchr-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-memchr-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of memchr function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-memchr.c"
Added: fsf/trunk/libc/benchtests/bench-memchr.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-memchr.c (added)
+++ fsf/trunk/libc/benchtests/bench-memchr.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,137 @@
+/* Measure memchr functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_MAIN
+#define TEST_NAME "memchr"
+#include "bench-string.h"
+
+typedef char *(*proto_t) (const char *, int, size_t);
+char *simple_memchr (const char *, int, size_t);
+
+IMPL (simple_memchr, 0)
+IMPL (memchr, 1)
+
+char *
+simple_memchr (const char *s, int c, size_t n)
+{
+ while (n--)
+ if (*s++ == (char) c)
+ return (char *) s - 1;
+ return NULL;
+}
+
+static void
+do_one_test (impl_t *impl, const char *s, int c, size_t n, char *exp_res)
+{
+ char *res = CALL (impl, s, c, n);
+ if (res != exp_res)
+ {
+ error (0, 0, "Wrong result in function %s %p %p", impl->name,
+ res, exp_res);
+ ret = 1;
+ return;
+ }
+
+ if (HP_TIMING_AVAIL)
+ {
+ hp_timing_t start __attribute ((unused));
+ hp_timing_t stop __attribute ((unused));
+ hp_timing_t best_time = ~ (hp_timing_t) 0;
+ size_t i;
+
+ for (i = 0; i < 32; ++i)
+ {
+ HP_TIMING_NOW (start);
+ CALL (impl, s, c, n);
+ HP_TIMING_NOW (stop);
+ HP_TIMING_BEST (best_time, start, stop);
+ }
+
+ printf ("\t%zd", (size_t) best_time);
+ }
+}
+
+static void
+do_test (size_t align, size_t pos, size_t len, int seek_char)
+{
+ size_t i;
+ char *result;
+
+ align &= 7;
+ if (align + len >= page_size)
+ return;
+
+ for (i = 0; i < len; ++i)
+ {
+ buf1[align + i] = 1 + 23 * i % 127;
+ if (buf1[align + i] == seek_char)
+ buf1[align + i] = seek_char + 1;
+ }
+ buf1[align + len] = 0;
+
+ if (pos < len)
+ {
+ buf1[align + pos] = seek_char;
+ buf1[align + len] = -seek_char;
+ result = (char *) (buf1 + align + pos);
+ }
+ else
+ {
+ result = NULL;
+ buf1[align + len] = seek_char;
+ }
+
+ if (HP_TIMING_AVAIL)
+ printf ("Length %4zd, alignment %2zd:", pos, align);
+
+ FOR_EACH_IMPL (impl, 0)
+ do_one_test (impl, (char *) (buf1 + align), seek_char, len, result);
+
+ if (HP_TIMING_AVAIL)
+ putchar ('\n');
+}
+
+int
+test_main (void)
+{
+ size_t i;
+
+ test_init ();
+
+ printf ("%20s", "");
+ FOR_EACH_IMPL (impl, 0)
+ printf ("\t%s", impl->name);
+ putchar ('\n');
+
+ for (i = 1; i < 8; ++i)
+ {
+ do_test (0, 16 << i, 2048, 23);
+ do_test (i, 64, 256, 23);
+ do_test (0, 16 << i, 2048, 0);
+ do_test (i, 64, 256, 0);
+ }
+ for (i = 1; i < 32; ++i)
+ {
+ do_test (0, i, i + 1, 23);
+ do_test (0, i, i + 1, 0);
+ }
+
+ return ret;
+}
+
+#include "../test-skeleton.c"
Added: fsf/trunk/libc/benchtests/bench-memcmp-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-memcmp-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-memcmp-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of memcmp function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-memcmp.c"
Added: fsf/trunk/libc/benchtests/bench-memcmp.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-memcmp.c (added)
+++ fsf/trunk/libc/benchtests/bench-memcmp.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,183 @@
+/* Measure memcmp functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_MAIN
+#ifdef WIDE
+# define TEST_NAME "wmemcmp"
+#else
+# define TEST_NAME "memcmp"
+#endif
+#include "bench-string.h"
+#ifdef WIDE
+# include <inttypes.h>
+# include <wchar.h>
+
+# define MEMCMP wmemcmp
+# define MEMCPY wmemcpy
+# define SIMPLE_MEMCMP simple_wmemcmp
+# define CHAR wchar_t
+# define UCHAR wchar_t
+# define CHARBYTES 4
+# define CHAR__MIN WCHAR_MIN
+# define CHAR__MAX WCHAR_MAX
+int
+simple_wmemcmp (const wchar_t *s1, const wchar_t *s2, size_t n)
+{
+ int ret = 0;
+ /* Warning!
+ wmemcmp has to use SIGNED comparison for elements.
+ memcmp has to use UNSIGNED comparison for elemnts.
+ */
+ while (n-- && (ret = *s1 < *s2 ? -1 : *s1 == *s2 ? 0 : 1) == 0) {s1++; s2++;}
+ return ret;
+}
+#else
+# include <limits.h>
+
+# define MEMCMP memcmp
+# define MEMCPY memcpy
+# define SIMPLE_MEMCMP simple_memcmp
+# define CHAR char
+# define MAX_CHAR 255
+# define UCHAR unsigned char
+# define CHARBYTES 1
+# define CHAR__MIN CHAR_MIN
+# define CHAR__MAX CHAR_MAX
+
+int
+simple_memcmp (const char *s1, const char *s2, size_t n)
+{
+ int ret = 0;
+
+ while (n-- && (ret = *(unsigned char *) s1++ - *(unsigned char *) s2++) == 0);
+ return ret;
+}
+#endif
+
+typedef int (*proto_t) (const CHAR *, const CHAR *, size_t);
+
+IMPL (SIMPLE_MEMCMP, 0)
+IMPL (MEMCMP, 1)
+
+static void
+do_one_test (impl_t *impl, const CHAR *s1, const CHAR *s2, size_t len,
+ int exp_result)
+{
+ if (HP_TIMING_AVAIL)
+ {
+ hp_timing_t start __attribute ((unused));
+ hp_timing_t stop __attribute ((unused));
+ hp_timing_t best_time = ~ (hp_timing_t) 0;
+ size_t i;
+
+ for (i = 0; i < 32; ++i)
+ {
+ HP_TIMING_NOW (start);
+ CALL (impl, s1, s2, len);
+ HP_TIMING_NOW (stop);
+ HP_TIMING_BEST (best_time, start, stop);
+ }
+
+ printf ("\t%zd", (size_t) best_time);
+ }
+}
+
+static void
+do_test (size_t align1, size_t align2, size_t len, int exp_result)
+{
+ size_t i;
+ CHAR *s1, *s2;
+
+ if (len == 0)
+ return;
+
+ align1 &= 63;
+ if (align1 + (len + 1) * CHARBYTES >= page_size)
+ return;
+
+ align2 &= 63;
+ if (align2 + (len + 1) * CHARBYTES >= page_size)
+ return;
+
+ s1 = (CHAR *) (buf1 + align1);
+ s2 = (CHAR *) (buf2 + align2);
+
+ for (i = 0; i < len; i++)
+ s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % CHAR__MAX;
+
+ s1[len] = align1;
+ s2[len] = align2;
+ s2[len - 1] -= exp_result;
+
+ if (HP_TIMING_AVAIL)
+ printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
+
+ FOR_EACH_IMPL (impl, 0)
+ do_one_test (impl, s1, s2, len, exp_result);
+
+ if (HP_TIMING_AVAIL)
+ putchar ('\n');
+}
+
+int
+test_main (void)
+{
+ size_t i;
+
+ test_init ();
+
+ printf ("%23s", "");
+ FOR_EACH_IMPL (impl, 0)
+ printf ("\t%s", impl->name);
+ putchar ('\n');
+
+ for (i = 1; i < 16; ++i)
+ {
+ do_test (i * CHARBYTES, i * CHARBYTES, i, 0);
+ do_test (i * CHARBYTES, i * CHARBYTES, i, 1);
+ do_test (i * CHARBYTES, i * CHARBYTES, i, -1);
+ }
+
+ for (i = 0; i < 16; ++i)
+ {
+ do_test (0, 0, i, 0);
+ do_test (0, 0, i, 1);
+ do_test (0, 0, i, -1);
+ }
+
+ for (i = 1; i < 10; ++i)
+ {
+ do_test (0, 0, 2 << i, 0);
+ do_test (0, 0, 2 << i, 1);
+ do_test (0, 0, 2 << i, -1);
+ do_test (0, 0, 16 << i, 0);
+ do_test ((8 - i) * CHARBYTES, (2 * i) * CHARBYTES, 16 << i, 0);
+ do_test (0, 0, 16 << i, 1);
+ do_test (0, 0, 16 << i, -1);
+ }
+
+ for (i = 1; i < 8; ++i)
+ {
+ do_test (i * CHARBYTES, 2 * (i * CHARBYTES), 8 << i, 0);
+ do_test (i * CHARBYTES, 2 * (i * CHARBYTES), 8 << i, 1);
+ do_test (i * CHARBYTES, 2 * (i * CHARBYTES), 8 << i, -1);
+ }
+
+ return ret;
+}
+#include "../test-skeleton.c"
Added: fsf/trunk/libc/benchtests/bench-memcpy-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-memcpy-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-memcpy-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of memcpy function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-memcpy.c"
Added: fsf/trunk/libc/benchtests/bench-memcpy.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-memcpy.c (added)
+++ fsf/trunk/libc/benchtests/bench-memcpy.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,163 @@
+/* Measure memcpy functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef MEMCPY_RESULT
+# define MEMCPY_RESULT(dst, len) dst
+# define MIN_PAGE_SIZE 131072
+# define TEST_MAIN
+# define TEST_NAME "memcpy"
+# include "bench-string.h"
+
+char *simple_memcpy (char *, const char *, size_t);
+char *builtin_memcpy (char *, const char *, size_t);
+
+IMPL (simple_memcpy, 0)
+IMPL (builtin_memcpy, 0)
+IMPL (memcpy, 1)
+
+char *
+simple_memcpy (char *dst, const char *src, size_t n)
+{
+ char *ret = dst;
+ while (n--)
+ *dst++ = *src++;
+ return ret;
+}
+
+char *
+builtin_memcpy (char *dst, const char *src, size_t n)
+{
+ return __builtin_memcpy (dst, src, n);
+}
+#endif
+
+typedef char *(*proto_t) (char *, const char *, size_t);
+
+static void
+do_one_test (impl_t *impl, char *dst, const char *src,
+ size_t len)
+{
+ if (CALL (impl, dst, src, len) != MEMCPY_RESULT (dst, len))
+ {
+ error (0, 0, "Wrong result in function %s %p %p", impl->name,
+ CALL (impl, dst, src, len), MEMCPY_RESULT (dst, len));
+ ret = 1;
+ return;
+ }
+
+ if (memcmp (dst, src, len) != 0)
+ {
+ error (0, 0, "Wrong result in function %s dst \"%s\" src \"%s\"",
+ impl->name, dst, src);
+ ret = 1;
+ return;
+ }
+
+ if (HP_TIMING_AVAIL)
+ {
+ hp_timing_t start __attribute ((unused));
+ hp_timing_t stop __attribute ((unused));
+ hp_timing_t best_time = ~ (hp_timing_t) 0;
+ size_t i;
+
+ for (i = 0; i < 32; ++i)
+ {
+ HP_TIMING_NOW (start);
+ CALL (impl, dst, src, len);
+ HP_TIMING_NOW (stop);
+ HP_TIMING_BEST (best_time, start, stop);
+ }
+
+ printf ("\t%zd", (size_t) best_time);
+ }
+}
+
+static void
+do_test (size_t align1, size_t align2, size_t len)
+{
+ size_t i, j;
+ char *s1, *s2;
+
+ align1 &= 63;
+ if (align1 + len >= page_size)
+ return;
+
+ align2 &= 63;
+ if (align2 + len >= page_size)
+ return;
+
+ s1 = (char *) (buf1 + align1);
+ s2 = (char *) (buf2 + align2);
+
+ for (i = 0, j = 1; i < len; i++, j += 23)
+ s1[i] = j;
+
+ if (HP_TIMING_AVAIL)
+ printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
+
+ FOR_EACH_IMPL (impl, 0)
+ do_one_test (impl, s2, s1, len);
+
+ if (HP_TIMING_AVAIL)
+ putchar ('\n');
+}
+
+int
+test_main (void)
+{
+ size_t i;
+
+ test_init ();
+
+ printf ("%23s", "");
+ FOR_EACH_IMPL (impl, 0)
+ printf ("\t%s", impl->name);
+ putchar ('\n');
+
+ for (i = 0; i < 18; ++i)
+ {
+ do_test (0, 0, 1 << i);
+ do_test (i, 0, 1 << i);
+ do_test (0, i, 1 << i);
+ do_test (i, i, 1 << i);
+ }
+
+ for (i = 0; i < 32; ++i)
+ {
+ do_test (0, 0, i);
+ do_test (i, 0, i);
+ do_test (0, i, i);
+ do_test (i, i, i);
+ }
+
+ for (i = 3; i < 32; ++i)
+ {
+ if ((i & (i - 1)) == 0)
+ continue;
+ do_test (0, 0, 16 * i);
+ do_test (i, 0, 16 * i);
+ do_test (0, i, 16 * i);
+ do_test (i, i, 16 * i);
+ }
+
+ do_test (0, 0, getpagesize ());
+
+ return ret;
+}
+
+#include "../test-skeleton.c"
Added: fsf/trunk/libc/benchtests/bench-memmem-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-memmem-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-memmem-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of memmem function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-memmem.c"
Added: fsf/trunk/libc/benchtests/bench-memmem.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-memmem.c (added)
+++ fsf/trunk/libc/benchtests/bench-memmem.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,172 @@
+/* Measure memmem functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_MAIN
+#define TEST_NAME "memmem"
+#define BUF1PAGES 20
+#define ITERATIONS 500
+#include "bench-string.h"
+
+typedef char *(*proto_t) (const void *, size_t, const void *, size_t);
+void *simple_memmem (const void *, size_t, const void *, size_t);
+
+IMPL (simple_memmem, 0)
+IMPL (memmem, 1)
+
+void *
+simple_memmem (const void *haystack, size_t haystack_len, const void *needle,
+ size_t needle_len)
+{
+ const char *begin;
+ const char *const last_possible
+ = (const char *) haystack + haystack_len - needle_len;
+
+ if (needle_len == 0)
+ /* The first occurrence of the empty string is deemed to occur at
+ the beginning of the string. */
+ return (void *) haystack;
+
+ /* Sanity check, otherwise the loop might search through the whole
+ memory. */
+ if (__builtin_expect (haystack_len < needle_len, 0))
+ return NULL;
+
+ for (begin = (const char *) haystack; begin <= last_possible; ++begin)
+ if (begin[0] == ((const char *) needle)[0] &&
+ !memcmp ((const void *) &begin[1],
+ (const void *) ((const char *) needle + 1),
+ needle_len - 1))
+ return (void *) begin;
+
+ return NULL;
+}
+
+static void
+do_one_test (impl_t *impl, const void *haystack, size_t haystack_len,
+ const void *needle, size_t needle_len, const void *expected)
+{
+ if (HP_TIMING_AVAIL)
+ {
+ hp_timing_t start __attribute ((unused));
+ hp_timing_t stop __attribute ((unused));
+ hp_timing_t best_time = ~ (hp_timing_t) 0;
+ size_t i;
+
+ for (i = 0; i < 32; ++i)
+ {
+ HP_TIMING_NOW (start);
+ CALL (impl, haystack, haystack_len, needle, needle_len);
+ HP_TIMING_NOW (stop);
+ HP_TIMING_BEST (best_time, start, stop);
+ }
+
+ printf ("\t%zd", (size_t) best_time);
+ }
+}
+
+static void
+do_test (const char *str, size_t len, size_t idx)
+{
+ char tmpbuf[len];
+
+ memcpy (tmpbuf, buf1 + idx, len);
+ memcpy (buf1 + idx, str, len);
+
+ if (HP_TIMING_AVAIL)
+ printf ("String %s, offset %zd:", str, idx);
+
+ FOR_EACH_IMPL (impl, 0)
+ do_one_test (impl, buf1, BUF1PAGES * page_size, str, len, buf1 + idx);
+
+ memcpy (buf1 + idx, tmpbuf, len);
+
+ if (HP_TIMING_AVAIL)
+ putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+ for (size_t n = 0; n < ITERATIONS; ++n)
+ {
+ char tmpbuf[32];
+
+ size_t shift = random () % 11;
+ size_t rel = random () % ((2 << (shift + 1)) * 64);
+ size_t idx = MIN ((2 << shift) * 64 + rel, BUF1PAGES * page_size - 2);
+ size_t len = random () % (sizeof (tmpbuf) - 1) + 1;
+ len = MIN (len, BUF1PAGES * page_size - idx - 1);
+ memcpy (tmpbuf, buf1 + idx, len);
+ for (size_t i = random () % len / 2 + 1; i > 0; --i)
+ {
+ size_t off = random () % len;
+ char ch = '0' + random () % 10;
+
+ buf1[idx + off] = ch;
+ }
+
+ if (HP_TIMING_AVAIL)
+ printf ("String %.*s, offset %zd:", (int) len, buf1 + idx, idx);
+
+ FOR_EACH_IMPL (impl, 0)
+ do_one_test (impl, buf1, BUF1PAGES * page_size, buf1 + idx, len,
+ buf1 + idx);
+
+ if (HP_TIMING_AVAIL)
+ putchar ('\n');
+
+ memcpy (buf1 + idx, tmpbuf, len);
+ }
+}
+
+static const char *const strs[] =
+ {
+ "00000", "00112233", "0123456789", "0000111100001111",
+ "00000111110000022222", "012345678901234567890",
+ "abc0", "aaaa0", "abcabc0"
+ };
+
+
+int
+test_main (void)
+{
+ size_t i;
+
+ test_init ();
+
+ printf ("%23s", "");
+ FOR_EACH_IMPL (impl, 0)
+ printf ("\t%s", impl->name);
+ putchar ('\n');
+
+ for (i = 0; i < BUF1PAGES * page_size; ++i)
+ buf1[i] = 60 + random () % 32;
+
+ for (i = 0; i < sizeof (strs) / sizeof (strs[0]); ++i)
+ for (size_t j = 0; j < 120; j += 7)
+ {
+ size_t len = strlen (strs[i]);
+
+ do_test (strs[i], len, j);
+ }
+
+ do_random_tests ();
+ return ret;
+}
+
+#include "../test-skeleton.c"
Added: fsf/trunk/libc/benchtests/bench-memmove-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-memmove-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-memmove-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of memmove function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-memmove.c"
Added: fsf/trunk/libc/benchtests/bench-memmove.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-memmove.c (added)
+++ fsf/trunk/libc/benchtests/bench-memmove.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,187 @@
+/* Measure memmove functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_MAIN
+#ifdef TEST_BCOPY
+# define TEST_NAME "bcopy"
+#else
+# define TEST_NAME "memmove"
+#endif
+#include "bench-string.h"
+
+char *simple_memmove (char *, const char *, size_t);
+
+#ifdef TEST_BCOPY
+typedef void (*proto_t) (const char *, char *, size_t);
+void simple_bcopy (const char *, char *, size_t);
+
+IMPL (simple_bcopy, 0)
+IMPL (bcopy, 1)
+
+void
+simple_bcopy (const char *src, char *dst, size_t n)
+{
+ simple_memmove (dst, src, n);
+}
+#else
+typedef char *(*proto_t) (char *, const char *, size_t);
+
+IMPL (simple_memmove, 0)
+IMPL (memmove, 1)
+#endif
+
+char *
+simple_memmove (char *dst, const char *src, size_t n)
+{
+ char *ret = dst;
+ if (src < dst)
+ {
+ dst += n;
+ src += n;
+ while (n--)
+ *--dst = *--src;
+ }
+ else
+ while (n--)
+ *dst++ = *src++;
+ return ret;
+}
+
+static void
+do_one_test (impl_t *impl, char *dst, char *src, const char *orig_src,
+ size_t len)
+{
+ memcpy (src, orig_src, len);
+#ifdef TEST_BCOPY
+ CALL (impl, src, dst, len);
+#else
+ char *res;
+
+ res = CALL (impl, dst, src, len);
+ if (res != dst)
+ {
+ error (0, 0, "Wrong result in function %s %p %p", impl->name,
+ res, dst);
+ ret = 1;
+ return;
+ }
+#endif
+
+ if (memcmp (dst, orig_src, len) != 0)
+ {
+ error (0, 0, "Wrong result in function %s dst \"%s\" src \"%s\"",
+ impl->name, dst, src);
+ ret = 1;
+ return;
+ }
+
+ if (HP_TIMING_AVAIL)
+ {
+ hp_timing_t start __attribute ((unused));
+ hp_timing_t stop __attribute ((unused));
+ hp_timing_t best_time = ~ (hp_timing_t) 0;
+ size_t i;
+
+ for (i = 0; i < 32; ++i)
+ {
+ HP_TIMING_NOW (start);
+#ifdef TEST_BCOPY
+ CALL (impl, src, dst, len);
+#else
+ CALL (impl, dst, src, len);
+#endif
+ HP_TIMING_NOW (stop);
+ HP_TIMING_BEST (best_time, start, stop);
+ }
+
+ printf ("\t%zd", (size_t) best_time);
+ }
+}
+
+static void
+do_test (size_t align1, size_t align2, size_t len)
+{
+ size_t i, j;
+ char *s1, *s2;
+
+ align1 &= 63;
+ if (align1 + len >= page_size)
+ return;
+
+ align2 &= 63;
+ if (align2 + len >= page_size)
+ return;
+
+ s1 = (char *) (buf1 + align1);
+ s2 = (char *) (buf2 + align2);
+
+ for (i = 0, j = 1; i < len; i++, j += 23)
+ s1[i] = j;
+
+ if (HP_TIMING_AVAIL)
+ printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
+
+ FOR_EACH_IMPL (impl, 0)
+ do_one_test (impl, s2, (char *) (buf2 + align1), s1, len);
+
+ if (HP_TIMING_AVAIL)
+ putchar ('\n');
+}
+
+int
+test_main (void)
+{
+ size_t i;
+
+ test_init ();
+
+ printf ("%23s", "");
+ FOR_EACH_IMPL (impl, 0)
+ printf ("\t%s", impl->name);
+ putchar ('\n');
+
+ for (i = 0; i < 14; ++i)
+ {
+ do_test (0, 32, 1 << i);
+ do_test (32, 0, 1 << i);
+ do_test (0, i, 1 << i);
+ do_test (i, 0, 1 << i);
+ }
+
+ for (i = 0; i < 32; ++i)
+ {
+ do_test (0, 32, i);
+ do_test (32, 0, i);
+ do_test (0, i, i);
+ do_test (i, 0, i);
+ }
+
+ for (i = 3; i < 32; ++i)
+ {
+ if ((i & (i - 1)) == 0)
+ continue;
+ do_test (0, 32, 16 * i);
+ do_test (32, 0, 16 * i);
+ do_test (0, i, 16 * i);
+ do_test (i, 0, 16 * i);
+ }
+
+ return ret;
+}
+
+#include "../test-skeleton.c"
Added: fsf/trunk/libc/benchtests/bench-mempcpy-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-mempcpy-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-mempcpy-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of mempcpy function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-mempcpy.c"
Added: fsf/trunk/libc/benchtests/bench-mempcpy.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-mempcpy.c (added)
+++ fsf/trunk/libc/benchtests/bench-mempcpy.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,37 @@
+/* Measure mempcpy functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define MEMCPY_RESULT(dst, len) (dst) + (len)
+#define TEST_MAIN
+#define TEST_NAME "mempcpy"
+#include "bench-string.h"
+
+char *simple_mempcpy (char *, const char *, size_t);
+
+IMPL (simple_mempcpy, 0)
+IMPL (mempcpy, 1)
+
+char *
+simple_mempcpy (char *dst, const char *src, size_t n)
+{
+ while (n--)
+ *dst++ = *src++;
+ return dst;
+}
+
+#include "bench-memcpy.c"
Added: fsf/trunk/libc/benchtests/bench-memset-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-memset-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-memset-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of memset function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-memset.c"
Added: fsf/trunk/libc/benchtests/bench-memset.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-memset.c (added)
+++ fsf/trunk/libc/benchtests/bench-memset.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,169 @@
+/* Measure memset functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_MAIN
+#ifdef TEST_BZERO
+# define TEST_NAME "bzero"
+#else
+# define TEST_NAME "memset"
+#endif
+#define MIN_PAGE_SIZE 131072
+#include "bench-string.h"
+
+char *simple_memset (char *, int, size_t);
+
+#ifdef TEST_BZERO
+typedef void (*proto_t) (char *, size_t);
+void simple_bzero (char *, size_t);
+void builtin_bzero (char *, size_t);
+
+IMPL (simple_bzero, 0)
+IMPL (builtin_bzero, 0)
+IMPL (bzero, 1)
+
+void
+simple_bzero (char *s, size_t n)
+{
+ simple_memset (s, 0, n);
+}
+
+void
+builtin_bzero (char *s, size_t n)
+{
+ __builtin_bzero (s, n);
+}
+#else
+typedef char *(*proto_t) (char *, int, size_t);
+char *builtin_memset (char *, int, size_t);
+
+IMPL (simple_memset, 0)
+IMPL (builtin_memset, 0)
+IMPL (memset, 1)
+
+char *
+builtin_memset (char *s, int c, size_t n)
+{
+ return __builtin_memset (s, c, n);
+}
+#endif
+
+char *
+simple_memset (char *s, int c, size_t n)
+{
+ char *r = s, *end = s + n;
+ while (r < end)
+ *r++ = c;
+ return s;
+}
+
+static void
+do_one_test (impl_t *impl, char *s, int c __attribute ((unused)), size_t n)
+{
+ char tstbuf[n];
+#ifdef TEST_BZERO
+ simple_bzero (tstbuf, n);
+ CALL (impl, s, n);
+ if (memcmp (s, tstbuf, n) != 0)
+#else
+ char *res = CALL (impl, s, c, n);
+ if (res != s
+ || simple_memset (tstbuf, c, n) != tstbuf
+ || memcmp (s, tstbuf, n) != 0)
+#endif
+ {
+ error (0, 0, "Wrong result in function %s", impl->name);
+ ret = 1;
+ return;
+ }
+
+ if (HP_TIMING_AVAIL)
+ {
+ hp_timing_t start __attribute ((unused));
+ hp_timing_t stop __attribute ((unused));
+ hp_timing_t best_time = ~ (hp_timing_t) 0;
+ size_t i;
+
+ for (i = 0; i < 32; ++i)
+ {
+ HP_TIMING_NOW (start);
+#ifdef TEST_BZERO
+ CALL (impl, s, n);
+#else
+ CALL (impl, s, c, n);
+#endif
+
+ HP_TIMING_NOW (stop);
+ HP_TIMING_BEST (best_time, start, stop);
+ }
+
+ printf ("\t%zd", (size_t) best_time);
+ }
+}
+
+static void
+do_test (size_t align, int c, size_t len)
+{
+ align &= 7;
+ if (align + len > page_size)
+ return;
+
+ if (HP_TIMING_AVAIL)
+ printf ("Length %4zd, alignment %2zd, c %2d:", len, align, c);
+
+ FOR_EACH_IMPL (impl, 0)
+ do_one_test (impl, (char *) buf1 + align, c, len);
+
+ if (HP_TIMING_AVAIL)
+ putchar ('\n');
+}
+
+int
+test_main (void)
+{
+ size_t i;
+ int c = 0;
+
+ test_init ();
+
+ printf ("%24s", "");
+ FOR_EACH_IMPL (impl, 0)
+ printf ("\t%s", impl->name);
+ putchar ('\n');
+
+#ifndef TEST_BZERO
+ for (c = -65; c <= 130; c += 65)
+#endif
+ {
+ for (i = 0; i < 18; ++i)
+ do_test (0, c, 1 << i);
+ for (i = 1; i < 32; ++i)
+ {
+ do_test (i, c, i);
+ if (i & (i - 1))
+ do_test (0, c, i);
+ }
+ do_test (1, c, 14);
+ do_test (3, c, 1024);
+ do_test (4, c, 64);
+ do_test (2, c, 25);
+ }
+
+ return ret;
+}
+
+#include "../test-skeleton.c"
Added: fsf/trunk/libc/benchtests/bench-rawmemchr-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-rawmemchr-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-rawmemchr-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of rawmemchr function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-rawmemchr.c"
Added: fsf/trunk/libc/benchtests/bench-rawmemchr.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-rawmemchr.c (added)
+++ fsf/trunk/libc/benchtests/bench-rawmemchr.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,133 @@
+/* Measure memchr functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <assert.h>
+
+#define TEST_MAIN
+#define TEST_NAME "rawmemchr"
+#include "bench-string.h"
+
+typedef char *(*proto_t) (const char *, int);
+char *simple_rawmemchr (const char *, int);
+
+IMPL (simple_rawmemchr, 0)
+IMPL (rawmemchr, 1)
+
+char *
+simple_rawmemchr (const char *s, int c)
+{
+ while (1)
+ if (*s++ == (char) c)
+ return (char *) s - 1;
+ return NULL;
+}
+
+static void
+do_one_test (impl_t *impl, const char *s, int c, char *exp_res)
+{
+ char *res = CALL (impl, s, c);
+ if (res != exp_res)
+ {
+ error (0, 0, "Wrong result in function %s %p %p", impl->name,
+ res, exp_res);
+ ret = 1;
+ return;
+ }
+
+ if (HP_TIMING_AVAIL)
+ {
+ hp_timing_t start __attribute ((unused));
+ hp_timing_t stop __attribute ((unused));
+ hp_timing_t best_time = ~ (hp_timing_t) 0;
+ size_t i;
+
+ for (i = 0; i < 32; ++i)
+ {
+ HP_TIMING_NOW (start);
+ CALL (impl, s, c);
+ HP_TIMING_NOW (stop);
+ HP_TIMING_BEST (best_time, start, stop);
+ }
+
+ printf ("\t%zd", (size_t) best_time);
+ }
+}
+
+static void
+do_test (size_t align, size_t pos, size_t len, int seek_char)
+{
+ size_t i;
+ char *result;
+
+ align &= 7;
+ if (align + len >= page_size)
+ return;
+
+ for (i = 0; i < len; ++i)
+ {
+ buf1[align + i] = 1 + 23 * i % 127;
+ if (buf1[align + i] == seek_char)
+ buf1[align + i] = seek_char + 1;
+ }
+ buf1[align + len] = 0;
+
+ assert (pos < len);
+
+ buf1[align + pos] = seek_char;
+ buf1[align + len] = -seek_char;
+ result = (char *) (buf1 + align + pos);
+
+ if (HP_TIMING_AVAIL)
+ printf ("Length %4zd, alignment %2zd:", pos, align);
+
+ FOR_EACH_IMPL (impl, 0)
+ do_one_test (impl, (char *) (buf1 + align), seek_char, result);
+
+ if (HP_TIMING_AVAIL)
+ putchar ('\n');
+}
+
+int
+test_main (void)
+{
+ size_t i;
+
+ test_init ();
+
+ printf ("%20s", "");
+ FOR_EACH_IMPL (impl, 0)
+ printf ("\t%s", impl->name);
+ putchar ('\n');
+
+ for (i = 1; i < 7; ++i)
+ {
+ do_test (0, 16 << i, 2048, 23);
+ do_test (i, 64, 256, 23);
+ do_test (0, 16 << i, 2048, 0);
+ do_test (i, 64, 256, 0);
+ }
+ for (i = 1; i < 32; ++i)
+ {
+ do_test (0, i, i + 1, 23);
+ do_test (0, i, i + 1, 0);
+ }
+
+ return ret;
+}
+
+#include "../test-skeleton.c"
Added: fsf/trunk/libc/benchtests/bench-stpcpy-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-stpcpy-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-stpcpy-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of stpcpy function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-stpcpy.c"
Added: fsf/trunk/libc/benchtests/bench-stpcpy.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-stpcpy.c (added)
+++ fsf/trunk/libc/benchtests/bench-stpcpy.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,36 @@
+/* Measure stpcpy functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define STRCPY_RESULT(dst, len) ((dst) + (len))
+#define TEST_MAIN
+#define TEST_NAME "stpcpy"
+#include "bench-string.h"
+
+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;
+}
+
+#include "bench-strcpy.c"
Added: fsf/trunk/libc/benchtests/bench-stpcpy_chk-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-stpcpy_chk-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-stpcpy_chk-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of stpcpy checking function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-stpcpy_chk.c"
Added: fsf/trunk/libc/benchtests/bench-stpcpy_chk.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-stpcpy_chk.c (added)
+++ fsf/trunk/libc/benchtests/bench-stpcpy_chk.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,45 @@
+/* Measure stpcpy checking functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define STRCPY_RESULT(dst, len) ((dst) + (len))
+#define TEST_MAIN
+#define TEST_NAME "stpcpy_chk"
+#include "bench-string.h"
+
+extern void __attribute__ ((noreturn)) __chk_fail (void);
+char *simple_stpcpy_chk (char *, const char *, size_t);
+extern char *normal_stpcpy (char *, const char *, size_t)
+ __asm ("stpcpy");
+extern char *__stpcpy_chk (char *, const char *, size_t);
+
+IMPL (simple_stpcpy_chk, 0)
+IMPL (normal_stpcpy, 1)
+IMPL (__stpcpy_chk, 2)
+
+char *
+simple_stpcpy_chk (char *dst, const char *src, size_t len)
+{
+ if (! len)
+ __chk_fail ();
+ while ((*dst++ = *src++) != '\0')
+ if (--len == 0)
+ __chk_fail ();
+ return dst - 1;
+}
+
+#include "bench-strcpy_chk.c"
Added: fsf/trunk/libc/benchtests/bench-stpncpy-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-stpncpy-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-stpncpy-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of stpncpy function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-stpncpy.c"
Added: fsf/trunk/libc/benchtests/bench-stpncpy.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-stpncpy.c (added)
+++ fsf/trunk/libc/benchtests/bench-stpncpy.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,59 @@
+/* Measure stpncpy functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define STRNCPY_RESULT(dst, len, n) ((dst) + ((len) > (n) ? (n) : (len)))
+#define TEST_MAIN
+#define TEST_NAME "stpncpy"
+#include "bench-string.h"
+
+char *simple_stpncpy (char *, const char *, size_t);
+char *stupid_stpncpy (char *, const char *, size_t);
+
+IMPL (stupid_stpncpy, 0)
+IMPL (simple_stpncpy, 0)
+IMPL (stpncpy, 1)
+
+char *
+simple_stpncpy (char *dst, const char *src, size_t n)
+{
+ while (n--)
+ if ((*dst++ = *src++) == '\0')
+ {
+ size_t i;
+
+ for (i = 0; i < n; ++i)
+ dst[i] = '\0';
+ return dst - 1;
+ }
+ return dst;
+}
+
+char *
+stupid_stpncpy (char *dst, const char *src, size_t n)
+{
+ size_t nc = strnlen (src, n);
+ size_t i;
+
+ for (i = 0; i < nc; ++i)
+ dst[i] = src[i];
+ for (; i < n; ++i)
+ dst[i] = '\0';
+ return dst + nc;
+}
+
+#include "bench-strncpy.c"
Added: fsf/trunk/libc/benchtests/bench-strcasecmp-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-strcasecmp-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-strcasecmp-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of strcasecmp function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-strcasecmp.c"
Added: fsf/trunk/libc/benchtests/bench-strcasecmp.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-strcasecmp.c (added)
+++ fsf/trunk/libc/benchtests/bench-strcasecmp.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,183 @@
+/* Measure strcasecmp functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <ctype.h>
+#define TEST_MAIN
+#define TEST_NAME "strcasecmp"
+#include "bench-string.h"
+
+typedef int (*proto_t) (const char *, const char *);
+static int simple_strcasecmp (const char *, const char *);
+static int stupid_strcasecmp (const char *, const char *);
+
+IMPL (stupid_strcasecmp, 0)
+IMPL (simple_strcasecmp, 0)
+IMPL (strcasecmp, 1)
+
+static int
+simple_strcasecmp (const char *s1, const char *s2)
+{
+ int ret;
+
+ while ((ret = ((unsigned char) tolower (*s1)
+ - (unsigned char) tolower (*s2))) == 0
+ && *s1++)
+ ++s2;
+ return ret;
+}
+
+static int
+stupid_strcasecmp (const char *s1, const char *s2)
+{
+ size_t ns1 = strlen (s1) + 1, ns2 = strlen (s2) + 1;
+ size_t n = ns1 < ns2 ? ns1 : ns2;
+ int ret = 0;
+
+ while (n--)
+ {
+ if ((ret = ((unsigned char) tolower (*s1)
+ - (unsigned char) tolower (*s2))) != 0)
+ break;
+ ++s1;
+ ++s2;
+ }
+ return ret;
+}
+
+static void
+do_one_test (impl_t *impl, const char *s1, const char *s2, int exp_result)
+{
+ int result = CALL (impl, s1, s2);
+ if ((exp_result == 0 && result != 0)
+ || (exp_result < 0 && result >= 0)
+ || (exp_result > 0 && result <= 0))
+ {
+ error (0, 0, "Wrong result in function %s %d %d", impl->name,
+ result, exp_result);
+ ret = 1;
+ return;
+ }
+
+ if (HP_TIMING_AVAIL)
+ {
+ hp_timing_t start __attribute ((unused));
+ hp_timing_t stop __attribute ((unused));
+ hp_timing_t best_time = ~ (hp_timing_t) 0;
+ size_t i;
+
+ for (i = 0; i < 32; ++i)
+ {
+ HP_TIMING_NOW (start);
+ CALL (impl, s1, s2);
+ HP_TIMING_NOW (stop);
+ HP_TIMING_BEST (best_time, start, stop);
+ }
+
+ printf ("\t%zd", (size_t) best_time);
+ }
+}
+
+static void
+do_test (size_t align1, size_t align2, size_t len, int max_char,
+ int exp_result)
+{
+ size_t i;
+ char *s1, *s2;
+
+ if (len == 0)
+ return;
+
+ align1 &= 7;
+ if (align1 + len + 1 >= page_size)
+ return;
+
+ align2 &= 7;
+ if (align2 + len + 1 >= page_size)
+ return;
+
+ s1 = (char *) (buf1 + align1);
+ s2 = (char *) (buf2 + align2);
+
+ for (i = 0; i < len; i++)
+ {
+ s1[i] = toupper (1 + 23 * i % max_char);
+ s2[i] = tolower (s1[i]);
+ }
+
+ s1[len] = s2[len] = 0;
+ s1[len + 1] = 23;
+ s2[len + 1] = 24 + exp_result;
+ if ((s2[len - 1] == 'z' && exp_result == -1)
+ || (s2[len - 1] == 'a' && exp_result == 1))
+ s1[len - 1] += exp_result;
+ else
+ s2[len - 1] -= exp_result;
+
+ if (HP_TIMING_AVAIL)
+ printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
+
+ FOR_EACH_IMPL (impl, 0)
+ do_one_test (impl, s1, s2, exp_result);
+
+ if (HP_TIMING_AVAIL)
+ putchar ('\n');
+}
+
+int
+test_main (void)
+{
+ size_t i;
+
+ test_init ();
+
+ printf ("%23s", "");
+ FOR_EACH_IMPL (impl, 0)
+ printf ("\t%s", impl->name);
+ putchar ('\n');
+
+ for (i = 1; i < 16; ++i)
+ {
+ do_test (i, i, i, 127, 0);
+ do_test (i, i, i, 127, 1);
+ do_test (i, i, i, 127, -1);
+ }
+
+ for (i = 1; i < 10; ++i)
+ {
+ do_test (0, 0, 2 << i, 127, 0);
+ do_test (0, 0, 2 << i, 254, 0);
+ do_test (0, 0, 2 << i, 127, 1);
+ do_test (0, 0, 2 << i, 254, 1);
+ do_test (0, 0, 2 << i, 127, -1);
+ do_test (0, 0, 2 << i, 254, -1);
+ }
+
+ for (i = 1; i < 8; ++i)
+ {
+ do_test (i, 2 * i, 8 << i, 127, 0);
+ do_test (2 * i, i, 8 << i, 254, 0);
+ do_test (i, 2 * i, 8 << i, 127, 1);
+ do_test (2 * i, i, 8 << i, 254, 1);
+ do_test (i, 2 * i, 8 << i, 127, -1);
+ do_test (2 * i, i, 8 << i, 254, -1);
+ }
+
+ return ret;
+}
+
+#include "../test-skeleton.c"
Added: fsf/trunk/libc/benchtests/bench-strcasestr-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-strcasestr-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-strcasestr-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of strcasestr function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-strcasestr.c"
Added: fsf/trunk/libc/benchtests/bench-strcasestr.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-strcasestr.c (added)
+++ fsf/trunk/libc/benchtests/bench-strcasestr.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,186 @@
+/* Measure strcasestr functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_MAIN
+#define TEST_NAME "strcasestr"
+#include "bench-string.h"
+
+
+#define STRCASESTR simple_strcasestr
+#define NO_ALIAS
+#define __strncasecmp strncasecmp
+#include "../string/strcasestr.c"
+
+
+static char *
+stupid_strcasestr (const char *s1, const char *s2)
+{
+ ssize_t s1len = strlen (s1);
+ ssize_t s2len = strlen (s2);
+
+ if (s2len > s1len)
+ return NULL;
+
+ for (ssize_t i = 0; i <= s1len - s2len; ++i)
+ {
+ size_t j;
+ for (j = 0; j < s2len; ++j)
+ if (tolower (s1[i + j]) != tolower (s2[j]))
+ break;
+ if (j == s2len)
+ return (char *) s1 + i;
+ }
+
+ return NULL;
+}
+
+
+typedef char *(*proto_t) (const char *, const char *);
+
+IMPL (stupid_strcasestr, 0)
+IMPL (simple_strcasestr, 0)
+IMPL (strcasestr, 1)
+
+
+static void
+do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result)
+{
+ if (HP_TIMING_AVAIL)
+ {
+ hp_timing_t start __attribute ((unused));
+ hp_timing_t stop __attribute ((unused));
+ hp_timing_t best_time = ~(hp_timing_t) 0;
+ size_t i;
+
+ for (i = 0; i < 32; ++i)
+ {
+ HP_TIMING_NOW (start);
+ CALL (impl, s1, s2);
+ HP_TIMING_NOW (stop);
+ HP_TIMING_BEST (best_time, start, stop);
+ }
+
+ printf ("\t%zd", (size_t) best_time);
+ }
+}
+
+
+static void
+do_test (size_t align1, size_t align2, size_t len1, size_t len2,
+ int fail)
+{
+ char *s1 = (char *) (buf1 + align1);
+ char *s2 = (char *) (buf2 + align2);
+
+ static const char d[] = "1234567890abcxyz";
+#define dl (sizeof (d) - 1)
+ char *ss2 = s2;
+ for (size_t l = len2; l > 0; l = l > dl ? l - dl : 0)
+ {
+ size_t t = l > dl ? dl : l;
+ ss2 = mempcpy (ss2, d, t);
+ }
+ s2[len2] = '\0';
+
+ if (fail)
+ {
+ char *ss1 = s1;
+ for (size_t l = len1; l > 0; l = l > dl ? l - dl : 0)
+ {
+ size_t t = l > dl ? dl : l;
+ memcpy (ss1, d, t);
+ ++ss1[len2 > 7 ? 7 : len2 - 1];
+ ss1 += t;
+ }
+ }
+ else
+ {
+ memset (s1, '0', len1);
+ for (size_t i = 0; i < len2; ++i)
+ s1[len1 - len2 + i] = toupper (s2[i]);
+ }
+ s1[len1] = '\0';
+
+ if (HP_TIMING_AVAIL)
+ printf ("Length %4zd/%zd, alignment %2zd/%2zd, %s:",
+ len1, len2, align1, align2, fail ? "fail" : "found");
+
+ FOR_EACH_IMPL (impl, 0)
+ do_one_test (impl, s1, s2, fail ? NULL : s1 + len1 - len2);
+
+ if (HP_TIMING_AVAIL)
+ putchar ('\n');
+}
+
+static int
+test_main (void)
+{
+ test_init ();
+
+ printf ("%23s", "");
+ FOR_EACH_IMPL (impl, 0)
+ printf ("\t%s", impl->name);
+ putchar ('\n');
+
+ for (size_t klen = 2; klen < 32; ++klen)
+ for (size_t hlen = 2 * klen; hlen < 16 * klen; hlen += klen)
+ {
+ do_test (0, 0, hlen, klen, 0);
+ do_test (0, 0, hlen, klen, 1);
+ do_test (0, 3, hlen, klen, 0);
+ do_test (0, 3, hlen, klen, 1);
+ do_test (0, 9, hlen, klen, 0);
+ do_test (0, 9, hlen, klen, 1);
+ do_test (0, 15, hlen, klen, 0);
+ do_test (0, 15, hlen, klen, 1);
+
+ do_test (3, 0, hlen, klen, 0);
+ do_test (3, 0, hlen, klen, 1);
+ do_test (3, 3, hlen, klen, 0);
+ do_test (3, 3, hlen, klen, 1);
+ do_test (3, 9, hlen, klen, 0);
+ do_test (3, 9, hlen, klen, 1);
+ do_test (3, 15, hlen, klen, 0);
+ do_test (3, 15, hlen, klen, 1);
+
+ do_test (9, 0, hlen, klen, 0);
+ do_test (9, 0, hlen, klen, 1);
+ do_test (9, 3, hlen, klen, 0);
+ do_test (9, 3, hlen, klen, 1);
+ do_test (9, 9, hlen, klen, 0);
+ do_test (9, 9, hlen, klen, 1);
+ do_test (9, 15, hlen, klen, 0);
+ do_test (9, 15, hlen, klen, 1);
+
+ do_test (15, 0, hlen, klen, 0);
+ do_test (15, 0, hlen, klen, 1);
+ do_test (15, 3, hlen, klen, 0);
+ do_test (15, 3, hlen, klen, 1);
+ do_test (15, 9, hlen, klen, 0);
+ do_test (15, 9, hlen, klen, 1);
+ do_test (15, 15, hlen, klen, 0);
+ do_test (15, 15, hlen, klen, 1);
+ }
+
+ do_test (0, 0, page_size - 1, 16, 0);
+ do_test (0, 0, page_size - 1, 16, 1);
+
+ return ret;
+}
+
+#include "../test-skeleton.c"
Added: fsf/trunk/libc/benchtests/bench-strcat-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-strcat-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-strcat-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of strcat function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-strcat.c"
Added: fsf/trunk/libc/benchtests/bench-strcat.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-strcat.c (added)
+++ fsf/trunk/libc/benchtests/bench-strcat.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,155 @@
+/* Measure strcat functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_MAIN
+#define TEST_NAME "strcat"
+#include "bench-string.h"
+
+typedef char *(*proto_t) (char *, const char *);
+char *simple_strcat (char *, const char *);
+
+IMPL (simple_strcat, 0)
+IMPL (strcat, 1)
+
+char *
+simple_strcat (char *dst, const char *src)
+{
+ char *ret = dst;
+ while (*dst++ != '\0');
+ --dst;
+ while ((*dst++ = *src++) != '\0');
+ return ret;
+}
+
+static void
+do_one_test (impl_t *impl, char *dst, const char *src)
+{
+ size_t k = strlen (dst);
+ if (CALL (impl, dst, src) != dst)
+ {
+ error (0, 0, "Wrong result in function %s %p %p", impl->name,
+ CALL (impl, dst, src), dst);
+ ret = 1;
+ return;
+ }
+
+ if (strcmp (dst + k, src) != 0)
+ {
+ error (0, 0, "Wrong result in function %s dst \"%s\" src \"%s\"",
+ impl->name, dst, src);
+ ret = 1;
+ return;
+ }
+
+ if (HP_TIMING_AVAIL)
+ {
+ hp_timing_t start __attribute ((unused));
+ hp_timing_t stop __attribute ((unused));
+ hp_timing_t best_time = ~ (hp_timing_t) 0;
+ size_t i;
+
+ for (i = 0; i < 32; ++i)
+ {
+ dst[k] = '\0';
+ HP_TIMING_NOW (start);
+ CALL (impl, dst, src);
+ HP_TIMING_NOW (stop);
+ HP_TIMING_BEST (best_time, start, stop);
+ }
+
+ printf ("\t%zd", (size_t) best_time);
+ }
+}
+
+static void
+do_test (size_t align1, size_t align2, size_t len1, size_t len2, int max_char)
+{
+ size_t i;
+ char *s1, *s2;
+
+ align1 &= 7;
+ if (align1 + len1 >= page_size)
+ return;
+
+ align2 &= 7;
+ if (align2 + len1 + len2 >= page_size)
+ return;
+
+ s1 = (char *) (buf1 + align1);
+ s2 = (char *) (buf2 + align2);
+
+ for (i = 0; i < len1; ++i)
+ s1[i] = 32 + 23 * i % (max_char - 32);
+ s1[len1] = '\0';
+
+ for (i = 0; i < len2; i++)
+ s2[i] = 32 + 23 * i % (max_char - 32);
+
+ if (HP_TIMING_AVAIL)
+ printf ("Length %4zd/%4zd, alignment %2zd/%2zd:", len1, len2, align1, align2);
+
+ FOR_EACH_IMPL (impl, 0)
+ {
+ s2[len2] = '\0';
+ do_one_test (impl, s2, s1);
+ }
+
+ if (HP_TIMING_AVAIL)
+ putchar ('\n');
+}
+
+int
+test_main (void)
+{
+ size_t i;
+
+ test_init ();
+
+ printf ("%28s", "");
+ FOR_EACH_IMPL (impl, 0)
+ printf ("\t%s", impl->name);
+ putchar ('\n');
+
+ for (i = 0; i < 16; ++i)
+ {
+ do_test (0, 0, i, i, 127);
+ do_test (0, 0, i, i, 255);
+ do_test (0, i, i, i, 127);
+ do_test (i, 0, i, i, 255);
+ }
+
+ for (i = 1; i < 8; ++i)
+ {
+ do_test (0, 0, 8 << i, 8 << i, 127);
+ do_test (8 - i, 2 * i, 8 << i, 8 << i, 127);
+ do_test (0, 0, 8 << i, 2 << i, 127);
+ do_test (8 - i, 2 * i, 8 << i, 2 << i, 127);
+ }
+
+ for (i = 1; i < 8; ++i)
+ {
+ do_test (i, 2 * i, 8 << i, 1, 127);
+ do_test (2 * i, i, 8 << i, 1, 255);
+ do_test (i, i, 8 << i, 10, 127);
+ do_test (i, i, 8 << i, 10, 255);
+ }
+
+ return ret;
+}
+
+#include "../test-skeleton.c"
Added: fsf/trunk/libc/benchtests/bench-strchr-ifunc.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-strchr-ifunc.c (added)
+++ fsf/trunk/libc/benchtests/bench-strchr-ifunc.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,20 @@
+/* Measure IFUNC implementations of strchr function.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "bench-strchr.c"
Added: fsf/trunk/libc/benchtests/bench-strchr.c
==============================================================================
--- fsf/trunk/libc/benchtests/bench-strchr.c (added)
+++ fsf/trunk/libc/benchtests/bench-strchr.c Wed Jun 12 00:02:20 2013
@@ -1,0 +1,206 @@
+/* Measure STRCHR functions.
+ Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
[... 42612 lines stripped ...]
_______________________________________________
Commits mailing list
Commits@xxxxxxxxxx
http://eglibc.org/cgi-bin/mailman/listinfo/commits