diff options
author | Bad Diode <bd@badd10de.dev> | 2021-01-25 22:01:00 +0100 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-01-25 22:01:00 +0100 |
commit | e24186fc1917c5e8b91924af0c3c7c55816ff5d6 (patch) | |
tree | 6b20f24824736e822ba614811f312a7c7c2fd43b /src/platform.h | |
download | mic-e24186fc1917c5e8b91924af0c3c7c55816ff5d6.tar.gz mic-e24186fc1917c5e8b91924af0c3c7c55816ff5d6.zip |
Introducing MIC
Diffstat (limited to 'src/platform.h')
-rw-r--r-- | src/platform.h | 25 |
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. | ||
6 | typedef 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 | ||