factor/vm/os-unix.hpp

59 lines
1.3 KiB
C++
Raw Normal View History

2009-05-13 02:08:16 -04:00
#include <unistd.h>
#include <sys/param.h>
2009-05-02 05:04:19 -04:00
#include <dirent.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/time.h>
#include <dlfcn.h>
#include <signal.h>
#include <pthread.h>
#include <sched.h>
2009-05-02 05:04:19 -04:00
#include "atomic-gcc.hpp"
2013-05-11 22:24:31 -04:00
namespace factor {
2009-05-04 02:46:13 -04:00
2009-05-04 05:50:24 -04:00
typedef char vm_char;
typedef char symbol_char;
2009-05-02 05:04:19 -04:00
#define STRING_LITERAL(string) string
#define SSCANF sscanf
#define STRCMP strcmp
#define STRNCMP strncmp
#define STRDUP strdup
#define SNPRINTF snprintf
2009-05-02 05:04:19 -04:00
2009-10-03 19:20:35 -04:00
#define FTELL ftello
2009-05-02 05:04:19 -04:00
#define FSEEK fseeko
2013-05-11 22:24:31 -04:00
#define OPEN_READ(path) fopen(path, "rb")
#define OPEN_WRITE(path) fopen(path, "wb")
#ifdef _GNU_SOURCE
extern "C" {
extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen) __THROW __nonnull ((2));
}
#define strerror_r __xpg_strerror_r
#endif
2014-07-05 21:58:24 -04:00
#define THREADSAFE_STRERROR(errnum, buf, buflen) strerror_r(errnum, buf, buflen)
2009-05-02 05:04:19 -04:00
#define print_native_string(string) print_string(string)
2009-05-02 05:04:19 -04:00
2009-08-25 03:55:18 -04:00
typedef pthread_t THREADHANDLE;
2009-05-02 05:04:19 -04:00
2013-05-11 22:24:31 -04:00
THREADHANDLE start_thread(void* (*start_routine)(void*), void* args);
inline static THREADHANDLE thread_id() { return pthread_self(); }
2009-05-02 05:04:19 -04:00
uint64_t nano_count();
void sleep_nanos(uint64_t nsec);
2013-05-11 22:24:31 -04:00
void move_file(const vm_char* path1, const vm_char* path2);
2013-05-11 22:24:31 -04:00
static inline void breakpoint() { __builtin_trap(); }
2009-05-04 02:46:13 -04:00
}