[PATCH 1/6] newlib: string: refactor str/mem-family functions

Corinna Vinschen vinschen@redhat.com
Mon Feb 10 12:10:46 GMT 2025


Hi Alexey,

On Jan 27 10:43, Alexey Lapshin wrote:
> Move common macros to local.h header
> ---
>  newlib/libc/string/local.h     | 32 +++++++++++++++++++++++
>  newlib/libc/string/memccpy.c   | 34 +++++-------------------
>  newlib/libc/string/memchr.c    | 43 ++++++-------------------------
>  newlib/libc/string/memcmp.c    | 20 ++++-----------
>  newlib/libc/string/memcpy.c    | 23 ++++-------------
>  newlib/libc/string/memmove.c   | 23 ++++-------------
>  newlib/libc/string/mempcpy.c   | 24 +++++------------
>  newlib/libc/string/memrchr.c   | 47 ++++++++--------------------------
>  newlib/libc/string/memset.c    | 18 +++++--------
>  newlib/libc/string/rawmemchr.c | 35 +++----------------------
>  newlib/libc/string/stpcpy.c    | 23 ++---------------
>  newlib/libc/string/stpncpy.c   | 32 +++++------------------
>  newlib/libc/string/strcat.c    | 25 +++---------------
>  newlib/libc/string/strchr.c    | 30 ++++------------------
>  newlib/libc/string/strcmp.c    | 23 ++---------------
>  newlib/libc/string/strcpy.c    | 23 ++---------------
>  newlib/libc/string/strlen.c    | 23 +++--------------
>  newlib/libc/string/strncat.c   | 24 +++--------------
>  newlib/libc/string/strncmp.c   | 24 +++--------------
>  newlib/libc/string/strncpy.c   | 26 +++----------------
>  20 files changed, 120 insertions(+), 432 deletions(-)

After applying this patch, I'm getting warnings:

newlib/libc/string/strcmp.c: In function ‘strcmp’:
newlib/libc/string/strcmp.c:52:8: warning: implicit declaration of function ‘UNALIGNED_X_Y’ [-Wimplicit-function-declaration]
   52 |   if (!UNALIGNED_X_Y(s1, s2))
      |        ^~~~~~~~~~~~~
newlib/libc/string/strcmp.c:61:15: warning: implicit declaration of function ‘DETECT_NULL’ [-Wimplicit-function-declaration]
   61 |           if (DETECT_NULL(*a1))
      |               ^~~~~~~~~~~

newlib/libc/string/strchr.c: In function ‘strchr’:
newlib/libc/string/strchr.c:48:14: warning: implicit declaration of function ‘UNALIGNED_X’ [-Wimplicit-function-declaration]
   48 |       while (UNALIGNED_X(s))
      |              ^~~~~~~~~~~
newlib/libc/string/strchr.c:56:15: warning: implicit declaration of function ‘DETECT_NULL’ [-Wimplicit-function-declaration]
   56 |       while (!DETECT_NULL(*aligned_addr))
      |               ^~~~~~~~~~~
newlib/libc/string/strchr.c:80:42: warning: implicit declaration of function ‘DETECT_CHAR’ [-Wimplicit-function-declaration]
   80 |   while (!DETECT_NULL(*aligned_addr) && !DETECT_CHAR(*aligned_addr, mask))
      |                                          ^~~~~~~~~~~

home/corinna/src/cygwin/vanilla/newlib/libc/string/strcpy.c: In function ‘strcpy’:
newlib/libc/string/strcpy.c:53:8: warning: implicit declaration of function ‘UNALIGNED_X_Y’ [-Wimplicit-function-declaration]
   53 |   if (!UNALIGNED_X_Y(src, dst))
      |        ^~~~~~~~~~~~~
newlib/libc/string/strcpy.c:60:15: warning: implicit declaration of function ‘DETECT_NULL’ [-Wimplicit-function-declaration]
   60 |       while (!DETECT_NULL(*aligned_src))
      |               ^~~~~~~~~~~

newlib/libc/string/stpcpy.c: In function ‘stpcpy’:
  CC       libc/reent/libc_a-statr.o
newlib/libc/string/stpcpy.c:45:8: warning: implicit declaration of function ‘UNALIGNED_X_Y’ [-Wimplicit-function-declaration]
   45 |   if (!UNALIGNED_X_Y(src, dst))
      |        ^~~~~~~~~~~~~
newlib/libc/string/stpcpy.c:52:15: warning: implicit declaration of function ‘DETECT_NULL’ [-Wimplicit-function-declaration]
   52 |       while (!DETECT_NULL(*aligned_src))
      |               ^~~~~~~~~~~

Looks like there's an include missing.


Thanks,
Corinna



More information about the Newlib mailing list