[Glibc-bsd-commits] r4745 - in trunk/freebsd-glue: debian include/sys

Robert Millan rmh at alioth.debian.org
Sat Jul 13 21:27:55 UTC 2013


Author: rmh
Date: 2013-07-13 21:27:55 +0000 (Sat, 13 Jul 2013)
New Revision: 4745

Modified:
   trunk/freebsd-glue/debian/changelog
   trunk/freebsd-glue/include/sys/cdefs.h
Log:
Add __containerof() to <sys/cdefs.h>.

Modified: trunk/freebsd-glue/debian/changelog
===================================================================
--- trunk/freebsd-glue/debian/changelog	2013-07-13 14:23:34 UTC (rev 4744)
+++ trunk/freebsd-glue/debian/changelog	2013-07-13 21:27:55 UTC (rev 4745)
@@ -1,6 +1,7 @@
 freebsd-glue (0.0.8) UNRELEASED; urgency=low
 
   * Include <grp.h> in <unistd.h> (for initgroups).
+  * Add __containerof() to <sys/cdefs.h>.
 
  -- Robert Millan <rmh at debian.org>  Wed, 10 Jul 2013 00:12:06 +0200
 

Modified: trunk/freebsd-glue/include/sys/cdefs.h
===================================================================
--- trunk/freebsd-glue/include/sys/cdefs.h	2013-07-13 14:23:34 UTC (rev 4744)
+++ trunk/freebsd-glue/include/sys/cdefs.h	2013-07-13 21:27:55 UTC (rev 4745)
@@ -52,6 +52,11 @@
 #define __printflike(fmtarg, firstvararg) \
 	__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
 
+#define	__containerof(x, s, m) ({					\
+	const volatile __typeof(((s *)0)->m) *__x = (x);		\
+	__DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\
+})
+
 /* Requires freebsd-gcc extensions */
 #define __printf0like(fmtarg, firstvararg)
 




More information about the Glibc-bsd-commits mailing list