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>
119 lines
4.5 KiB
C
119 lines
4.5 KiB
C
/** @file
|
|
|
|
Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
|
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
@par Glossary:
|
|
- Cm or CM - Configuration Manager
|
|
- Obj or OBJ - Object
|
|
**/
|
|
|
|
#pragma once
|
|
|
|
#include <ConfigurationManagerObject.h>
|
|
|
|
/** This macro defines the Configuration Manager Protocol GUID.
|
|
|
|
GUID: {D85A4835-5A82-4894-AC02-706F43D5978E}
|
|
*/
|
|
#define EDKII_CONFIGURATION_MANAGER_PROTOCOL_GUID \
|
|
{ 0xd85a4835, 0x5a82, 0x4894, \
|
|
{ 0xac, 0x2, 0x70, 0x6f, 0x43, 0xd5, 0x97, 0x8e } \
|
|
};
|
|
|
|
/** This macro defines the Configuration Manager Protocol Revision.
|
|
*/
|
|
#define EDKII_CONFIGURATION_MANAGER_PROTOCOL_REVISION CREATE_REVISION (1, 0)
|
|
|
|
#pragma pack(1)
|
|
|
|
/**
|
|
Forward declarations:
|
|
*/
|
|
typedef struct ConfigurationManagerProtocol EDKII_CONFIGURATION_MANAGER_PROTOCOL;
|
|
typedef struct PlatformRepositoryInfo EDKII_PLATFORM_REPOSITORY_INFO;
|
|
|
|
/** The GetObject function defines the interface implemented by the
|
|
Configuration Manager Protocol for returning the Configuration
|
|
Manager Objects.
|
|
|
|
@param [in] This Pointer to the Configuration Manager Protocol.
|
|
@param [in] CmObjectId The Configuration Manager Object ID.
|
|
@param [in] Token An optional token identifying the object. If
|
|
unused this must be CM_NULL_TOKEN.
|
|
@param [out] CmObject Pointer to the Configuration Manager Object
|
|
descriptor describing the requested Object.
|
|
|
|
@retval EFI_SUCCESS Success.
|
|
@retval EFI_INVALID_PARAMETER A parameter is invalid.
|
|
@retval EFI_NOT_FOUND The required object information is not found.
|
|
@retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration Manager
|
|
is less than the Object size for the requested
|
|
object.
|
|
**/
|
|
typedef
|
|
EFI_STATUS
|
|
(EFIAPI *EDKII_CONFIGURATION_MANAGER_GET_OBJECT)(
|
|
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This,
|
|
IN CONST CM_OBJECT_ID CmObjectId,
|
|
IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
|
|
IN OUT CM_OBJ_DESCRIPTOR *CONST CmObject
|
|
);
|
|
|
|
/** The SetObject function defines the interface implemented by the
|
|
Configuration Manager Protocol for updating the Configuration
|
|
Manager Objects.
|
|
|
|
@param [in] This Pointer to the Configuration Manager Protocol.
|
|
@param [in] CmObjectId The Configuration Manager Object ID.
|
|
@param [in] Token An optional token identifying the object. If
|
|
unused this must be CM_NULL_TOKEN.
|
|
@param [out] CmObject Pointer to the Configuration Manager Object
|
|
descriptor describing the Object.
|
|
|
|
@retval EFI_SUCCESS The operation completed successfully.
|
|
@retval EFI_INVALID_PARAMETER A parameter is invalid.
|
|
@retval EFI_NOT_FOUND The required object information is not found.
|
|
@retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration Manager
|
|
is less than the Object size for the requested
|
|
object.
|
|
@retval EFI_UNSUPPORTED This operation is not supported.
|
|
**/
|
|
typedef
|
|
EFI_STATUS
|
|
(EFIAPI *EDKII_CONFIGURATION_MANAGER_SET_OBJECT)(
|
|
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This,
|
|
IN CONST CM_OBJECT_ID CmObjectId,
|
|
IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
|
|
IN CM_OBJ_DESCRIPTOR *CONST CmObject
|
|
);
|
|
|
|
/** The EDKII_CONFIGURATION_MANAGER_PROTOCOL structure describes the
|
|
Configuration Manager Protocol interface.
|
|
*/
|
|
typedef struct ConfigurationManagerProtocol {
|
|
/// The Configuration Manager Protocol revision.
|
|
UINT32 Revision;
|
|
|
|
/** The interface used to request information about
|
|
the Configuration Manager Objects.
|
|
*/
|
|
EDKII_CONFIGURATION_MANAGER_GET_OBJECT GetObject;
|
|
|
|
/** The interface used to update the information stored
|
|
in the Configuration Manager repository.
|
|
*/
|
|
EDKII_CONFIGURATION_MANAGER_SET_OBJECT SetObject;
|
|
|
|
/** Pointer to an implementation defined abstract repository
|
|
provisioned by the Configuration Manager.
|
|
*/
|
|
EDKII_PLATFORM_REPOSITORY_INFO *PlatRepoInfo;
|
|
} EDKII_CONFIGURATION_MANAGER_PROTOCOL;
|
|
|
|
/** The Configuration Manager Protocol GUID.
|
|
*/
|
|
extern EFI_GUID gEdkiiConfigurationManagerProtocolGuid;
|
|
|
|
#pragma pack()
|