From: Bruno Haible Date: Mon, 30 Dec 2024 14:17:42 +0000 (+0100) Subject: doc: Document the 'inline' module. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=cd2d160f3973841f583da83bdd875bbadedce835;p=gnulib.git doc: Document the 'inline' module. * doc/static-inline.texi: Document the 'inline' module. * m4/inline.m4: Fix comment. --- diff --git a/ChangeLog b/ChangeLog index 89efd2834d..bacd26e18f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-12-30 Bruno Haible + + doc: Document the 'inline' module. + * doc/static-inline.texi: Document the 'inline' module. + * m4/inline.m4: Fix comment. + 2024-12-30 Bruno Haible signal: Deprecate old stub module. diff --git a/doc/static-inline.texi b/doc/static-inline.texi index 5faf4f252d..9e12750384 100644 --- a/doc/static-inline.texi +++ b/doc/static-inline.texi @@ -1,4 +1,4 @@ -@c GNU static-inline module documentation +@c Documentation of gnulib module 'inline'. @c Copyright (C) 2019--2024 Free Software Foundation, Inc. @@ -14,6 +14,21 @@ @cindex static inline @cindex inline -In order to mark functions as @code{static inline}, the only -prerequisite you need is an @code{AC_REQUIRE([AC_C_INLINE])}. +In order to mark functions as @code{static inline} in @code{.c} files, +the only prerequisite you need is an @code{AC_REQUIRE([AC_C_INLINE])}. No Gnulib module is needed. + +@mindex inline +When marking functions as @code{static inline} in @code{.h} files, +on the other hand, +it is useful to avoid the following problem: +When gcc or clang is not optimizing, it generates the same object code +for every @code{static inline} function +that is actually used in the current compilation unit, +thus bloating the size of the resulting binary. +(Code of @code{static inline} functions +that are unused in the current compilation unit gets dropped; +that is not an issue.) +To avoid this problem, use the Gnulib module @samp{inline} +and make the @code{static inline} function definition conditional +on the value of the C macro @code{HAVE_INLINE}. diff --git a/m4/inline.m4 b/m4/inline.m4 index fe4c0e7147..c002bc64a3 100644 --- a/m4/inline.m4 +++ b/m4/inline.m4 @@ -1,5 +1,5 @@ # inline.m4 -# serial 4 +# serial 5 dnl Copyright (C) 2006, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,7 +10,9 @@ dnl Test for the 'inline' keyword or equivalent. dnl Define 'inline' to a supported equivalent, or to nothing if not supported, dnl like AC_C_INLINE does. Also, define HAVE_INLINE if 'inline' or an dnl equivalent is effectively supported, i.e. if the compiler is likely to -dnl drop unused 'static inline' functions. +dnl actually inline 'static inline' functions when there are used. (All +dnl versions of gcc and clang actually drop the code of 'static inline' +dnl functions that are unused in the current compilation unit.) AC_DEFUN([gl_INLINE], [ AC_REQUIRE([AC_C_INLINE])