From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6313 Path: news.gmane.org!not-for-mail From: Sergey Dmitrouk Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] Convert some is* macros to inline functions Date: Tue, 14 Oct 2014 12:01:08 +0300 Message-ID: <20141014090108.GA2635@zx-spectrum> References: <20141013142020.GA26828@zx-spectrum.accesssoftek.com> <1413210914.4885.1174.camel@eris.loria.fr> <20141013180056.GA28588@zx-spectrum.accesssoftek.com> <20141013180622.GE32028@brightrain.aerifal.cx> <20141013184956.GA4874@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="azLHFNyN32YCQGCU" X-Trace: ger.gmane.org 1413281415 21675 80.91.229.3 (14 Oct 2014 10:10:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 14 Oct 2014 10:10:15 +0000 (UTC) To: "musl@lists.openwall.com" Original-X-From: musl-return-6326-gllmg-musl=m.gmane.org@lists.openwall.com Tue Oct 14 12:10:08 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Xdz3O-0000Jb-8v for gllmg-musl@plane.gmane.org; Tue, 14 Oct 2014 12:10:06 +0200 Original-Received: (qmail 11875 invoked by uid 550); 14 Oct 2014 10:11:18 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 11867 invoked from network); 14 Oct 2014 10:11:18 -0000 Content-Disposition: inline In-Reply-To: <20141013184956.GA4874@port70.net> Xref: news.gmane.org gmane.linux.lib.musl.general:6313 Archived-At: --azLHFNyN32YCQGCU Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline On Mon, Oct 13, 2014 at 11:49:56AM -0700, Szabolcs Nagy wrote: > the c++ standard could be more explicit about this incompatibility > with c: it states the requirement in a note for the headers > and then defines the semantics for the headers in terms of > the one Sad, but true. I wish it was stated better. > The only way to achieve equivalent inline behavior in C++ is to > provide a definition as an extern inline function. Seems to be true, so newlib and glibc have checks for __cplusplus define. Alternative would be to provide 26 fake headers containing #include_next directive, but it's not very portable solution. Attached is the patch, which simply adds #ifndef __cplusplus around macros. At the end, it seems to be the right thing to do, although the way it's defined is rather confusing. Thanks, Sergey --azLHFNyN32YCQGCU Content-Type: text/plain; charset="us-ascii" Content-Disposition: attachment; filename="musl-hide-is-macros-for-cxx.patch" diff --git a/include/ctype.h b/include/ctype.h index a6f44df..eef574b 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -27,6 +27,7 @@ static __inline int __isspace(int _c) return _c == ' ' || (unsigned)_c-'\t' < 5; } +#ifndef __cplusplus #define isalpha(a) ((((unsigned)(a)|32)-'a') < 26) #define isdigit(a) (((unsigned)(a)-'0') < 10) #define islower(a) (((unsigned)(a)-'a') < 26) @@ -34,6 +35,7 @@ static __inline int __isspace(int _c) #define isprint(a) (((unsigned)(a)-0x20) < 0x5f) #define isgraph(a) (((unsigned)(a)-0x21) < 0x5e) #define isspace(a) __isspace(a) +#endif #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ diff --git a/include/wchar.h b/include/wchar.h index 9fd967c..8cfb584 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -176,9 +176,12 @@ int iswctype(wint_t, wctype_t); wint_t towlower(wint_t); wint_t towupper(wint_t); wctype_t wctype(const char *); + +#ifndef __cplusplus #undef iswdigit #define iswdigit(a) ((unsigned)(a)-'0' < 10) #endif +#endif #ifdef __cplusplus } diff --git a/include/wctype.h b/include/wctype.h index 3ac24f1..3da1219 100644 --- a/include/wctype.h +++ b/include/wctype.h @@ -43,8 +43,10 @@ wint_t towupper(wint_t); wctrans_t wctrans(const char *); wctype_t wctype(const char *); +#ifndef __cplusplus #undef iswdigit #define iswdigit(a) (((unsigned)(a)-L'0') < 10) +#endif #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) --azLHFNyN32YCQGCU--