summaryrefslogtreecommitdiffstats
path: root/prelude
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-08 18:09:13 -0800
committerGitHub <noreply@github.com>2024-03-08 18:09:13 -0800
commit5074ee7c8a7f154273ed26815a8018df27dc03bb (patch)
tree9418fab849f254291172068049c8c97955e75cf0 /prelude
parent0629b22bf09ae6b3c3689c5f98492df7577bf0d2 (diff)
Improve cpp prelude. (#3725)
Diffstat (limited to 'prelude')
-rw-r--r--prelude/slang-cpp-scalar-intrinsics.h6
-rw-r--r--prelude/slang-cpp-types.h3
2 files changed, 6 insertions, 3 deletions
diff --git a/prelude/slang-cpp-scalar-intrinsics.h b/prelude/slang-cpp-scalar-intrinsics.h
index acbe00152..8fc90fac8 100644
--- a/prelude/slang-cpp-scalar-intrinsics.h
+++ b/prelude/slang-cpp-scalar-intrinsics.h
@@ -43,7 +43,7 @@ SLANG_FORCE_INLINE float _bitCastUIntToFloat(uint32_t ui) { Union32 u; u.u = ui;
// This impl is based on FloatToHalf that is in Slang codebase
-uint32_t f32tof16(const float value)
+SLANG_FORCE_INLINE uint32_t f32tof16(const float value)
{
const uint32_t inBits = _bitCastFloatToUInt(value);
@@ -97,7 +97,7 @@ uint32_t f32tof16(const float value)
static const float g_f16tof32Magic = _bitCastIntToFloat((127 + (127 - 15)) << 23);
-float f16tof32(const uint32_t value)
+SLANG_FORCE_INLINE float f16tof32(const uint32_t value)
{
const uint32_t sign = (value & 0x8000) << 16;
uint32_t exponent = (value & 0x7c00) >> 10;
@@ -469,7 +469,7 @@ SLANG_FORCE_INLINE int64_t I64_max(int64_t a, int64_t b) { return a > b ? a : b;
# include <intrin.h>
# endif
-void InterlockedAdd(uint32_t* dest, uint32_t value, uint32_t* oldValue)
+SLANG_FORCE_INLINE void InterlockedAdd(uint32_t* dest, uint32_t value, uint32_t* oldValue)
{
# ifdef _WIN32
*oldValue = _InterlockedExchangeAdd((long*)dest, (long)value);
diff --git a/prelude/slang-cpp-types.h b/prelude/slang-cpp-types.h
index ac66ad9f3..74a750b63 100644
--- a/prelude/slang-cpp-types.h
+++ b/prelude/slang-cpp-types.h
@@ -5,6 +5,9 @@
namespace SLANG_PRELUDE_NAMESPACE {
#endif
+#ifndef SLANG_FORCE_INLINE
+# define SLANG_FORCE_INLINE inline
+#endif
#include "slang-cpp-types-core.h"