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 +----------------------------------------------------------------------+
19 #include "hphp/util/assertions.h"
22 ///////////////////////////////////////////////////////////////////////////////
24 enum class Arch
{ X64
, ARM
, };
26 constexpr Arch
arch() {
27 #if defined(__aarch64__)
34 constexpr bool arch_any() { return false; }
37 * Convenience helper for guarding on a set of architectures.
39 template<class... Tail
>
40 bool arch_any(Arch a
, Tail
&&... archs
) {
41 return arch() == a
|| arch_any(archs
...);
45 * MSVC's Preprocessor is completely idiotic, so we have to play by its rules
46 * and forcefully expand the variadic args so they aren't all interpreted as the
47 * first argument to func.
49 #define MSVC_GLUE(x, y) x y
52 * Macro for defining easy arch-dispatch wrappers.
54 * We need to specify the return type explicitly, or else we may drop refs.
56 #define ARCH_SWITCH_CALL(func, ...) \
57 ([&]() -> decltype(x64::func(__VA_ARGS__)) { \
60 return x64::MSVC_GLUE(func, (__VA_ARGS__)); \
62 return arm::MSVC_GLUE(func, (__VA_ARGS__)); \
67 ///////////////////////////////////////////////////////////////////////////////