You've already forked edk2-upstream
mirror of
https://github.com/Dasharo/edk2-upstream.git
synced 2026-03-06 15:03:57 -08: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>
91 lines
2.7 KiB
C
91 lines
2.7 KiB
C
/** @file
|
|
System reset Library Services. This library class defines a set of
|
|
methods that reset the whole system.
|
|
|
|
Copyright (c) 2005 - 2019, Intel Corporation. All rights reserved.<BR>
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
**/
|
|
|
|
#pragma once
|
|
|
|
#include <Uefi/UefiBaseType.h>
|
|
#include <Uefi/UefiMultiPhase.h>
|
|
|
|
/**
|
|
This function causes a system-wide reset (cold reset), in which
|
|
all circuitry within the system returns to its initial state. This type of reset
|
|
is asynchronous to system operation and operates without regard to
|
|
cycle boundaries.
|
|
|
|
If this function returns, it means that the system does not support cold reset.
|
|
**/
|
|
VOID
|
|
EFIAPI
|
|
ResetCold (
|
|
VOID
|
|
);
|
|
|
|
/**
|
|
This function causes a system-wide initialization (warm reset), in which all processors
|
|
are set to their initial state. Pending cycles are not corrupted.
|
|
|
|
If this function returns, it means that the system does not support warm reset.
|
|
**/
|
|
VOID
|
|
EFIAPI
|
|
ResetWarm (
|
|
VOID
|
|
);
|
|
|
|
/**
|
|
This function causes the system to enter a power state equivalent
|
|
to the ACPI G2/S5 or G3 states.
|
|
|
|
If this function returns, it means that the system does not support shutdown reset.
|
|
**/
|
|
VOID
|
|
EFIAPI
|
|
ResetShutdown (
|
|
VOID
|
|
);
|
|
|
|
/**
|
|
This function causes a systemwide reset. The exact type of the reset is
|
|
defined by the EFI_GUID that follows the Null-terminated Unicode string passed
|
|
into ResetData. If the platform does not recognize the EFI_GUID in ResetData
|
|
the platform must pick a supported reset type to perform.The platform may
|
|
optionally log the parameters from any non-normal reset that occurs.
|
|
|
|
@param[in] DataSize The size, in bytes, of ResetData.
|
|
@param[in] ResetData The data buffer starts with a Null-terminated string,
|
|
followed by the EFI_GUID.
|
|
**/
|
|
VOID
|
|
EFIAPI
|
|
ResetPlatformSpecific (
|
|
IN UINTN DataSize,
|
|
IN VOID *ResetData
|
|
);
|
|
|
|
/**
|
|
The ResetSystem function resets the entire platform.
|
|
|
|
@param[in] ResetType The type of reset to perform.
|
|
@param[in] ResetStatus The status code for the reset.
|
|
@param[in] DataSize The size, in bytes, of ResetData.
|
|
@param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
|
|
the data buffer starts with a Null-terminated string, optionally
|
|
followed by additional binary data. The string is a description
|
|
that the caller may use to further indicate the reason for the
|
|
system reset.
|
|
**/
|
|
VOID
|
|
EFIAPI
|
|
ResetSystem (
|
|
IN EFI_RESET_TYPE ResetType,
|
|
IN EFI_STATUS ResetStatus,
|
|
IN UINTN DataSize,
|
|
IN VOID *ResetData OPTIONAL
|
|
);
|