mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-20 12:14:27 +02:00
MdePkg: Use builtin offsetof function for GCC 4.0 and newer
GCC 4.0 and newer have a builtin function for implementing 'offsetof' therefore we make use of it for our OFFSET_OF macro. References: http://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Offsetof.html http://gcc.gnu.org/onlinedocs/gcc-4.5.1/gcc/Offsetof.html git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10931 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
2b0fcbf537
commit
818ff8c267
@ -573,7 +573,15 @@ typedef UINTN *BASE_LIST;
|
||||
@return Offset, in bytes, of field.
|
||||
|
||||
**/
|
||||
#ifdef __GNUC__
|
||||
#if __GNUC__ >= 4
|
||||
#define OFFSET_OF(TYPE, Field) ((UINTN) __builtin_offsetof(TYPE, Field))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef OFFSET_OF
|
||||
#define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
|
||||
#endif
|
||||
|
||||
/**
|
||||
Macro that returns a pointer to the data structure that contains a specified field of
|
||||
|
Loading…
x
Reference in New Issue
Block a user