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