aboutsummaryrefslogtreecommitdiff
path: root/code/handmade_intrinsics.h
diff options
context:
space:
mode:
Diffstat (limited to 'code/handmade_intrinsics.h')
-rw-r--r--code/handmade_intrinsics.h98
1 files changed, 77 insertions, 21 deletions
diff --git a/code/handmade_intrinsics.h b/code/handmade_intrinsics.h
index 2a3a69e..00b2769 100644
--- a/code/handmade_intrinsics.h
+++ b/code/handmade_intrinsics.h
@@ -3,75 +3,98 @@
#ifndef HANDMADE_INTRINSICS_H
#define HANDMADE_INTRINSICS_H
+#if COMPILER_GNU
+#include <x86intrin.h>
+#endif
//
// TODO(casey): Remove math.h
//
#include <math.h>
-inline s32
-RoundReal32ToInt32(r32 Real32)
+inline
+s32 SignOf(s32 Value)
+{
+ s32 Result = (Value >= 0) ? 1 : -1;
+ return Result;
+}
+
+inline
+r32 AbsoluteValue(r32 Real32)
+{
+ r32 Result = fabs(Real32);
+ return Result;
+}
+
+inline
+s32 RoundReal32ToInt32(r32 Real32)
{
s32 Result = (s32)(roundf(Real32));
return Result;
}
-inline u32
-RoundReal32ToUInt32(r32 Real32)
+inline
+u32 RoundReal32ToUInt32(r32 Real32)
{
u32 Result = (u32)(roundf(Real32));
return Result;
}
-inline u32
-TruncateReal32ToUInt32(r32 Real32)
+inline
+u32 TruncateReal32ToUInt32(r32 Real32)
{
u32 Result = (u32)Real32;
return Result;
}
-inline s32
-TruncateReal32ToInt32(r32 Real32)
+inline
+s32 TruncateReal32ToInt32(r32 Real32)
{
s32 Result = (s32)Real32;
return Result;
}
-inline s32
-FloorReal32ToInt32(r32 Real32)
+inline
+s32 FloorReal32ToInt32(r32 Real32)
{
s32 Result = (s32)floorf(Real32);
return Result;
}
-inline r32
-Sin(r32 Angle)
+inline
+s32 CeilReal32ToInt32(r32 Real32)
+{
+ s32 Result = (s32)ceilf(Real32);
+ return Result;
+}
+inline
+r32 Sin(r32 Angle)
{
r32 Result = sinf(Angle);
return Result;
}
-inline r32
-Cos(r32 Angle)
+inline
+r32 Cos(r32 Angle)
{
r32 Result = cosf(Angle);
return Result;
}
-inline r32
-Atan2(r32 Y, r32 X)
+inline
+r32 Atan2(r32 Y, r32 X)
{
r32 Result = atan2f(Y, X);
return Result;
+
}
-
struct bit_scan_result
{
b32 Found;
u32 Index;
-};
-
-internal inline bit_scan_result
-FindLeastSignificantSetBit(u32 Value)
+}
+;
+internal inline
+bit_scan_result FindLeastSignificantSetBit(u32 Value)
{
bit_scan_result Result = {};
@@ -100,4 +123,37 @@ FindLeastSignificantSetBit(u32 Value)
return Result;
}
+u32 RotateLeft(u32 Value, u32 Count)
+{
+ u32 Result = 0;
+
+#if 0
+#elif COMPILER_GNU
+ Result = _rotl(Value, Count);
+#endif
+
+ return Result;
+}
+
+u32 RotateRight(u32 Value, u32 Count)
+{
+ u32 Result = 0;
+
+#if 0
+#elif COMPILER_GNU
+ Result = _rotr(Value, Count);
+#endif
+
+ return Result;
+}
+
+
+inline
+r32 SquareRoot(r32 Real32)
+{
+ r32 Result = sqrtf(Real32);
+ return Result;
+}
+
+
#endif //HANDMADE_INTRINSICS_H