[PATCH 2/2] wayland-util: Rename ARRAY_LENGTH -> __WL_ARRAY_LENGTH
Chad Versace
chad.versace at linux.intel.com
Thu Oct 18 09:15:08 PDT 2012
wayland-util.h defined an unprefixed macro, ARRAY_LENGTH, which polluted
the global namespace. This caused symbol collisions in projects that
defined ARRAY_LENGTH slightly differently.
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
cursor/wayland-cursor.c | 2 +-
src/connection.c | 6 +++---
src/event-loop.c | 2 +-
src/scanner.c | 4 ++--
src/wayland-util.h | 2 +-
tests/list-test.c | 20 ++++++++++----------
6 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/cursor/wayland-cursor.c b/cursor/wayland-cursor.c
index 0d1fec7..fd09292 100644
--- a/cursor/wayland-cursor.c
+++ b/cursor/wayland-cursor.c
@@ -238,7 +238,7 @@ load_default_theme(struct wl_cursor_theme *theme)
free(theme->name);
theme->name = strdup("default");
- theme->cursor_count = ARRAY_LENGTH(cursor_metadata);;
+ theme->cursor_count = __WL_ARRAY_LENGTH(cursor_metadata);;
theme->cursors = malloc(theme->cursor_count * sizeof(*theme->cursors));
for (i = 0; i < theme->cursor_count; ++i)
diff --git a/src/connection.c b/src/connection.c
index 141875e..19a4244 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -350,7 +350,7 @@ wl_connection_write(struct wl_connection *connection,
const void *data, size_t count)
{
if (connection->out.head - connection->out.tail +
- count > ARRAY_LENGTH(connection->out.data)) {
+ count > __WL_ARRAY_LENGTH(connection->out.data)) {
connection->want_flush = 1;
if (wl_connection_flush(connection) < 0)
return -1;
@@ -367,7 +367,7 @@ wl_connection_queue(struct wl_connection *connection,
const void *data, size_t count)
{
if (connection->out.head - connection->out.tail +
- count > ARRAY_LENGTH(connection->out.data)) {
+ count > __WL_ARRAY_LENGTH(connection->out.data)) {
connection->want_flush = 1;
if (wl_connection_flush(connection) < 0)
return -1;
@@ -657,7 +657,7 @@ wl_connection_demarshal(struct wl_connection *connection,
struct wl_closure *closure;
count = arg_count_for_signature(signature) + 2;
- if (count > ARRAY_LENGTH(closure->types)) {
+ if (count > __WL_ARRAY_LENGTH(closure->types)) {
printf("too many args (%d)\n", count);
errno = EINVAL;
wl_connection_consume(connection, size);
diff --git a/src/event-loop.c b/src/event-loop.c
index 65f8ea6..5d0a59f 100644
--- a/src/event-loop.c
+++ b/src/event-loop.c
@@ -404,7 +404,7 @@ wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout)
wl_event_loop_dispatch_idle(loop);
- count = epoll_wait(loop->epoll_fd, ep, ARRAY_LENGTH(ep), timeout);
+ count = epoll_wait(loop->epoll_fd, ep, __WL_ARRAY_LENGTH(ep), timeout);
if (count < 0)
return -1;
diff --git a/src/scanner.c b/src/scanner.c
index 47c22cb..10be308 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -1106,13 +1106,13 @@ emit_code(struct protocol *protocol)
i->name, i->name, i->version);
if (!wl_list_empty(&i->request_list))
- printf("\tARRAY_LENGTH(%s_requests), %s_requests,\n",
+ printf("\t__WL_ARRAY_LENGTH(%s_requests), %s_requests,\n",
i->name, i->name);
else
printf("\t0, NULL,\n");
if (!wl_list_empty(&i->event_list))
- printf("\tARRAY_LENGTH(%s_events), %s_events,\n",
+ printf("\t__WL_ARRAY_LENGTH(%s_events), %s_events,\n",
i->name, i->name);
else
printf("\t0, NULL,\n");
diff --git a/src/wayland-util.h b/src/wayland-util.h
index 3a29840..832e427 100644
--- a/src/wayland-util.h
+++ b/src/wayland-util.h
@@ -39,7 +39,7 @@ extern "C" {
#define WL_EXPORT
#endif
-#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
+#define __WL_ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
struct wl_message {
const char *name;
diff --git a/tests/list-test.c b/tests/list-test.c
index 6058fe3..c67627b 100644
--- a/tests/list-test.c
+++ b/tests/list-test.c
@@ -74,19 +74,19 @@ TEST(list_iterator)
i = 0;
wl_list_for_each(e, &list, link) {
- assert(i < ARRAY_LENGTH(reference));
+ assert(i < __WL_ARRAY_LENGTH(reference));
assert(e->i == reference[i]);
i++;
}
- assert(i == ARRAY_LENGTH(reference));
+ assert(i == __WL_ARRAY_LENGTH(reference));
i = 0;
wl_list_for_each_reverse(e, &list, link) {
- assert(i < ARRAY_LENGTH(reference));
- assert(e->i == reference[ARRAY_LENGTH(reference) - i - 1]);
+ assert(i < __WL_ARRAY_LENGTH(reference));
+ assert(e->i == reference[__WL_ARRAY_LENGTH(reference) - i - 1]);
i++;
}
- assert(i == ARRAY_LENGTH(reference));
+ assert(i == __WL_ARRAY_LENGTH(reference));
}
static int
@@ -124,10 +124,10 @@ TEST(list_remove)
wl_list_insert(&list, &e1.link);
wl_list_insert(list.prev, &e2.link);
wl_list_insert(list.prev, &e3.link);
- assert(validate_list(&list, reference1, ARRAY_LENGTH(reference1)));
+ assert(validate_list(&list, reference1, __WL_ARRAY_LENGTH(reference1)));
wl_list_remove(&e2.link);
- assert(validate_list(&list, reference2, ARRAY_LENGTH(reference2)));
+ assert(validate_list(&list, reference2, __WL_ARRAY_LENGTH(reference2)));
}
TEST(list_insert_list)
@@ -146,7 +146,7 @@ TEST(list_insert_list)
wl_list_insert(&list, &e1.link);
wl_list_insert(list.prev, &e2.link);
wl_list_insert(list.prev, &e3.link);
- assert(validate_list(&list, reference1, ARRAY_LENGTH(reference1)));
+ assert(validate_list(&list, reference1, __WL_ARRAY_LENGTH(reference1)));
e4.i = 76543;
e5.i = 1;
@@ -156,8 +156,8 @@ TEST(list_insert_list)
wl_list_insert(&other, &e4.link);
wl_list_insert(other.prev, &e5.link);
wl_list_insert(other.prev, &e6.link);
- assert(validate_list(&other, reference2, ARRAY_LENGTH(reference2)));
+ assert(validate_list(&other, reference2, __WL_ARRAY_LENGTH(reference2)));
wl_list_insert_list(list.next, &other);
- assert(validate_list(&list, reference3, ARRAY_LENGTH(reference3)));
+ assert(validate_list(&list, reference3, __WL_ARRAY_LENGTH(reference3)));
}
--
1.7.11.7
More information about the wayland-devel
mailing list