mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
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.
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>
39 lines
1.3 KiB
C
39 lines
1.3 KiB
C
/** @file
|
|
Header file for NV data structure definition.
|
|
|
|
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
**/
|
|
|
|
#pragma once
|
|
|
|
#include <Guid/TlsAuthConfigHii.h>
|
|
|
|
#define TLS_AUTH_CONFIG_GUID_SIZE 36
|
|
#define TLS_AUTH_CONFIG_GUID_STORAGE_SIZE 37
|
|
|
|
#define TLS_AUTH_CONFIG_FORMID1_FORM 1
|
|
#define TLS_AUTH_CONFIG_FORMID2_FORM 2
|
|
#define TLS_AUTH_CONFIG_FORMID3_FORM 3
|
|
#define TLS_AUTH_CONFIG_FORMID4_FORM 4
|
|
#define TLS_AUTH_CONFIG_FORMID5_FORM 5
|
|
|
|
#define KEY_TLS_AUTH_CONFIG_SERVER_CA 0x1000
|
|
#define KEY_TLS_AUTH_CONFIG_CLIENT_CERT 0x1001
|
|
#define KEY_TLS_AUTH_CONFIG_ENROLL_CERT 0x1002
|
|
#define KEY_TLS_AUTH_CONFIG_DELETE_CERT 0x1003
|
|
#define KEY_TLS_AUTH_CONFIG_ENROLL_CERT_FROM_FILE 0x1004
|
|
#define KEY_TLS_AUTH_CONFIG_CERT_GUID 0x1005
|
|
#define KEY_TLS_AUTH_CONFIG_VALUE_SAVE_AND_EXIT 0x1006
|
|
#define KEY_TLS_AUTH_CONFIG_VALUE_NO_SAVE_AND_EXIT 0x1007
|
|
|
|
#define OPTION_DEL_CA_ESTION_ID 0x2000
|
|
#define OPTION_CONFIG_RANGE 0x1000
|
|
|
|
#define LABEL_CA_DELETE 0x1101
|
|
#define LABEL_END 0xffff
|
|
|
|
typedef struct {
|
|
CHAR16 CertGuid[TLS_AUTH_CONFIG_GUID_STORAGE_SIZE];
|
|
} TLS_AUTH_CONFIG_IFR_NVDATA;
|