[coreboot-gerrit] New patch to review for coreboot: a68bde2 Move container_of() macro to stddef.h

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Mon Jan 5 20:13:10 CET 2015


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8109

-gerrit

commit a68bde222cd70e1c61f497ff2931611402d1d5e4
Author: Stefan Reinauer <reinauer at chromium.org>
Date:   Mon Jan 5 11:09:11 2015 -0800

    Move container_of() macro to stddef.h
    
    It's not a SPI related macro, hence move it to stddef.h where
    other similar macros live.
    
    Change-Id: I1008894af7a272f1bc36d3ae6cee3881132b6ba9
    Signed-off-by: Stefan Reinauer <stefan.reinauer at coreboot.org>
---
 src/include/spi_flash.h | 11 -----------
 src/include/stddef.h    | 11 +++++++++++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h
index 7cf0229..8b8b0c5 100644
--- a/src/include/spi_flash.h
+++ b/src/include/spi_flash.h
@@ -28,17 +28,6 @@
 #include <console/console.h>
 #include <spi-generic.h>
 
-/**
- * container_of - cast a member of a structure out to the containing structure
- * @ptr:	the pointer to the member.
- * @type:	the type of the container struct this is embedded in.
- * @member:	the name of the member within the struct.
- *
- */
-#define container_of(ptr, type, member) ({			\
-	const typeof( ((type *)0)->member ) *__mptr = (ptr);	\
-	(type *)( (char *)__mptr - offsetof(type,member) );})
-
 struct spi_flash {
 	struct spi_slave *spi;
 
diff --git a/src/include/stddef.h b/src/include/stddef.h
index 137de04..2c41c5e 100644
--- a/src/include/stddef.h
+++ b/src/include/stddef.h
@@ -32,6 +32,17 @@ typedef unsigned int wint_t;
 	offsetof(struct structure, member) == offset, \
 	"`struct " #structure "` offset for `" #member "` is not " #offset )
 
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr:	the pointer to the member.
+ * @type:	the type of the container struct this is embedded in.
+ * @member:	the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({			\
+	const typeof( ((type *)0)->member ) *__mptr = (ptr);	\
+	(type *)( (char *)__mptr - offsetof(type,member) );})
+
 #ifdef __PRE_RAM__
 #define ROMSTAGE_CONST const
 #else



More information about the coreboot-gerrit mailing list