mirror of
https://github.com/oasislinux/oasis.git
synced 2026-05-12 21:34:47 +02:00
106 lines
3.8 KiB
Diff
106 lines
3.8 KiB
Diff
From 23c46e045a2a44331aafd3245d82c4fb216044b9 Mon Sep 17 00:00:00 2001
|
|
From: Michael Forney <mforney@mforney.org>
|
|
Date: Sat, 2 May 2026 20:10:48 -0700
|
|
Subject: [PATCH] Add C23 attribute support
|
|
|
|
---
|
|
pngconf.h | 25 +++++++++++++++++++++++--
|
|
pngerror.c | 8 ++++----
|
|
pngpriv.h | 6 +++---
|
|
3 files changed, 30 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/pngconf.h b/pngconf.h
|
|
index 000d7b1a8..16d290ccd 100644
|
|
--- a/pngconf.h
|
|
+++ b/pngconf.h
|
|
@@ -299,7 +299,7 @@
|
|
#ifndef PNG_EXPORTA
|
|
# define PNG_EXPORTA(ordinal, type, name, args, attributes) \
|
|
PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \
|
|
- PNG_LINKAGE_API attributes)
|
|
+ attributes PNG_LINKAGE_API)
|
|
#endif
|
|
|
|
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
|
|
@@ -339,7 +339,28 @@
|
|
* version 1.2.41. Disabling these removes the warnings but may also produce
|
|
* less efficient code.
|
|
*/
|
|
-# if defined(__clang__) && defined(__has_attribute)
|
|
+# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
|
|
+# if !defined(PNG_USE_RESULT)
|
|
+# define PNG_USE_RESULT [[nodiscard]]
|
|
+# endif
|
|
+# if !defined(PNG_NORETURN) && __has_attribute(__noreturn__)
|
|
+# define PNG_NORETURN [[noreturn]]
|
|
+# endif
|
|
+# if !defined(PNG_ALLOCATED) && defined(__has_c_attribute) && __has_c_attribute(gnu::malloc)
|
|
+# define PNG_ALLOCATED [[gnu::malloc]]
|
|
+# endif
|
|
+# if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__)
|
|
+# define PNG_DEPRECATED [[deprecated]]
|
|
+# endif
|
|
+# if !defined(PNG_PRIVATE) && defined(__has_c_attribute) && __has_c_attribute(gnu::unavailable)
|
|
+# define PNG_PRIVATE [[gnu::unavailable(\
|
|
+ "This function is not exported by libpng.")]]
|
|
+# endif
|
|
+# ifndef PNG_RESTRICT
|
|
+# define PNG_RESTRICT restrict
|
|
+# endif
|
|
+
|
|
+# elif defined(__clang__) && defined(__has_attribute)
|
|
/* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */
|
|
# if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)
|
|
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
|
|
diff --git a/pngerror.c b/pngerror.c
|
|
index 29ebda794..4bab0a63c 100644
|
|
--- a/pngerror.c
|
|
+++ b/pngerror.c
|
|
@@ -20,8 +20,8 @@
|
|
|
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
|
|
|
-static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr,
|
|
- png_const_charp error_message)),PNG_NORETURN);
|
|
+PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr,
|
|
+ png_const_charp error_message)),PNG_NORETURN static);
|
|
|
|
#ifdef PNG_WARNINGS_SUPPORTED
|
|
static void /* PRIVATE */
|
|
@@ -707,9 +707,9 @@ png_free_jmpbuf(png_structrp png_ptr)
|
|
* function is used by default, or if the program supplies NULL for the
|
|
* error function pointer in png_set_error_fn().
|
|
*/
|
|
-static PNG_FUNCTION(void /* PRIVATE */,
|
|
+PNG_FUNCTION(void /* PRIVATE */,
|
|
png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
|
- PNG_NORETURN)
|
|
+ PNG_NORETURN static)
|
|
{
|
|
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
|
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
|
diff --git a/pngpriv.h b/pngpriv.h
|
|
index 9bfdb7134..2dcf50c7b 100644
|
|
--- a/pngpriv.h
|
|
+++ b/pngpriv.h
|
|
@@ -396,13 +396,13 @@
|
|
|
|
#ifndef PNG_INTERNAL_FUNCTION
|
|
# define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\
|
|
- PNG_LINKAGE_FUNCTION PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)
|
|
+ PNG_FUNCTION(type, name, args, attributes PNG_LINKAGE_FUNCTION)
|
|
#endif
|
|
|
|
#ifndef PNG_INTERNAL_CALLBACK
|
|
# define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\
|
|
- PNG_LINKAGE_CALLBACK PNG_FUNCTION(type, (PNGCBAPI name), args,\
|
|
- PNG_EMPTY attributes)
|
|
+ PNG_FUNCTION(type, (PNGCBAPI name), args,\
|
|
+ attributes PNG_LINKAGE_CALLBACK)
|
|
#endif
|
|
|
|
/* If floating or fixed point APIs are disabled they may still be compiled
|
|
--
|
|
2.49.0
|
|
|