Linux-Sparse Archive on lore.kernel.org
 help / color / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 11/12] builtin: add support for __atomic_clear()
Date: Sun, 18 Oct 2020 00:56:32 +0200
Message-ID: <20201017225633.53274-12-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20201017225633.53274-1-luc.vanoostenryck@gmail.com>

The first argument is supposed to be a pointer to a bool, but
of course, a volatile qualified pointer should be accepted too.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 builtin.c                         |  1 +
 validation/builtin-atomic-clear.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
 create mode 100644 validation/builtin-atomic-clear.c

diff --git a/builtin.c b/builtin.c
index 94f86a87c3e2..1c502597315f 100644
--- a/builtin.c
+++ b/builtin.c
@@ -483,6 +483,7 @@ static const struct builtin_fn builtins_common[] = {
 #define vol_ptr		&volatile_ptr_ctype
 	{ "__atomic_add_fetch", NULL, 0, { vol_ptr, &dyntype, &int_ctype }, .op = &atomic_op },
 	{ "__atomic_and_fetch", NULL, 0, { vol_ptr, &dyntype, &int_ctype }, .op = &atomic_op },
+	{ "__atomic_clear", &void_ctype, 0, { &volatile_bool_ptr_ctype, &int_ctype }},
 	{ "__atomic_compare_exchange", &bool_ctype, 0, { vol_ptr, &ptr_ctype, &ptr_ctype, &bool_ctype, &int_ctype, &int_ctype }, .op = &atomic_op },
 	{ "__atomic_compare_exchange_n", &bool_ctype, 0, { vol_ptr, &ptr_ctype, &dyntype, &bool_ctype, &int_ctype, &int_ctype }, .op = &atomic_op },
 	{ "__atomic_exchange", &void_ctype, 0, { vol_ptr, &ptr_ctype, &ptr_ctype, &int_ctype }, .op = &atomic_op },
diff --git a/validation/builtin-atomic-clear.c b/validation/builtin-atomic-clear.c
new file mode 100644
index 000000000000..ef430c64c244
--- /dev/null
+++ b/validation/builtin-atomic-clear.c
@@ -0,0 +1,15 @@
+void foo(void *ptr, _Bool *bptr, volatile void *vptr, volatile _Bool *vbptr, int mo)
+{
+	__atomic_clear(ptr, mo);
+	__atomic_clear(bptr, mo);
+	__atomic_clear(vptr, mo);
+	__atomic_clear(vbptr, mo);
+}
+
+/*
+ * check-name: builtin-atomic-clear
+ *
+ * check-error-start
+builtin-atomic-clear.c:1:6: warning: symbol 'foo' was not declared. Should it be static?
+ * check-error-end
+ */
-- 
2.28.0


  parent reply index

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-17 22:56 [PATCH 00/12] fix and complete the evaluation of atomic builtins Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 01/12] builtin: add generic .args method Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 02/12] builtin: add builtin type for volatile void * Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 03/12] builtin: make eval_sync_compare_and_swap() more generic Luc Van Oostenryck
2020-10-18 21:31   ` Ramsay Jones
2020-10-19  4:59     ` Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 04/12] builtin: evaluate __sync_*_fetch*() Luc Van Oostenryck
2020-10-18 23:59   ` Ramsay Jones
2020-10-19  4:44     ` Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 05/12] builtin: fix evaluation of __sync_lock_release Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 06/12] builtin: __sync_synchronize() too is variadic Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 07/12] builtin: add predefines for __ATOMIC_RELAXED & friends Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 08/12] builtin: add support for __atomic_add_fetch(), Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 09/12] builtin: add support for others generic atomic builtins Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 10/12] builtin: add builtin type: [volatile] pointer to bool Luc Van Oostenryck
2020-10-17 22:56 ` Luc Van Oostenryck [this message]
2020-10-17 22:56 ` [PATCH 12/12] builtin: add support for remaining atomic builtins Luc Van Oostenryck

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=20201017225633.53274-12-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    /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

Linux-Sparse Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-sparse/0 linux-sparse/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-sparse linux-sparse/ https://lore.kernel.org/linux-sparse \
		linux-sparse@vger.kernel.org
	public-inbox-index linux-sparse

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-sparse


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git