Commit 3dd05c and subsequent ones introduced the use of the GNU

specific __attribute__((__unused__)), which breaks MSVC compilation...

I'll use this as a reminder that gnu-efi is compiled with more than
GNU toolchains, and that contributors might want to be careful about
adding GNU-specific extensions...

This patch does the following:
Create a new eficompiler.h header that sets all compiler-specific
options and extensions
Create a new EFI_UNUSED macro to be used in lieu of
__attribute__((__unused__)) and applies it to the relevant sources
Move the ALIGN(x) macro, previously defined in efisetjmp.h to the new header

Oh, and it also fixes a bunch of trailing whitespaces (because my code
editor is set to do just that by default).

Signed-off-by: Pete Batard <pbatard@users.sf.net>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
This commit is contained in:
Nigel Croxon 2016-03-25 13:32:54 -04:00
parent 1acb1d9dae
commit 5ff74ecae8
15 changed files with 112 additions and 89 deletions

View File

@ -40,8 +40,8 @@
#include <elf.h>
EFI_STATUS _relocate (long ldbase, Elf64_Dyn *dyn,
EFI_HANDLE image __attribute__((__unused__)),
EFI_SYSTEM_TABLE *systab __attribute__((__unused__)))
EFI_HANDLE image EFI_UNUSED,
EFI_SYSTEM_TABLE *systab EFI_UNUSED)
{
long relsz = 0, relent = 0;
Elf64_Rela *rel = 0;

View File

@ -40,8 +40,8 @@
#include <elf.h>
EFI_STATUS _relocate (long ldbase, Elf32_Dyn *dyn,
EFI_HANDLE image __attribute__((__unused__)),
EFI_SYSTEM_TABLE *systab __attribute__((__unused__)))
EFI_HANDLE image EFI_UNUSED,
EFI_SYSTEM_TABLE *systab EFI_UNUSED)
{
long relsz = 0, relent = 0;
Elf32_Rel *rel = 0;

View File

@ -39,8 +39,8 @@
#include <elf.h>
EFI_STATUS _relocate (long ldbase, Elf32_Dyn *dyn,
EFI_HANDLE image __attribute__((__unused__)),
EFI_SYSTEM_TABLE *systab __attribute__((__unused__)))
EFI_HANDLE image EFI_UNUSED,
EFI_SYSTEM_TABLE *systab EFI_UNUSED)
{
long relsz = 0, relent = 0;
Elf32_Rel *rel = 0;

View File

@ -41,8 +41,8 @@
#include <elf.h>
EFI_STATUS _relocate (long ldbase, Elf64_Dyn *dyn,
EFI_HANDLE image __attribute__((__unused__)),
EFI_SYSTEM_TABLE *systab __attribute__((__unused__)))
EFI_HANDLE image EFI_UNUSED,
EFI_SYSTEM_TABLE *systab EFI_UNUSED)
{
long relsz = 0, relent = 0;
Elf64_Rel *rel = 0;

View File

@ -33,6 +33,7 @@ Revision History
#define EFI_FIRMWARE_REVISION ((EFI_FIRMWARE_MAJOR_REVISION <<16) | (EFI_FIRMWARE_MINOR_REVISION))
#include "efibind.h"
#include "eficompiler.h"
#include "efidef.h"
#include "efidevp.h"
#include "efipciio.h"

30
inc/eficompiler.h Normal file
View File

@ -0,0 +1,30 @@
/*++
Copyright (c) 2016 Pete Batard <pete@akeo.ie>
Module Name:
eficompiler.h
Abstract:
Compiler specific adjustments
--*/
#ifdef _MSC_EXTENSIONS
#define EFI_UNUSED
#else
#define EFI_UNUSED __attribute__((__unused__))
#endif
#ifdef _MSC_EXTENSIONS
#define ALIGN(x) __declspec(align(x))
#else
#define ALIGN(x) __attribute__((__aligned__(x)))
#endif
/* Also add a catch-all on __attribute__() for MS compilers */
#ifdef _MSC_EXTENSIONS
#define __attribute__(x)
#endif

View File

@ -1,12 +1,6 @@
#ifndef GNU_EFI_SETJMP_H
#define GNU_EFI_SETJMP_H
#ifdef _MSC_EXTENSIONS
#define ALIGN(x) __declspec(align(x))
#else
#define ALIGN(x) __attribute__((__aligned__(x)))
#endif
#include "efisetjmp_arch.h"
extern UINTN setjmp(jmp_buf *env);

View File

@ -19,8 +19,8 @@
VOID
InitializeLibPlatform (
IN EFI_HANDLE ImageHandle __attribute__((__unused__)),
IN EFI_SYSTEM_TABLE *SystemTable __attribute__((__unused__))
IN EFI_HANDLE ImageHandle EFI_UNUSED,
IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
)
{
}

View File

@ -19,8 +19,8 @@
VOID
InitializeLibPlatform (
IN EFI_HANDLE ImageHandle __attribute__((__unused__)),
IN EFI_SYSTEM_TABLE *SystemTable __attribute__((__unused__))
IN EFI_HANDLE ImageHandle EFI_UNUSED,
IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
)
{
}

View File

@ -63,7 +63,7 @@ DevicePathInstance (
//
// Check for end of device path type
//
//
for (Count = 0; ; Count++) {
Next = NextDevicePathNode(DevPath);
@ -128,7 +128,7 @@ AppendDevicePath (
)
// Src1 may have multiple "instances" and each instance is appended
// Src2 is appended to each instance is Src1. (E.g., it's possible
// to append a new instance to the complete device path by passing
// to append a new instance to the complete device path by passing
// it in Src2)
{
UINTN Src1Size, Src1Inst, Src2Size, Size;
@ -164,7 +164,7 @@ AppendDevicePath (
Src1Inst = DevicePathInstanceCount(Src1);
Src2Size = DevicePathSize(Src2);
Size = Src1Size * Src1Inst + Src2Size;
Dst = AllocatePool (Size);
if (Dst) {
DstPos = (UINT8 *) Dst;
@ -217,7 +217,7 @@ AppendDevicePathNode (
}
CopyMem (Temp, Src2, Length);
Eop = NextDevicePathNode(Temp);
Eop = NextDevicePathNode(Temp);
SetDevicePathEndNode(Eop);
//
@ -244,7 +244,7 @@ FileDevicePath (
{
UINTN Size;
FILEPATH_DEVICE_PATH *FilePath;
EFI_DEVICE_PATH *Eop, *DevicePath;
EFI_DEVICE_PATH *Eop, *DevicePath;
Size = StrSize(FileName);
FilePath = AllocateZeroPool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + sizeof(EFI_DEVICE_PATH));
@ -292,7 +292,7 @@ DevicePathSize (
//
// Search for the end of the device path structure
//
//
Start = DevPath;
while (!IsDevicePathEnd(DevPath)) {
@ -312,7 +312,7 @@ DuplicateDevicePath (
)
{
EFI_DEVICE_PATH *NewDevPath;
UINTN Size;
UINTN Size;
//
@ -340,10 +340,10 @@ UnpackDevicePath (
{
EFI_DEVICE_PATH *Src, *Dest, *NewPath;
UINTN Size;
//
// Walk device path and round sizes to valid boundries
//
//
Src = DevPath;
Size = 0;
@ -416,7 +416,7 @@ AppendDevicePathInstance (
CopyMem (Ptr, Src, SrcSize);
// FreePool (Src);
while (!IsDevicePathEnd(DevPath)) {
DevPath = NextDevicePathNode(DevPath);
}
@ -426,7 +426,7 @@ AppendDevicePathInstance (
// idea.
//
DevPath->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;
DevPath = NextDevicePathNode(DevPath);
CopyMem (DevPath, Instance, InstanceSize);
return (EFI_DEVICE_PATH *)Ptr;
@ -490,7 +490,7 @@ _DevPathPccard (
{
PCCARD_DEVICE_PATH *Pccard;
Pccard = DevPath;
Pccard = DevPath;
CatPrint(Str, L"Pccard(0x%x)", Pccard-> FunctionNumber );
}
@ -502,7 +502,7 @@ _DevPathMemMap (
{
MEMMAP_DEVICE_PATH *MemMap;
MemMap = DevPath;
MemMap = DevPath;
CatPrint(Str, L"MemMap(%d,0x%x,0x%x)",
MemMap->MemoryType,
MemMap->StartingAddress,
@ -540,7 +540,7 @@ _DevPathVendor (
case MESSAGING_DEVICE_PATH: Type = L"Msg"; break;
case MEDIA_DEVICE_PATH: Type = L"Media"; break;
default: Type = L"?"; break;
}
}
CatPrint(Str, L"Ven%s(%g", Type, &Vendor->Guid);
if (CompareGuid (&Vendor->Guid, &UnknownDevice) == 0) {
@ -617,7 +617,7 @@ _DevPathAtapi (
ATAPI_DEVICE_PATH *Atapi;
Atapi = DevPath;
CatPrint(Str, L"Ata(%s,%s)",
CatPrint(Str, L"Ata(%s,%s)",
Atapi->PrimarySecondary ? L"Secondary" : L"Primary",
Atapi->SlaveMaster ? L"Slave" : L"Master"
);
@ -708,7 +708,7 @@ _DevPathMacAddr (
if (MAC->IfType == 0x01 || MAC->IfType == 0x00) {
HwAddressSize = 6;
}
CatPrint(Str, L"Mac(");
for(Index = 0; Index < HwAddressSize; Index++) {
@ -721,7 +721,7 @@ _DevPathMacAddr (
}
static VOID
CatPrintIPv4(
CatPrintIPv4(
IN OUT POOL_PRINT * Str ,
IN EFI_IPv4_ADDRESS * Address
)
@ -742,7 +742,7 @@ IsNotNullIPv4(
}
static VOID
CatPrintNetworkProtocol(
CatPrintNetworkProtocol(
IN OUT POOL_PRINT * Str ,
IN UINT16 Proto
)
@ -799,7 +799,7 @@ _DevPathIPv4 (
#define CatPrintIPv6_ADD( x , y ) ( ( (UINT16) ( x ) ) << 8 | ( y ) )
static VOID
CatPrintIPv6(
CatPrintIPv6(
IN OUT POOL_PRINT * Str ,
IN EFI_IPv6_ADDRESS * Address
)
@ -933,19 +933,19 @@ _DevPathHardDrive (
Hd = DevPath;
switch (Hd->SignatureType) {
case SIGNATURE_TYPE_MBR:
CatPrint(Str, L"HD(Part%d,Sig%08X)",
CatPrint(Str, L"HD(Part%d,Sig%08X)",
Hd->PartitionNumber,
*((UINT32 *)(&(Hd->Signature[0])))
);
break;
case SIGNATURE_TYPE_GUID:
CatPrint(Str, L"HD(Part%d,Sig%g)",
CatPrint(Str, L"HD(Part%d,Sig%g)",
Hd->PartitionNumber,
(EFI_GUID *) &(Hd->Signature[0])
(EFI_GUID *) &(Hd->Signature[0])
);
break;
default:
CatPrint(Str, L"HD(Part%d,MBRType=%02x,SigType=%02x)",
CatPrint(Str, L"HD(Part%d,MBRType=%02x,SigType=%02x)",
Hd->PartitionNumber,
Hd->MBRType,
Hd->SignatureType
@ -972,7 +972,7 @@ _DevPathFilePath (
IN VOID *DevPath
)
{
FILEPATH_DEVICE_PATH *Fp;
FILEPATH_DEVICE_PATH *Fp;
Fp = DevPath;
CatPrint(Str, L"%s", Fp->PathName);
@ -1017,7 +1017,7 @@ _DevPathBssBss (
static VOID
_DevPathEndInstance (
IN OUT POOL_PRINT *Str,
IN VOID *DevPath __attribute__((__unused__))
IN VOID *DevPath EFI_UNUSED
)
{
CatPrint(Str, L",");
@ -1084,7 +1084,7 @@ _DevPathNodeUnknown (
struct {
UINT8 Type;
UINT8 SubType;
VOID (*Function)(POOL_PRINT *, VOID *);
VOID (*Function)(POOL_PRINT *, VOID *);
} DevPathTable[] = {
{ HARDWARE_DEVICE_PATH, HW_PCI_DP, _DevPathPci},
{ HARDWARE_DEVICE_PATH, HW_PCCARD_DP, _DevPathPccard},
@ -1131,7 +1131,7 @@ DevicePathToStr (
{
POOL_PRINT Str;
EFI_DEVICE_PATH *DevPathNode;
VOID (*DumpNode)(POOL_PRINT *, VOID *);
VOID (*DumpNode)(POOL_PRINT *, VOID *);
UINTN Index, NewSize;
ZeroMem(&Str, sizeof(Str));
@ -1146,7 +1146,7 @@ DevicePathToStr (
//
// Process each device path node
//
//
DevPathNode = DevPath;
while (!IsDevicePathEnd(DevPathNode)) {
@ -1232,7 +1232,7 @@ LibDuplicateDevicePathInstance (
)
{
EFI_DEVICE_PATH *NewDevPath,*DevicePathInst,*Temp;
UINTN Size = 0;
UINTN Size = 0;
//
// get the size of an instance from the input
@ -1240,18 +1240,18 @@ LibDuplicateDevicePathInstance (
Temp = DevPath;
DevicePathInst = DevicePathInstance (&Temp, &Size);
//
// Make a copy and set proper end type
//
NewDevPath = NULL;
if (Size) {
if (Size) {
NewDevPath = AllocatePool (Size + sizeof(EFI_DEVICE_PATH));
}
if (NewDevPath) {
CopyMem (NewDevPath, DevicePathInst, Size);
Temp = NextDevicePathNode(NewDevPath);
Temp = NextDevicePathNode(NewDevPath);
SetDevicePathEndNode(Temp);
}

View File

@ -23,14 +23,14 @@ EFI_STATUS
InitializeGlobalIoDevice (
IN EFI_DEVICE_PATH *DevicePath,
IN EFI_GUID *Protocol,
IN CHAR8 *ErrorStr __attribute__((__unused__)),
OUT EFI_DEVICE_IO_INTERFACE **GlobalIoFncs
IN CHAR8 *ErrorStr EFI_UNUSED,
OUT EFI_DEVICE_IO_INTERFACE **GlobalIoFncs
)
/*++
Routine Description:
Check to see if DevicePath exists for a given Protocol. Return Error if it
Check to see if DevicePath exists for a given Protocol. Return Error if it
exists. Return GlobalIoFuncs set match the DevicePath
Arguments:
@ -68,60 +68,60 @@ Returns:
return Status;
}
UINT32
UINT32
ReadPort (
IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
IN EFI_IO_WIDTH Width,
IN UINTN Port
)
{
UINT32 Data;
EFI_STATUS Status __attribute__((__unused__));
EFI_STATUS Status EFI_UNUSED;
Status = uefi_call_wrapper(GlobalIoFncs->Io.Read, 5, GlobalIoFncs, Width, (UINT64)Port, 1, &Data);
ASSERT(!EFI_ERROR(Status));
return Data;
}
UINT32
UINT32
WritePort (
IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
IN EFI_IO_WIDTH Width,
IN UINTN Port,
IN UINTN Data
)
{
EFI_STATUS Status __attribute__((__unused__));
EFI_STATUS Status EFI_UNUSED;
Status = uefi_call_wrapper(GlobalIoFncs->Io.Write, 5, GlobalIoFncs, Width, (UINT64)Port, 1, &Data);
ASSERT(!EFI_ERROR(Status));
return (UINT32)Data;
}
UINT32
UINT32
ReadPciConfig (
IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
IN EFI_IO_WIDTH Width,
IN UINTN Address
)
{
UINT32 Data;
EFI_STATUS Status __attribute__((__unused__));
EFI_STATUS Status EFI_UNUSED;
Status = uefi_call_wrapper(GlobalIoFncs->Pci.Read, 5, GlobalIoFncs, Width, (UINT64)Address, 1, &Data);
ASSERT(!EFI_ERROR(Status));
return Data;
}
UINT32
UINT32
WritePciConfig (
IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
IN EFI_IO_WIDTH Width,
IN UINTN Address,
IN UINTN Data
)
{
EFI_STATUS Status __attribute__((__unused__));
EFI_STATUS Status EFI_UNUSED;
Status = uefi_call_wrapper(GlobalIoFncs->Pci.Write, 5, GlobalIoFncs, Width, (UINT64)Address, 1, &Data);
ASSERT(!EFI_ERROR(Status));

View File

@ -19,8 +19,8 @@ Revision History
VOID
InitializeLibPlatform (
IN EFI_HANDLE ImageHandle __attribute__((__unused__)),
IN EFI_SYSTEM_TABLE *SystemTable __attribute__((__unused__))
IN EFI_HANDLE ImageHandle EFI_UNUSED,
IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
)
{
}

View File

@ -19,8 +19,8 @@ Revision History
VOID
InitializeLibPlatform (
IN EFI_HANDLE ImageHandle __attribute__((__unused__)),
IN EFI_SYSTEM_TABLE *SystemTable __attribute__((__unused__))
IN EFI_HANDLE ImageHandle EFI_UNUSED,
IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
)
{
PLABEL SalPlabel;

View File

@ -52,8 +52,7 @@ StrnCmp (
INTN EFIAPI
LibStubStriCmp (
IN EFI_UNICODE_COLLATION_INTERFACE *This
__attribute__((__unused__)),
IN EFI_UNICODE_COLLATION_INTERFACE *This EFI_UNUSED,
IN CHAR16 *s1,
IN CHAR16 *s2
)
@ -63,8 +62,8 @@ LibStubStriCmp (
VOID EFIAPI
LibStubStrLwrUpr (
IN EFI_UNICODE_COLLATION_INTERFACE *This __attribute__((__unused__)),
IN CHAR16 *Str __attribute__((__unused__))
IN EFI_UNICODE_COLLATION_INTERFACE *This EFI_UNUSED,
IN CHAR16 *Str EFI_UNUSED
)
{
}
@ -119,7 +118,7 @@ StrCat (
IN CHAR16 *Dest,
IN CONST CHAR16 *Src
)
{
{
RtStrCat(Dest, Src);
}
@ -165,7 +164,7 @@ strlena (
// string length
{
UINTN len;
for (len=0; *s1; s1+=1, len+=1) ;
return len;
}
@ -270,7 +269,7 @@ Atoi (
return u;
}
BOOLEAN
BOOLEAN
MetaMatch (
IN CHAR16 *String,
IN CHAR16 *Pattern
@ -283,11 +282,11 @@ MetaMatch (
Pattern += 1;
switch (p) {
case 0:
case 0:
// End of pattern. If end of string, TRUE match
return *String ? FALSE : TRUE;
return *String ? FALSE : TRUE;
case '*':
case '*':
// Match zero or more chars
while (*String) {
if (MetaMatch (String, Pattern)) {
@ -297,7 +296,7 @@ MetaMatch (
}
return MetaMatch (String, Pattern);
case '?':
case '?':
// Match any one char
if (!*String) {
return FALSE;
@ -305,7 +304,7 @@ MetaMatch (
String += 1;
break;
case '[':
case '[':
// Match char set
c = *String;
if (!c) {
@ -324,17 +323,17 @@ MetaMatch (
return FALSE; // syntax problem
}
if (c >= l && c <= p) { // if in range,
if (c >= l && c <= p) { // if in range,
break; // it's a match
}
}
l = p;
if (c == p) { // if char matches
break; // move on
}
}
// skip to end of match char set
while (p && p != ']') {
p = *Pattern;
@ -359,8 +358,7 @@ MetaMatch (
BOOLEAN EFIAPI
LibStubMetaiMatch (
IN EFI_UNICODE_COLLATION_INTERFACE *This
__attribute__((__unused__)),
IN EFI_UNICODE_COLLATION_INTERFACE *This EFI_UNUSED,
IN CHAR16 *String,
IN CHAR16 *Pattern
)
@ -369,7 +367,7 @@ LibStubMetaiMatch (
}
BOOLEAN
BOOLEAN
MetaiMatch (
IN CHAR16 *String,
IN CHAR16 *Pattern

View File

@ -19,8 +19,8 @@ Revision History
VOID
InitializeLibPlatform (
IN EFI_HANDLE ImageHandle __attribute__((__unused__)),
IN EFI_SYSTEM_TABLE *SystemTable __attribute__((__unused__))
IN EFI_HANDLE ImageHandle EFI_UNUSED,
IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
)
{
}