]> Savannah Git Hosting - gnulib.git/commitdiff
doc: Document the 'inline' module.
authorBruno Haible <bruno@clisp.org>
Mon, 30 Dec 2024 14:17:42 +0000 (15:17 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 30 Dec 2024 14:17:42 +0000 (15:17 +0100)
* doc/static-inline.texi: Document the 'inline' module.
* m4/inline.m4: Fix comment.

ChangeLog
doc/static-inline.texi
m4/inline.m4

index 89efd2834d589490fb6fb9238ab44f1f404af388..bacd26e18f9e1c0736b9fb06f89ad09de1207249 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-12-30  Bruno Haible  <bruno@clisp.org>
+
+       doc: Document the 'inline' module.
+       * doc/static-inline.texi: Document the 'inline' module.
+       * m4/inline.m4: Fix comment.
+
 2024-12-30  Bruno Haible  <bruno@clisp.org>
 
        signal: Deprecate old stub module.
index 5faf4f252da67ab0348f7c95150f952376bfe5e1..9e12750384953f3165dc2af2a9a16b43db0fffdb 100644 (file)
@@ -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.
 
 @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}.
index fe4c0e7147aa39ce0e54555500940d911b43304b..c002bc64a3e48c942a26dd0284627e0527d34229 100644 (file)
@@ -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])