linux/arch/x86/um/vdso/um_vdso.c
<<
>>
Prefs
   1/*
   2 * Copyright (C) 2011 Richard Weinberger <richrd@nod.at>
   3 *
   4 * This program is free software; you can redistribute it and/or modify
   5 * it under the terms of the GNU General Public License version 2 as
   6 * published by the Free Software Foundation.
   7 *
   8 * This vDSO turns all calls into a syscall so that UML can trap them.
   9 */
  10
  11
  12/* Disable profiling for userspace code */
  13#define DISABLE_BRANCH_PROFILING
  14
  15#include <linux/time.h>
  16#include <linux/getcpu.h>
  17#include <asm/unistd.h>
  18
  19int __vdso_clock_gettime(clockid_t clock, struct timespec *ts)
  20{
  21        long ret;
  22
  23        asm("syscall" : "=a" (ret) :
  24                "0" (__NR_clock_gettime), "D" (clock), "S" (ts) : "memory");
  25
  26        return ret;
  27}
  28int clock_gettime(clockid_t, struct timespec *)
  29        __attribute__((weak, alias("__vdso_clock_gettime")));
  30
  31int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
  32{
  33        long ret;
  34
  35        asm("syscall" : "=a" (ret) :
  36                "0" (__NR_gettimeofday), "D" (tv), "S" (tz) : "memory");
  37
  38        return ret;
  39}
  40int gettimeofday(struct timeval *, struct timezone *)
  41        __attribute__((weak, alias("__vdso_gettimeofday")));
  42
  43time_t __vdso_time(time_t *t)
  44{
  45        long secs;
  46
  47        asm volatile("syscall"
  48                : "=a" (secs)
  49                : "0" (__NR_time), "D" (t) : "cc", "r11", "cx", "memory");
  50
  51        return secs;
  52}
  53int time(time_t *t) __attribute__((weak, alias("__vdso_time")));
  54
  55long
  56__vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
  57{
  58        /*
  59         * UML does not support SMP, we can cheat here. :)
  60         */
  61
  62        if (cpu)
  63                *cpu = 0;
  64        if (node)
  65                *node = 0;
  66
  67        return 0;
  68}
  69
  70long getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
  71        __attribute__((weak, alias("__vdso_getcpu")));
  72