summaryrefslogtreecommitdiffstats
path: root/libc/misc/time
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc/time')
-rw-r--r--libc/misc/time/Makefile.in67
-rw-r--r--libc/misc/time/__time_tm.c8
-rw-r--r--libc/misc/time/_time_localtime_tzi.c8
-rw-r--r--libc/misc/time/_time_mktime.c8
-rw-r--r--libc/misc/time/_time_mktime_tzi.c8
-rw-r--r--libc/misc/time/_time_t2tm.c8
-rw-r--r--libc/misc/time/adjtime.c8
-rw-r--r--libc/misc/time/asctime.c8
-rw-r--r--libc/misc/time/asctime_r.c8
-rw-r--r--libc/misc/time/clock.c8
-rw-r--r--libc/misc/time/ctime.c8
-rw-r--r--libc/misc/time/ctime_r.c8
-rw-r--r--libc/misc/time/difftime.c8
-rw-r--r--libc/misc/time/dysize.c8
-rw-r--r--libc/misc/time/ftime.c4
-rw-r--r--libc/misc/time/gmtime.c8
-rw-r--r--libc/misc/time/gmtime_r.c8
-rw-r--r--libc/misc/time/localtime.c8
-rw-r--r--libc/misc/time/localtime_r.c8
-rw-r--r--libc/misc/time/mktime.c8
-rw-r--r--libc/misc/time/strftime.c8
-rw-r--r--libc/misc/time/strftime_l.c9
-rw-r--r--libc/misc/time/strptime.c8
-rw-r--r--libc/misc/time/strptime_l.c9
-rw-r--r--libc/misc/time/time.c253
-rw-r--r--libc/misc/time/timegm.c8
-rw-r--r--libc/misc/time/tzset.c8
-rw-r--r--libc/misc/time/wcsftime.c8
-rw-r--r--libc/misc/time/wcsftime_l.c9
29 files changed, 365 insertions, 170 deletions
diff --git a/libc/misc/time/Makefile.in b/libc/misc/time/Makefile.in
index b62032a25..b710b8b7c 100644
--- a/libc/misc/time/Makefile.in
+++ b/libc/misc/time/Makefile.in
@@ -1,73 +1,40 @@
# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-MSRC:=time.c
-MOBJ:= asctime.o asctime_r.o clock.o ctime.o ctime_r.o gmtime.o gmtime_r.o \
- localtime.o localtime_r.o mktime.o strftime.o strptime.o tzset.o \
- _time_t2tm.o __time_tm.o _time_mktime.o dysize.o timegm.o \
- _time_mktime_tzi.o _time_localtime_tzi.o
-MOBJx:=
+CSRC := adjtime.c ftime.c
+# multi source time.c
+CSRC += asctime.c asctime_r.c clock.c ctime.c ctime_r.c gmtime.c gmtime_r.c \
+ localtime.c localtime_r.c mktime.c strftime.c strptime.c tzset.c \
+ _time_t2tm.c __time_tm.c _time_mktime.c dysize.c timegm.c \
+ _time_mktime_tzi.c _time_localtime_tzi.c
ifeq ($(UCLIBC_HAS_FLOATS),y)
-MOBJ+=difftime.o
+CSRC += difftime.c
endif
ifeq ($(UCLIBC_HAS_XLOCALE),y)
-MOBJx:=strftime_l.o strptime_l.o
+CSRC += strftime_l.c strptime_l.c
endif
-
ifeq ($(UCLIBC_HAS_WCHAR),y)
-MOBJ+=wcsftime.o
+CSRC += wcsftime.c
ifeq ($(UCLIBC_HAS_XLOCALE),y)
-MOBJx+=wcsftime_l.o
+CSRC += wcsftime_l.c
endif
endif
-CSRC:=adjtime.c ftime.c
-
-MISC_TIME_DIR:=$(top_srcdir)libc/misc/time
-MISC_TIME_OUT:=$(top_builddir)libc/misc/time
-
-MISC_TIME_NO_MULTI:=strftime.o mktime.o strptime.o gmtime.o localtime.o asctime.o asctime_r.o gmtime_r.o localtime_r.o
-
-MISC_TIME_SRC:=$(patsubst %.c,$(MISC_TIME_DIR)/%.c,$(CSRC))
-MISC_TIME_OBJ:=$(patsubst %.c,$(MISC_TIME_OUT)/%.o,$(CSRC))
-
-MISC_TIME_MSRC:=$(patsubst %.c,$(MISC_TIME_DIR)/%.c,$(MSRC))
-MISC_TIME_MOBJ:=$(patsubst %.o,$(MISC_TIME_OUT)/%.o,$(MOBJ))
-MISC_TIME_MOBJx:=$(patsubst %.o,$(MISC_TIME_OUT)/%.o,$(MOBJx))
-
-MISC_TIME_DEF:=$(patsubst %,-DL_%,$(subst .o,,$(filter-out $(MISC_TIME_NO_MULTI),$(notdir $(MISC_TIME_MOBJ)))))
-
-MISC_TIME_OBJS:=$(MISC_TIME_OBJ) $(MISC_TIME_MOBJ)
-
-$(MISC_TIME_MOBJ): $(MISC_TIME_MSRC)
- $(compile.m)
-
-$(MISC_TIME_MOBJ:.o=.os): $(MISC_TIME_MSRC)
- $(compile.m)
-
-$(MISC_TIME_MOBJx): $(MISC_TIME_MSRC)
- $(compile.m) -D__UCLIBC_DO_XLOCALE
-
-$(MISC_TIME_MOBJx:.o=.os): $(MISC_TIME_MSRC)
- $(compile.m) -D__UCLIBC_DO_XLOCALE
+MISC_TIME_DIR := $(top_srcdir)libc/misc/time
+MISC_TIME_OUT := $(top_builddir)libc/misc/time
-libc-a-y+=$(MISC_TIME_OBJS)
-libc-a-$(UCLIBC_HAS_XLOCALE)+=$(MISC_TIME_MOBJx)
-libc-so-y+=$(MISC_TIME_OBJS:.o=.os)
-libc-so-$(UCLIBC_HAS_XLOCALE)+=$(MISC_TIME_MOBJx:.o=.os)
+MISC_TIME_SRC := $(patsubst %.c,$(MISC_TIME_DIR)/%.c,$(CSRC))
+MISC_TIME_OBJ := $(patsubst %.c,$(MISC_TIME_OUT)/%.o,$(CSRC))
-CFLAGS-multi-y+=$(MISC_TIME_DEF)
-libc-multi-y+=$(MISC_TIME_MSRC)
-libc-nomulti-y+=$(patsubst %.o,$(MISC_TIME_OUT)/%.o,$(MISC_TIME_NO_MULTI))
-libc-nomulti-$(UCLIBC_HAS_XLOCALE)+=$(MISC_TIME_MOBJx)
+libc-y += $(MISC_TIME_OBJ)
-objclean-y+=misc_time_objclean
+objclean-y += misc_time_objclean
misc_time_objclean:
$(RM) $(MISC_TIME_OUT)/*.{o,os}
diff --git a/libc/misc/time/__time_tm.c b/libc/misc/time/__time_tm.c
new file mode 100644
index 000000000..59b7d8aac
--- /dev/null
+++ b/libc/misc/time/__time_tm.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___time_tm
+#include "time.c"
diff --git a/libc/misc/time/_time_localtime_tzi.c b/libc/misc/time/_time_localtime_tzi.c
new file mode 100644
index 000000000..32728a491
--- /dev/null
+++ b/libc/misc/time/_time_localtime_tzi.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__time_localtime_tzi
+#include "time.c"
diff --git a/libc/misc/time/_time_mktime.c b/libc/misc/time/_time_mktime.c
new file mode 100644
index 000000000..1fd920020
--- /dev/null
+++ b/libc/misc/time/_time_mktime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__time_mktime
+#include "time.c"
diff --git a/libc/misc/time/_time_mktime_tzi.c b/libc/misc/time/_time_mktime_tzi.c
new file mode 100644
index 000000000..543893e6a
--- /dev/null
+++ b/libc/misc/time/_time_mktime_tzi.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__time_mktime_tzi
+#include "time.c"
diff --git a/libc/misc/time/_time_t2tm.c b/libc/misc/time/_time_t2tm.c
new file mode 100644
index 000000000..903651ffd
--- /dev/null
+++ b/libc/misc/time/_time_t2tm.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__time_t2tm
+#include "time.c"
diff --git a/libc/misc/time/adjtime.c b/libc/misc/time/adjtime.c
index fd33ff60d..cfa94339a 100644
--- a/libc/misc/time/adjtime.c
+++ b/libc/misc/time/adjtime.c
@@ -1,10 +1,16 @@
-#define adjtimex __adjtimex
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
#include <limits.h>
#include <sys/time.h>
#include <sys/timex.h>
#include <errno.h>
+libc_hidden_proto(adjtimex)
+
#define MAX_SEC (LONG_MAX / 1000000L - 2)
#define MIN_SEC (LONG_MIN / 1000000L + 2)
diff --git a/libc/misc/time/asctime.c b/libc/misc/time/asctime.c
new file mode 100644
index 000000000..d80c017a6
--- /dev/null
+++ b/libc/misc/time/asctime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_asctime
+#include "time.c"
diff --git a/libc/misc/time/asctime_r.c b/libc/misc/time/asctime_r.c
new file mode 100644
index 000000000..aec38b139
--- /dev/null
+++ b/libc/misc/time/asctime_r.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_asctime_r
+#include "time.c"
diff --git a/libc/misc/time/clock.c b/libc/misc/time/clock.c
new file mode 100644
index 000000000..9cc425412
--- /dev/null
+++ b/libc/misc/time/clock.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_clock
+#include "time.c"
diff --git a/libc/misc/time/ctime.c b/libc/misc/time/ctime.c
new file mode 100644
index 000000000..4bd09a8a9
--- /dev/null
+++ b/libc/misc/time/ctime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_ctime
+#include "time.c"
diff --git a/libc/misc/time/ctime_r.c b/libc/misc/time/ctime_r.c
new file mode 100644
index 000000000..c03f5c95d
--- /dev/null
+++ b/libc/misc/time/ctime_r.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_ctime_r
+#include "time.c"
diff --git a/libc/misc/time/difftime.c b/libc/misc/time/difftime.c
new file mode 100644
index 000000000..4bcec2c06
--- /dev/null
+++ b/libc/misc/time/difftime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_difftime
+#include "time.c"
diff --git a/libc/misc/time/dysize.c b/libc/misc/time/dysize.c
new file mode 100644
index 000000000..b1bf84b64
--- /dev/null
+++ b/libc/misc/time/dysize.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_dysize
+#include "time.c"
diff --git a/libc/misc/time/ftime.c b/libc/misc/time/ftime.c
index 904763241..233d6f70d 100644
--- a/libc/misc/time/ftime.c
+++ b/libc/misc/time/ftime.c
@@ -16,11 +16,11 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define gettimeofday __gettimeofday
-
#include <sys/timeb.h>
#include <sys/time.h>
+libc_hidden_proto(gettimeofday)
+
int ftime(timebuf)
struct timeb *timebuf;
{
diff --git a/libc/misc/time/gmtime.c b/libc/misc/time/gmtime.c
new file mode 100644
index 000000000..24a512c03
--- /dev/null
+++ b/libc/misc/time/gmtime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_gmtime
+#include "time.c"
diff --git a/libc/misc/time/gmtime_r.c b/libc/misc/time/gmtime_r.c
new file mode 100644
index 000000000..8677dd2d6
--- /dev/null
+++ b/libc/misc/time/gmtime_r.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_gmtime_r
+#include "time.c"
diff --git a/libc/misc/time/localtime.c b/libc/misc/time/localtime.c
new file mode 100644
index 000000000..e4bffbd2d
--- /dev/null
+++ b/libc/misc/time/localtime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_localtime
+#include "time.c"
diff --git a/libc/misc/time/localtime_r.c b/libc/misc/time/localtime_r.c
new file mode 100644
index 000000000..5351834b2
--- /dev/null
+++ b/libc/misc/time/localtime_r.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_localtime_r
+#include "time.c"
diff --git a/libc/misc/time/mktime.c b/libc/misc/time/mktime.c
new file mode 100644
index 000000000..2b2c8e459
--- /dev/null
+++ b/libc/misc/time/mktime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_mktime
+#include "time.c"
diff --git a/libc/misc/time/strftime.c b/libc/misc/time/strftime.c
new file mode 100644
index 000000000..2eb827dad
--- /dev/null
+++ b/libc/misc/time/strftime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strftime
+#include "time.c"
diff --git a/libc/misc/time/strftime_l.c b/libc/misc/time/strftime_l.c
new file mode 100644
index 000000000..e1d34ad4a
--- /dev/null
+++ b/libc/misc/time/strftime_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strftime_l
+#define __UCLIBC_DO_XLOCALE
+#include "time.c"
diff --git a/libc/misc/time/strptime.c b/libc/misc/time/strptime.c
new file mode 100644
index 000000000..771633fb6
--- /dev/null
+++ b/libc/misc/time/strptime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strptime
+#include "time.c"
diff --git a/libc/misc/time/strptime_l.c b/libc/misc/time/strptime_l.c
new file mode 100644
index 000000000..16ee7e1bd
--- /dev/null
+++ b/libc/misc/time/strptime_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strptime_l
+#define __UCLIBC_DO_XLOCALE
+#include "time.c"
diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c
index 74b38f99e..fb79883c9 100644
--- a/libc/misc/time/time.c
+++ b/libc/misc/time/time.c
@@ -129,49 +129,62 @@
* differs (intentionally) from glibc's behavior.
*/
-#define strnlen __strnlen
-#define gettimeofday __gettimeofday
-
-#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <time.h>
+#include <sys/time.h>
#include <limits.h>
#include <assert.h>
#include <errno.h>
#include <ctype.h>
#include <langinfo.h>
#include <locale.h>
+#include <fcntl.h>
+#include <unistd.h>
#include <bits/uClibc_uintmaxtostr.h>
-extern void __tzset (void) __THROW attribute_hidden;
-
-extern long int __strtol (__const char *__restrict __nptr,
- char **__restrict __endptr, int __base)
- __THROW __nonnull ((1)) __wur attribute_hidden;
-
-extern char *__nl_langinfo (nl_item __item) __THROW attribute_hidden;
-
+#ifdef __UCLIBC_HAS_WCHAR__
+#include <wchar.h>
+#endif
#ifdef __UCLIBC_HAS_XLOCALE__
#include <xlocale.h>
-extern long int __strtol_l (__const char *__restrict __nptr,
- char **__restrict __endptr, int __base,
- __locale_t __loc) __THROW __nonnull ((1, 4)) __wur attribute_hidden;
-extern int __strncasecmp_l (__const char *__s1, __const char *__s2,
- size_t __n, __locale_t __loc)
- __THROW __attribute_pure__ __nonnull ((1, 2, 4)) attribute_hidden;
-extern size_t __strftime_l (char *__restrict __s, size_t __maxsize,
- __const char *__restrict __format,
- __const struct tm *__restrict __tp,
- __locale_t __loc) __THROW attribute_hidden;
+#endif
-extern char *__strptime_l (__const char *__restrict __s,
- __const char *__restrict __fmt, struct tm *__tp,
- __locale_t __loc) __THROW attribute_hidden;
+libc_hidden_proto(asctime)
+libc_hidden_proto(asctime_r)
+libc_hidden_proto(ctime)
+libc_hidden_proto(localtime)
+libc_hidden_proto(localtime_r)
+
+libc_hidden_proto(memset)
+libc_hidden_proto(memcpy)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strcpy)
+libc_hidden_proto(strlen)
+libc_hidden_proto(strncpy)
+libc_hidden_proto(strnlen)
+/* libc_hidden_proto(sprintf) */
+libc_hidden_proto(open)
+libc_hidden_proto(read)
+libc_hidden_proto(close)
+libc_hidden_proto(getenv)
+libc_hidden_proto(tzset)
+libc_hidden_proto(gettimeofday)
+libc_hidden_proto(strncasecmp)
+libc_hidden_proto(strtol)
+libc_hidden_proto(strtoul)
+libc_hidden_proto(nl_langinfo)
-extern char *__nl_langinfo_l (nl_item __item, __locale_t l) attribute_hidden;
+#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(strncasecmp_l)
+libc_hidden_proto(strtol_l)
+libc_hidden_proto(strtoul_l)
+libc_hidden_proto(nl_langinfo_l)
+libc_hidden_proto(__ctype_b_loc)
+#else
+libc_hidden_proto(__ctype_b)
#endif
#ifndef __isleap
@@ -191,8 +204,6 @@ extern char *__nl_langinfo_l (nl_item __item, __locale_t l) attribute_hidden;
#ifdef __UCLIBC_HAS_TZ_FILE__
#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
#include "paths.h"
/* ":<tzname>+hh:mm:ss<tzname>+hh:mm:ss,Mmm.w.d/hh:mm:ss,Mmm.w.d/hh:mm:ss" + nul */
/* 1 + 2*(1+TZNAME_MAX+1 + 9 + 7 + 9) + 1 = 2*TZNAME_MAX + 56 */
@@ -206,12 +217,7 @@ extern char *__nl_langinfo_l (nl_item __item, __locale_t l) attribute_hidden;
/**********************************************************************/
-extern struct tm __time_tm;
-
-extern struct tm *__localtime_r (__const time_t *__restrict __timer,
- struct tm *__restrict __tp) attribute_hidden;
-
-extern struct tm *__localtime (__const time_t *__timer) attribute_hidden;
+extern struct tm __time_tm attribute_hidden;
typedef struct {
long gmt_offset;
@@ -225,12 +231,12 @@ typedef struct {
#ifdef __UCLIBC_HAS_THREADS__
# include <pthread.h>
-extern pthread_mutex_t _time_tzlock;
+extern pthread_mutex_t _time_tzlock attribute_hidden;
#endif
#define TZLOCK __pthread_mutex_lock(&_time_tzlock)
#define TZUNLOCK __pthread_mutex_unlock(&_time_tzlock)
-extern rule_struct _time_tzinfo[2];
+extern rule_struct _time_tzinfo[2] attribute_hidden;
extern struct tm *_time_t2tm(const time_t *__restrict timer,
int offset, struct tm *__restrict result) attribute_hidden;
@@ -244,21 +250,16 @@ extern struct tm *__time_localtime_tzi(const time_t *__restrict timer,
extern time_t _time_mktime_tzi(struct tm *timeptr, int store_on_success,
rule_struct *tzi) attribute_hidden;
-extern char *__asctime (__const struct tm *__tp) attribute_hidden;
-
-extern char *__asctime_r (__const struct tm *__restrict __tp,
- char *__restrict __buf) attribute_hidden;
-
/**********************************************************************/
#ifdef L_asctime
static char __time_str[26];
-char attribute_hidden *__asctime(const struct tm *ptm)
+char *asctime(const struct tm *ptm)
{
- return __asctime_r(ptm, __time_str);
+ return asctime_r(ptm, __time_str);
}
-strong_alias(__asctime,asctime)
+libc_hidden_def(asctime)
#endif
/**********************************************************************/
@@ -278,7 +279,7 @@ strong_alias(__asctime,asctime)
* };
* static char result[26];
*
- * __sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
+ * sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
* wday_name[timeptr->tm_wday],
* mon_name[timeptr->tm_mon],
* timeptr->tm_mday, timeptr->tm_hour,
@@ -326,7 +327,7 @@ static const unsigned char at_data[] = {
' ', '?', '?', '?', '?', '\n', 0
};
-char attribute_hidden *__asctime_r(register const struct tm *__restrict ptm,
+char *asctime_r(register const struct tm *__restrict ptm,
register char *__restrict buffer)
{
int tmp;
@@ -335,23 +336,23 @@ char attribute_hidden *__asctime_r(register const struct tm *__restrict ptm,
assert(buffer);
#ifdef SAFE_ASCTIME_R
- __memcpy(buffer, at_data + 3*(7 + 12), sizeof(at_data) - 3*(7 + 12));
+ memcpy(buffer, at_data + 3*(7 + 12), sizeof(at_data) - 3*(7 + 12));
if (((unsigned int)(ptm->tm_wday)) <= 6) {
- __memcpy(buffer, at_data + 3 * ptm->tm_wday, 3);
+ memcpy(buffer, at_data + 3 * ptm->tm_wday, 3);
}
if (((unsigned int)(ptm->tm_mon)) <= 11) {
- __memcpy(buffer + 4, at_data + 3*7 + 3 * ptm->tm_mon, 3);
+ memcpy(buffer + 4, at_data + 3*7 + 3 * ptm->tm_mon, 3);
}
#else
assert(((unsigned int)(ptm->tm_wday)) <= 6);
assert(((unsigned int)(ptm->tm_mon)) <= 11);
- __memcpy(buffer, at_data + 3*(7 + 12) - 3, sizeof(at_data) + 3 - 3*(7 + 12));
+ memcpy(buffer, at_data + 3*(7 + 12) - 3, sizeof(at_data) + 3 - 3*(7 + 12));
- __memcpy(buffer, at_data + 3 * ptm->tm_wday, 3);
- __memcpy(buffer + 4, at_data + 3*7 + 3 * ptm->tm_mon, 3);
+ memcpy(buffer, at_data + 3 * ptm->tm_wday, 3);
+ memcpy(buffer + 4, at_data + 3*7 + 3 * ptm->tm_mon, 3);
#endif
#ifdef SAFE_ASCTIME_R
@@ -400,16 +401,16 @@ char attribute_hidden *__asctime_r(register const struct tm *__restrict ptm,
return buffer - 8;
}
-strong_alias(__asctime_r,asctime_r)
+libc_hidden_def(asctime_r)
#endif
/**********************************************************************/
#ifdef L_clock
-#define times __times
-
#include <sys/times.h>
+libc_hidden_proto(times)
+
#ifndef __BCC__
#if CLOCKS_PER_SEC != 1000000L
#error unexpected value for CLOCKS_PER_SEC!
@@ -474,21 +475,21 @@ clock_t clock(void)
/**********************************************************************/
#ifdef L_ctime
-char attribute_hidden *__ctime(const time_t *clock)
+char *ctime(const time_t *t)
{
/* ANSI/ISO/SUSv3 say that ctime is equivalent to the following. */
- return __asctime(__localtime(clock));
+ return asctime(localtime(t));
}
-strong_alias(__ctime,ctime)
+libc_hidden_def(ctime)
#endif
/**********************************************************************/
#ifdef L_ctime_r
-char *ctime_r(const time_t *clock, char *buf)
+char *ctime_r(const time_t *t, char *buf)
{
struct tm xtm;
- return __asctime_r(__localtime_r(clock, &xtm), buf);
+ return asctime_r(localtime_r(t, &xtm), buf);
}
#endif
@@ -556,28 +557,28 @@ struct tm *gmtime_r(const time_t *__restrict timer,
/**********************************************************************/
#ifdef L_localtime
-struct tm attribute_hidden *__localtime(const time_t *timer)
+struct tm *localtime(const time_t *timer)
{
register struct tm *ptm = &__time_tm;
/* In this implementation, tzset() is called by localtime_r(). */
- __localtime_r(timer, ptm); /* Can return NULL... */
+ localtime_r(timer, ptm); /* Can return NULL... */
return ptm;
}
-strong_alias(__localtime,localtime)
+libc_hidden_def(localtime)
#endif
/**********************************************************************/
#ifdef L_localtime_r
-struct tm attribute_hidden *__localtime_r(register const time_t *__restrict timer,
+struct tm *localtime_r(register const time_t *__restrict timer,
register struct tm *__restrict result)
{
TZLOCK;
- __tzset();
+ tzset();
__time_localtime_tzi(timer, result, _time_tzinfo);
@@ -585,7 +586,7 @@ struct tm attribute_hidden *__localtime_r(register const time_t *__restrict time
return result;
}
-strong_alias(__localtime_r,localtime_r)
+libc_hidden_def(localtime_r)
#endif
/**********************************************************************/
@@ -610,7 +611,7 @@ static const char *lookup_tzname(const char *key)
ll_tzname_item_t *p;
for (p=ll_tzname ; p ; p=p->next) {
- if (!__strcmp(p->tzname, key)) {
+ if (!strcmp(p->tzname, key)) {
return p->tzname;
}
}
@@ -621,7 +622,7 @@ static const char *lookup_tzname(const char *key)
/* Insert as 3rd item in the list. */
p->next = ll_tzname[1].next;
ll_tzname[1].next = p;
- __strcpy(p->tzname, key);
+ strcpy(p->tzname, key);
return p->tzname;
}
}
@@ -754,7 +755,7 @@ time_t mktime(struct tm *timeptr)
/* Another name for `mktime'. */
/* time_t timelocal(struct tm *tp) */
-weak_alias(mktime,timelocal)
+strong_alias(mktime,timelocal)
#endif
/**********************************************************************/
@@ -765,8 +766,8 @@ time_t timegm(struct tm *timeptr)
{
rule_struct gmt_tzinfo[2];
- __memset(gmt_tzinfo, 0, sizeof(gmt_tzinfo));
- __strcpy(gmt_tzinfo[0].tzname, "GMT"); /* Match glibc behavior here. */
+ memset(gmt_tzinfo, 0, sizeof(gmt_tzinfo));
+ strcpy(gmt_tzinfo[0].tzname, "GMT"); /* Match glibc behavior here. */
return _time_mktime_tzi(timeptr, 1, gmt_tzinfo);
}
@@ -777,13 +778,17 @@ time_t timegm(struct tm *timeptr)
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-size_t attribute_hidden __strftime(char *__restrict s, size_t maxsize,
+libc_hidden_proto(strftime)
+
+libc_hidden_proto(strftime_l)
+
+size_t strftime(char *__restrict s, size_t maxsize,
const char *__restrict format,
const struct tm *__restrict timeptr)
{
- return __strftime_l(s, maxsize, format, timeptr, __UCLIBC_CURLOCALE);
+ return strftime_l(s, maxsize, format, timeptr, __UCLIBC_CURLOCALE);
}
-strong_alias(__strftime,strftime)
+libc_hidden_def(strftime)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -983,7 +988,8 @@ static int load_field(int k, const struct tm *__restrict timeptr)
#warning TODO: Check multibyte format string validity.
#endif
-size_t attribute_hidden __UCXL(strftime)(char *__restrict s, size_t maxsize,
+libc_hidden_proto(__XL_NPP(strftime))
+size_t __XL_NPP(strftime)(char *__restrict s, size_t maxsize,
const char *__restrict format,
const struct tm *__restrict timeptr __LOCALE_PARAM )
{
@@ -1003,7 +1009,7 @@ size_t attribute_hidden __UCXL(strftime)(char *__restrict s, size_t maxsize,
unsigned char mod;
unsigned char code;
- __tzset(); /* We'll, let's get this out of the way. */
+ tzset(); /* We'll, let's get this out of the way. */
lvl = 0;
p = format;
@@ -1056,7 +1062,7 @@ size_t attribute_hidden __UCXL(strftime)(char *__restrict s, size_t maxsize,
+ (code & 7);
#ifdef ENABLE_ERA_CODE
if ((mod & NO_E_MOD) /* Actually, this means E modifier present. */
- && (*(o = __UCXL(nl_langinfo)(_NL_ITEM(LC_TIME,
+ && (*(o = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
(int)(((unsigned char *)p)[4]))
__LOCALE_ARG
)))
@@ -1065,7 +1071,7 @@ size_t attribute_hidden __UCXL(strftime)(char *__restrict s, size_t maxsize,
goto LOOP;
}
#endif
- p = __UCXL(nl_langinfo)(_NL_ITEM(LC_TIME,
+ p = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
(int)(*((unsigned char *)p)))
__LOCALE_ARG
);
@@ -1242,7 +1248,7 @@ size_t attribute_hidden __UCXL(strftime)(char *__restrict s, size_t maxsize,
if ((code & MASK_SPEC) == STRING_SPEC) {
o_count = SIZE_MAX;
field_val += spec[STRINGS_NL_ITEM_START + (code & 0xf)];
- o = __UCXL(nl_langinfo)(_NL_ITEM(LC_TIME, field_val) __LOCALE_ARG );
+ o = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME, field_val) __LOCALE_ARG );
} else {
o_count = ((i >> 1) & 3) + 1;
o = buf + o_count;
@@ -1265,8 +1271,7 @@ size_t attribute_hidden __UCXL(strftime)(char *__restrict s, size_t maxsize,
}
goto LOOP;
}
-
-__UCXL_ALIAS(strftime)
+libc_hidden_def(__XL_NPP(strftime))
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -1284,12 +1289,16 @@ __UCXL_ALIAS(strftime)
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-char attribute_hidden *__strptime(const char *__restrict buf, const char *__restrict format,
+libc_hidden_proto(strptime)
+
+libc_hidden_proto(strptime_l)
+
+char *strptime(const char *__restrict buf, const char *__restrict format,
struct tm *__restrict tm)
{
- return __strptime_l(buf, format, tm, __UCLIBC_CURLOCALE);
+ return strptime_l(buf, format, tm, __UCLIBC_CURLOCALE);
}
-strong_alias(__strptime,strptime)
+libc_hidden_def(strptime)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -1435,7 +1444,8 @@ static const unsigned char spec[] = {
#define MAX_PUSH 4
-char attribute_hidden *__UCXL(strptime)(const char *__restrict buf, const char *__restrict format,
+libc_hidden_proto(__XL_NPP(strptime))
+char *__XL_NPP(strptime)(const char *__restrict buf, const char *__restrict format,
struct tm *__restrict tm __LOCALE_PARAM)
{
register const char *p;
@@ -1503,7 +1513,7 @@ char attribute_hidden *__UCXL(strptime)(const char *__restrict buf, const char *
+ (code & 7);
#ifdef ENABLE_ERA_CODE
if ((mod & NO_E_MOD) /* Actually, this means E modifier present. */
- && (*(o = __UCXL(nl_langinfo)(_NL_ITEM(LC_TIME,
+ && (*(o = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
(int)(((unsigned char *)p)[4]))
__LOCALE_ARG
)))
@@ -1512,7 +1522,7 @@ char attribute_hidden *__UCXL(strptime)(const char *__restrict buf, const char *
goto LOOP;
}
#endif
- p = __UCXL(nl_langinfo)(_NL_ITEM(LC_TIME,
+ p = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
(int)(*((unsigned char *)p)))
__LOCALE_ARG );
goto LOOP;
@@ -1527,8 +1537,8 @@ char attribute_hidden *__UCXL(strptime)(const char *__restrict buf, const char *
/* Go backwards to check full names before abreviations. */
do {
--j;
- o = __UCXL(nl_langinfo)(i+j __LOCALE_ARG);
- if (!__UCXL(strncasecmp)(buf,o,__strlen(o) __LOCALE_ARG) && *o) {
+ o = __XL_NPP(nl_langinfo)(i+j __LOCALE_ARG);
+ if (!__XL_NPP(strncasecmp)(buf,o,strlen(o) __LOCALE_ARG) && *o) {
do { /* Found a match. */
++buf;
} while (*++o);
@@ -1556,9 +1566,9 @@ char attribute_hidden *__UCXL(strptime)(const char *__restrict buf, const char *
__set_errno(0);
if (!ISSPACE(*buf)) { /* Signal an error if whitespace. */
#ifdef TIME_T_IS_UNSIGNED
- t = __UCXL(strtoul)(buf, &o, 10 __LOCALE_ARG);
+ t = __XL_NPP(strtoul)(buf, &o, 10 __LOCALE_ARG);
#else
- t = __UCXL(strtol)(buf, &o, 10 __LOCALE_ARG);
+ t = __XL_NPP(strtol)(buf, &o, 10 __LOCALE_ARG);
#endif
}
if ((o == buf) || errno) { /* Not a number or overflow. */
@@ -1568,7 +1578,7 @@ char attribute_hidden *__UCXL(strptime)(const char *__restrict buf, const char *
buf = o;
if (!code) { /* s */
- __localtime_r(&t, tm); /* TODO: check for failure? */
+ localtime_r(&t, tm); /* TODO: check for failure? */
i = 0;
do { /* Now copy values from tm to fields. */
fields[i] = ((int *) tm)[i];
@@ -1644,8 +1654,7 @@ char attribute_hidden *__UCXL(strptime)(const char *__restrict buf, const char *
}
return NULL;
}
-
-__UCXL_ALIAS(strptime)
+libc_hidden_def(__XL_NPP(strptime))
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -1694,12 +1703,18 @@ static const char vals[] = {
#define DEFAULT_RULES (vals + 22)
/* Initialize to UTC. */
+libc_hidden_proto(daylight)
int daylight = 0;
+libc_hidden_data_def(daylight)
+libc_hidden_proto(timezone)
long timezone = 0;
+libc_hidden_data_def(timezone)
+libc_hidden_proto(tzname)
char *tzname[2] = { (char *) UTC, (char *) (UTC-1) };
+libc_hidden_data_def(tzname)
#ifdef __UCLIBC_HAS_THREADS__
-pthread_mutex_t _time_tzlock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+attribute_hidden pthread_mutex_t _time_tzlock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
#endif
rule_struct _time_tzinfo[2];
@@ -1783,11 +1798,11 @@ static char *read_TZ_file(char *buf)
size_t todo;
char *p = NULL;
- if ((fd = __open(__UCLIBC_TZ_FILE_PATH__, O_RDONLY)) >= 0) {
+ if ((fd = open(__UCLIBC_TZ_FILE_PATH__, O_RDONLY)) >= 0) {
todo = TZ_BUFLEN;
p = buf;
do {
- if ((r = __read(fd, p, todo)) < 0) {
+ if ((r = read(fd, p, todo)) < 0) {
goto ERROR;
}
if (r == 0) {
@@ -1807,14 +1822,18 @@ static char *read_TZ_file(char *buf)
ERROR:
p = NULL;
}
- __close(fd);
+ close(fd);
}
return p;
}
#endif /* __UCLIBC_HAS_TZ_FILE__ */
-void attribute_hidden __tzset(void)
+#ifndef __UCLIBC_HAS_CTYPE_TABLES__
+libc_hidden_proto(isascii)
+#endif
+
+void tzset(void)
{
register const char *e;
register char *s;
@@ -1832,7 +1851,7 @@ void attribute_hidden __tzset(void)
TZLOCK;
- e = __getenv(TZ); /* TZ env var always takes precedence. */
+ e = getenv(TZ); /* TZ env var always takes precedence. */
#if defined(__UCLIBC_HAS_TZ_FILE__) && !defined(__UCLIBC_HAS_TZ_FILE_READ_MANY__)
/* Put this inside the lock to prevent the possiblity of two different
@@ -1859,8 +1878,8 @@ void attribute_hidden __tzset(void)
#ifdef __UCLIBC_HAS_TZ_CACHING__
*oldval = 0; /* Set oldval to an empty string. */
#endif /* __UCLIBC_HAS_TZ_CACHING__ */
- __memset(_time_tzinfo, 0, 2*sizeof(rule_struct));
- __strcpy(_time_tzinfo[0].tzname, UTC);
+ memset(_time_tzinfo, 0, 2*sizeof(rule_struct));
+ strcpy(_time_tzinfo[0].tzname, UTC);
goto DONE;
}
@@ -1869,13 +1888,13 @@ void attribute_hidden __tzset(void)
}
#ifdef __UCLIBC_HAS_TZ_CACHING__
- if (__strcmp(e, oldval) == 0) { /* Same string as last time... */
+ if (strcmp(e, oldval) == 0) { /* Same string as last time... */
goto FAST_DONE; /* So nothing to do. */
}
/* Make a copy of the TZ env string. It won't be nul-terminated if
* it is too long, but it that case it will be illegal and will be reset
* to the empty string anyway. */
- __strncpy(oldval, e, TZ_BUFLEN);
+ strncpy(oldval, e, TZ_BUFLEN);
#endif /* __UCLIBC_HAS_TZ_CACHING__ */
count = 0;
@@ -1989,7 +2008,7 @@ void attribute_hidden __tzset(void)
}
}
- __memcpy(_time_tzinfo, new_rules, sizeof(new_rules));
+ memcpy(_time_tzinfo, new_rules, sizeof(new_rules));
DONE:
tzname[0] = _time_tzinfo[0].tzname;
tzname[1] = _time_tzinfo[1].tzname;
@@ -2001,7 +2020,7 @@ void attribute_hidden __tzset(void)
#endif
TZUNLOCK;
}
-strong_alias(__tzset,tzset)
+libc_hidden_def(tzset)
#endif
/**********************************************************************/
/* #ifdef L_utime */
@@ -2203,7 +2222,7 @@ time_t attribute_hidden _time_mktime(struct tm *timeptr, int store_on_success)
TZLOCK;
- __tzset();
+ tzset();
t = _time_mktime_tzi(timeptr, store_on_success, _time_tzinfo);
@@ -2236,7 +2255,7 @@ time_t attribute_hidden _time_mktime_tzi(struct tm *timeptr, int store_on_succes
register const unsigned char *s;
int d, default_dst;
- __memcpy(p, timeptr, sizeof(struct tm));
+ memcpy(p, timeptr, sizeof(struct tm));
if (!tzi[1].tzname[0]) { /* No dst in this timezone, */
p[8] = 0; /* so set tm_isdst to 0. */
@@ -2326,7 +2345,7 @@ time_t attribute_hidden _time_mktime_tzi(struct tm *timeptr, int store_on_succes
if (store_on_success) {
- __memcpy(timeptr, p, sizeof(struct tm));
+ memcpy(timeptr, p, sizeof(struct tm));
}
@@ -2340,29 +2359,29 @@ time_t attribute_hidden _time_mktime_tzi(struct tm *timeptr, int store_on_succes
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-extern size_t __wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
- __const wchar_t *__restrict __format,
- __const struct tm *__restrict __timeptr,
- __locale_t __loc) __THROW attribute_hidden;
+libc_hidden_proto(wcsftime)
+
+libc_hidden_proto(wcsftime_l)
size_t wcsftime(wchar_t *__restrict s, size_t maxsize,
const wchar_t *__restrict format,
const struct tm *__restrict timeptr)
{
- return __wcsftime_l(s, maxsize, format, timeptr, __UCLIBC_CURLOCALE);
+ return wcsftime_l(s, maxsize, format, timeptr, __UCLIBC_CURLOCALE);
}
+libc_hidden_def(wcsftime)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
-size_t attribute_hidden __UCXL(wcsftime)(wchar_t *__restrict s, size_t maxsize,
+libc_hidden_proto(__XL_NPP(wcsftime))
+size_t __XL_NPP(wcsftime)(wchar_t *__restrict s, size_t maxsize,
const wchar_t *__restrict format,
const struct tm *__restrict timeptr __LOCALE_PARAM )
{
#warning wcsftime always fails
return 0; /* always fail */
}
-
-__UCXL_ALIAS(wcsftime)
+libc_hidden_def(__XL_NPP(wcsftime))
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
diff --git a/libc/misc/time/timegm.c b/libc/misc/time/timegm.c
new file mode 100644
index 000000000..ae2fc7df5
--- /dev/null
+++ b/libc/misc/time/timegm.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_timegm
+#include "time.c"
diff --git a/libc/misc/time/tzset.c b/libc/misc/time/tzset.c
new file mode 100644
index 000000000..e5607a51b
--- /dev/null
+++ b/libc/misc/time/tzset.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_tzset
+#include "time.c"
diff --git a/libc/misc/time/wcsftime.c b/libc/misc/time/wcsftime.c
new file mode 100644
index 000000000..e4b25c0d1
--- /dev/null
+++ b/libc/misc/time/wcsftime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcsftime
+#include "time.c"
diff --git a/libc/misc/time/wcsftime_l.c b/libc/misc/time/wcsftime_l.c
new file mode 100644
index 000000000..68c295458
--- /dev/null
+++ b/libc/misc/time/wcsftime_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcsftime_l
+#define __UCLIBC_DO_XLOCALE
+#include "time.c"