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>
86 lines
2.1 KiB
C
86 lines
2.1 KiB
C
/*++ @file
|
|
|
|
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
Portions copyright (c) 2011, Apple Inc. All rights reserved.
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
**/
|
|
|
|
#pragma once
|
|
|
|
#include <PiDxe.h>
|
|
|
|
#include <Guid/EmuSystemConfig.h>
|
|
#include <Guid/EventGroup.h>
|
|
#include <Protocol/EmuThunk.h>
|
|
#include <Protocol/EmuIoThunk.h>
|
|
#include <Protocol/EmuGraphicsWindow.h>
|
|
#include <Protocol/GenericMemoryTest.h>
|
|
#include <Protocol/LoadedImage.h>
|
|
#include <Protocol/FirmwareVolume2.h>
|
|
|
|
#include <Library/DebugLib.h>
|
|
#include <Library/BaseMemoryLib.h>
|
|
#include <Library/UefiBootServicesTableLib.h>
|
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
|
#include <Library/MemoryAllocationLib.h>
|
|
#include <Library/BaseLib.h>
|
|
#include <Library/PcdLib.h>
|
|
#include <Library/UefiBootManagerLib.h>
|
|
#include <Library/DevicePathLib.h>
|
|
#include <Library/UefiLib.h>
|
|
#include <Library/BootLogoLib.h>
|
|
#include <Library/HobLib.h>
|
|
#include <Library/HiiLib.h>
|
|
|
|
#define CONSOLE_OUT 0x00000001
|
|
#define STD_ERROR 0x00000002
|
|
#define CONSOLE_IN 0x00000004
|
|
#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
|
|
|
|
typedef struct {
|
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
|
UINTN ConnectType;
|
|
} BDS_CONSOLE_CONNECT_ENTRY;
|
|
|
|
extern BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
|
|
|
|
#define gEndEntire \
|
|
{ \
|
|
END_DEVICE_PATH_TYPE,\
|
|
END_ENTIRE_DEVICE_PATH_SUBTYPE,\
|
|
{ \
|
|
END_DEVICE_PATH_LENGTH,\
|
|
0\
|
|
}\
|
|
}
|
|
|
|
typedef struct {
|
|
EMU_VENDOR_DEVICE_PATH_NODE EmuBus;
|
|
EMU_VENDOR_DEVICE_PATH_NODE EmuGraphicsWindow;
|
|
EFI_DEVICE_PATH_PROTOCOL End;
|
|
} EMU_PLATFORM_GRAPHICS_WINDOW_DEVICE_PATH;
|
|
|
|
//
|
|
// Platform BDS Functions
|
|
//
|
|
|
|
/**
|
|
Perform the memory test base on the memory test intensive level,
|
|
and update the memory resource.
|
|
|
|
@param Level The memory test intensive level.
|
|
|
|
@retval EFI_STATUS Success test all the system memory and update
|
|
the memory resource
|
|
|
|
**/
|
|
EFI_STATUS
|
|
PlatformBootManagerMemoryTest (
|
|
IN EXTENDMEM_COVERAGE_LEVEL Level
|
|
);
|
|
|
|
VOID
|
|
PlatformBdsConnectSequence (
|
|
VOID
|
|
);
|