Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/include/asm Adapt DRMKMS BUILD_BUG_ON_...



details:   https://anonhg.NetBSD.org/src/rev/aab2e2aa05d3
branches:  trunk
changeset: 454521:aab2e2aa05d3
user:      kamil <kamil%NetBSD.org@localhost>
date:      Fri Sep 20 10:54:07 2019 +0000

description:
Adapt DRMKMS BUILD_BUG_ON_MSG() to static_assert semantics

static_assert is violated with runtime-only compiler semantics in a few
places. Instead of breaking the build, stop asserting these corner cases.

diffstat:

 sys/external/bsd/drm2/include/asm/bug.h |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (24 lines):

diff -r cc36230fbeea -r aab2e2aa05d3 sys/external/bsd/drm2/include/asm/bug.h
--- a/sys/external/bsd/drm2/include/asm/bug.h   Fri Sep 20 10:34:54 2019 +0000
+++ b/sys/external/bsd/drm2/include/asm/bug.h   Fri Sep 20 10:54:07 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bug.h,v 1.4 2018/08/27 06:19:16 riastradh Exp $        */
+/*     $NetBSD: bug.h,v 1.5 2019/09/20 10:54:07 kamil Exp $    */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -40,7 +40,13 @@
 
 #define        BUILD_BUG()             do {} while (0)
 #define        BUILD_BUG_ON(CONDITION) CTASSERT(!(CONDITION))
-#define        BUILD_BUG_ON_MSG(CONDITION,MSG) CTASSERT(!(CONDITION))
+/*
+ * static_assert is violated with runtime-only compiler semantics in a few
+ * places. Instead of breaking the build, stop asserting these corner cases.
+ */
+#define        BUILD_BUG_ON_MSG(CONDITION,MSG)                                 \
+       CTASSERT((__builtin_choose_expr(                                \
+               __builtin_constant_p(CONDITION), !(CONDITION), 1)))
 
 
 /* XXX Rate limit?  */



Home | Main Index | Thread Index | Old Index