Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/riastradh-drm2]: src/sys/external/bsd/drm2/include/linux Make container_...
details: https://anonhg.NetBSD.org/src/rev/2228fc5614b2
branches: riastradh-drm2
changeset: 788230:2228fc5614b2
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Jul 24 02:49:52 2013 +0000
description:
Make container_of type-safe with the help of a judicious sizeof.
Still avoids multiple evaluation of the pointer operand expression.
diffstat:
sys/external/bsd/drm2/include/linux/kernel.h | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diffs (21 lines):
diff -r 1b7dc7099157 -r 2228fc5614b2 sys/external/bsd/drm2/include/linux/kernel.h
--- a/sys/external/bsd/drm2/include/linux/kernel.h Wed Jul 24 02:49:35 2013 +0000
+++ b/sys/external/bsd/drm2/include/linux/kernel.h Wed Jul 24 02:49:52 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kernel.h,v 1.1.2.10 2013/07/24 02:28:07 riastradh Exp $ */
+/* $NetBSD: kernel.h,v 1.1.2.11 2013/07/24 02:49:52 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -41,7 +41,10 @@
#define unlikely(X) __predict_false(X)
#define container_of(PTR, TYPE, FIELD) \
- ((TYPE *)(((char *)(PTR)) - offsetof(TYPE, FIELD)))
+ ((void)sizeof((PTR) - \
+ &((TYPE *)(((char *)(PTR)) - \
+ offsetof(TYPE, FIELD)))->FIELD), \
+ ((TYPE *)(((char *)(PTR)) - offsetof(TYPE, FIELD))))
#define ARRAY_SIZE(ARRAY) __arraycount(ARRAY)
Home |
Main Index |
Thread Index |
Old Index