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.biesheu...@linaro.org>
Cc: Cecil Sheng <cecil.sh...@hpe.com>
Cc: Chao Zhang <chao.b.zh...@intel.com>
Cc: Dandan Bi <dandan...@intel.com>
Cc: Daryl McDaniel <edk2-li...@mc2research.org>
Cc: David Wei <david....@intel.com>
Cc: Eric Dong <eric.d...@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
Cc: Gary Lin <g...@suse.com>
Cc: Jaben Carsey <jaben.car...@intel.com>
Cc: Jeff Fan <jeff....@intel.com>
Cc: Jiaxin Wu <jiaxin...@intel.com>
Cc: Jordan Justen <jordan.l.jus...@intel.com>
Cc: Liming Gao <liming....@intel.com>
Cc: Michael D Kinney <michael.d.kin...@intel.com>
Cc: Ruiyu Ni <ruiyu...@intel.com>
Cc: Siyuan Fu <siyuan...@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Cc: Tim He <tim...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 MdePkg/Include/Base.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
index c66614846488..8bdb257e37bd 100644
--- a/MdePkg/Include/Base.h
+++ b/MdePkg/Include/Base.h
@@ -1211,5 +1211,18 @@ typedef UINTN RETURN_STATUS;
   #define RETURN_ADDRESS(L)     ((VOID *) 0)
 #endif
 
+/**
+  Return the number of elements in an array.
+
+  @param  Array  An object of array type. Array is only used as an argument to
+                 the sizeof operator, therefore Array is never evaluated. The
+                 caller is responsible for ensuring that Array's type is not
+                 incomplete; that is, Array must have known constant size.
+
+  @return The number of elements in Array. The result has type UINTN.
+
+**/
+#define ARRAY_SIZE(Array) (sizeof (Array) / sizeof (Array)[0])
+
 #endif
 
-- 
2.9.2


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to