mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
FmpDevicePkg: 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.
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>
This commit is contained in:
parent
f2b15ce3f5
commit
58ace50a43
12 changed files with 12 additions and 48 deletions
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
**/
|
||||
|
||||
#ifndef __CAPSULE_UPDATE_POLICY_DXE_H__
|
||||
#define __CAPSULE_UPDATE_POLICY_DXE_H__
|
||||
#pragma once
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
|
|
@ -136,5 +135,3 @@ CapsuleUpdatePolicyInitialize (
|
|||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@
|
|||
|
||||
**/
|
||||
|
||||
#ifndef _FMP_DXE_H_
|
||||
#define _FMP_DXE_H_
|
||||
#pragma once
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Library/DebugLib.h>
|
||||
|
|
@ -365,5 +364,3 @@ SetPackageInfo (
|
|||
IN UINT32 PackageVersion,
|
||||
IN CONST CHAR16 *PackageVersionName
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@
|
|||
|
||||
**/
|
||||
|
||||
#ifndef __VARIABLE_SUPPORT_H__
|
||||
#define __VARIABLE_SUPPORT_H__
|
||||
#pragma once
|
||||
|
||||
///
|
||||
/// Default values for FMP Controller State information
|
||||
|
|
@ -234,5 +233,3 @@ EFI_STATUS
|
|||
LockAllFmpVariables (
|
||||
IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
**/
|
||||
|
||||
#ifndef __LAST_ATTEMPT_STATUS_H__
|
||||
#define __LAST_ATTEMPT_STATUS_H__
|
||||
#pragma once
|
||||
|
||||
///
|
||||
/// Last Attempt Status Unsuccessful Vendor Range Map
|
||||
|
|
@ -77,5 +76,3 @@
|
|||
/// The maximum value allowed for FMP device library errors.
|
||||
///
|
||||
#define LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE 0x1FFF
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
**/
|
||||
|
||||
#ifndef __CAPSULE_UPDATE_POLICY_LIB__
|
||||
#define __CAPSULE_UPDATE_POLICY_LIB__
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
Determine if the system power state supports a capsule update.
|
||||
|
|
@ -99,5 +98,3 @@ EFIAPI
|
|||
IsLockFmpDeviceAtLockEventGuidRequired (
|
||||
VOID
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@
|
|||
|
||||
**/
|
||||
|
||||
#ifndef __FMP_DEPENDENCY_CHECK_LIB__
|
||||
#define __FMP_DEPENDENCY_CHECK_LIB__
|
||||
#pragma once
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Protocol/FirmwareManagement.h>
|
||||
|
|
@ -40,5 +39,3 @@ CheckFmpDependency (
|
|||
IN UINT32 DependenciesSize,
|
||||
OUT UINT32 *LastAttemptStatus OPTIONAL
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
**/
|
||||
|
||||
#ifndef __FMP_DEPENDENCY_DEVICE_LIB__
|
||||
#define __FMP_DEPENDENCY_DEVICE_LIB__
|
||||
#pragma once
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Protocol/FirmwareManagement.h>
|
||||
|
|
@ -47,5 +46,3 @@ EFIAPI
|
|||
GetFmpDependency (
|
||||
OUT UINT32 *DepexSize
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@
|
|||
|
||||
**/
|
||||
|
||||
#ifndef __FMP_DEPENDENCY_LIB__
|
||||
#define __FMP_DEPENDENCY_LIB__
|
||||
#pragma once
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Protocol/FirmwareManagement.h>
|
||||
|
|
@ -100,5 +99,3 @@ EvaluateDependency (
|
|||
IN UINTN FmpVersionsCount,
|
||||
OUT UINT32 *LastAttemptStatus OPTIONAL
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@
|
|||
|
||||
**/
|
||||
|
||||
#ifndef __FMP_DEVICE_LIB__
|
||||
#define __FMP_DEVICE_LIB__
|
||||
#pragma once
|
||||
|
||||
#include <Protocol/FirmwareManagement.h>
|
||||
|
||||
|
|
@ -604,5 +603,3 @@ EFIAPI
|
|||
FmpDeviceLock (
|
||||
VOID
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@
|
|||
|
||||
**/
|
||||
|
||||
#ifndef __FMP_LAST_ATTEMPT_STATUS_H__
|
||||
#define __FMP_LAST_ATTEMPT_STATUS_H__
|
||||
#pragma once
|
||||
|
||||
///
|
||||
/// Last attempt status codes defined for additional granularity in FmpDevicePkg components.
|
||||
|
|
@ -79,5 +78,3 @@ enum LAST_ATTEMPT_STATUS_EXPANDED_ERROR_LIST {
|
|||
LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_DESC_SIZE_BUFFER_FAILED,
|
||||
LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_FMP_VER_BUFFER_FAILED
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@
|
|||
|
||||
**/
|
||||
|
||||
#ifndef _FMP_PAYLOAD_HEADER_LIB_H__
|
||||
#define _FMP_PAYLOAD_HEADER_LIB_H__
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
Returns the FMP Payload Header size in bytes.
|
||||
|
|
@ -79,5 +78,3 @@ GetFmpPayloadHeaderLowestSupportedVersion (
|
|||
IN CONST UINTN FmpPayloadSize,
|
||||
OUT UINT32 *LowestSupportedVersion
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@
|
|||
|
||||
**/
|
||||
|
||||
#ifndef __CAPSULE_UPDATE_POLICY_H__
|
||||
#define __CAPSULE_UPDATE_POLICY_H__
|
||||
#pragma once
|
||||
|
||||
#define EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL_GUID \
|
||||
{ \
|
||||
|
|
@ -128,5 +127,3 @@ struct _EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL {
|
|||
};
|
||||
|
||||
extern EFI_GUID gEdkiiCapsuleUpdatePolicyProtocolGuid;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue