| 1 | /*++ |
| 2 | |
| 3 | Copyright (c) Microsoft. All rights reserved. |
| 4 | |
| 5 | Module Name: |
| 6 | |
| 7 | defs.h |
| 8 | |
| 9 | Abstract: |
| 10 | |
| 11 | This file contains shared platform definitions. |
| 12 | |
| 13 | --*/ |
| 14 | |
| 15 | #pragma once |
| 16 | |
| 17 | #if defined(_MSC_VER) |
| 18 | #define THROW_INVALID_ARG_IF(condition) THROW_HR_IF(E_INVALIDARG, condition) |
| 19 | |
| 20 | #define THROW_IF_FAILED_EXCEPT(result, accepted) \ |
| 21 | do \ |
| 22 | { \ |
| 23 | auto _result = (result); \ |
| 24 | if (FAILED(_result) && _result != (accepted)) \ |
| 25 | { \ |
| 26 | THROW_HR(_result); \ |
| 27 | } \ |
| 28 | } while (0) |
| 29 | |
| 30 | #elif defined(__GNUC__) |
| 31 | #define THROW_INVALID_ARG_IF(condition) THROW_ERRNO_IF(EINVAL, condition) |
| 32 | #define _stricmp strcasecmp |
| 33 | #define _wcsicmp wcscasecmp |
| 34 | #endif |
| 35 | |
| 36 | #define NON_COPYABLE(Type) \ |
| 37 | Type(const Type&) = delete; \ |
| 38 | Type& operator=(const Type&) = delete; |
| 39 | |
| 40 | #define NON_MOVABLE(Type) \ |
| 41 | Type(Type&&) = delete; \ |
| 42 | Type& operator=(Type&&) = delete; |
| 43 | |
| 44 | #define DEFAULT_MOVABLE(Type) \ |
| 45 | Type(Type&&) = default; \ |
| 46 | Type& operator=(Type&&) = default; |
| 47 | |
| 48 | namespace wsl::shared { |
| 49 | |
| 50 | inline constexpr std::uint32_t VersionMajor = WSL_PACKAGE_VERSION_MAJOR; |
| 51 | inline constexpr std::uint32_t VersionMinor = WSL_PACKAGE_VERSION_MINOR; |
| 52 | inline constexpr std::uint32_t VersionRevision = WSL_PACKAGE_VERSION_REVISION; |
| 53 | inline constexpr std::tuple<uint32_t, uint32_t, uint32_t> PackageVersion{VersionMajor, VersionMinor, VersionRevision}; |
| 54 | |
| 55 | #ifdef WSL_OFFICIAL_BUILD |
| 56 | |
| 57 | inline constexpr bool OfficialBuild = true; |
| 58 | |
| 59 | #else |
| 60 | |
| 61 | inline constexpr bool OfficialBuild = false; |
| 62 | |
| 63 | #endif |
| 64 | |
| 65 | #ifdef DEBUG |
| 66 | |
| 67 | inline constexpr bool Debug = true; |
| 68 | |
| 69 | #else |
| 70 | |
| 71 | inline constexpr bool Debug = false; |
| 72 | |
| 73 | #endif |
| 74 | |
| 75 | #ifdef _AMD64_ |
| 76 | |
| 77 | inline constexpr bool Arm64 = false; |
| 78 | |
| 79 | #elif _ARM64_ |
| 80 | |
| 81 | inline constexpr bool Arm64 = true; |
| 82 | |
| 83 | #else |
| 84 | |
| 85 | #error Unsupported compiler or build environment |
| 86 | |
| 87 | #endif |
| 88 | |
| 89 | } // namespace wsl::shared |