summaryrefslogtreecommitdiffstats
path: root/lib/stdio.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stdio.in.h')
-rw-r--r--lib/stdio.in.h93
1 files changed, 79 insertions, 14 deletions
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 433e848..4947307 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <stdio.h>.
- Copyright (C) 2004, 2007-2023 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2007-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -38,8 +38,14 @@
/* Suppress macOS deprecation warnings for sprintf and vsprintf. */
#if (defined __APPLE__ && defined __MACH__) && !defined _POSIX_C_SOURCE
-# define _POSIX_C_SOURCE 200809L
-# define _GL_DEFINED__POSIX_C_SOURCE
+# ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
+# include <AvailabilityMacros.h>
+# endif
+# if (defined MAC_OS_X_VERSION_MIN_REQUIRED \
+ && 130000 <= MAC_OS_X_VERSION_MIN_REQUIRED)
+# define _POSIX_C_SOURCE 200809L
+# define _GL_DEFINED__POSIX_C_SOURCE
+# endif
#endif
#define _GL_ALREADY_INCLUDING_STDIO_H
@@ -58,7 +64,8 @@
#define _@GUARD_PREFIX@_STDIO_H
/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT,
- GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
+ _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NOTHROW, GNULIB_POSIXCHECK,
+ HAVE_RAW_DECL_*. */
#if !_GL_CONFIG_H_INCLUDED
#error "Please include config.h first."
#endif
@@ -133,6 +140,38 @@
# endif
#endif
+/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
+ allocated memory. */
+#ifndef _GL_ATTRIBUTE_MALLOC
+# if __GNUC__ >= 3 || defined __clang__
+# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+# define _GL_ATTRIBUTE_MALLOC
+# endif
+#endif
+
+/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
+ */
+#ifndef _GL_ATTRIBUTE_NOTHROW
+# if defined __cplusplus
+# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4
+# if __cplusplus >= 201103L
+# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
+# else
+# define _GL_ATTRIBUTE_NOTHROW throw ()
+# endif
+# else
+# define _GL_ATTRIBUTE_NOTHROW
+# endif
+# else
+# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
+# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
+# else
+# define _GL_ATTRIBUTE_NOTHROW
+# endif
+# endif
+#endif
+
/* An __attribute__ __format__ specifier for a function that takes a format
string and arguments, where the format string directives are the ones
standardized by ISO C99 and POSIX.
@@ -322,7 +361,8 @@ _GL_CXXALIASWARN (fcloseall);
# endif
_GL_FUNCDECL_RPL (fdopen, FILE *,
(int fd, const char *mode)
- _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
+ _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
+ _GL_ATTRIBUTE_MALLOC);
_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
# elif defined _WIN32 && !defined __CYGWIN__
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -333,9 +373,18 @@ _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
# else
# if __GNUC__ >= 11
/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+_GL_FUNCDECL_SYS (fdopen, FILE *,
+ (int fd, const char *mode)
+ _GL_ATTRIBUTE_NOTHROW
+ _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
+ _GL_ATTRIBUTE_MALLOC);
+# else
_GL_FUNCDECL_SYS (fdopen, FILE *,
(int fd, const char *mode)
- _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
+ _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
+ _GL_ATTRIBUTE_MALLOC);
+# endif
# endif
_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
# endif
@@ -343,9 +392,18 @@ _GL_CXXALIASWARN (fdopen);
#else
# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fdopen
/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+_GL_FUNCDECL_SYS (fdopen, FILE *,
+ (int fd, const char *mode)
+ _GL_ATTRIBUTE_NOTHROW
+ _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
+ _GL_ATTRIBUTE_MALLOC);
+# else
_GL_FUNCDECL_SYS (fdopen, FILE *,
(int fd, const char *mode)
- _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
+ _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
+ _GL_ATTRIBUTE_MALLOC);
+# endif
# endif
# if defined GNULIB_POSIXCHECK
# undef fdopen
@@ -456,7 +514,8 @@ _GL_CXXALIASWARN (fileno);
# endif
_GL_FUNCDECL_RPL (fopen, FILE *,
(const char *restrict filename, const char *restrict mode)
- _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
+ _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
+ _GL_ATTRIBUTE_MALLOC);
_GL_CXXALIAS_RPL (fopen, FILE *,
(const char *restrict filename, const char *restrict mode));
# else
@@ -1111,13 +1170,15 @@ _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
# endif
_GL_FUNCDECL_RPL (popen, FILE *,
(const char *cmd, const char *mode)
- _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1));
+ _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
+ _GL_ATTRIBUTE_MALLOC);
_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
# else
# if !@HAVE_POPEN@ || __GNUC__ >= 11
_GL_FUNCDECL_SYS (popen, FILE *,
(const char *cmd, const char *mode)
- _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1));
+ _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
+ _GL_ATTRIBUTE_MALLOC);
# endif
_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
# endif
@@ -1127,7 +1188,8 @@ _GL_CXXALIASWARN (popen);
/* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */
_GL_FUNCDECL_SYS (popen, FILE *,
(const char *cmd, const char *mode)
- _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1));
+ _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
+ _GL_ATTRIBUTE_MALLOC);
# endif
# if defined GNULIB_POSIXCHECK
# undef popen
@@ -1465,13 +1527,15 @@ _GL_CXXALIASWARN (tempnam);
# define tmpfile rpl_tmpfile
# endif
_GL_FUNCDECL_RPL (tmpfile, FILE *, (void)
- _GL_ATTRIBUTE_DEALLOC (fclose, 1));
+ _GL_ATTRIBUTE_DEALLOC (fclose, 1)
+ _GL_ATTRIBUTE_MALLOC);
_GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
# else
# if __GNUC__ >= 11
/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
_GL_FUNCDECL_SYS (tmpfile, FILE *, (void)
- _GL_ATTRIBUTE_DEALLOC (fclose, 1));
+ _GL_ATTRIBUTE_DEALLOC (fclose, 1)
+ _GL_ATTRIBUTE_MALLOC);
# endif
_GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
# endif
@@ -1482,7 +1546,8 @@ _GL_CXXALIASWARN (tmpfile);
# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile
/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
_GL_FUNCDECL_SYS (tmpfile, FILE *, (void)
- _GL_ATTRIBUTE_DEALLOC (fclose, 1));
+ _GL_ATTRIBUTE_DEALLOC (fclose, 1)
+ _GL_ATTRIBUTE_MALLOC);
# endif
# if defined GNULIB_POSIXCHECK
# undef tmpfile