From bca83618cda7ee4f683b4685d10db9e1bef4983c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 Jul 2018 12:58:13 +0200 Subject: [PATCH] Add fallback implementation for constexpr and alignof --- src/hb-private.hh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/hb-private.hh b/src/hb-private.hh index 5cec8e0b4..6893bfd35 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -84,6 +84,10 @@ extern "C" void hb_free_impl(void *ptr); #define nullptr NULL #endif +#ifndef constexpr +#define constexpr const +#endif + // Static assertions #ifndef static_assert #define static_assert(e, msg) \ @@ -98,6 +102,20 @@ extern "C" void hb_free_impl(void *ptr); #define thread_local #endif +#ifndef alignof +#define alignof(x) _hb_alignof::value; +template +struct _hb_alignof +{ + struct s + { + char c; + T t; + }; + static constexpr unsigned int value = offsetof (s, t); +}; +#endif // alignof + #endif // __cplusplus < 201103L #if (defined(__GNUC__) || defined(__clang__)) && defined(__OPTIMIZE__)