use __restrict__ in headers for g++ compatibility

This commit is contained in:
Lephenixnoir 2021-06-13 16:51:47 +02:00
parent 6be2a3d52e
commit 518a866750
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
9 changed files with 86 additions and 79 deletions

View file

@ -50,7 +50,7 @@ extern void __printf_enable_fixed(void);
*/
struct __printf_output {
/* Final output, after buffering */
char * restrict str;
char * __restrict__ str;
FILE *fp;
int fd;
/* Size of the final output */
@ -66,8 +66,8 @@ struct __printf_output {
/* Generic formatted printing. */
extern int __printf(
struct __printf_output * restrict __out,
char const * restrict __format,
struct __printf_output * __restrict__ __out,
char const * __restrict__ __format,
va_list *__args);
@ -116,9 +116,9 @@ struct __printf_format {
** -> __args is a pointer to the variable list of arguments to read from
*/
typedef void __printf_formatter_t(
struct __printf_output * restrict __out,
struct __printf_format * restrict __opts,
va_list * restrict __args
struct __printf_output *__out,
struct __printf_format *__opts,
va_list *__args
);
/*

View file

@ -245,14 +245,14 @@ extern imaxdiv_t imaxdiv(intmax_t __num, intmax_t __denom);
/* Parse an intmax_t from string. */
extern intmax_t strtoimax(
char const * restrict __ptr,
char ** restrict __endptr,
char const * __restrict__ __ptr,
char ** __restrict__ __endptr,
int __base);
/* Parse an uintmax_t from string. */
extern uintmax_t strtoumax(
char const * restrict __ptr,
char ** restrict __endptr,
char const * __restrict__ __ptr,
char ** __restrict__ __endptr,
int __base);
#endif /*__INTTYPES_H__*/

View file

@ -36,8 +36,8 @@ typedef uint32_t kernel_sigset_t;
#include <sys/types.h>
/* Get and/or change the set of blocked signals. */
extern int sigprocmask (int __how, const sigset_t *restrict __set,
sigset_t *restrict __oldset);
extern int sigprocmask (int __how, const sigset_t * __restrict__ __set,
sigset_t * __restrict__ __oldset);
/*
** Send signal SIG to process number PID. If PID is zero, send SIG to all

View file

@ -42,32 +42,36 @@ extern FILE *stderr;
*/
/* Formatted print to file. */
extern int fprintf(FILE * restrict __fp, char const * restrict __format, ...);
extern int fprintf(FILE * __restrict__ __fp,
char const * __restrict__ __format, ...);
/* Formatted print to stdout. */
extern int printf(char const * restrict __format, ...);
extern int printf(
char const * __restrict__ __format, ...);
/* Formatted print to string (with limited size). */
extern int snprintf(char * restrict __str, size_t __size,
char const * restrict __format, ...);
extern int snprintf(char * __restrict__ __str, size_t __size,
char const * __restrict__ __format, ...);
/* Formatted print to string (with unlimited size!). */
extern int sprintf(char * restrict __str, char const * restrict __format, ...);
extern int sprintf(char * __restrict__ __str,
char const * __restrict__ __format, ...);
/* Formatted print to file (variable argument list). */
extern int vfprintf(FILE * restrict __fp, char const * restrict __format,
va_list __args);
extern int vfprintf(FILE * __restrict__ __fp,
char const * __restrict__ __format, va_list __args);
/* Formatted print to stdout (variable argument list). */
extern int vprintf(char const * restrict __format, va_list __args);
extern int vprintf(
char const * __restrict__ __format, va_list __args);
/* Formatted print to string (limited size, variable argument list). */
extern int vsnprintf(char * restrict __str, size_t __size,
char const * restrict __format, va_list __args);
extern int vsnprintf(char * __restrict__ __str, size_t __size,
char const * __restrict__ __format, va_list __args);
/* Formatted print to string (unlimited size!, variable argument list). */
extern int vsprintf(char * restrict __str, char const * restrict __format,
va_list __args);
extern int vsprintf(char * __restrict__ __str,
char const * __restrict__ __format, va_list __args);
/* putx() - display char / string */
extern int putchar(int c);
@ -76,16 +80,19 @@ extern int puts(const char *s);
/* Extensions. */
/* Formatted print to file descriptor. */
extern int dprintf(int __fd, char const * restrict __format, ...);
extern int dprintf(int __fd,
char const * __restrict__ __format, ...);
/* Formatted print to file descriptor (variable argument list). */
extern int vdprintf(int __fd, char const * restrict __format, va_list __args);
extern int vdprintf(int __fd,
char const * __restrict__ __format, va_list __args);
/* Allocating sprintf(). */
extern int asprintf(char ** restrict __str,char const * restrict __format,...);
extern int asprintf(char ** __restrict__ __str,
char const * __restrict__ __format, ...);
/* Allocating vsprintf(). */
extern int vasprintf(char ** restrict __str, char const * restrict __format,
va_list __args);
extern int vasprintf(char ** __restrict__ __str,
char const * __restrict__ __format, va_list __args);
#endif /*__STDIO_H__*/

View file

@ -96,42 +96,42 @@ extern double atof(char const *__ptr);
/* Parse a long int from a string. */
extern long int strtol(
char const * restrict __ptr,
char ** restrict __endptr,
char const * __restrict__ __ptr,
char ** __restrict__ __endptr,
int __base);
/* Parse a long unsigned int from a string. */
extern unsigned long int strtoul(
char const * restrict __ptr,
char ** restrict __endptr,
char const * __restrict__ __ptr,
char ** __restrict__ __endptr,
int __base);
/* Parse a long long int from a string. */
extern long long int strtoll(
char const * restrict __ptr,
char ** restrict __endptr,
char const * __restrict__ __ptr,
char ** __restrict__ __endptr,
int __base);
/* Parse a long long unsigned int from a string. */
extern unsigned long long int strtoull(
char const * restrict __ptr,
char ** restrict __endptr,
char const * __restrict__ __ptr,
char ** __restrict__ __endptr,
int __base);
/* Parse a double from a string. */
extern double strtod(
char const * restrict __ptr,
char ** restrict __endptr);
char const * __restrict__ __ptr,
char ** __restrict__ __endptr);
/* Parse a float from a string. */
extern float strtof(
char const * restrict __ptr,
char ** restrict __endptr);
char const * __restrict__ __ptr,
char ** __restrict__ __endptr);
/* Parse a long double from a string. */
extern long double strtold(
char const * restrict __ptr,
char ** restrict __endptr);
char const * __restrict__ __ptr,
char ** __restrict__ __endptr);
/* Pseudo-random sequence generation functions. */

