Backports Archive on lore.kernel.org
 help / color / Atom feed
From: Hauke Mehrtens <hauke@hauke-m.de>
To: backports@vger.kernel.org
Cc: johannes@sipsolutions.net, Hauke Mehrtens <hauke@hauke-m.de>
Subject: [PATCH 3/8] backports: stddef.h: Add sizeof_field()
Date: Sat, 21 Mar 2020 00:39:45 +0100
Message-ID: <20200320233950.32257-4-hauke@hauke-m.de> (raw)
In-Reply-To: <20200320233950.32257-1-hauke@hauke-m.de>

This backports sizeof_field() from upstream Linux commit 4229a470175b
("stddef.h: Introduce sizeof_field()"). This is now used by multiple
drivers.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 backport/backport-include/linux/stddef.h | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/backport/backport-include/linux/stddef.h b/backport/backport-include/linux/stddef.h
index 2c836b00..a6cdc67d 100644
--- a/backport/backport-include/linux/stddef.h
+++ b/backport/backport-include/linux/stddef.h
@@ -2,6 +2,16 @@
 #define __BACKPORT_LINUX_STDDEF_H
 #include_next <linux/stddef.h>
 
+#ifndef sizeof_field
+/**
+ * sizeof_field(TYPE, MEMBER)
+ *
+ * @TYPE: The structure containing the field of interest
+ * @MEMBER: The field to return the size of
+ */
+#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER))
+#endif
+
 #ifndef offsetofend
 /**
  * offsetofend(TYPE, MEMBER)
@@ -10,7 +20,7 @@
  * @MEMBER: The member within the structure to get the end offset of
  */
 #define offsetofend(TYPE, MEMBER) \
-	(offsetof(TYPE, MEMBER)	+ sizeof(((TYPE *)0)->MEMBER))
+	(offsetof(TYPE, MEMBER)	+ sizeof_field(TYPE, MEMBER))
 #endif
 
 #endif /* __BACKPORT_LINUX_STDDEF_H */
-- 
2.20.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in

  parent reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-20 23:39 [PATCH 0/8] backports: Update to version 5.5.10 Hauke Mehrtens
2020-03-20 23:39 ` [PATCH 1/8] backports: patches: Refresh against kernel 5.5.10 Hauke Mehrtens
2020-03-20 23:39 ` [PATCH 2/8] backports: fs.h: Add compat_ptr_ioctl() Hauke Mehrtens
2020-03-20 23:39 ` Hauke Mehrtens [this message]
2020-03-20 23:39 ` [PATCH 4/8] backports: Make qtnfmac depend on kernel 5.1 or later Hauke Mehrtens
2020-03-20 23:39 ` [PATCH 5/8] backports: rcupdate.h: Add rcu_swap_protected() Hauke Mehrtens
2020-03-20 23:39 ` [PATCH 6/8] backports: netdevice.h: Add return value to napi_complete() Hauke Mehrtens
2020-03-20 23:39 ` [PATCH 7/8] backports: Do not build BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION on < 3.13 Hauke Mehrtens
2020-03-20 23:39 ` [PATCH 8/8] backports: page_ref.h: Exclude page_ref_count() on kernel >= 4.4.216 Hauke Mehrtens

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=20200320233950.32257-4-hauke@hauke-m.de \
    --to=hauke@hauke-m.de \
    --cc=backports@vger.kernel.org \
    --cc=johannes@sipsolutions.net \
    /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

Backports Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/backports/0 backports/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 backports backports/ https://lore.kernel.org/backports \
		backports@vger.kernel.org
	public-inbox-index backports

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.backports


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