From ede5c3f8d96008f63e2fcd3448fc88edd909d936 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 13 Apr 2018 18:34:30 -0700 Subject: [PATCH] macros: add G_GNUC_NO_INLINE function attribute https://bugzilla.gnome.org/show_bug.cgi?id=795180 --- docs/reference/glib/glib-sections.txt | 1 + glib/docs.c | 19 +++++++++++++++++++ glib/gmacros.h | 2 ++ 3 files changed, 22 insertions(+) diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt index f4b8dba54..32a7664e8 100644 --- a/docs/reference/glib/glib-sections.txt +++ b/docs/reference/glib/glib-sections.txt @@ -445,6 +445,7 @@ G_GNUC_NULL_TERMINATED G_GNUC_WARN_UNUSED_RESULT G_GNUC_FUNCTION G_GNUC_PRETTY_FUNCTION +G_GNUC_NO_INLINE G_GNUC_NO_INSTRUMENT G_HAVE_GNUC_VISIBILITY G_GNUC_INTERNAL diff --git a/glib/docs.c b/glib/docs.c index 4b1d97c2b..a67bc3411 100644 --- a/glib/docs.c +++ b/glib/docs.c @@ -2048,6 +2048,25 @@ * See the GNU C documentation for more details. */ +/** + * G_GNUC_NO_INLINE: + * + * Expands to the GNU C `noinline` function attribute if the compiler is gcc. + * If the compiler is not gcc, this macro expands to nothing. + * + * Declaring a function as `noinline` prevents the function from being + * considered for inlining. + * + * The attribute may be placed before the declaration, right before the + * `static` keyword. + * + * See the + * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noinline-function-attribute) + * for more details. + * + * Since: 2.58 + */ + /** * G_GNUC_MALLOC: * diff --git a/glib/gmacros.h b/glib/gmacros.h index 617e79a2d..55fb81e5b 100644 --- a/glib/gmacros.h +++ b/glib/gmacros.h @@ -97,9 +97,11 @@ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) #define G_GNUC_PURE __attribute__((__pure__)) #define G_GNUC_MALLOC __attribute__((__malloc__)) +#define G_GNUC_NO_INLINE __attribute__((noinline)) #else #define G_GNUC_PURE #define G_GNUC_MALLOC +#define G_GNUC_NO_INLINE #endif #if __GNUC__ >= 4