]> gitweb.factorcode.org Git - factor.git/blob - vm/os-unix.hpp
os-unix.hpp: Use the old strerror_r insetad of the newfangled one.
[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
14 #include "atomic-gcc.hpp"
15
16 namespace factor {
17
18 typedef char vm_char;
19 typedef char symbol_char;
20
21 #define STRING_LITERAL(string) string
22
23 #define SSCANF sscanf
24 #define STRCMP strcmp
25 #define STRNCMP strncmp
26 #define STRDUP strdup
27 #define SNPRINTF snprintf
28
29 #define FTELL ftello
30 #define FSEEK fseeko
31
32 #define OPEN_READ(path) fopen(path, "rb")
33 #define OPEN_WRITE(path) fopen(path, "wb")
34
35 #ifdef _GNU_SOURCE
36 extern "C" {
37   extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen) __THROW __nonnull ((2));
38 }
39 #define strerror_r __xpg_strerror_r
40 #endif
41
42 #define THREADSAFE_STRERROR(errnum, buf, buflen) strerror_r(errnum, buf, buflen)
43
44 #define print_native_string(string) print_string(string)
45
46 typedef pthread_t THREADHANDLE;
47
48 THREADHANDLE start_thread(void* (*start_routine)(void*), void* args);
49 inline static THREADHANDLE thread_id() { return pthread_self(); }
50
51 uint64_t nano_count();
52 void sleep_nanos(uint64_t nsec);
53
54 void move_file(const vm_char* path1, const vm_char* path2);
55
56 static inline void breakpoint() { __builtin_trap(); }
57
58 }