From b0afb8fe0ff1d87165af9df61501197a06240dda Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 28 Dec 2025 12:13:40 +0100 Subject: Sync with Gnulib stable-202507 code (a8ac9f9ce5) --- gl/error.in.h | 71 ++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 13 deletions(-) (limited to 'gl/error.in.h') diff --git a/gl/error.in.h b/gl/error.in.h index 51f8cafd..6c512ec8 100644 --- a/gl/error.in.h +++ b/gl/error.in.h @@ -1,5 +1,5 @@ /* Declarations for error-reporting functions. - Copyright (C) 1995-1997, 2003, 2006, 2008-2024 Free Software Foundation, + Copyright (C) 1995-1997, 2003, 2006, 2008-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -23,20 +23,23 @@ or error_at_line(...) invocations. */ /* The include_next requires a split double-inclusion guard. */ -#if @HAVE_ERROR_H@ +#if @HAVE_ERROR_H@ && !defined __MINGW32__ # @INCLUDE_NEXT@ @NEXT_ERROR_H@ #endif #ifndef _@GUARD_PREFIX@_ERROR_H #define _@GUARD_PREFIX@_ERROR_H -/* This file uses _GL_ATTRIBUTE_ALWAYS_INLINE, _GL_ATTRIBUTE_FORMAT, - _GL_ATTRIBUTE_MAYBE_UNUSED. */ +/* This file uses _GL_ATTRIBUTE_ALWAYS_INLINE, _GL_ATTRIBUTE_COLD, + _GL_ATTRIBUTE_FORMAT, _GL_ATTRIBUTE_MAYBE_UNUSED. */ #if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif -/* Get 'unreachable'. */ +/* Get va_list. */ +#include + +/* Get 'gl_unreachable'. */ #include /* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM. */ @@ -54,11 +57,11 @@ It evaluates its arguments only once. Test case: Compile copy-file.c with "gcc -Wimplicit-fallthrough". */ #if defined __GNUC__ || defined __clang__ -/* Use 'unreachable' to tell the compiler when the function call does not +/* Use 'gl_unreachable' to tell the compiler when the function call does not return. */ # define __gl_error_call1(function, status, ...) \ ((function) (status, __VA_ARGS__), \ - (status) != 0 ? unreachable () : (void) 0) + (status) != 0 ? gl_unreachable () : (void) 0) /* If STATUS is a not a constant, the function call may or may not return; therefore -Wimplicit-fallthrough will produce a warning. Use a compound statement in order to evaluate STATUS only once. @@ -92,7 +95,8 @@ extern "C" { # define error rpl_error # endif _GL_FUNCDECL_RPL (error, void, - (int __status, int __errnum, const char *__format, ...) + (int __status, int __errnum, const char *__format, ...), + _GL_ATTRIBUTE_COLD _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4))); _GL_CXXALIAS_RPL (error, void, (int __status, int __errnum, const char *__format, ...)); @@ -104,7 +108,8 @@ _GL_CXXALIAS_RPL (error, void, #else # if ! @HAVE_ERROR@ _GL_FUNCDECL_SYS (error, void, - (int __status, int __errnum, const char *__format, ...) + (int __status, int __errnum, const char *__format, ...), + _GL_ATTRIBUTE_COLD _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4))); # endif _GL_CXXALIAS_SYS (error, void, @@ -117,7 +122,7 @@ _GL_CXXALIAS_SYS (error, void, # pragma GCC diagnostic ignored "-Wattributes" _GL_ATTRIBUTE_MAYBE_UNUSED static void -_GL_ATTRIBUTE_ALWAYS_INLINE +_GL_ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_COLD _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4)) _gl_inline_error (int __status, int __errnum, const char *__format, ...) { @@ -147,7 +152,8 @@ _GL_CXXALIASWARN (error); # endif _GL_FUNCDECL_RPL (error_at_line, void, (int __status, int __errnum, const char *__filename, - unsigned int __lineno, const char *__format, ...) + unsigned int __lineno, const char *__format, ...), + _GL_ATTRIBUTE_COLD _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6))); _GL_CXXALIAS_RPL (error_at_line, void, (int __status, int __errnum, const char *__filename, @@ -161,7 +167,8 @@ _GL_CXXALIAS_RPL (error_at_line, void, # if ! @HAVE_ERROR_AT_LINE@ _GL_FUNCDECL_SYS (error_at_line, void, (int __status, int __errnum, const char *__filename, - unsigned int __lineno, const char *__format, ...) + unsigned int __lineno, const char *__format, ...), + _GL_ATTRIBUTE_COLD _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6))); # endif _GL_CXXALIAS_SYS (error_at_line, void, @@ -175,7 +182,7 @@ _GL_CXXALIAS_SYS (error_at_line, void, # pragma GCC diagnostic ignored "-Wattributes" _GL_ATTRIBUTE_MAYBE_UNUSED static void -_GL_ATTRIBUTE_ALWAYS_INLINE +_GL_ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_COLD _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6)) _gl_inline_error_at_line (int __status, int __errnum, const char *__filename, unsigned int __lineno, const char *__format, ...) @@ -196,6 +203,44 @@ _gl_inline_error_at_line (int __status, int __errnum, const char *__filename, #endif _GL_CXXALIASWARN (error_at_line); +/* Print a message with 'vfprintf (stderr, FORMAT, ARGS)'; + if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). + If STATUS is nonzero, terminate the program with 'exit (STATUS)'. + Use the globals error_print_progname and error_message_count similarly + to error(). */ + +extern void verror (int __status, int __errnum, const char *__format, + va_list __args) + _GL_ATTRIBUTE_COLD + _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 0)); +#ifndef _GL_NO_INLINE_ERROR +# ifndef verror +# define verror(status, ...) \ + __gl_error_call (verror, status, __VA_ARGS__) +# define GNULIB_defined_verror 1 +# endif +#endif + +/* Print a message with 'vfprintf (stderr, FORMAT, ARGS)'; + if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). + If STATUS is nonzero, terminate the program with 'exit (STATUS)'. + If FNAME is not NULL, prepend the message with "FNAME:LINENO:". + Use the globals error_print_progname, error_message_count, and + error_one_per_line similarly to error_at_line(). */ + +extern void verror_at_line (int __status, int __errnum, const char *__fname, + unsigned int __lineno, const char *__format, + va_list __args) + _GL_ATTRIBUTE_COLD + _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 5, 0)); +#ifdef _GL_NO_INLINE_ERROR +# ifndef verror_at_line +# define verror_at_line(status, ...) \ + __gl_error_call (verror_at_line, status, __VA_ARGS__) +# define GNULIB_defined_verror_at_line 1 +# endif +#endif + /* If NULL, error will flush stdout, then print on stderr the program name, a colon and a space. Otherwise, error will call this function without parameters instead. */ -- cgit v1.2.3-74-g34f1