Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys void invading the users' namespace with __launder_ty...
details: https://anonhg.NetBSD.org/src/rev/137c2b84609f
branches: trunk
changeset: 791637:137c2b84609f
user: mrg <mrg%NetBSD.org@localhost>
date: Wed Nov 27 04:24:15 2013 +0000
description:
void invading the users' namespace with __launder_type().
adjust the comment a little.
diffstat:
sys/sys/queue.h | 29 +++++++++++++++++------------
1 files changed, 17 insertions(+), 12 deletions(-)
diffs (47 lines):
diff -r 101708165c1d -r 137c2b84609f sys/sys/queue.h
--- a/sys/sys/queue.h Wed Nov 27 02:04:48 2013 +0000
+++ b/sys/sys/queue.h Wed Nov 27 04:24:15 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: queue.h,v 1.62 2013/11/26 16:57:04 christos Exp $ */
+/* $NetBSD: queue.h,v 1.63 2013/11/27 04:24:15 mrg Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -640,21 +640,26 @@
*/
/*
- * We use this ugly hack to work around the fact that the CIRCLEQ
- * macros violate the C aliasing rules by comparing 'struct name *'
- * and 'struct type *' (see CIRCLEQ_HEAD() below). Modern compilers
- * (such as GCC 4.8) declare this to be always false and this makes
- * most of the macros below not function correctly.
+ * __launder_type(): We use this ugly hack to work around the the compiler
+ * noticing that two types may not alias each other and elide tests in code.
+ * We hit this in the CIRCLEQ macros when comparing 'struct name *' and
+ * 'struct type *' (see CIRCLEQ_HEAD()). Modern compilers (such as GCC
+ * 4.8) declare these comparisons as always false, causing the code to
+ * not run as designed.
+ *
+ * This hack is only to be used for comparisons and thus can be fully const.
+ * Do not use for assignment.
*
- * This hack is only to be used for comparisons and thus can be
- * fully const. Do not use for assignment.
+ * If we ever choose to change the ABI of the CIRCLEQ macros, we could fix
+ * this by changing the head/tail sentinal values, but see the note above
+ * this one.
*/
-static inline const void * __launder_type(const void *x);
+static inline const void * __launder_type(const void *);
static inline const void *
-__launder_type(const void *x)
+__launder_type(const void *__x)
{
- __asm volatile("" : "+r" (x));
- return x;
+ __asm __volatile("" : "+r" (__x));
+ return __x;
}
#if defined(_KERNEL) && defined(QUEUEDEBUG)
Home |
Main Index |
Thread Index |
Old Index