diff options
author | 2015-09-13 11:38:08 +0000 | |
---|---|---|
committer | 2015-09-13 11:38:08 +0000 | |
commit | eb78bd260d741b897cab9290c84b6d3a4152659f (patch) | |
tree | eee57fd24b72b4c5706428bad9078f1709c8b22b | |
parent | Wrap <uuid.h> so that calls go direct and the symbols are all weak (diff) | |
download | wireguard-openbsd-eb78bd260d741b897cab9290c84b6d3a4152659f.tar.xz wireguard-openbsd-eb78bd260d741b897cab9290c84b6d3a4152659f.zip |
Wrap <ctype.h> and <wctype.h> so that calls go direct and the symbols not
in standard C are all weak.
Hide several symbols internal to the implementation
-rw-r--r-- | lib/libc/Symbols.list | 8 | ||||
-rw-r--r-- | lib/libc/gen/ctype_.c | 3 | ||||
-rw-r--r-- | lib/libc/gen/isctype.c | 15 | ||||
-rw-r--r-- | lib/libc/gen/tolower_.c | 4 | ||||
-rw-r--r-- | lib/libc/gen/toupper_.c | 4 | ||||
-rw-r--r-- | lib/libc/hidden/ctype.h | 46 | ||||
-rw-r--r-- | lib/libc/hidden/wctype.h | 42 | ||||
-rw-r--r-- | lib/libc/locale/_wctrans_local.h | 12 | ||||
-rw-r--r-- | lib/libc/locale/iswctype.c | 21 | ||||
-rw-r--r-- | lib/libc/locale/rune_local.h | 6 | ||||
-rw-r--r-- | lib/libc/locale/wctoint.h | 4 |
11 files changed, 136 insertions, 29 deletions
diff --git a/lib/libc/Symbols.list b/lib/libc/Symbols.list index c5f9988e6e4..98d2a9772f3 100644 --- a/lib/libc/Symbols.list +++ b/lib/libc/Symbols.list @@ -931,20 +931,12 @@ _DefaultMonetaryLocale _DefaultNumericLocale _DefaultRuneLocale _DefaultTimeLocale -_NukeRune -_Read_RuneMagi -___runetype_mb -__install_currentrunelocale_ctype -__make_ctype_tabs __mb_cur_max __mb_len_max_runtime __mlocale_changed __nlocale_changed -_findrunelocale -_newrunelocale _towctrans_ext _wctrans_init -_xpg4_setrunelocale btowc iswalnum iswalpha diff --git a/lib/libc/gen/ctype_.c b/lib/libc/gen/ctype_.c index 89c8257585f..ba61e1a541a 100644 --- a/lib/libc/gen/ctype_.c +++ b/lib/libc/gen/ctype_.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ctype_.c,v 1.10 2011/09/22 09:06:10 stsp Exp $ */ +/* $OpenBSD: ctype_.c,v 1.11 2015/09/13 11:38:08 guenther Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. * All rights reserved. @@ -74,3 +74,4 @@ const char _C_ctype_[1 + CTYPE_NUM_CHARS] = { }; const char *_ctype_ = _C_ctype_; +DEF_STRONG(_ctype_); diff --git a/lib/libc/gen/isctype.c b/lib/libc/gen/isctype.c index 970b5e274cd..a4e944ca7df 100644 --- a/lib/libc/gen/isctype.c +++ b/lib/libc/gen/isctype.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isctype.c,v 1.11 2005/08/08 08:05:34 espie Exp $ */ +/* $OpenBSD: isctype.c,v 1.12 2015/09/13 11:38:08 guenther Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. * All rights reserved. @@ -43,6 +43,7 @@ isalnum(int c) { return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_U|_L|_N))); } +DEF_STRONG(isalnum); #undef isalpha int @@ -50,6 +51,7 @@ isalpha(int c) { return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_U|_L))); } +DEF_STRONG(isalpha); #undef isblank int @@ -57,6 +59,7 @@ isblank(int c) { return (c == ' ' || c == '\t'); } +DEF_STRONG(isblank); #undef iscntrl int @@ -64,6 +67,7 @@ iscntrl(int c) { return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _C)); } +DEF_STRONG(iscntrl); #undef isdigit int @@ -71,6 +75,7 @@ isdigit(int c) { return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _N)); } +DEF_STRONG(isdigit); #undef isgraph int @@ -78,6 +83,7 @@ isgraph(int c) { return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_P|_U|_L|_N))); } +DEF_STRONG(isgraph); #undef islower int @@ -85,6 +91,7 @@ islower(int c) { return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _L)); } +DEF_STRONG(islower); #undef isprint int @@ -92,6 +99,7 @@ isprint(int c) { return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_P|_U|_L|_N|_B))); } +DEF_STRONG(isprint); #undef ispunct int @@ -99,6 +107,7 @@ ispunct(int c) { return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _P)); } +DEF_STRONG(ispunct); #undef isspace int @@ -106,6 +115,7 @@ isspace(int c) { return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _S)); } +DEF_STRONG(isspace); #undef isupper int @@ -113,6 +123,7 @@ isupper(int c) { return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _U)); } +DEF_STRONG(isupper); #undef isxdigit int @@ -120,6 +131,7 @@ isxdigit(int c) { return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_N|_X))); } +DEF_STRONG(isxdigit); #undef isascii int @@ -127,6 +139,7 @@ isascii(int c) { return ((unsigned int)c <= 0177); } +DEF_WEAK(isascii); #undef toascii int diff --git a/lib/libc/gen/tolower_.c b/lib/libc/gen/tolower_.c index 50dcc7b4c86..c1599969270 100644 --- a/lib/libc/gen/tolower_.c +++ b/lib/libc/gen/tolower_.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tolower_.c,v 1.9 2005/08/08 08:05:34 espie Exp $ */ +/* $OpenBSD: tolower_.c,v 1.10 2015/09/13 11:38:08 guenther Exp $ */ /* * Written by J.T. Conklin <jtc@netbsd.org>. * Public domain. @@ -46,6 +46,7 @@ const short _C_tolower_[1 + CTYPE_NUM_CHARS] = { }; const short *_tolower_tab_ = _C_tolower_; +DEF_STRONG(_tolower_tab_); #undef tolower int @@ -55,3 +56,4 @@ tolower(int c) return(c); return((_tolower_tab_ + 1)[c]); } +DEF_STRONG(tolower); diff --git a/lib/libc/gen/toupper_.c b/lib/libc/gen/toupper_.c index 40931992d80..9e2c6c7b14c 100644 --- a/lib/libc/gen/toupper_.c +++ b/lib/libc/gen/toupper_.c @@ -1,4 +1,4 @@ -/* $OpenBSD: toupper_.c,v 1.10 2005/08/09 08:36:48 kevlo Exp $ */ +/* $OpenBSD: toupper_.c,v 1.11 2015/09/13 11:38:08 guenther Exp $ */ /* * Written by J.T. Conklin <jtc@netbsd.org>. * Public domain. @@ -47,6 +47,7 @@ const short _C_toupper_[1 + CTYPE_NUM_CHARS] = { }; const short *_toupper_tab_ = _C_toupper_; +DEF_STRONG(_toupper_tab_); #undef toupper int @@ -56,3 +57,4 @@ toupper(int c) return(c); return((_toupper_tab_ + 1)[c]); } +DEF_STRONG(toupper); diff --git a/lib/libc/hidden/ctype.h b/lib/libc/hidden/ctype.h new file mode 100644 index 00000000000..3f6efc7e5d5 --- /dev/null +++ b/lib/libc/hidden/ctype.h @@ -0,0 +1,46 @@ +/* $OpenBSD: ctype.h,v 1.1 2015/09/13 11:38:08 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_CTYPE_H_ +#define _LIBC_CTYPE_H_ + +#include_next <ctype.h> + +extern PROTO_NORMAL(_ctype_); +extern PROTO_NORMAL(_tolower_tab_); +extern PROTO_NORMAL(_toupper_tab_); + +PROTO_NORMAL(isalnum); +PROTO_NORMAL(isalpha); +PROTO_NORMAL(iscntrl); +PROTO_NORMAL(isdigit); +PROTO_NORMAL(isgraph); +PROTO_NORMAL(islower); +PROTO_NORMAL(isprint); +PROTO_NORMAL(ispunct); +PROTO_NORMAL(isspace); +PROTO_NORMAL(isupper); +PROTO_NORMAL(isxdigit); +PROTO_NORMAL(tolower); +PROTO_NORMAL(toupper); +PROTO_NORMAL(isblank); +PROTO_NORMAL(isascii); +PROTO_DEPRECATED(toascii); +PROTO_STD_DEPRECATED(_tolower); +PROTO_STD_DEPRECATED(_toupper); + +#endif /* !_LIBC_CTYPE_H_ */ diff --git a/lib/libc/hidden/wctype.h b/lib/libc/hidden/wctype.h new file mode 100644 index 00000000000..006432f4ec2 --- /dev/null +++ b/lib/libc/hidden/wctype.h @@ -0,0 +1,42 @@ +/* $OpenBSD: wctype.h,v 1.1 2015/09/13 11:38:08 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_WCTYPE_H_ +#define _LIBC_WCTYPE_H_ + +#include_next <wctype.h> + +PROTO_STD_DEPRECATED(iswalnum); +PROTO_STD_DEPRECATED(iswalpha); +PROTO_STD_DEPRECATED(iswblank); +PROTO_STD_DEPRECATED(iswcntrl); +PROTO_STD_DEPRECATED(iswctype); +PROTO_STD_DEPRECATED(iswdigit); +PROTO_STD_DEPRECATED(iswgraph); +PROTO_STD_DEPRECATED(iswlower); +PROTO_STD_DEPRECATED(iswprint); +PROTO_STD_DEPRECATED(iswpunct); +PROTO_NORMAL(iswspace); +PROTO_NORMAL(iswupper); +PROTO_STD_DEPRECATED(iswxdigit); +PROTO_STD_DEPRECATED(towctrans); +PROTO_NORMAL(towlower); +PROTO_STD_DEPRECATED(towupper); +PROTO_STD_DEPRECATED(wctrans); +PROTO_STD_DEPRECATED(wctype); + +#endif /* !_LIBC_WCTYPE_H_ */ diff --git a/lib/libc/locale/_wctrans_local.h b/lib/libc/locale/_wctrans_local.h index 4487f729369..6686ff3b2ea 100644 --- a/lib/libc/locale/_wctrans_local.h +++ b/lib/libc/locale/_wctrans_local.h @@ -29,17 +29,19 @@ #ifndef _WCTRANS_LOCAL_H_ #define _WCTRANS_LOCAL_H_ -extern wint_t _towctrans_ext(wint_t, _WCTransEntry *); -extern void _wctrans_init(_RuneLocale *); +__BEGIN_HIDDEN_DECLS +wint_t _towctrans_ext(wint_t, _WCTransEntry *); +void _wctrans_init(_RuneLocale *); +__END_HIDDEN_DECLS -static __inline wint_t +static inline wint_t _towctrans(wint_t c, _WCTransEntry *te) { return (_RUNE_ISCACHED(c) ? te->te_cached[(rune_t)c]:_towctrans_ext(c, te)); } -static __inline struct _WCTransEntry * +static inline struct _WCTransEntry * _wctrans_lower(_RuneLocale *rl) { if (rl->rl_wctrans[_WCTRANS_INDEX_LOWER].te_name==NULL) @@ -47,7 +49,7 @@ _wctrans_lower(_RuneLocale *rl) return (&rl->rl_wctrans[_WCTRANS_INDEX_LOWER]); } -static __inline struct _WCTransEntry * +static inline struct _WCTransEntry * _wctrans_upper(_RuneLocale *rl) { if (rl->rl_wctrans[_WCTRANS_INDEX_UPPER].te_name==NULL) diff --git a/lib/libc/locale/iswctype.c b/lib/libc/locale/iswctype.c index fb0cde26392..8c14cda37a3 100644 --- a/lib/libc/locale/iswctype.c +++ b/lib/libc/locale/iswctype.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iswctype.c,v 1.5 2015/09/12 16:23:14 guenther Exp $ */ +/* $OpenBSD: iswctype.c,v 1.6 2015/09/13 11:38:08 guenther Exp $ */ /* $NetBSD: iswctype.c,v 1.15 2005/02/09 21:35:46 kleink Exp $ */ /* @@ -45,12 +45,12 @@ #include "rune_local.h" #include "_wctrans_local.h" -static __inline _RuneType __runetype_w(wint_t); -static __inline int __isctype_w(wint_t, _RuneType); -static __inline wint_t __toupper_w(wint_t); -static __inline wint_t __tolower_w(wint_t); +static inline _RuneType __runetype_w(wint_t); +static inline int __isctype_w(wint_t, _RuneType); +static inline wint_t __toupper_w(wint_t); +static inline wint_t __tolower_w(wint_t); -static __inline _RuneType +static inline _RuneType __runetype_w(wint_t c) { _RuneLocale *rl = _CurrentRuneLocale; @@ -59,19 +59,19 @@ __runetype_w(wint_t c) rl->rl_runetype[c] : ___runetype_mb(c)); } -static __inline int +static inline int __isctype_w(wint_t c, _RuneType f) { return (!!(__runetype_w(c) & f)); } -static __inline wint_t +static inline wint_t __toupper_w(wint_t c) { return (_towctrans(c, _wctrans_upper(_CurrentRuneLocale))); } -static __inline wint_t +static inline wint_t __tolower_w(wint_t c) { return (_towctrans(c, _wctrans_lower(_CurrentRuneLocale))); @@ -136,12 +136,14 @@ iswspace(wint_t c) { return (__isctype_w((c), _CTYPE_S)); } +DEF_STRONG(iswspace); int iswupper(wint_t c) { return (__isctype_w((c), _CTYPE_U)); } +DEF_STRONG(iswupper); int iswxdigit(wint_t c) @@ -160,6 +162,7 @@ towlower(wint_t c) { return (__tolower_w(c)); } +DEF_STRONG(towlower); int wcwidth(wchar_t c) diff --git a/lib/libc/locale/rune_local.h b/lib/libc/locale/rune_local.h index 78bee7e0b68..97491447955 100644 --- a/lib/libc/locale/rune_local.h +++ b/lib/libc/locale/rune_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rune_local.h,v 1.3 2013/11/12 06:10:28 deraadt Exp $ */ +/* $OpenBSD: rune_local.h,v 1.4 2015/09/13 11:38:08 guenther Exp $ */ /* $NetBSD: rune_local.h,v 1.7 2003/03/02 22:18:15 tshiozak Exp $ */ /*- @@ -30,6 +30,8 @@ #ifndef _RUNE_LOCAL_H_ #define _RUNE_LOCAL_H_ +__BEGIN_HIDDEN_DECLS + /* rune.c */ extern _RuneLocale *_Read_RuneMagi(FILE *fp); extern void _NukeRune(_RuneLocale *); @@ -46,4 +48,6 @@ extern void __install_currentrunelocale_ctype(void); /* ___runetype_mb.c */ extern _RuneType ___runetype_mb(wint_t); +__END_HIDDEN_DECLS + #endif diff --git a/lib/libc/locale/wctoint.h b/lib/libc/locale/wctoint.h index c9bf084c348..ea50c5ae1b6 100644 --- a/lib/libc/locale/wctoint.h +++ b/lib/libc/locale/wctoint.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wctoint.h,v 1.1 2005/07/01 08:59:27 espie Exp $ */ +/* $OpenBSD: wctoint.h,v 1.2 2015/09/13 11:38:08 guenther Exp $ */ /* $NetBSD: __wctoint.h,v 1.1 2001/09/28 11:25:37 yamt Exp $ */ /*- @@ -30,7 +30,7 @@ */ -__inline static int +inline static int wctoint(wchar_t wc) { int n; |