diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2015-09-12 14:35:41 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2015-09-12 14:35:41 +0000 |
commit | b07c97c87be5939f100e53cd34f6fa62eaaaf71e (patch) | |
tree | f6bd4fcf637650a0335d25eb1e65a995a39240e0 | |
parent | cbc615853ba21e735aa71aff468b9f0f8dd2843c (diff) |
Wrap <time.h> so that internal calls go direct and symbols not in C99 are weak
Add prototypes to localtime.c for offtime(), time2posix(), posix2time() to
reduce noise with -Wmissing-prototypes
Eliminate unnecessary #includes
-rw-r--r-- | lib/libc/gen/time.c | 5 | ||||
-rw-r--r-- | lib/libc/hidden/time.h | 25 | ||||
-rw-r--r-- | lib/libc/time/asctime.c | 4 | ||||
-rw-r--r-- | lib/libc/time/localtime.c | 18 | ||||
-rw-r--r-- | lib/libc/time/strftime.c | 3 | ||||
-rw-r--r-- | lib/libc/time/strptime.c | 3 |
6 files changed, 51 insertions, 7 deletions
diff --git a/lib/libc/gen/time.c b/lib/libc/gen/time.c index 3a57500d433..bb63f42384d 100644 --- a/lib/libc/gen/time.c +++ b/lib/libc/gen/time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: time.c,v 1.5 2005/08/08 08:05:34 espie Exp $ */ +/* $OpenBSD: time.c,v 1.6 2015/09/12 14:35:40 guenther Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -28,8 +28,8 @@ * SUCH DAMAGE. */ -#include <sys/types.h> #include <sys/time.h> +#include <time.h> time_t time(time_t *t) @@ -42,3 +42,4 @@ time(time_t *t) *t = (time_t)tt.tv_sec; return (tt.tv_sec); } +DEF_STRONG(time); diff --git a/lib/libc/hidden/time.h b/lib/libc/hidden/time.h index f28504cd9e2..188f40c8a60 100644 --- a/lib/libc/hidden/time.h +++ b/lib/libc/hidden/time.h @@ -1,4 +1,4 @@ -/* $OpenBSD: time.h,v 1.1 2015/09/11 15:38:33 guenther Exp $ */ +/* $OpenBSD: time.h,v 1.2 2015/09/12 14:35:40 guenther Exp $ */ /* * Copyright (c) 2015 Philip Guenther <guenther@openbsd.org> * @@ -20,8 +20,31 @@ #include_next <time.h> +extern PROTO_NORMAL(tzname); + +PROTO_NORMAL(asctime); +PROTO_NORMAL(asctime_r); +PROTO_STD_DEPRECATED(clock); +PROTO_DEPRECATED(clock_getcpuclockid); PROTO_NORMAL(clock_getres); PROTO_NORMAL(clock_gettime); PROTO_NORMAL(clock_settime); +PROTO_STD_DEPRECATED(ctime); +PROTO_DEPRECATED(ctime_r); +PROTO_STD_DEPRECATED(difftime); +PROTO_NORMAL(gmtime); +PROTO_NORMAL(gmtime_r); +PROTO_NORMAL(localtime); +PROTO_NORMAL(localtime_r); +PROTO_NORMAL(mktime); +/*PROTO_CANCEL(nanosleep);*/ +PROTO_NORMAL(strftime); +PROTO_NORMAL(strptime); +PROTO_NORMAL(time); +PROTO_DEPRECATED(timegm); +PROTO_DEPRECATED(timelocal); +PROTO_DEPRECATED(timeoff); +PROTO_NORMAL(tzset); +PROTO_DEPRECATED(tzsetwall); #endif /* !_LIBC_TIME_H_ */ diff --git a/lib/libc/time/asctime.c b/lib/libc/time/asctime.c index 403cfcc361c..16203d747e7 100644 --- a/lib/libc/time/asctime.c +++ b/lib/libc/time/asctime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asctime.c,v 1.21 2015/02/16 17:35:38 tedu Exp $ */ +/* $OpenBSD: asctime.c,v 1.22 2015/09/12 14:35:40 guenther Exp $ */ /* ** This file is in the public domain, so clarified as of ** 1996-06-05 by Arthur David Olson. @@ -117,6 +117,7 @@ asctime_r(const struct tm *timeptr, char *buf) */ return asctime3(timeptr, buf, STD_ASCTIME_BUF_SIZE); } +DEF_WEAK(asctime_r); /* ** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, 2004 Edition. @@ -134,3 +135,4 @@ asctime(const struct tm *timeptr) else return asctime3(timeptr, resultp, sizeof(result)); } +DEF_STRONG(asctime); diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c index 4e1d22b476a..c84649affcb 100644 --- a/lib/libc/time/localtime.c +++ b/lib/libc/time/localtime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: localtime.c,v 1.52 2015/04/07 01:47:04 millert Exp $ */ +/* $OpenBSD: localtime.c,v 1.53 2015/09/12 14:35:40 guenther Exp $ */ /* ** This file is in the public domain, so clarified as of ** 1996-06-05 by Arthur David Olson. @@ -168,6 +168,15 @@ static int tzload(const char * name, struct state * sp, static int tzparse(const char * name, struct state * sp, int lastditch); +#ifdef STD_INSPIRED +struct tm *offtime(const time_t *, long); +time_t time2posix(time_t); +time_t posix2time(time_t); +PROTO_DEPRECATED(offtime); +PROTO_DEPRECATED(time2posix); +PROTO_DEPRECATED(posix2time); +#endif + static struct state * lclptr; static struct state * gmtptr; @@ -186,6 +195,7 @@ char * tzname[2] = { wildabbr, wildabbr }; +DEF_WEAK(tzname); /* ** Section 4.12.3 of X3.159-1989 requires that @@ -1169,6 +1179,7 @@ tzset(void) tzset_basic(); _THREAD_PRIVATE_MUTEX_UNLOCK(lcl); } +DEF_WEAK(tzset); /* ** The easy way to behave "as if no library function calls" localtime @@ -1285,6 +1296,7 @@ localtime_r(const time_t *timep, struct tm *p_tm) _THREAD_PRIVATE_MUTEX_UNLOCK(lcl); return p_tm; } +DEF_WEAK(localtime_r); struct tm * localtime(const time_t *timep) @@ -1296,6 +1308,7 @@ localtime(const time_t *timep) return NULL; return localtime_r(timep, p_tm); } +DEF_STRONG(localtime); /* ** gmtsub is to gmtime as localsub is to localtime. @@ -1343,6 +1356,7 @@ gmtime_r(const time_t *timep, struct tm *p_tm) gmtsub(timep, 0L, p_tm); return p_tm; } +DEF_WEAK(gmtime_r); struct tm * gmtime(const time_t *timep) @@ -1355,6 +1369,7 @@ gmtime(const time_t *timep) return gmtime_r(timep, p_tm); } +DEF_WEAK(gmtime); #ifdef STD_INSPIRED @@ -1876,6 +1891,7 @@ mktime(struct tm *tmp) _THREAD_PRIVATE_MUTEX_UNLOCK(lcl); return ret; } +DEF_STRONG(mktime); #ifdef STD_INSPIRED diff --git a/lib/libc/time/strftime.c b/lib/libc/time/strftime.c index 4c117f184c9..84c4c18e38f 100644 --- a/lib/libc/time/strftime.c +++ b/lib/libc/time/strftime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strftime.c,v 1.26 2015/02/16 17:11:54 tedu Exp $ */ +/* $OpenBSD: strftime.c,v 1.27 2015/09/12 14:35:40 guenther Exp $ */ /* ** Copyright (c) 1989, 1993 ** The Regents of the University of California. All rights reserved. @@ -136,6 +136,7 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *t) *p = '\0'; return p - s; } +DEF_STRONG(strftime); static char * _fmt(const char *format, const struct tm *t, char *pt, const char *ptlim, int *warnp) diff --git a/lib/libc/time/strptime.c b/lib/libc/time/strptime.c index 8c337a2ce1e..fe78b476b98 100644 --- a/lib/libc/time/strptime.c +++ b/lib/libc/time/strptime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strptime.c,v 1.20 2015/04/07 01:49:11 millert Exp $ */ +/* $OpenBSD: strptime.c,v 1.21 2015/09/12 14:35:40 guenther Exp $ */ /* $NetBSD: strptime.c,v 1.12 1998/01/20 21:39:40 mycroft Exp $ */ /*- * Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc. @@ -83,6 +83,7 @@ strptime(const char *buf, const char *fmt, struct tm *tm) { return(_strptime(buf, fmt, tm, 1)); } +DEF_WEAK(strptime); static char * _strptime(const char *buf, const char *fmt, struct tm *tm, int initialize) |