]> gitweb.factorcode.org Git - factor.git/blob - vm/os-linux.cpp
removed some error vm-> functions
[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() this yourself. */
7 const char *vm_executable_path()
8 {
9         char *path = (char *)vm->safe_malloc(PATH_MAX + 1);
10
11         int size = readlink("/proc/self/exe", path, PATH_MAX);
12         if (size < 0)
13         {
14                 vm->fatal_error("Cannot read /proc/self/exe",0);
15                 return NULL;
16         }
17         else
18         {
19                 path[size] = '\0';
20                 return vm->safe_strdup(path);
21         }
22 }
23
24 #ifdef SYS_inotify_init
25
26 VM_C_API int inotify_init()
27 {
28         return syscall(SYS_inotify_init);
29 }
30
31 VM_C_API int inotify_add_watch(int fd, const char *name, u32 mask)
32 {
33         return syscall(SYS_inotify_add_watch, fd, name, mask);
34 }
35
36 VM_C_API int inotify_rm_watch(int fd, u32 wd)
37 {
38         return syscall(SYS_inotify_rm_watch, fd, wd);
39 }
40
41 #else
42
43 VM_C_API int inotify_init()
44 {
45         vm->not_implemented_error();
46         return -1;
47 }
48
49 VM_C_API int inotify_add_watch(int fd, const char *name, u32 mask)
50 {
51         vm->not_implemented_error();
52         return -1;
53 }
54
55 VM_C_API int inotify_rm_watch(int fd, u32 wd)
56 {
57         vm->not_implemented_error();
58         return -1;
59 }
60
61 #endif
62
63 }