summaryrefslogtreecommitdiff
path: root/lib/libc/stdtime
diff options
context:
space:
mode:
authorcvs2svn <cvs2svn@FreeBSD.org>1999-01-21 00:55:32 +0000
committercvs2svn <cvs2svn@FreeBSD.org>1999-01-21 00:55:32 +0000
commit76b5366091f76c9bc73570149ef5055648fc2c39 (patch)
tree590d020e0f2a5bea6e09d66d951a674443b21d67 /lib/libc/stdtime
parent4b4d01da6f07f7754ff6a6e4f5223e9f0984d1a6 (diff)
Notes
Diffstat (limited to 'lib/libc/stdtime')
-rw-r--r--lib/libc/stdtime/asctime.c7
-rw-r--r--lib/libc/stdtime/ctime.3119
-rw-r--r--lib/libc/stdtime/localtime.c10
3 files changed, 35 insertions, 101 deletions
diff --git a/lib/libc/stdtime/asctime.c b/lib/libc/stdtime/asctime.c
index 832f18592ff3..b9da143029eb 100644
--- a/lib/libc/stdtime/asctime.c
+++ b/lib/libc/stdtime/asctime.c
@@ -14,6 +14,10 @@ static char elsieid[] = "@(#)asctime.c 7.7";
#include "private.h"
#include "tzfile.h"
+#ifndef _THREAD_SAFE
+static char *asctime_r __P((const struct tm *, char *));
+#endif
+
/*
** A la X3J11, with core dump avoidance.
*/
@@ -28,6 +32,9 @@ const struct tm * timeptr;
return(asctime_r(timeptr, result));
}
+#ifndef _THREAD_SAFE
+static
+#endif
char *
asctime_r(timeptr, result)
const struct tm * timeptr;
diff --git a/lib/libc/stdtime/ctime.3 b/lib/libc/stdtime/ctime.3
index 2b8ca3e45adc..b14a92c47bf9 100644
--- a/lib/libc/stdtime/ctime.3
+++ b/lib/libc/stdtime/ctime.3
@@ -31,22 +31,17 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)ctime.3 8.1 (Berkeley) 6/4/93
-.\" $Id$
+.\" @(#)ctime.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd January 2, 1999
+.Dd June 4, 1993
.Dt CTIME 3
.Os BSD 4.3
.Sh NAME
.Nm asctime ,
-.Nm asctime_r ,
.Nm ctime ,
-.Nm ctime_r ,
.Nm difftime ,
.Nm gmtime ,
-.Nm gmtime_r ,
.Nm localtime ,
-.Nm localtime_r ,
.Nm mktime ,
.Nm timegm
.Nd transform binary date and time values
@@ -67,14 +62,6 @@
.Fn mktime "struct tm *tm"
.Ft time_t
.Fn timegm "struct tm *tm"
-.Ft char *
-.Fn ctime_r "const time_t *clock" "char *buf"
-.Ft struct tm *
-.Fn localtime_r "const time_t *clock" "struct tm *result"
-.Ft struct tm *
-.Fn gmtime_r "const time_t *clock" "struct tm *result"
-.Ft char *
-.Fn asctime_r "const struct tm *tm" "char *buf"
.Sh DESCRIPTION
The functions
.Fn ctime ,
@@ -138,22 +125,6 @@ Thu Nov 24 18:22:48 1986\en\e0
.Pp
All the fields have constant width.
.Pp
-.Fn ctime_r
-provides the same functionality as
-.Fn ctime
-except the caller must provide the output buffer
-.Fa buf
-to store the result, which must be at least 26 characters long.
-.Fn localtime_r
-and
-.Fn gmtime_r
-provide the same functionality as
-.Fn localtime
-and
-.Fn gmtime
-respectively, except the caller must provide the output buffer
-.Fa result .
-.Pp
The
.Fn asctime
function
@@ -164,30 +135,14 @@ pointed at by
to the form
shown in the example above.
.Pp
-.Fn asctime_r
-provides the same functionality as
-.Fn asctime
-except the caller provide the output buffer
-.Fa buf
-to store the result, which must be at least 26 characters long.
-.Pp
-The functions
+The function
.Fn mktime
-and
-.Fn timegm
-converts the broken-down time in the structure
+converts the broken-down time, expressed as local time, in the structure
pointed to by tm into a time value with the same encoding as that of the
values returned by the
.Xr time 3
-function (that is, seconds from the Epoch,
-.Tn UTC ) .
-.Fn mktime
-interprets the input structure according to the current timezone setting
-(see
-.Xr tzset 3 ) .
-.Fn timegm
-interprets the input structure as representing Universal Coordinated Time
-.Pq Tn UTC .
+function, that is, seconds from the Epoch,
+.Tn UTC .
.Pp
The original values of the
.Fa tm_wday
@@ -206,13 +161,7 @@ A negative value for
causes the
.Fn mktime
function to attempt to divine whether summer time is in effect for the
-specified time.
-The
-.Fa tm_isdst
-and
-.Fa tm_gmtoff
-members are forced to zero by
-.Fn timegm . )
+specified time.)
.Pp
On successful completion, the values of the
.Fa tm_wday
@@ -231,6 +180,15 @@ are determined.
returns the specified calendar time; if the calendar time cannot be
represented, it returns \-1;
.Pp
+The function
+.Fn timegm
+is
+.Fn mktime
+analog, but assume that broke-down time expressed as UTC (not local) time.
+This function also set
+.Fa tm_isdst
+field to 0.
+.Pp
The
.Fn difftime
function
@@ -276,33 +234,6 @@ values indicating east of the Prime Meridian.
.Xr time 3 ,
.Xr tzset 3 ,
.Xr tzfile 5
-.Sh STANDARDS
-The
-.Fn asctime ,
-.Fn ctime ,
-.Fn difftime ,
-.Fn gmtime ,
-.Fn localtime ,
-and
-.Fn mktime
-functions conform to
-.St -isoC ,
-and conform to
-.St -p1003.1
-provided the selected local timezone does not contain a leap-second table
-(see
-.Xr zic 8 ) .
-.Pp
-The
-.Fn asctime_r ,
-.Fn ctime_r ,
-.Fn gmtime_r ,
-and
-.Fn localtime_r
-functions are expected to conform to
-.St -iso9945-1
-(again provided the selected local timezone does not contain a leap-second
-table).
.Sh HISTORY
This manual page is derived from
the time package contributed to Berkeley by
@@ -310,23 +241,13 @@ Arthur Olsen and which appeared in
.Bx 4.3 .
.Sh BUGS
Except for
-.Fn difftime ,
+.Fn difftime
+and
.Fn mktime ,
-and the
-.Fn \&_r
-variants of the other functions,
these functions leaves their result in an internal static object and return
a pointer to that object. Subsequent calls to these
function will modify the same object.
.Pp
-The C Standard provides no mechanism for a program to modify its current
-local timezone setting, and the
-.Tn POSIX Ns No \&-standard
-method is not reentrant. (However, thread-safe implementations are provided
-in the
-.Tn POSIX
-threaded environment.)
-.Pp
The
.Fa tm_zone
field of a returned tm structure points to a static array of characters,
@@ -341,3 +262,7 @@ Use of the external variable
is discouraged; the
.Fa tm_zone
entry in the tm structure is preferred.
+.Pp
+Avoid using out-of-range values with
+.Fn mktime
+when setting up lunch with promptness sticklers in Riyadh.
diff --git a/lib/libc/stdtime/localtime.c b/lib/libc/stdtime/localtime.c
index 9e130bd560e2..ad227cf32029 100644
--- a/lib/libc/stdtime/localtime.c
+++ b/lib/libc/stdtime/localtime.c
@@ -1082,21 +1082,19 @@ struct tm * const tmp;
#endif /* defined TM_ZONE */
}
+#ifdef _THREAD_SAFE
struct tm *
localtime_r(timep, p_tm)
const time_t * const timep;
struct tm *p_tm;
{
-#ifdef _THREAD_SAFE
pthread_mutex_lock(&lcl_mutex);
-#endif
tzset();
localsub(timep, 0L, p_tm);
-#ifdef _THREAD_SAFE
pthread_mutex_unlock(&lcl_mutex);
-#endif
return(p_tm);
}
+#endif
struct tm *
localtime(timep)
@@ -1216,12 +1214,14 @@ const time_t * const timep;
#endif
}
+#ifdef _THREAD_SAFE
struct tm *
gmtime_r(const time_t * timep, struct tm * tm)
{
gmtsub(timep, 0L, tm);
return(tm);
}
+#endif
#ifdef STD_INSPIRED
@@ -1350,6 +1350,7 @@ const time_t * const timep;
return asctime(localtime(timep));
}
+#ifdef _THREAD_SAFE
char *
ctime_r(timep, buf)
const time_t * const timep;
@@ -1358,6 +1359,7 @@ char *buf;
struct tm tm;
return asctime_r(localtime_r(timep, &tm), buf);
}
+#endif
/*
** Adapted from code provided by Robert Elz, who writes: