[Spice-devel] [PATCH spice-common] reuse {start, end}-packed headers to specify packed structure

Frediano Ziglio fziglio at redhat.com
Mon Jun 12 09:39:17 UTC 2017


Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 common/lz.c   | 21 +++++----------------
 common/quic.c | 24 +++++++-----------------
 2 files changed, 12 insertions(+), 33 deletions(-)

diff --git a/common/lz.c b/common/lz.c
index 2589223..28f450b 100644
--- a/common/lz.c
+++ b/common/lz.c
@@ -382,30 +382,23 @@ void lz_destroy(LzContext *lz)
 #endif
 
 
-#ifdef __GNUC__
-#define ATTR_PACKED __attribute__ ((__packed__))
-#else
-#define ATTR_PACKED
-#pragma pack(push)
-#pragma pack(1)
-#endif
-
+#include <spice/start-packed.h>
 
 /* the palette images will be treated as one byte pixels. Their width should be transformed
    accordingly.
 */
-typedef struct ATTR_PACKED one_byte_pixel_t {
+typedef struct SPICE_ATTR_PACKED one_byte_pixel_t {
     uint8_t a;
 } one_byte_pixel_t;
 
-typedef struct ATTR_PACKED rgb32_pixel_t {
+typedef struct SPICE_ATTR_PACKED rgb32_pixel_t {
     uint8_t b;
     uint8_t g;
     uint8_t r;
     uint8_t pad;
 } rgb32_pixel_t;
 
-typedef struct ATTR_PACKED rgb24_pixel_t {
+typedef struct SPICE_ATTR_PACKED rgb24_pixel_t {
     uint8_t b;
     uint8_t g;
     uint8_t r;
@@ -413,11 +406,7 @@ typedef struct ATTR_PACKED rgb24_pixel_t {
 
 typedef uint16_t rgb16_pixel_t;
 
-#ifndef __GNUC__
-#pragma pack(pop)
-#endif
-
-#undef ATTR_PACKED
+#include <spice/end-packed.h>
 
 
 #define MAX_COPY 32
diff --git a/common/quic.c b/common/quic.c
index 2cd1f0d..d22a9b7 100644
--- a/common/quic.c
+++ b/common/quic.c
@@ -741,39 +741,33 @@ static inline void init_decode_io(Encoder *encoder)
     encoder->io_available_bits = 0;
 }
 
-#ifdef __GNUC__
-#define ATTR_PACKED __attribute__ ((__packed__))
-#else
-#define ATTR_PACKED
-#pragma pack(push)
-#pragma pack(1)
-#endif
+#include <spice/start-packed.h>
 
-typedef struct ATTR_PACKED one_byte_pixel_t {
+typedef struct SPICE_ATTR_PACKED one_byte_pixel_t {
     BYTE a;
 } one_byte_t;
 
-typedef struct ATTR_PACKED three_bytes_pixel_t {
+typedef struct SPICE_ATTR_PACKED three_bytes_pixel_t {
     BYTE a;
     BYTE b;
     BYTE c;
 } three_bytes_t;
 
-typedef struct ATTR_PACKED four_bytes_pixel_t {
+typedef struct SPICE_ATTR_PACKED four_bytes_pixel_t {
     BYTE a;
     BYTE b;
     BYTE c;
     BYTE d;
 } four_bytes_t;
 
-typedef struct ATTR_PACKED rgb32_pixel_t {
+typedef struct SPICE_ATTR_PACKED rgb32_pixel_t {
     BYTE b;
     BYTE g;
     BYTE r;
     BYTE pad;
 } rgb32_pixel_t;
 
-typedef struct ATTR_PACKED rgb24_pixel_t {
+typedef struct SPICE_ATTR_PACKED rgb24_pixel_t {
     BYTE b;
     BYTE g;
     BYTE r;
@@ -781,11 +775,7 @@ typedef struct ATTR_PACKED rgb24_pixel_t {
 
 typedef uint16_t rgb16_pixel_t;
 
-#ifndef __GNUC__
-#pragma pack(pop)
-#endif
-
-#undef ATTR_PACKED
+#include <spice/end-packed.h>
 
 #define ONE_BYTE
 #include "quic_tmpl.c"
-- 
2.9.4



More information about the Spice-devel mailing list