]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Base.h
Define VERIFY_SIZE_OF macro to verify size of basic UEFI Data types. This should...
[mirror_edk2.git] / MdePkg / Include / Base.h
index 5b1f418d1af4d9c9c0d356d718584c0119751e0f..a2d275223c64f01ddd798f2df39281137359daa6 100644 (file)
@@ -27,24 +27,35 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 //\r
 #include <ProcessorBind.h>\r
 \r
+\r
+/**\r
+  Verifies the storage size of a given data type.\r
+  \r
+  This macro generates a divide by zero error or a zero size array declaration in\r
+  the preprocessor if the size is incorrect.  These are declared as "extern" so\r
+  the space for these arrays will not be in the modules.\r
+\r
+  @param  TYPE  The date type to determine the size of.\r
+  @param  Size  The expected size for the TYPE.\r
+\r
+**/\r
+#define VERIFY_SIZE_OF(TYPE, Size) extern UINT8 _VerifySizeof##TYPE[(sizeof(TYPE) == (Size)) / (sizeof(TYPE) == (Size))]\r
+\r
 //\r
 // Verify that ProcessorBind.h produced UEFI Data Types that are compliant with \r
-// Section 2.3.1 of the UEFI 2.3 Specification.  Generates a divide by zero \r
-// error or a zero size array declaration in the preprocessor if the size is \r
-// incorrect.  These are declared as "extern" so the space for these arrays will \r
-// not be in the modules.\r
+// Section 2.3.1 of the UEFI 2.3 Specification.  \r
 //\r
-extern UINT8 _VerifySizeOfBoolean [(sizeof(BOOLEAN) == 1) / (sizeof(BOOLEAN) == 1)];\r
-extern UINT8 _VerifySizeOfInt8    [(sizeof(INT8)    == 1) / (sizeof(INT8)    == 1)];\r
-extern UINT8 _VerifySizeOfUint8   [(sizeof(UINT8)   == 1) / (sizeof(UINT8)   == 1)];\r
-extern UINT8 _VerifySizeOfInt16   [(sizeof(INT16)   == 2) / (sizeof(INT16)   == 2)];\r
-extern UINT8 _VerifySizeOfUint16  [(sizeof(UINT16)  == 2) / (sizeof(UINT16)  == 2)];\r
-extern UINT8 _VerifySizeOfInt32   [(sizeof(INT32)   == 4) / (sizeof(INT32)   == 4)];\r
-extern UINT8 _VerifySizeOfUint32  [(sizeof(UINT32)  == 4) / (sizeof(UINT32)  == 4)];\r
-extern UINT8 _VerifySizeOfInt64   [(sizeof(INT64)   == 8) / (sizeof(INT64)   == 8)];\r
-extern UINT8 _VerifySizeOfUint64  [(sizeof(UINT64)  == 8) / (sizeof(UINT64)  == 8)];\r
-extern UINT8 _VerifySizeOfChar8   [(sizeof(CHAR8)   == 1) / (sizeof(CHAR8)   == 1)];\r
-extern UINT8 _VerifySizeOfChar16  [(sizeof(CHAR16)  == 2) / (sizeof(CHAR16)  == 2)];\r
+VERIFY_SIZE_OF (BOOLEAN, 1);\r
+VERIFY_SIZE_OF (INT8, 1);\r
+VERIFY_SIZE_OF (UINT8, 1);\r
+VERIFY_SIZE_OF (INT16, 2);\r
+VERIFY_SIZE_OF (UINT16, 2);\r
+VERIFY_SIZE_OF (INT32, 4);\r
+VERIFY_SIZE_OF (UINT32, 4);\r
+VERIFY_SIZE_OF (INT64, 8);\r
+VERIFY_SIZE_OF (UINT64, 8);\r
+VERIFY_SIZE_OF (CHAR8, 1);\r
+VERIFY_SIZE_OF (CHAR16, 2);\r
 \r
 //\r
 // The Microsoft* C compiler can removed references to unreferenced data items\r