sm64pc/src/pc/platform.h

42 lines
1.2 KiB
C

#ifndef _SM64_PLATFORM_H_
#define _SM64_PLATFORM_H_
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <pthread.h>
#include <semaphore.h>
/* Platform-specific functions and whatnot */
#define SYS_MAX_PATH 1024 // FIXME: define this on different platforms
// NULL terminated list of platform specific read-only data paths
extern const char *sys_ropaths[];
// crossplatform impls of misc stuff
char *sys_strdup(const char *src);
char *sys_strlwr(char *src);
int sys_strcasecmp(const char *s1, const char *s2);
void sys_sleep(const uint64_t us);
double sys_profile_time(void);
void sys_mutex_lock(pthread_mutex_t *mutex);
void sys_mutex_unlock(pthread_mutex_t *mutex);
void sys_semaphore_init(sem_t *sem, int pshared, unsigned int value);
void sys_semaphore_wait(sem_t *sem);
void sys_semaphore_post(sem_t *sem);
void sys_semaphore_destroy(sem_t *sem);
// path stuff
const char *sys_user_path(void);
const char *sys_exe_path(void);
const char *sys_file_extension(const char *fpath);
const char *sys_file_name(const char *fpath);
// shows an error message in some way and terminates the game
void sys_fatal(const char *fmt, ...) __attribute__ ((noreturn));
#endif // _SM64_PLATFORM_H_