am 59ed029b: Merge "Upgrade to tzcode2013d."

* commit '59ed029b286a1564f635377296e4f088e0fd2afa':
  Upgrade to tzcode2013d.
This commit is contained in:
Elliott Hughes 2013-07-15 10:11:04 -07:00 committed by Android Git Automerger
commit f384be3b5c
7 changed files with 834 additions and 896 deletions

View File

@ -70,11 +70,6 @@ libc_common_src_files := \
string/strtok.c \ string/strtok.c \
wchar/wcswidth.c \ wchar/wcswidth.c \
wchar/wcsxfrm.c \ wchar/wcsxfrm.c \
tzcode/asctime.c \
tzcode/difftime.c \
tzcode/localtime.c \
tzcode/strftime.c \
tzcode/strptime.c \
bionic/arc4random.c \ bionic/arc4random.c \
bionic/atoi.c \ bionic/atoi.c \
bionic/atol.c \ bionic/atol.c \
@ -247,6 +242,13 @@ libc_bionic_src_files := \
bionic/wait.cpp \ bionic/wait.cpp \
bionic/wchar.cpp \ bionic/wchar.cpp \
libc_tzcode_src_files := \
tzcode/asctime.c \
tzcode/difftime.c \
tzcode/localtime.c \
tzcode/strftime.c \
tzcode/strptime.c \
libc_upstream_freebsd_src_files := \ libc_upstream_freebsd_src_files := \
upstream-freebsd/lib/libc/stdio/clrerr.c \ upstream-freebsd/lib/libc/stdio/clrerr.c \
upstream-freebsd/lib/libc/stdio/fclose.c \ upstream-freebsd/lib/libc/stdio/fclose.c \
@ -490,14 +492,6 @@ libc_common_cflags := \
-DLOG_ON_HEAP_ERROR \ -DLOG_ON_HEAP_ERROR \
-Wall -Wextra -Wall -Wextra
# these macro definitions are required to implement the
# 'timezone' and 'daylight' global variables, as well as
# properly update the 'tm_gmtoff' field in 'struct tm'.
#
libc_common_cflags += \
-DTM_GMTOFF=tm_gmtoff \
-DUSG_COMPAT=1
ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true) ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
libc_common_cflags += -DDEBUG libc_common_cflags += -DDEBUG
endif endif
@ -707,6 +701,28 @@ LOCAL_SYSTEM_SHARED_LIBRARIES :=
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
# ========================================================
# libc_tzcode.a - upstream 'tzcode' code
# ========================================================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(libc_tzcode_src_files)
LOCAL_CFLAGS := \
$(libc_common_cflags) \
-std=gnu99 \
-DSTD_INSPIRED=1 \
-DTZDIR=\"/system/usr/share/zoneinfo\" \
-DTM_GMTOFF=tm_gmtoff \
-DUSG_COMPAT=1
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_tzcode
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_SYSTEM_SHARED_LIBRARIES :=
include $(BUILD_STATIC_LIBRARY)
# ======================================================== # ========================================================
# libc_freebsd.a - upstream FreeBSD C library code # libc_freebsd.a - upstream FreeBSD C library code
# ======================================================== # ========================================================
@ -782,7 +798,12 @@ LOCAL_CFLAGS := $(libc_common_cflags) \
LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_common LOCAL_MODULE := libc_common
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_WHOLE_STATIC_LIBRARIES := libbionic_ssp libc_bionic libc_freebsd libc_netbsd LOCAL_WHOLE_STATIC_LIBRARIES := \
libbionic_ssp \
libc_bionic \
libc_freebsd \
libc_netbsd \
libc_tzcode
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
# TODO: split out the asflags. # TODO: split out the asflags.

View File

