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>
125 lines
3.3 KiB
C
125 lines
3.3 KiB
C
/** @file
|
|
Header file for ACPI table parser
|
|
|
|
Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
**/
|
|
|
|
#pragma once
|
|
|
|
/**
|
|
The maximum number of ACPI table parsers.
|
|
*/
|
|
#define MAX_ACPI_TABLE_PARSERS 32
|
|
|
|
/** An invalid/NULL signature value.
|
|
*/
|
|
#define ACPI_PARSER_SIGNATURE_NULL 0
|
|
|
|
/**
|
|
A function that parses the ACPI table.
|
|
|
|
@param [in] Trace If TRUE, trace the ACPI fields.
|
|
@param [in] Ptr Pointer to the start of the buffer.
|
|
@param [in] AcpiTableLength Length of the ACPI table.
|
|
@param [in] AcpiTableRevision Revision of the ACPI table.
|
|
**/
|
|
typedef
|
|
VOID
|
|
(EFIAPI *PARSE_ACPI_TABLE_PROC)(
|
|
IN BOOLEAN Trace,
|
|
IN UINT8 *Ptr,
|
|
IN UINT32 AcpiTableLength,
|
|
IN UINT8 AcpiTableRevision
|
|
);
|
|
|
|
/**
|
|
The ACPI table parser information
|
|
**/
|
|
typedef struct AcpiTableParser {
|
|
/// ACPI table signature
|
|
UINT32 Signature;
|
|
|
|
/// The ACPI table parser function.
|
|
PARSE_ACPI_TABLE_PROC Parser;
|
|
} ACPI_TABLE_PARSER;
|
|
|
|
/**
|
|
Register the ACPI table Parser
|
|
|
|
This function registers the ACPI table parser.
|
|
|
|
@param [in] Signature The ACPI table signature.
|
|
@param [in] ParserProc The ACPI table parser.
|
|
|
|
@retval EFI_SUCCESS The parser is registered.
|
|
@retval EFI_INVALID_PARAMETER A parameter is invalid.
|
|
@retval EFI_ALREADY_STARTED The parser for the Table
|
|
was already registered.
|
|
@retval EFI_OUT_OF_RESOURCES No space to register the
|
|
parser.
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
RegisterParser (
|
|
IN UINT32 Signature,
|
|
IN PARSE_ACPI_TABLE_PROC ParserProc
|
|
);
|
|
|
|
/**
|
|
Deregister the ACPI table Parser
|
|
|
|
This function deregisters the ACPI table parser.
|
|
|
|
@param [in] Signature The ACPI table signature.
|
|
|
|
@retval EFI_SUCCESS The parser was deregistered.
|
|
@retval EFI_INVALID_PARAMETER A parameter is invalid.
|
|
@retval EFI_NOT_FOUND A registered parser was not found.
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
DeregisterParser (
|
|
IN UINT32 Signature
|
|
);
|
|
|
|
/**
|
|
This function processes the ACPI tables.
|
|
This function calls ProcessTableReportOptions() to list the ACPI
|
|
tables, perform binary dump of the tables and determine if the
|
|
ACPI fields should be traced.
|
|
|
|
This function also invokes the parser for the ACPI tables.
|
|
|
|
This function also performs a RAW dump of the ACPI table including
|
|
the unknown/unparsed ACPI tables and validates the checksum.
|
|
|
|
@param [in] Ptr Pointer to the start of the ACPI
|
|
table data buffer.
|
|
**/
|
|
VOID
|
|
EFIAPI
|
|
ProcessAcpiTable (
|
|
IN UINT8 *Ptr
|
|
);
|
|
|
|
/**
|
|
Get the ACPI table Parser
|
|
|
|
This function returns the ACPI table parser proc from the list of
|
|
registered parsers.
|
|
|
|
@param [in] Signature The ACPI table signature.
|
|
@param [out] ParserProc Pointer to a ACPI table parser proc.
|
|
|
|
@retval EFI_SUCCESS The parser was returned successfully.
|
|
@retval EFI_INVALID_PARAMETER A parameter is invalid.
|
|
@retval EFI_NOT_FOUND A registered parser was not found.
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
GetParser (
|
|
IN UINT32 Signature,
|
|
OUT PARSE_ACPI_TABLE_PROC *ParserProc
|
|
);
|