LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File libvncserver-byteswap.patch of Package LibVNCServer (Project devel:libraries:c_c++)

--- rfb/rfb.h.orig
+++ rfb/rfb.h
@@ -711,19 +711,18 @@ typedef struct _rfbClientRec {
      ((cl)->enableCursorPosUpdates && (cl)->cursorWasMoved) ||             \
      !sraRgnEmpty((cl)->copyRegion) || !sraRgnEmpty((cl)->modifiedRegion))
 
+#include <byteswap.h>
 /*
  * Macros for endian swapping.
  */
 
-#define Swap16(s) ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff))
+#define Swap16(s) bswap_16(s)
 
 #define Swap24(l) ((((l) & 0xff) << 16) | (((l) >> 16) & 0xff) | \
                    (((l) & 0x00ff00)))
 
-#define Swap32(l) (((l) >> 24) | \
-                   (((l) & 0x00ff0000) >> 8)  | \
-                   (((l) & 0x0000ff00) << 8)  | \
-                   ((l) << 24))
+#define Swap32(l) bswap_32(l)
+
 
 
 extern char rfbEndianTest;
--- rfb/rfbclient.h.orig
+++ rfb/rfbclient.h
@@ -38,25 +38,16 @@
 #include <unistd.h>
 #include <rfb/rfbproto.h>
 #include <rfb/keysym.h>
+#include <byteswap.h>
 
 #define rfbClientSwap16IfLE(s) \
-    (*(char *)&client->endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s))
+    (*(char *)&client->endianTest ? (bswap_16(s)) : (s))
 
 #define rfbClientSwap32IfLE(l) \
-    (*(char *)&client->endianTest ? ((((l) & 0xff000000) >> 24) | \
-			     (((l) & 0x00ff0000) >> 8)  | \
-			     (((l) & 0x0000ff00) << 8)  | \
-			     (((l) & 0x000000ff) << 24))  : (l))
+    (*(char *)&client->endianTest ? (bswap_32(l)) : (l))
 
 #define rfbClientSwap64IfLE(l) \
-    (*(char *)&client->endianTest ? ((((l) & 0xff00000000000000ULL) >> 56) | \
-			     (((l) & 0x00ff000000000000ULL) >> 40)  | \
-			     (((l) & 0x0000ff0000000000ULL) >> 24)  | \
-			     (((l) & 0x000000ff00000000ULL) >> 8)  | \
-			     (((l) & 0x00000000ff000000ULL) << 8)  | \
-			     (((l) & 0x0000000000ff0000ULL) << 24)  | \
-			     (((l) & 0x000000000000ff00ULL) << 40)  | \
-			     (((l) & 0x00000000000000ffULL) << 56))  : (l))
+    (*(char *)&client->endianTest ? (bswap_64(l)): (l))
 
 #define FLASH_PORT_OFFSET 5400
 #define LISTEN_PORT_OFFSET 5500