2022-11-30 12:17:30 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2022-11-09 19:16:08 +00:00
|
|
|
#ifndef _BLISP_UTIL_H
|
|
|
|
#define _BLISP_UTIL_H
|
|
|
|
|
2023-01-07 14:07:25 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
2022-11-09 19:16:08 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#else
|
|
|
|
#include <time.h>
|
|
|
|
#endif
|
|
|
|
|
2023-01-07 14:07:25 +00:00
|
|
|
static void blisp_dlog(const char* format, ...)
|
|
|
|
{
|
|
|
|
fflush(stdout);
|
|
|
|
va_list args;
|
|
|
|
va_start(args, format);
|
|
|
|
vfprintf(stderr, format, args);
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-01-07 10:50:51 +00:00
|
|
|
static void sleep_ms(int milliseconds) {
|
2022-11-09 19:16:08 +00:00
|
|
|
#ifdef WIN32
|
2023-01-07 10:50:51 +00:00
|
|
|
Sleep(milliseconds);
|
2022-11-09 19:16:08 +00:00
|
|
|
#else
|
2023-01-07 10:50:51 +00:00
|
|
|
struct timespec ts;
|
|
|
|
ts.tv_sec = milliseconds / 1000;
|
|
|
|
ts.tv_nsec = (milliseconds % 1000) * 1000000;
|
|
|
|
nanosleep(&ts, NULL);
|
2022-11-09 19:16:08 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|