summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2013-02-06 09:50:22 -0800
committerPaul Berry <[email protected]>2013-02-08 06:51:22 -0800
commita4b9678a5451465b7df8a7fd8acc1fa9c5300181 (patch)
tree078f79863aba0302e75868a29dca29fbf71a808f /src/mesa/main
parentdc92b2d11fb939cf2a0ef330559d49304086c10a (diff)
Consolidate some redundant definitions of ARRAY_SIZE() macro.
Previous to this patch, there were 13 identical definitions of this macro in Mesa source. That's ridiculous. This patch consolidates 6 of them to a single definition in src/mesa/main/macros.h. Unfortunately, I wasn't able to eliminate the remaining definitions, since they occur in places that don't include src/mesa/main/macros.h: - include/pci_ids/pci_id_driver_map.h - src/egl/drivers/dri2/egl_dri2.h - src/egl/main/egldefines.h - src/gbm/main/backend.c - src/gbm/main/gbm.c - src/glx/glxclient.h - src/mapi/mapi/stub.c I'm open to suggestions as to how to deal with the remaining redundancy. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/hash_table.c3
-rw-r--r--src/mesa/main/macros.h3
-rw-r--r--src/mesa/main/set.c3
3 files changed, 5 insertions, 4 deletions
diff --git a/src/mesa/main/hash_table.c b/src/mesa/main/hash_table.c
index 2bd1929aa9d..af0510da105 100644
--- a/src/mesa/main/hash_table.c
+++ b/src/mesa/main/hash_table.c
@@ -44,10 +44,9 @@
#include <string.h>
#include "main/hash_table.h"
+#include "main/macros.h"
#include "ralloc.h"
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
-
static const uint32_t deleted_key_value;
/**
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index d1e81fe082c..f6d38fb6480 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -766,5 +766,8 @@ DIFFERENT_SIGNS(GLfloat x, GLfloat y)
#define ENUM_TO_DOUBLE(E) ((GLdouble)(GLint)(E))
#define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE)
+/* Compute the size of an array */
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+
#endif
diff --git a/src/mesa/main/set.c b/src/mesa/main/set.c
index 736841fc9c0..2519b96947a 100644
--- a/src/mesa/main/set.c
+++ b/src/mesa/main/set.c
@@ -34,11 +34,10 @@
#include <stdlib.h>
+#include "macros.h"
#include "set.h"
#include "ralloc.h"
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
-
/*
* From Knuth -- a good choice for hash/rehash values is p, p-2 where
* p and p-2 are both prime. These tables are sized to have an extra 10%