better save_image that doesn't corrupt your factor image if you're out of disk space...
[factor/jcg.git] / vm / os-unix.h
blob9f911acdedd506809ae7422fcb136c2543858e7c
1 #include <dirent.h>
2 #include <sys/mman.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <unistd.h>
6 #include <sys/time.h>
7 #include <dlfcn.h>
8 #include <signal.h>
9 #include <pthread.h>
11 typedef char F_CHAR;
12 typedef char F_SYMBOL;
14 #define from_native_string from_char_string
15 #define unbox_native_string unbox_char_string
16 #define string_to_native_alien(string) string_to_char_alien(string,true)
17 #define unbox_symbol_string unbox_char_string
19 #define STRING_LITERAL(string) string
21 #define SSCANF sscanf
22 #define STRCMP strcmp
23 #define STRNCMP strncmp
24 #define STRDUP strdup
25 #define MOVE_FILE_FAILS(old,new) (rename((old),(new)) < 0)
26 #define DELETE_FILE_FAILS(old) (unlink((old)) < 0)
28 #define FIXNUM_FORMAT "%ld"
29 #define CELL_FORMAT "%lu"
30 #define CELL_HEX_FORMAT "%lx"
32 #ifdef FACTOR_64
33 #define CELL_HEX_PAD_FORMAT "%016lx"
34 #else
35 #define CELL_HEX_PAD_FORMAT "%08lx"
36 #endif
38 #define FIXNUM_FORMAT "%ld"
40 #define OPEN_READ(path) fopen(path,"rb")
41 #define OPEN_WRITE(path) fopen(path,"wb")
43 #define print_native_string(string) print_string(string)
45 void start_thread(void *(*start_routine)(void *));
47 void init_ffi(void);
48 void ffi_dlopen(F_DLL *dll);
49 void *ffi_dlsym(F_DLL *dll, F_SYMBOL *symbol);
50 void ffi_dlclose(F_DLL *dll);
52 void unix_init_signals(void);
53 void signal_handler(int signal, siginfo_t* siginfo, void* uap);
54 void dump_stack_signal(int signal, siginfo_t* siginfo, void* uap);
56 s64 current_micros(void);
57 void sleep_micros(CELL usec);
59 void open_console(void);