Date: Sat, 21 Feb 2026 09:53:14 -0800 From: "Enji Cooper (yaneurabeya)" <yaneurabeya@gmail.com> To: John Baldwin <jhb@freebsd.org> Cc: Enji Cooper <ngie@FreeBSD.org>, "src-committers@freebsd.org" <src-committers@FreeBSD.org>, "dev-commits-src-all@freebsd.org" <dev-commits-src-all@FreeBSD.org>, "dev-commits-src-main@freebsd.org" <dev-commits-src-main@FreeBSD.org> Subject: Re: git: d1f1402dff63 - main - libnetbsd: import `__CTASSERT(..)` macros Message-ID: <2D23AD65-FC83-486F-99BD-1C2DAF6BCE05@gmail.com> In-Reply-To: <c1290a5c-b617-4a8a-a8eb-0c9b35931110@FreeBSD.org> References: <6998e4cc.32d8e.74c069d@gitrepo.freebsd.org> <c1290a5c-b617-4a8a-a8eb-0c9b35931110@FreeBSD.org>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] > On Feb 21, 2026, at 8:04 AM, John Baldwin <jhb@freebsd.org> wrote: > > On 2/20/26 17:48, Enji Cooper wrote: >> The branch main has been updated by ngie: >> URL: https://cgit.FreeBSD.org/src/commit/?id=d1f1402dff63dd163d4ba4ac65f7f2ffd00c5e08 >> commit d1f1402dff63dd163d4ba4ac65f7f2ffd00c5e08 >> Author: Enji Cooper <ngie@FreeBSD.org> >> AuthorDate: 2026-02-20 20:24:46 +0000 >> Commit: Enji Cooper <ngie@FreeBSD.org> >> 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`. > > FYI, _Static_assert is not a FreeBSD-ism, it's part of C11. Our old CTASSERT is > a FreeBSD-ism that this extends, but really, these should be implemented in > terms of _Static_assert when possible. Something like: > > #if is_c11 > #define __CTASSERT(x) __Static_assert(x) > #else > /* all the rest */ > #endif > > If __CTASSERT0 is used directly anywhere, you could emulate it via something like > > #define __CTASSERT0(x, y, z) __Static_assert(x, __STRING(y) "_" __STRING(z)) > > (Note that we build all of userspace as C17 by default in 15.0 and later.) Hi jhb@! Excellent points. Incorporating our macros/adaptations can cause grief sometimes and I don’t want to porting more code than necessary, so I have incorporated these macros (and a few others) wholesale from NetBSD (I got these from [1]). -Enji 1. https://github.com/NetBSD/src/blob/c26cc77b3a0b26b95a2df2e0154e2b2f7292ab20/sys/sys/cdefs.h#L168-L182 [-- Attachment #2 --] <html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><br><div><blockquote type="cite"><div>On Feb 21, 2026, at 8:04 AM, John Baldwin <jhb@freebsd.org> wrote:</div><br class="Apple-interchange-newline"><div><div>On 2/20/26 17:48, Enji Cooper wrote:<br><blockquote type="cite">The branch main has been updated by ngie:<br>URL: https://cgit.FreeBSD.org/src/commit/?id=d1f1402dff63dd163d4ba4ac65f7f2ffd00c5e08<br>commit d1f1402dff63dd163d4ba4ac65f7f2ffd00c5e08<br>Author: Enji Cooper <ngie@FreeBSD.org><br>AuthorDate: 2026-02-20 20:24:46 +0000<br>Commit: Enji Cooper <ngie@FreeBSD.org><br>CommitDate: 2026-02-20 22:45:06 +0000<br> libnetbsd: import `__CTASSERT(..)` macros<br> These compile-time assert macros are similar to `Static_assert` on FreeBSD.<br> These macros are in use in newer versions of `contrib/netbsd-tests`.<br></blockquote><br>FYI, _Static_assert is not a FreeBSD-ism, it's part of C11. Our old CTASSERT is<br>a FreeBSD-ism that this extends, but really, these should be implemented in<br>terms of _Static_assert when possible. Something like:<br><br>#if is_c11<br>#define __CTASSERT(x) __Static_assert(x)<br>#else<br>/* all the rest */<br>#endif<br><br>If __CTASSERT0 is used directly anywhere, you could emulate it via something like<br><br>#define __CTASSERT0(x, y, z) __Static_assert(x, __STRING(y) "_" __STRING(z))<br><br>(Note that we build all of userspace as C17 by default in 15.0 and later.)<br></div></div></blockquote></div><div><br></div>Hi jhb@!<br><div><br></div><div>Excellent points. <font color="#000000">Incorporating our macros/adaptations can cause grief sometimes and I don’t want to porting more code than necessary, so I have </font>incorporated these macros (and a few others) wholesale from NetBSD (I got these from [1]).</div><div><br></div><div>-Enji</div><div><br></div><div>1. <span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"> </span><a href="https://github.com/NetBSD/src/blob/c26cc77b3a0b26b95a2df2e0154e2b2f7292ab20/sys/sys/cdefs.h#L168-L182">https://github.com/NetBSD/src/blob/c26cc77b3a0b26b95a2df2e0154e2b2f7292ab20/sys/sys/cdefs.h#L168-L182</a></div></body></html>home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2D23AD65-FC83-486F-99BD-1C2DAF6BCE05>
