git: 99984e4b41c4 - main - edk2: #ifdef out STATIC_ASSERTS when !_STANDALONE

From: Warner Losh <imp_at_FreeBSD.org>
Date: Wed, 23 Apr 2025 21:35:58 UTC
The branch main has been updated by imp:

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

commit 99984e4b41c4ac792c812f1d5b48997e9ac0188f
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2025-04-23 21:31:11 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-04-23 21:31:11 +0000

    edk2: #ifdef out STATIC_ASSERTS when !_STANDALONE
    
    All FreeBSD ABIs do not conform to the EDK2 preconditions (except boot
    loader). These asserts test those things. Since the code from EDK2 that
    we use does not depend on L" and L' details, commenting them out is fine.
    
    Note: This was not in the update since I had to redo it too many times
    due to lost races and it was a tricky update.
    
    Sponsored by:           Netflix
---
 sys/contrib/edk2/Include/Base.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sys/contrib/edk2/Include/Base.h b/sys/contrib/edk2/Include/Base.h
index 6989b10f9e0b..e3d03a9cc5ab 100644
--- a/sys/contrib/edk2/Include/Base.h
+++ b/sys/contrib/edk2/Include/Base.h
@@ -824,8 +824,15 @@ STATIC_ASSERT (sizeof (INT64)   == 8, "sizeof (INT64) does not meet UEFI Specifi
 STATIC_ASSERT (sizeof (UINT64)  == 8, "sizeof (UINT64) does not meet UEFI Specification Data Type requirements");
 STATIC_ASSERT (sizeof (CHAR8)   == 1, "sizeof (CHAR8) does not meet UEFI Specification Data Type requirements");
 STATIC_ASSERT (sizeof (CHAR16)  == 2, "sizeof (CHAR16) does not meet UEFI Specification Data Type requirements");
+/*
+ * FreeBSD uses these headers in userland wher the following two assertions
+ * fail, but it also takes lengths to never use either of these constructs. The
+ * boot loader, however, uses them and needs these assertionst o be correct.
+ */
+#ifdef _STANDALONE
 STATIC_ASSERT (sizeof (L'A')    == 2, "sizeof (L'A') does not meet UEFI Specification Data Type requirements");
 STATIC_ASSERT (sizeof (L"A")    == 4, "sizeof (L\"A\") does not meet UEFI Specification Data Type requirements");
+#endif
 
 STATIC_ASSERT (ALIGNOF (BOOLEAN) == sizeof (BOOLEAN), "Alignment of BOOLEAN does not meet UEFI Specification Data Type requirements");
 STATIC_ASSERT (ALIGNOF (INT8)    == sizeof (INT8), "Alignment of INT8 does not meet UEFI Specification Data Type requirements");