summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzoulasc <christos@zoulas.com>2019-03-16 00:19:16 (GMT)
committerQi Wang <interwq@gmail.com>2019-04-15 22:14:46 (GMT)
commit7f7935cf7805036d42fb510592ab8b40bcfb0690 (patch)
treeb253d5715e216fcdf2d6280a532cdce988a3d1b9
parent14e4176758379875c4ef486d6c57327ed07edd86 (diff)
downloadjemalloc-7f7935cf7805036d42fb510592ab8b40bcfb0690.zip
jemalloc-7f7935cf7805036d42fb510592ab8b40bcfb0690.tar.gz
jemalloc-7f7935cf7805036d42fb510592ab8b40bcfb0690.tar.bz2
Add an autoconf feature test for format_arg and a jemalloc-specific
macro for it.
-rw-r--r--configure.ac12
-rw-r--r--include/jemalloc/internal/emitter.h2
-rw-r--r--include/jemalloc/jemalloc_defs.h.in3
-rw-r--r--include/jemalloc/jemalloc_macros.h.in6
4 files changed, 22 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 96f76d3..9cc2a6b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -851,6 +851,18 @@ if test "x${je_cv_format_printf}" = "xyes" ; then
AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_PRINTF], [ ])
fi
+dnl Check for format_arg(...) attribute support.
+JE_CFLAGS_SAVE()
+JE_CFLAGS_ADD([-Werror])
+JE_CFLAGS_ADD([-herror_on_warning])
+JE_COMPILABLE([format(printf, ...) attribute], [#include <stdlib.h>],
+ [const char * __attribute__((__format_arg__(1))) foo(const char *format);],
+ [je_cv_format_arg])
+JE_CFLAGS_RESTORE()
+if test "x${je_cv_format_arg}" = "xyes" ; then
+ AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_ARG], [ ])
+fi
+
dnl Support optional additions to rpath.
AC_ARG_WITH([rpath],
[AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
diff --git a/include/jemalloc/internal/emitter.h b/include/jemalloc/internal/emitter.h
index 981dbe0..542bc79 100644
--- a/include/jemalloc/internal/emitter.h
+++ b/include/jemalloc/internal/emitter.h
@@ -86,7 +86,7 @@ emitter_printf(emitter_t *emitter, const char *format, ...) {
va_end(ap);
}
-static inline const char * __attribute__((__format_arg__(3)))
+static inline const char * JEMALLOC_FORMAT_ARG(3)
emitter_gen_fmt(char *out_fmt, size_t out_size, const char *fmt_specifier,
emitter_justify_t justify, int width) {
size_t written;
diff --git a/include/jemalloc/jemalloc_defs.h.in b/include/jemalloc/jemalloc_defs.h.in
index 6d89435..11c3918 100644
--- a/include/jemalloc/jemalloc_defs.h.in
+++ b/include/jemalloc/jemalloc_defs.h.in
@@ -4,6 +4,9 @@
/* Defined if alloc_size attribute is supported. */
#undef JEMALLOC_HAVE_ATTR_ALLOC_SIZE
+/* Defined if format_arg(...) attribute is supported. */
+#undef JEMALLOC_HAVE_ATTR_FORMAT_ARG
+
/* Defined if format(gnu_printf, ...) attribute is supported. */
#undef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF
diff --git a/include/jemalloc/jemalloc_macros.h.in b/include/jemalloc/jemalloc_macros.h.in
index a00ce11..59e2955 100644
--- a/include/jemalloc/jemalloc_macros.h.in
+++ b/include/jemalloc/jemalloc_macros.h.in
@@ -69,6 +69,7 @@
# define JEMALLOC_EXPORT __declspec(dllimport)
# endif
# endif
+# define JEMALLOC_FORMAT_ARG(i)
# define JEMALLOC_FORMAT_PRINTF(s, i)
# define JEMALLOC_NOINLINE __declspec(noinline)
# ifdef __cplusplus
@@ -96,6 +97,11 @@
# ifndef JEMALLOC_EXPORT
# define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default"))
# endif
+# ifdef JEMALLOC_HAVE_ATTR_FORMAT_ARG
+# define JEMALLOC_FORMAT_ARG(i) JEMALLOC_ATTR(__format_arg__(3))
+# else
+# define JEMALLOC_FORMAT_ARG(i)
+# endif
# ifdef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF
# define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(gnu_printf, s, i))
# elif defined(JEMALLOC_HAVE_ATTR_FORMAT_PRINTF)