mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] lib: string: implement mempcpy
Date: Wed, 2 Nov 2022 09:04:04 +0100	[thread overview]
Message-ID: <20221102080404.GD3143@pengutronix.de> (raw)
In-Reply-To: <20221101064310.3227410-1-a.fatoum@pengutronix.de>

On Tue, Nov 01, 2022 at 07:43:10AM +0100, Ahmad Fatoum wrote:
> mempcpy(3) is a GNU libc extension that like stpcpy returns not the
> start of the destination buffer, but the first byte after its end.
> 
> Provide it as it is useful when concatenating buffers or known-size
> strings.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> v1 -> v2:
>   - split off function from series using it. Other series needs
>     commits reordered.

Applied, thanks

Sascha

> ---
>  include/string.h | 1 +
>  lib/string.c     | 5 +++++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/include/string.h b/include/string.h
> index 2cc727fd1d7a..596440ca8164 100644
> --- a/include/string.h
> +++ b/include/string.h
> @@ -4,6 +4,7 @@
>  
>  #include <linux/string.h>
>  
> +void *mempcpy(void *dest, const void *src, size_t count);
>  int strtobool(const char *str, int *val);
>  char *strsep_unescaped(char **, const char *);
>  char *stpcpy(char *dest, const char *src);
> diff --git a/lib/string.c b/lib/string.c
> index fd4d7da10a7c..edd36da4d4f2 100644
> --- a/lib/string.c
> +++ b/lib/string.c
> @@ -603,6 +603,11 @@ void *__memcpy(void * dest, const void *src, size_t count)
>  	__alias(__default_memcpy);
>  #endif
>  
> +void *mempcpy(void *dest, const void *src, size_t count)
> +{
> +	return memcpy(dest, src, count) + count;
> +}
> +EXPORT_SYMBOL(mempcpy);
>  
>  #ifndef __HAVE_ARCH_MEMMOVE
>  /**
> -- 
> 2.30.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2022-11-02  8:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-01  6:43 Ahmad Fatoum
2022-11-02  8:04 ` Sascha Hauer [this message]

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=20221102080404.GD3143@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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