Initial commit
Some checks failed
CI / build-and-analyze (push) Failing after 1m18s

This commit is contained in:
2026-08-09 12:55:16 +03:00
commit 04e02490b7
25 changed files with 1293 additions and 0 deletions

32
posix/Timespec.h Normal file
View File

@@ -0,0 +1,32 @@
#ifndef CGE_THREAD_TIMESPEC_H
#define CGE_THREAD_TIMESPEC_H
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
static int convertToTimespec(struct timespec *ts, uint32_t timeout) {
#if (_POSIX_TIMERS > 0)
if (clock_gettime(CLOCK_REALTIME, ts))
#endif
{
struct timeval tv;
if (gettimeofday(&tv, NULL))
return 0;
ts->tv_sec = tv.tv_sec;
ts->tv_nsec = tv.tv_usec * 1000;
}
ts->tv_sec += timeout / 1000;
ts->tv_nsec += (timeout % 1000) * 1000000;
while (ts->tv_nsec >= 1000000000) {
ts->tv_nsec -= 1000000000;
ts->tv_sec += 1;
}
return 1;
}
#endif /* CGE_THREAD_TIMESPEC_H */