[git commit] make ARRAY_SIZE commonly available internally

Mike Frysinger vapier at gentoo.org
Sun Nov 27 09:33:03 UTC 2011


commit: http://git.uclibc.org/uClibc/commit/?id=0405cb8f5b647fadf61f7539828ef88a883223e2
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

Some places have opencoded the ARRAY_SIZE macro, so move it to a global
internal location so other places can leverage it.

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 include/libc-internal.h |    2 ++
 libc/inet/resolv.c      |    3 ---
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/libc-internal.h b/include/libc-internal.h
index 3ac0b05..9fb1ea2 100644
--- a/include/libc-internal.h
+++ b/include/libc-internal.h
@@ -74,6 +74,8 @@ libc_hidden_proto(__chk_fail)
 
 #endif /* __ASSEMBLER__ */
 
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
 /* Some people like to build up uClibc with *-elf toolchains, so
  * a little grease here until we drop '#ifdef __linux__' checks
  * from our source code.
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index 1155850..a730584 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -352,9 +352,6 @@ Domain name in a message can be represented as either:
 #define DPRINTF(X,args...)
 #endif
 
-#undef ARRAY_SIZE
-#define ARRAY_SIZE(v) (sizeof(v) / sizeof((v)[0]))
-
 /* Make sure the incoming char * buffer is aligned enough to handle our random
  * structures.  This define is the same as we use for malloc alignment (which
  * has same requirements).  The offset is the number of bytes we need to adjust


More information about the uClibc-cvs mailing list