From: Julian Seward Date: Wed, 12 Apr 2006 17:15:35 +0000 (+0000) Subject: Recent GCCs (3.4+ at least) optimize static unused functions out, so X-Git-Tag: svn/VALGRIND_3_2_0~114 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13ef1e1c4575662402d0f09e55e16159d9f322d4;p=thirdparty%2Fvalgrind.git Recent GCCs (3.4+ at least) optimize static unused functions out, so making VALGRIND_PRINTF and VALGRIND_PRINTF_BACKTRACE static and attribute unused proved to be much better than always compiling it as exported weak function. (Jakub Jelinek) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5845 --- diff --git a/include/valgrind.h b/include/valgrind.h index a719b20d1a..b5c8222b4a 100644 --- a/include/valgrind.h +++ b/include/valgrind.h @@ -2338,10 +2338,11 @@ typedef #else /* NVALGRIND */ -int VALGRIND_PRINTF(const char *format, ...) - __attribute__((format(__printf__, 1, 2))); -__attribute__((weak)) -int +/* Modern GCC will optimize the static routine out if unused, + and unused attribute will shut down warnings about it. */ +static int VALGRIND_PRINTF(const char *format, ...) + __attribute__((format(__printf__, 1, 2), __unused__)); +static int VALGRIND_PRINTF(const char *format, ...) { unsigned long _qzz_res; @@ -2354,10 +2355,9 @@ VALGRIND_PRINTF(const char *format, ...) return (int)_qzz_res; } -int VALGRIND_PRINTF_BACKTRACE(const char *format, ...) - __attribute__((format(__printf__, 1, 2))); -__attribute__((weak)) -int +static int VALGRIND_PRINTF_BACKTRACE(const char *format, ...) + __attribute__((format(__printf__, 1, 2), __unused__)); +static int VALGRIND_PRINTF_BACKTRACE(const char *format, ...) { unsigned long _qzz_res;