On Thu, 22 Sep 2022 12:28:56 +1000 Jonathan Gray <j...@jsg.id.au> wrote:
> On Wed, Sep 21, 2022 at 10:13:44PM -0400, George Koehler wrote: > This uses the compiler builtin __BYTE_ORDER__ instead of endian.h > BYTE_ORDER. > > Both could be avoided by using htole32() instead. Then the two > ifdefs could be removed as well. My 1st patch used swap32; this 2nd patch uses le32toh and works equally well. ok for either swap32 or le32toh? Index: Makefile =================================================================== RCS file: /cvs/ports/graphics/webp-pixbuf-loader/Makefile,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 Makefile --- Makefile 12 Aug 2022 11:42:55 -0000 1.1.1.1 +++ Makefile 22 Sep 2022 03:12:56 -0000 @@ -3,6 +3,7 @@ COMMENT= WebP GDK Pixbuf Loader library GH_ACCOUNT= aruiz GH_PROJECT= webp-pixbuf-loader GH_TAGNAME= 0.0.6 +REVISION= 0 CATEGORIES= graphics Index: patches/patch-io-webp_c =================================================================== RCS file: patches/patch-io-webp_c diff -N patches/patch-io-webp_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-io-webp_c 22 Sep 2022 03:12:56 -0000 @@ -0,0 +1,27 @@ +Use <endian.h> on BE_ARCHS; OpenBSD doesn't have <byteswap.h>. + +Index: io-webp.c +--- io-webp.c.orig ++++ io-webp.c +@@ -12,9 +12,7 @@ + + #include "io-webp.h" + +-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +-#include <byteswap.h> +-#endif ++#include <endian.h> + + #define IMAGE_READ_BUFFER_SIZE 65535 + +@@ -278,9 +276,7 @@ gdk_pixbuf__webp_anim_load_increment (gpointer co + /* The next 4 bytes give the size of the webp container less the 8 byte header. */ + uint32_t anim_size = *(uint32_t *) (buf + 4); /* gives file size not counting the first 8 bytes. */ + +- #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +- anim_size = bswap_32(anim_size); +- #endif ++ anim_size = le32toh(anim_size); + + uint32_t file_size = anim_size + 8; + if (file_size < size) {