]> gitweb.factorcode.org Git - factor.git/blob - vm/os-linux.cpp
Move vmpp to vm
[factor.git] / vm / os-linux.cpp
1 #include "master.hpp"
2
3 /* Snarfed from SBCL linux-so.c. You must free() this yourself. */
4 const char *vm_executable_path(void)
5 {
6         char *path = safe_malloc(PATH_MAX + 1);
7
8         int size = readlink("/proc/self/exe", path, PATH_MAX);
9         if (size < 0)
10         {
11                 fatal_error("Cannot read /proc/self/exe",0);
12                 return NULL;
13         }
14         else
15         {
16                 path[size] = '\0';
17                 return safe_strdup(path);
18         }
19 }
20
21 #ifdef SYS_inotify_init
22
23 int inotify_init(void)
24 {
25         return syscall(SYS_inotify_init);
26 }
27
28 int inotify_add_watch(int fd, const char *name, u32 mask)
29 {
30         return syscall(SYS_inotify_add_watch, fd, name, mask);
31 }
32
33 int inotify_rm_watch(int fd, u32 wd)
34 {
35         return syscall(SYS_inotify_rm_watch, fd, wd);
36 }
37
38 #else
39
40 int inotify_init(void)
41 {
42         not_implemented_error();
43         return -1;
44 }
45
46 int inotify_add_watch(int fd, const char *name, u32 mask)
47 {
48         not_implemented_error();
49         return -1;
50 }
51
52 int inotify_rm_watch(int fd, u32 wd)
53 {
54         not_implemented_error();
55         return -1;
56 }
57
58 #endif