New upstream version 4.18.0

This commit is contained in:
Chris Hofstaedtler
2025-08-26 22:55:14 +02:00
parent a9c3448878
commit 9d5ab87d61
580 changed files with 25692 additions and 19474 deletions

View File

@@ -0,0 +1,13 @@
// SPDX-FileCopyrightText: 2025, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "string/sprintf/aprintf.h"
#include <stdarg.h>
extern inline char *aprintf(const char *restrict fmt, ...);
extern inline char *vaprintf(const char *restrict fmt, va_list ap);

View File

@@ -0,0 +1,57 @@
// SPDX-FileCopyrightText: 2025, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_STRING_SPRINTF_APRINTF_H_
#define SHADOW_INCLUDE_LIB_STRING_SPRINTF_APRINTF_H_
#include <config.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include "attr.h"
ATTR_MALLOC(free)
format_attr(printf, 1, 2)
inline char *aprintf(const char *restrict fmt, ...);
ATTR_MALLOC(free)
format_attr(printf, 1, 0)
inline char *vaprintf(const char *restrict fmt, va_list ap);
// allocate print formatted
// Like asprintf(3), but simpler; omit the length.
inline char *
aprintf(const char *restrict fmt, ...)
{
char *p;
va_list ap;
va_start(ap, fmt);
p = vaprintf(fmt, ap);
va_end(ap);
return p;
}
// Like vasprintf(3), but simpler; omit the length.
inline char *
vaprintf(const char *restrict fmt, va_list ap)
{
char *p;
if (vasprintf(&p, fmt, ap) == -1)
return NULL;
return p;
}
#endif // include guard

View File

@@ -18,7 +18,7 @@
#define SNPRINTF(s, fmt, ...) \
( \
snprintf_(s, NITEMS(s), fmt __VA_OPT__(,) __VA_ARGS__) \
snprintf_(s, countof(s), fmt __VA_OPT__(,) __VA_ARGS__) \
)

View File

@@ -40,7 +40,7 @@ inline char *vstpeprintf(char *dst, char *end, const char *restrict fmt,
*
* end Pointer to one after the last element of the buffer
* pointed to by `dst`. Usually, it should be calculated
* as `dst + NITEMS(dst)`.
* as `dst + countof(dst)`.
*
* fmt Format string
*

View File

@@ -0,0 +1,13 @@
// SPDX-FileCopyrightText: 2023-2025, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "string/sprintf/xaprintf.h"
#include <stdarg.h>
extern inline char *xaprintf(const char *restrict fmt, ...);
extern inline char *xvaprintf(const char *restrict fmt, va_list ap);

View File

@@ -0,0 +1,59 @@
// SPDX-FileCopyrightText: 2023-2025, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_STRING_SPRINTF_XASPRINTF_H_
#define SHADOW_INCLUDE_LIB_STRING_SPRINTF_XASPRINTF_H_
#include <config.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include "attr.h"
#include "string/sprintf/aprintf.h"
ATTR_MALLOC(free)
format_attr(printf, 1, 2)
inline char *xaprintf(const char *restrict fmt, ...);
ATTR_MALLOC(free)
format_attr(printf, 1, 0)
inline char *xvaprintf(const char *restrict fmt, va_list ap);
// exit-on-error allocate print formatted
inline char *
xaprintf(const char *restrict fmt, ...)
{
char *p;
va_list ap;
va_start(ap, fmt);
p = xvaprintf(fmt, ap);
va_end(ap);
return p;
}
inline char *
xvaprintf(const char *restrict fmt, va_list ap)
{
char *p;
p = vaprintf(fmt, ap);
if (p == NULL) {
perror("vaprintf");
exit(EXIT_FAILURE);
}
return p;
}
#endif // include guard

View File

@@ -1,14 +0,0 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "string/sprintf/xasprintf.h"
#include <stdarg.h>
extern inline int xasprintf(char **restrict s, const char *restrict fmt, ...);
extern inline int xvasprintf(char **restrict s, const char *restrict fmt,
va_list ap);

View File

@@ -1,54 +0,0 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_STRING_SPRINTF_XASPRINTF_H_
#define SHADOW_INCLUDE_LIB_STRING_SPRINTF_XASPRINTF_H_
#include <config.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include "attr.h"
format_attr(printf, 2, 3)
inline int xasprintf(char **restrict s, const char *restrict fmt, ...);
format_attr(printf, 2, 0)
inline int xvasprintf(char **restrict s, const char *restrict fmt, va_list ap);
inline int
xasprintf(char **restrict s, const char *restrict fmt, ...)
{
int len;
va_list ap;
va_start(ap, fmt);
len = xvasprintf(s, fmt, ap);
va_end(ap);
return len;
}
inline int
xvasprintf(char **restrict s, const char *restrict fmt, va_list ap)
{
int len;
len = vasprintf(s, fmt, ap);
if (len == -1) {
perror("asprintf");
exit(EXIT_FAILURE);
}
return len;
}
#endif // include guard