From a5417308e46c07f5d6d7d2c4267f30a95138d10f Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 20 Jan 2016 05:08:04 +0000 Subject: [PATCH] tests/tests.h: add ARRAY_SIZE and LENGTH_OF macros * tests/tests.h (ARRAY_SIZE, LENGTH_OF): New macros. * tests/aio.c (ARRAY_SIZE): Remove. * tests/mmsg.c (LENGTH_OF): Remove. --- tests/aio.c | 2 -- tests/mmsg.c | 2 -- tests/tests.h | 3 +++ 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/aio.c b/tests/aio.c index 29d2191d..5335a260 100644 --- a/tests/aio.c +++ b/tests/aio.c @@ -42,8 +42,6 @@ && defined __NR_io_destroy # include -# define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) - int main(void) { diff --git a/tests/mmsg.c b/tests/mmsg.c index ba6cfe41..fe758a7a 100644 --- a/tests/mmsg.c +++ b/tests/mmsg.c @@ -45,8 +45,6 @@ struct mmsghdr { }; # endif -# define LENGTH_OF(arg) ((unsigned int) sizeof(arg) - 1) - static int send_mmsg(int fd, struct mmsghdr *vec, unsigned int vlen, unsigned int flags) { diff --git a/tests/tests.h b/tests/tests.h index de8302ad..c55b3296 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -66,6 +66,9 @@ void tprintf(const char *, ...) /* Make a hexdump copy of C string */ const char *hexdump_strdup(const char *); +# define ARRAY_SIZE(arg) ((unsigned int) (sizeof(arg) / sizeof((arg)[0]))) +# define LENGTH_OF(arg) ((unsigned int) sizeof(arg) - 1) + # define SKIP_MAIN_UNDEFINED(arg) \ int main(void) { error_msg_and_skip("undefined: %s", arg); } -- 2.40.0