]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: debug: avoid build warnings with DEBUG_MEM_STATS
authorWilly Tarreau <w@1wt.eu>
Thu, 2 Jul 2020 08:25:01 +0000 (10:25 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 2 Jul 2020 08:25:01 +0000 (10:25 +0200)
Some libcs define strdup() as a macro and cause redefine warnings to
be emitted, so let's first undefine all functions we redefine.

include/haproxy/bug.h

index 99e585e443cd3f643a364b1ed824b274a49a1834..a008126f5c85d9b88a0db665cfbf4d45f846af31 100644 (file)
@@ -93,6 +93,7 @@ struct mem_stats {
        int type;
 };
 
+#undef calloc
 #define calloc(x,y)  ({                                                        \
        size_t __x = (x); size_t __y = (y);                             \
        static struct mem_stats _ __attribute__((used,__section__("mem_stats"))) = { \
@@ -106,6 +107,10 @@ struct mem_stats {
        calloc(__x,__y);                                                \
 })
 
+/* note: we can't redefine free() because we have a few variables and struct
+ * members called like this.
+ */
+#undef __free
 #define __free(x)  ({                                                  \
        void *__x = (x);                                                \
        static struct mem_stats _ __attribute__((used,__section__("mem_stats"))) = { \
@@ -118,6 +123,7 @@ struct mem_stats {
        free(__x);                                                      \
 })
 
+#undef malloc
 #define malloc(x)  ({                                                  \
        size_t __x = (x);                                               \
        static struct mem_stats _ __attribute__((used,__section__("mem_stats"))) = { \
@@ -131,6 +137,7 @@ struct mem_stats {
        malloc(__x);                                                    \
 })
 
+#undef realloc
 #define realloc(x,y)  ({                                               \
        void *__x = (x); size_t __y = (y);                              \
        static struct mem_stats _ __attribute__((used,__section__("mem_stats"))) = { \
@@ -144,6 +151,7 @@ struct mem_stats {
        realloc(__x,__y);                                               \
 })
 
+#undef strdup
 #define strdup(x)  ({                                                  \
        const char *__x = (x); size_t __y = strlen(__x);                \
        static struct mem_stats _ __attribute__((used,__section__("mem_stats"))) = { \