diff --git a/gnuefi/reloc_aarch64.c b/gnuefi/reloc_aarch64.c index 2f3d5bd..0867279 100644 --- a/gnuefi/reloc_aarch64.c +++ b/gnuefi/reloc_aarch64.c @@ -40,8 +40,8 @@ #include 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; diff --git a/gnuefi/reloc_arm.c b/gnuefi/reloc_arm.c index bafff3e..7585066 100644 --- a/gnuefi/reloc_arm.c +++ b/gnuefi/reloc_arm.c @@ -40,8 +40,8 @@ #include 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; diff --git a/gnuefi/reloc_ia32.c b/gnuefi/reloc_ia32.c index 0a8d482..da9d8a7 100644 --- a/gnuefi/reloc_ia32.c +++ b/gnuefi/reloc_ia32.c @@ -39,8 +39,8 @@ #include 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; diff --git a/gnuefi/reloc_x86_64.c b/gnuefi/reloc_x86_64.c index 6f241bf..04b75b2 100644 --- a/gnuefi/reloc_x86_64.c +++ b/gnuefi/reloc_x86_64.c @@ -41,8 +41,8 @@ #include 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; diff --git a/inc/efi.h b/inc/efi.h index 1e3a0de..97feee4 100644 --- a/inc/efi.h +++ b/inc/efi.h @@ -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" diff --git a/inc/eficompiler.h b/inc/eficompiler.h new file mode 100644 index 0000000..26636c7 --- /dev/null +++ b/inc/eficompiler.h @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2016 Pete Batard + +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 diff --git a/inc/efisetjmp.h b/inc/efisetjmp.h index 9cb6cec..da8d050 100644 --- a/inc/efisetjmp.h +++ b/inc/efisetjmp.h @@ -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); diff --git a/lib/aarch64/initplat.c b/lib/aarch64/initplat.c index 2ac03a7..286f637 100644 --- a/lib/aarch64/initplat.c +++ b/lib/aarch64/initplat.c @@ -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 ) { } diff --git a/lib/arm/initplat.c b/lib/arm/initplat.c index b9e22eb..c063118 100644 --- a/lib/arm/initplat.c +++ b/lib/arm/initplat.c @@ -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 ) { } diff --git a/lib/dpath.c b/lib/dpath.c index 478cb88..7486252 100644 --- a/lib/dpath.c +++ b/lib/dpath.c @@ -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); } diff --git a/lib/hw.c b/lib/hw.c index ae32df2..09a77f9 100644 --- a/lib/hw.c +++ b/lib/hw.c @@ -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)); diff --git a/lib/ia32/initplat.c b/lib/ia32/initplat.c index d252540..7c887a6 100644 --- a/lib/ia32/initplat.c +++ b/lib/ia32/initplat.c @@ -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 ) { } diff --git a/lib/ia64/initplat.c b/lib/ia64/initplat.c index 9d713b8..810d4fe 100644 --- a/lib/ia64/initplat.c +++ b/lib/ia64/initplat.c @@ -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; diff --git a/lib/str.c b/lib/str.c index 6a87fde..cf1495c 100644 --- a/lib/str.c +++ b/lib/str.c @@ -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 diff --git a/lib/x86_64/initplat.c b/lib/x86_64/initplat.c index d252540..7c887a6 100644 --- a/lib/x86_64/initplat.c +++ b/lib/x86_64/initplat.c @@ -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 ) { }