Blame SOURCES/ia-string-funct-test-rtm.patch

190885
From 294c22ed9aa3f576f58b9af69c9a34225fcf02aa Mon Sep 17 00:00:00 2001
190885
From: "H.J. Lu" <hjl.tools@gmail.com>
190885
Date: Tue, 23 Feb 2021 06:33:10 -0800
190885
Subject: [PATCH] x86: Add string/memory function tests in RTM region
190885
190885
At function exit, AVX optimized string/memory functions have VZEROUPPER
190885
which triggers RTM abort.   When such functions are called inside a
190885
transactionally executing RTM region, RTM abort causes severe performance
190885
degradation.  Add tests to verify that string/memory functions won't
190885
cause RTM abort in RTM region.
190885
190885
(cherry picked from commit 4bd660be40967cd69072f69ebc2ad32bfcc1f206)
190885
---
190885
 sysdeps/x86/Makefile          | 23 +++++++++++
190885
 sysdeps/x86/tst-memchr-rtm.c  | 54 ++++++++++++++++++++++++++
190885
 sysdeps/x86/tst-memcmp-rtm.c  | 52 +++++++++++++++++++++++++
190885
 sysdeps/x86/tst-memmove-rtm.c | 53 ++++++++++++++++++++++++++
190885
 sysdeps/x86/tst-memrchr-rtm.c | 54 ++++++++++++++++++++++++++
190885
 sysdeps/x86/tst-memset-rtm.c  | 45 ++++++++++++++++++++++
190885
 sysdeps/x86/tst-strchr-rtm.c  | 54 ++++++++++++++++++++++++++
190885
 sysdeps/x86/tst-strcpy-rtm.c  | 53 ++++++++++++++++++++++++++
190885
 sysdeps/x86/tst-string-rtm.h  | 72 +++++++++++++++++++++++++++++++++++
190885
 sysdeps/x86/tst-strlen-rtm.c  | 53 ++++++++++++++++++++++++++
190885
 sysdeps/x86/tst-strncmp-rtm.c | 52 +++++++++++++++++++++++++
190885
 sysdeps/x86/tst-strrchr-rtm.c | 53 ++++++++++++++++++++++++++
190885
 12 files changed, 618 insertions(+)
190885
 create mode 100644 sysdeps/x86/tst-memchr-rtm.c
190885
 create mode 100644 sysdeps/x86/tst-memcmp-rtm.c
190885
 create mode 100644 sysdeps/x86/tst-memmove-rtm.c
190885
 create mode 100644 sysdeps/x86/tst-memrchr-rtm.c
190885
 create mode 100644 sysdeps/x86/tst-memset-rtm.c
190885
 create mode 100644 sysdeps/x86/tst-strchr-rtm.c
190885
 create mode 100644 sysdeps/x86/tst-strcpy-rtm.c
190885
 create mode 100644 sysdeps/x86/tst-string-rtm.h
190885
 create mode 100644 sysdeps/x86/tst-strlen-rtm.c
190885
 create mode 100644 sysdeps/x86/tst-strncmp-rtm.c
190885
 create mode 100644 sysdeps/x86/tst-strrchr-rtm.c
190885
190885
diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile
190885
index 59e928e9..5be71ada 100644
190885
--- a/sysdeps/x86/Makefile
190885
+++ b/sysdeps/x86/Makefile
190885
@@ -17,6 +17,29 @@ endif
190885
 
190885
 ifeq ($(subdir),string)
190885
 sysdep_routines += cacheinfo
