From patchwork Thu Apr 14 04:55:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaakov Selkowitz X-Patchwork-Id: 65778 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp390920qge; Wed, 13 Apr 2016 21:56:14 -0700 (PDT) X-Received: by 10.98.73.221 with SMTP id r90mr18423857pfi.70.1460609774546; Wed, 13 Apr 2016 21:56:14 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id m17si5291137pfj.147.2016.04.13.21.56.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Apr 2016 21:56:14 -0700 (PDT) Received-SPF: pass (google.com: domain of newlib-return-13639-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of newlib-return-13639-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-13639-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=VCxNG1VfOsvGRjnfOpVLh6falPeVmDzejAQyL3tQBIAsgDl6VqKD/ Ftzsoeo8XP81wOVFeFZRRzd3rvA6XeRK3r5jnJkig4UIC8c4Z/tjGUeyZ+voCJDI mGWZtpgC5IE1iQR0z+M53cUMKD4CMP4jUTTSUGpybUxVA3ztLnonlI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=VGcgA2xoGXzPGtm/iFkpOSdHvrE=; b=U+XLtXCcitx9LvM3rDmbU+rVd75w /Fryli79ujU1KAMRxbUCoY1d5HbpRhNrJbB9MSM0JOVJ7BdIciKNblChTWqloS0Q H0+ho6P1/SLNUngXaJordhleiJ7woaH3CBpg32Hi3er62YkcF4LktD3tl4PM5Gyz 9xYvLxveSgnaP6M= Received: (qmail 104985 invoked by alias); 14 Apr 2016 04:56:01 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 104963 invoked by uid 89); 14 Apr 2016 04:56:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=6914 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 14 Apr 2016 04:55:58 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A53CB81F07 for ; Thu, 14 Apr 2016 04:55:57 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-24.rdu2.redhat.com [10.10.116.24]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3E4tuZa012449 (version=TLSv1/SSLv3 cipher=AES256-SHA256 bits=256 verify=NO) for ; Thu, 14 Apr 2016 00:55:57 -0400 From: Yaakov Selkowitz To: newlib@sourceware.org Subject: [PATCH] Feature test macros overhaul: string.h and strings.h overlaps Date: Wed, 13 Apr 2016 23:55:35 -0500 Message-Id: <1460609735-10332-1-git-send-email-yselkowi@redhat.com> strings.h is the header mandated for these functions in POSIX.1 prior to 2008 (when most of these were removed). The declarations in string.h are only for BSD compatibility. But when both headers are included, avoid duplicate declarations. Also, mark stpcpy and stpncpy as POSIX.1-2008. Signed-off-by: Yaakov Selkowitz --- newlib/libc/include/string.h | 14 +++++++------- newlib/libc/include/strings.h | 5 +++++ 2 files changed, 12 insertions(+), 7 deletions(-) -- 2.8.0 diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h index 68ee412..56c7fc2 100644 --- a/newlib/libc/include/string.h +++ b/newlib/libc/include/string.h @@ -46,7 +46,7 @@ size_t _EXFUN(strxfrm,(char *__restrict, const char *__restrict, size_t)); #if __MISC_VISIBLE || __POSIX_VISIBLE char *_EXFUN(strtok_r,(char *__restrict, const char *__restrict, char **__restrict)); #endif -#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE < 200809) +#if __BSD_VISIBLE /* POSIX declaration is in */ int _EXFUN(bcmp,(const void *, const void *, size_t)); void _EXFUN(bcopy,(const void *, void *, size_t)); void _EXFUN(bzero,(void *, size_t)); @@ -56,10 +56,8 @@ void _EXFUN(explicit_bzero,(void *, size_t)); int _EXFUN(timingsafe_bcmp,(const void *, const void *, size_t)); int _EXFUN(timingsafe_memcmp,(const void *, const void *, size_t)); #endif -#if __MISC_VISIBLE || __POSIX_VISIBLE >= 200809 +#if __BSD_VISIBLE /* POSIX declaration is in */ int _EXFUN(ffs,(int)); -#endif -#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE < 200809) char *_EXFUN(index,(const char *, int)); #endif #if __MISC_VISIBLE || __POSIX_VISIBLE @@ -71,12 +69,14 @@ _PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t)); _PTR _EXFUN(memrchr,(const _PTR, int, size_t)); _PTR _EXFUN(rawmemchr,(const _PTR, int)); #endif -#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE < 200809) +#if __BSD_VISIBLE /* POSIX declaration is in */ char *_EXFUN(rindex,(const char *, int)); #endif +#if __POSIX_VISIBLE >= 200809 char *_EXFUN(stpcpy,(char *__restrict, const char *__restrict)); char *_EXFUN(stpncpy,(char *__restrict, const char *__restrict, size_t)); -#if __BSD_VISIBLE || __POSIX_VISIBLE +#endif +#if __BSD_VISIBLE /* POSIX declaration is in */ int _EXFUN(strcasecmp,(const char *, const char *)); #endif #if __GNU_VISIBLE @@ -123,7 +123,7 @@ char * _EXFUN(_strerror_r, (struct _reent *, int, int, int *)); size_t _EXFUN(strlcat,(char *, const char *, size_t)); size_t _EXFUN(strlcpy,(char *, const char *, size_t)); #endif -#if __BSD_VISIBLE || __POSIX_VISIBLE +#if __BSD_VISIBLE /* POSIX declaration is in */ int _EXFUN(strncasecmp,(const char *, const char *, size_t)); #endif #if __POSIX_VISIBLE >= 200809 diff --git a/newlib/libc/include/strings.h b/newlib/libc/include/strings.h index fdccfca..e467467 100644 --- a/newlib/libc/include/strings.h +++ b/newlib/libc/include/strings.h @@ -7,6 +7,9 @@ #ifndef _STRINGS_H_ #define _STRINGS_H_ +/* These functions are already declared in with __BSD_VISIBLE */ +#if !(defined(_STRING_H_) && __BSD_VISIBLE) + #include "_ansi.h" #include #include @@ -32,4 +35,6 @@ int _EXFUN(strncasecmp,(const char *, const char *, size_t)); _END_STD_C +#endif /* !(_STRING_H_ && __BSD_VISIBLE) */ + #endif /* _STRINGS_H_ */