-/* Copyright (C) 2021-2022 Harry Godden (hgn) - All Rights Reserved */
+#ifndef VG_PLATFORM_H
+#define VG_PLATFORM_H
-typedef uint8_t u8;
-typedef uint16_t u16;
-typedef uint32_t u32;
-typedef uint64_t u64;
-typedef int8_t i8;
-typedef int16_t i16;
-typedef int32_t i32;
-typedef int64_t i64;
+/* Copyright (C) 2021-2022 Harry Godden (hgn) - All Rights Reserved */
typedef unsigned int uint;
typedef float v4f[4];
typedef v2f m2x2f[2];
typedef v3f m3x3f[3];
-typedef v3f m4x3f[4]; /* TODO why this is 4x4 too? */
+typedef v3f m4x3f[4];
typedef v4f m4x4f[4];
typedef v3f boxf[2];
}
#endif
}
+
+static void vg_sleep_ms( long msec )
+{
+ struct timespec ts;
+
+ ts.tv_sec = msec / 1000;
+ ts.tv_nsec = (msec % 1000) * 1000000;
+ nanosleep( &ts, &ts );
+}
+
+/* diff two timespecs in MS */
+static double vg_time_diff( struct timespec start, struct timespec end )
+{
+ double elapsed = 1000.0*end.tv_sec + 1e-6*end.tv_nsec
+ - (1000.0*start.tv_sec + 1e-6*start.tv_nsec);
+
+ return elapsed;
+}
+
+#endif