Back to index

glibc  2.9
timer_settime.c
Go to the documentation of this file.
00001 /* Copyright (C) 2003 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public License as
00007    published by the Free Software Foundation; either version 2.1 of the
00008    License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; see the file COPYING.LIB.  If not,
00017    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.  */
00019 
00020 #include <errno.h>
00021 #include <stdlib.h>
00022 #include <time.h>
00023 #include <sysdep.h>
00024 #include <kernel-features.h>
00025 #include "kernel-posix-timers.h"
00026 
00027 
00028 #ifdef __NR_timer_settime
00029 # ifndef __ASSUME_POSIX_TIMERS
00030 static int compat_timer_settime (timer_t timerid, int flags,
00031                              const struct itimerspec *value,
00032                              struct itimerspec *ovalue);
00033 #  define timer_settime static compat_timer_settime
00034 #  include <nptl/sysdeps/pthread/timer_settime.c>
00035 #  undef timer_settime
00036 # endif
00037 
00038 # ifdef timer_settime_alias
00039 #  define timer_settime timer_settime_alias
00040 # endif
00041 
00042 
00043 int
00044 timer_settime (timerid, flags, value, ovalue)
00045      timer_t timerid;
00046      int flags;
00047      const struct itimerspec *value;
00048      struct itimerspec *ovalue;
00049 {
00050 # undef timer_settime
00051 # ifndef __ASSUME_POSIX_TIMERS
00052   if (__no_posix_timers >= 0)
00053 # endif
00054     {
00055       struct timer *kt = (struct timer *) timerid;
00056 
00057       /* Delete the kernel timer object.  */
00058       int res = INLINE_SYSCALL (timer_settime, 4, kt->ktimerid, flags,
00059                             value, ovalue);
00060 
00061 # ifndef __ASSUME_POSIX_TIMERS
00062       if (res != -1 || errno != ENOSYS)
00063        {
00064          /* We know the syscall support is available.  */
00065          __no_posix_timers = 1;
00066 # endif
00067          return res;
00068 # ifndef __ASSUME_POSIX_TIMERS
00069        }
00070 # endif
00071 
00072 # ifndef __ASSUME_POSIX_TIMERS
00073       __no_posix_timers = -1;
00074 # endif
00075     }
00076 
00077 # ifndef __ASSUME_POSIX_TIMERS
00078   return compat_timer_settime (timerid, flags, value, ovalue);
00079 # endif
00080 }
00081 #else
00082 # ifdef timer_settime_alias
00083 #  define timer_settime timer_settime_alias
00084 # endif
00085 /* The new system calls are not available.  Use the userlevel
00086    implementation.  */
00087 # include <nptl/sysdeps/pthread/timer_settime.c>
00088 #endif