]> gitweb.factorcode.org Git - factor.git/blob - vm/os-unix.hpp
tools.scaffold: don't use sequences.extras.
[factor.git] / vm / os-unix.hpp
1 #include <unistd.h>
2 #include <sys/param.h>
3 #include <dirent.h>
4 #include <sys/mman.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <unistd.h>
8 #include <sys/time.h>
9 #include <dlfcn.h>
10 #include <signal.h>
11 #include <pthread.h>
12 #include <sched.h>
13 #include "atomic-gcc.hpp"
14
15 namespace factor {
16
17 typedef char vm_char;
18 typedef char symbol_char;
19
20 #define STRING_LITERAL(string) string
21
22 #define SSCANF sscanf
23 #define STRCMP strcmp
24 #define STRNCMP strncmp
25 #define STRDUP strdup
26
27 #define FTELL ftello
28 #define FSEEK fseeko
29
30 #define OPEN_READ(path) fopen(path, "rb")
31 #define OPEN_WRITE(path) fopen(path, "wb")
32
33 #ifdef _GNU_SOURCE
34 extern "C" {
35   extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen);
36 }
37 #define strerror_r __xpg_strerror_r
38 #endif
39
40 #define THREADSAFE_STRERROR(errnum, buf, buflen) strerror_r(errnum, buf, buflen)
41
42 #define print_native_string(string) print_string(string)
43
44 typedef pthread_t THREADHANDLE;
45
46 THREADHANDLE start_thread(void* (*start_routine)(void*), void* args);
47 inline static THREADHANDLE thread_id() { return pthread_self(); }
48
49 uint64_t nano_count();
50 void sleep_nanos(uint64_t nsec);
51
52 void check_ENOMEM(const char* msg);
53
54 static inline void breakpoint() { __builtin_trap(); }
55
56 #define AS_UTF8(ptr) ptr
57 }