2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_ARCH_H
18 #define incl_HPHP_ARCH_H
20 #include "hphp/util/assertions.h"
23 ///////////////////////////////////////////////////////////////////////////////
25 enum class Arch
{ X64
, ARM
, PPC64
, };
27 constexpr Arch
arch() {
28 #if defined(__powerpc64__)
30 #elif defined(__aarch64__)
37 constexpr bool arch_any() { return false; }
40 * Convenience helper for guarding on a set of architectures.
42 template<class... Tail
>
43 bool arch_any(Arch a
, Tail
&&... archs
) {
44 return arch() == a
|| arch_any(archs
...);
48 * MSVC's Preprocessor is completely idiotic, so we have to play by its rules
49 * and forcefully expand the variadic args so they aren't all interpreted as the
50 * first argument to func.
52 #define MSVC_GLUE(x, y) x y
55 * Macro for defining easy arch-dispatch wrappers.
57 * We need to specify the return type explicitly, or else we may drop refs.
59 #define ARCH_SWITCH_CALL(func, ...) \
60 ([&]() -> decltype(x64::func(__VA_ARGS__)) { \
63 return x64::MSVC_GLUE(func, (__VA_ARGS__)); \
65 return arm::MSVC_GLUE(func, (__VA_ARGS__)); \
67 return ppc64::MSVC_GLUE(func, (__VA_ARGS__)); \
72 ///////////////////////////////////////////////////////////////////////////////