[prev in list] [next in list] [prev in thread] [next in thread]
List: uclibc
Subject: svn commit: trunk/uClibc: include libc/string libc/string/generic etc...
From: vda.linux () googlemail ! com (Denys Vlasenko)
Date: 2009-07-21 22:52:25
Message-ID: 200907220052.25790.vda.linux () googlemail ! com
[Download RAW message or body]
On Wednesday 22 July 2009 00:26, Bernhard Reutner-Fischer wrote:
> On Tue, Jul 21, 2009 at 03:36:03PM +0200, Denys Vlasenko wrote:
> >On Tue, Jul 21, 2009 at 4:01 AM, Mike Frysinger<vapier at gentoo.org> wrote:
> >>> Please try attached patch. For me it compiles. Resulting code
> >>> from memchr(buffer, '\n', pending):
> >>
> >> fixes building for me, but please unify the branches before committing
> >
> >Sorry. What does it mean "unify the branches"?
>
> Only one insn changed between OPTIMIZE, i.e. please just:
Constraint changed too, from "i" (c) to "2" (c).
This was difficult to spot. This would be wrong
(it will probably build, but will contain extra
unneeded insn):
void *edi;
int ecx, eax;
__asm__ __volatile__(
" jecxz 1f\n"
#if defined __OPTIMIZE__
" movb %4, %%al\n" /* const c to %%al */
#endif
" repne; scasb\n"
" leal -1(%%edi), %%edi\n"
" je 2f\n"
"1:\n"
" xorl %%edi, %%edi\n"
"2:\n"
: "=&D" (edi), "=&c" (ecx), "=&a" (eax)
: "0" (s), "2" (c), "1" (count)
/* : no clobbers */
);
return edi;
asm is error prone, and when I was coding the fix,
I decided that keeping -O0 and !-O0 implementations
totally separate is reducing that risk.
You do not need to mentally imagine how the code looks like
in both cases by parsing #ifdefs, and whether it is correct
- you already see both cases:
#if defined __OPTIMIZE__
void *edi;
int ecx, eax;
__asm__ __volatile__(
" jecxz 1f\n"
" movb %4, %%al\n" /* const c to %%al */
" repne; scasb\n"
" leal -1(%%edi), %%edi\n"
" je 2f\n"
"1:\n"
" xorl %%edi, %%edi\n"
"2:\n"
: "=&D" (edi), "=&c" (ecx), "=&a" (eax)
: "0" (s), "i" (c), "1" (count)
/* : no clobbers */
);
return edi;
#else
/* With -O0, gcc can't figure out how to encode CONST c
* as an immediate operand. Generating slightly bigger code
* (usually "movl CONST,%eax", 3 bytes bigger than needed):
*/
void *edi;
int ecx, eax;
__asm__ __volatile__(
" jecxz 1f\n"
" repne; scasb\n"
" leal -1(%%edi), %%edi\n"
" je 2f\n"
"1:\n"
" xorl %%edi, %%edi\n"
"2:\n"
: "=&D" (edi), "=&c" (ecx), "=&a" (eax)
: "0" (s), "2" (c), "1" (count)
/* : no clobbers */
);
return edi;
#endif
But it's wordy, yes.
--
vda
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic