diff options
Diffstat (limited to 'newlib/libc/time')
-rw-r--r-- | newlib/libc/time/Makefile.am | 67 | ||||
-rw-r--r-- | newlib/libc/time/Makefile.in | 429 | ||||
-rw-r--r-- | newlib/libc/time/asctime.c | 64 | ||||
-rw-r--r-- | newlib/libc/time/asctime_r.c | 27 | ||||
-rw-r--r-- | newlib/libc/time/clock.c | 69 | ||||
-rw-r--r-- | newlib/libc/time/ctime.c | 53 | ||||
-rw-r--r-- | newlib/libc/time/ctime_r.c | 15 | ||||
-rw-r--r-- | newlib/libc/time/difftime.c | 44 | ||||
-rw-r--r-- | newlib/libc/time/gmtime.c | 66 | ||||
-rw-r--r-- | newlib/libc/time/gmtime_r.c | 14 | ||||
-rw-r--r-- | newlib/libc/time/lcltime.c | 58 | ||||
-rw-r--r-- | newlib/libc/time/lcltime_r.c | 18 | ||||
-rw-r--r-- | newlib/libc/time/local.h | 54 | ||||
-rw-r--r-- | newlib/libc/time/mktime.c | 250 | ||||
-rw-r--r-- | newlib/libc/time/mktm_r.c | 248 | ||||
-rw-r--r-- | newlib/libc/time/strftime.c | 476 | ||||
-rw-r--r-- | newlib/libc/time/strptime.c | 438 | ||||
-rw-r--r-- | newlib/libc/time/time.c | 59 | ||||
-rw-r--r-- | newlib/libc/time/time.tex | 90 | ||||
-rw-r--r-- | newlib/libc/time/tzlock.c | 44 | ||||
-rw-r--r-- | newlib/libc/time/tzset.c | 72 | ||||
-rw-r--r-- | newlib/libc/time/tzset_r.c | 206 |
22 files changed, 0 insertions, 2861 deletions
diff --git a/newlib/libc/time/Makefile.am b/newlib/libc/time/Makefile.am deleted file mode 100644 index 3735def7c..000000000 --- a/newlib/libc/time/Makefile.am +++ /dev/null @@ -1,67 +0,0 @@ -## Process this file with automake to generate Makefile.in - -AUTOMAKE_OPTIONS = cygnus - -INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) - -LIB_SOURCES = \ - asctime.c \ - asctime_r.c \ - clock.c \ - ctime.c \ - ctime_r.c \ - difftime.c \ - gmtime.c \ - gmtime_r.c \ - lcltime.c \ - lcltime_r.c \ - mktime.c \ - mktm_r.c \ - strftime.c \ - strptime.c \ - time.c \ - tzlock.c \ - tzset.c \ - tzset_r.c - -libtime_la_LDFLAGS = -Xcompiler -nostdlib - -if USE_LIBTOOL -noinst_LTLIBRARIES = libtime.la -libtime_la_SOURCES = $(LIB_SOURCES) -noinst_DATA = objectlist.awk.in -else -noinst_LIBRARIES = lib.a -lib_a_SOURCES = $(LIB_SOURCES) -noinst_DATA = -endif # USE_LIBTOOL - -include $(srcdir)/../../Makefile.shared - -CHEWOUT_FILES = \ - asctime.def \ - clock.def \ - ctime.def \ - difftime.def \ - gmtime.def \ - lcltime.def \ - mktime.def \ - strftime.def \ - time.def \ - tzlock.def \ - tzset.def - -SUFFIXES = .def - -CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str - -.c.def: - $(CHEW) < $< > $*.def 2> $*.ref - touch stmp-def - -TARGETDOC = ../tmp.texi - -doc: $(CHEWOUT_FILES) - cat $(srcdir)/time.tex >> $(TARGETDOC) - -CLEANFILES = $(CHEWOUT_FILES) *.ref diff --git a/newlib/libc/time/Makefile.in b/newlib/libc/time/Makefile.in deleted file mode 100644 index 8fe997b28..000000000 --- a/newlib/libc/time/Makefile.in +++ /dev/null @@ -1,429 +0,0 @@ -# Makefile.in generated automatically by automake 1.4 from Makefile.am - -# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - - - -SHELL = @SHELL@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include - -DESTDIR = - -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ - -top_builddir = .. - -ACLOCAL = @ACLOCAL@ -AUTOCONF = @AUTOCONF@ -AUTOMAKE = @AUTOMAKE@ -AUTOHEADER = @AUTOHEADER@ - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -transform = @program_transform_name@ - -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_alias = @build_alias@ -build_triplet = @build@ -host_alias = @host_alias@ -host_triplet = @host@ -target_alias = @target_alias@ -target_triplet = @target@ -AR = @AR@ -AS = @AS@ -CC = @CC@ -CPP = @CPP@ -CRT0 = @CRT0@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -DLLTOOL = @DLLTOOL@ -EXEEXT = @EXEEXT@ -GCJ = @GCJ@ -GCJFLAGS = @GCJFLAGS@ -LDFLAGS = @LDFLAGS@ -LIBC_EXTRA_DEF = @LIBC_EXTRA_DEF@ -LIBC_EXTRA_LIB = @LIBC_EXTRA_LIB@ -LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ -LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ -LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ -LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ -LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ -LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ -LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ -LIBC_SYS_LIB = @LIBC_SYS_LIB@ -LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ -LIBTOOL = @LIBTOOL@ -LN_S = @LN_S@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -NEWLIB_CFLAGS = @NEWLIB_CFLAGS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -RANLIB = @RANLIB@ -STRIP = @STRIP@ -VERSION = @VERSION@ -aext = @aext@ -extra_dir = @extra_dir@ -libm_machine_dir = @libm_machine_dir@ -machine_dir = @machine_dir@ -newlib_basedir = @newlib_basedir@ -oext = @oext@ -sys_dir = @sys_dir@ - -AUTOMAKE_OPTIONS = cygnus - -INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) - -LIB_SOURCES = \ - asctime.c \ - asctime_r.c \ - clock.c \ - ctime.c \ - ctime_r.c \ - difftime.c \ - gmtime.c \ - gmtime_r.c \ - lcltime.c \ - lcltime_r.c \ - mktime.c \ - mktm_r.c \ - strftime.c \ - strptime.c \ - time.c \ - tzlock.c \ - tzset.c \ - tzset_r.c - - -libtime_la_LDFLAGS = -Xcompiler -nostdlib - -@USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = @USE_LIBTOOL_TRUE@libtime.la -@USE_LIBTOOL_TRUE@libtime_la_SOURCES = @USE_LIBTOOL_TRUE@$(LIB_SOURCES) -@USE_LIBTOOL_TRUE@noinst_DATA = @USE_LIBTOOL_TRUE@objectlist.awk.in -@USE_LIBTOOL_FALSE@noinst_DATA = -@USE_LIBTOOL_FALSE@noinst_LIBRARIES = @USE_LIBTOOL_FALSE@lib.a -@USE_LIBTOOL_FALSE@lib_a_SOURCES = @USE_LIBTOOL_FALSE@$(LIB_SOURCES) - -CHEWOUT_FILES = \ - asctime.def \ - clock.def \ - ctime.def \ - difftime.def \ - gmtime.def \ - lcltime.def \ - mktime.def \ - strftime.def \ - time.def \ - tzlock.def \ - tzset.def - - -SUFFIXES = .def - -CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str - -TARGETDOC = ../tmp.texi - -CLEANFILES = $(CHEWOUT_FILES) *.ref -mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs -CONFIG_CLEAN_FILES = -LIBRARIES = $(noinst_LIBRARIES) - - -DEFS = @DEFS@ -I. -I$(srcdir) -CPPFLAGS = @CPPFLAGS@ -LIBS = @LIBS@ -lib_a_LIBADD = -@USE_LIBTOOL_FALSE@lib_a_OBJECTS = asctime.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@asctime_r.$(OBJEXT) clock.$(OBJEXT) ctime.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@ctime_r.$(OBJEXT) difftime.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@gmtime.$(OBJEXT) gmtime_r.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@lcltime.$(OBJEXT) lcltime_r.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@mktime.$(OBJEXT) mktm_r.$(OBJEXT) strftime.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@strptime.$(OBJEXT) time.$(OBJEXT) tzlock.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@tzset.$(OBJEXT) tzset_r.$(OBJEXT) -LTLIBRARIES = $(noinst_LTLIBRARIES) - -libtime_la_LIBADD = -@USE_LIBTOOL_TRUE@libtime_la_OBJECTS = asctime.lo asctime_r.lo clock.lo \ -@USE_LIBTOOL_TRUE@ctime.lo ctime_r.lo difftime.lo gmtime.lo gmtime_r.lo \ -@USE_LIBTOOL_TRUE@lcltime.lo lcltime_r.lo mktime.lo mktm_r.lo \ -@USE_LIBTOOL_TRUE@strftime.lo strptime.lo time.lo tzlock.lo tzset.lo \ -@USE_LIBTOOL_TRUE@tzset_r.lo -CFLAGS = @CFLAGS@ -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ -DATA = $(noinst_DATA) - -DIST_COMMON = Makefile.am Makefile.in - - -DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) - -TAR = gtar -GZIP_ENV = --best -SOURCES = $(lib_a_SOURCES) $(libtime_la_SOURCES) -OBJECTS = $(lib_a_OBJECTS) $(libtime_la_OBJECTS) - -all: all-redirect -.SUFFIXES: -.SUFFIXES: .S .c .def .lo .o .obj .s -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) $(srcdir)/../../Makefile.shared - cd $(top_srcdir) && $(AUTOMAKE) --cygnus time/Makefile - -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) \ - && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status - - -mostlyclean-noinstLIBRARIES: - -clean-noinstLIBRARIES: - -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) - -distclean-noinstLIBRARIES: - -maintainer-clean-noinstLIBRARIES: - -.c.o: - $(COMPILE) -c $< - -# FIXME: We should only use cygpath when building on Windows, -# and only if it is available. -.c.obj: - $(COMPILE) -c `cygpath -w $<` - -.s.o: - $(COMPILE) -c $< - -.S.o: - $(COMPILE) -c $< - -mostlyclean-compile: - -rm -f *.o core *.core - -rm -f *.$(OBJEXT) - -clean-compile: - -distclean-compile: - -rm -f *.tab.c - -maintainer-clean-compile: - -.c.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -.s.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -.S.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -maintainer-clean-libtool: - -lib.a: $(lib_a_OBJECTS) $(lib_a_DEPENDENCIES) - -rm -f lib.a - $(AR) cru lib.a $(lib_a_OBJECTS) $(lib_a_LIBADD) - $(RANLIB) lib.a - -mostlyclean-noinstLTLIBRARIES: - -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - -distclean-noinstLTLIBRARIES: - -maintainer-clean-noinstLTLIBRARIES: - -libtime.la: $(libtime_la_OBJECTS) $(libtime_la_DEPENDENCIES) - $(LINK) $(libtime_la_LDFLAGS) $(libtime_la_OBJECTS) $(libtime_la_LIBADD) $(LIBS) - -tags: TAGS - -ID: $(HEADERS) $(SOURCES) $(LISP) - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - here=`pwd` && cd $(srcdir) \ - && mkid -f$$here/ID $$unique $(LISP) - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ - || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) - -mostlyclean-tags: - -clean-tags: - -distclean-tags: - -rm -f TAGS ID - -maintainer-clean-tags: - -distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) - -subdir = time - -distdir: $(DISTFILES) - @for file in $(DISTFILES); do \ - if test -f $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ - else \ - test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file || :; \ - fi; \ - done -info-am: -info: info-am -dvi-am: -dvi: dvi-am -check-am: -check: check-am -installcheck-am: -installcheck: installcheck-am -install-info-am: -install-info: install-info-am -install-exec-am: -install-exec: install-exec-am - -install-data-am: -install-data: install-data-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -install: install-am -uninstall-am: -uninstall: uninstall-am -all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(DATA) -all-redirect: all-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install -installdirs: - - -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) - -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -maintainer-clean-generic: -mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \ - mostlyclean-libtool mostlyclean-noinstLTLIBRARIES \ - mostlyclean-tags mostlyclean-generic - -mostlyclean: mostlyclean-am - -clean-am: clean-noinstLIBRARIES clean-compile clean-libtool \ - clean-noinstLTLIBRARIES clean-tags clean-generic \ - mostlyclean-am - -clean: clean-am - -distclean-am: distclean-noinstLIBRARIES distclean-compile \ - distclean-libtool distclean-noinstLTLIBRARIES \ - distclean-tags distclean-generic clean-am - -rm -f libtool - -distclean: distclean-am - -maintainer-clean-am: maintainer-clean-noinstLIBRARIES \ - maintainer-clean-compile maintainer-clean-libtool \ - maintainer-clean-noinstLTLIBRARIES \ - maintainer-clean-tags maintainer-clean-generic \ - distclean-am - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." - -maintainer-clean: maintainer-clean-am - -.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \ -clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \ -mostlyclean-compile distclean-compile clean-compile \ -maintainer-clean-compile mostlyclean-libtool distclean-libtool \ -clean-libtool maintainer-clean-libtool mostlyclean-noinstLTLIBRARIES \ -distclean-noinstLTLIBRARIES clean-noinstLTLIBRARIES \ -maintainer-clean-noinstLTLIBRARIES tags mostlyclean-tags distclean-tags \ -clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \ -check-am installcheck-am installcheck install-info-am install-info \ -install-exec-am install-exec install-data-am install-data install-am \ -install uninstall-am uninstall all-redirect all-am all installdirs \ -mostlyclean-generic distclean-generic clean-generic \ -maintainer-clean-generic clean mostlyclean distclean maintainer-clean - - -objectlist.awk.in: $(noinst_LTLIBRARIES) - -rm -f objectlist.awk.in - for i in `ls *.lo` ; \ - do \ - echo $$i `pwd`/$$i >> objectlist.awk.in ; \ - done - -.c.def: - $(CHEW) < $< > $*.def 2> $*.ref - touch stmp-def - -doc: $(CHEWOUT_FILES) - cat $(srcdir)/time.tex >> $(TARGETDOC) - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/newlib/libc/time/asctime.c b/newlib/libc/time/asctime.c deleted file mode 100644 index e4011856d..000000000 --- a/newlib/libc/time/asctime.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * asctime.c - * Original Author: G. Haley - * - * Converts the broken down time in the structure pointed to by tim_p into a - * string of the form - * - * Wed Jun 15 11:38:07 1988\n\0 - * - * Returns a pointer to the string. - */ - -/* -FUNCTION -<<asctime>>---format time as string - -INDEX - asctime -INDEX - _asctime_r - -ANSI_SYNOPSIS - #include <time.h> - char *asctime(const struct tm *<[clock]>); - char *asctime_r(const struct tm *<[clock]>, char *<[buf]>); - -TRAD_SYNOPSIS - #include <time.h> - char *asctime(<[clock]>) - struct tm *<[clock]>; - char *asctime_r(<[clock]>) - struct tm *<[clock]>; - char *<[buf]>; - -DESCRIPTION -Format the time value at <[clock]> into a string of the form -. Wed Jun 15 11:38:07 1988\n\0 -The string is generated in a static buffer; each call to <<asctime>> -overwrites the string generated by previous calls. - -RETURNS -A pointer to the string containing a formatted timestamp. - -PORTABILITY -ANSI C requires <<asctime>>. - -<<asctime>> requires no supporting OS subroutines. -*/ - -#include <time.h> -#include <_ansi.h> -#include <reent.h> - -#ifndef _REENT_ONLY - -char * -_DEFUN (asctime, (tim_p), - _CONST struct tm *tim_p) -{ - _REENT_CHECK_ASCTIME_BUF(_REENT); - return asctime_r (tim_p, _REENT_ASCTIME_BUF(_REENT)); -} - -#endif diff --git a/newlib/libc/time/asctime_r.c b/newlib/libc/time/asctime_r.c deleted file mode 100644 index 2c02667e6..000000000 --- a/newlib/libc/time/asctime_r.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * asctime_r.c - */ - -#include <stdio.h> -#include <time.h> - -char * -_DEFUN (asctime_r, (tim_p, result), - _CONST struct tm *tim_p _AND - char *result) -{ - static _CONST char day_name[7][3] = { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" - }; - static _CONST char mon_name[12][3] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; - - sprintf (result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n", - day_name[tim_p->tm_wday], - mon_name[tim_p->tm_mon], - tim_p->tm_mday, tim_p->tm_hour, tim_p->tm_min, - tim_p->tm_sec, 1900 + tim_p->tm_year); - return result; -} diff --git a/newlib/libc/time/clock.c b/newlib/libc/time/clock.c deleted file mode 100644 index b15915d6a..000000000 --- a/newlib/libc/time/clock.c +++ /dev/null @@ -1,69 +0,0 @@ -/* NetWare can not use this implementation of clock, since it does not - have times or any similar function. It provides its own version of - clock in clib.nlm. If we can not use clib.nlm, then we must write - clock in sys/netware. */ - -#ifdef CLOCK_PROVIDED - -int _dummy_clock = 1; - -#else - -/* - * clock.c - * Original Author: G. Haley - * - * Determines the processor time used by the program since invocation. The time - * in seconds is the value returned divided by the value of the macro CLK_TCK. - * If the processor time used is not available, (clock_t) -1 is returned. - */ - -/* -FUNCTION -<<clock>>---cumulative processor time - -INDEX - clock - -ANSI_SYNOPSIS - #include <time.h> - clock_t clock(void); - -TRAD_SYNOPSIS - #include <time.h> - clock_t clock(); - -DESCRIPTION -Calculates the best available approximation of the cumulative amount -of time used by your program since it started. To convert the result -into seconds, divide by the macro <<CLOCKS_PER_SEC>>. - -RETURNS -The amount of processor time used so far by your program, in units -defined by the machine-dependent macro <<CLOCKS_PER_SEC>>. If no -measurement is available, the result is <<-1>>. - -PORTABILITY -ANSI C requires <<clock>> and <<CLOCKS_PER_SEC>>. - -Supporting OS subroutine required: <<times>>. -*/ - -#include <time.h> -#include <sys/times.h> -#include <reent.h> - -clock_t -clock () -{ - struct tms tim_s; - clock_t res; - - if ((res = (clock_t) _times_r (_REENT, &tim_s)) != -1) - res = (clock_t) (tim_s.tms_utime + tim_s.tms_stime + - tim_s.tms_cutime + tim_s.tms_cstime); - - return res; -} - -#endif /* CLOCK_PROVIDED */ diff --git a/newlib/libc/time/ctime.c b/newlib/libc/time/ctime.c deleted file mode 100644 index 63954c640..000000000 --- a/newlib/libc/time/ctime.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * ctime.c - * Original Author: G. Haley - */ - -/* -FUNCTION -<<ctime>>---convert time to local and format as string - -INDEX - ctime - -ANSI_SYNOPSIS - #include <time.h> - char *ctime(const time_t *<[clock]>); - char *ctime_r(const time_t *<[clock]>, char *<[buf]>); - -TRAD_SYNOPSIS - #include <time.h> - char *ctime(<[clock]>) - time_t *<[clock]>; - - char *ctime_r(<[clock]>, <[buf]>) - time_t *<[clock]>; - char *<[buf]>; - -DESCRIPTION -Convert the time value at <[clock]> to local time (like <<localtime>>) -and format it into a string of the form -. Wed Jun 15 11:38:07 1988\n\0 -(like <<asctime>>). - -RETURNS -A pointer to the string containing a formatted timestamp. - -PORTABILITY -ANSI C requires <<ctime>>. - -<<ctime>> requires no supporting OS subroutines. -*/ - -#include <time.h> - -#ifndef _REENT_ONLY - -char * -_DEFUN (ctime, (tim_p), - _CONST time_t * tim_p) -{ - return asctime (localtime (tim_p)); -} - -#endif diff --git a/newlib/libc/time/ctime_r.c b/newlib/libc/time/ctime_r.c deleted file mode 100644 index fda8cac1e..000000000 --- a/newlib/libc/time/ctime_r.c +++ /dev/null @@ -1,15 +0,0 @@ -/* - * ctime_r.c - */ - -#include <time.h> - -char * -_DEFUN (ctime_r, (tim_p, result), - _CONST time_t * tim_p _AND - char * result) - -{ - struct tm tm; - return asctime_r (localtime_r (tim_p, &tm), result); -} diff --git a/newlib/libc/time/difftime.c b/newlib/libc/time/difftime.c deleted file mode 100644 index 93a4f0004..000000000 --- a/newlib/libc/time/difftime.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * difftime.c - * Original Author: G. Haley - */ - -/* -FUNCTION -<<difftime>>---subtract two times - -INDEX - difftime - -ANSI_SYNOPSIS - #include <time.h> - double difftime(time_t <[tim1]>, time_t <[tim2]>); - -TRAD_SYNOPSIS - #include <time.h> - double difftime(<[tim1]>, <[tim2]>) - time_t <[tim1]>; - time_t <[tim2]>; - -DESCRIPTION -Subtracts the two times in the arguments: `<<<[tim1]> - <[tim2]>>>'. - -RETURNS -The difference (in seconds) between <[tim2]> and <[tim1]>, as a <<double>>. - -PORTABILITY -ANSI C requires <<difftime>>, and defines its result to be in seconds -in all implementations. - -<<difftime>> requires no supporting OS subroutines. -*/ - -#include <time.h> - -double -_DEFUN (difftime, (tim1, tim2), - time_t tim1 _AND - time_t tim2) -{ - return ((double) tim1 - tim2); -} diff --git a/newlib/libc/time/gmtime.c b/newlib/libc/time/gmtime.c deleted file mode 100644 index d8e687559..000000000 --- a/newlib/libc/time/gmtime.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * gmtime.c - * Original Author: G. Haley - * - * Converts the calendar time pointed to by tim_p into a broken-down time - * expressed as Greenwich Mean Time (GMT). Returns a pointer to a structure - * containing the broken-down time, or a null pointer if GMT is not - * available. - */ - -/* -FUNCTION -<<gmtime>>---convert time to UTC traditional form - -INDEX - gmtime - -ANSI_SYNOPSIS - #include <time.h> - struct tm *gmtime(const time_t *<[clock]>); - struct tm *gmtime_r(const time_t *<[clock]>, struct tm *<[res]>); - -TRAD_SYNOPSIS - #include <time.h> - struct tm *gmtime(<[clock]>) - const time_t *<[clock]>; - struct tm *gmtime_r(<[clock]>, <[res]>) - const time_t *<[clock]>; - struct tm *<[res]>; - -DESCRIPTION -<<gmtime>> assumes the time at <[clock]> represents a local time. -<<gmtime>> converts it to UTC (Universal Coordinated Time, also known in some -countries as GMT, Greenwich Mean time), then converts the -representation from the arithmetic representation to -the traditional representation defined by <<struct tm>>. - -<<gmtime>> constructs the traditional time representation in static -storage; each call to <<gmtime>> or <<localtime>> will overwrite the -information generated by previous calls to either function. - -RETURNS -A pointer to the traditional time representation (<<struct tm>>). - -PORTABILITY -ANSI C requires <<gmtime>>. - -<<gmtime>> requires no supporting OS subroutines. -*/ - -#include <stdlib.h> -#include <time.h> - -#define _GMT_OFFSET 0 - -#ifndef _REENT_ONLY - -struct tm * -_DEFUN (gmtime, (tim_p), - _CONST time_t * tim_p) -{ - _REENT_CHECK_TM(_REENT); - return gmtime_r (tim_p, (struct tm *)_REENT_TM(_REENT)); -} - -#endif diff --git a/newlib/libc/time/gmtime_r.c b/newlib/libc/time/gmtime_r.c deleted file mode 100644 index fb39238d3..000000000 --- a/newlib/libc/time/gmtime_r.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * gmtime_r.c - */ - -#include <time.h> -#include "local.h" - -struct tm * -_DEFUN (gmtime_r, (tim_p, res), - _CONST time_t * tim_p _AND - struct tm *res) -{ - return (_mktm_r (tim_p, res, 1)); -} diff --git a/newlib/libc/time/lcltime.c b/newlib/libc/time/lcltime.c deleted file mode 100644 index 1cdc64fd0..000000000 --- a/newlib/libc/time/lcltime.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * localtime.c - */ - -/* -FUNCTION -<<localtime>>---convert time to local representation - -INDEX - localtime - -ANSI_SYNOPSIS - #include <time.h> - struct tm *localtime(time_t *<[clock]>); - struct tm *localtime_r(time_t *<[clock]>, struct tm *<[res]>); - -TRAD_SYNOPSIS - #include <time.h> - struct tm *localtime(<[clock]>) - time_t *<[clock]>; - struct tm *localtime(<[clock]>, <[res]>) - time_t *<[clock]>; - struct tm *<[res]>; - -DESCRIPTION -<<localtime>> converts the time at <[clock]> into local time, then -converts its representation from the arithmetic representation to the -traditional representation defined by <<struct tm>>. - -<<localtime>> constructs the traditional time representation in static -storage; each call to <<gmtime>> or <<localtime>> will overwrite the -information generated by previous calls to either function. - -<<mktime>> is the inverse of <<localtime>>. - -RETURNS -A pointer to the traditional time representation (<<struct tm>>). - -PORTABILITY -ANSI C requires <<localtime>>. - -<<localtime>> requires no supporting OS subroutines. -*/ - -#include <time.h> -#include <reent.h> - -#ifndef _REENT_ONLY - -struct tm * -_DEFUN (localtime, (tim_p), - _CONST time_t * tim_p) -{ - _REENT_CHECK_TM(_REENT); - return localtime_r (tim_p, (struct tm *)_REENT_TM(_REENT)); -} - -#endif diff --git a/newlib/libc/time/lcltime_r.c b/newlib/libc/time/lcltime_r.c deleted file mode 100644 index cf386719c..000000000 --- a/newlib/libc/time/lcltime_r.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * localtime_r.c - * - * Converts the calendar time pointed to by tim_p into a broken-down time - * expressed as local time. Returns a pointer to a structure containing the - * broken-down time. - */ - -#include <time.h> -#include "local.h" - -struct tm * -_DEFUN (localtime_r, (tim_p, res), - _CONST time_t * tim_p _AND - struct tm *res) -{ - return _mktm_r (tim_p, res, 0); -} diff --git a/newlib/libc/time/local.h b/newlib/libc/time/local.h deleted file mode 100644 index 722808715..000000000 --- a/newlib/libc/time/local.h +++ /dev/null @@ -1,54 +0,0 @@ -/* local header used by libc/time routines */ -#include <_ansi.h> -#include <time.h> - -#define SECSPERMIN 60L -#define MINSPERHOUR 60L -#define HOURSPERDAY 24L -#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) -#define SECSPERDAY (SECSPERHOUR * HOURSPERDAY) -#define DAYSPERWEEK 7 -#define MONSPERYEAR 12 - -#define YEAR_BASE 1900 -#define EPOCH_YEAR 1970 -#define EPOCH_WDAY 4 -#define EPOCH_YEARS_SINCE_LEAP 2 -#define EPOCH_YEARS_SINCE_CENTURY 70 -#define EPOCH_YEARS_SINCE_LEAP_CENTURY 370 - -#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0) - -extern time_t __tzstart_std; -extern time_t __tzstart_dst; -extern int __tznorth; -extern int __tzyear; - -typedef struct __tzrule_struct -{ - char ch; - int m; - int n; - int d; - int s; - time_t change; - int offset; -} __tzrule_type; - -extern __tzrule_type __tzrule[2]; - -struct tm * _EXFUN (_mktm_r, (_CONST time_t *, struct tm *, int __is_gmtime)); -int _EXFUN (__tzcalc_limits, (int __year)); - -/* locks for multi-threading */ -#ifdef __SINGLE_THREAD__ -#define TZ_LOCK -#define TZ_UNLOCK -#else -#define TZ_LOCK __tz_lock() -#define TZ_UNLOCK __tz_unlock() -#endif - -void _EXFUN(__tz_lock,(_VOID)); -void _EXFUN(__tz_unlock,(_VOID)); - diff --git a/newlib/libc/time/mktime.c b/newlib/libc/time/mktime.c deleted file mode 100644 index f6f080d84..000000000 --- a/newlib/libc/time/mktime.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * mktime.c - * Original Author: G. Haley - * - * Converts the broken-down time, expressed as local time, in the structure - * pointed to by tim_p into a calendar time value. The original values of the - * tm_wday and tm_yday fields of the structure are ignored, and the original - * values of the other fields have no restrictions. On successful completion - * the fields of the structure are set to represent the specified calendar - * time. Returns the specified calendar time. If the calendar time can not be - * represented, returns the value (time_t) -1. - */ - -/* -FUNCTION -<<mktime>>---convert time to arithmetic representation - -INDEX - mktime - -ANSI_SYNOPSIS - #include <time.h> - time_t mktime(struct tm *<[timp]>); - -TRAD_SYNOPSIS - #include <time.h> - time_t mktime(<[timp]>) - struct tm *<[timp]>; - -DESCRIPTION -<<mktime>> assumes the time at <[timp]> is a local time, and converts -its representation from the traditional representation defined by -<<struct tm>> into a representation suitable for arithmetic. - -<<localtime>> is the inverse of <<mktime>>. - -RETURNS -If the contents of the structure at <[timp]> do not form a valid -calendar time representation, the result is <<-1>>. Otherwise, the -result is the time, converted to a <<time_t>> value. - -PORTABILITY -ANSI C requires <<mktime>>. - -<<mktime>> requires no supporting OS subroutines. -*/ - -#include <stdlib.h> -#include <time.h> -#include "local.h" - -#define _SEC_IN_MINUTE 60L -#define _SEC_IN_HOUR 3600L -#define _SEC_IN_DAY 86400L - -static _CONST int DAYS_IN_MONTH[12] = -{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - -#define _DAYS_IN_MONTH(x) ((x == 1) ? days_in_feb : DAYS_IN_MONTH[x]) - -static _CONST int _DAYS_BEFORE_MONTH[12] = -{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; - -#define _ISLEAP(y) (((y) % 4) == 0 && (((y) % 100) != 0 || (((y)+1900) % 400) == 0)) -#define _DAYS_IN_YEAR(year) (_ISLEAP(year) ? 366 : 365) - -static void -validate_structure (tim_p) - struct tm *tim_p; -{ - div_t res; - int days_in_feb = 28; - - /* calculate time & date to account for out of range values */ - if (tim_p->tm_sec < 0 || tim_p->tm_sec > 59) - { - res = div (tim_p->tm_sec, 60); - tim_p->tm_min += res.quot; - if ((tim_p->tm_sec = res.rem) < 0) - { - tim_p->tm_sec += 60; - --tim_p->tm_min; - } - } - - if (tim_p->tm_min < 0 || tim_p->tm_min > 59) - { - res = div (tim_p->tm_min, 60); - tim_p->tm_hour += res.quot; - if ((tim_p->tm_min = res.rem) < 0) - { - tim_p->tm_min += 60; - --tim_p->tm_hour; - } - } - - if (tim_p->tm_hour < 0 || tim_p->tm_hour > 23) - { - res = div (tim_p->tm_hour, 24); - tim_p->tm_mday += res.quot; - if ((tim_p->tm_hour = res.rem) < 0) - { - tim_p->tm_hour += 24; - --tim_p->tm_mday; - } - } - - if (tim_p->tm_mon > 11) - { - res = div (tim_p->tm_mon, 12); - tim_p->tm_year += res.quot; - if ((tim_p->tm_mon = res.rem) < 0) - { - tim_p->tm_mon += 12; - --tim_p->tm_year; - } - } - - if (_DAYS_IN_YEAR (tim_p->tm_year) == 366) - days_in_feb = 29; - - if (tim_p->tm_mday <= 0) - { - while (tim_p->tm_mday <= 0) - { - if (--tim_p->tm_mon == -1) - { - tim_p->tm_year--; - tim_p->tm_mon = 11; - days_in_feb = - ((_DAYS_IN_YEAR (tim_p->tm_year) == 366) ? - 29 : 28); - } - tim_p->tm_mday += _DAYS_IN_MONTH (tim_p->tm_mon); - } - } - else - { - while (tim_p->tm_mday > _DAYS_IN_MONTH (tim_p->tm_mon)) - { - tim_p->tm_mday -= _DAYS_IN_MONTH (tim_p->tm_mon); - if (++tim_p->tm_mon == 12) - { - tim_p->tm_year++; - tim_p->tm_mon = 0; - days_in_feb = - ((_DAYS_IN_YEAR (tim_p->tm_year) == 366) ? - 29 : 28); - } - } - } -} - -time_t -mktime (tim_p) - struct tm *tim_p; -{ - time_t tim = 0; - long days = 0; - int year, isdst; - - /* validate structure */ - validate_structure (tim_p); - - /* compute hours, minutes, seconds */ - tim += tim_p->tm_sec + (tim_p->tm_min * _SEC_IN_MINUTE) + - (tim_p->tm_hour * _SEC_IN_HOUR); - - /* compute days in year */ - days += tim_p->tm_mday - 1; - days += _DAYS_BEFORE_MONTH[tim_p->tm_mon]; - if (tim_p->tm_mon > 1 && _DAYS_IN_YEAR (tim_p->tm_year) == 366) - days++; - - /* compute day of the year */ - tim_p->tm_yday = days; - - if (tim_p->tm_year > 10000 - || tim_p->tm_year < -10000) - { - return (time_t) -1; - } - - /* compute days in other years */ - if (tim_p->tm_year > 70) - { - for (year = 70; year < tim_p->tm_year; year++) - days += _DAYS_IN_YEAR (year); - } - else if (tim_p->tm_year < 70) - { - for (year = 69; year > tim_p->tm_year; year--) - days -= _DAYS_IN_YEAR (year); - days -= _DAYS_IN_YEAR (year); - } - - /* compute day of the week */ - if ((tim_p->tm_wday = (days + 4) % 7) < 0) - tim_p->tm_wday += 7; - - /* compute total seconds */ - tim += (days * _SEC_IN_DAY); - - isdst = tim_p->tm_isdst; - - if (_daylight) - { - int y = tim_p->tm_year + YEAR_BASE; - if (y == __tzyear || __tzcalc_limits (y)) - { - /* calculate start of dst in dst local time and - start of std in both std local time and dst local time */ - time_t startdst_dst = __tzrule[0].change - __tzrule[1].offset; - time_t startstd_dst = __tzrule[1].change - __tzrule[1].offset; - time_t startstd_std = __tzrule[1].change - __tzrule[0].offset; - /* if the time is in the overlap between dst and std local times */ - if (tim >= startstd_std && tim < startstd_dst) - ; /* we let user decide or leave as -1 */ - else - { - isdst = (__tznorth - ? (tim >= startdst_dst && tim < startstd_std) - : (tim >= startdst_dst || tim < startstd_std)); - /* if user committed and was wrong, perform correction */ - if ((isdst ^ tim_p->tm_isdst) == 1) - { - /* we either subtract or add the difference between - time zone offsets, depending on which way the user got it wrong */ - int diff = __tzrule[0].offset - __tzrule[1].offset; - if (!isdst) - diff = -diff; - tim_p->tm_sec += diff; - validate_structure (tim_p); - tim += diff; /* we also need to correct our current time calculation */ - } - } - } - } - - /* add appropriate offset to put time in gmt format */ - if (isdst == 1) - tim += __tzrule[1].offset; - else /* otherwise assume std time */ - tim += __tzrule[0].offset; - - /* reset isdst flag to what we have calculated */ - tim_p->tm_isdst = isdst; - - return tim; -} diff --git a/newlib/libc/time/mktm_r.c b/newlib/libc/time/mktm_r.c deleted file mode 100644 index 4fdfb9b7b..000000000 --- a/newlib/libc/time/mktm_r.c +++ /dev/null @@ -1,248 +0,0 @@ -/* - * mktm_r.c - * Original Author: Adapted from tzcode maintained by Arthur David Olson. - * Modifications: Changed to mktm_r and added __tzcalc_limits - 04/10/02, Jeff Johnston - * - * Converts the calendar time pointed to by tim_p into a broken-down time - * expressed as local time. Returns a pointer to a structure containing the - * broken-down time. - */ - -#include <stdlib.h> -#include <time.h> -#include "local.h" - -static _CONST int mon_lengths[2][MONSPERYEAR] = { - {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, - {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} -} ; - -static _CONST int year_lengths[2] = { - 365, - 366 -} ; - -struct tm * -_DEFUN (_mktm_r, (tim_p, res, is_gmtime), - _CONST time_t * tim_p _AND - struct tm *res _AND - int is_gmtime) -{ - long days, rem; - time_t lcltime; - int i; - int y; - int yleap; - _CONST int *ip; - - /* base decision about std/dst time on current time */ - lcltime = *tim_p; - - days = ((long)lcltime) / SECSPERDAY; - rem = ((long)lcltime) % SECSPERDAY; - while (rem < 0) - { - rem += SECSPERDAY; - --days; - } - while (rem >= SECSPERDAY) - { - rem -= SECSPERDAY; - ++days; - } - - /* compute hour, min, and sec */ - res->tm_hour = (int) (rem / SECSPERHOUR); - rem %= SECSPERHOUR; - res->tm_min = (int) (rem / SECSPERMIN); - res->tm_sec = (int) (rem % SECSPERMIN); - - /* compute day of week */ - if ((res->tm_wday = ((EPOCH_WDAY + days) % DAYSPERWEEK)) < 0) - res->tm_wday += DAYSPERWEEK; - - /* compute year & day of year */ - y = EPOCH_YEAR; - if (days >= 0) - { - for (;;) - { - yleap = isleap(y); - if (days < year_lengths[yleap]) - break; - y++; - days -= year_lengths[yleap]; - } - } - else - { - do - { - --y; - yleap = isleap(y); - days += year_lengths[yleap]; - } while (days < 0); - } - - res->tm_year = y - YEAR_BASE; - res->tm_yday = days; - ip = mon_lengths[yleap]; - for (res->tm_mon = 0; days >= ip[res->tm_mon]; ++res->tm_mon) - days -= ip[res->tm_mon]; - res->tm_mday = days + 1; - - if (!is_gmtime) - { - int offset; - int hours, mins, secs; - - TZ_LOCK; - if (_daylight) - { - if (y == __tzyear || __tzcalc_limits (y)) - res->tm_isdst = (__tznorth - ? (*tim_p >= __tzrule[0].change && *tim_p < __tzrule[1].change) - : (*tim_p >= __tzrule[0].change || *tim_p < __tzrule[1].change)); - else - res->tm_isdst = -1; - } - else - res->tm_isdst = 0; - - offset = (res->tm_isdst == 1 ? __tzrule[1].offset : __tzrule[0].offset); - - hours = offset / SECSPERHOUR; - offset = offset % SECSPERHOUR; - - mins = offset / SECSPERMIN; - secs = offset % SECSPERMIN; - - res->tm_sec -= secs; - res->tm_min -= mins; - res->tm_hour -= hours; - - if (res->tm_sec >= SECSPERMIN) - { - res->tm_min += 1; - res->tm_sec -= SECSPERMIN; - } - else if (res->tm_sec < 0) - { - res->tm_min -= 1; - res->tm_sec += SECSPERMIN; - } - if (res->tm_min >= MINSPERHOUR) - { - res->tm_hour += 1; - res->tm_min -= MINSPERHOUR; - } - else if (res->tm_min < 0) - { - res->tm_hour -= 1; - res->tm_min += MINSPERHOUR; - } - if (res->tm_hour >= HOURSPERDAY) - { - ++res->tm_yday; - ++res->tm_wday; - if (res->tm_wday > 6) - res->tm_wday = 0; - ++res->tm_mday; - res->tm_hour -= HOURSPERDAY; - if (res->tm_mday >= ip[res->tm_mon]) - { - res->tm_mday -= ip[res->tm_mon] - 1; - res->tm_mon += 1; - if (res->tm_mon == 12) - { - res->tm_mon = 0; - res->tm_year += 1; - res->tm_yday = 0; - } - } - } - else if (res->tm_hour < 0) - { - res->tm_yday -= 1; - res->tm_wday -= 1; - if (res->tm_wday < 0) - res->tm_wday = 6; - res->tm_mday -= 1; - res->tm_hour += 24; - if (res->tm_mday == 0) - { - res->tm_mon -= 1; - if (res->tm_mon < 0) - { - res->tm_mon = 11; - res->tm_year -= 1; - res->tm_yday = 365 + isleap(res->tm_year); - } - res->tm_mday = ip[res->tm_mon]; - } - } - TZ_UNLOCK; - } - else - res->tm_isdst = 0; - - return (res); -} - -int -_DEFUN (__tzcalc_limits, (year), - int year) -{ - int days, year_days, years; - int i, j; - - if (year < EPOCH_YEAR) - return 0; - - __tzyear = year; - - years = (year - EPOCH_YEAR); - - year_days = years * 365 + - (years - 1 + EPOCH_YEARS_SINCE_LEAP) / 4 - (years - 1 + EPOCH_YEARS_SINCE_CENTURY) / 100 + - (years - 1 + EPOCH_YEARS_SINCE_LEAP_CENTURY) / 400; - - for (i = 0; i < 2; ++i) - { - if (__tzrule[i].ch == 'J') - days = year_days + __tzrule[i].d + (isleap(year) && __tzrule[i].d >= 60); - else if (__tzrule[i].ch == 'D') - days = year_days + __tzrule[i].d; - else - { - int yleap = isleap(year); - int m_day, m_wday, wday_diff; - _CONST int *ip = mon_lengths[yleap]; - - days = year_days; - - for (j = 1; j < __tzrule[i].m; ++j) - days += ip[j-1]; - - m_wday = (EPOCH_WDAY + days) % DAYSPERWEEK; - - wday_diff = __tzrule[i].d - m_wday; - if (wday_diff < 0) - wday_diff += DAYSPERWEEK; - m_day = (__tzrule[i].n - 1) * DAYSPERWEEK + wday_diff; - - while (m_day >= ip[j]) - m_day -= DAYSPERWEEK; - - days += m_day; - } - - /* store the change-over time in GMT form by adding offset */ - __tzrule[i].change = days * SECSPERDAY + __tzrule[i].s + __tzrule[i].offset; - } - - __tznorth = (__tzrule[0].change < __tzrule[1].change); - - return 1; -} - diff --git a/newlib/libc/time/strftime.c b/newlib/libc/time/strftime.c deleted file mode 100644 index 9c115b62d..000000000 --- a/newlib/libc/time/strftime.c +++ /dev/null @@ -1,476 +0,0 @@ -/* - * strftime.c - * Original Author: G. Haley - * - * Places characters into the array pointed to by s as controlled by the string - * pointed to by format. If the total number of resulting characters including - * the terminating null character is not more than maxsize, returns the number - * of characters placed into the array pointed to by s (not including the - * terminating null character); otherwise zero is returned and the contents of - * the array indeterminate. - */ - -/* -FUNCTION -<<strftime>>---flexible calendar time formatter - -INDEX - strftime - -ANSI_SYNOPSIS - #include <time.h> - size_t strftime(char *<[s]>, size_t <[maxsize]>, - const char *<[format]>, const struct tm *<[timp]>); - -TRAD_SYNOPSIS - #include <time.h> - size_t strftime(<[s]>, <[maxsize]>, <[format]>, <[timp]>) - char *<[s]>; - size_t <[maxsize]>; - char *<[format]>; - struct tm *<[timp]>; - -DESCRIPTION -<<strftime>> converts a <<struct tm>> representation of the time (at -<[timp]>) into a string, starting at <[s]> and occupying no more than -<[maxsize]> characters. - -You control the format of the output using the string at <[format]>. -<<*<[format]>>> can contain two kinds of specifications: text to be -copied literally into the formatted string, and time conversion -specifications. Time conversion specifications are two-character -sequences beginning with `<<%>>' (use `<<%%>>' to include a percent -sign in the output). Each defined conversion specification selects a -field of calendar time data from <<*<[timp]>>>, and converts it to a -string in one of the following ways: - -o+ -o %a -An abbreviation for the day of the week. - -o %A -The full name for the day of the week. - -o %b -An abbreviation for the month name. - -o %B -The full name of the month. - -o %c -A string representing the complete date and time, in the form -. Mon Apr 01 13:13:13 1992 - -o %d -The day of the month, formatted with two digits. - -o %e -The day of the month, formatted with leading space if single digit. - -o %H -The hour (on a 24-hour clock), formatted with two digits. - -o %I -The hour (on a 12-hour clock), formatted with two digits. - -o %j -The count of days in the year, formatted with three digits -(from `<<001>>' to `<<366>>'). - -o %m -The month number, formatted with two digits. - -o %M -The minute, formatted with two digits. - -o %p -Either `<<AM>>' or `<<PM>>' as appropriate. - -o %S -The second, formatted with two digits. - -o %U -The week number, formatted with two digits (from `<<00>>' to `<<53>>'; -week number 1 is taken as beginning with the first Sunday in a year). -See also <<%W>>. - -o %w -A single digit representing the day of the week: Sunday is day <<0>>. - -o %W -Another version of the week number: like `<<%U>>', but counting week 1 -as beginning with the first Monday in a year. - -o -o %x -A string representing the complete date, in a format like -. Mon Apr 01 1992 - -o %X -A string representing the full time of day (hours, minutes, and -seconds), in a format like -. 13:13:13 - -o %y -The last two digits of the year. - -o %Y -The full year, formatted with four digits to include the century. - -o %Z -The time zone name. If tm_isdst is -1, no output is generated. -Otherwise, the time zone name based on the TZ environment variable -is used. - -o %% -A single character, `<<%>>'. -o- - -RETURNS -When the formatted time takes up no more than <[maxsize]> characters, -the result is the length of the formatted string. Otherwise, if the -formatting operation was abandoned due to lack of room, the result is -<<0>>, and the string starting at <[s]> corresponds to just those -parts of <<*<[format]>>> that could be completely filled in within the -<[maxsize]> limit. - -PORTABILITY -ANSI C requires <<strftime>>, but does not specify the contents of -<<*<[s]>>> when the formatted string would require more than -<[maxsize]> characters. - -<<strftime>> requires no supporting OS subroutines. -*/ - -#include <stddef.h> -#include <stdio.h> -#include <time.h> -#include "local.h" - -static _CONST int dname_len[7] = -{6, 6, 7, 9, 8, 6, 8}; - -static _CONST char *_CONST dname[7] = -{"Sunday", "Monday", "Tuesday", "Wednesday", - "Thursday", "Friday", "Saturday"}; - -static _CONST int mname_len[12] = -{7, 8, 5, 5, 3, 4, 4, 6, 9, 7, 8, 8}; - -static _CONST char *_CONST mname[12] = -{"January", "February", "March", "April", - "May", "June", "July", "August", "September", "October", "November", - "December"}; - -size_t -_DEFUN (strftime, (s, maxsize, format, tim_p), - char *s _AND - size_t maxsize _AND - _CONST char *format _AND - _CONST struct tm *tim_p) -{ - size_t count = 0; - int i; - - for (;;) - { - while (*format && *format != '%') - { - if (count < maxsize - 1) - s[count++] = *format++; - else - return 0; - } - - if (*format == '\0') - break; - - format++; - switch (*format) - { - case 'a': - for (i = 0; i < 3; i++) - { - if (count < maxsize - 1) - s[count++] = - dname[tim_p->tm_wday][i]; - else - return 0; - } - break; - case 'A': - for (i = 0; i < dname_len[tim_p->tm_wday]; i++) - { - if (count < maxsize - 1) - s[count++] = - dname[tim_p->tm_wday][i]; - else - return 0; - } - break; - case 'b': - for (i = 0; i < 3; i++) - { - if (count < maxsize - 1) - s[count++] = - mname[tim_p->tm_mon][i]; - else - return 0; - } - break; - case 'B': - for (i = 0; i < mname_len[tim_p->tm_mon]; i++) - { - if (count < maxsize - 1) - s[count++] = - mname[tim_p->tm_mon][i]; - else - return 0; - } - break; - case 'c': - if (count < maxsize - 24) - { - for (i = 0; i < 3; i++) - s[count++] = - dname[tim_p->tm_wday][i]; - s[count++] = ' '; - for (i = 0; i < 3; i++) - s[count++] = - mname[tim_p->tm_mon][i]; - - sprintf (&s[count], - " %.2d %2.2d:%2.2d:%2.2d %.4d", - tim_p->tm_mday, tim_p->tm_hour, - tim_p->tm_min, - tim_p->tm_sec, 1900 + - tim_p->tm_year); - count += 17; - } - else - return 0; - break; - case 'd': - if (count < maxsize - 2) - { - sprintf (&s[count], "%.2d", - tim_p->tm_mday); - count += 2; - } - else - return 0; - break; - case 'e': - if (count < maxsize - 2) - { - sprintf (&s[count], "%2d", - tim_p->tm_mday); - count += 2; - } - else - return 0; - break; - case 'H': - if (count < maxsize - 2) - { - sprintf (&s[count], "%2.2d", - tim_p->tm_hour); - count += 2; - } - else - return 0; - break; - case 'I': - if (count < maxsize - 2) - { - if (tim_p->tm_hour == 0 || - tim_p->tm_hour == 12) - { - s[count++] = '1'; - s[count++] = '2'; - } - else - { - sprintf (&s[count], "%.2d", - tim_p->tm_hour % 12); - count += 2; - } - } - else - return 0; - break; - case 'j': - if (count < maxsize - 3) - { - sprintf (&s[count], "%.3d", - tim_p->tm_yday + 1); - count += 3; - } - else - return 0; - break; - case 'm': - if (count < maxsize - 2) - { - sprintf (&s[count], "%.2d", - tim_p->tm_mon + 1); - count += 2; - } - else - return 0; - break; - case 'M': - if (count < maxsize - 2) - { - sprintf (&s[count], "%2.2d", - tim_p->tm_min); - count += 2; - } - else - return 0; - break; - case 'p': - if (count < maxsize - 2) - { - if (tim_p->tm_hour < 12) - s[count++] = 'A'; - else - s[count++] = 'P'; - - s[count++] = 'M'; - } - else - return 0; - break; - case 'S': - if (count < maxsize - 2) - { - sprintf (&s[count], "%2.2d", - tim_p->tm_sec); - count += 2; - } - else - return 0; - break; - case 'U': - if (count < maxsize - 2) - { - sprintf (&s[count], "%2.2d", - (tim_p->tm_yday + 7 - - tim_p->tm_wday) / 7); - count += 2; - } - else - return 0; - break; - case 'w': - if (count < maxsize - 1) - { - sprintf (&s[count], "%1.1d", - tim_p->tm_wday); - count++; - } - else - return 0; - break; - case 'W': - if (count < maxsize - 2) - { - int wday = (tim_p->tm_wday) ? tim_p->tm_wday - 1 : 6; - sprintf (&s[count], "%2.2d", - (tim_p->tm_yday + 7 - - wday) / 7); - count += 2; - } - else - return 0; - break; - case 'x': - if (count < maxsize - 15) - { - for (i = 0; i < 3; i++) - s[count++] = - dname[tim_p->tm_wday][i]; - s[count++] = ' '; - for (i = 0; i < 3; i++) - s[count++] = - mname[tim_p->tm_mon][i]; - - sprintf (&s[count], - " %.2d %.4d", tim_p->tm_mday, - 1900 + tim_p->tm_year); - count += 8; - } - else - return 0; - break; - case 'X': - if (count < maxsize - 8) - { - sprintf (&s[count], - "%2.2d:%2.2d:%2.2d", - tim_p->tm_hour, tim_p->tm_min, - tim_p->tm_sec); - count += 8; - } - else - return 0; - break; - case 'y': - if (count < maxsize - 2) - { - /* The year could be greater than 100, so we need the value - modulo 100. The year could be negative, so we need to - correct for a possible negative remainder. */ - sprintf (&s[count], "%2.2d", - (tim_p->tm_year % 100 + 100) % 100); - count += 2; - } - else - return 0; - break; - case 'Y': - if (count < maxsize - 4) - { - sprintf (&s[count], "%.4d", - 1900 + tim_p->tm_year); - count += 4; - } - else - return 0; - break; - case 'Z': - if (tim_p->tm_isdst >= 0) - { - int size; - TZ_LOCK; - size = strlen(_tzname[tim_p->tm_isdst]); - for (i = 0; i < size; i++) - { - if (count < maxsize - 1) - s[count++] = _tzname[tim_p->tm_isdst][i]; - else - { - TZ_UNLOCK; - return 0; - } - } - TZ_UNLOCK; - } - break; - case '%': - if (count < maxsize - 1) - s[count++] = '%'; - else - return 0; - break; - } - if (*format) - format++; - else - break; - } - s[count] = '\0'; - - return count; -} diff --git a/newlib/libc/time/strptime.c b/newlib/libc/time/strptime.c deleted file mode 100644 index 929ad9211..000000000 --- a/newlib/libc/time/strptime.c +++ /dev/null @@ -1,438 +0,0 @@ -/* - * Copyright (c) 1999 Kungliga Tekniska Högskolan - * (Royal Institute of Technology, Stockholm, Sweden). - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of KTH nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY KTH AND ITS CONTRIBUTORS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KTH OR ITS CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include <stddef.h> -#include <stdio.h> -#include <time.h> - -static const char *abb_weekdays[] = { - "Sun", - "Mon", - "Tue", - "Wed", - "Thu", - "Fri", - "Sat", - NULL -}; - -static const char *full_weekdays[] = { - "Sunday", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", - NULL -}; - -static const char *abb_month[] = { - "Jan", - "Feb", - "Mar", - "Apr", - "May", - "Jun", - "Jul", - "Aug", - "Sep", - "Oct", - "Nov", - "Dec", - NULL -}; - -static const char *full_month[] = { - "January", - "February", - "Mars", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December", - NULL, -}; - -static const char *ampm[] = { - "am", - "pm", - NULL -}; - -/* - * tm_year is relative this year - */ -const int tm_year_base = 1900; - -/* - * Return TRUE iff `year' was a leap year. - * Needed for strptime. - */ -static int -is_leap_year (int year) -{ - return (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0); -} - -/* Needed for strptime. */ -static int -match_string (const char **buf, const char **strs) -{ - int i = 0; - - for (i = 0; strs[i] != NULL; ++i) { - int len = strlen (strs[i]); - - if (strncasecmp (*buf, strs[i], len) == 0) { - *buf += len; - return i; - } - } - return -1; -} - -/* Needed for strptime. */ -static int -first_day (int year) -{ - int ret = 4; - - for (; year > 1970; --year) - ret = (ret + 365 + is_leap_year (year) ? 1 : 0) % 7; - return ret; -} - -/* - * Set `timeptr' given `wnum' (week number [0, 53]) - * Needed for strptime - */ - -static void -set_week_number_sun (struct tm *timeptr, int wnum) -{ - int fday = first_day (timeptr->tm_year + tm_year_base); - - timeptr->tm_yday = wnum * 7 + timeptr->tm_wday - fday; - if (timeptr->tm_yday < 0) { - timeptr->tm_wday = fday; - timeptr->tm_yday = 0; - } -} - -/* - * Set `timeptr' given `wnum' (week number [0, 53]) - * Needed for strptime - */ - -static void -set_week_number_mon (struct tm *timeptr, int wnum) -{ - int fday = (first_day (timeptr->tm_year + tm_year_base) + 6) % 7; - - timeptr->tm_yday = wnum * 7 + (timeptr->tm_wday + 6) % 7 - fday; - if (timeptr->tm_yday < 0) { - timeptr->tm_wday = (fday + 1) % 7; - timeptr->tm_yday = 0; - } -} - -/* - * Set `timeptr' given `wnum' (week number [0, 53]) - * Needed for strptime - */ -static void -set_week_number_mon4 (struct tm *timeptr, int wnum) -{ - int fday = (first_day (timeptr->tm_year + tm_year_base) + 6) % 7; - int offset = 0; - - if (fday < 4) - offset += 7; - - timeptr->tm_yday = offset + (wnum - 1) * 7 + timeptr->tm_wday - fday; - if (timeptr->tm_yday < 0) { - timeptr->tm_wday = fday; - timeptr->tm_yday = 0; - } -} - -/* strptime: roken */ -//extern "C" -char * -//strptime (const char *buf, const char *format, struct tm *timeptr) -_DEFUN (strptime, (buf, format, timeptr), - _CONST char *buf _AND - _CONST char *format _AND - struct tm *timeptr) -{ - char c; - - for (; (c = *format) != '\0'; ++format) { - char *s; - int ret; - - if (isspace (c)) { - while (isspace (*buf)) - ++buf; - } else if (c == '%' && format[1] != '\0') { - c = *++format; - if (c == 'E' || c == 'O') - c = *++format; - switch (c) { - case 'A' : - ret = match_string (&buf, full_weekdays); - if (ret < 0) - return NULL; - timeptr->tm_wday = ret; - break; - case 'a' : - ret = match_string (&buf, abb_weekdays); - if (ret < 0) - return NULL; - timeptr->tm_wday = ret; - break; - case 'B' : - ret = match_string (&buf, full_month); - if (ret < 0) - return NULL; - timeptr->tm_mon = ret; - break; - case 'b' : - case 'h' : - ret = match_string (&buf, abb_month); - if (ret < 0) - return NULL; - timeptr->tm_mon = ret; - break; - case 'C' : - ret = strtol (buf, &s, 10); - if (s == buf) - return NULL; - timeptr->tm_year = (ret * 100) - tm_year_base; - buf = s; - break; - case 'c' : - abort (); - case 'D' : /* %m/%d/%y */ - s = strptime (buf, "%m/%d/%y", timeptr); - if (s == NULL) - return NULL; - buf = s; - break; - case 'd' : - case 'e' : - ret = strtol (buf, &s, 10); - if (s == buf) - return NULL; - timeptr->tm_mday = ret; - buf = s; - break; - case 'H' : - case 'k' : - ret = strtol (buf, &s, 10); - if (s == buf) - return NULL; - timeptr->tm_hour = ret; - buf = s; - break; - case 'I' : - case 'l' : - ret = strtol (buf, &s, 10); - if (s == buf) - return NULL; - if (ret == 12) - timeptr->tm_hour = 0; - else - timeptr->tm_hour = ret; - buf = s; - break; - case 'j' : - ret = strtol (buf, &s, 10); - if (s == buf) - return NULL; - timeptr->tm_yday = ret - 1; - buf = s; - break; - case 'm' : - ret = strtol (buf, &s, 10); - if (s == buf) - return NULL; - timeptr->tm_mon = ret - 1; - buf = s; - break; - case 'M' : - ret = strtol (buf, &s, 10); - if (s == buf) - return NULL; - timeptr->tm_min = ret; - buf = s; - break; - case 'n' : - if (*buf == '\n') - ++buf; - else - return NULL; - break; - case 'p' : - ret = match_string (&buf, ampm); - if (ret < 0) - return NULL; - if (timeptr->tm_hour == 0) { - if (ret == 1) - timeptr->tm_hour = 12; - } else - timeptr->tm_hour += 12; - break; - case 'r' : /* %I:%M:%S %p */ - s = strptime (buf, "%I:%M:%S %p", timeptr); - if (s == NULL) - return NULL; - buf = s; - break; - case 'R' : /* %H:%M */ - s = strptime (buf, "%H:%M", timeptr); - if (s == NULL) - return NULL; - buf = s; - break; - case 'S' : - ret = strtol (buf, &s, 10); - if (s == buf) - return NULL; - timeptr->tm_sec = ret; - buf = s; - break; - case 't' : - if (*buf == '\t') - ++buf; - else - return NULL; - break; - case 'T' : /* %H:%M:%S */ - case 'X' : - s = strptime (buf, "%H:%M:%S", timeptr); - if (s == NULL) - return NULL; - buf = s; - break; - case 'u' : - ret = strtol (buf, &s, 10); - if (s == buf) - return NULL; - timeptr->tm_wday = ret - 1; - buf = s; - break; - case 'w' : - ret = strtol (buf, &s, 10); - if (s == buf) - return NULL; - timeptr->tm_wday = ret; - buf = s; - break; - case 'U' : - ret = strtol (buf, &s, 10); - if (s == buf) - return NULL; - set_week_number_sun (timeptr, ret); - buf = s; - break; - case 'V' : - ret = strtol (buf, &s, 10); - if (s == buf) - return NULL; - set_week_number_mon4 (timeptr, ret); - buf = s; - break; - case 'W' : - ret = strtol (buf, &s, 10); - if (s == buf) - return NULL; - set_week_number_mon (timeptr, ret); - buf = s; - break; - case 'x' : - s = strptime (buf, "%Y:%m:%d", timeptr); - if (s == NULL) - return NULL; - buf = s; - break; - case 'y' : - ret = strtol (buf, &s, 10); - if (s == buf) - return NULL; - if (ret < 70) - timeptr->tm_year = 100 + ret; - else - timeptr->tm_year = ret; - buf = s; - break; - case 'Y' : - ret = strtol (buf, &s, 10); - if (s == buf) - return NULL; - timeptr->tm_year = ret - tm_year_base; - buf = s; - break; - case 'Z' : - abort (); - case '\0' : - --format; - /* FALLTHROUGH */ - case '%' : - if (*buf == '%') - ++buf; - else - return NULL; - break; - default : - if (*buf == '%' || *++buf == c) - ++buf; - else - return NULL; - break; - } - } else { - if (*buf == c) - ++buf; - else - return NULL; - } - } - return (char *)buf; -} - diff --git a/newlib/libc/time/time.c b/newlib/libc/time/time.c deleted file mode 100644 index 38cce50f9..000000000 --- a/newlib/libc/time/time.c +++ /dev/null @@ -1,59 +0,0 @@ -/* FIXME: doc says "not avail" due to #if 0. - DELETE that line if inappropriate! */ -/* -FUNCTION -<<time>>---get current calendar time (as single number) - -INDEX - time - -ANSI_SYNOPSIS - #include <time.h> - time_t time(time_t *<[t]>); - -TRAD_SYNOPSIS - #include <time.h> - time_t time(<[t]>) - time_t *<[t]>; - -DESCRIPTION -<<time>> looks up the best available representation of the current -time and returns it, encoded as a <<time_t>>. It stores the same -value at <[t]> unless the argument is <<NULL>>. - -RETURNS -A <<-1>> result means the current time is not available; otherwise the -result represents the current time. - -PORTABILITY -ANSI C requires <<time>>. - -Supporting OS subroutine required: Some implementations require -<<gettimeofday>>. -*/ - -#ifdef HAVE_GETTIMEOFDAY - -/* Most times we have a system call in newlib/libc/sys/.. to do this job */ - -#include <_ansi.h> -#include <reent.h> -#include <sys/types.h> -#include <sys/time.h> - -time_t -_DEFUN (time, (t), - time_t * t) -{ - struct timeval now; - - if (_gettimeofday_r (_REENT, &now, (struct timezone *) 0) >= 0) - { - if (t) - *t = now.tv_sec; - return now.tv_sec; - } - return -1; -} - -#endif diff --git a/newlib/libc/time/time.tex b/newlib/libc/time/time.tex deleted file mode 100644 index ace08b036..000000000 --- a/newlib/libc/time/time.tex +++ /dev/null @@ -1,90 +0,0 @@ -@node Timefns -@chapter Time Functions (@file{time.h}) - -This chapter groups functions used either for reporting on time -(elapsed, current, or compute time) or to perform calculations based -on time. - -The header file @file{time.h} defines three types. @code{clock_t} and -@code{time_t} are both used for representations of time particularly -suitable for arithmetic. (In this implementation, quantities of type -@code{clock_t} have the highest resolution possible on your machine, -and quantities of type @code{time_t} resolve to seconds.) @code{size_t} -is also defined if necessary for quantities representing sizes. - -@file{time.h} also defines the structure @code{tm} for the traditional -representation of Gregorian calendar time as a series of numbers, with -the following fields: - -@table @code -@item tm_sec -Seconds. - -@item tm_min -Minutes. - -@item tm_hour -Hours. - -@item tm_mday -Day. - -@item tm_mon -Month. - -@item tm_year -Year (since 1900). - -@item tm_wday -Day of week: the number of days since Sunday. - -@item tm_yday -Number of days elapsed since last January 1. - -@item tm_isdst -Daylight Savings Time flag: positive means DST in effect, zero means DST -not in effect, negative means no information about DST is available. -@end table - -@menu -* asctime:: Format time as string -* clock:: Cumulative processor time -* ctime:: Convert time to local and format as string -* difftime:: Subtract two times -* gmtime:: Convert time to UTC (GMT) traditional representation -* localtime:: Convert time to local representation -* mktime:: Convert time to arithmetic representation -* strftime:: Flexible calendar time formatter -* time:: Get current calendar time (as single number) -* tzset:: Set timezone info -@end menu - -@page -@include time/asctime.def - -@page -@include time/clock.def - -@page -@include time/ctime.def - -@page -@include time/difftime.def - -@page -@include time/gmtime.def - -@page -@include time/lcltime.def - -@page -@include time/mktime.def - -@page -@include time/strftime.def - -@page -@include time/time.def - -@page -@include time/tzset.def diff --git a/newlib/libc/time/tzlock.c b/newlib/libc/time/tzlock.c deleted file mode 100644 index 66fa1c366..000000000 --- a/newlib/libc/time/tzlock.c +++ /dev/null @@ -1,44 +0,0 @@ -/* -FUNCTION -<<__tz_lock>>, <<__tz_unlock>>--lock time zone global variables - -INDEX - __tz_lock -INDEX - __tz_unlock - -ANSI_SYNOPSIS - #include "local.h" - void __tz_lock (void); - void __tz_unlock (void); - -TRAD_SYNOPSIS - void __tz_lock(); - void __tz_unlock(); - -DESCRIPTION -The <<tzset>> facility functions call these functions when they need -to ensure the values of global variables. The version of these routines supplied -in the library do not do anything. If multiple threads of execution -can call the time functions and give up scheduling in the middle, then you -you need to define your own versions of these functions in order to -safely lock the time zone variables during a call. If you do not, the results -of <<localtime>>, <<mktime>>, <<ctime>>, and <<strftime>> are undefined. - -The lock <<__tz_lock>> may not be called recursively; that is, -a call <<__tz_lock>> will always lock all subsequent <<__tz_lock>> calls -until the corresponding <<__tz_unlock>> call on the same thread is made. -*/ - -#include <_ansi.h> -#include "local.h" - -_VOID -_DEFUN_VOID (__tz_lock) -{ -} - -_VOID -_DEFUN_VOID (__tz_unlock) -{ -} diff --git a/newlib/libc/time/tzset.c b/newlib/libc/time/tzset.c deleted file mode 100644 index c70e3ee6e..000000000 --- a/newlib/libc/time/tzset.c +++ /dev/null @@ -1,72 +0,0 @@ -/* -FUNCTION -<<tzset>>---set timezone characteristics from TZ environment variable - -INDEX - tzset - -ANSI_SYNOPSIS - #include <time.h> - void tzset(void); - void _tzset_r (struct _reent *); - -TRAD_SYNOPSIS - #include <time.h> - void tzset(); - void _tzset_r (reent_ptr) - struct _reent *reent_ptr; - -DESCRIPTION -<<tzset>> examines the TZ environment variable and sets up the three -external variables: <<_timezone>>, <<_daylight>>, and <<tzname>>. The -value of <<_timezone>> shall be the offset from the current time zone -to GMT. The value of <<_daylight>> shall be 0 if there is no daylight -savings time for the current time zone, otherwise it will be non-zero. -The <<tzname>> array has two entries: the first is the name of the -standard time zone, the second is the name of the daylight-savings time -zone. - -The TZ environment variable is expected to be in the following POSIX -format: - - stdoffset1[dst[offset2][,start[/time1],end[/time2]]] - -where: std is the name of the standard time-zone (minimum 3 chars) - offset1 is the value to add to local time to arrive at Universal time - it has the form: hh[:mm[:ss]] - dst is the name of the alternate (daylight-savings) time-zone (min 3 chars) - offset2 is the value to add to local time to arrive at Universal time - it has the same format as the std offset - start is the day that the alternate time-zone starts - time1 is the optional time that the alternate time-zone starts - (this is in local time and defaults to 02:00:00 if not specified) - end is the day that the alternate time-zone ends - time2 is the time that the alternate time-zone ends - (it is in local time and defaults to 02:00:00 if not specified) - -Note that there is no white-space padding between fields. Also note that -if TZ is null, the default is Universal GMT which has no daylight-savings -time. If TZ is empty, the default EST5EDT is used. - -The function <<_tzset_r>> is identical to <<tzset>> only it is reentrant -and is used for applications that use multiple threads. - -RETURNS -There is no return value. - -PORTABILITY -<<tzset>> is part of the POSIX standard. - -Supporting OS subroutine required: None -*/ - -#include <_ansi.h> -#include <reent.h> -#include <time.h> -#include "local.h" - -_VOID -_DEFUN_VOID (tzset) -{ - _tzset_r (_REENT); -} diff --git a/newlib/libc/time/tzset_r.c b/newlib/libc/time/tzset_r.c deleted file mode 100644 index 9469028a4..000000000 --- a/newlib/libc/time/tzset_r.c +++ /dev/null @@ -1,206 +0,0 @@ -#include <_ansi.h> -#include <reent.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/time.h> -#include "local.h" - -static char __tzname_std[11]; -static char __tzname_dst[11]; -static char *prev_tzenv = NULL; - -/* default to GMT */ -char *_tzname[2] = {"GMT" "GMT"}; -int _daylight = 0; -time_t _timezone = (time_t)0; - -int __tzyear = 0; - -int __tznorth = 1; - -__tzrule_type __tzrule[2] = { {'J', 0, 0, 0, 0, (time_t)0, 0 }, - {'J', 0, 0, 0, 0, (time_t)0, 0 } }; - -_VOID -_DEFUN (_tzset_r, (reent_ptr), - struct _reent *reent_ptr) -{ - char *tzenv; - int hh, mm, ss, sign, m, w, d, n; - int i, ch; - - if ((tzenv = _getenv_r (reent_ptr, "TZ")) == NULL) - { - TZ_LOCK; - _timezone = (time_t)0; - _daylight = 0; - _tzname[0] = "GMT"; - _tzname[1] = "GMT"; - TZ_UNLOCK; - return; - } - - TZ_LOCK; - - if (prev_tzenv != NULL && strcmp(tzenv, prev_tzenv) == 0) - { - TZ_UNLOCK; - return; - } - - free(prev_tzenv); - prev_tzenv = _malloc_r (reent_ptr, strlen(tzenv) + 1); - if (prev_tzenv != NULL) - strcpy (prev_tzenv, tzenv); - - /* ignore implementation-specific format specifier */ - if (*tzenv == ':') - ++tzenv; - - if (sscanf (tzenv, "%10[^0-9,+-]%n", __tzname_std, &n) <= 0) - { - TZ_UNLOCK; - return; - } - - tzenv += n; - - sign = 1; - if (*tzenv == '-') - { - sign = -1; - ++tzenv; - } - else if (*tzenv == '+') - ++tzenv; - - mm = 0; - ss = 0; - - if (sscanf (tzenv, "%hu%n:%hu%n:%hu%n", &hh, &n, &mm, &n, &ss, &n) < 1) - { - TZ_UNLOCK; - return; - } - - __tzrule[0].offset = sign * (ss + SECSPERMIN * mm + SECSPERHOUR * hh); - _tzname[0] = __tzname_std; - tzenv += n; - - if (sscanf (tzenv, "%10[^0-9,+-]%n", __tzname_dst, &n) <= 0) - { - _tzname[1] = _tzname[0]; - TZ_UNLOCK; - return; - } - else - _tzname[1] = __tzname_dst; - - tzenv += n; - - /* otherwise we have a dst name, look for the offset */ - sign = 1; - if (*tzenv == '-') - { - sign = -1; - ++tzenv; - } - else if (*tzenv == '+') - ++tzenv; - - hh = 0; - mm = 0; - ss = 0; - - if (sscanf (tzenv, "%hu%n:%hu%n:%hu%n", &hh, &n, &mm, &n, &ss, &n) <= 0) - __tzrule[1].offset = __tzrule[0].offset - 3600; - else - __tzrule[1].offset = sign * (ss + SECSPERMIN * mm + SECSPERHOUR * hh); - - tzenv += n; - - if (*tzenv == ',') - ++tzenv; - - for (i = 0; i < 2; ++i) - { - if (*tzenv == 'M') - { - if (sscanf (tzenv, "M%hu%n.%hu%n.%hu%n", &m, &n, &w, &n, &d, &n) != 3 || - m < 1 || m > 12 || w < 1 || w > 5 || d > 6) - { - TZ_UNLOCK; - return; - } - - __tzrule[i].ch = 'M'; - __tzrule[i].m = m; - __tzrule[i].n = w; - __tzrule[i].d = d; - - tzenv += n; - } - else - { - char *end; - if (*tzenv == 'J') - { - ch = 'J'; - ++tzenv; - } - else - ch = 'D'; - - d = strtoul (tzenv, &end, 10); - - /* if unspecified, default to US settings */ - if (end == tzenv) - { - if (i == 0) - { - __tzrule[0].ch = 'M'; - __tzrule[0].m = 4; - __tzrule[0].n = 1; - __tzrule[0].d = 0; - } - else - { - __tzrule[1].ch = 'M'; - __tzrule[1].m = 10; - __tzrule[1].n = 5; - __tzrule[1].d = 0; - } - } - else - { - __tzrule[i].ch = ch; - __tzrule[i].d = d; - } - - tzenv = end; - } - - /* default time is 02:00:00 am */ - hh = 2; - mm = 0; - ss = 0; - - if (*tzenv == '/') - sscanf (tzenv, "%hu%n:%hu%n:%hu%n", &hh, &n, &mm, &n, &ss, &n); - - __tzrule[i].s = ss + SECSPERMIN * mm + SECSPERHOUR * hh; - } - - __tzcalc_limits (__tzyear); - _timezone = (time_t)(__tzrule[0].offset); - _daylight = __tzrule[0].offset != __tzrule[1].offset; - - TZ_UNLOCK; -} - - - - - |