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 Define swap in ...
details: https://anonhg.NetBSD.org/src/rev/7040846ebf9e
branches: riastradh-drm2
changeset: 788099:7040846ebf9e
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Jul 24 02:14:10 2013 +0000
description:
Define swap in <linux/kernel.h>.
Kinda hokey definition, but this avoids typeof.
diffstat:
sys/external/bsd/drm2/include/linux/kernel.h | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diffs (27 lines):
diff -r ec23643bca98 -r 7040846ebf9e sys/external/bsd/drm2/include/linux/kernel.h
--- a/sys/external/bsd/drm2/include/linux/kernel.h Wed Jul 24 02:13:57 2013 +0000
+++ b/sys/external/bsd/drm2/include/linux/kernel.h Wed Jul 24 02:14:10 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kernel.h,v 1.1.2.6 2013/07/24 02:12:00 riastradh Exp $ */
+/* $NetBSD: kernel.h,v 1.1.2.7 2013/07/24 02:14:10 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -53,4 +53,17 @@
#define WARN_ON(CONDITION) WARN(CONDITION, "%s\n", #CONDITION)
+#define swap(X, Y) do \
+{ \
+ /* XXX Kludge for type-safety. */ \
+ if (&(X) != &(Y)) { \
+ CTASSERT(sizeof(X) == sizeof(Y)); \
+ /* XXX Can't do this much better without typeof. */ \
+ char __swap_tmp[sizeof(X)]; \
+ (void)memcpy(__swap_tmp, &(X), sizeof(X)); \
+ (void)memcpy(&(X), &(Y), sizeof(X)); \
+ (void)memcpy(&(Y), __swap_tmp, sizeof(X)); \
+ } \
+} while (0)
+
#endif /* _LINUX_KERNEL_H_ */
Home |
Main Index |
Thread Index |
Old Index