aboutsummaryrefslogtreecommitdiffstats
path: root/src/platform.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform.h')
-rw-r--r--src/platform.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/platform.h b/src/platform.h
new file mode 100644
index 0000000..877453c
--- /dev/null
+++ b/src/platform.h
@@ -0,0 +1,25 @@
1#ifndef MIC_PLATFORM_H
2#define MIC_PLATFORM_H
3
4// Function pointers for the PlatformAPI. This allows the app to call platform
5// specific functions that perform IO, memory allocations, etc.
6typedef struct PlatformAPI {
7 // Reads an entire file into a null terminated buffer. It doesn't perform
8 // memory allocations and may crash if there is not enough memory or if it
9 // is uninitialized. Returns the number of bytes read.
10 size_t (*read_file)(const char *path, char *memory);
11
12 // Custom memory allocation functions for the platform.
13 void *(*malloc)(size_t size);
14 void (*free)(void *ptr);
15 void *(*calloc)(size_t nmemb, size_t size);
16 void *(*realloc)(void *ptr, size_t size);
17
18 // Sleep/wait for a given number of microseconds.
19 void (*sleep)(size_t microseconds);
20
21 // Logging functions.
22 void (*log)(const char *format, ...);
23} PlatformAPI;
24
25#endif // MIC_PLATFORM_H