All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <petr.vorel@gmail.com>
To: ltp@lists.linux.it
Cc: Hui Min Mina Chou <minachou@andestech.com>,
	Khem Raj <raj.khem@gmail.com>
Subject: [LTP] [PATCH v2 1/2] m4: mprotect04: Replace __builtin___clear_cache with __clear_cache
Date: Sun, 12 Oct 2025 21:49:45 +0200	[thread overview]
Message-ID: <20251012194946.370905-2-petr.vorel@gmail.com> (raw)
In-Reply-To: <20251012194946.370905-1-petr.vorel@gmail.com>

__clear_cache() should be quite common now and we already use it in
hugemmap15.c. Convert autotools m4 check to detect it.

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
Same as v1.

 configure.ac                                  |  2 +-
 m4/ltp-builtin_clear_cache.m4                 | 19 ------------------
 m4/ltp-clear_cache.m4                         | 20 +++++++++++++++++++
 .../kernel/syscalls/mprotect/mprotect04.c     |  7 +++----
 4 files changed, 24 insertions(+), 24 deletions(-)
 delete mode 100644 m4/ltp-builtin_clear_cache.m4
 create mode 100644 m4/ltp-clear_cache.m4

diff --git a/configure.ac b/configure.ac
index 0480f46ca2..461fa2b577 100644
--- a/configure.ac
+++ b/configure.ac
@@ -393,9 +393,9 @@ AC_CONFIG_COMMANDS([syscalls.h], [cd ${ac_top_srcdir}/include/lapi/syscalls; ./g
 # NOTE: don't create custom functions for simple checks, put them into this file
 LTP_CHECK_ACL_SUPPORT
 LTP_CHECK_ATOMIC_MEMORY_MODEL
-LTP_CHECK_BUILTIN_CLEAR_CACHE
 LTP_CHECK_CAPABILITY_SUPPORT
 LTP_CHECK_CC_WARN_OLDSTYLE
+LTP_CHECK_CLEAR_CACHE
 LTP_CHECK_CRYPTO
 LTP_CHECK_FORTIFY_SOURCE
 LTP_CHECK_KERNEL_DEVEL
diff --git a/m4/ltp-builtin_clear_cache.m4 b/m4/ltp-builtin_clear_cache.m4
deleted file mode 100644
index 86e1cfc914..0000000000
--- a/m4/ltp-builtin_clear_cache.m4
+++ /dev/null
@@ -1,19 +0,0 @@
-dnl SPDX-License-Identifier: GPL-2.0-or-later
-dnl Copyright (c) Linux Test Project, 2016
-
-AC_DEFUN([LTP_CHECK_BUILTIN_CLEAR_CACHE],[
-	AC_MSG_CHECKING([for __builtin___clear_cache])
-	AC_LINK_IFELSE([AC_LANG_SOURCE([[
-int main(void) {
-	char arr[16];
-	__builtin___clear_cache(arr, arr + sizeof(arr));
-        return 0;
-}]])],[has_bcc="yes"])
-
-if test "x$has_bcc" = xyes; then
-	AC_DEFINE(HAVE_BUILTIN_CLEAR_CACHE,1,[Define to 1 if you have __builtin___clear_cache])
-	AC_MSG_RESULT(yes)
-else
-	AC_MSG_RESULT(no)
-fi
-])
diff --git a/m4/ltp-clear_cache.m4 b/m4/ltp-clear_cache.m4
new file mode 100644
index 0000000000..99c6a1b653
--- /dev/null
+++ b/m4/ltp-clear_cache.m4
@@ -0,0 +1,20 @@
+dnl SPDX-License-Identifier: GPL-2.0-or-later
+dnl Copyright (c) Linux Test Project, 2016
+dnl Copyright (c) Linux Test Project, 2025
+
+AC_DEFUN([LTP_CHECK_CLEAR_CACHE],[
+	AC_MSG_CHECKING([for __clear_cache])
+	AC_LINK_IFELSE([AC_LANG_SOURCE([[
+int main(void) {
+	char arr[16];
+	__clear_cache(arr, arr + sizeof(arr));
+        return 0;
+}]])],[has_clear_cache="yes"])
+
+if test "x$has_clear_cache" = xyes; then
+	AC_DEFINE(HAVE_CLEAR_CACHE, 1, [Define to 1 if you have __clear_cache])
+	AC_MSG_RESULT(yes)
+else
+	AC_MSG_RESULT(no)
+fi
+])
diff --git a/testcases/kernel/syscalls/mprotect/mprotect04.c b/testcases/kernel/syscalls/mprotect/mprotect04.c
index 6c7f6bd017..fa4d3be4ba 100644
--- a/testcases/kernel/syscalls/mprotect/mprotect04.c
+++ b/testcases/kernel/syscalls/mprotect/mprotect04.c
@@ -152,11 +152,10 @@ static int page_present(void *p)
 
 static void clear_cache(void *start, int len)
 {
-#if HAVE_BUILTIN_CLEAR_CACHE == 1
-	__builtin___clear_cache(start, start + len);
+#ifdef HAVE_CLEAR_CACHE
+	__clear_cache(start, start + len);
 #else
-	tst_brkm(TCONF, cleanup,
-		"compiler doesn't have __builtin___clear_cache()");
+	tst_brkm(TCONF, cleanup, "compiler doesn't have __clear_cache()");
 #endif
 }
 
-- 
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2025-10-12 19:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-12 19:49 [LTP] [PATCH v2 0/2] __builtin___clear_cache() => __clear_cache() Petr Vorel
2025-10-12 19:49 ` Petr Vorel [this message]
2025-12-18 12:22   ` [LTP] [PATCH v2 1/2] m4: mprotect04: Replace __builtin___clear_cache with __clear_cache Andrea Cervesato via ltp
2026-01-22 10:23   ` Jan Stancek via ltp
2025-10-12 19:49 ` [LTP] [PATCH v2 2/2] hugemmap15: Check for __clear_cache() Petr Vorel
2026-03-26 10:31   ` Andrea Cervesato via ltp
2026-03-26 11:05     ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251012194946.370905-2-petr.vorel@gmail.com \
    --to=petr.vorel@gmail.com \
    --cc=ltp@lists.linux.it \
    --cc=minachou@andestech.com \
    --cc=raj.khem@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.