Fumofumotris/source/fumoengine/fumocommon.c

38 lines
587 B
C
Raw Normal View History

2024-04-30 21:41:31 +00:00
#include "fumocommon.h"
2024-03-25 05:34:59 +00:00
#include <time.h>
2024-04-30 21:41:31 +00:00
2024-05-07 03:29:10 +00:00
usize min_usize(usize a, usize b)
2024-04-30 21:41:31 +00:00
{
return a < b ? a : b;
}
2024-03-25 05:34:59 +00:00
2024-05-07 03:29:10 +00:00
nsec TimeNow()
2024-03-25 05:34:59 +00:00
{
struct timespec ts;
timespec_get(&ts, TIME_UTC);
2024-04-22 22:13:13 +00:00
return ts.tv_nsec + ts.tv_sec * ONE_E_9;
2024-03-25 05:34:59 +00:00
}
2024-04-22 22:13:13 +00:00
double TimeNowD()
2024-03-25 05:34:59 +00:00
{
2024-04-16 22:14:53 +00:00
struct timespec ts;
timespec_get(&ts, TIME_UTC);
return ts.tv_sec + (double)ts.tv_nsec / 1000000000.0;
2024-05-07 03:29:10 +00:00
}
u32 Hash(void *item, usize size)
{
u8 *data = (u8 *)item;
u32 h = 98317;
for (usize i = 0; i < size; i++) {
h ^= data[i];
h *= 0x5bd1e995;
h ^= h >> 15;
}
return h;
2024-03-25 05:34:59 +00:00
}