@ -9,12 +9,6 @@
** whereas the output of asctime is supposed to be constant. ** whereas the output of asctime is supposed to be constant.
*/ */
#ifndef lint
#ifndef NOID
static char elsieid[] = "@(#)asctime.c 8.2";
#endif /* !defined NOID */
#endif /* !defined lint */
/*LINTLIBRARY*/ /*LINTLIBRARY*/
#include "private.h" #include "private.h"
@ -39,9 +33,9 @@ static char elsieid[] = "@(#)asctime.c 8.2";
** but many implementations pad anyway; most likely the standards are buggy. ** but many implementations pad anyway; most likely the standards are buggy.
*/ */
#ifdef __GNUC__ #ifdef __GNUC__
#define ASCTIME_FMT "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n" #define ASCTIME_FMT "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n"
#else /* !defined __GNUC__ */ #else /* !defined __GNUC__ */
#define ASCTIME_FMT "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %-4s\n" #define ASCTIME_FMT "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %-4s\n"
#endif /* !defined __GNUC__ */ #endif /* !defined __GNUC__ */
/* /*
** For years that are more than four digits we put extra spaces before the year ** For years that are more than four digits we put extra spaces before the year
@ -50,12 +44,12 @@ static char elsieid[] = "@(#)asctime.c 8.2";
** that no output is better than wrong output). ** that no output is better than wrong output).
*/ */
#ifdef __GNUC__ #ifdef __GNUC__
#define ASCTIME_FMT_B "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %s\n" #define ASCTIME_FMT_B "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %s\n"
#else /* !defined __GNUC__ */ #else /* !defined __GNUC__ */
#define ASCTIME_FMT_B "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %s\n" #define ASCTIME_FMT_B "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %s\n"
#endif /* !defined __GNUC__ */ #endif /* !defined __GNUC__ */
#define STD_ASCTIME_BUF_SIZE 26 #define STD_ASCTIME_BUF_SIZE 26
/* /*
** Big enough for something such as ** Big enough for something such as
** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n ** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n
@ -66,64 +60,65 @@ static char elsieid[] = "@(#)asctime.c 8.2";
** as an example; the define below calculates the maximum for the system at ** as an example; the define below calculates the maximum for the system at
** hand. ** hand.
*/ */
#define MAX_ASCTIME_BUF_SIZE (2*3+5*INT_STRLEN_MAXIMUM(int)+7+2+1+1) #define MAX_ASCTIME_BUF_SIZE (2*3+5*INT_STRLEN_MAXIMUM(int)+7+2+1+1)
static char buf_asctime[MAX_ASCTIME_BUF_SIZE]; static char buf_asctime[MAX_ASCTIME_BUF_SIZE];
/* /*
** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, 2004 Edition. ** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, 2004 Edition.
*/ */
char * char *
asctime_r(timeptr, buf) asctime_r(register const struct tm *timeptr, char *buf)
register const struct tm * timeptr;
char * buf;
{ {
static const char wday_name[][3] = { static const char wday_name[][3] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
}; };
static const char mon_name[][3] = { static const char mon_name[][3] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
}; };
register const char * wn; register const char * wn;
register const char * mn; register const char * mn;
char year[INT_STRLEN_MAXIMUM(int) + 2]; char year[INT_STRLEN_MAXIMUM(int) + 2];
char result[MAX_ASCTIME_BUF_SIZE]; char result[MAX_ASCTIME_BUF_SIZE];
if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK) if (timeptr == NULL) {
wn = "???"; errno = EINVAL;
else wn = wday_name[timeptr->tm_wday]; return strcpy(buf, "??? ??? ?? ??:??:?? ????\n");
if (timeptr->tm_mon < 0 || timeptr->tm_mon >= MONSPERYEAR) }
mn = "???"; if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK)
else mn = mon_name[timeptr->tm_mon]; wn = "???";
/* else wn = wday_name[timeptr->tm_wday];
** Use strftime's %Y to generate the year, to avoid overflow problems if (timeptr->tm_mon < 0 || timeptr->tm_mon >= MONSPERYEAR)
** when computing timeptr->tm_year + TM_YEAR_BASE. mn = "???";
** Assume that strftime is unaffected by other out-of-range members else mn = mon_name[timeptr->tm_mon];
** (e.g., timeptr->tm_mday) when processing "%Y". /*
*/ ** Use strftime's %Y to generate the year, to avoid overflow problems
(void) strftime(year, sizeof year, "%Y", timeptr); ** when computing timeptr->tm_year + TM_YEAR_BASE.
/* ** Assume that strftime is unaffected by other out-of-range members
** We avoid using snprintf since it's not available on all systems. ** (e.g., timeptr->tm_mday) when processing "%Y".
*/ */
(void) sprintf(result, (void) strftime(year, sizeof year, "%Y", timeptr);
((strlen(year) <= 4) ? ASCTIME_FMT : ASCTIME_FMT_B), /*
wn, mn, ** We avoid using snprintf since it's not available on all systems.
timeptr->tm_mday, timeptr->tm_hour, */
timeptr->tm_min, timeptr->tm_sec, (void) sprintf(result,
year); ((strlen(year) <= 4) ? ASCTIME_FMT : ASCTIME_FMT_B),
if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime) { wn, mn,
(void) strcpy(buf, result); timeptr->tm_mday, timeptr->tm_hour,
return buf; timeptr->tm_min, timeptr->tm_sec,
} else { year);
if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime)
return strcpy(buf, result);
else {
#ifdef EOVERFLOW #ifdef EOVERFLOW
errno = EOVERFLOW; errno = EOVERFLOW;
#else /* !defined EOVERFLOW */ #else /* !defined EOVERFLOW */
errno = EINVAL; errno = EINVAL;
#endif /* !defined EOVERFLOW */ #endif /* !defined EOVERFLOW */
return NULL; return NULL;
} }
} }
/* /*
@ -131,8 +126,7 @@ char * buf;
*/ */
char * char *
asctime(timeptr) asctime(register const struct tm *timeptr)
register const struct tm * timeptr;
{ {
return asctime_r(timeptr, buf_asctime); return asctime_r(timeptr, buf_asctime);
} }

View File