View file

@ -12,20 +12,20 @@ extern void *memcpy(void *__dest, void const *__src, size_t __n);
extern void *memmove(void *__dest, void const *__src, size_t __n);
/* Copy string __src into __dest. */
extern char *strcpy(char * restrict __dest, char const * restrict __src);
extern char *strcpy(char *__restrict__ __dest, char const *__restrict__ __src);
/* Copy at most __n characters of __src into __dest. */
extern char *strncpy(char * restrict __dest, char const * restrict __src,
size_t __n);
extern char *strncpy(char * __restrict__ __dest,
char const * __restrict__ __src, size_t __n);
/* Concatenation functions. */
/* Copy __src at the end of __dest. */
extern char *strcat(char * restrict __dest, char const * restrict __src);
extern char *strcat(char *__restrict__ __dest, char const *__restrict__ __src);
/* Copy at most __n characters of __src into __dest. */
extern char *strncat(char * restrict __dest, char const * restrict __src,
size_t __n);
extern char *strncat(char * __restrict__ __dest,
char const * __restrict__ __src, size_t __n);
/* Comparison functions. */
@ -42,8 +42,8 @@ extern int strcoll(char const *__s1, char const *__s2);
extern int strncmp(char const *__s1, char const *__s2, size_t __n);
/* Transform __src into __dest in a way that morphs strcoll into strcmp. */
extern size_t strxfrm(char * restrict __dest, char const * restrict __src,
size_t __n);
extern size_t strxfrm(char * __restrict__ __dest,
char const * __restrict__ __src, size_t __n);
/* Search functions. */
@ -69,7 +69,7 @@ extern size_t strspn(char const *__s, char const *__include);
extern char *strstr(char const *__s1, char const *__s2);
/* Break __s into tokens delimited by characters from __separators. */
extern char *strtok(char * restrict __s, char const * restrict __separators);
extern char *strtok(char * __restrict__ __s, char const * __restrict__ __seps);
/* Miscellaneous functions. */

