summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-10-02 20:06:58 -0400
committerMatthias Clasen <mclasen@redhat.com>2022-10-02 20:44:37 -0400
commit5c4db967c42d0eee69d3f0ad5e78fc5d241c4415 (patch)
tree0698d4ace0c53e72747cfb7aad66e2dac89eba19
parent73da2201d11d04ea2475cf8982d306f28a1b1299 (diff)
downloadglib-wip/matthiasc/try-inlining-magic.tar.gz
Just don't bother with inlining for msvc.
-rw-r--r--glib/gtestutils.c24
-rw-r--r--glib/gtestutils.h16
2 files changed, 39 insertions, 1 deletions
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index 7730c77c9..b8a850e46 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -35,9 +35,33 @@
* Since: 2.16
*/
+/* We are providing an inline version of g_strcmp0, as well as a regular,
+ * exported library symbol.
+ *
+ * Our approach to this is following the 'C99 strategy' outlined in
+ * https://www.greenend.org.uk/rjk/tech/inline.html:
+ * Provide an inline definition in the header, and put an extern
+ * declaration into one source file (this one), to force the compiler
+ * to emit an instance of the function in this translation unit.
+ *
+ * Since this does not seem to work with msvc, we arrange things so that
+ * in the msvc case, we provide the usual extern declaration in the header
+ * and not expose the inline definition unless the header is included here,
+ * in which case we are defining away the inline to get a regular instance
+ * of the function.
+ */
+
+#ifdef _MSC_VER
+
+#define GLIB_INLINE
+
+#else
+
GLIB_AVAILABLE_IN_ALL
int g_strcmp0 (const char *str1, const char *str2);
+#endif
+
#include "gtestutils.h"
#include "gfileutils.h"
diff --git a/glib/gtestutils.h b/glib/gtestutils.h
index 969c69dda..9a860ad28 100644
--- a/glib/gtestutils.h
+++ b/glib/gtestutils.h
@@ -238,10 +238,22 @@ typedef void (*GTestFixtureFunc) (gpointer fixture,
} G_STMT_END
#endif /* !G_DISABLE_ASSERT */
+#if defined(_MSC_VER)
+
+GLIB_AVAILABLE_IN_ALL
+int g_strcmp0 (const char *str1,
+ const char *str2);
+
+#else
+
#ifndef GLIB_INLINE
-#define GLIB_INLINE
+#define GLIB_INLINE inline
#endif
+#endif
+
+#if defined(GLIB_INLINE) || defined(__GTK_DOC_IGNORE__)
+
GLIB_INLINE int
g_strcmp0 (const char *str1,
const char *str2)
@@ -253,6 +265,8 @@ g_strcmp0 (const char *str1,
return strcmp (str1, str2);
}
+#endif
+
/* report performance results */
GLIB_AVAILABLE_IN_ALL
void g_test_minimized_result (double minimized_quantity,