All of lore.kernel.org
 help / color / mirror / Atom feed
From: Colin Vidal <colin@cvidal.org>
To: "kernel-hardening@lists.openwall.com"
	<kernel-hardening@lists.openwall.com>,
	"Reshetova, Elena" <elena.reshetova@intel.com>
Subject: [kernel-hardening] atomic64_wrap_t generic implementation
Date: Wed, 12 Oct 2016 21:42:12 +0200	[thread overview]
Message-ID: <1476301332.19131.24.camel@cvidal.org> (raw)

Hi Elena,

diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
index dad68bf..4987419 100644
--- a/include/asm-generic/atomic64.h
+++ b/include/asm-generic/atomic64.h
@@ -16,6 +16,8 @@ typedef struct {
        long long counter;
 } atomic64_t;
 
+typedef atomic64_t atomic64_wrap_t;
+
 #define ATOMIC64_INIT(i)       { (i) }
 
 extern long long atomic64_read(const atomic64_t *v);
@@ -62,4 +64,15 @@ extern int    atomic64_add_unless(atomic64_t *v, long long a, long long u);
 #define atomic64_dec_and_test(v)       (atomic64_dec_return((v)) == 0)
 #define atomic64_inc_not_zero(v)       atomic64_add_unless((v), 1LL, 0LL)
 
+#define atomic64_read_wrap(v) atomic64_read(v)
+#define atomic64_set_wrap(v, i) atomic64_set((v), (i))
+#define atomic64_add_wrap(a, v) atomic64_add((a), (v))
+#define atomic64_add_return_wrap(a, v) atomic64_add_return((a), (v))
+#define atomic64_sub_wrap(a, v) atomic64_sub((a), (v))
+#define atomic64_inc_wrap(v) atomic64_inc(v)
+#define atomic64_inc_return_wrap(v) atomic64_inc_return(v)
+#define atomic64_dec_wrap(v) atomic64_dec(v)
+#define atomic64_cmpxchg_wrap(v, o, n) atomic64_cmpxchg((v), (o), (n))
+#define atomic64_xchg_wrap(v, n) atomic64_xchg((v), (n))

Isen't there a type error ? For instance:

atomic64_wrap_t atom_wrap;

atomic64_read_wrap(atom_wrap) will be expanded into
atomic64_read(atom_wrap), which would lead to a type error (atomic64_t
expected).

Perhaps the more simple thing to do would be

-typedef atomic64_t atomic64_wrap_t;
+#define atomic64_wrap_t atomic64_t

since the implementations are the same here.

Or I missed something obvious?

Thanks,

Colin

             reply	other threads:[~2016-10-12 19:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-12 19:42 Colin Vidal [this message]
2016-10-13 17:25 ` [kernel-hardening] RE: atomic64_wrap_t generic implementation Reshetova, Elena
2016-10-13 18:59   ` [kernel-hardening] " Colin Vidal
2016-10-13 19:21   ` [kernel-hardening] " David Windsor
2016-10-14 12:47     ` Reshetova, Elena
2016-10-18  8:04 ` [kernel-hardening] " AKASHI Takahiro
2016-10-18  8:35   ` Colin Vidal

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=1476301332.19131.24.camel@cvidal.org \
    --to=colin@cvidal.org \
    --cc=elena.reshetova@intel.com \
    --cc=kernel-hardening@lists.openwall.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.