summaryrefslogtreecommitdiffstats
path: root/benchmark
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-12-31 17:21:49 +0100
committerDavid Robillard <d@drobilla.net>2020-12-31 18:13:53 +0100
commitce3e4266e4f0712b27563d079b7e7b6fd8013014 (patch)
tree85cae1c8f7fc3f727b8fb14795f358a18fdbc022 /benchmark
parentdd6e02903318710ef5c517759b64e6b4e7e2972d (diff)
downloadzix-ce3e4266e4f0712b27563d079b7e7b6fd8013014.tar.gz
zix-ce3e4266e4f0712b27563d079b7e7b6fd8013014.tar.bz2
zix-ce3e4266e4f0712b27563d079b7e7b6fd8013014.zip
Disable glib warnings in the code
Though annoying, this avoids relying on special compiler flags to suppress them.
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/dict_bench.c3
-rw-r--r--benchmark/tree_bench.c3
-rw-r--r--benchmark/warnings.h42
3 files changed, 48 insertions, 0 deletions
diff --git a/benchmark/dict_bench.c b/benchmark/dict_bench.c
index 23e2f55..5d849d6 100644
--- a/benchmark/dict_bench.c
+++ b/benchmark/dict_bench.c
@@ -15,12 +15,15 @@
*/
#include "bench.h"
+#include "warnings.h"
#include "zix/chunk.h"
#include "zix/common.h"
#include "zix/hash.h"
+ZIX_DISABLE_GLIB_WARNINGS
#include <glib.h>
+ZIX_RESTORE_WARNINGS
#include <ctype.h>
#include <stdarg.h>
diff --git a/benchmark/tree_bench.c b/benchmark/tree_bench.c
index 4d1f30f..2ba7204 100644
--- a/benchmark/tree_bench.c
+++ b/benchmark/tree_bench.c
@@ -15,12 +15,15 @@
*/
#include "bench.h"
+#include "warnings.h"
#include "zix/btree.h"
#include "zix/common.h"
#include "zix/tree.h"
+ZIX_DISABLE_GLIB_WARNINGS
#include <glib.h>
+ZIX_RESTORE_WARNINGS
#include <inttypes.h>
#include <stdarg.h>
diff --git a/benchmark/warnings.h b/benchmark/warnings.h
new file mode 100644
index 0000000..cb3a618
--- /dev/null
+++ b/benchmark/warnings.h
@@ -0,0 +1,42 @@
+/*
+ Copyright 2020 David Robillard <d@drobilla.net>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+#ifndef WARNINGS_H
+#define WARNINGS_H
+
+#if defined(__clang__)
+
+# define ZIX_DISABLE_GLIB_WARNINGS \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Wdocumentation-unknown-command\"") \
+ _Pragma("clang diagnostic ignored \"-Wdocumentation\"")
+
+# define ZIX_RESTORE_WARNINGS _Pragma("clang diagnostic pop")
+
+#elif defined(__GNUC__)
+
+# define ZIX_DISABLE_GLIB_WARNINGS _Pragma("GCC diagnostic push")
+
+# define ZIX_RESTORE_WARNINGS _Pragma("GCC diagnostic pop")
+
+#else
+
+# define ZIX_DISABLE_GLIB_WARNINGS
+# define ZIX_RESTORE_WARNINGS
+
+#endif
+
+#endif // WARNINGS_H