Add mempcpy(3)
We'll use it for implementing stpecpy(), and may be interesting to have it around. Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
parent
8a9285aacb
commit
e0e9e57a72
@ -47,7 +47,7 @@ AC_CHECK_HEADER([shadow.h],,[AC_MSG_ERROR([You need a libc with shadow.h])])
|
||||
|
||||
AC_CHECK_FUNCS(arc4random_buf futimes \
|
||||
getentropy getrandom getspnam getusershell \
|
||||
initgroups lckpwdf lutimes \
|
||||
initgroups lckpwdf lutimes mempcpy \
|
||||
setgroups updwtmp updwtmpx innetgr \
|
||||
getspnam_r \
|
||||
memset_explicit explicit_bzero stpeprintf)
|
||||
|
31
lib/mempcpy.h
Normal file
31
lib/mempcpy.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023, Alejandro Colomar <alx@kernel.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SHADOW_INCLUDE_LIB_MEMPCPY_H_
|
||||
#define SHADOW_INCLUDE_LIB_MEMPCPY_H_
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if !defined(HAVE_MEMPCPY)
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
inline void *mempcpy(void *restrict dst, const void *restrict src, size_t n);
|
||||
|
||||
|
||||
inline void *
|
||||
mempcpy(void *restrict dst, const void *restrict src, size_t n)
|
||||
{
|
||||
return memcpy(dst, src, n) + n;
|
||||
}
|
||||
|
||||
|
||||
#endif // !HAVE_MEMPCPY
|
||||
#endif // include guard
|
@ -44,6 +44,7 @@ libmisc_la_SOURCES = \
|
||||
list.c log.c \
|
||||
loginprompt.c \
|
||||
mail.c \
|
||||
mempcpy.c \
|
||||
motd.c \
|
||||
myname.c \
|
||||
obscure.c \
|
||||
|
23
libmisc/mempcpy.c
Normal file
23
libmisc/mempcpy.c
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023, Alejandro Colomar <alx@kernel.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if !defined(HAVE_MEMPCPY)
|
||||
|
||||
#ident "$Id$"
|
||||
|
||||
#include "mempcpy.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
extern inline void *mempcpy(void *restrict dst, const void *restrict src,
|
||||
size_t n);
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user