From 137270c9e6af14990af1d6d31b2d710b13040820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 19 Nov 2004 19:44:09 +0000 Subject: [PATCH] Readded our ctime.c - removed equivalent versions from localtime.c, so that not everything is in this one file. Removed definition of STD_INSPIRED: this not only fixes some warnings, it also removes functions that are not exported under BeOS, and there is no reason to change that. Added weak export of timelocal() in case STD_INSPIRED is not defined in localtime.c. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10037 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/time/Jamfile | 5 +++-- src/kernel/libroot/posix/time/ctime.c | 23 ++++++++++++++++++++ src/kernel/libroot/posix/time/localtime.c | 26 +++-------------------- 3 files changed, 29 insertions(+), 25 deletions(-) create mode 100644 src/kernel/libroot/posix/time/ctime.c diff --git a/src/kernel/libroot/posix/time/Jamfile b/src/kernel/libroot/posix/time/Jamfile index ecb4071e4e..fe9c17c37d 100644 --- a/src/kernel/libroot/posix/time/Jamfile +++ b/src/kernel/libroot/posix/time/Jamfile @@ -1,12 +1,13 @@ SubDir OBOS_TOP src kernel libroot posix time ; # for localtime.c strftime.c -SubDirCcFlags -DNOID -DTZDIR='\"/etc/timezones\"' -DUSG_COMPAT -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone -DSTD_INSPIRED=1 -DPCTS=1 ; +SubDirCcFlags -DNOID -DTZDIR='\"/etc/timezones\"' -DUSG_COMPAT -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone -DPCTS=1 ; UsePrivateHeaders [ FDirName libroot time ] ; KernelMergeObject posix_time.o : asctime.c + ctime.c difftime.c localtime.c stime.c @@ -77,4 +78,4 @@ KernelMergeObject posix_time.o : # out by the National Institute of Standards and Technology # which claims to test C and Posix conformance. If you want to pass PCTS, add # -DPCTS -# to the end of the "CFLAGS=" line. \ No newline at end of file +# to the end of the "CFLAGS=" line. diff --git a/src/kernel/libroot/posix/time/ctime.c b/src/kernel/libroot/posix/time/ctime.c new file mode 100644 index 0000000000..5542e9256d --- /dev/null +++ b/src/kernel/libroot/posix/time/ctime.c @@ -0,0 +1,23 @@ +/* + * Copyright 2004, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ + + +#include + + +char * +ctime(const time_t *_timer) +{ + return asctime(localtime(_timer)); +} + + +char * +ctime_r(const time_t *_timer, char *buf) +{ + struct tm tm; + return asctime_r(localtime_r(_timer, &tm), buf); +} + diff --git a/src/kernel/libroot/posix/time/localtime.c b/src/kernel/libroot/posix/time/localtime.c index 8cdcd802ec..b16a24f277 100644 --- a/src/kernel/libroot/posix/time/localtime.c +++ b/src/kernel/libroot/posix/time/localtime.c @@ -1243,28 +1243,6 @@ register struct tm * const tmp; #endif /* defined TM_GMTOFF */ } -char * -ctime(timep) -const time_t * const timep; -{ -/* -** Section 4.12.3.2 of X3.159-1989 requires that -** The ctime function converts the calendar time pointed to by timer -** to local time in the form of a string. It is equivalent to -** asctime(localtime(timer)) -*/ - return asctime(localtime(timep)); -} - -char * -ctime_r(timep, buf) -const time_t * const timep; -char * buf; -{ - struct tm tm; - - return asctime_r(localtime_r(timep, &tm), buf); -} /* ** Adapted from code provided by Robert Elz, who writes: @@ -1617,7 +1595,9 @@ struct tm * const tmp; return time1(tmp, localsub, 0L); } -#ifdef STD_INSPIRED +#ifndef STD_INSPIRED +#pragma weak timelocal=mktime +#else time_t timelocal(tmp)