summaryrefslogtreecommitdiff
path: root/lib/mktime.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-09-13 17:59:53 +0000
committerJim Meyering <jim@meyering.net>2003-09-13 17:59:53 +0000
commita05e8213a3eb94a06c0429d922eb67ed91365996 (patch)
tree99091aedb849622f1347047d79e2ddfe31aa23e3 /lib/mktime.c
parentf4bf3aa571773509b0b2443e6536d6c71660e935 (diff)
downloadcoreutils-a05e8213a3eb94a06c0429d922eb67ed91365996.tar.xz
(my_mktime_localtime_r): Remove; all uses changed to __localtime_r.
(__localtime_r) [!defined _LIBC]: New macro. Include <time_r.h>. (__mktime_internal) [!defined _LIBC]: Now extern, not static.
Diffstat (limited to 'lib/mktime.c')
-rw-r--r--lib/mktime.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/lib/mktime.c b/lib/mktime.c
index 00b834b05..3dab58ad8 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -100,22 +100,15 @@ const unsigned short int __mon_yday[2][13] =
};
-#ifdef _LIBC
-# define my_mktime_localtime_r __localtime_r
-#else
-/* If we're a mktime substitute in a GNU program, then prefer
- localtime to localtime_r, since many localtime_r implementations
- are buggy. */
-static struct tm *
-my_mktime_localtime_r (const time_t *t, struct tm *tp)
-{
- struct tm *l = localtime (t);
- if (! l)
- return 0;
- *tp = *l;
- return tp;
-}
-#endif /* ! _LIBC */
+#ifndef _LIBC
+/* 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.
+ See the gnulib time_r module for one way to implement this. */
+# include "time_r.h"
+# undef __localtime_r
+# define __localtime_r localtime_r
+#endif
/* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) -
(YEAR0-YDAY0 HOUR0:MIN0:SEC0) in seconds, assuming that the clocks
@@ -238,9 +231,6 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *),
Use *OFFSET to keep track of a guess at the offset of the result,
compared to what the result would be for UTC without leap seconds.
If *OFFSET's guess is correct, only one CONVERT call is needed. */
-#ifndef _LIBC
-static
-#endif
time_t
__mktime_internal (struct tm *tp,
struct tm *(*convert) (const time_t *, struct tm *),
@@ -480,7 +470,7 @@ mktime (struct tm *tp)
__tzset ();
#endif
- return __mktime_internal (tp, my_mktime_localtime_r, &localtime_offset);
+ return __mktime_internal (tp, __localtime_r, &localtime_offset);
}
#ifdef weak_alias