[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 2/5] xen/common: Shuffle use of __attribute__((packed))



This introduced a formal define in compiler.h, and is otherwise manual
shuffling of __attribute__((packed)) statements to __packed at the head of the
structure.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Acked-by: Keir Fraser <keir@xxxxxxx>
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
---
 xen/common/trace.c           |    8 ++++----
 xen/common/unlzma.c          |    4 ++--
 xen/drivers/char/ehci-dbgp.c |    8 ++++----
 xen/include/xen/compat.h     |    2 +-
 xen/include/xen/compiler.h   |    2 ++
 5 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/xen/common/trace.c b/xen/common/trace.c
index 73ba57c..1814165 100644
--- a/xen/common/trace.c
+++ b/xen/common/trace.c
@@ -641,11 +641,11 @@ static inline void insert_wrap_record(struct t_buf *buf,
 
 static inline void insert_lost_records(struct t_buf *buf)
 {
-    struct {
+    struct __packed {
         u32 lost_records;
         u16 did, vid;
         u64 first_tsc;
-    } __attribute__((packed)) ed;
+    } ed;
 
     ed.vid = current->vcpu_id;
     ed.did = current->domain->domain_id;
@@ -819,10 +819,10 @@ unlock:
 void __trace_hypercall(uint32_t event, unsigned long op,
                        const unsigned long *args)
 {
-    struct {
+    struct __packed {
         uint32_t op;
         uint32_t args[6];
-    } __attribute__((packed)) d;
+    } d;
     uint32_t *a = d.args;
 
 #define APPEND_ARG32(i)                         \
diff --git a/xen/common/unlzma.c b/xen/common/unlzma.c
index 4d04330..103d2df 100644
--- a/xen/common/unlzma.c
+++ b/xen/common/unlzma.c
@@ -214,11 +214,11 @@ rc_bit_tree_decode(struct rc *rc, uint16_t *p, int 
num_levels, int *symbol)
  */
 
 
-struct lzma_header {
+struct __packed lzma_header {
        uint8_t pos;
        uint32_t dict_size;
        uint64_t dst_size;
-} __attribute__ ((packed)) ;
+};
 
 
 #define LZMA_BASE_SIZE 1846
diff --git a/xen/drivers/char/ehci-dbgp.c b/xen/drivers/char/ehci-dbgp.c
index b900d60..3feeafe 100644
--- a/xen/drivers/char/ehci-dbgp.c
+++ b/xen/drivers/char/ehci-dbgp.c
@@ -251,25 +251,25 @@ struct ehci_dbg_port {
  * For most devices, interfaces don't coordinate with each other, so
  * such requests may be made at any time.
  */
-struct usb_ctrlrequest {
+struct __packed usb_ctrlrequest {
     u8 bRequestType;
     u8 bRequest;
     __le16 wValue;
     __le16 wIndex;
     __le16 wLength;
-} __attribute__ ((packed));
+};
 
 /* USB_DT_DEBUG: for special highspeed devices, replacing serial console */
 
 #define USB_DT_DEBUG    0x0a
 
-struct usb_debug_descriptor {
+struct __packed usb_debug_descriptor {
     u8 bLength;
     u8 bDescriptorType;
     /* bulk endpoints with 8 byte maxpacket */
     u8 bDebugInEndpoint;
     u8 bDebugOutEndpoint;
-} __attribute__((packed));
+};
 
 #define USB_DEBUG_DEVNUM 127
 
diff --git a/xen/include/xen/compat.h b/xen/include/xen/compat.h
index ca60699..d58aede 100644
--- a/xen/include/xen/compat.h
+++ b/xen/include/xen/compat.h
@@ -14,7 +14,7 @@
 #define __DEFINE_COMPAT_HANDLE(name, type) \
     typedef struct { \
         compat_ptr_t c; \
-        type *_[0] __attribute__((__packed__)); \
+        type *_[0] __packed; \
     } __compat_handle_ ## name
 
 #define DEFINE_COMPAT_HANDLE(name) \
diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h
index c80398d..6e07990 100644
--- a/xen/include/xen/compiler.h
+++ b/xen/include/xen/compiler.h
@@ -16,6 +16,8 @@
 
 #define noreturn      __attribute__((noreturn))
 
+#define __packed      __attribute__((packed))
+
 #if (!defined(__clang__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 5))
 #define unreachable() do {} while (1)
 #else
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.