mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] lib: string: implement mempcpy
@ 2022-11-01  6:43 Ahmad Fatoum
  2022-11-02  8:04 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2022-11-01  6:43 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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.
---
 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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] lib: string: implement mempcpy
  2022-11-01  6:43 [PATCH] lib: string: implement mempcpy Ahmad Fatoum
@ 2022-11-02  8:04 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2022-11-02  8:04 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

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 |



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-02  8:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-01  6:43 [PATCH] lib: string: implement mempcpy Ahmad Fatoum
2022-11-02  8:04 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox