From 83fe108b0a9bc4f2deb14695bb0c8b2011e79f28 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 30 Mar 2011 22:00:57 -0400 Subject: [PATCH] Add clock_adjtime syscall. --- ChangeLog | 8 + NEWS | 4 +- sysdeps/unix/sysv/linux/bits/time.h | 93 +++++++++++ sysdeps/unix/sysv/linux/{sys => bits}/timex.h | 54 +----- sysdeps/unix/sysv/linux/sys/timex.h | 226 ++++++++------------------ sysdeps/unix/sysv/linux/syscalls.list | 1 + 6 files changed, 181 insertions(+), 205 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/bits/time.h copy sysdeps/unix/sysv/linux/{sys => bits}/timex.h (75%) rewrite sysdeps/unix/sysv/linux/sys/timex.h (61%) diff --git a/ChangeLog b/ChangeLog index 7c537958cd..612d2c03a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-03-30 Ulrich Drepper + + * sysdeps/unix/sysv/linux/syscalls.list: Add clock_adjtime. + * sysdeps/unix/sysv/linux/bits/time.h: New file. + * sysdeps/unix/sysv/linux/sys/timex.h: Move struct timex definition + to... + * sysdeps/unix/sysv/linux/bits/timex.h: ...here. New file. + 2011-03-22 Ulrich Drepper * sysdeps/unix/sysv/linux/i386/sysconf.c (intel_check_word): Increment diff --git a/NEWS b/NEWS index 4557b4578a..eba3e8b435 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -GNU C Library NEWS -- history of user-visible changes. 2011-3-21 +GNU C Library NEWS -- history of user-visible changes. 2011-3-30 Copyright (C) 1992-2009, 2010, 2011 Free Software Foundation, Inc. See the end for copying conditions. @@ -7,6 +7,8 @@ using `glibc' in the "product" field. Version 2.14 +* New Linux interfaces: clock_adjtime + * The following bugs are resolved with this release: 11724, 12445, 12454, 12460, 12469, 12489, 12509, 12510, 12583, 12587, 12597 diff --git a/sysdeps/unix/sysv/linux/bits/time.h b/sysdeps/unix/sysv/linux/bits/time.h new file mode 100644 index 0000000000..02a05114f2 --- /dev/null +++ b/sysdeps/unix/sysv/linux/bits/time.h @@ -0,0 +1,93 @@ +/* System-dependent timing definitions. Linux version. + Copyright (C) 1996,1997,1999-2003,2010,2011 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * Never include this file directly; use instead. + */ + +#if defined __need_timeval || defined __USE_GNU +# ifndef _STRUCT_TIMEVAL +# define _STRUCT_TIMEVAL 1 +# include + +/* A time value that is accurate to the nearest + microsecond but also has a range of years. */ +struct timeval + { + __time_t tv_sec; /* Seconds. */ + __suseconds_t tv_usec; /* Microseconds. */ + }; +# endif /* struct timeval */ +#endif + +#ifndef __need_timeval +# ifndef _BITS_TIME_H +# define _BITS_TIME_H 1 + +/* ISO/IEC 9899:1990 7.12.1: + The macro `CLOCKS_PER_SEC' is the number per second of the value + returned by the `clock' function. */ +/* CAE XSH, Issue 4, Version 2: + The value of CLOCKS_PER_SEC is required to be 1 million on all + XSI-conformant systems. */ +# define CLOCKS_PER_SEC 1000000l + +# if !defined __STRICT_ANSI__ && !defined __USE_XOPEN2K +/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK + presents the real value for clock ticks per second for the system. */ +# include +extern long int __sysconf (int); +# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */ +# endif + +# ifdef __USE_POSIX199309 +/* Identifier for system-wide realtime clock. */ +# define CLOCK_REALTIME 0 +/* Monotonic system-wide clock. */ +# define CLOCK_MONOTONIC 1 +/* High-resolution timer from the CPU. */ +# define CLOCK_PROCESS_CPUTIME_ID 2 +/* Thread-specific CPU-time clock. */ +# define CLOCK_THREAD_CPUTIME_ID 3 +/* Monotonic system-wide clock, not adjusted for frequency scaling. */ +# define CLOCK_MONOTONIC_RAW 4 +/* Identifier for system-wide realtime clock, updated only on ticks. */ +# define CLOCK_REALTIME_COARSE 5 +/* Monotonic system-wide clock, updated only on ticks. */ +# define CLOCK_MONOTONIC_COARSE 6 + +/* Flag to indicate time is absolute. */ +# define TIMER_ABSTIME 1 +# endif + +# ifdef __USE_GNU +# include + +__BEGIN_DECLS + +/* Tune a POSIX clock. */ +extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW; + +__END_DECLS +# endif /* use GNU */ + +# endif /* bits/time.h */ +#endif + +#undef __need_timeval diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/bits/timex.h similarity index 75% copy from sysdeps/unix/sysv/linux/sys/timex.h copy to sysdeps/unix/sysv/linux/bits/timex.h index 13b94d6f4f..67de67e1ca 100644 --- a/sysdeps/unix/sysv/linux/sys/timex.h +++ b/sysdeps/unix/sysv/linux/bits/timex.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-1997, 1999, 2007, 2009 Free Software Foundation, Inc. +/* Copyright (C) 1995-1997,1999,2007,2009,2011 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,29 +16,11 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef _SYS_TIMEX_H -#define _SYS_TIMEX_H 1 - -#include -#include +#ifndef _BITS_TIMEX_H +#define _BITS_TIMEX_H 1 /* These definitions from linux/timex.h as of 2.6.30. */ -#define NTP_API 4 /* NTP API version */ - -struct ntptimeval -{ - struct timeval time; /* current time (ro) */ - long int maxerror; /* maximum error (us) (ro) */ - long int esterror; /* estimated error (us) (ro) */ - long int tai; /* TAI offset (ro) */ - - long int __unused1; - long int __unused2; - long int __unused3; - long int __unused4; -}; - struct timex { unsigned int modes; /* mode selector */ @@ -123,32 +105,4 @@ struct timex #define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK) -/* Clock states (time_state) */ -#define TIME_OK 0 /* clock synchronized, no leap second */ -#define TIME_INS 1 /* insert leap second */ -#define TIME_DEL 2 /* delete leap second */ -#define TIME_OOP 3 /* leap second in progress */ -#define TIME_WAIT 4 /* leap second has occurred */ -#define TIME_ERROR 5 /* clock not synchronized */ -#define TIME_BAD TIME_ERROR /* bw compat */ - -/* Maximum time constant of the PLL. */ -#define MAXTC 6 - -__BEGIN_DECLS - -extern int __adjtimex (struct timex *__ntx) __THROW; -extern int adjtimex (struct timex *__ntx) __THROW; - -#ifdef __REDIRECT_NTH -extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv), - ntp_gettimex); -#else -extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW; -# define ntp_gettime ntp_gettimex -#endif -extern int ntp_adjtime (struct timex *__tntx) __THROW; - -__END_DECLS - -#endif /* sys/timex.h */ +#endif /* bits/timex.h */ diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/sys/timex.h dissimilarity index 61% index 13b94d6f4f..de61bb54df 100644 --- a/sysdeps/unix/sysv/linux/sys/timex.h +++ b/sysdeps/unix/sysv/linux/sys/timex.h @@ -1,154 +1,72 @@ -/* Copyright (C) 1995-1997, 1999, 2007, 2009 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _SYS_TIMEX_H -#define _SYS_TIMEX_H 1 - -#include -#include - -/* These definitions from linux/timex.h as of 2.6.30. */ - -#define NTP_API 4 /* NTP API version */ - -struct ntptimeval -{ - struct timeval time; /* current time (ro) */ - long int maxerror; /* maximum error (us) (ro) */ - long int esterror; /* estimated error (us) (ro) */ - long int tai; /* TAI offset (ro) */ - - long int __unused1; - long int __unused2; - long int __unused3; - long int __unused4; -}; - -struct timex -{ - unsigned int modes; /* mode selector */ - long int offset; /* time offset (usec) */ - long int freq; /* frequency offset (scaled ppm) */ - long int maxerror; /* maximum error (usec) */ - long int esterror; /* estimated error (usec) */ - int status; /* clock command/status */ - long int constant; /* pll time constant */ - long int precision; /* clock precision (usec) (read only) */ - long int tolerance; /* clock frequency tolerance (ppm) (read only) */ - struct timeval time; /* (read only) */ - long int tick; /* (modified) usecs between clock ticks */ - - long int ppsfreq; /* pps frequency (scaled ppm) (ro) */ - long int jitter; /* pps jitter (us) (ro) */ - int shift; /* interval duration (s) (shift) (ro) */ - long int stabil; /* pps stability (scaled ppm) (ro) */ - long int jitcnt; /* jitter limit exceeded (ro) */ - long int calcnt; /* calibration intervals (ro) */ - long int errcnt; /* calibration errors (ro) */ - long int stbcnt; /* stability limit exceeded (ro) */ - - int tai; /* TAI offset (ro) */ - - /* ??? */ - int :32; int :32; int :32; int :32; - int :32; int :32; int :32; int :32; - int :32; int :32; int :32; -}; - -/* Mode codes (timex.mode) */ -#define ADJ_OFFSET 0x0001 /* time offset */ -#define ADJ_FREQUENCY 0x0002 /* frequency offset */ -#define ADJ_MAXERROR 0x0004 /* maximum time error */ -#define ADJ_ESTERROR 0x0008 /* estimated time error */ -#define ADJ_STATUS 0x0010 /* clock status */ -#define ADJ_TIMECONST 0x0020 /* pll time constant */ -#define ADJ_TAI 0x0080 /* set TAI offset */ -#define ADJ_MICRO 0x1000 /* select microsecond resolution */ -#define ADJ_NANO 0x2000 /* select nanosecond resolution */ -#define ADJ_TICK 0x4000 /* tick value */ -#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ -#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */ - -/* xntp 3.4 compatibility names */ -#define MOD_OFFSET ADJ_OFFSET -#define MOD_FREQUENCY ADJ_FREQUENCY -#define MOD_MAXERROR ADJ_MAXERROR -#define MOD_ESTERROR ADJ_ESTERROR -#define MOD_STATUS ADJ_STATUS -#define MOD_TIMECONST ADJ_TIMECONST -#define MOD_CLKB ADJ_TICK -#define MOD_CLKA ADJ_OFFSET_SINGLESHOT /* 0x8000 in original */ -#define MOD_TAI ADJ_TAI -#define MOD_MICRO ADJ_MICRO -#define MOD_NANO ADJ_NANO - - -/* Status codes (timex.status) */ -#define STA_PLL 0x0001 /* enable PLL updates (rw) */ -#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */ -#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */ -#define STA_FLL 0x0008 /* select frequency-lock mode (rw) */ - -#define STA_INS 0x0010 /* insert leap (rw) */ -#define STA_DEL 0x0020 /* delete leap (rw) */ -#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */ -#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */ - -#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */ -#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */ -#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */ -#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ - -#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ -#define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */ -#define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */ -#define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */ - -/* Read-only bits */ -#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ - STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK) - -/* Clock states (time_state) */ -#define TIME_OK 0 /* clock synchronized, no leap second */ -#define TIME_INS 1 /* insert leap second */ -#define TIME_DEL 2 /* delete leap second */ -#define TIME_OOP 3 /* leap second in progress */ -#define TIME_WAIT 4 /* leap second has occurred */ -#define TIME_ERROR 5 /* clock not synchronized */ -#define TIME_BAD TIME_ERROR /* bw compat */ - -/* Maximum time constant of the PLL. */ -#define MAXTC 6 - -__BEGIN_DECLS - -extern int __adjtimex (struct timex *__ntx) __THROW; -extern int adjtimex (struct timex *__ntx) __THROW; - -#ifdef __REDIRECT_NTH -extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv), - ntp_gettimex); -#else -extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW; -# define ntp_gettime ntp_gettimex -#endif -extern int ntp_adjtime (struct timex *__tntx) __THROW; - -__END_DECLS - -#endif /* sys/timex.h */ +/* Copyright (C) 1995-1997,1999,2007,2009,2011 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_TIMEX_H +#define _SYS_TIMEX_H 1 + +#include +#include + +/* These definitions from linux/timex.h as of 2.6.30. */ + +#include + +#define NTP_API 4 /* NTP API version */ + +struct ntptimeval +{ + struct timeval time; /* current time (ro) */ + long int maxerror; /* maximum error (us) (ro) */ + long int esterror; /* estimated error (us) (ro) */ + long int tai; /* TAI offset (ro) */ + + long int __unused1; + long int __unused2; + long int __unused3; + long int __unused4; +}; + +/* Clock states (time_state) */ +#define TIME_OK 0 /* clock synchronized, no leap second */ +#define TIME_INS 1 /* insert leap second */ +#define TIME_DEL 2 /* delete leap second */ +#define TIME_OOP 3 /* leap second in progress */ +#define TIME_WAIT 4 /* leap second has occurred */ +#define TIME_ERROR 5 /* clock not synchronized */ +#define TIME_BAD TIME_ERROR /* bw compat */ + +/* Maximum time constant of the PLL. */ +#define MAXTC 6 + +__BEGIN_DECLS + +extern int __adjtimex (struct timex *__ntx) __THROW; +extern int adjtimex (struct timex *__ntx) __THROW; + +#ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv), + ntp_gettimex); +#else +extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW; +# define ntp_gettime ntp_gettimex +#endif +extern int ntp_adjtime (struct timex *__tntx) __THROW; + +__END_DECLS + +#endif /* sys/timex.h */ diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index 0f3345490c..03c784b492 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -4,6 +4,7 @@ adjtimex adjtime adjtimex i:p __adjtimex adjtimex ntp_adjtime __adjtimex_interna bdflush EXTRA bdflush i:ii bdflush capget EXTRA capget i:pp capget capset EXTRA capset i:pp capset +clock_adjtime EXTRA clock_adjtime i:ip clock_adjtime creat - creat Ci:si __libc_creat creat create_module EXTRA create_module 3 create_module delete_module EXTRA delete_module 3 delete_module -- 2.11.4.GIT