Skip to content

Commit

Permalink
Make CompareGuid match EDK2 ABI
Browse files Browse the repository at this point in the history
* return BOOLEAN instead of INTN
* Use EFIAPI
* Opposite return codes

Signed-off-by: Callum Farmer <[email protected]>
  • Loading branch information
gmbr3 committed Aug 3, 2024
1 parent 13c46e4 commit a093fe0
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 16 deletions.
9 changes: 5 additions & 4 deletions inc/efilib.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,11 @@ ReleaseLock (
);


INTN
CompareGuid(
IN EFI_GUID *Guid1,
IN EFI_GUID *Guid2
BOOLEAN
EFIAPI
CompareGuid_1 (
IN CONST EFI_GUID *Guid1,
IN CONST EFI_GUID *Guid2
);

VOID *
Expand Down
7 changes: 4 additions & 3 deletions inc/efirtlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,12 @@ RtStrSize (
IN CONST CHAR16 *s1
);

INTN
BOOLEAN
EFIAPI
RUNTIMEFUNCTION
RtCompareGuid (
IN EFI_GUID *Guid1,
IN EFI_GUID *Guid2
IN CONST EFI_GUID *Guid1,
IN CONST EFI_GUID *Guid2
);

UINT8
Expand Down
34 changes: 34 additions & 0 deletions inc/legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,39 @@ ReallocatePool_0 (

/* end CopyMem */

/* CompareGuid */

#ifndef GNU_EFI_USE_COMPAREGUID_ABI
#define GNU_EFI_USE_COMPAREGUID_ABI 1
#endif

#if GNU_EFI_USE_COMPAREGUID_ABI == 0
#define CompareGuid CompareGuid_0
#else
#define CompareGuid CompareGuid_1
#endif

/* prevent circular headers */
BOOLEAN
EFIAPI
CompareGuid_1 (
IN CONST EFI_GUID *Guid1,
IN CONST EFI_GUID *Guid2
);

static
inline
INTN
EFIAPI
CompareGuid_0 (
IN EFI_GUID *Guid1,
IN EFI_GUID *Guid2)
{
if (CompareGuid_1(Guid1, Guid2)) {
return 0;
} else {
return 1;
}
}

#endif
9 changes: 5 additions & 4 deletions lib/guid.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,11 @@ InitializeGuid (
{
}

INTN
CompareGuid(
IN EFI_GUID *Guid1,
IN EFI_GUID *Guid2
BOOLEAN
EFIAPI
CompareGuid_1 (
IN CONST EFI_GUID *Guid1,
IN CONST EFI_GUID *Guid2
)
/*++
Expand Down
15 changes: 10 additions & 5 deletions lib/runtime/efirtlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,12 @@ RtCompareMem (
#ifndef __GNUC__
#pragma RUNTIME_CODE(RtCompareGuid)
#endif
INTN
BOOLEAN
EFIAPI
RUNTIMEFUNCTION
RtCompareGuid (
IN EFI_GUID *Guid1,
IN EFI_GUID *Guid2
IN CONST EFI_GUID *Guid1,
IN CONST EFI_GUID *Guid2
)
/*++
Expand All @@ -152,7 +153,7 @@ Routine Description:
Guid2 - guid to compare
Returns:
= 0 if Guid1 == Guid2
= 1 if Guid1 == Guid2
--*/
{
Expand All @@ -170,7 +171,11 @@ Routine Description:
r |= g1[2] - g2[2];
r |= g1[3] - g2[3];

return r;
if (r==0) {
return 1;
} else {
return 0;
}
}


0 comments on commit a093fe0

Please sign in to comment.