New upstream version 4.17.0~rc1

This commit is contained in:
Chris Hofstaedtler
2024-12-06 19:17:25 +01:00
parent 9f68246a01
commit f78a468368
858 changed files with 9076 additions and 13407 deletions
+12
View File
@@ -0,0 +1,12 @@
// SPDX-FileCopyrightText: 2022-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "string/strcpy/stpecpy.h"
#if !defined(HAVE_STPECPY)
extern inline char *stpecpy(char *dst, char *end, const char *restrict src);
#endif
+88
View File
@@ -0,0 +1,88 @@
// SPDX-FileCopyrightText: 2022-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_STRING_STRCPY_STPECPY_H_
#define SHADOW_INCLUDE_LIB_STRING_STRCPY_STPECPY_H_
#include <config.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include "attr.h"
#if !defined(HAVE_STPECPY)
ATTR_STRING(3)
inline char *stpecpy(char *dst, char *end, const char *restrict src);
#endif
/*
* SYNOPSIS
* [[gnu::null_terminated_string_arg(3)]]
* char *_Nullable stpecpy(char *_Nullable dst, char end[0],
* const char *restrict src);
*
* ARGUMENTS
* dst Destination buffer where to copy a string.
*
* end Pointer to one after the last element of the buffer
* pointed to by `dst`. Usually, it should be calculated
* as `dst + NITEMS(dst)`.
*
* src Source string to be copied into dst.
*
* DESCRIPTION
* This function copies the string pointed to by src, into a string
* at the buffer pointed to by dst. If the destination buffer,
* limited by a pointer to its end --one after its last element--,
* isn't large enough to hold the copy, the resulting string is
* truncated.
*
* This function can be chained with calls to [v]stpeprintf().
*
* RETURN VALUE
* dst + strlen(dst)
* • On success, this function returns a pointer to the
* terminating NUL byte.
*
* end
* • If this call truncated the resulting string.
* • If `dst == end` (a previous chained call to these
* functions truncated).
* NULL
* • If `dst == NULL` (a previous chained call to
* [v]stpeprintf() failed).
*
* ERRORS
* This function doesn't set errno.
*/
#if !defined(HAVE_STPECPY)
inline char *
stpecpy(char *dst, char *end, const char *restrict src)
{
bool trunc;
size_t dsize, dlen, slen;
if (dst == end)
return end;
if (dst == NULL)
return NULL;
dsize = end - dst;
slen = strnlen(src, dsize);
trunc = (slen == dsize);
dlen = slen - trunc;
return stpcpy(mempcpy(dst, src, dlen), "") + trunc;
}
#endif
#endif // include guard
+7
View File
@@ -0,0 +1,7 @@
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "string/strcpy/strncat.h"
+19
View File
@@ -0,0 +1,19 @@
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_STRING_STRCPY_STRNCAT_H_
#define SHADOW_INCLUDE_LIB_STRING_STRCPY_STRNCAT_H_
#include <config.h>
#include <string.h>
#include "sizeof.h"
#define STRNCAT(dst, src) strncat(dst, src, NITEMS(src))
#endif // include guard
+7
View File
@@ -0,0 +1,7 @@
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "string/strcpy/strncpy.h"
+19
View File
@@ -0,0 +1,19 @@
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_STRING_STRCPY_STRNCPY_H_
#define SHADOW_INCLUDE_LIB_STRING_STRCPY_STRNCPY_H_
#include <config.h>
#include <string.h>
#include "sizeof.h"
#define STRNCPY(dst, src) strncpy(dst, src, NITEMS(dst))
#endif // include guard
+14
View File
@@ -0,0 +1,14 @@
// SPDX-FileCopyrightText: 2022-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include <stddef.h>
#include <sys/types.h>
#include "string/strcpy/strtcpy.h"
extern inline ssize_t strtcpy(char *restrict dst, const char *restrict src,
size_t dsize);
+77
View File
@@ -0,0 +1,77 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_STRING_STRCPY_STRTCPY_H_
#define SHADOW_INCLUDE_LIB_STRING_STRCPY_STRTCPY_H_
#include <config.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include "attr.h"
#include "sizeof.h"
/*
* SYNOPSIS
* [[gnu::null_terminated_string_arg(2)]]
* int STRTCPY(char dst[restrict], const char *restrict src);
*
* ARGUMENTS
* dst Destination buffer where to copy a string.
* src Source string to be copied into dst.
*
* DESCRIPTION
* This macro copies the string pointed to by src, into a string
* at the buffer pointed to by dst. If the destination buffer,
* isn't large enough to hold the copy, the resulting string is
* truncated. The size of the buffer is calculated internally via
* NITEMS().
*
* RETURN VALUE
* -1 If this call truncated the resulting string.
*
* strlen(dst)
* On success.
*
* ERRORS
* This function doesn't set errno.
*/
#define STRTCPY(dst, src) strtcpy(dst, src, NITEMS(dst))
ATTR_STRING(2)
inline ssize_t strtcpy(char *restrict dst, const char *restrict src,
size_t dsize);
inline ssize_t
strtcpy(char *restrict dst, const char *restrict src, size_t dsize)
{
bool trunc;
size_t dlen, slen;
if (dsize == 0)
return -1;
slen = strnlen(src, dsize);
trunc = (slen == dsize);
dlen = slen - trunc;
stpcpy(mempcpy(dst, src, dlen), "");
if (trunc)
return -1;
return slen;
}
#endif // include guard