summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-08-19 12:22:31 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-08-25 11:47:59 +0200
commit87a72de7359ad89246791169a842c8de9d0c9498 (patch)
treebc487e6d70c7f946e495f9d4d453b80336687436
parent42d709065e9f83419a2545e9344a392b6df3200e (diff)
compat/util: split macros header
-rw-r--r--compat/macros.hpp65
-rw-r--r--compat/util.hpp65
2 files changed, 66 insertions, 64 deletions
diff --git a/compat/macros.hpp b/compat/macros.hpp
new file mode 100644
index 00000000..84d6bd03
--- /dev/null
+++ b/compat/macros.hpp
@@ -0,0 +1,65 @@
+#pragma once
+
+#if defined _MSC_VER
+# define never_inline __declspec(noinline)
+#elif defined __GNUG__
+# define never_inline __attribute__((noinline))
+#else
+# define never_inline
+#endif
+
+#if defined _MSC_VER || defined __GNUG__
+# define restrict __restrict
+#else
+# define restrict
+#endif
+
+#if defined _MSC_VER
+# define restrict_ref restrict
+#elif defined __GNUG__
+# define restrict_ref restrict
+#else
+# define restrict_ref
+#endif
+
+#if defined _MSC_VER
+# define force_inline __forceinline
+#elif defined __GNUG__
+# define force_inline __attribute__((always_inline, gnu_inline)) inline
+#else
+# define force_inline inline
+#endif
+
+#if defined __GNUG__
+# define flatten __attribute__((flatten, noinline))
+#else
+# define flatten
+#endif
+
+#ifdef Q_CREATOR_RUN
+# define DEFUN_WARN_UNUSED
+#elif defined(_MSC_VER)
+# define DEFUN_WARN_UNUSED _Check_return_
+#else
+# define DEFUN_WARN_UNUSED __attribute__((warn_unused_result))
+#endif
+
+#if defined(__GNUG__)
+# define unused(t, i) t __attribute__((unused)) i
+#else
+# define unused(t, i) t
+#endif
+
+#if !defined(_WIN32)
+# define unused_on_unix(t, i) unused(t, i)
+#else
+# define unused_on_unix(t, i) t i
+#endif
+
+#if defined __GNUC__
+# define likely(x) __builtin_expect(!!(x),1)
+# define unlikely(x) __builtin_expect(!!(x),0)
+#else
+# define likely(x) (x)
+# define unlikely(x) (x)
+#endif
diff --git a/compat/util.hpp b/compat/util.hpp
index 6db5324b..59c270ed 100644
--- a/compat/util.hpp
+++ b/compat/util.hpp
@@ -4,6 +4,7 @@
#include "run-in-thread.hpp"
#include "meta.hpp"
#include "functional.hpp"
+#include "macros.hpp"
#include <memory>
#include <cmath>
@@ -25,34 +26,6 @@
template<typename t> using mem = std::shared_ptr<t>;
template<typename t> using ptr = std::unique_ptr<t>;
-#ifdef Q_CREATOR_RUN
-# define DEFUN_WARN_UNUSED
-#elif defined(_MSC_VER)
-# define DEFUN_WARN_UNUSED _Check_return_
-#else
-# define DEFUN_WARN_UNUSED __attribute__((warn_unused_result))
-#endif
-
-#if defined(__GNUG__)
-# define unused(t, i) t __attribute__((unused)) i
-#else
-# define unused(t, i) t
-#endif
-
-#if !defined(_WIN32)
-# define unused_on_unix(t, i) unused(t, i)
-#else
-# define unused_on_unix(t, i) t i
-#endif
-
-#if defined __GNUC__
-# define likely(x) __builtin_expect(!!(x),1)
-# define unlikely(x) __builtin_expect(!!(x),0)
-#else
-# define likely(x) (x)
-# define unlikely(x) (x)
-#endif
-
template<typename t>
inline int iround(const t& val)
{
@@ -112,39 +85,3 @@ inline auto clamp(const t& val, const u& min, const w& max)
using tp = decltype(val + min + max);
return ::util_detail::clamp<tp>::clamp_(val, min, max);
}
-
-#if defined _MSC_VER
-# define never_inline __declspec(noinline)
-#elif defined __GNUG__
-# define never_inline __attribute__((noinline))
-#else
-# define never_inline
-#endif
-
-#if defined _MSC_VER || defined __GNUG__
-# define restrict __restrict
-#else
-# define restrict
-#endif
-
-#if defined _MSC_VER
-# define restrict_ref restrict
-#elif defined __GNUG__
-# define restrict_ref restrict
-#else
-# define restrict_ref
-#endif
-
-#if defined _MSC_VER
-# define force_inline __forceinline
-#elif defined __GNUG__
-# define force_inline __attribute__((always_inline, gnu_inline)) inline
-#else
-# define force_inline inline
-#endif
-
-#if defined __GNUG__
-# define flatten __attribute__((flatten, noinline))
-#else
-# define flatten
-#endif