+/*
+ * GCC enables -finline-small-functions in most optimization modes; this works
+ * on a highlevel estimate of how big a function actually is and occasionally
+ * this produces really bad results.
+ *
+ * While old versions of GCC do not support this attribute the result seems
+ * to be merely a warning so hopefully we can get away with this check and
+ * save a configure test.
+ */
+#ifndef CDECL__NOINLINE
+# if __GNUC__
+# define CDECL__NOINLINE __attribute__((__noinline__))
+# else
+# define CDECL__NOINLINE /**/
+# endif
+#endif
+
+/*
+ * Build-time hook for white-box testing of memory allocation behaviour.
+ */
+#if TEST_MALLOC_HOOK
+void *test_realloc_hook(void *, size_t);
+
+static inline void *test_wrap_malloc(size_t n)
+{
+ return test_realloc_hook(0, n);
+}
+
+static inline void test_wrap_free(void *p)
+{
+ test_realloc_hook(p, 0);
+}
+
+#undef realloc
+#define realloc test_realloc_hook
+#undef malloc
+#define malloc test_wrap_malloc
+#undef free
+#define free test_wrap_free
+#endif
+