The branch main has been updated by ngie:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d1f1402dff63dd163d4ba4ac65f7f2ffd00c5e08

commit d1f1402dff63dd163d4ba4ac65f7f2ffd00c5e08
Author:     Enji Cooper <[email protected]>
AuthorDate: 2026-02-20 20:24:46 +0000
Commit:     Enji Cooper <[email protected]>
CommitDate: 2026-02-20 22:45:06 +0000

    libnetbsd: import `__CTASSERT(..)` macros
    
    These compile-time assert macros are similar to `Static_assert` on FreeBSD.
    
    These macros are in use in newer versions of `contrib/netbsd-tests`.
    
    Obtained from:  https://github.com/NetBSD/src (c26cc77b3a0b26b95a2)
    MFC after:      1 week
---
 lib/libnetbsd/sys/cdefs.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lib/libnetbsd/sys/cdefs.h b/lib/libnetbsd/sys/cdefs.h
index fcc3cc6f15be..78c80735ad01 100644
--- a/lib/libnetbsd/sys/cdefs.h
+++ b/lib/libnetbsd/sys/cdefs.h
@@ -54,6 +54,22 @@
 #define        ___STRING(x)    __STRING(x)
 #define        ___CONCAT(x,y)  __CONCAT(x,y)
 
+/*
+ * Compile Time Assertion.
+ */
+#ifdef __COUNTER__
+#define        __CTASSERT(x)           __CTASSERT0(x, __ctassert, __COUNTER__)
+#else
+#define        __CTASSERT(x)           __CTASSERT99(x, __INCLUDE_LEVEL__, 
__LINE__)
+#define        __CTASSERT99(x, a, b)   __CTASSERT0(x, __CONCAT(__ctassert,a), \
+                                              __CONCAT(_,b))
+#endif
+#define        __CTASSERT0(x, y, z)    __CTASSERT1(x, y, z)
+#define        __CTASSERT1(x, y, z)    \
+       struct y ## z ## _struct { \
+               unsigned int y ## z : /*CONSTCOND*/(x) ? 1 : -1; \
+       }
+
 /*
  * The following macro is used to remove const cast-away warnings
  * from gcc -Wcast-qual; it should be used with caution because it

Reply via email to