Skip to content
Snippets Groups Projects
linux.cc 1.17 KiB
Newer Older
  • Learn to ignore specific revisions
  • /*
     * Copyright (C) 2013 Cloudius Systems, Ltd.
     *
     * This work is open source software, licensed under the terms of the
     * BSD license as described in the LICENSE file in the top-level directory.
     */
    
    
    #include <osv/debug.hh>
    
    #include <boost/format.hpp>
    
    #include <osv/sched.hh>
    
    #include <syscall.h>
    
    #include <stdarg.h>
    #include <time.h>
    
    long gettid()
    {
    
    Avi Kivity's avatar
    Avi Kivity committed
        return sched::thread::current()->id();
    
    long syscall(long number, ...)
    {
    
        switch (number) {
        case __NR_gettid: return gettid();
    
        case __NR_clock_gettime: {
            va_list args;
            clockid_t arg1;
            struct timespec *arg2;
            va_start(args, number);
            arg1 = va_arg(args, typeof(arg1));
            arg2 = va_arg(args, typeof(arg2));
            va_end(args);
            return clock_gettime(arg1, arg2);
            }
    
        case __NR_clock_getres: {
            va_list args;
            clockid_t arg1;
            struct timespec *arg2;
            va_start(args, number);
            arg1 = va_arg(args, typeof(arg1));
            arg2 = va_arg(args, typeof(arg2));
            va_end(args);
            return clock_getres(arg1, arg2);
            }
    
        abort("syscall(): unimplemented system call %d. Aborting.\n", number);