1 /* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
3 The GNU C Library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Library General Public License as
5 published by the Free Software Foundation; either version 2 of the
6 License, or (at your option) any later version.
8 The GNU C Library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public
14 License along with the GNU C Library; see the file COPYING.LIB. If
15 not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. */
21 #include <sys/timex.h>
23 #define MAX_SEC (INT_MAX / 1000000L - 2)
24 #define MIN_SEC (INT_MIN / 1000000L + 2)
32 const struct timeval
*itv
;
41 /* We will do some check here. */
42 tmp
.tv_sec
= itv
->tv_sec
+ itv
->tv_usec
/ 1000000L;
43 tmp
.tv_usec
= itv
->tv_usec
% 1000000L;
44 if (tmp
.tv_sec
> MAX_SEC
|| tmp
.tv_sec
< MIN_SEC
)
49 tntx
.offset
= tmp
.tv_usec
+ tmp
.tv_sec
* 1000000L;
50 tntx
.modes
= ADJ_OFFSET_SINGLESHOT
;
55 if (__adjtimex (&tntx
) < 0) return -1;
61 otv
->tv_usec
= -(-tntx
.offset
% 1000000);
62 otv
->tv_sec
= -(-tntx
.offset
/ 1000000);
66 otv
->tv_usec
= tntx
.offset
% 1000000;
67 otv
->tv_sec
= tntx
.offset
/ 1000000;
73 weak_alias (__adjtime
, adjtime
)