@ -3,63 +3,54 @@
** 1996-06-05 by Arthur David Olson. ** 1996-06-05 by Arthur David Olson.
*/ */
#ifndef lint
#ifndef NOID
static char elsieid[] = "@(#)difftime.c 8.1";
#endif /* !defined NOID */
#endif /* !defined lint */
/*LINTLIBRARY*/ /*LINTLIBRARY*/
#include "private.h" /* for time_t, TYPE_INTEGRAL, and TYPE_SIGNED */ #include "private.h" /* for time_t, TYPE_INTEGRAL, and TYPE_SIGNED */
double double ATTRIBUTE_CONST
difftime(time1, time0) difftime(const time_t time1, const time_t time0)
const time_t time1;
const time_t time0;
{ {
/* /*
** If (sizeof (double) > sizeof (time_t)) simply convert and subtract ** If (sizeof (double) > sizeof (time_t)) simply convert and subtract
** (assuming that the larger type has more precision). ** (assuming that the larger type has more precision).
** This is the common real-world case circa 2004. */
*/ if (sizeof (double) > sizeof (time_t))
if (sizeof (double) > sizeof (time_t)) return (double) time1 - (double) time0;
return (double) time1 - (double) time0; if (!TYPE_INTEGRAL(time_t)) {
if (!TYPE_INTEGRAL(time_t)) { /*
/* ** time_t is floating.
** time_t is floating. */
*/ return time1 - time0;
return time1 - time0; }
} if (!TYPE_SIGNED(time_t)) {
if (!TYPE_SIGNED(time_t)) { /*
/* ** time_t is integral and unsigned.
** time_t is integral and unsigned. ** The difference of two unsigned values can't overflow
** The difference of two unsigned values can't overflow ** if the minuend is greater than or equal to the subtrahend.
** if the minuend is greater than or equal to the subtrahend. */
*/ if (time1 >= time0)
if (time1 >= time0) return time1 - time0;
return time1 - time0; else return -(double) (time0 - time1);
else return -((double) (time0 - time1)); }
} /*
/* ** time_t is integral and signed.
** time_t is integral and signed. ** Handle cases where both time1 and time0 have the same sign
** Handle cases where both time1 and time0 have the same sign ** (meaning that their difference cannot overflow).
** (meaning that their difference cannot overflow). */
*/ if ((time1 < 0) == (time0 < 0))
if ((time1 < 0) == (time0 < 0)) return time1 - time0;
return time1 - time0; /*
/* ** time1 and time0 have opposite signs.
** time1 and time0 have opposite signs. ** Punt if uintmax_t is too narrow.
** Punt if unsigned long is too narrow. ** This suffers from double rounding; attempt to lessen that
*/ ** by using long double temporaries.
if (sizeof (unsigned long) < sizeof (time_t)) */
return (double) time1 - (double) time0; if (sizeof (uintmax_t) < sizeof (time_t))
/* return (long double) time1 - (long double) time0;
** Stay calm...decent optimizers will eliminate the complexity below. /*
*/ ** Stay calm...decent optimizers will eliminate the complexity below.
if (time1 >= 0 /* && time0 < 0 */) */
return (unsigned long) time1 + if (time1 >= 0 /* && time0 < 0 */)
(unsigned long) (-(time0 + 1)) + 1; return (uintmax_t) time1 + (uintmax_t) (-1 - time0) + 1;
return -(double) ((unsigned long) time0 + return -(double) ((uintmax_t) time0 + (uintmax_t) (-1 - time1) + 1);
(unsigned long) (-(time1 + 1)) + 1);
} }

File diff suppressed because it is too large Load Diff

View File

