aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-04-29 10:08:04 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-04-29 10:08:04 +0200
commit8d3fc9f5f9c0593fcae9c451efe6c89c64dcbe84 (patch)
tree8c0182f9bf94aaa8afe5126988e07af82c4409fd /src/utils
parentcdf46d85efe7fa54e8c302a255214341c567b4af (diff)
downloadnissy-core-8d3fc9f5f9c0593fcae9c451efe6c89c64dcbe84.tar.gz
nissy-core-8d3fc9f5f9c0593fcae9c451efe6c89c64dcbe84.zip
Added stop / pause / resume solve to API
Diffstat (limited to '')
-rw-r--r--src/utils/sleep.h48
-rw-r--r--src/utils/utils.h1
2 files changed, 49 insertions, 0 deletions
diff --git a/src/utils/sleep.h b/src/utils/sleep.h
new file mode 100644
index 0000000..d618e9b
--- /dev/null
+++ b/src/utils/sleep.h
@@ -0,0 +1,48 @@
1STATIC void msleep(int);
2
3#if defined(WIN32)
4
5#define NISSY_CANSLEEP true
6
7STATIC void
8msleep(int milliseconds)
9{
10 Sleep(milliseconds);
11}
12
13#elif defined(__wasm__)
14
15#include <emscripten.h>
16
17#define NISSY_CANSLEEP true
18
19STATIC void
20msleep(int milliseconds)
21{
22 emscripten_sleep(milliseconds);
23}
24
25#elif defined(__unix__)
26
27#include <time.h>
28
29#define NISSY_CANSLEEP true
30
31STATIC void
32msleep(int milliseconds)
33{
34 struct timespec t;
35 t.tv_sec = milliseconds / 1000;
36 t.tv_nsec = (milliseconds % 1000) * 1000000;
37 nanosleep(&t, NULL);
38}
39
40#else
41
42#define NISSY_CANSLEEP false
43STATIC void
44msleep(int milliseconds)
45{
46}
47
48#endif
diff --git a/src/utils/utils.h b/src/utils/utils.h
index ce4355e..d14b285 100644
--- a/src/utils/utils.h
+++ b/src/utils/utils.h
@@ -1,3 +1,4 @@
1#include "dbg_log.h" 1#include "dbg_log.h"
2#include "constants.h" 2#include "constants.h"
3#include "math.h" 3#include "math.h"
4#include "sleep.h"

Generated with cgit - Back to sebastiano.tronto.net