190885
+
190885
+tests += \
190885
+  tst-memchr-rtm \
190885
+  tst-memcmp-rtm \
190885
+  tst-memmove-rtm \
190885
+  tst-memrchr-rtm \
190885
+  tst-memset-rtm \
190885
+  tst-strchr-rtm \
190885
+  tst-strcpy-rtm \
190885
+  tst-strlen-rtm \
190885
+  tst-strncmp-rtm \
190885
+  tst-strrchr-rtm
190885
+
190885
+CFLAGS-tst-memchr-rtm.c += -mrtm
190885
+CFLAGS-tst-memcmp-rtm.c += -mrtm
190885
+CFLAGS-tst-memmove-rtm.c += -mrtm
190885
+CFLAGS-tst-memrchr-rtm.c += -mrtm
190885
+CFLAGS-tst-memset-rtm.c += -mrtm
190885
+CFLAGS-tst-strchr-rtm.c += -mrtm
190885
+CFLAGS-tst-strcpy-rtm.c += -mrtm
190885
+CFLAGS-tst-strlen-rtm.c += -mrtm
190885
+CFLAGS-tst-strncmp-rtm.c += -mrtm
190885
+CFLAGS-tst-strrchr-rtm.c += -mrtm
190885
 endif
190885
 
190885
 ifneq ($(enable-cet),no)
