gdk/loaders/gdkjpeg.c: fix compilation on 32-bit systems

../gdk/loaders/gdkjpeg.c: In function ‘gdk_save_jpeg’:
../gdk/loaders/gdkjpeg.c:291:32: error: passing argument 3 of ‘jpeg_mem_dest’ from incompatible pointer type [-Wincompatible-pointer-types]
  291 |   jpeg_mem_dest (&info, &data, &size);
      |                                ^~~~~
      |                                |
      |                                gulong * {aka long unsigned int *}
In file included from ../gdk/loaders/gdkjpeg.c:30:
/home/thomas/br-test-pkg/bootlin-armv7-glibc/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/jpeglib.h:979:28: note: expected ‘size_t *’ {aka ‘unsigned int *’} but argument is of type ‘gulong *’ {aka ‘long unsigned int *’}

See multiple versions:

https://www.ijg.org/files/jpegsrc.v9c.tar.gz
- #define JPEG_LIB_VERSION        90	/* Compatibility version 9.0 */
- #define JPEG_LIB_VERSION_MAJOR  9
- #define JPEG_LIB_VERSION_MINOR  3
- EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
			       unsigned char ** outbuffer,
			       unsigned long * outsize));

https://www.ijg.org/files/jpegsrc.v9d.tar.gz
- #define JPEG_LIB_VERSION        90	/* Compatibility version 9.0 */
- #define JPEG_LIB_VERSION_MAJOR  9
- #define JPEG_LIB_VERSION_MINOR  4
- EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
			       unsigned char ** outbuffer,
			       size_t * outsize));

https://github.com/libjpeg-turbo/libjpeg-turbo/blob/3.0.4/jpeglib.h
https://github.com/libjpeg-turbo/libjpeg-turbo/blob/3.0.4/jconfig.h.in
- #define LIBJPEG_TURBO_VERSION  @VERSION@
- EXTERN(void) jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
                           unsigned long *outsize);

The jpegsrc changed the method signature with the v9d release,
libjpeg-turbo did not changed it's signature (yet).

Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com>
This commit is contained in:
Thomas Devoogdt
2024-09-19 13:20:08 +00:00
committed by Matthias Clasen
parent cc92230f56
commit ac2e3a17ce

View File

@@ -42,6 +42,12 @@
#define siglongjmp longjmp
#endif
#define JPEG_MEM_DEST_USES_SIZE_T \
(!(LIBJPEG_TURBO_VERSION_NUMBER) && \
(((JPEG_LIB_VERSION) > 90) || \
((JPEG_LIB_VERSION) == 90 && (JPEG_LIB_VERSION_MAJOR) > 9) || \
((JPEG_LIB_VERSION) == 90 && (JPEG_LIB_VERSION_MAJOR) == 9 && (JPEG_LIB_VERSION_MINOR) > 3)))
struct error_handler_data {
struct jpeg_error_mgr pub;
sigjmp_buf setjmp_buffer;
@@ -231,7 +237,11 @@ gdk_save_jpeg (GdkTexture *texture)
struct error_handler_data jerr;
struct jpeg_error_mgr err;
guchar *data = NULL;
#if JPEG_MEM_DEST_USES_SIZE_T
gsize size = 0;
#else
gulong size = 0;
#endif
guchar *input = NULL;
GdkTextureDownloader downloader;
GBytes *texbytes = NULL;