On 2/5/24 18:56, Chris Wellons wrote:
> *An improved chkstk function on Windows*
> https://nullprogram.com/blog/2024/02/05/
>
> I also recently added a libmemory
> <https://github.com/skeeto/w64devkit/blob/master/src/libmemory.c> to
> w64devkit, providing tiny, public domain definitions of |memset|,
> |memcpy|, |memmove|, |memcmp|, and |strlen|. All compilers fabricate
> calls to these five functions even if you don’t call them yourself,
> which is how they were selected. (Not because I like them. I really
> don’t. <https://nullprogram.com/blog/2023/02/11/>). If a |-nostdlib|
> build complains about these, too, then add |-lmemory|.
You may already know this, but libgcc contains public domain C versions
of memcpy, memset, and memmove. They’re not optimized, but they’re in
the top level of the libgcc directory in the GCC source and presumably
free and unencumbered to reuse.
Thanks, I didn't know about these. I found them in the GCC source like you
said, and they're nearly 20 years old, but they're not actually present in
libgcc.a. They were originally checked in outside of libgcc/, later moved
there during reorganization, and it looks like maybe they only exist for
GCC's own internal use (like the additional definitions in libiberty)? I
don't see them included in builds, so maybe they're now vestigial.
While memset, memcpy, and memcmp look fine, libgcc/memmove.c has several
defects, so I wouldn't want to use it anyway. I'm glad you pointed these
out, though!