View file

@ -8,9 +8,9 @@
{len} Minimal number of characters to print
{pre} Number of digits after the decimal dot */
void __printf_format_D(
struct __printf_output * restrict out,
struct __printf_format * restrict opt,
va_list * restrict args)
struct __printf_output *out,
struct __printf_format *opt,
va_list *args)
{
int64_t n = __printf_load_i(opt->size, args);

View file

@ -198,9 +198,9 @@ static void exponent_notation(
//---
static void __printf_format_eEfFgG(
struct __printf_output * restrict out,
struct __printf_format * restrict opt,
va_list * restrict args)
struct __printf_output *out,
struct __printf_format *opt,
va_list *args)
{
double v = va_arg(*args, double);
digit_buffer[0] = '0';

View file

@ -7,9 +7,9 @@
(-) Move spaces to the right
{len} Specifies numbers of (whitespace-padded) characters to print */
void __printf_format_c(
struct __printf_output * restrict out,
struct __printf_format * restrict opt,
va_list * restrict args)
struct __printf_output *out,
struct __printf_format *opt,
va_list *args)
{
int c = va_arg(*args, int);
@ -28,9 +28,9 @@ void __printf_format_c(
{len} Minimal numbers of characters to output
{pre} Maximal numbers of bytes to read from argument */
void __printf_format_s(
struct __printf_output * restrict out,
struct __printf_format * restrict opt,
va_list * restrict args)
struct __printf_output *out,
struct __printf_format *opt,
va_list *args)
{
char const *s = va_arg(*args, char const *);
@ -58,9 +58,9 @@ void __printf_format_s(
{len} Minimal number of characters to print
{pre} Forces a minimal number of digits, creating 0s (overrides '0') */
void __printf_format_di(
struct __printf_output * restrict out,
struct __printf_format * restrict opt,
va_list * restrict args)
struct __printf_output *out,
struct __printf_format *opt,
va_list *args)
{
int64_t n = __printf_load_i(opt->size, args);
@ -101,9 +101,9 @@ void __printf_format_di(
{len} Minimal number of characters to print
{pre} Forces a minimal number of digits, creating 0s (overrides '0') */
void __printf_format_ouxX(
struct __printf_output * restrict out,
struct __printf_format * restrict opt,
va_list * restrict args)
struct __printf_output *out,
struct __printf_format *opt,
va_list *args)
{
uint64_t n = __printf_load_u(opt->size, args);
@ -144,9 +144,9 @@ void __printf_format_ouxX(
/* Pointer formatter (%p) */
void __printf_format_p(
struct __printf_output * restrict out,
struct __printf_format * restrict opt,
va_list * restrict args)
struct __printf_output *out,
struct __printf_format *opt,
va_list *args)
{
(void)opt;
void *p = va_arg(*args, void *);
@ -161,9 +161,9 @@ void __printf_format_p(
/* errno message formatter (%m) */
void __printf_format_m(
struct __printf_output * restrict out,
struct __printf_format * restrict opt,
va_list * restrict args)
struct __printf_output *out,
struct __printf_format *opt,
va_list *args)
{
(void)opt;
(void)args;
@ -174,9 +174,9 @@ void __printf_format_m(
/* Number of characters written so far (%n) */
void __printf_format_n(
struct __printf_output * restrict out,
struct __printf_format * restrict opt,
va_list * restrict args)
struct __printf_output *out,
struct __printf_format *opt,
va_list *args)
{
void *p = va_arg(*args, void *);