commit 7fb4f44

Michael Forney  ·  2026-05-03 03:12:56 +0000 UTC
parent f3316c2
libpng: Use C23 attributes when available
3 files changed,  +107, -1
+1, -0
1@@ -203,6 +203,7 @@
2 [submodule "pkg/libpng/src"]
3 	path = pkg/libpng/src
4 	url = https://github.com/glennrp/libpng
5+	ignore = all
6 [submodule "pkg/mupdf/src"]
7 	path = pkg/mupdf/src
8 	url = https://github.com/oasislinux/mupdf.git
+105, -0
  1@@ -0,0 +1,105 @@
  2+From 23c46e045a2a44331aafd3245d82c4fb216044b9 Mon Sep 17 00:00:00 2001
  3+From: Michael Forney <mforney@mforney.org>
  4+Date: Sat, 2 May 2026 20:10:48 -0700
  5+Subject: [PATCH] Add C23 attribute support
  6+
  7+---
  8+ pngconf.h  | 25 +++++++++++++++++++++++--
  9+ pngerror.c |  8 ++++----
 10+ pngpriv.h  |  6 +++---
 11+ 3 files changed, 30 insertions(+), 9 deletions(-)
 12+
 13+diff --git a/pngconf.h b/pngconf.h
 14+index 000d7b1a8..16d290ccd 100644
 15+--- a/pngconf.h
 16++++ b/pngconf.h
 17+@@ -299,7 +299,7 @@
 18+ #ifndef PNG_EXPORTA
 19+ #  define PNG_EXPORTA(ordinal, type, name, args, attributes) \
 20+       PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \
 21+-      PNG_LINKAGE_API attributes)
 22++      attributes PNG_LINKAGE_API)
 23+ #endif
 24+ 
 25+ /* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
 26+@@ -339,7 +339,28 @@
 27+    * version 1.2.41.  Disabling these removes the warnings but may also produce
 28+    * less efficient code.
 29+    */
 30+-#  if defined(__clang__) && defined(__has_attribute)
 31++#  if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 32++#    if !defined(PNG_USE_RESULT)
 33++#      define PNG_USE_RESULT [[nodiscard]]
 34++#    endif
 35++#    if !defined(PNG_NORETURN) && __has_attribute(__noreturn__)
 36++#      define PNG_NORETURN [[noreturn]]
 37++#    endif
 38++#    if !defined(PNG_ALLOCATED) && defined(__has_c_attribute) && __has_c_attribute(gnu::malloc)
 39++#      define PNG_ALLOCATED [[gnu::malloc]]
 40++#    endif
 41++#    if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__)
 42++#      define PNG_DEPRECATED [[deprecated]]
 43++#    endif
 44++#    if !defined(PNG_PRIVATE) && defined(__has_c_attribute) && __has_c_attribute(gnu::unavailable)
 45++#      define PNG_PRIVATE [[gnu::unavailable(\
 46++             "This function is not exported by libpng.")]]
 47++#    endif
 48++#    ifndef PNG_RESTRICT
 49++#      define PNG_RESTRICT restrict
 50++#    endif
 51++
 52++#  elif defined(__clang__) && defined(__has_attribute)
 53+    /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */
 54+ #    if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)
 55+ #      define PNG_USE_RESULT __attribute__((__warn_unused_result__))
 56+diff --git a/pngerror.c b/pngerror.c
 57+index 29ebda794..4bab0a63c 100644
 58+--- a/pngerror.c
 59++++ b/pngerror.c
 60+@@ -20,8 +20,8 @@
 61+ 
 62+ #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
 63+ 
 64+-static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr,
 65+-    png_const_charp error_message)),PNG_NORETURN);
 66++PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr,
 67++    png_const_charp error_message)),PNG_NORETURN static);
 68+ 
 69+ #ifdef PNG_WARNINGS_SUPPORTED
 70+ static void /* PRIVATE */
 71+@@ -707,9 +707,9 @@ png_free_jmpbuf(png_structrp png_ptr)
 72+  * function is used by default, or if the program supplies NULL for the
 73+  * error function pointer in png_set_error_fn().
 74+  */
 75+-static PNG_FUNCTION(void /* PRIVATE */,
 76++PNG_FUNCTION(void /* PRIVATE */,
 77+ png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
 78+-    PNG_NORETURN)
 79++    PNG_NORETURN static)
 80+ {
 81+ #ifdef PNG_CONSOLE_IO_SUPPORTED
 82+ #ifdef PNG_ERROR_NUMBERS_SUPPORTED
 83+diff --git a/pngpriv.h b/pngpriv.h
 84+index 9bfdb7134..2dcf50c7b 100644
 85+--- a/pngpriv.h
 86++++ b/pngpriv.h
 87+@@ -396,13 +396,13 @@
 88+ 
 89+ #ifndef PNG_INTERNAL_FUNCTION
 90+ #  define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\
 91+-      PNG_LINKAGE_FUNCTION PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)
 92++      PNG_FUNCTION(type, name, args, attributes PNG_LINKAGE_FUNCTION)
 93+ #endif
 94+ 
 95+ #ifndef PNG_INTERNAL_CALLBACK
 96+ #  define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\
 97+-      PNG_LINKAGE_CALLBACK PNG_FUNCTION(type, (PNGCBAPI name), args,\
 98+-         PNG_EMPTY attributes)
 99++      PNG_FUNCTION(type, (PNGCBAPI name), args,\
100++         attributes PNG_LINKAGE_CALLBACK)
101+ #endif
102+ 
103+ /* If floating or fixed point APIs are disabled they may still be compiled
104+-- 
105+2.49.0
106+
+1, -1
1@@ -1 +1 @@
2-1.6.43 r0
3+1.6.43 r1