commit 400ecf36bb0b73f6390f9641e6cb8bbfb91a5cfd
   Author: Paul Eggert <eggert@cs.ucla.edu>
   Date:   Fri Oct 12 07:53:12 2012 -0700

   Assume C89.

400ecf36bb
This commit is contained in:
rodrigc 2015-10-08 11:42:15 +00:00
parent 753bf3d282
commit a931eab7f4
3 changed files with 45 additions and 80 deletions

View File

@ -18,9 +18,7 @@ __FBSDID("$FreeBSD$");
#include "un-namespace.h" #include "un-namespace.h"
double double
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

View File

@ -173,8 +173,9 @@ struct rule {
static long detzcode(const char * codep); static long detzcode(const char * codep);
static time_t detzcode64(const char * codep); static time_t detzcode64(const char * codep);
static int differ_by_repeat(time_t t1, time_t t0); static int differ_by_repeat(time_t t1, time_t t0);
static const char * getzname(const char * strp); static const char * getzname(const char * strp) ATTRIBUTE_PURE;
static const char * getqzname(const char * strp, const int delim); static const char * getqzname(const char * strp, const int delim)
ATTRIBUTE_PURE;
static const char * getnum(const char * strp, int * nump, int min, static const char * getnum(const char * strp, int * nump, int min,
int max); int max);
static const char * getsecs(const char * strp, long * secsp); static const char * getsecs(const char * strp, long * secsp);
@ -186,7 +187,7 @@ static struct tm * gmtsub(const time_t * timep, long offset,
static struct tm * localsub(const time_t * timep, long offset, static struct tm * localsub(const time_t * timep, long offset,
struct tm * tmp); struct tm * tmp);
static int increment_overflow(int * number, int delta); static int increment_overflow(int * number, int delta);
static int leaps_thru_end_of(int y); static int leaps_thru_end_of(int y) ATTRIBUTE_PURE;
static int long_increment_overflow(long * number, int delta); static int long_increment_overflow(long * number, int delta);
static int long_normalize_overflow(long * tensptr, static int long_normalize_overflow(long * tensptr,
int * unitsptr, int base); int * unitsptr, int base);
@ -210,7 +211,8 @@ static struct tm * timesub(const time_t * timep, long offset,
static int tmcomp(const struct tm * atmp, static int tmcomp(const struct tm * atmp,
const struct tm * btmp); const struct tm * btmp);
static time_t transtime(time_t janfirst, int year, static time_t transtime(time_t janfirst, int year,
const struct rule * rulep, long offset); const struct rule * rulep, long offset)
ATTRIBUTE_PURE;
static int typesequiv(const struct state * sp, int a, int b); static int typesequiv(const struct state * sp, int a, int b);
static int tzload(const char * name, struct state * sp, static int tzload(const char * name, struct state * sp,
int doextend); int doextend);
@ -269,8 +271,7 @@ time_t altzone = 0;
#endif /* defined ALTZONE */ #endif /* defined ALTZONE */
static long static long
detzcode(codep) detzcode(const char *const codep)
const char * const codep;
{ {
long result; long result;
int i; int i;
@ -282,8 +283,7 @@ const char * const codep;
} }
static time_t static time_t
detzcode64(codep) detzcode64(const char *const codep)
const char * const codep;
{ {
register time_t result; register time_t result;
register int i; register int i;
@ -355,9 +355,7 @@ settzname(void)
} }
static int static int
differ_by_repeat(t1, t0) differ_by_repeat(const time_t t1, const time_t t0)
const time_t t1;
const time_t t0;
{ {
int_fast64_t _t0 = t0; int_fast64_t _t0 = t0;
int_fast64_t _t1 = t1; int_fast64_t _t1 = t1;
@ -1217,8 +1215,7 @@ const int lastditch;
} }
static void static void
gmtload(sp) gmtload(struct state *const sp)
struct state * const sp;
{ {
if (tzload(gmt, sp, TRUE) != 0) if (tzload(gmt, sp, TRUE) != 0)
(void) tzparse(gmt, sp, TRUE); (void) tzparse(gmt, sp, TRUE);
@ -1241,7 +1238,7 @@ tzsetwall_basic(int rdlocked)
#ifdef ALL_STATE #ifdef ALL_STATE
if (lclptr == NULL) { if (lclptr == NULL) {
lclptr = (struct state *) calloc(1, sizeof *lclptr); lclptr = calloc(1, sizeof *lclptr);
if (lclptr == NULL) { if (lclptr == NULL) {
settzname(); /* all we can do */ settzname(); /* all we can do */
_RWLOCK_UNLOCK(&lcl_rwlock); _RWLOCK_UNLOCK(&lcl_rwlock);
@ -1341,10 +1338,7 @@ tzset(void)
/*ARGSUSED*/ /*ARGSUSED*/
static struct tm * static struct tm *
localsub(timep, offset, tmp) localsub(const time_t *const timep, const long offset, struct tm *const tmp)
const time_t * const timep;
const long offset;
struct tm * const tmp;
{ {
struct state * sp; struct state * sp;
const struct ttinfo * ttisp; const struct ttinfo * ttisp;
@ -1440,8 +1434,7 @@ localtime_key_init(void)
} }
struct tm * struct tm *
localtime(timep) localtime(const time_t *const timep)
const time_t * const timep;
{ {
struct tm *p_tm; struct tm *p_tm;
@ -1475,9 +1468,7 @@ const time_t * const timep;
*/ */
struct tm * struct tm *
localtime_r(timep, tmp) localtime_r(const time_t *const timep, struct tm *tmp)
const time_t * const timep;
struct tm * tmp;
{ {
_RWLOCK_RDLOCK(&lcl_rwlock); _RWLOCK_RDLOCK(&lcl_rwlock);
tzset_basic(1); tzset_basic(1);
@ -1541,8 +1532,7 @@ gmtime_key_init(void)
} }
struct tm * struct tm *
gmtime(timep) gmtime(const time_t *const timep)
const time_t * const timep;
{ {
struct tm *p_tm; struct tm *p_tm;
@ -1577,9 +1567,7 @@ const time_t * const timep;
*/ */
struct tm * struct tm *
gmtime_r(timep, tmp) gmtime_r(const time_t *const timep, struct tm *tmp)
const time_t * const timep;
struct tm * tmp;
{ {
return gmtsub(timep, 0L, tmp); return gmtsub(timep, 0L, tmp);
} }
@ -1587,9 +1575,7 @@ struct tm * tmp;
#ifdef STD_INSPIRED #ifdef STD_INSPIRED
struct tm * struct tm *
offtime(timep, offset) offtime(const time_t *const timep, const long offset)
const time_t * const timep;
const long offset;
{ {
return gmtsub(timep, offset, &tm); return gmtsub(timep, offset, &tm);
} }
@ -1744,8 +1730,7 @@ struct tm * const tmp;
} }
char * char *
ctime(timep) ctime(const time_t *const timep)
const time_t * const timep;
{ {
/* /*
** Section 4.12.3.2 of X3.159-1989 requires that ** Section 4.12.3.2 of X3.159-1989 requires that
@ -1757,9 +1742,7 @@ const time_t * const timep;
} }
char * char *
ctime_r(timep, buf) ctime_r(const time_t *const timep, char *buf)
const time_t * const timep;
char * buf;
{ {
struct tm mytm; struct tm mytm;
@ -1808,10 +1791,7 @@ int delta;
} }
static int static int
normalize_overflow(tensptr, unitsptr, base) normalize_overflow(int *const tensptr, int *const unitsptr, const int base)
int * const tensptr;
int * const unitsptr;
const int base;
{ {
int tensdelta; int tensdelta;
@ -1823,10 +1803,7 @@ const int base;
} }
static int static int
long_normalize_overflow(tensptr, unitsptr, base) long_normalize_overflow(long *const tensptr, int *const unitsptr, const int base)
long * const tensptr;
int * const unitsptr;
const int base;
{ {
register int tensdelta; register int tensdelta;
@ -1854,12 +1831,11 @@ const struct tm * const btmp;
} }
static time_t static time_t
time2sub(tmp, funcp, offset, okayp, do_norm_secs) time2sub(struct tm *const tmp,
struct tm * const tmp; struct tm *(*const funcp)(const time_t *, long, struct tm *),
struct tm * (* const funcp)(const time_t*, long, struct tm*); const long offset,
const long offset; int *const okayp,
int * const okayp; const int do_norm_secs)
const int do_norm_secs;
{ {
const struct state * sp; const struct state * sp;
int dir; int dir;
@ -2041,11 +2017,10 @@ const int do_norm_secs;
} }
static time_t static time_t
time2(tmp, funcp, offset, okayp) time2(struct tm * const tmp,
struct tm * const tmp; struct tm * (*const funcp)(const time_t *, long, struct tm *),
struct tm * (* const funcp)(const time_t*, long, struct tm*); const long offset,
const long offset; int *const okayp)
int * const okayp;
{ {
time_t t; time_t t;
@ -2137,8 +2112,7 @@ const long offset;
} }
time_t time_t
mktime(tmp) mktime(struct tm *const tmp)
struct tm * const tmp;
{ {
time_t mktime_return_value; time_t mktime_return_value;
_RWLOCK_RDLOCK(&lcl_rwlock); _RWLOCK_RDLOCK(&lcl_rwlock);
@ -2151,8 +2125,7 @@ struct tm * const tmp;
#ifdef STD_INSPIRED #ifdef STD_INSPIRED
time_t time_t
timelocal(tmp) timelocal(struct tm *const tmp)
struct tm * const tmp;
{ {
if (tmp != NULL) if (tmp != NULL)
tmp->tm_isdst = -1; /* in case it wasn't initialized */ tmp->tm_isdst = -1; /* in case it wasn't initialized */
@ -2160,8 +2133,7 @@ struct tm * const tmp;
} }
time_t time_t
timegm(tmp) timegm(struct tm *const tmp)
struct tm * const tmp;
{ {
if (tmp != NULL) if (tmp != NULL)
tmp->tm_isdst = 0; tmp->tm_isdst = 0;
@ -2169,9 +2141,7 @@ struct tm * const tmp;
} }
time_t time_t
timeoff(tmp, offset) timeoff(struct tm *const tmp, const long offset)
struct tm * const tmp;
const long offset;
{ {
if (tmp != NULL) if (tmp != NULL)
tmp->tm_isdst = 0; tmp->tm_isdst = 0;
@ -2188,8 +2158,7 @@ const long offset;
*/ */
long long
gtime(tmp) gtime(struct tm *const tmp)
struct tm * const tmp;
{ {
const time_t t = mktime(tmp); const time_t t = mktime(tmp);
@ -2215,8 +2184,7 @@ struct tm * const tmp;
*/ */
static long static long
leapcorr(timep) leapcorr(time_t *timep)
time_t * timep;
{ {
struct state * sp; struct state * sp;
struct lsinfo * lp; struct lsinfo * lp;
@ -2233,16 +2201,14 @@ time_t * timep;
} }
time_t time_t
time2posix(t) time2posix(time_t t)
time_t t;
{ {
tzset(); tzset();
return t - leapcorr(&t); return t - leapcorr(&t);
} }
time_t time_t
posix2time(t) posix2time(time_t t)
time_t t;
{ {
time_t x; time_t x;
time_t y; time_t y;

View File

@ -173,6 +173,12 @@ 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__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)
# define ATTRIBUTE_PURE __attribute__ ((__pure__))
#else
# define ATTRIBUTE_PURE /* empty */
#endif
/* /*
** Workarounds for compilers/systems. ** Workarounds for compilers/systems.
*/ */
@ -191,13 +197,8 @@ extern char * asctime_r(struct tm const *, char *);
** Private function declarations. ** Private function declarations.
*/ */
char * icalloc(int nelem, int elsize);
char * icatalloc(char * old, const char * new); char * icatalloc(char * old, const char * new);
char * icpyalloc(const char * string); char * icpyalloc(const char * string);
char * imalloc(int n);
void * irealloc(void * pointer, int size);
void icfree(char * pointer);
void ifree(char * pointer);
const char * scheck(const char * string, const char * format); const char * scheck(const char * string, const char * format);
/* /*