From: Jakub Narebski <jnareb@gmail.com>
To: Andreas Ericsson <ae@op5.se>
Cc: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>,
"Junio C Hamano" <gitster@pobox.com>,
"Git Mailing List" <git@vger.kernel.org>
Subject: Re: [PATCH 1/2] Add strchrnul()
Date: Fri, 9 Nov 2007 17:44:49 +0100 [thread overview]
Message-ID: <200711091744.50017.jnareb@gmail.com> (raw)
In-Reply-To: <473467C4.8020208@op5.se>
Andreas Ericsson wrote:
> Jakub Narebski wrote:
>> René Scharfe wrote:
>>> +#if !defined(__GLIBC__) && !__GLIBC_PREREQ(2, 1)
>>> +# define strchrnul(s, c) gitstrchrnul(s, c)
>>> +static inline char *gitstrchrnul(const char *s, int c)
>>> +{
>>> + while (*s && *s != c)
>>> + s++;
>>> +
>>> + return (char *)s;
>>> +}
>>> +#endif
>>> +
>>
>> This is good solution, although I'm not sure about the check itself.
>> What if somebody has libc which is not glibc, but it does have
>> strchrnul?
>
> They most likely fall into the minority that get to suffer from
> using code that's as fast as what's in there today, although
> a bit more readable. The glibc optimization is really only
> worthwhile for architectures where strchrnul()-like operations
> have microcode support, or when it's used on large strings.
If we end up using this solution, then adding test for strchrnul in the
configure (configure.ac and config.mak.in) is not needed...
> YMMV. I suppose rewriting it as
>
> #if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 1)
#if !defined(HAVE_STRCHRNUL) && \
defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 1)
> # define HAVE_STRCHRNUL
> #endif
>
> #ifdef HAVE_STRCHRNUL
> ...
>
> would work too, and will provide an easier way out for other fellas
> wanting to say "Hey, my favourite solaris libc has this too!". OTOH,
> that rewrite can be done when the first such case appears.
...but if we end up using this version (be it HAVE_STRCHRNUL, or
NO_STRCHRNUL), then test for strchrnul in ./configure is I think
necessary.
--
Jakub Narebski
Poland
next prev parent reply other threads:[~2007-11-09 16:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-09 0:49 [PATCH 1/2] Add strchrnul() René Scharfe
2007-11-09 1:21 ` Johannes Schindelin
2007-11-09 3:31 ` Jeff King
2007-11-09 10:22 ` Andreas Ericsson
2007-11-09 13:42 ` Jakub Narebski
2007-11-09 13:59 ` Andreas Ericsson
2007-11-09 16:44 ` Jakub Narebski [this message]
2007-11-10 11:55 ` [PATCH] Simplify strchrnul() compat code René Scharfe
2007-11-10 14:04 ` Andreas Ericsson
2007-11-11 10:44 ` Junio C Hamano
2007-11-11 12:35 ` Andreas Ericsson
2007-11-12 9:03 ` David Symonds
2007-11-12 9:12 ` Johannes Sixt
2007-11-12 9:24 ` David Symonds
2007-11-12 9:50 ` Johannes Sixt
2007-11-12 9:52 ` David Symonds
2007-11-12 10:07 ` Jakub Narebski
2007-11-12 10:09 ` [PATCH] Fix preprocessor logic that determines the availablity of strchrnul() Johannes Sixt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200711091744.50017.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=ae@op5.se \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=rene.scharfe@lsrfire.ath.cx \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).