.file = __FILE__, .line = __LINE__, \
.type = MEM_STATS_TYPE_CALLOC, \
}; \
- HA_GLOBL("__start_mem_stats"); \
- HA_GLOBL("__stop_mem_stats"); \
+ HA_WEAK("__start_mem_stats"); \
+ HA_WEAK("__stop_mem_stats"); \
_HA_ATOMIC_INC(&_.calls); \
_HA_ATOMIC_ADD(&_.size, __x * __y); \
calloc(__x,__y); \
.file = __FILE__, .line = __LINE__, \
.type = MEM_STATS_TYPE_FREE, \
}; \
- HA_GLOBL("__start_mem_stats"); \
- HA_GLOBL("__stop_mem_stats"); \
+ HA_WEAK("__start_mem_stats"); \
+ HA_WEAK("__stop_mem_stats"); \
if (__x) \
_HA_ATOMIC_INC(&_.calls); \
free(__x); \
.file = __FILE__, .line = __LINE__, \
.type = MEM_STATS_TYPE_FREE, \
}; \
- HA_GLOBL("__start_mem_stats"); \
- HA_GLOBL("__stop_mem_stats"); \
+ HA_WEAK("__start_mem_stats"); \
+ HA_WEAK("__stop_mem_stats"); \
if (__builtin_constant_p((x)) || __builtin_constant_p(*(x))) { \
HA_LINK_ERROR(call_to_ha_free_attempts_to_free_a_constant); \
} \
.file = __FILE__, .line = __LINE__, \
.type = MEM_STATS_TYPE_MALLOC, \
}; \
- HA_GLOBL("__start_mem_stats"); \
- HA_GLOBL("__stop_mem_stats"); \
+ HA_WEAK("__start_mem_stats"); \
+ HA_WEAK("__stop_mem_stats"); \
_HA_ATOMIC_INC(&_.calls); \
_HA_ATOMIC_ADD(&_.size, __x); \
malloc(__x); \
.file = __FILE__, .line = __LINE__, \
.type = MEM_STATS_TYPE_REALLOC, \
}; \
- HA_GLOBL("__start_mem_stats"); \
- HA_GLOBL("__stop_mem_stats"); \
+ HA_WEAK("__start_mem_stats"); \
+ HA_WEAK("__stop_mem_stats"); \
_HA_ATOMIC_INC(&_.calls); \
_HA_ATOMIC_ADD(&_.size, __y); \
realloc(__x,__y); \
.file = __FILE__, .line = __LINE__, \
.type = MEM_STATS_TYPE_STRDUP, \
}; \
- HA_GLOBL("__start_mem_stats"); \
- HA_GLOBL("__stop_mem_stats"); \
+ HA_WEAK("__start_mem_stats"); \
+ HA_WEAK("__stop_mem_stats"); \
_HA_ATOMIC_INC(&_.calls); \
_HA_ATOMIC_ADD(&_.size, __y); \
strdup(__x); \
#endif // USE_OBSOLETE_LINKER
-/* Declare a symbol as global and if possible, as weak. Since we don't want to
+/* Declare a symbol as weak if possible, otherwise global. Since we don't want to
* error on multiple definitions, the symbol is declared weak. On MacOS ".weak"
* does not exist and we must continue to use ".globl" instead. Note that
* ".global" is to be avoided on other platforms as llvm complains about it
* anyway (and most likely it will only work with !USE_OBSOLETE_LINKER).
*/
#if defined(__APPLE__)
-# define __HA_GLOBL(sym) __asm__(".globl " #sym)
+# define __HA_WEAK(sym) __asm__(".globl " #sym)
#else
-# define __HA_GLOBL(sym) __asm__(".weak " #sym)
+# define __HA_WEAK(sym) __asm__(".weak " #sym)
#endif
-#define HA_GLOBL(sym) __HA_GLOBL(sym)
+#define HA_WEAK(sym) __HA_WEAK(sym)
+
+/* declare a symbol as global */
+#define __HA_GLOBL(sym) __asm__(".globl " #sym)
+#define HA_GLOBL(sym) __HA_GLOBL(sym)
/* use this attribute on a variable to move it to the read_mostly section */
#if !defined(__read_mostly)