2 * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
9 #include "remapped_functions.h"
13 # define HIDDEN_FUNCTION(function) do {} while (0)
14 # define HIDDEN_FUNCTION_ATTRIBUTE __attribute__((visibility("hidden")))
16 # define HIDDEN_FUNCTION(function) asm volatile(".hidden " #function)
17 # define HIDDEN_FUNCTION_ATTRIBUTE
21 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
22 fchmod(int fd
, mode_t mode
)
24 HIDDEN_FUNCTION(fchmod
);
26 return _haiku_build_fchmod(fd
, mode
);
30 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
31 fchmodat(int fd
, const char* path
, mode_t mode
, int flag
)
33 HIDDEN_FUNCTION(fchmodat
);
35 return _haiku_build_fchmodat(fd
, path
, mode
, flag
);
39 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
40 fstat(int fd
, struct stat
* st
)
42 HIDDEN_FUNCTION(fstat
);
44 return _haiku_build_fstat(fd
, st
);
48 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
49 fstatat(int fd
, const char* path
, struct stat
* st
, int flag
)
51 HIDDEN_FUNCTION(fstatat
);
53 return _haiku_build_fstatat(fd
, path
, st
, flag
);
57 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
58 mkdirat(int fd
, const char* path
, mode_t mode
)
60 HIDDEN_FUNCTION(mkdirat
);
62 return _haiku_build_mkdirat(fd
, path
, mode
);
66 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
67 mkfifoat(int fd
, const char* path
, mode_t mode
)
69 HIDDEN_FUNCTION(mkfifoat
);
71 return _haiku_build_mkfifoat(fd
, path
, mode
);
75 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
76 utimensat(int fd
, const char* path
, const struct timespec times
[2], int flag
)
78 HIDDEN_FUNCTION(utimensat
);
80 return _haiku_build_utimensat(fd
, path
, times
, flag
);
84 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
85 futimens(int fd
, const struct timespec times
[2])
87 HIDDEN_FUNCTION(futimens
);
89 return _haiku_build_futimens(fd
, times
);
93 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
94 faccessat(int fd
, const char* path
, int accessMode
, int flag
)
96 HIDDEN_FUNCTION(faccessat
);
98 return _haiku_build_faccessat(fd
, path
, accessMode
, flag
);
102 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
105 HIDDEN_FUNCTION(fchdir
);
107 return _haiku_build_fchdir(fd
);
111 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
114 HIDDEN_FUNCTION(close
);
116 return _haiku_build_close(fd
);
120 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
123 HIDDEN_FUNCTION(dup
);
125 return _haiku_build_dup(fd
);
129 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
130 dup2(int fd1
, int fd2
)
132 HIDDEN_FUNCTION(dup2
);
134 return _haiku_build_dup2(fd1
, fd2
);
138 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
139 linkat(int toFD
, const char* toPath
, int pathFD
, const char* path
, int flag
)
141 HIDDEN_FUNCTION(linkat
);
143 return _haiku_build_linkat(toFD
, toPath
, pathFD
, path
, flag
);
147 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
148 unlinkat(int fd
, const char* path
, int flag
)
150 HIDDEN_FUNCTION(unlinkat
);
152 return _haiku_build_unlinkat(fd
, path
, flag
);
156 extern "C" ssize_t HIDDEN_FUNCTION_ATTRIBUTE
157 readlinkat(int fd
, const char* path
, char* buffer
, size_t bufferSize
)
159 HIDDEN_FUNCTION(readlinkat
);
161 return _haiku_build_readlinkat(fd
, path
, buffer
, bufferSize
);
165 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
166 symlinkat(const char* toPath
, int fd
, const char* symlinkPath
)
168 HIDDEN_FUNCTION(symlinkat
);
170 return _haiku_build_symlinkat(toPath
, fd
, symlinkPath
);
174 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
175 ftruncate(int fd
, off_t newSize
)
177 HIDDEN_FUNCTION(ftruncate
);
179 return _haiku_build_ftruncate(fd
, newSize
);
183 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
184 fchown(int fd
, uid_t owner
, gid_t group
)
186 HIDDEN_FUNCTION(fchown
);
188 return _haiku_build_fchown(fd
, owner
, group
);
192 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
193 fchownat(int fd
, const char* path
, uid_t owner
, gid_t group
, int flag
)
195 HIDDEN_FUNCTION(fchownat
);
197 return _haiku_build_fchownat(fd
, path
, owner
, group
, flag
);
201 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
202 mknodat(int fd
, const char* name
, mode_t mode
, dev_t dev
)
204 HIDDEN_FUNCTION(mknodat
);
206 return _haiku_build_mknodat(fd
, name
, mode
, dev
);
210 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
211 creat(const char* path
, mode_t mode
)
213 HIDDEN_FUNCTION(RESOLVE(creat
));
215 return _haiku_build_creat(path
, mode
);
219 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
220 open(const char* path
, int openMode
, ...)
222 HIDDEN_FUNCTION(open
);
224 mode_t permissions
= 0;
225 if ((openMode
& O_CREAT
) != 0) {
227 va_start(args
, openMode
);
228 mode_t mask
= umask(0);
230 permissions
= va_arg(args
, int);
234 return _haiku_build_open(path
, openMode
, permissions
);
238 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
239 openat(int fd
, const char* path
, int openMode
, ...)
241 HIDDEN_FUNCTION(openat
);
243 mode_t permissions
= 0;
244 if ((openMode
& O_CREAT
) != 0) {
246 va_start(args
, openMode
);
247 mode_t mask
= umask(0);
249 permissions
= va_arg(args
, int);
253 return _haiku_build_openat(fd
, path
, openMode
, permissions
);
257 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
258 fcntl(int fd
, int op
, ...)
260 HIDDEN_FUNCTION(fcntl
);
264 int argument
= va_arg(args
, int);
267 return _haiku_build_fcntl(fd
, op
, argument
);
271 extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
272 renameat(int fromFD
, const char* from
, int toFD
, const char* to
)
274 HIDDEN_FUNCTION(renameat
);
276 return _haiku_build_renameat(fromFD
, from
, toFD
, to
);