libc/wchar: Add wmemcpy() - scc - simple c99 compiler
 (HTM) git clone git://git.simple-cc.org/scc
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit f82bc6684d7c33065ce616b79528e7a0e439d1df
 (DIR) parent 391c2dacb748852e77bfe811556b145ecdda684b
 (HTM) Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
       Date:   Tue, 25 Mar 2025 19:03:27 +0100
       
       libc/wchar: Add wmemcpy()
       
       Diffstat:
         M src/libc/objs/common-objs.mk        |       1 +
         A src/libc/wchar/wmemcpy.c            |      10 ++++++++++
         M tests/libc/execute/.gitignore       |       1 +
         A tests/libc/execute/0050-wmemcpy.c   |      24 ++++++++++++++++++++++++
         M tests/libc/execute/libc-tests.lst   |       1 +
       
       5 files changed, 37 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/src/libc/objs/common-objs.mk b/src/libc/objs/common-objs.mk
       @@ -134,5 +134,6 @@ COMMON_OBJS =\
                wchar/wcsrtombs.$O\
                wchar/wcwidth.$O\
                wchar/wmemchr.$O\
       +        wchar/wmemcpy.$O\
                wchar/putwc.$O\
                wchar/_validutf8.$O\
 (DIR) diff --git a/src/libc/wchar/wmemcpy.c b/src/libc/wchar/wmemcpy.c
       @@ -0,0 +1,10 @@
       +#include <string.h>
       +#include <wchar.h>
       +
       +#undef wmemcpy
       +
       +wchar_t *
       +wmemcpy(wchar_t *restrict d, const wchar_t *restrict s, size_t n)
       +{
       +        return memcpy(d, s, n * sizeof(wchar_t));
       +}
 (DIR) diff --git a/tests/libc/execute/.gitignore b/tests/libc/execute/.gitignore
       @@ -46,4 +46,5 @@
        0047-wcscoll
        0048-wcscpy
        0049-wmemchr
       +0050-wmemcpy
        test.log
 (DIR) diff --git a/tests/libc/execute/0050-wmemcpy.c b/tests/libc/execute/0050-wmemcpy.c
       @@ -0,0 +1,24 @@
       +#include <assert.h>
       +#include <stdio.h>
       +#include <wchar.h>
       +
       +/*
       +output:
       +testing
       +done
       +end:
       +*/
       +
       +int
       +main()
       +{
       +        wchar_t buf[40];
       +        wchar_t abc[] = {'a', 'b', 'c', '\0'};
       +
       +        puts("testing");
       +        assert(!wmemcmp(wmemcpy(buf, abc, 3), abc, 3));
       +        assert(wmemcpy(buf, abc, 0) == buf);
       +        puts("done");
       +
       +        return 0;
       +}
 (DIR) diff --git a/tests/libc/execute/libc-tests.lst b/tests/libc/execute/libc-tests.lst
       @@ -45,3 +45,4 @@
        0047-wcscoll
        0048-wcscpy
        0049-wmemchr
       +0050-wmemcpy