kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=450463521fbe6e556f7c86d6436814442cce2951

commit 450463521fbe6e556f7c86d6436814442cce2951
Author: Kim Woelders <k...@woelders.dk>
Date:   Fri Oct 11 15:28:53 2019 +0200

    Rename/add byte swap macros
---
 src/lib/common.h                  | 12 ++++++++----
 src/modules/loaders/loader_argb.c |  4 ++--
 src/modules/loaders/loader_ico.c  | 38 +++++++++++++++++++-------------------
 3 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/src/lib/common.h b/src/lib/common.h
index 7d282a4..201df30 100644
--- a/src/lib/common.h
+++ b/src/lib/common.h
@@ -27,11 +27,15 @@
      (((x) & 0xff00 ) >> 8))
 
 #ifdef WORDS_BIGENDIAN
-#define SWAP_LE_16(x) x = SWAP16(x)
-#define SWAP_LE_32(x) x = SWAP32(x)
+#define SWAP_LE_16(x) SWAP16(x)
+#define SWAP_LE_32(x) SWAP32(x)
+#define SWAP_LE_16_INPLACE(x) x = SWAP16(x)
+#define SWAP_LE_32_INPLACE(x) x = SWAP32(x)
 #else
-#define SWAP_LE_16(x)
-#define SWAP_LE_32(x)
+#define SWAP_LE_16(x) (x)
+#define SWAP_LE_32(x) (x)
+#define SWAP_LE_16_INPLACE(x)
+#define SWAP_LE_32_INPLACE(x)
 #endif
 
 #define PIXEL_ARGB(a, r, g, b)  ((a) << 24) | ((r) << 16) | ((g) << 8) | (b)
diff --git a/src/modules/loaders/loader_argb.c 
b/src/modules/loaders/loader_argb.c
index 5ba2015..2a092bc 100644
--- a/src/modules/loaders/loader_argb.c
+++ b/src/modules/loaders/loader_argb.c
@@ -64,7 +64,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
                }
 #ifdef WORDS_BIGENDIAN
              for (l = 0; l < im->w; l++)
-                SWAP_LE_32(ptr[l]);
+                SWAP_LE_32_INPLACE(ptr[l]);
 #endif
              ptr += im->w;
              if (progress)
@@ -121,7 +121,7 @@ save(ImlibImage * im, ImlibProgressFunction progress, char 
progress_granularity)
 
            memcpy(buf, ptr, im->w * 4);
            for (x = 0; x < im->w; x++)
-              SWAP_LE_32(buf[x]);
+              SWAP_LE_32_INPLACE(buf[x]);
            fwrite(buf, im->w, 4, f);
         }
 #else
diff --git a/src/modules/loaders/loader_ico.c b/src/modules/loaders/loader_ico.c
index 6a69778..c228d39 100644
--- a/src/modules/loaders/loader_ico.c
+++ b/src/modules/loaders/loader_ico.c
@@ -106,11 +106,11 @@ ico_read_idir(ico_t * ico, int ino)
    ie->w = (ie->ide.width > 0) ? ie->ide.width : 256;
    ie->h = (ie->ide.height > 0) ? ie->ide.height : 256;
 
-   SWAP_LE_16(ie->ide.planes);
-   SWAP_LE_16(ie->ide.bpp);
+   SWAP_LE_16_INPLACE(ie->ide.planes);
+   SWAP_LE_16_INPLACE(ie->ide.bpp);
 
-   SWAP_LE_32(ie->ide.size);
-   SWAP_LE_32(ie->ide.offs);
+   SWAP_LE_32_INPLACE(ie->ide.size);
+   SWAP_LE_32_INPLACE(ie->ide.offs);
 
    D("Entry %2d: Idir: WxHxD = %dx%dx%d, colors = %d\n",
      ino, ie->w, ie->h, ie->ide.bpp, ie->ide.colors);
@@ -129,19 +129,19 @@ ico_read_icon(ico_t * ico, int ino)
    if (nr != sizeof(ie->bih))
       goto bail;
 
-   SWAP_LE_32(ie->bih.header_size);
-   SWAP_LE_32(ie->bih.width);
-   SWAP_LE_32(ie->bih.height);
+   SWAP_LE_32_INPLACE(ie->bih.header_size);
+   SWAP_LE_32_INPLACE(ie->bih.width);
+   SWAP_LE_32_INPLACE(ie->bih.height);
 
-   SWAP_LE_32(ie->bih.planes);
-   SWAP_LE_32(ie->bih.bpp);
+   SWAP_LE_32_INPLACE(ie->bih.planes);
+   SWAP_LE_32_INPLACE(ie->bih.bpp);
 
-   SWAP_LE_32(ie->bih.compression);
-   SWAP_LE_32(ie->bih.size);
-   SWAP_LE_32(ie->bih.res_hor);
-   SWAP_LE_32(ie->bih.res_ver);
-   SWAP_LE_32(ie->bih.colors);
-   SWAP_LE_32(ie->bih.colors_important);
+   SWAP_LE_32_INPLACE(ie->bih.compression);
+   SWAP_LE_32_INPLACE(ie->bih.size);
+   SWAP_LE_32_INPLACE(ie->bih.res_hor);
+   SWAP_LE_32_INPLACE(ie->bih.res_ver);
+   SWAP_LE_32_INPLACE(ie->bih.colors);
+   SWAP_LE_32_INPLACE(ie->bih.colors_important);
 
    if (ie->bih.header_size != 40)
      {
@@ -175,7 +175,7 @@ ico_read_icon(ico_t * ico, int ino)
            goto bail;
 #ifdef WORDS_BIGENDIAN
         for (nr = 0; nr < ie->bih.colors; nr++)
-           SWAP_LE_32(ie->cmap[nr]);
+           SWAP_LE_32_INPLACE(ie->cmap[nr]);
 #endif
         break;
      default:
@@ -220,9 +220,9 @@ ico_read(char *filename)
    if (nr != sizeof(ico->idir))
       goto bail;
 
-   SWAP_LE_16(ico->idir.rsvd);
-   SWAP_LE_16(ico->idir.type);
-   SWAP_LE_16(ico->idir.icons);
+   SWAP_LE_16_INPLACE(ico->idir.rsvd);
+   SWAP_LE_16_INPLACE(ico->idir.type);
+   SWAP_LE_16_INPLACE(ico->idir.icons);
 
    if (ico->idir.rsvd != 0 ||
        (ico->idir.type != 1 && ico->idir.type != 2) || ico->idir.icons <= 0)

-- 


Reply via email to