mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-22 10:50:07 +00:00
Mon Sep 18 12:39:22 1995 Paul Eggert <eggert@twinsun.com>
* mktime.c (localtime_r): Add substitute if the system doesn't provide one. Mon Sep 18 14:39:20 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> * time/gmtime.c (gmtime_r): Define as weak alias. * time/localtime.c (localtime_r): Define as weak alias. * time/time.h [__USE_REENTRANT] (gmtime_r, localtime_r): Declare them. * errno.h: Only define _ERRNO_H #ifndef __need_Emath. #undef __need_Emath after including errnos.h. [_ERRNO_H]: Protect decls with this. Sun Sep 17 08:22:12 1995 Paul Eggert <eggert@twinsun.com> Fix mktime so that it does not write over localtime's returned value. * localtime.c (__localtime_r): New function, with extra arg specifying where to store result. (localtime): Use it. (_tmbuf): New var. * gmtime.c (__gmtime_r, gmtime, _tmbuf): Likewise. * mktime.c (__mktime_internal): Conversion function is now __localtime_r style, not localtime style. (mktime): Pass __localtime_r, not localtime. * timegm.c (timegm): Pass __gmtime_r, not gmtime. * offtime.c (__offtime): New arg specifying where to store result. * time.h (__mktime_internal, __offtime): Adjust decls accordingly. (__gmtime_r, __localtime_r): New decls. * time/localtime.c: <stddef.h>, <ctype.h>, <stdio.h>, <stdlib.h>, <string.h>: Remove includes. <errno.h>: Add include. * time/mktime.c, time/time.h, time/timegm.c (__mktime_internal): Renamed from _mktime_internal to avoid namespace pollution. * time/gmtime.c: Clear tm_isdst. * misc/efgcvt_r.c (ecvt_r, fcvt_r): Last arg is size_t, not int. * stdlib/stdlib.h (ecvt_r, fcvt_r): Fix type of last arg: make it size_t. * sysdeps/mach/hurd/fpathconf.c: Call __io_pathconf instead of __file_pathconf. * sysdeps/mach/hurd/pathconf.c: Likewise.
This commit is contained in:
parent
aa9109070f
commit
c22164805d
48
ChangeLog
48
ChangeLog
@ -1,5 +1,53 @@
|
|||||||
|
Mon Sep 18 12:39:22 1995 Paul Eggert <eggert@twinsun.com>
|
||||||
|
|
||||||
|
* mktime.c (localtime_r): Add substitute if the system doesn't
|
||||||
|
provide one.
|
||||||
|
|
||||||
|
Mon Sep 18 14:39:20 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
|
||||||
|
|
||||||
|
* time/gmtime.c (gmtime_r): Define as weak alias.
|
||||||
|
* time/localtime.c (localtime_r): Define as weak alias.
|
||||||
|
* time/time.h [__USE_REENTRANT] (gmtime_r, localtime_r): Declare them.
|
||||||
|
|
||||||
|
* errno.h: Only define _ERRNO_H #ifndef __need_Emath.
|
||||||
|
#undef __need_Emath after including errnos.h.
|
||||||
|
[_ERRNO_H]: Protect decls with this.
|
||||||
|
|
||||||
|
Sun Sep 17 08:22:12 1995 Paul Eggert <eggert@twinsun.com>
|
||||||
|
|
||||||
|
Fix mktime so that it does not write over localtime's returned value.
|
||||||
|
* localtime.c (__localtime_r): New function, with extra arg
|
||||||
|
specifying where to store result.
|
||||||
|
(localtime): Use it.
|
||||||
|
(_tmbuf): New var.
|
||||||
|
* gmtime.c (__gmtime_r, gmtime, _tmbuf): Likewise.
|
||||||
|
* mktime.c (__mktime_internal): Conversion function is now
|
||||||
|
__localtime_r style, not localtime style.
|
||||||
|
(mktime): Pass __localtime_r, not localtime.
|
||||||
|
* timegm.c (timegm): Pass __gmtime_r, not gmtime.
|
||||||
|
* offtime.c (__offtime): New arg specifying where to store result.
|
||||||
|
* time.h (__mktime_internal, __offtime): Adjust decls accordingly.
|
||||||
|
(__gmtime_r, __localtime_r): New decls.
|
||||||
|
|
||||||
|
* time/localtime.c: <stddef.h>, <ctype.h>, <stdio.h>,
|
||||||
|
<stdlib.h>, <string.h>: Remove includes.
|
||||||
|
<errno.h>: Add include.
|
||||||
|
|
||||||
|
* time/mktime.c, time/time.h, time/timegm.c (__mktime_internal):
|
||||||
|
Renamed from _mktime_internal to avoid namespace pollution.
|
||||||
|
|
||||||
|
* time/gmtime.c: Clear tm_isdst.
|
||||||
|
|
||||||
Mon Sep 18 01:58:40 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
|
Mon Sep 18 01:58:40 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
|
||||||
|
|
||||||
|
* misc/efgcvt_r.c (ecvt_r, fcvt_r): Last arg is size_t, not int.
|
||||||
|
* stdlib/stdlib.h (ecvt_r, fcvt_r): Fix type of last arg: make it
|
||||||
|
size_t.
|
||||||
|
|
||||||
|
* sysdeps/mach/hurd/fpathconf.c: Call __io_pathconf instead of
|
||||||
|
__file_pathconf.
|
||||||
|
* sysdeps/mach/hurd/pathconf.c: Likewise.
|
||||||
|
|
||||||
* Makefile (subdirs): Add sysvipc.
|
* Makefile (subdirs): Add sysvipc.
|
||||||
|
|
||||||
* stdlib/srand48_r.c (srand48_r): Use UL suffix for huge constant.
|
* stdlib/srand48_r.c (srand48_r): Use UL suffix for huge constant.
|
||||||
|
12
errno.h
12
errno.h
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -22,14 +22,21 @@ Cambridge, MA 02139, USA. */
|
|||||||
|
|
||||||
#ifndef _ERRNO_H
|
#ifndef _ERRNO_H
|
||||||
|
|
||||||
|
/* The includer defined __need_Emath if he wants only the definitions
|
||||||
|
of EDOM and ERANGE, and not everything else. */
|
||||||
|
#ifndef __need_Emath
|
||||||
#define _ERRNO_H 1
|
#define _ERRNO_H 1
|
||||||
#include <features.h>
|
#include <features.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
/* Get the error number constants. */
|
/* Get the error number constants from the system-specific file.
|
||||||
|
This file will test __need_Emath and _ERRNO_H. */
|
||||||
#include <errnos.h>
|
#include <errnos.h>
|
||||||
|
#undef __need_Emath
|
||||||
|
|
||||||
|
#ifdef _ERRNO_H
|
||||||
/* Declare the `errno' variable. */
|
/* Declare the `errno' variable. */
|
||||||
extern int errno;
|
extern int errno;
|
||||||
|
|
||||||
@ -41,5 +48,6 @@ extern char *program_invocation_name, *program_invocation_short_name;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* errno.h */
|
#endif /* errno.h */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
|
/* Copyright (C) 1991, 1992, 1993, 1995 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
@ -29,7 +29,7 @@ fcvt_r (value, ndigit, decpt, sign, buf, len)
|
|||||||
double value;
|
double value;
|
||||||
int ndigit, *decpt, *sign;
|
int ndigit, *decpt, *sign;
|
||||||
char *buf;
|
char *buf;
|
||||||
int len;
|
size_t len;
|
||||||
{
|
{
|
||||||
int n, i;
|
int n, i;
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ ecvt_r (value, ndigit, decpt, sign, buf, len)
|
|||||||
double value;
|
double value;
|
||||||
int ndigit, *decpt, *sign;
|
int ndigit, *decpt, *sign;
|
||||||
char *buf;
|
char *buf;
|
||||||
int len;
|
size_t len;
|
||||||
{
|
{
|
||||||
ndigit -= (int) floor (log10 (value));
|
ndigit -= (int) floor (log10 (value));
|
||||||
if (ndigit < 0)
|
if (ndigit < 0)
|
||||||
|
@ -409,9 +409,9 @@ char *gcvt __P ((double __value, int __ndigit, char *__buf));
|
|||||||
/* Reentrant version of the functions above which provide their own
|
/* Reentrant version of the functions above which provide their own
|
||||||
buffers. */
|
buffers. */
|
||||||
int ecvt_r __P ((double __value, int __ndigit, int *__decpt, int *sign,
|
int ecvt_r __P ((double __value, int __ndigit, int *__decpt, int *sign,
|
||||||
char *__buf, int *__len));
|
char *__buf, size_t __len));
|
||||||
int fcvt_r __P ((double __value, int __ndigit, int *__decpt, int *sign,
|
int fcvt_r __P ((double __value, int __ndigit, int *__decpt, int *sign,
|
||||||
char *__buf, int *__len));
|
char *__buf, size_t __len));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ __fpathconf (int fd, int name)
|
|||||||
error_t err;
|
error_t err;
|
||||||
long int value;
|
long int value;
|
||||||
|
|
||||||
if (err = HURD_DPORT_USE (fd, __file_pathconf (port, name, &value)))
|
if (err = HURD_DPORT_USE (fd, __io_pathconf (port, name, &value)))
|
||||||
return __hurd_dfail (fd, err), -1L;
|
return __hurd_dfail (fd, err), -1L;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
@ -31,7 +31,7 @@ __pathconf (const char *file, int name)
|
|||||||
file_t port = __file_name_lookup (file, 0, 0);
|
file_t port = __file_name_lookup (file, 0, 0);
|
||||||
if (port == MACH_PORT_NULL)
|
if (port == MACH_PORT_NULL)
|
||||||
return -1L;
|
return -1L;
|
||||||
err = __file_pathconf (port, name, &value);
|
err = __io_pathconf (port, name, &value);
|
||||||
__mach_port_deallocate (__mach_task_self (), port);
|
__mach_port_deallocate (__mach_task_self (), port);
|
||||||
if (err)
|
if (err)
|
||||||
return __hurd_fail (err), -1L;
|
return __hurd_fail (err), -1L;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991, 1993 Free Software Foundation, Inc.
|
/* Copyright (C) 1991, 1993, 1995 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -20,14 +20,28 @@ Cambridge, MA 02139, USA. */
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
/* Defined in localtime.c. */
|
||||||
|
extern struct tm _tmbuf;
|
||||||
|
|
||||||
/* Return the `struct tm' representation of *T in UTC. */
|
/* Return the `struct tm' representation of *T in UTC. */
|
||||||
struct tm *
|
struct tm *
|
||||||
DEFUN(gmtime, (t), CONST time_t *t)
|
DEFUN(gmtime, (t), CONST time_t *t)
|
||||||
{
|
{
|
||||||
struct tm *tp = __offtime (t, 0L);
|
return __gmtime_r (t, &_tmbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the `struct tm' representation of *T in UTC,
|
||||||
|
using *TP to store the result. */
|
||||||
|
struct tm *
|
||||||
|
DEFUN(__gmtime_r, (t, tp),
|
||||||
|
CONST time_t *t AND struct tm *tp)
|
||||||
|
{
|
||||||
|
__offtime (t, 0L, tp);
|
||||||
|
|
||||||
|
tp->tm_isdst = 0;
|
||||||
tp->tm_gmtoff = 0L;
|
tp->tm_gmtoff = 0L;
|
||||||
tp->tm_zone = "GMT";
|
tp->tm_zone = "GMT";
|
||||||
|
|
||||||
return tp;
|
return tp;
|
||||||
}
|
}
|
||||||
|
weak_alias (__gmtime_r, gmtime_r)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
|
/* Copyright (C) 1991, 1992, 1993, 1995 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -16,24 +16,29 @@ License along with the GNU C Library; see the file COPYING.LIB. If
|
|||||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
Cambridge, MA 02139, USA. */
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
/* The C Standard says that localtime and gmtime return the same pointer. */
|
||||||
|
struct tm _tmbuf;
|
||||||
|
|
||||||
/* Return the `struct tm' representation of *TIMER in the local timezone. */
|
/* Return the `struct tm' representation of *TIMER in the local timezone. */
|
||||||
struct tm *
|
struct tm *
|
||||||
localtime (timer)
|
localtime (timer)
|
||||||
const time_t *timer;
|
const time_t *timer;
|
||||||
|
{
|
||||||
|
return __localtime_r (timer, &_tmbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tm *
|
||||||
|
__localtime_r (timer, tp)
|
||||||
|
const time_t *timer;
|
||||||
|
struct tm *tp;
|
||||||
{
|
{
|
||||||
extern int __use_tzfile;
|
extern int __use_tzfile;
|
||||||
extern int __tz_compute __P ((time_t timer, struct tm *tp));
|
extern int __tz_compute __P ((time_t timer, struct tm *tp));
|
||||||
extern int __tzfile_compute __P ((time_t timer,
|
extern int __tzfile_compute __P ((time_t timer,
|
||||||
long int *leap_correct, int *leap_hit));
|
long int *leap_correct, int *leap_hit));
|
||||||
register struct tm *tp;
|
|
||||||
long int leap_correction;
|
long int leap_correction;
|
||||||
int leap_extra_secs;
|
int leap_extra_secs;
|
||||||
|
|
||||||
@ -57,21 +62,22 @@ localtime (timer)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tp = gmtime (timer);
|
struct tm *gmtp = __gmtime_r (timer, tp);
|
||||||
if (tp == NULL)
|
if (gmtp == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (! __tz_compute (*timer, tp))
|
if (! __tz_compute (*timer, gmtp))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
leap_correction = 0L;
|
leap_correction = 0L;
|
||||||
leap_extra_secs = 0;
|
leap_extra_secs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tp = __offtime (timer, __timezone - leap_correction);
|
__offtime (timer, __timezone - leap_correction, tp);
|
||||||
tp->tm_sec += leap_extra_secs;
|
tp->tm_sec += leap_extra_secs;
|
||||||
tp->tm_isdst = __daylight;
|
tp->tm_isdst = __daylight;
|
||||||
tp->tm_gmtoff = __timezone;
|
tp->tm_gmtoff = __timezone;
|
||||||
tp->tm_zone = __tzname[__daylight];
|
tp->tm_zone = __tzname[__daylight];
|
||||||
return tp;
|
return tp;
|
||||||
}
|
}
|
||||||
|
weak_alias (__localtime_r, localtime_r)
|
||||||
|
@ -217,9 +217,9 @@ do_normalization (tmptr)
|
|||||||
#define BAD_STRUCT_TM ((time_t) -1)
|
#define BAD_STRUCT_TM ((time_t) -1)
|
||||||
|
|
||||||
time_t
|
time_t
|
||||||
_mktime_internal (timeptr, producer)
|
__mktime_internal (timeptr, producer)
|
||||||
struct tm *timeptr;
|
struct tm *timeptr;
|
||||||
struct tm *(*producer) __P ((const time_t *));
|
struct tm *(*producer) __P ((const time_t *, struct tm *));
|
||||||
{
|
{
|
||||||
struct tm our_tm; /* our working space */
|
struct tm our_tm; /* our working space */
|
||||||
struct tm *me = &our_tm; /* a pointer to the above */
|
struct tm *me = &our_tm; /* a pointer to the above */
|
||||||
@ -276,6 +276,7 @@ _mktime_internal (timeptr, producer)
|
|||||||
|
|
||||||
{
|
{
|
||||||
struct tm *guess_tm;
|
struct tm *guess_tm;
|
||||||
|
struct tm guess_struct;
|
||||||
time_t guess = 0;
|
time_t guess = 0;
|
||||||
time_t distance = 0;
|
time_t distance = 0;
|
||||||
time_t last_distance = 0;
|
time_t last_distance = 0;
|
||||||
@ -288,7 +289,7 @@ _mktime_internal (timeptr, producer)
|
|||||||
|
|
||||||
times_through_search++;
|
times_through_search++;
|
||||||
|
|
||||||
guess_tm = (*producer) (&guess);
|
guess_tm = (*producer) (&guess, &guess_struct);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debugging_enabled)
|
if (debugging_enabled)
|
||||||
@ -399,6 +400,26 @@ _mktime_internal (timeptr, producer)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ! HAVE_LOCALTIME_R && ! defined (localtime_r)
|
||||||
|
#ifdef _LIBC
|
||||||
|
#define localtime_r __localtime_r
|
||||||
|
#else
|
||||||
|
/* Approximate localtime_r as best we can in its absence. */
|
||||||
|
#define localtime_r my_localtime_r /* Avoid clash with system localtime_r. */
|
||||||
|
static struct tm *
|
||||||
|
localtime_r (t, tp)
|
||||||
|
const time_t *t;
|
||||||
|
struct tm *tp;
|
||||||
|
{
|
||||||
|
struct tm *l = localtime (t);
|
||||||
|
if (! l)
|
||||||
|
return NULL;
|
||||||
|
*tp = *l;
|
||||||
|
return tp;
|
||||||
|
}
|
||||||
|
#endif /* ! _LIBC */
|
||||||
|
#endif /* ! HAVE_LOCALTIME_R && ! defined (localtime_r) */
|
||||||
|
|
||||||
time_t
|
time_t
|
||||||
#ifdef DEBUG /* make it work even if the system's
|
#ifdef DEBUG /* make it work even if the system's
|
||||||
libc has it's own mktime routine */
|
libc has it's own mktime routine */
|
||||||
@ -408,7 +429,7 @@ mktime (timeptr)
|
|||||||
#endif
|
#endif
|
||||||
struct tm *timeptr;
|
struct tm *timeptr;
|
||||||
{
|
{
|
||||||
return _mktime_internal (timeptr, localtime);
|
return __mktime_internal (timeptr, localtime_r);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef weak_alias
|
#ifdef weak_alias
|
||||||
|
@ -26,19 +26,17 @@ extern CONST unsigned short int __mon_lengths[2][12];
|
|||||||
#define SECS_PER_HOUR (60 * 60)
|
#define SECS_PER_HOUR (60 * 60)
|
||||||
#define SECS_PER_DAY (SECS_PER_HOUR * 24)
|
#define SECS_PER_DAY (SECS_PER_HOUR * 24)
|
||||||
|
|
||||||
/* Returns the `struct tm' representation of *T,
|
/* Compute the `struct tm' representation of *T,
|
||||||
offset OFFSET seconds east of UCT. */
|
offset OFFSET seconds east of UTC,
|
||||||
struct tm *
|
and store year, yday, mon, mday, wday, hour, min, sec into *TP. */
|
||||||
DEFUN(__offtime, (t, offset), CONST time_t *t AND long int offset)
|
void
|
||||||
|
DEFUN(__offtime, (t, offset, tp),
|
||||||
|
CONST time_t *t AND long int offset AND struct tm *tp)
|
||||||
{
|
{
|
||||||
static struct tm tbuf;
|
|
||||||
register long int days, rem;
|
register long int days, rem;
|
||||||
register int y;
|
register int y;
|
||||||
register CONST unsigned short int *ip;
|
register CONST unsigned short int *ip;
|
||||||
|
|
||||||
if (t == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
days = *t / SECS_PER_DAY;
|
days = *t / SECS_PER_DAY;
|
||||||
rem = *t % SECS_PER_DAY;
|
rem = *t % SECS_PER_DAY;
|
||||||
rem += offset;
|
rem += offset;
|
||||||
@ -52,14 +50,14 @@ DEFUN(__offtime, (t, offset), CONST time_t *t AND long int offset)
|
|||||||
rem -= SECS_PER_DAY;
|
rem -= SECS_PER_DAY;
|
||||||
++days;
|
++days;
|
||||||
}
|
}
|
||||||
tbuf.tm_hour = rem / SECS_PER_HOUR;
|
tp->tm_hour = rem / SECS_PER_HOUR;
|
||||||
rem %= SECS_PER_HOUR;
|
rem %= SECS_PER_HOUR;
|
||||||
tbuf.tm_min = rem / 60;
|
tp->tm_min = rem / 60;
|
||||||
tbuf.tm_sec = rem % 60;
|
tp->tm_sec = rem % 60;
|
||||||
/* January 1, 1970 was a Thursday. */
|
/* January 1, 1970 was a Thursday. */
|
||||||
tbuf.tm_wday = (4 + days) % 7;
|
tp->tm_wday = (4 + days) % 7;
|
||||||
if (tbuf.tm_wday < 0)
|
if (tp->tm_wday < 0)
|
||||||
tbuf.tm_wday += 7;
|
tp->tm_wday += 7;
|
||||||
y = 1970;
|
y = 1970;
|
||||||
while (days >= (rem = __isleap(y) ? 366 : 365))
|
while (days >= (rem = __isleap(y) ? 366 : 365))
|
||||||
{
|
{
|
||||||
@ -71,14 +69,12 @@ DEFUN(__offtime, (t, offset), CONST time_t *t AND long int offset)
|
|||||||
--y;
|
--y;
|
||||||
days += __isleap(y) ? 366 : 365;
|
days += __isleap(y) ? 366 : 365;
|
||||||
}
|
}
|
||||||
tbuf.tm_year = y - 1900;
|
tp->tm_year = y - 1900;
|
||||||
tbuf.tm_yday = days;
|
tp->tm_yday = days;
|
||||||
ip = __mon_lengths[__isleap(y)];
|
ip = __mon_lengths[__isleap(y)];
|
||||||
for (y = 0; days >= ip[y]; ++y)
|
for (y = 0; days >= ip[y]; ++y)
|
||||||
days -= ip[y];
|
days -= ip[y];
|
||||||
tbuf.tm_mon = y;
|
tp->tm_mon = y;
|
||||||
tbuf.tm_mday = days + 1;
|
tp->tm_mday = days + 1;
|
||||||
tbuf.tm_isdst = -1;
|
tp->tm_isdst = -1;
|
||||||
|
|
||||||
return &tbuf;
|
|
||||||
}
|
}
|
||||||
|
31
time/time.h
31
time/time.h
@ -111,8 +111,9 @@ extern time_t mktime __P ((struct tm *__tp));
|
|||||||
/* Subroutine of `mktime'. Return the `time_t' representation of TP and
|
/* Subroutine of `mktime'. Return the `time_t' representation of TP and
|
||||||
normalize TP, given that a `struct tm *' maps to a `time_t' as performed
|
normalize TP, given that a `struct tm *' maps to a `time_t' as performed
|
||||||
by FUNC. */
|
by FUNC. */
|
||||||
extern time_t _mktime_internal __P ((struct tm *__tp,
|
extern time_t __mktime_internal __P ((struct tm *__tp,
|
||||||
struct tm *(*__func) (const time_t *)));
|
struct tm *(*__func) (const time_t *,
|
||||||
|
struct tm *)));
|
||||||
|
|
||||||
|
|
||||||
/* Format TP into S according to FORMAT.
|
/* Format TP into S according to FORMAT.
|
||||||
@ -130,10 +131,28 @@ extern struct tm *gmtime __P ((__const time_t *__timer));
|
|||||||
of *TIMER in the local timezone. */
|
of *TIMER in the local timezone. */
|
||||||
extern struct tm *localtime __P ((__const time_t *__timer));
|
extern struct tm *localtime __P ((__const time_t *__timer));
|
||||||
|
|
||||||
/* Return the `struct tm' representation of *TIMER,
|
#ifdef __USE_REENTRANT
|
||||||
offset OFFSET seconds east of Universal Coordinated Time. */
|
/* Return the `struct tm' representation of *TIMER in UTC,
|
||||||
extern struct tm *__offtime __P ((__const time_t *__timer,
|
using *TP to store the result. */
|
||||||
long int __offset));
|
extern struct tm *__gmtime_r __P ((__const time_t *__timer,
|
||||||
|
struct tm *__tp));
|
||||||
|
extern struct tm *gmtime_r __P ((__const time_t *__timer,
|
||||||
|
struct tm *__tp));
|
||||||
|
|
||||||
|
/* Return the `struct tm' representation of *TIMER in local time,
|
||||||
|
using *TP to store the result. */
|
||||||
|
extern struct tm *__localtime_r __P ((__const time_t *__timer,
|
||||||
|
struct tm *__tp));
|
||||||
|
extern struct tm *localtime_r __P ((__const time_t *__timer,
|
||||||
|
struct tm *__tp));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Compute the `struct tm' representation of *T,
|
||||||
|
offset OFFSET seconds east of UTC,
|
||||||
|
and store year, yday, mon, mday, wday, hour, min, sec into *TP. */
|
||||||
|
extern void __offtime __P ((__const time_t *__timer,
|
||||||
|
long int __offset,
|
||||||
|
struct tm *__TP));
|
||||||
|
|
||||||
/* Return a string of the form "Day Mon dd hh:mm:ss yyyy\n"
|
/* Return a string of the form "Day Mon dd hh:mm:ss yyyy\n"
|
||||||
that is the representation of TP in this format. */
|
that is the representation of TP in this format. */
|
||||||
|
@ -23,5 +23,5 @@ timegm (tmp)
|
|||||||
struct tm *const tmp;
|
struct tm *const tmp;
|
||||||
{
|
{
|
||||||
tmp->tm_isdst = 0;
|
tmp->tm_isdst = 0;
|
||||||
return _mktime_internal (tmp, gmtime);
|
return __mktime_internal (tmp, __gmtime_r);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user