blob: 877453cd48125e1fdda7b92c0fa4883314c308a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#ifndef MIC_PLATFORM_H
#define MIC_PLATFORM_H
// Function pointers for the PlatformAPI. This allows the app to call platform
// specific functions that perform IO, memory allocations, etc.
typedef struct PlatformAPI {
// Reads an entire file into a null terminated buffer. It doesn't perform
// memory allocations and may crash if there is not enough memory or if it
// is uninitialized. Returns the number of bytes read.
size_t (*read_file)(const char *path, char *memory);
// Custom memory allocation functions for the platform.
void *(*malloc)(size_t size);
void (*free)(void *ptr);
void *(*calloc)(size_t nmemb, size_t size);
void *(*realloc)(void *ptr, size_t size);
// Sleep/wait for a given number of microseconds.
void (*sleep)(size_t microseconds);
// Logging functions.
void (*log)(const char *format, ...);
} PlatformAPI;
#endif // MIC_PLATFORM_H
|