RE: [PATCH] lib/string.c: implement stpcpy

2020-08-15 Thread David Laight
From: Nick Desaulniers > Sent: 15 August 2020 01:24 > > LLVM implemented a recent "libcall optimization" that lowers calls to > `sprintf(dest, "%s", str)` where the return value is used to > `stpcpy(dest, str) - dest`. This generally avoids the machinery involved > in parsing format strings. > >

Re: [PATCH] lib/string.c: implement stpcpy

2020-08-15 Thread Arvind Sankar
On Fri, Aug 14, 2020 at 05:24:15PM -0700, Nick Desaulniers wrote: > +#ifndef __HAVE_ARCH_STPCPY > +/** > + * stpcpy - copy a string from src to dest returning a pointer to the new end > + * of dest, including src's NULL terminator. May overrun dest. > + * @dest: pointer to end of string be

Re: [PATCH] lib/string.c: implement stpcpy

2020-08-15 Thread Nick Desaulniers
On Fri, Aug 14, 2020 at 5:52 PM Joe Perches wrote: > > On Fri, 2020-08-14 at 17:24 -0700, Nick Desaulniers wrote: > > LLVM implemented a recent "libcall optimization" that lowers calls to > > `sprintf(dest, "%s", str)` where the return value is used to > > `stpcpy(dest, str) - dest`. This generall

Re: [PATCH] lib/string.c: implement stpcpy

2020-08-15 Thread Nick Desaulniers
On Fri, Aug 14, 2020 at 6:33 PM Arvind Sankar wrote: > > On Fri, Aug 14, 2020 at 05:24:15PM -0700, Nick Desaulniers wrote: > > +#ifndef __HAVE_ARCH_STPCPY > > +/** > > + * stpcpy - copy a string from src to dest returning a pointer to the new > > end > > + * of dest, including src's NULL

Re: [PATCH] lib/string.c: implement stpcpy

2020-08-15 Thread Joe Perches
On Fri, 2020-08-14 at 17:24 -0700, Nick Desaulniers wrote: > LLVM implemented a recent "libcall optimization" that lowers calls to > `sprintf(dest, "%s", str)` where the return value is used to > `stpcpy(dest, str) - dest`. This generally avoids the machinery involved > in parsing format strings. [

Re: [PATCH] lib/string.c: implement stpcpy

2020-08-15 Thread Arvind Sankar
On Fri, Aug 14, 2020 at 09:33:10PM -0400, Arvind Sankar wrote: > On Fri, Aug 14, 2020 at 05:24:15PM -0700, Nick Desaulniers wrote: > > +#ifndef __HAVE_ARCH_STPCPY > > +/** > > + * stpcpy - copy a string from src to dest returning a pointer to the new > > end > > + * of dest, including src

Re: [PATCH] lib/string.c: implement stpcpy

2020-08-15 Thread Sami Tolvanen
Hi Nick, On Fri, Aug 14, 2020 at 5:24 PM Nick Desaulniers wrote: > > LLVM implemented a recent "libcall optimization" that lowers calls to > `sprintf(dest, "%s", str)` where the return value is used to > `stpcpy(dest, str) - dest`. This generally avoids the machinery involved > in parsing format

[PATCH] lib/string.c: implement stpcpy

2020-08-14 Thread Nick Desaulniers
LLVM implemented a recent "libcall optimization" that lowers calls to `sprintf(dest, "%s", str)` where the return value is used to `stpcpy(dest, str) - dest`. This generally avoids the machinery involved in parsing format strings. `stpcpy` is just like `strcpy` except: 1. it returns the pointer to