xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: Jan Beulich <jbeulich@suse.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Ian Jackson" <iwj@xenproject.org>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [PATCH 03/23] string: drop redundant declarations
Date: Thu, 1 Apr 2021 15:59:03 +0100	[thread overview]
Message-ID: <69ccb1f4-12c8-b3ce-3271-16e19908cce1@xen.org> (raw)
In-Reply-To: <e0915251-b0cc-79ee-feec-08722e1243fb@suse.com>

Hi Jan,

On 01/04/2021 11:20, Jan Beulich wrote:
> These standard functions shouldn't need custom declarations. The only
> case where redundancy might be needed is if there were inline functions
> there. But we don't have any here (anymore). Prune the per-arch headers
> of duplicate declarations while moving the asm/string.h inclusion past
> the declarations.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Julien Grall <jgrall@amazon.com>

Cheers,

> 
> --- a/xen/include/asm-arm/string.h
> +++ b/xen/include/asm-arm/string.h
> @@ -8,41 +8,21 @@
>    */
>   
>   #define __HAVE_ARCH_STRRCHR
> -char *strrchr(const char *s, int c);
> -
>   #define __HAVE_ARCH_STRCHR
> -char *strchr(const char *s, int c);
> -
>   #if defined(CONFIG_ARM_64)
>   #define __HAVE_ARCH_STRCMP
> -int strcmp(const char *, const char *);
> -
>   #define __HAVE_ARCH_STRNCMP
> -int strncmp(const char *, const char *, size_t);
> -
>   #define __HAVE_ARCH_STRLEN
> -size_t strlen(const char *);
> -
>   #define __HAVE_ARCH_STRNLEN
> -size_t strnlen(const char *, size_t);
>   #endif
>   
>   #define __HAVE_ARCH_MEMCPY
> -void *memcpy(void *, const void *, size_t);
> -
>   #if defined(CONFIG_ARM_64)
>   #define __HAVE_ARCH_MEMCMP
> -int memcmp(const void *, const void *, size_t);
>   #endif
> -
>   #define __HAVE_ARCH_MEMMOVE
> -void *memmove(void *dest, const void *src, size_t n);
> -
>   #define __HAVE_ARCH_MEMSET
> -void *memset(void *, int, size_t);
> -
>   #define __HAVE_ARCH_MEMCHR
> -void *memchr(const void *, int, size_t);
>   
>   #if defined(CONFIG_ARM_32)
>   
> --- a/xen/include/asm-x86/string.h
> +++ b/xen/include/asm-x86/string.h
> @@ -2,15 +2,12 @@
>   #define __X86_STRING_H__
>   
>   #define __HAVE_ARCH_MEMCPY
> -void *memcpy(void *dest, const void *src, size_t n);
>   #define memcpy(d, s, n) __builtin_memcpy(d, s, n)
>   
>   #define __HAVE_ARCH_MEMMOVE
> -void *memmove(void *dest, const void *src, size_t n);
>   #define memmove(d, s, n) __builtin_memmove(d, s, n)
>   
>   #define __HAVE_ARCH_MEMSET
> -void *memset(void *dest, int c, size_t n);
>   #define memset(s, c, n) __builtin_memset(s, c, n)
>   
>   #endif /* __X86_STRING_H__ */
> --- a/xen/include/xen/string.h
> +++ b/xen/include/xen/string.h
> @@ -4,11 +4,6 @@
>   #include <xen/types.h>	/* for size_t */
>   
>   /*
> - * Include machine specific inline routines
> - */
> -#include <asm/string.h>
> -
> -/*
>    * These string functions are considered too dangerous for normal use.
>    * Use safe_strcpy(), safe_strcat(), strlcpy(), strlcat() as appropriate.
>    */
> @@ -17,97 +12,78 @@
>   #define strncpy __xen_has_no_strncpy__
>   #define strncat __xen_has_no_strncat__
>   
> -#ifndef __HAVE_ARCH_STRLCPY
>   size_t strlcpy(char *, const char *, size_t);
> -#endif
> -
> -#ifndef __HAVE_ARCH_STRLCAT
>   size_t strlcat(char *, const char *, size_t);
> -#endif
> +int strcmp(const char *, const char *);
> +int strncmp(const char *, const char *, size_t);
> +int strnicmp(const char *, const char *, size_t);
> +int strcasecmp(const char *, const char *);
> +char *strchr(const char *, int);
> +char *strrchr(const char *, int);
> +char *strstr(const char *, const char *);
> +size_t strlen(const char *);
> +size_t strnlen(const char *, size_t);
> +char *strpbrk(const char *, const char *);
> +char *strsep(char **, const char *);
> +size_t strspn(const char *, const char *);
> +
> +void *memset(void *, int, size_t);
> +void *memcpy(void *, const void *, size_t);
> +void *memmove(void *, const void *, size_t);
> +int memcmp(const void *, const void *, size_t);
> +void *memchr(const void *, int, size_t);
> +void *memchr_inv(const void *, int, size_t);
> +
> +#include <asm/string.h>
>   
>   #ifndef __HAVE_ARCH_STRCMP
> -int strcmp(const char *, const char *);
>   #define strcmp(s1, s2) __builtin_strcmp(s1, s2)
>   #endif
>   
>   #ifndef __HAVE_ARCH_STRNCMP
> -int strncmp(const char *, const char *, size_t);
>   #define strncmp(s1, s2, n) __builtin_strncmp(s1, s2, n)
>   #endif
>   
> -#ifndef __HAVE_ARCH_STRNICMP
> -int strnicmp(const char *, const char *, size_t);
> -#endif
> -
>   #ifndef __HAVE_ARCH_STRCASECMP
> -int strcasecmp(const char *, const char *);
>   #define strcasecmp(s1, s2) __builtin_strcasecmp(s1, s2)
>   #endif
>   
>   #ifndef __HAVE_ARCH_STRCHR
> -char *strchr(const char *, int);
>   #define strchr(s1, c) __builtin_strchr(s1, c)
>   #endif
>   
>   #ifndef __HAVE_ARCH_STRRCHR
> -char *strrchr(const char *, int);
>   #define strrchr(s1, c) __builtin_strrchr(s1, c)
>   #endif
>   
>   #ifndef __HAVE_ARCH_STRSTR
> -char *strstr(const char *, const char *);
>   #define strstr(s1, s2) __builtin_strstr(s1, s2)
>   #endif
>   
>   #ifndef __HAVE_ARCH_STRLEN
> -size_t strlen(const char *);
>   #define strlen(s1) __builtin_strlen(s1)
>   #endif
>   
> -#ifndef __HAVE_ARCH_STRNLEN
> -size_t strnlen(const char *, size_t);
> -#endif
> -
> -#ifndef __HAVE_ARCH_STRPBRK
> -char *strpbrk(const char *, const char *);
> -#endif
> -
> -#ifndef __HAVE_ARCH_STRSEP
> -char *strsep(char **, const char *);
> -#endif
> -
> -#ifndef __HAVE_ARCH_STRSPN
> -size_t strspn(const char *, const char *);
> -#endif
> -
> -
>   #ifndef __HAVE_ARCH_MEMSET
> -void *memset(void *, int, size_t);
>   #define memset(s, c, n) __builtin_memset(s, c, n)
>   #endif
>   
>   #ifndef __HAVE_ARCH_MEMCPY
> -void *memcpy(void *, const void *, size_t);
>   #define memcpy(d, s, n) __builtin_memcpy(d, s, n)
>   #endif
>   
>   #ifndef __HAVE_ARCH_MEMMOVE
> -void *memmove(void *, const void *, size_t);
>   #define memmove(d, s, n) __builtin_memmove(d, s, n)
>   #endif
>   
>   #ifndef __HAVE_ARCH_MEMCMP
> -int memcmp(const void *, const void *, size_t);
>   #define memcmp(s1, s2, n) __builtin_memcmp(s1, s2, n)
>   #endif
>   
>   #ifndef __HAVE_ARCH_MEMCHR
> -void *memchr(const void *, int, size_t);
>   #define memchr(s, c, n) __builtin_memchr(s, c, n)
>   #endif
>   
> -void *memchr_inv(const void *, int, size_t);
> -
>   #define is_char_array(x) __builtin_types_compatible_p(typeof(x), char[])
>   
>   /* safe_xxx always NUL-terminates and returns !=0 if result is truncated. */
> 

