diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2015-09-06 20:26:21 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2015-09-06 20:26:21 +0000 |
commit | c6bf97d16a542c52641d770845f80d8ec64ac35a (patch) | |
tree | ed721a3e95fc1990f483b41d7d802c744f00b604 | |
parent | bacd9b916ff9a0a46a5789e4cba77f57eb617158 (diff) |
Fix aliasing of sys_errlist, sys_nerr, sys_siglist, and sys_signame
to eliminate duplicate copies of the tables and get direct access internally
ok kettenis@ deraadt@
-rw-r--r-- | lib/libc/Symbols.list | 3 | ||||
-rw-r--r-- | lib/libc/gen/Makefile.inc | 5 | ||||
-rw-r--r-- | lib/libc/gen/_sys_errlist.c | 26 | ||||
-rw-r--r-- | lib/libc/gen/_sys_nerr.c | 12 | ||||
-rw-r--r-- | lib/libc/gen/_sys_siglist.c | 22 | ||||
-rw-r--r-- | lib/libc/gen/errlist.c | 13 | ||||
-rw-r--r-- | lib/libc/gen/siglist.c | 6 | ||||
-rw-r--r-- | lib/libc/gen/signame.c | 3 | ||||
-rw-r--r-- | lib/libc/hidden/errno.h | 35 | ||||
-rw-r--r-- | lib/libc/hidden/signal.h | 27 | ||||
-rw-r--r-- | lib/libc/hidden/stdio.h | 13 | ||||
-rw-r--r-- | lib/libc/include/namespace.h | 9 | ||||
-rw-r--r-- | lib/libc/string/strerror_r.c | 10 |
13 files changed, 93 insertions, 91 deletions
diff --git a/lib/libc/Symbols.list b/lib/libc/Symbols.list index c48e3c0ce1e..c74a51b4d17 100644 --- a/lib/libc/Symbols.list +++ b/lib/libc/Symbols.list @@ -515,9 +515,6 @@ __sigintr __signbit __signbitf __signbitl -__sys_errlist -__sys_nerr -__sys_siglist _ctype_ _longjmp _ng_makekey diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index f3fe2098195..981850d70b6 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.68 2015/04/07 01:47:04 millert Exp $ +# $OpenBSD: Makefile.inc,v 1.69 2015/09/06 20:26:20 guenther Exp $ # gen sources .PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/gen ${LIBCSRCDIR}/gen @@ -27,9 +27,6 @@ SRCS+= alarm.c assert.c auth_subr.c authenticate.c \ utime.c valloc.c vis.c wait.c wait3.c waitpid.c warn.c \ warnc.c warnx.c vwarn.c vwarnc.c vwarnx.c verr.c verrc.c verrx.c -# indirect reference stubs, to be removed soon. -SRCS+= _sys_errlist.c _sys_nerr.c _sys_siglist.c - # machine-dependent gen sources # m-d Makefile.inc must include sources for: # _setjmp() fabs() frexp() infinity ldexp() modf() __nan diff --git a/lib/libc/gen/_sys_errlist.c b/lib/libc/gen/_sys_errlist.c deleted file mode 100644 index eca96af95f0..00000000000 --- a/lib/libc/gen/_sys_errlist.c +++ /dev/null @@ -1,26 +0,0 @@ -/* $OpenBSD: _sys_errlist.c,v 1.4 2012/12/05 23:19:59 deraadt Exp $ */ -/* - * Written by J.T. Conklin, December 12, 1994 - * Public domain. - */ - -#include <sys/types.h> - -#ifdef __indr_reference -__indr_reference(_sys_errlist, sys_errlist); -__indr_reference(_sys_errlist, __sys_errlist); /* Backwards compat with v.12 */ -#else - -#undef _sys_errlist -#undef _sys_nerr -#define _sys_errlist sys_errlist -#define _sys_nerr sys_nerr -#include "errlist.c" - -#undef _sys_errlist -#undef _sys_nerr -#define _sys_errlist __sys_errlist -#define _sys_nerr __sys_nerr -#include "errlist.c" - -#endif diff --git a/lib/libc/gen/_sys_nerr.c b/lib/libc/gen/_sys_nerr.c deleted file mode 100644 index a053debdc9b..00000000000 --- a/lib/libc/gen/_sys_nerr.c +++ /dev/null @@ -1,12 +0,0 @@ -/* $OpenBSD: _sys_nerr.c,v 1.4 2012/12/05 23:19:59 deraadt Exp $ */ -/* - * Written by J.T. Conklin, December 12, 1994 - * Public domain. - */ - -#include <sys/types.h> - -#ifdef __indr_reference -__indr_reference(_sys_nerr, sys_nerr); -__indr_reference(_sys_nerr, __sys_nerr); /* Backwards compat with v.12 */ -#endif diff --git a/lib/libc/gen/_sys_siglist.c b/lib/libc/gen/_sys_siglist.c deleted file mode 100644 index 877709eb3a2..00000000000 --- a/lib/libc/gen/_sys_siglist.c +++ /dev/null @@ -1,22 +0,0 @@ -/* $OpenBSD: _sys_siglist.c,v 1.4 2012/12/05 23:19:59 deraadt Exp $ */ -/* - * Written by J.T. Conklin, December 12, 1994 - * Public domain. - */ - -#include <sys/types.h> - -#ifdef __indr_reference -__indr_reference(_sys_siglist, sys_siglist); -__indr_reference(_sys_siglist, __sys_siglist); /* Backwards compat with v.12 */ -#else - -#undef _sys_siglist -#define _sys_siglist sys_siglist -#include "siglist.c" - -#undef _sys_siglist -#define _sys_siglist __sys_siglist -#include "siglist.c" - -#endif diff --git a/lib/libc/gen/errlist.c b/lib/libc/gen/errlist.c index a1963162c26..cd957e4024d 100644 --- a/lib/libc/gen/errlist.c +++ b/lib/libc/gen/errlist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: errlist.c,v 1.15 2014/03/16 18:38:30 guenther Exp $ */ +/* $OpenBSD: errlist.c,v 1.16 2015/09/06 20:26:20 guenther Exp $ */ /* * Copyright (c) 1982, 1985, 1993 * The Regents of the University of California. All rights reserved. @@ -28,7 +28,9 @@ * SUCH DAMAGE. */ -const char *const _sys_errlist[] = { +#include <errno.h> + +const char *const sys_errlist[] = { "Undefined error: 0", /* 0 - ENOERROR */ "Operation not permitted", /* 1 - EPERM */ "No such file or directory", /* 2 - ENOENT */ @@ -141,4 +143,9 @@ const char *const _sys_errlist[] = { "No message of desired type", /* 90 - ENOMSG */ "Not supported", /* 91 - ENOTSUP */ }; -int _sys_nerr = { sizeof _sys_errlist/sizeof _sys_errlist[0] }; +DEF_WEAK(sys_errlist); +const int sys_nerr = { sizeof sys_errlist/sizeof sys_errlist[0] }; +DEF_WEAK(sys_nerr); + +__strong_alias(_sys_errlist, sys_errlist); +__strong_alias(_sys_nerr, sys_nerr); diff --git a/lib/libc/gen/siglist.c b/lib/libc/gen/siglist.c index 70002c538b5..1fb94722101 100644 --- a/lib/libc/gen/siglist.c +++ b/lib/libc/gen/siglist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: siglist.c,v 1.6 2012/12/05 23:20:00 deraadt Exp $ */ +/* $OpenBSD: siglist.c,v 1.7 2015/09/06 20:26:20 guenther Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -30,7 +30,7 @@ #include <signal.h> -const char *const _sys_siglist[NSIG] = { +const char *const sys_siglist[NSIG] = { "Signal 0", "Hangup", /* SIGHUP */ "Interrupt", /* SIGINT */ @@ -65,3 +65,5 @@ const char *const _sys_siglist[NSIG] = { "User defined signal 2", /* SIGUSR2 */ "Thread AST", /* SIGTHR */ }; +DEF_WEAK(sys_siglist); +__strong_alias(_sys_siglist, sys_siglist); diff --git a/lib/libc/gen/signame.c b/lib/libc/gen/signame.c index 39841917fa9..79d2fe743d0 100644 --- a/lib/libc/gen/signame.c +++ b/lib/libc/gen/signame.c @@ -1,4 +1,4 @@ -/* $OpenBSD: signame.c,v 1.5 2009/11/27 19:47:45 guenther Exp $ */ +/* $OpenBSD: signame.c,v 1.6 2015/09/06 20:26:20 guenther Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. @@ -66,3 +66,4 @@ const char *const sys_signame[NSIG] = { "USR2", /* SIGUSR2 */ "THR", /* SIGTHR */ }; +DEF_WEAK(sys_signame); diff --git a/lib/libc/hidden/errno.h b/lib/libc/hidden/errno.h new file mode 100644 index 00000000000..ee18c32f089 --- /dev/null +++ b/lib/libc/hidden/errno.h @@ -0,0 +1,35 @@ +/* $OpenBSD: errno.h,v 1.1 2015/09/06 20:26:20 guenther Exp $ */ +/* + * Copyright (c) 2015 Philip Guenther <guenther@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBC_ERRNO_H_ +#define _LIBC_ERRNO_H_ + +/* we want the const-correct declarations inside libc */ +#define __SYS_ERRLIST + +#include_next <errno.h> +#include "namespace.h" + +extern const int sys_nerr; +extern const char *const sys_errlist[]; + +extern PROTO_NORMAL(sys_nerr); +extern PROTO_NORMAL(sys_errlist); + +/*PROTO_OVERRIDABLE(__errno);*/ + +#endif /* _LIBC_ERRNO_H_ */ diff --git a/lib/libc/hidden/signal.h b/lib/libc/hidden/signal.h new file mode 100644 index 00000000000..f3535fcabea --- /dev/null +++ b/lib/libc/hidden/signal.h @@ -0,0 +1,27 @@ +/* $OpenBSD: signal.h,v 1.1 2015/09/06 20:26:20 guenther Exp $ */ +/* + * Copyright (c) 2015 Philip Guenther <guenther@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBC_SIGNAL_H +#define _LIBC_SIGNAL_H + +#include_next <signal.h> +#include "namespace.h" + +extern PROTO_NORMAL(sys_siglist); +extern PROTO_NORMAL(sys_signame); + +#endif /* !_LIBC_SIGNAL_H */ diff --git a/lib/libc/hidden/stdio.h b/lib/libc/hidden/stdio.h index 8a5530cd54f..440a6bbfc8b 100644 --- a/lib/libc/hidden/stdio.h +++ b/lib/libc/hidden/stdio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: stdio.h,v 1.1 2015/08/31 02:53:56 guenther Exp $ */ +/* $OpenBSD: stdio.h,v 1.2 2015/09/06 20:26:20 guenther Exp $ */ /* * Copyright (c) 2015 Philip Guenther <guenther@openbsd.org> * @@ -14,12 +14,13 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $OpenBSD: stdio.h,v 1.1 2015/08/31 02:53:56 guenther Exp $ */ -/* $NetBSD: stdio.h,v 1.18 1996/04/25 18:29:21 jtc Exp $ */ #ifndef _LIBC_STDIO_H_ #define _LIBC_STDIO_H_ +/* we want the const-correct declarations inside libc */ +#define __SYS_ERRLIST + #include_next <stdio.h> #include "namespace.h" @@ -27,6 +28,12 @@ __BEGIN_HIDDEN_DECLS char *_mktemp(char *); __END_HIDDEN_DECLS +extern const int sys_nerr; +extern const char *const sys_errlist[]; + +extern PROTO_NORMAL(sys_nerr); +extern PROTO_NORMAL(sys_errlist); + PROTO_NORMAL(__srget); PROTO_NORMAL(__swbuf); PROTO_NORMAL(asprintf); diff --git a/lib/libc/include/namespace.h b/lib/libc/include/namespace.h index 381ccc35be7..939515251e9 100644 --- a/lib/libc/include/namespace.h +++ b/lib/libc/include/namespace.h @@ -1,15 +1,8 @@ -/* $OpenBSD: namespace.h,v 1.4 2015/09/05 11:25:30 guenther Exp $ */ +/* $OpenBSD: namespace.h,v 1.5 2015/09/06 20:26:20 guenther Exp $ */ #ifndef _LIBC_NAMESPACE_H_ #define _LIBC_NAMESPACE_H_ -/* These will be replaced with symbol renaming ala PROTO_NORMAL */ -#define strtoq _strtoq -#define strtouq _strtouq -#define sys_errlist _sys_errlist -#define sys_nerr _sys_nerr -#define sys_siglist _sys_siglist - /* * Copyright (c) 2015 Philip Guenther <guenther@openbsd.org> * diff --git a/lib/libc/string/strerror_r.c b/lib/libc/string/strerror_r.c index 2262cb512d5..8a15ff1afc4 100644 --- a/lib/libc/string/strerror_r.c +++ b/lib/libc/string/strerror_r.c @@ -1,14 +1,10 @@ -/* $OpenBSD: strerror_r.c,v 1.10 2015/09/05 11:25:30 guenther Exp $ */ +/* $OpenBSD: strerror_r.c,v 1.11 2015/09/06 20:26:20 guenther Exp $ */ /* Public Domain <marc@snafu.org> */ #ifdef NLS #include <nl_types.h> #endif -#define sys_errlist _sys_errlist -#define sys_nerr _sys_nerr -#define sys_siglist _sys_siglist - #include <errno.h> #include <limits.h> #include <signal.h> @@ -65,7 +61,7 @@ __itoa(int num, int sign, char *buffer, size_t start, size_t end) static int __num2string(int num, int sign, int setid, char *buf, size_t buflen, - char * list[], size_t max, const char *def) + const char * const list[], size_t max, const char *def) { int ret = 0; size_t len; @@ -129,7 +125,7 @@ DEF_WEAK(strerror_r); char * __strsignal(int num, char *buf) { - __num2string(num, 0, 2, buf, NL_TEXTMAX, (char **)sys_siglist, NSIG, + __num2string(num, 0, 2, buf, NL_TEXTMAX, sys_siglist, NSIG, USIGPREFIX); return buf; } |