Skip to content

Commit

Permalink
linux: make write syscall available
Browse files Browse the repository at this point in the history
The jemalloc memory allocator likes to bypass the libc when calling write, so
it calls the syscall directly. Let's make write available through this interface
as well.

Signed-off-by: Glauber Costa <[email protected]>
Reviewed-by: Nadav Har'El <[email protected]>
  • Loading branch information
Glauber Costa committed Apr 9, 2014
1 parent 734ab68 commit bb4e1ca
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ int futex(int *uaddr, int op, int val, const struct timespec *timeout,
long syscall(long number, ...)
{
switch (number) {
case __NR_write: {
va_list args;
int arg1;
const void *arg2;
size_t arg3;
va_start(args, number);
arg1 = va_arg(args, typeof(arg1));
arg2 = va_arg(args, typeof(arg2));
arg3 = va_arg(args, typeof(arg3));
va_end(args);

return write(arg1, arg2, arg3);
}
case __NR_gettid: return gettid();
case __NR_clock_gettime: {
va_list args;
Expand Down

0 comments on commit bb4e1ca

Please sign in to comment.