1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-07 06:43:00 +03:00

* time/mktime.c: (my_mktime_localtime_r):

Remove.  All uses changed to __localtime_r.
	(__localtime_r) [!defined _LIBC]: New macro.  Include "time_r.h" to
	get its implementation.
	Fix compile-command to allow for TIME_R_POSIX.

	* time/strftime.c (my_strftime_gmtime_r, my_strftime_localtime_r):
	Remove.  All uses changed to __localtime_r and __gmtime_r.
	(__gmtime_r, __localtime_r) [!HAVE_TM_GMTOFF]: New macros.
	Include "time_r.h" to get their implementations.

	* time/timegm.c: Allow use in GNU applications outside glibc.
	[defined HAVE_CONFIG_H]: Include <config.h>.
	[!defined _LIBC]: Include "timegm.h", <time_r.h>.
	Define __gmtime_r, and declare __mktime_internal.
	(timegm): Define via a prototype, since we can safely assume C89 now.
This commit is contained in:
Roland McGrath
2003-12-31 23:58:57 +00:00
parent a4e2a16911
commit 7683e14078
4 changed files with 67 additions and 62 deletions

View File

@@ -167,44 +167,22 @@ extern char *tzname[];
#ifdef _LIBC
# define my_strftime_gmtime_r __gmtime_r
# define my_strftime_localtime_r __localtime_r
# define tzname __tzname
# define tzset __tzset
#else
#endif
/* If we're a strftime substitute in a GNU program, then prefer gmtime
to gmtime_r, since many gmtime_r implementations are buggy.
Similarly for localtime_r. */
# if ! HAVE_TM_GMTOFF
static struct tm *my_strftime_gmtime_r __P ((const time_t *, struct tm *));
static struct tm *
my_strftime_gmtime_r (t, tp)
const time_t *t;
struct tm *tp;
{
struct tm *l = gmtime (t);
if (! l)
return 0;
*tp = *l;
return tp;
}
# endif /* ! HAVE_TM_GMTOFF */
static struct tm *my_strftime_localtime_r __P ((const time_t *, struct tm *));
static struct tm *
my_strftime_localtime_r (t, tp)
const time_t *t;
struct tm *tp;
{
struct tm *l = localtime (t);
if (! l)
return 0;
*tp = *l;
return tp;
}
#endif /* ! defined _LIBC */
#if !HAVE_TM_GMTOFF
/* Portable standalone applications should supply a "time_r.h" that
declares a POSIX-compliant localtime_r, for the benefit of older
implementations that lack localtime_r or have a nonstandard one.
Similarly for gmtime_r. See the gnulib time_r module for one way
to implement this. */
# include "time_r.h"
# undef __gmtime_r
# undef __localtime_r
# define __gmtime_r gmtime_r
# define __localtime_r localtime_r
#endif
#if !defined memset && !defined HAVE_MEMSET && !defined _LIBC
@@ -1388,7 +1366,7 @@ my_strftime (s, maxsize, format, tp ut_argument LOCALE_PARAM)
occurred. */
struct tm tm;
if (! my_strftime_localtime_r (&lt, &tm)
if (! __localtime_r (&lt, &tm)
|| ((ltm.tm_sec ^ tm.tm_sec)
| (ltm.tm_min ^ tm.tm_min)
| (ltm.tm_hour ^ tm.tm_hour)
@@ -1398,7 +1376,7 @@ my_strftime (s, maxsize, format, tp ut_argument LOCALE_PARAM)
break;
}
if (! my_strftime_gmtime_r (&lt, &gtm))
if (! __gmtime_r (&lt, &gtm))
break;
diff = tm_diff (&ltm, &gtm);