Skip to content

Commit

Permalink
update preprocessor machinery
Browse files Browse the repository at this point in the history
  • Loading branch information
marzer committed Jun 14, 2023
1 parent 5c8c992 commit 3beb8b2
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 6 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 1000000
PenaltyIndentedWhitespace: 0
PointerAlignment: Left
QualifierAlignment: Leave
ReflowComments: true
SortIncludes: false
SortJavaStaticImport: Before
Expand Down
61 changes: 55 additions & 6 deletions include/mz/tagged_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//----------------------------------------------------------------------------------------------------------------------
// THIS FILE WAS ASSEMBLED FROM MULTIPLE HEADER FILES BY A SCRIPT - PLEASE DON'T EDIT IT DIRECTLY
// upstream: 4d0991fb8dd0c440c0d6c2ab33941ce76ce3c41d
//----------------------------------------------------------------------------------------------------------------------
//
// MIT License
Expand Down Expand Up @@ -68,6 +67,10 @@
#endif
#endif

#ifndef MZ_MAKE_VERSION
#define MZ_MAKE_VERSION(major, minor, patch) (((major)*10000) + ((minor)*100) + ((patch)))
#endif

#ifndef MZ_INTELLISENSE
#ifdef __INTELLISENSE__
#define MZ_INTELLISENSE 1
Expand All @@ -91,6 +94,40 @@
#else
#define MZ_CLANG 0
#endif

// special handling for apple clang; see:
// - https://github.com/marzer/tomlplusplus/issues/189
// - https://en.wikipedia.org/wiki/Xcode
// -
// https://stackoverflow.com/questions/19387043/how-can-i-reliably-detect-the-version-of-clang-at-preprocessing-time
#if MZ_CLANG && defined(__apple_build_version__)
#undef MZ_CLANG
#define MZ_CLANG_VERSION MZ_MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
#if MZ_CLANG_VERSION >= MZ_MAKE_VERSION(15, 0, 0)
#define MZ_CLANG 16
#elif MZ_CLANG_VERSION >= MZ_MAKE_VERSION(14, 3, 0)
#define MZ_CLANG 15
#elif MZ_CLANG_VERSION >= MZ_MAKE_VERSION(14, 0, 0)
#define MZ_CLANG 14
#elif MZ_CLANG_VERSION >= MZ_MAKE_VERSION(13, 1, 6)
#define MZ_CLANG 13
#elif MZ_CLANG_VERSION >= MZ_MAKE_VERSION(13, 0, 0)
#define MZ_CLANG 12
#elif MZ_CLANG_VERSION >= MZ_MAKE_VERSION(12, 0, 5)
#define MZ_CLANG 11
#elif MZ_CLANG_VERSION >= MZ_MAKE_VERSION(12, 0, 0)
#define MZ_CLANG 10
#elif MZ_CLANG_VERSION >= MZ_MAKE_VERSION(11, 0, 3)
#define MZ_CLANG 9
#elif MZ_CLANG_VERSION >= MZ_MAKE_VERSION(11, 0, 0)
#define MZ_CLANG 8
#elif MZ_CLANG_VERSION >= MZ_MAKE_VERSION(10, 0, 1)
#define MZ_CLANG 7
#else
#define MZ_CLANG 6 // not strictly correct but doesn't matter below this
#endif
#undef MZ_CLANG_VERSION
#endif
#endif

#ifndef MZ_ICC
Expand Down Expand Up @@ -139,6 +176,14 @@
#endif
#endif

#ifndef MZ_CUDA
#if defined(__CUDACC__) || defined(__CUDA_ARCH__) || defined(__CUDA_LIBDEVICE__)
#define MZ_CUDA 1
#else
#define MZ_CUDA 0
#endif
#endif

#ifndef MZ_ARCH_AMD64
#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64)
#define MZ_ARCH_AMD64 1
Expand Down Expand Up @@ -204,8 +249,8 @@
#if MZ_HAS_CPP_ATTR(nodiscard) >= 201603
#define MZ_NODISCARD [[nodiscard]]
#define MZ_NODISCARD_CLASS [[nodiscard]]
#elif MZ_CLANG || MZ_GCC_LIKE || MZ_HAS_ATTR(warn_unused_result)
#define MZ_NODISCARD MZ_ATTR(warn_unused_result)
#elif MZ_CLANG || MZ_GCC_LIKE || MZ_HAS_ATTR(__warn_unused_result__)
#define MZ_NODISCARD MZ_ATTR(__warn_unused_result__)
#else
#define MZ_NODISCARD
#endif
Expand All @@ -220,11 +265,15 @@
#endif

#if MZ_MSVC_LIKE
#define MZ_ASSUME(cond) __assume(cond)
#define MZ_ASSUME(expr) __assume(expr)
#elif MZ_ICC || MZ_CLANG || MZ_HAS_BUILTIN(__builtin_assume)
#define MZ_ASSUME(cond) __builtin_assume(cond)
#define MZ_ASSUME(expr) __builtin_assume(expr)
#elif MZ_HAS_CPP_ATTR(assume) >= 202207
#define MZ_ASSUME(expr) [[assume(expr)]]
#elif MZ_HAS_ATTR(__assume__)
#define MZ_ASSUME(expr) __attribute__((__assume__(expr)))
#else
#define MZ_ASSUME(cond) static_cast<void>(0)
#define MZ_ASSUME(expr) static_cast<void>(0)
#endif

#ifndef MZ_PURE_GETTER
Expand Down
22 changes: 22 additions & 0 deletions tagged_ptr.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"files.associations": {
"type_traits": "cpp",
"concepts": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdlib": "cpp",
"initializer_list": "cpp",
"xstddef": "cpp",
"xtr1common": "cpp",
"version": "cpp",
"xstring": "cpp"
},
"explorer.sortOrder": "type"
}
}

0 comments on commit 3beb8b2

Please sign in to comment.