From patchwork Tue Dec 13 18:10:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 87924 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp2344456qgi; Tue, 13 Dec 2016 10:11:00 -0800 (PST) X-Received: by 10.84.216.17 with SMTP id m17mr196785357pli.82.1481652660176; Tue, 13 Dec 2016 10:11:00 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n11si48854299plg.331.2016.12.13.10.10.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Dec 2016 10:11:00 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-75841-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 libc-alpha-return-75841-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-75841-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.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:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=cBKlF4vFaKI4j279 s6qH/S7TZzEcnvg/Nr/+iwZ6Ik7KQ/k0/Rkjv7Kl0H7XacVk0OmT55qK0mLQoHIy wE2c1WehpOPl2h4+6/jXjvyxjqJx5jq11ExLVgs0bj1v/yZS9ki10jo5mFLKjBJW zqYumvZwRFzeezhOVWtPqjWZYE4= 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:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=z9g6f719jbXyw2zKRd3+4j LCQoY=; b=csGq1q0bnrcwjwE82lnarH0F6ibpDkXGrziVupbhIS4OJRqIzWFnIJ Nda8bBEfLvwyEDtFx+1P/mrqLQlsHxVex3Ar9PUsVAccBgTa8Xj+VcTA9w4ddHpB Hoefo7ZOHsHdMTk6aO5G9MEPdkzIszfOOVtc2iFcWRxh3q/a5MB/I= Received: (qmail 125080 invoked by alias); 13 Dec 2016 18:10:49 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 125065 invoked by uid 89); 13 Dec 2016 18:10:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=strsepc, *__strsep_3c, strsep, **__stringp X-HELO: mail-vk0-f50.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=0xaQMW9Gr9f/AsaNzqQmpuZocg9it2JGLSScptxbpkU=; b=bBOzmKrgsESEOV6qg/H/+Pquw7Zse8MeBbvck9/ihAbACsz9aFL5ox+Jd05N2iQH5i encmGUoryeZNSKQb3eNumZtrkzqlUURHPEVWgP82vTXfb3DqHs4HSnkoL8MV009N8iLh +c7Erklj9LGHTpoDO1T8jHXBRQtpy/Naifj8T/o1EPhAOnuDLP38AG4RckNBhhU+5GE8 TMVlALpL53WuNQ9mZkTBwMGb8U+gAmtNOVs/AFzGnVFdPD2T0aAOWi72LA0hKmJK7Qbq hS0jc7R1P7F65pBe4wv/v1x0eRXimpwjNbBeAclhcp7usYqHRfq46XFneq8A+Ebm+S2n gd8A== X-Gm-Message-State: AKaTC00olVy+iCCptOfx/w07KO5WWBNXH4Gh+xrz2U7l0dE9wibOnFxZ0dp+xSgnx3s8YnPs X-Received: by 10.159.34.41 with SMTP id 38mr34255893uad.160.1481652636193; Tue, 13 Dec 2016 10:10:36 -0800 (PST) Subject: Re: [PATCH v3] Improve strsep To: libc-alpha@sourceware.org References: From: Adhemerval Zanella Message-ID: <4fb02cf3-1ea7-1e79-1088-bdc10fe4cb67@linaro.org> Date: Tue, 13 Dec 2016 16:10:31 -0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: With a correction and a suggestion below I think this ok. On 13/12/2016 10:44, Wilco Dijkstra wrote: > - > -__STRING_INLINE char *__strsep_3c (char **__s, char __reject1, char __reject2, > - char __reject3); > -__STRING_INLINE char * > -__strsep_3c (char **__s, char __reject1, char __reject2, char __reject3) > -{ > - char *__retval = *__s; > - if (__retval != NULL) > - { > - char *__cp = __retval; > - while (1) > - { > - if (*__cp == '\0') > - { > - __cp = NULL; > - break; > - } > - if (*__cp == __reject1 || *__cp == __reject2 || *__cp == __reject3) > - { > - *__cp++ = '\0'; > - break; > - } > - ++__cp; > - } > - *__s = __cp; > - } > - return __retval; > -} > -# ifdef __USE_MISC > -# define strsep(s, reject) __strsep (s, reject) Without the indirection some link namespace tests fails with: [initial] fpathconf -> [libc.a(fpathconf.o)] __fstatvfs64 -> [libc.a(fstatvfs.o)] __internal_statvfs -> [libc.a(internal_statvfs.o)] strsep Previously strsep was redirected internally to __strsep_g and it contains the requires libc_hidden_{def,proto}, however I think we just can simplify internal strsep altogether by simply replace __strset_g definition and usage with __strsep. We still need to strong_alias strsep to __strsep_g and export it unfortunately. Based on your patch: diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c index 116ec49..dd2edde 100644 --- a/elf/dl-minimal.c +++ b/elf/dl-minimal.c @@ -377,4 +377,3 @@ __strsep (char **stringp, const char *delim) return begin; } weak_alias (__strsep, strsep) -strong_alias (__strsep, __strsep_g) diff --git a/include/string.h b/include/string.h index e145bfd..dffafd5 100644 --- a/include/string.h +++ b/include/string.h @@ -91,8 +91,7 @@ libc_hidden_proto (strcoll) libc_hidden_proto (__strcoll_l) libc_hidden_proto (__strxfrm_l) libc_hidden_proto (__strtok_r) -extern char *__strsep_g (char **__stringp, const char *__delim); -libc_hidden_proto (__strsep_g) +libc_hidden_proto (__strsep) libc_hidden_proto (strnlen) libc_hidden_proto (__strnlen) libc_hidden_proto (memmem) @@ -125,7 +124,7 @@ libc_hidden_builtin_proto (ffs) extern __typeof (__stpcpy) __stpcpy attribute_hidden; extern __typeof (__strdup) __strdup attribute_hidden; extern __typeof (__strerror_r) __strerror_r attribute_hidden; -extern __typeof (__strsep_g) __strsep_g attribute_hidden; +extern __typeof (__strsep) __strsep attribute_hidden; extern __typeof (memchr) memchr attribute_hidden; extern __typeof (memcmp) memcmp attribute_hidden; diff --git a/string/strsep.c b/string/strsep.c index 68581c8..6af0bdc 100644 --- a/string/strsep.c +++ b/string/strsep.c @@ -45,5 +45,5 @@ __strsep (char **stringp, const char *delim) return begin; } weak_alias (__strsep, strsep) +libc_hidden_def (__strsep) strong_alias (__strsep, __strsep_g) -libc_hidden_def (__strsep_g) diff --git a/sysdeps/unix/sysv/linux/internal_statvfs.c b/sysdeps/unix/sysv/linux/internal_statvfs.c index 012f93f..ce649cd 100644 --- a/sysdeps/unix/sysv/linux/internal_statvfs.c +++ b/sysdeps/unix/sysv/linux/internal_statvfs.c @@ -168,7 +168,7 @@ __statvfs_getflags (const char *name, int fstype, int fd) char *cp = mntbuf.mnt_opts; char *opt; - while ((opt = strsep (&cp, ",")) != NULL) + while ((opt = __strsep (&cp, ",")) != NULL) if (strcmp (opt, "ro") == 0) result |= ST_RDONLY; else if (strcmp (opt, "nosuid") == 0)