190885
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
190885
new file mode 100644
190885
index 00000000..e4749401
190885
--- /dev/null
190885
+++ b/sysdeps/x86/tst-memchr-rtm.c
190885
@@ -0,0 +1,54 @@
190885
+/* Test case for memchr inside a transactionally executing RTM region.
190885
+   Copyright (C) 2021 Free Software Foundation, Inc.
190885
+   This file is part of the GNU C Library.
190885
+
190885
+   The GNU C Library is free software; you can redistribute it and/or
190885
+   modify it under the terms of the GNU Lesser General Public
190885
+   License as published by the Free Software Foundation; either
190885
+   version 2.1 of the License, or (at your option) any later version.
190885
+
190885
+   The GNU C Library is distributed in the hope that it will be useful,
190885
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
190885
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
190885
+   Lesser General Public License for more details.
190885
+
190885
+   You should have received a copy of the GNU Lesser General Public
190885
+   License along with the GNU C Library; if not, see
190885
+   <https://www.gnu.org/licenses/>.  */
190885
+
190885
+#include <tst-string-rtm.h>
190885
+
190885
+#define LOOP 3000
190885
+#define STRING_SIZE 1024
190885
+char string1[STRING_SIZE];
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+prepare (void)
190885
+{
190885
+  memset (string1, 'a', STRING_SIZE);
190885
+  string1[100] = 'c';
190885
+  string1[STRING_SIZE - 100] = 'c';
190885
+  char *p = memchr (string1, 'c', STRING_SIZE);
190885
+  if (p == &string1[100])
190885
+    return EXIT_SUCCESS;
190885
+  else
190885
+    return EXIT_FAILURE;
190885
+}
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+function (void)
190885
+{
190885
+  char *p = memchr (string1, 'c', STRING_SIZE);
190885
+  if (p == &string1[100])
190885
+    return 0;
190885
+  else
190885
+    return 1;
190885
+}
190885
+
190885
+static int
190885
+do_test (void)
190885
+{
190885
+  return do_test_1 ("memchr", LOOP, prepare, function);
190885
+}
190885
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
190885
new file mode 100644
190885
index 00000000..e4c8a623
190885
--- /dev/null
190885
+++ b/sysdeps/x86/tst-memcmp-rtm.c
190885
@@ -0,0 +1,52 @@
190885
+/* Test case for memcmp inside a transactionally executing RTM region.
190885
+   Copyright (C) 2021 Free Software Foundation, Inc.
190885
+   This file is part of the GNU C Library.
190885
+
190885
+   The GNU C Library is free software; you can redistribute it and/or
190885
+   modify it under the terms of the GNU Lesser General Public
190885
+   License as published by the Free Software Foundation; either
190885
+   version 2.1 of the License, or (at your option) any later version.
190885
+
190885
+   The GNU C Library is distributed in the hope that it will be useful,
190885
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
190885
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
190885
+   Lesser General Public License for more details.
190885
+
190885
+   You should have received a copy of the GNU Lesser General Public
190885
+   License along with the GNU C Library; if not, see
190885
+   <https://www.gnu.org/licenses/>.  */
190885
+
190885
+#include <tst-string-rtm.h>
190885
+
190885
+#define LOOP 3000
190885
+#define STRING_SIZE 1024
190885
+char string1[STRING_SIZE];
190885
+char string2[STRING_SIZE];
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+prepare (void)
190885
+{
190885
+  memset (string1, 'a', STRING_SIZE);
190885
+  memset (string2, 'a', STRING_SIZE);
190885
+  if (memcmp (string1, string2, STRING_SIZE) == 0)
190885
+    return EXIT_SUCCESS;
190885
+  else
190885
+    return EXIT_FAILURE;
190885
+}
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+function (void)
190885
+{
190885
+  if (memcmp (string1, string2, STRING_SIZE) == 0)
190885
+    return 0;
190885
+  else
190885
+    return 1;
190885
+}
190885
+
190885
+static int
190885
+do_test (void)
190885
+{
190885
+  return do_test_1 ("memcmp", LOOP, prepare, function);
190885
+}
190885
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
190885
new file mode 100644
190885
index 00000000..4bf97ef1
190885
--- /dev/null
190885
+++ b/sysdeps/x86/tst-memmove-rtm.c
190885
@@ -0,0 +1,53 @@
190885
+/* Test case for memmove inside a transactionally executing RTM region.
190885
+   Copyright (C) 2021 Free Software Foundation, Inc.
190885
+   This file is part of the GNU C Library.
190885
+
190885
+   The GNU C Library is free software; you can redistribute it and/or
190885
+   modify it under the terms of the GNU Lesser General Public
190885
+   License as published by the Free Software Foundation; either
190885
+   version 2.1 of the License, or (at your option) any later version.
190885
+
190885
+   The GNU C Library is distributed in the hope that it will be useful,
190885
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
190885
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
190885
+   Lesser General Public License for more details.
190885
+
190885
+   You should have received a copy of the GNU Lesser General Public
190885
+   License along with the GNU C Library; if not, see
190885
+   <https://www.gnu.org/licenses/>.  */
190885
+
190885
+#include <tst-string-rtm.h>
190885
+
190885
+#define LOOP 3000
190885
+#define STRING_SIZE 1024
190885
+char string1[STRING_SIZE];
190885
+char string2[STRING_SIZE];
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+prepare (void)
190885
+{
190885
+  memset (string1, 'a', STRING_SIZE);
190885
+  if (memmove (string2, string1, STRING_SIZE) == string2
190885
+      && memcmp (string2, string1, STRING_SIZE) == 0)
190885
+    return EXIT_SUCCESS;
190885
+  else
190885
+    return EXIT_FAILURE;
190885
+}
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+function (void)
190885
+{
190885
+  if (memmove (string2, string1, STRING_SIZE) == string2
190885
+      && memcmp (string2, string1, STRING_SIZE) == 0)
190885
+    return 0;
190885
+  else
190885
+    return 1;
190885
+}
190885
+
190885
+static int
190885
+do_test (void)
190885
+{
190885
+  return do_test_1 ("memmove", LOOP, prepare, function);
190885
+}
190885
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
190885
new file mode 100644
190885
index 00000000..a57a5a8e
190885
--- /dev/null
190885
+++ b/sysdeps/x86/tst-memrchr-rtm.c
190885
@@ -0,0 +1,54 @@
190885
+/* Test case for memrchr inside a transactionally executing RTM region.
190885
+   Copyright (C) 2021 Free Software Foundation, Inc.
190885
+   This file is part of the GNU C Library.
190885
+
190885
+   The GNU C Library is free software; you can redistribute it and/or
190885
+   modify it under the terms of the GNU Lesser General Public
190885
+   License as published by the Free Software Foundation; either
190885
+   version 2.1 of the License, or (at your option) any later version.
190885
+
190885
+   The GNU C Library is distributed in the hope that it will be useful,
190885
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
190885
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
190885
+   Lesser General Public License for more details.
190885
+
190885
+   You should have received a copy of the GNU Lesser General Public
190885
+   License along with the GNU C Library; if not, see
190885
+   <https://www.gnu.org/licenses/>.  */
190885
+
190885
+#include <tst-string-rtm.h>
190885
+
190885
+#define LOOP 3000
190885
+#define STRING_SIZE 1024
190885
+char string1[STRING_SIZE];
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+prepare (void)
190885
+{
190885
+  memset (string1, 'a', STRING_SIZE);
190885
+  string1[100] = 'c';
190885
+  string1[STRING_SIZE - 100] = 'c';
190885
+  char *p = memrchr (string1, 'c', STRING_SIZE);
190885
+  if (p == &string1[STRING_SIZE - 100])
190885
+    return EXIT_SUCCESS;
190885
+  else
190885
+    return EXIT_FAILURE;
190885
+}
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+function (void)
190885
+{
190885
+  char *p = memrchr (string1, 'c', STRING_SIZE);
190885
+  if (p == &string1[STRING_SIZE - 100])
190885
+    return 0;
190885
+  else
190885
+    return 1;
190885
+}
190885
+
190885
+static int
190885
+do_test (void)
190885
+{
190885
+  return do_test_1 ("memrchr", LOOP, prepare, function);
190885
+}
190885
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
190885
new file mode 100644
190885
index 00000000..bf343a4d
190885
--- /dev/null
190885
+++ b/sysdeps/x86/tst-memset-rtm.c
190885
@@ -0,0 +1,45 @@
190885
+/* Test case for memset inside a transactionally executing RTM region.
190885
+   Copyright (C) 2021 Free Software Foundation, Inc.
190885
+   This file is part of the GNU C Library.
190885
+
190885
+   The GNU C Library is free software; you can redistribute it and/or
190885
+   modify it under the terms of the GNU Lesser General Public
190885
+   License as published by the Free Software Foundation; either
190885
+   version 2.1 of the License, or (at your option) any later version.
190885
+
190885
+   The GNU C Library is distributed in the hope that it will be useful,
190885
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
190885
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
190885
+   Lesser General Public License for more details.
190885
+
190885
+   You should have received a copy of the GNU Lesser General Public
190885
+   License along with the GNU C Library; if not, see
190885
+   <https://www.gnu.org/licenses/>.  */
190885
+
190885
+#include <tst-string-rtm.h>
190885
+
190885
+#define LOOP 3000
190885
+#define STRING_SIZE 1024
190885
+char string1[STRING_SIZE];
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+prepare (void)
190885
+{
190885
+  memset (string1, 'a', STRING_SIZE);
190885
+  return EXIT_SUCCESS;
190885
+}
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+function (void)
190885
+{
190885
+  memset (string1, 'a', STRING_SIZE);
190885
+  return 0;
190885
+}
190885
+
190885
+static int
190885
+do_test (void)
190885
+{
190885
+  return do_test_1 ("memset", LOOP, prepare, function);
190885
+}
190885
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
190885
new file mode 100644
190885
index 00000000..a82e29c0
190885
--- /dev/null
190885
+++ b/sysdeps/x86/tst-strchr-rtm.c
190885
@@ -0,0 +1,54 @@
190885
+/* Test case for strchr inside a transactionally executing RTM region.
190885
+   Copyright (C) 2021 Free Software Foundation, Inc.
190885
+   This file is part of the GNU C Library.
190885
+
190885
+   The GNU C Library is free software; you can redistribute it and/or
190885
+   modify it under the terms of the GNU Lesser General Public
190885
+   License as published by the Free Software Foundation; either
190885
+   version 2.1 of the License, or (at your option) any later version.
190885
+
190885
+   The GNU C Library is distributed in the hope that it will be useful,
190885
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
190885
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
190885
+   Lesser General Public License for more details.
190885
+
190885
+   You should have received a copy of the GNU Lesser General Public
190885
+   License along with the GNU C Library; if not, see
190885
+   <https://www.gnu.org/licenses/>.  */
190885
+
190885
+#include <tst-string-rtm.h>
190885
+
190885
+#define LOOP 3000
190885
+#define STRING_SIZE 1024
190885
+char string1[STRING_SIZE];
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+prepare (void)
190885
+{
190885
+  memset (string1, 'a', STRING_SIZE - 1);
190885
+  string1[100] = 'c';
190885
+  string1[STRING_SIZE - 100] = 'c';
190885
+  char *p = strchr (string1, 'c');
190885
+  if (p == &string1[100])
190885
+    return EXIT_SUCCESS;
190885
+  else
190885
+    return EXIT_FAILURE;
190885
+}
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+function (void)
190885
+{
190885
+  char *p = strchr (string1, 'c');
190885
+  if (p == &string1[100])
190885
+    return 0;
190885
+  else
190885
+    return 1;
190885
+}
190885
+
190885
+static int
190885
+do_test (void)
190885
+{
190885
+  return do_test_1 ("strchr", LOOP, prepare, function);
190885
+}
190885
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
190885
new file mode 100644
190885
index 00000000..2b2a583f
190885
--- /dev/null
190885
+++ b/sysdeps/x86/tst-strcpy-rtm.c
190885
@@ -0,0 +1,53 @@
190885
+/* Test case for strcpy inside a transactionally executing RTM region.
190885
+   Copyright (C) 2021 Free Software Foundation, Inc.
190885
+   This file is part of the GNU C Library.
190885
+
190885
+   The GNU C Library is free software; you can redistribute it and/or
190885
+   modify it under the terms of the GNU Lesser General Public
190885
+   License as published by the Free Software Foundation; either
190885
+   version 2.1 of the License, or (at your option) any later version.
190885
+
190885
+   The GNU C Library is distributed in the hope that it will be useful,
190885
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
190885
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
190885
+   Lesser General Public License for more details.
190885
+
190885
+   You should have received a copy of the GNU Lesser General Public
190885
+   License along with the GNU C Library; if not, see
190885
+   <https://www.gnu.org/licenses/>.  */
190885
+
190885
+#include <tst-string-rtm.h>
190885
+
190885
+#define LOOP 3000
190885
+#define STRING_SIZE 1024
190885
+char string1[STRING_SIZE];
190885
+char string2[STRING_SIZE];
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+prepare (void)
190885
+{
190885
+  memset (string1, 'a', STRING_SIZE - 1);
190885
+  if (strcpy (string2, string1) == string2
190885
+      && strcmp (string2, string1) == 0)
190885
+    return EXIT_SUCCESS;
190885
+  else
190885
+    return EXIT_FAILURE;
190885
+}
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+function (void)
190885
+{
190885
+  if (strcpy (string2, string1) == string2
190885
+      && strcmp (string2, string1) == 0)
190885
+    return 0;
190885
+  else
190885
+    return 1;
190885
+}
190885
+
190885
+static int
190885
+do_test (void)
190885
+{
190885
+  return do_test_1 ("strcpy", LOOP, prepare, function);
190885
+}
190885
diff --git a/sysdeps/x86/tst-string-rtm.h b/sysdeps/x86/tst-string-rtm.h
190885
new file mode 100644
190885
index 00000000..d2470afa
190885
--- /dev/null
190885
+++ b/sysdeps/x86/tst-string-rtm.h
190885
@@ -0,0 +1,72 @@
190885
+/* Test string function in a transactionally executing RTM region.
190885
+   Copyright (C) 2021 Free Software Foundation, Inc.
190885
+   This file is part of the GNU C Library.
190885
+
190885
+   The GNU C Library is free software; you can redistribute it and/or
190885
+   modify it under the terms of the GNU Lesser General Public
190885
+   License as published by the Free Software Foundation; either
190885
+   version 2.1 of the License, or (at your option) any later version.
190885
+
190885
+   The GNU C Library is distributed in the hope that it will be useful,
190885
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
190885
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
190885
+   Lesser General Public License for more details.
190885
+
190885
+   You should have received a copy of the GNU Lesser General Public
190885
+   License along with the GNU C Library; if not, see
190885
+   <https://www.gnu.org/licenses/>.  */
190885
+
190885
+#include <string.h>
190885
+#include <x86intrin.h>
190885
+#include <sys/platform/x86.h>
190885
+#include <support/check.h>
190885
+#include <support/test-driver.h>
190885
+
190885
+static int
190885
+do_test_1 (const char *name, unsigned int loop, int (*prepare) (void),
190885
+	   int (*function) (void))
190885
+{
190885
+  if (!CPU_FEATURE_USABLE (RTM))
190885
+    return EXIT_UNSUPPORTED;
190885
+
190885
+  int status = prepare ();
190885
+  if (status != EXIT_SUCCESS)
190885
+    return status;
190885
+
190885
+  unsigned int i;
190885
+  unsigned int naborts = 0;
190885
+  unsigned int failed = 0;
190885
+  for (i = 0; i < loop; i++)
190885
+    {
190885
+      failed |= function ();
190885
+      if (_xbegin() == _XBEGIN_STARTED)
190885
+	{
190885
+	  failed |= function ();
190885
+	  _xend();
190885
+	}
190885
+      else
190885
+	{
190885
+	  failed |= function ();
190885
+	  ++naborts;
190885
+	}
190885
+    }
190885
+
190885
+  if (failed)
190885
+    FAIL_EXIT1 ("%s() failed", name);
190885
+
190885
+  if (naborts)
190885
+    {
190885
+      /* NB: Low single digit (<= 5%) noise-level aborts are normal for
190885
+	 TSX.  */
190885
+      double rate = 100 * ((double) naborts) / ((double) loop);
190885
+      if (rate > 5)
190885
+	FAIL_EXIT1 ("TSX abort rate: %.2f%% (%d out of %d)",
190885
+		    rate, naborts, loop);
190885
+    }
190885
+
190885
+  return EXIT_SUCCESS;
190885
+}
190885
+
190885
+static int do_test (void);
190885
+
190885
+#include <support/test-driver.c>
190885
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
190885
new file mode 100644
190885
index 00000000..0dcf14db
190885
--- /dev/null
190885
+++ b/sysdeps/x86/tst-strlen-rtm.c
190885
@@ -0,0 +1,53 @@
190885
+/* Test case for strlen inside a transactionally executing RTM region.
190885
+   Copyright (C) 2021 Free Software Foundation, Inc.
190885
+   This file is part of the GNU C Library.
190885
+
190885
+   The GNU C Library is free software; you can redistribute it and/or
190885
+   modify it under the terms of the GNU Lesser General Public
190885
+   License as published by the Free Software Foundation; either
190885
+   version 2.1 of the License, or (at your option) any later version.
190885
+
190885
+   The GNU C Library is distributed in the hope that it will be useful,
190885
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
190885
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
190885
+   Lesser General Public License for more details.
190885
+
190885
+   You should have received a copy of the GNU Lesser General Public
190885
+   License along with the GNU C Library; if not, see
190885
+   <https://www.gnu.org/licenses/>.  */
190885
+
190885
+#include <tst-string-rtm.h>
190885
+
190885
+#define LOOP 3000
190885
+#define STRING_SIZE 1024
190885
+char string1[STRING_SIZE];
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+prepare (void)
190885
+{
190885
+  memset (string1, 'a', STRING_SIZE - 1);
190885
+  string1[STRING_SIZE - 100] = '\0';
190885
+  size_t len = strlen (string1);
190885
+  if (len == STRING_SIZE - 100)
190885
+    return EXIT_SUCCESS;
190885
+  else
190885
+    return EXIT_FAILURE;
190885
+}
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+function (void)
190885
+{
190885
+  size_t len = strlen (string1);
190885
+  if (len == STRING_SIZE - 100)
190885
+    return 0;
190885
+  else
190885
+    return 1;
190885
+}
190885
+
190885
+static int
190885
+do_test (void)
190885
+{
190885
+  return do_test_1 ("strlen", LOOP, prepare, function);
190885
+}
190885
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
190885
new file mode 100644
190885
index 00000000..236ad951
190885
--- /dev/null
190885
+++ b/sysdeps/x86/tst-strncmp-rtm.c
190885
@@ -0,0 +1,52 @@
190885
+/* Test case for strncmp inside a transactionally executing RTM region.
190885
+   Copyright (C) 2021 Free Software Foundation, Inc.
190885
+   This file is part of the GNU C Library.
190885
+
190885
+   The GNU C Library is free software; you can redistribute it and/or
190885
+   modify it under the terms of the GNU Lesser General Public
190885
+   License as published by the Free Software Foundation; either
190885
+   version 2.1 of the License, or (at your option) any later version.
190885
+
190885
+   The GNU C Library is distributed in the hope that it will be useful,
190885
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
190885
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
190885
+   Lesser General Public License for more details.
190885
+
190885
+   You should have received a copy of the GNU Lesser General Public
190885
+   License along with the GNU C Library; if not, see
190885
+   <https://www.gnu.org/licenses/>.  */
190885
+
190885
+#include <tst-string-rtm.h>
190885
+
190885
+#define LOOP 3000
190885
+#define STRING_SIZE 1024
190885
+char string1[STRING_SIZE];
190885
+char string2[STRING_SIZE];
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+prepare (void)
190885
+{
190885
+  memset (string1, 'a', STRING_SIZE - 1);
190885
+  memset (string2, 'a', STRING_SIZE - 1);
190885
+  if (strncmp (string1, string2, STRING_SIZE) == 0)
190885
+    return EXIT_SUCCESS;
190885
+  else
190885
+    return EXIT_FAILURE;
190885
+}
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+function (void)
190885
+{
190885
+  if (strncmp (string1, string2, STRING_SIZE) == 0)
190885
+    return 0;
190885
+  else
190885
+    return 1;
190885
+}
190885
+
190885
+static int
190885
+do_test (void)
190885
+{
190885
+  return do_test_1 ("strncmp", LOOP, prepare, function);
190885
+}
190885
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
190885
new file mode 100644
190885
index 00000000..e32bfaf5
190885
--- /dev/null
190885
+++ b/sysdeps/x86/tst-strrchr-rtm.c
190885
@@ -0,0 +1,53 @@
190885
+/* Test case for strrchr inside a transactionally executing RTM region.
190885
+   Copyright (C) 2021 Free Software Foundation, Inc.
190885
+   This file is part of the GNU C Library.
190885
+
190885
+   The GNU C Library is free software; you can redistribute it and/or
190885
+   modify it under the terms of the GNU Lesser General Public
190885
+   License as published by the Free Software Foundation; either
190885
+   version 2.1 of the License, or (at your option) any later version.
190885
+
190885
+   The GNU C Library is distributed in the hope that it will be useful,
190885
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
190885
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
190885
+   Lesser General Public License for more details.
190885
+
190885
+   You should have received a copy of the GNU Lesser General Public
190885
+   License along with the GNU C Library; if not, see
190885
+   <https://www.gnu.org/licenses/>.  */
190885
+
190885
+#include <tst-string-rtm.h>
190885
+
190885
+#define LOOP 3000
190885
+#define STRING_SIZE 1024
190885
+char string1[STRING_SIZE];
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+prepare (void)
190885
+{
190885
+  memset (string1, 'a', STRING_SIZE - 1);
190885
+  string1[STRING_SIZE - 100] = 'c';
190885
+  char *p = strrchr (string1, 'c');
190885
+  if (p == &string1[STRING_SIZE - 100])
190885
+    return EXIT_SUCCESS;
190885
+  else
190885
+    return EXIT_FAILURE;
190885
+}
190885
+
190885
+__attribute__ ((noinline, noclone))
190885
+static int
190885
+function (void)
190885
+{
190885
+  char *p = strrchr (string1, 'c');
190885
+  if (p == &string1[STRING_SIZE - 100])
190885
+    return 0;
190885
+  else
190885
+    return 1;
190885
+}
190885
+
190885
+static int
190885
+do_test (void)
190885
+{
190885
+  return do_test_1 ("strrchr", LOOP, prepare, function);
190885
+}
190885
-- 
190885
GitLab
190885