]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro
authorLaszlo Ersek <lersek@redhat.com>
Wed, 26 Oct 2016 15:03:49 +0000 (17:03 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Thu, 27 Oct 2016 08:50:07 +0000 (10:50 +0200)
Several modules use ARRAY_SIZE() already; centralize the definition. (The
module-specific macro definitions are guarded by #ifndef directives at
this point.)

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Cecil Sheng <cecil.sheng@hpe.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Daryl McDaniel <edk2-lists@mc2research.org>
Cc: David Wei <david.wei@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Gary Lin <glin@suse.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Tim He <tim.he@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
MdePkg/Include/Base.h

index c66614846488861ec71354df454e8d08d9fabca2..82a773ae744cb7c3767ce681d30c46fefa61921e 100644 (file)
@@ -1211,5 +1211,18 @@ typedef UINTN RETURN_STATUS;
   #define RETURN_ADDRESS(L)     ((VOID *) 0)\r
 #endif\r
 \r
+/**\r
+  Return the number of elements in an array.\r
+\r
+  @param  Array  An object of array type. Array is only used as an argument to\r
+                 the sizeof operator, therefore Array is never evaluated. The\r
+                 caller is responsible for ensuring that Array's type is not\r
+                 incomplete; that is, Array must have known constant size.\r
+\r
+  @return The number of elements in Array. The result has type UINTN.\r
+\r
+**/\r
+#define ARRAY_SIZE(Array) (sizeof (Array) / sizeof ((Array)[0]))\r
+\r
 #endif\r
 \r