-- 
Julien Grall


  reply	other threads:[~2021-04-01 14:59 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-01 10:14 [PATCH 00/23] further population of xen/lib/ Jan Beulich
2021-04-01 10:19 ` [PATCH 01/23] lib: move muldiv64() Jan Beulich
2021-04-15 10:00   ` Ping (x86): " Jan Beulich
2021-04-15 12:46   ` Roger Pau Monné
2021-04-01 10:19 ` [PATCH 02/23] lib: move 64-bit div/mod compiler helpers Jan Beulich
2021-04-01 14:56   ` Julien Grall
2021-04-01 15:23     ` Jan Beulich
2021-04-06 19:34       ` Julien Grall
2021-04-07  8:33         ` Jan Beulich
2021-04-07 14:06           ` Julien Grall
2021-04-01 10:20 ` [PATCH 03/23] string: drop redundant declarations Jan Beulich
2021-04-01 14:59   ` Julien Grall [this message]
2021-04-01 10:20 ` [PATCH 04/23] lib: move memset() Jan Beulich
2021-04-01 10:21 ` [PATCH 05/23] lib: move memcpy() Jan Beulich
2021-04-01 10:21 ` [PATCH 06/23] lib: move memmove() Jan Beulich
2021-04-01 10:22 ` [PATCH 07/23] lib: move memcmp() Jan Beulich
2021-04-01 10:22 ` [PATCH 08/23] lib: move memchr() Jan Beulich
2021-04-01 10:23 ` [PATCH 09/23] lib: move memchr_inv() Jan Beulich
2021-04-01 10:23 ` [PATCH 10/23] lib: move strlen() Jan Beulich
2021-04-01 10:23 ` [PATCH 11/23] lib: move strnlen() Jan Beulich
2021-04-01 10:24 ` [PATCH 12/23] lib: move strcmp() Jan Beulich
2021-04-01 10:25 ` [PATCH 13/23] lib: move strncmp() Jan Beulich
2021-04-01 10:25 ` [PATCH 14/23] lib: move strlcpy() Jan Beulich
2021-04-01 10:25 ` [PATCH 15/23] lib: move strlcat() Jan Beulich
2021-04-01 10:25 ` [PATCH 16/23] lib: move strchr() Jan Beulich
2021-04-01 10:26 ` [PATCH 17/23] lib: move strrchr() Jan Beulich
2021-04-01 10:26 ` [PATCH 18/23] lib: move strstr() Jan Beulich
2021-04-01 10:26 ` [PATCH 19/23] lib: move strcasecmp() Jan Beulich
2021-04-01 10:27 ` [PATCH 20/23] lib: move/rename strnicmp() to strncasecmp() Jan Beulich
2021-04-01 10:27 ` [PATCH 21/23] lib: move strspn() Jan Beulich
2021-04-01 10:28 ` [PATCH 22/23] lib: move strpbrk() Jan Beulich
2021-04-01 10:28 ` [PATCH 23/23] lib: move strsep() Jan Beulich
2021-04-01 11:54 ` [PATCH 00/23] further population of xen/lib/ Julien Grall
2021-04-01 13:43   ` Jan Beulich
2021-04-01 14:04     ` Julien Grall
2021-04-01 14:27       ` Jan Beulich
2021-04-01 14:55         ` Julien Grall
2021-04-01 15:25           ` Jan Beulich
2021-04-01 15:32             ` Julien Grall

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=69ccb1f4-12c8-b3ce-3271-16e19908cce1@xen.org \
    --to=julien@xen.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).