@ -15,17 +15,7 @@
** Thank you! ** Thank you!
*/ */
/* #define GRANDPARENTED "Local time zone must be set--see zic manual page"
** ID
*/
#ifndef lint
#ifndef NOID
static char privatehid[] = "@(#)private.h 8.2";
#endif /* !defined NOID */
#endif /* !defined lint */
#define GRANDPARENTED "Local time zone must be set--see zic manual page"
/* /*
** Defaults for preprocessor symbols. ** Defaults for preprocessor symbols.
@ -33,45 +23,45 @@ static char privatehid[] = "@(#)private.h 8.2";
*/ */
#ifndef HAVE_ADJTIME #ifndef HAVE_ADJTIME
#define HAVE_ADJTIME 1 #define HAVE_ADJTIME 1
#endif /* !defined HAVE_ADJTIME */ #endif /* !defined HAVE_ADJTIME */
#ifndef HAVE_GETTEXT #ifndef HAVE_GETTEXT
#define HAVE_GETTEXT 0 #define HAVE_GETTEXT 0
#endif /* !defined HAVE_GETTEXT */ #endif /* !defined HAVE_GETTEXT */
#ifndef HAVE_INCOMPATIBLE_CTIME_R #ifndef HAVE_INCOMPATIBLE_CTIME_R
#define HAVE_INCOMPATIBLE_CTIME_R 0 #define HAVE_INCOMPATIBLE_CTIME_R 0
#endif /* !defined INCOMPATIBLE_CTIME_R */ #endif /* !defined INCOMPATIBLE_CTIME_R */
#ifndef HAVE_SETTIMEOFDAY #ifndef HAVE_SETTIMEOFDAY
#define HAVE_SETTIMEOFDAY 3 #define HAVE_SETTIMEOFDAY 3
#endif /* !defined HAVE_SETTIMEOFDAY */ #endif /* !defined HAVE_SETTIMEOFDAY */
#ifndef HAVE_STRERROR
#define HAVE_STRERROR 1
#endif /* !defined HAVE_STRERROR */
#ifndef HAVE_SYMLINK #ifndef HAVE_SYMLINK
#define HAVE_SYMLINK 1 #define HAVE_SYMLINK 1
#endif /* !defined HAVE_SYMLINK */ #endif /* !defined HAVE_SYMLINK */
#ifndef HAVE_SYS_STAT_H #ifndef HAVE_SYS_STAT_H
#define HAVE_SYS_STAT_H 1 #define HAVE_SYS_STAT_H 1
#endif /* !defined HAVE_SYS_STAT_H */ #endif /* !defined HAVE_SYS_STAT_H */
#ifndef HAVE_SYS_WAIT_H #ifndef HAVE_SYS_WAIT_H
#define HAVE_SYS_WAIT_H 1 #define HAVE_SYS_WAIT_H 1
#endif /* !defined HAVE_SYS_WAIT_H */ #endif /* !defined HAVE_SYS_WAIT_H */
#ifndef HAVE_UNISTD_H #ifndef HAVE_UNISTD_H
#define HAVE_UNISTD_H 1 #define HAVE_UNISTD_H 1
#endif /* !defined HAVE_UNISTD_H */ #endif /* !defined HAVE_UNISTD_H */
#ifndef HAVE_UTMPX_H #ifndef HAVE_UTMPX_H
#define HAVE_UTMPX_H 0 #define HAVE_UTMPX_H 0
#endif /* !defined HAVE_UTMPX_H */ #endif /* !defined HAVE_UTMPX_H */
#ifndef LOCALE_HOME
#define LOCALE_HOME "/usr/lib/locale"
#endif /* !defined LOCALE_HOME */
#if HAVE_INCOMPATIBLE_CTIME_R #if HAVE_INCOMPATIBLE_CTIME_R
#define asctime_r _incompatible_asctime_r #define asctime_r _incompatible_asctime_r
#define ctime_r _incompatible_ctime_r #define ctime_r _incompatible_ctime_r
@ -81,11 +71,11 @@ static char privatehid[] = "@(#)private.h 8.2";
** Nested includes ** Nested includes
*/ */
#include "sys/types.h" /* for time_t */ #include "sys/types.h" /* for time_t */
#include "stdio.h" #include "stdio.h"
#include "errno.h" #include "errno.h"
#include "string.h" #include "string.h"
#include "limits.h" /* for CHAR_BIT et al. */ #include "limits.h" /* for CHAR_BIT et al. */
#include "time.h" #include "time.h"
#include "stdlib.h" #include "stdlib.h"
@ -94,28 +84,26 @@ static char privatehid[] = "@(#)private.h 8.2";
#endif /* HAVE_GETTEXT */ #endif /* HAVE_GETTEXT */
#if HAVE_SYS_WAIT_H #if HAVE_SYS_WAIT_H
#include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */ #include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
#endif /* HAVE_SYS_WAIT_H */ #endif /* HAVE_SYS_WAIT_H */
#ifndef WIFEXITED #ifndef WIFEXITED
#define WIFEXITED(status) (((status) & 0xff) == 0) #define WIFEXITED(status) (((status) & 0xff) == 0)
#endif /* !defined WIFEXITED */ #endif /* !defined WIFEXITED */
#ifndef WEXITSTATUS #ifndef WEXITSTATUS
#define WEXITSTATUS(status) (((status) >> 8) & 0xff) #define WEXITSTATUS(status) (((status) >> 8) & 0xff)
#endif /* !defined WEXITSTATUS */ #endif /* !defined WEXITSTATUS */
#if HAVE_UNISTD_H #if HAVE_UNISTD_H
#include "unistd.h" /* for F_OK and R_OK */ #include "unistd.h" /* for F_OK, R_OK, and other POSIX goodness */
#endif /* HAVE_UNISTD_H */ #endif /* HAVE_UNISTD_H */
#if !HAVE_UNISTD_H
#ifndef F_OK #ifndef F_OK
#define F_OK 0 #define F_OK 0
#endif /* !defined F_OK */ #endif /* !defined F_OK */
#ifndef R_OK #ifndef R_OK
#define R_OK 4 #define R_OK 4
#endif /* !defined R_OK */ #endif /* !defined R_OK */
#endif /* !HAVE_UNISTD_H */
/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */ /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
#define is_digit(c) ((unsigned)(c) - '0' <= 9) #define is_digit(c) ((unsigned)(c) - '0' <= 9)
@ -128,27 +116,73 @@ static char privatehid[] = "@(#)private.h 8.2";
*/ */
#ifndef HAVE_STDINT_H #ifndef HAVE_STDINT_H
#define HAVE_STDINT_H \ #define HAVE_STDINT_H \
(199901 <= __STDC_VERSION__ || \ (199901 <= __STDC_VERSION__ || \
2 < (__GLIBC__ + (0 < __GLIBC_MINOR__))) 2 < (__GLIBC__ + (0 < __GLIBC_MINOR__)))
#endif /* !defined HAVE_STDINT_H */ #endif /* !defined HAVE_STDINT_H */
#if HAVE_STDINT_H #if HAVE_STDINT_H
#include "stdint.h" #include "stdint.h"
#endif /* !HAVE_STDINT_H */ #endif /* !HAVE_STDINT_H */
#ifndef HAVE_INTTYPES_H
# define HAVE_INTTYPES_H HAVE_STDINT_H
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#ifndef INT_FAST64_MAX #ifndef INT_FAST64_MAX
/* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX. */ /* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX. */
#if defined LLONG_MAX || defined __LONG_LONG_MAX__ #if defined LLONG_MAX || defined __LONG_LONG_MAX__
typedef long long int_fast64_t; typedef long long int_fast64_t;
# ifdef LLONG_MAX
# define INT_FAST64_MIN LLONG_MIN
# define INT_FAST64_MAX LLONG_MAX
# else
# define INT_FAST64_MIN __LONG_LONG_MIN__
# define INT_FAST64_MAX __LONG_LONG_MAX__
# endif
# define SCNdFAST64 "lld"
#else /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */ #else /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
#if (LONG_MAX >> 31) < 0xffffffff #if (LONG_MAX >> 31) < 0xffffffff
Please use a compiler that supports a 64-bit integer type (or wider); Please use a compiler that supports a 64-bit integer type (or wider);
you may need to compile with "-DHAVE_STDINT_H". you may need to compile with "-DHAVE_STDINT_H".
#endif /* (LONG_MAX >> 31) < 0xffffffff */ #endif /* (LONG_MAX >> 31) < 0xffffffff */
typedef long int_fast64_t; typedef long int_fast64_t;
# define INT_FAST64_MIN LONG_MIN
# define INT_FAST64_MAX LONG_MAX
# define SCNdFAST64 "ld"
#endif /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */ #endif /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
#endif /* !defined INT_FAST64_MAX */ #endif /* !defined INT_FAST64_MAX */
#ifndef INT_FAST32_MAX
# if INT_MAX >> 31 == 0
typedef long int_fast32_t;
# else
typedef int int_fast32_t;
# endif
#endif
#ifndef INTMAX_MAX
# if defined LLONG_MAX || defined __LONG_LONG_MAX__
typedef long long intmax_t;
# define PRIdMAX "lld"
# else
typedef long intmax_t;
# define PRIdMAX "ld"
# endif
#endif
#ifndef UINTMAX_MAX
# if defined ULLONG_MAX || defined __LONG_LONG_MAX__
typedef unsigned long long uintmax_t;
# define PRIuMAX "llu"
# else
typedef unsigned long uintmax_t;
# define PRIuMAX "lu"
# endif
#endif
#ifndef INT32_MAX #ifndef INT32_MAX
#define INT32_MAX 0x7fffffff #define INT32_MAX 0x7fffffff
#endif /* !defined INT32_MAX */ #endif /* !defined INT32_MAX */
@ -156,74 +190,30 @@ typedef long int_fast64_t;
#define INT32_MIN (-1 - INT32_MAX) #define INT32_MIN (-1 - INT32_MAX)
#endif /* !defined INT32_MIN */ #endif /* !defined INT32_MIN */
#if 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
# define ATTRIBUTE_CONST __attribute__ ((const))
# define ATTRIBUTE_PURE __attribute__ ((__pure__))
#else
# define ATTRIBUTE_CONST /* empty */
# define ATTRIBUTE_PURE /* empty */
#endif
#if !defined _Noreturn && __STDC_VERSION__ < 201112
# if 2 < __GNUC__ + (8 <= __GNUC_MINOR__)
# define _Noreturn __attribute__ ((__noreturn__))
# else
# define _Noreturn
# endif
#endif
#if __STDC_VERSION__ < 199901 && !defined restrict
# define restrict /* empty */
#endif
/* /*
** Workarounds for compilers/systems. ** Workarounds for compilers/systems.
*/ */
/*
** If your compiler lacks prototypes, "#define P(x) ()".
*/
#ifndef P
#define P(x) x
#endif /* !defined P */
/*
** SunOS 4.1.1 headers lack EXIT_SUCCESS.
*/
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif /* !defined EXIT_SUCCESS */
/*
** SunOS 4.1.1 headers lack EXIT_FAILURE.
*/
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif /* !defined EXIT_FAILURE */
/*
** SunOS 4.1.1 headers lack FILENAME_MAX.
*/
#ifndef FILENAME_MAX
#ifndef MAXPATHLEN
#ifdef unix
#include "sys/param.h"
#endif /* defined unix */
#endif /* !defined MAXPATHLEN */
#ifdef MAXPATHLEN
#define FILENAME_MAX MAXPATHLEN
#endif /* defined MAXPATHLEN */
#ifndef MAXPATHLEN
#define FILENAME_MAX 1024 /* Pure guesswork */
#endif /* !defined MAXPATHLEN */
#endif /* !defined FILENAME_MAX */
/*
** SunOS 4.1.1 libraries lack remove.
*/
#ifndef remove
extern int unlink P((const char * filename));
#define remove unlink
#endif /* !defined remove */
/*
** Some ancient errno.h implementations don't declare errno.
** But some newer errno.h implementations define it as a macro.
** Fix the former without affecting the latter.
*/
#ifndef errno
extern int errno;
#endif /* !defined errno */
/* /*
** Some time.h implementations don't declare asctime_r. ** Some time.h implementations don't declare asctime_r.
** Others might define it as a macro. ** Others might define it as a macro.
@ -231,36 +221,83 @@ extern int errno;
*/ */
#ifndef asctime_r #ifndef asctime_r
extern char * asctime_r(); extern char * asctime_r(struct tm const *, char *);
#endif
/*
** Compile with -Dtime_tz=T to build the tz package with a private
** time_t type equivalent to T rather than the system-supplied time_t.
** This debugging feature can test unusual design decisions
** (e.g., time_t wider than 'long', or unsigned time_t) even on
** typical platforms.
*/
#ifdef time_tz
static time_t sys_time(time_t *x) { return time(x); }
# undef ctime
# define ctime tz_ctime
# undef ctime_r
# define ctime_r tz_ctime_r
# undef difftime
# define difftime tz_difftime
# undef gmtime
# define gmtime tz_gmtime
# undef gmtime_r
# define gmtime_r tz_gmtime_r
# undef localtime
# define localtime tz_localtime
# undef localtime_r
# define localtime_r tz_localtime_r
# undef mktime
# define mktime tz_mktime
# undef time
# define time tz_time
# undef time_t
# define time_t tz_time_t
typedef time_tz time_t;
char *ctime(time_t const *);
char *ctime_r(time_t const *, char *);
double difftime(time_t, time_t);
struct tm *gmtime(time_t const *);
struct tm *gmtime_r(time_t const *restrict, struct tm *restrict);
struct tm *localtime(time_t const *);
struct tm *localtime_r(time_t const *restrict, struct tm *restrict);
time_t mktime(struct tm *);
static time_t
time(time_t *p)
{
time_t r = sys_time(0);
if (p)
*p = r;
return r;
}
#endif #endif
/* /*
** Private function declarations. ** Private function declarations.
*/ */
char * icalloc P((int nelem, int elsize)); char * icatalloc(char * old, const char * new);
char * icatalloc P((char * old, const char * new)); char * icpyalloc(const char * string);
char * icpyalloc P((const char * string)); const char * scheck(const char * string, const char * format);
char * imalloc P((int n));
void * irealloc P((void * pointer, int size));
void icfree P((char * pointer));
void ifree P((char * pointer));
const char * scheck P((const char * string, const char * format));
/* /*
** Finally, some convenience items. ** Finally, some convenience items.
*/ */
#ifndef TRUE #ifndef TRUE
#define TRUE 1 #define TRUE 1
#endif /* !defined TRUE */ #endif /* !defined TRUE */
#ifndef FALSE #ifndef FALSE
#define FALSE 0 #define FALSE 0
#endif /* !defined FALSE */ #endif /* !defined FALSE */
#ifndef TYPE_BIT #ifndef TYPE_BIT
#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
#endif /* !defined TYPE_BIT */ #endif /* !defined TYPE_BIT */
#ifndef TYPE_SIGNED #ifndef TYPE_SIGNED
@ -284,8 +321,8 @@ const char * scheck P((const char * string, const char * format));
** add one more for a minus sign if the type is signed. ** add one more for a minus sign if the type is signed.
*/ */
#define INT_STRLEN_MAXIMUM(type) \ #define INT_STRLEN_MAXIMUM(type) \
((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \ ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
1 + TYPE_SIGNED(type)) 1 + TYPE_SIGNED(type))
#endif /* !defined INT_STRLEN_MAXIMUM */ #endif /* !defined INT_STRLEN_MAXIMUM */
/* /*
@ -305,7 +342,7 @@ const char * scheck P((const char * string, const char * format));
#ifndef INITIALIZE #ifndef INITIALIZE
#ifdef GNUC_or_lint #ifdef GNUC_or_lint
#define INITIALIZE(x) ((x) = 0) #define INITIALIZE(x) ((x) = 0)
#endif /* defined GNUC_or_lint */ #endif /* defined GNUC_or_lint */
#ifndef GNUC_or_lint #ifndef GNUC_or_lint
#define INITIALIZE(x) #define INITIALIZE(x)
@ -333,12 +370,12 @@ const char * scheck P((const char * string, const char * format));
#if HAVE_INCOMPATIBLE_CTIME_R #if HAVE_INCOMPATIBLE_CTIME_R
#undef asctime_r #undef asctime_r
#undef ctime_r #undef ctime_r
char *asctime_r P((struct tm const *, char *)); char *asctime_r(struct tm const *, char *);
char *ctime_r P((time_t const *, char *)); char *ctime_r(time_t const *, char *);
#endif /* HAVE_INCOMPATIBLE_CTIME_R */ #endif /* HAVE_INCOMPATIBLE_CTIME_R */
#ifndef YEARSPERREPEAT #ifndef YEARSPERREPEAT
#define YEARSPERREPEAT 400 /* years before a Gregorian repeat */ #define YEARSPERREPEAT 400 /* years before a Gregorian repeat */
#endif /* !defined YEARSPERREPEAT */ #endif /* !defined YEARSPERREPEAT */
/* /*
@ -346,15 +383,15 @@ char *ctime_r P((time_t const *, char *));
*/ */
#ifndef AVGSECSPERYEAR #ifndef AVGSECSPERYEAR
#define AVGSECSPERYEAR 31556952L #define AVGSECSPERYEAR 31556952L
#endif /* !defined AVGSECSPERYEAR */ #endif /* !defined AVGSECSPERYEAR */
#ifndef SECSPERREPEAT #ifndef SECSPERREPEAT
#define SECSPERREPEAT ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR) #define SECSPERREPEAT ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
#endif /* !defined SECSPERREPEAT */ #endif /* !defined SECSPERREPEAT */
#ifndef SECSPERREPEAT_BITS #ifndef SECSPERREPEAT_BITS
#define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */ #define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */
#endif /* !defined SECSPERREPEAT_BITS */ #endif /* !defined SECSPERREPEAT_BITS */
/* /*

View File

@ -111,12 +111,12 @@ static const struct lc_time_T C_time_locale = {
"%a %b %e %H:%M:%S %Z %Y" "%a %b %e %H:%M:%S %Z %Y"
}; };
static char * _add P((const char *, char *, const char *, int)); static char * _add(const char *, char *, const char *, int);
static char * _conv P((int, const char *, char *, const char *)); static char * _conv(int, const char *, char *, const char *);
static char * _fmt P((const char *, const struct tm *, char *, const char *, static char * _fmt(const char *, const struct tm *, char *, const char *,
int *, const struct strftime_locale*)); int *, const struct strftime_locale*);
static char * _yconv P((int, int, int, int, char *, const char *, int)); static char * _yconv(int, int, int, int, char *, const char *, int);
static char * getformat P((int, char *, char *, char *, char *)); static char * getformat(int, char *, char *, char *, char *);
extern char * tzname[]; extern char * tzname[];

View File

@ -15,73 +15,63 @@
** Thank you! ** Thank you!
*/ */
/*
** ID
*/
#ifndef lint
#ifndef NOID
static char tzfilehid[] = "@(#)tzfile.h 8.1";
#endif /* !defined NOID */
#endif /* !defined lint */
/* /*
** Information about time zone files. ** Information about time zone files.
*/ */
#ifndef TZDIR #ifndef TZDIR
#define TZDIR "/system/usr/share/zoneinfo" /* Time zone object file directory */ #define TZDIR "/usr/local/etc/zoneinfo" /* Time zone object file directory */
#endif /* !defined TZDIR */ #endif /* !defined TZDIR */
#ifndef TZDEFAULT #ifndef TZDEFAULT
#define TZDEFAULT "localtime" #define TZDEFAULT "localtime"
#endif /* !defined TZDEFAULT */ #endif /* !defined TZDEFAULT */
#ifndef TZDEFRULES #ifndef TZDEFRULES
#define TZDEFRULES "posixrules" #define TZDEFRULES "posixrules"
#endif /* !defined TZDEFRULES */ #endif /* !defined TZDEFRULES */
/* /*
** Each file begins with. . . ** Each file begins with. . .
*/ */
#define TZ_MAGIC "TZif" #define TZ_MAGIC "TZif"
struct tzhead { struct tzhead {
char tzh_magic[4]; /* TZ_MAGIC */ char tzh_magic[4]; /* TZ_MAGIC */
char tzh_version[1]; /* '\0' or '2' as of 2005 */ char tzh_version[1]; /* '\0' or '2' as of 2005 */
char tzh_reserved[15]; /* reserved--must be zero */ char tzh_reserved[15]; /* reserved--must be zero */
char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */ char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */
char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
char tzh_leapcnt[4]; /* coded number of leap seconds */ char tzh_leapcnt[4]; /* coded number of leap seconds */
char tzh_timecnt[4]; /* coded number of transition times */ char tzh_timecnt[4]; /* coded number of transition times */
char tzh_typecnt[4]; /* coded number of local time types */ char tzh_typecnt[4]; /* coded number of local time types */
char tzh_charcnt[4]; /* coded number of abbr. chars */ char tzh_charcnt[4]; /* coded number of abbr. chars */
}; };
/* /*
** . . .followed by. . . ** . . .followed by. . .
** **
** tzh_timecnt (char [4])s coded transition times a la time(2) ** tzh_timecnt (char [4])s coded transition times a la time(2)
** tzh_timecnt (unsigned char)s types of local time starting at above ** tzh_timecnt (unsigned char)s types of local time starting at above
** tzh_typecnt repetitions of ** tzh_typecnt repetitions of
** one (char [4]) coded UTC offset in seconds ** one (char [4]) coded UTC offset in seconds
** one (unsigned char) used to set tm_isdst ** one (unsigned char) used to set tm_isdst
** one (unsigned char) that's an abbreviation list index ** one (unsigned char) that's an abbreviation list index
** tzh_charcnt (char)s '\0'-terminated zone abbreviations ** tzh_charcnt (char)s '\0'-terminated zone abbreviations
** tzh_leapcnt repetitions of ** tzh_leapcnt repetitions of
** one (char [4]) coded leap second transition times ** one (char [4]) coded leap second transition times
** one (char [4]) total correction after above ** one (char [4]) total correction after above
** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition ** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
** time is standard time, if FALSE, ** time is standard time, if FALSE,
** transition time is wall clock time ** transition time is wall clock time
** if absent, transition times are ** if absent, transition times are
** assumed to be wall clock time ** assumed to be wall clock time
** tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition ** tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition
** time is UTC, if FALSE, ** time is UTC, if FALSE,
** transition time is local time ** transition time is local time
** if absent, transition times are ** if absent, transition times are
** assumed to be local time ** assumed to be local time
*/ */
/* /*
@ -100,81 +90,81 @@ struct tzhead {
*/ */
#ifndef TZ_MAX_TIMES #ifndef TZ_MAX_TIMES
#define TZ_MAX_TIMES 1200 #define TZ_MAX_TIMES 1200
#endif /* !defined TZ_MAX_TIMES */ #endif /* !defined TZ_MAX_TIMES */
#ifndef TZ_MAX_TYPES #ifndef TZ_MAX_TYPES
#ifndef NOSOLAR #ifndef NOSOLAR
#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ #define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
#endif /* !defined NOSOLAR */ #endif /* !defined NOSOLAR */
#ifdef NOSOLAR #ifdef NOSOLAR
/* /*
** Must be at least 14 for Europe/Riga as of Jan 12 1995, ** Must be at least 14 for Europe/Riga as of Jan 12 1995,
** as noted by Earl Chew. ** as noted by Earl Chew.
*/ */
#define TZ_MAX_TYPES 20 /* Maximum number of local time types */ #define TZ_MAX_TYPES 20 /* Maximum number of local time types */
#endif /* !defined NOSOLAR */ #endif /* !defined NOSOLAR */
#endif /* !defined TZ_MAX_TYPES */ #endif /* !defined TZ_MAX_TYPES */
#ifndef TZ_MAX_CHARS #ifndef TZ_MAX_CHARS
#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ #define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
/* (limited by what unsigned chars can hold) */ /* (limited by what unsigned chars can hold) */
#endif /* !defined TZ_MAX_CHARS */ #endif /* !defined TZ_MAX_CHARS */
#ifndef TZ_MAX_LEAPS #ifndef TZ_MAX_LEAPS
#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ #define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
#endif /* !defined TZ_MAX_LEAPS */ #endif /* !defined TZ_MAX_LEAPS */
#define SECSPERMIN 60 #define SECSPERMIN 60
#define MINSPERHOUR 60 #define MINSPERHOUR 60
#define HOURSPERDAY 24 #define HOURSPERDAY 24
#define DAYSPERWEEK 7 #define DAYSPERWEEK 7
#define DAYSPERNYEAR 365 #define DAYSPERNYEAR 365
#define DAYSPERLYEAR 366 #define DAYSPERLYEAR 366
#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) #define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) #define SECSPERDAY ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)
#define MONSPERYEAR 12 #define MONSPERYEAR 12
#define TM_SUNDAY 0 #define TM_SUNDAY 0
#define TM_MONDAY 1 #define TM_MONDAY 1
#define TM_TUESDAY 2 #define TM_TUESDAY 2
#define TM_WEDNESDAY 3 #define TM_WEDNESDAY 3
#define TM_THURSDAY 4 #define TM_THURSDAY 4
#define TM_FRIDAY 5 #define TM_FRIDAY 5
#define TM_SATURDAY 6 #define TM_SATURDAY 6
#define TM_JANUARY 0 #define TM_JANUARY 0
#define TM_FEBRUARY 1 #define TM_FEBRUARY 1
#define TM_MARCH 2 #define TM_MARCH 2
#define TM_APRIL 3 #define TM_APRIL 3
#define TM_MAY 4 #define TM_MAY 4
#define TM_JUNE 5 #define TM_JUNE 5
#define TM_JULY 6 #define TM_JULY 6
#define TM_AUGUST 7 #define TM_AUGUST 7
#define TM_SEPTEMBER 8 #define TM_SEPTEMBER 8
#define TM_OCTOBER 9 #define TM_OCTOBER 9
#define TM_NOVEMBER 10 #define TM_NOVEMBER 10
#define TM_DECEMBER 11 #define TM_DECEMBER 11
#define TM_YEAR_BASE 1900 #define TM_YEAR_BASE 1900
#define EPOCH_YEAR 1970 #define EPOCH_YEAR 1970
#define EPOCH_WDAY TM_THURSDAY #define EPOCH_WDAY TM_THURSDAY
#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
/* /*
** Since everything in isleap is modulo 400 (or a factor of 400), we know that ** Since everything in isleap is modulo 400 (or a factor of 400), we know that
** isleap(y) == isleap(y % 400) ** isleap(y) == isleap(y % 400)
** and so ** and so
** isleap(a + b) == isleap((a + b) % 400) ** isleap(a + b) == isleap((a + b) % 400)
** or ** or
** isleap(a + b) == isleap(a % 400 + b % 400) ** isleap(a + b) == isleap(a % 400 + b % 400)
** This is true even if % means modulo rather than Fortran remainder ** This is true even if % means modulo rather than Fortran remainder
** (which is allowed by C89 but not C99). ** (which is allowed by C89 but not C99).
** We use this to avoid addition overflow problems. ** We use this to avoid addition overflow problems.
*/ */
#define isleap_sum(a, b) isleap((a) % 400 + (b) % 400) #define isleap_sum(a, b) isleap((a) % 400 + (b) % 400)
#endif /* !defined TZFILE_H */ #endif /* !defined TZFILE_H */