summaryrefslogtreecommitdiff
path: root/src/include/c.h
diff options
context:
space:
mode:
authorAlvaro Herrera2012-10-08 19:12:27 +0000
committerAlvaro Herrera2012-10-08 19:28:01 +0000
commit976fa10d20ec9882229020fa16f4d74263066a40 (patch)
treeb315437bd9ceda77924d1245ec9a74116573c43b /src/include/c.h
parent08c8058ce90cf4b2644cabfa7e5f66e9da8ddd7d (diff)
Add support for easily declaring static inline functions
We already had those, but they forced modules to spell out the function bodies twice. Eliminate some duplicates we had already grown. Extracted from a somewhat larger patch from Andres Freund.
Diffstat (limited to 'src/include/c.h')
-rw-r--r--src/include/c.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/include/c.h b/src/include/c.h
index 127b5d94e3c..925d9617af4 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -748,6 +748,24 @@ typedef NameData *Name;
#endif /* HAVE__BUILTIN_TYPES_COMPATIBLE_P */
+/*
+ * Function inlining support -- Allow modules to define functions that may be
+ * inlined, if the compiler supports it.
+ *
+ * The function bodies must be defined in the module header prefixed by
+ * STATIC_IF_INLINE, protected by a cpp symbol that the module's .c file must
+ * define. If the compiler doesn't support inline functions, the function
+ * definitions are pulled in by the .c file as regular (not inline) symbols.
+ *
+ * The header must also declare the functions' prototypes, protected by
+ * !USE_INLINE.
+ */
+#ifdef USE_INLINE
+#define STATIC_IF_INLINE static inline
+#else
+#define STATIC_IF_INLINE
+#endif /* USE_INLINE */
+
/* ----------------------------------------------------------------
* Section 7: random stuff
* ----------------------------------------------------------------