edk2/CryptoPkg/Test/UnitTest/Library/BaseCryptLib
Michael Kubacki 0f42cae11c CryptoPkg: Replace include guards with #pragma once
Replace traditional `#ifndef`/`#define`/`#endif` include guards with
`#pragma` once.

`#pragma once` is a widely supported preprocessor directive that
prevents header files from being included multiple times. It is
supported by all toolchains used to build edk2: GCC, Clang/LLVM, and
MSVC.

Does not include updates to OpenSSL generated header files checked
into the repo. Those in `CryptoPkg\Library\OpensslLib\OpensslGen\`.

Compared to macro-based include guards, `#pragma once`:

- Eliminates the risk of macro name collisions or copy/paste errors
  where two headers inadvertently use the same guard macro.
- Eliminate inconsistency in the way include guard macros are named
  (e.g., some files use `__FILE_H__`, others use `FILE_H_`, etc.).
- Reduces boilerplate (three lines replaced by one).
- Avoids polluting the macro namespace with guard symbols.
- Can improve build times as the preprocessor can skip re-opening the
  file entirely, rather than re-reading it to find the matching
  `#endif` ("multiple-include optimization").
  - Note that some compilers may already optimize traditional include
    guards, by recognzining the idiomatic pattern.

This change is made acknowledging that overall portability of the
code will technically be reduced, as `#pragma once` is not part of the
C/C++ standards.

However, this is considered acceptable given:

1. edk2 already defines a subset of supported compilers in
   BaseTools/Conf/tools_def.template, all of which have supported
   `#pragma once` for over two decades.
2. There have been concerns raised to the project about inconsistent
   include guard naming and potential macro collisions.

Approximate compiler support dates:

- MSVC: Supported since Visual C++ 4.2 (1996)
- GCC: Supported since 3.4 (2004)
  (http://gnu.ist.utl.pt/software/gcc/gcc-3.4/changes.html)
- Clang (LLVM based): Since initial release in 2007

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-02-23 21:01:28 +00:00
..
TestEKUCerts CryptoPkg: BaseCryptLib: Add unit tests (Host and Shell based) 2020-10-18 00:49:58 +00:00
AeadAesGcmTests.c CryptoPkg: add UnitTest for AeadAesGcm. 2022-09-23 08:24:42 +00:00
AuthenticodeTests.c CryptoPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
BaseCryptLibUnitTests.c CryptoPkg: Unit test for Pkcs7GetAttachedContent() 2025-11-24 13:10:50 +00:00
BaseCryptLibUnitTestsMbedTls.c CryptoPkg/BaseCryptLibUnitTest: Separate MbedTls UnitTest Library. 2025-11-24 13:10:50 +00:00
BlockCipherTests.c CryptoPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
BnTests.c CryptoPkg/Test: Add unit test for CryptoBn 2022-09-23 10:08:24 +00:00
DhTests.c CryptoPkg/UnitTest: fix DH testcase 2022-04-12 14:39:01 +00:00
EcTests.c CryptoPkg: add unit test for EC key interface. 2022-10-12 05:56:00 +00:00
HashTests.c CryptoPkg: Add unit testcase for SM3 2024-09-23 06:11:25 +00:00
HkdfTests.c CryptoPkg: add Hkdf UnitTest. 2022-09-23 07:35:08 +00:00
HmacTests.c CryptoPkg: Add HMAC functions based on Mbedtls 2023-10-12 05:31:19 +00:00
OaepEncryptTests.c CryptoPkg/BaseCryptLibUnitTest: Separate MbedTls UnitTest Library. 2025-11-24 13:10:50 +00:00
ParallelhashTests.c CryptoPkg: Add new hash algorithm ParallelHash256HashAll in BaseCryptLib. 2022-03-18 06:49:18 +00:00
Pkcs5Pbkdf2Tests.c CryptoPkg: Resolve CodeQL Errors 2025-04-21 02:14:50 +00:00
Pkcs7AttachedContentSignatures.h CryptoPkg: Unit test for Pkcs7GetAttachedContent() 2025-11-24 13:10:50 +00:00
Pkcs7AttachedContentTest.c CryptoPkg/BaseCryptLibUnitTest: Separate MbedTls UnitTest Library. 2025-11-24 13:10:50 +00:00
Pkcs7EkuTests.c CryptoPkg/BaseCryptLibUnitTest: Separate MbedTls UnitTest Library. 2025-11-24 13:10:50 +00:00
Pkcs7EkuTestSignatures.h CryptoPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
RandTests.c CryptoPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
RsaPkcs7Tests.c CryptoPkg/BaseCryptLibUnitTest: Separate MbedTls UnitTest Library. 2025-11-24 13:10:50 +00:00
RsaPssTests.c CryptoPkg: Resolve CodeQL Errors 2025-04-21 02:14:50 +00:00
RsaTests.c CryptoPkg/BaseCryptLibUnitTest: Separate MbedTls UnitTest Library. 2025-11-24 13:10:50 +00:00
TestBaseCryptLib.h CryptoPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
TestBaseCryptLibHost.inf CryptoPkg: Unit test for Pkcs7GetAttachedContent() 2025-11-24 13:10:50 +00:00
TestBaseCryptLibHostMbedTls.inf CryptoPkg/BaseCryptLibUnitTest: Separate MbedTls UnitTest Library. 2025-11-24 13:10:50 +00:00
TestBaseCryptLibShell.inf CryptoPkg: Unit test for Pkcs7GetAttachedContent() 2025-11-24 13:10:50 +00:00
TSTests.c CryptoPkg/Test/UnitTest/Library/BaseCryptLib: Unit test fixes 2022-10-24 07:49:43 +00:00
UnitTestMain.c CryptoPkg: fix various typos 2025-11-21 21:49:59 +00:00
UnitTestMainHost.c CryptoPkg: fix various typos 2025-11-21 21:49:59 +00:00
X509Tests.c CryptoPkg: Resolve CodeQL Errors 2025-04-21 02:14:50 +00:00