From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: [PATCH 2/5] xen/common: Cleanup use of __attribute__((packed)) Date: Wed, 12 Mar 2014 19:08:36 +0000 Message-ID: <1394651319-8893-3-git-send-email-andrew.cooper3@citrix.com> References: <1394651319-8893-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1394651319-8893-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: George Dunlap , Andrew Cooper , Keir Fraser , Jan Beulich List-Id: xen-devel@lists.xenproject.org And standardise on having the statement at the head of the struct/union rather than at the tail. This introduced a formal define in compiler.h, and contains some mechanical shuffling in common code. Signed-off-by: Andrew Cooper CC: Keir Fraser CC: Jan Beulich CC: George Dunlap --- xen/common/trace.c | 4 ++-- xen/common/unlzma.c | 4 ++-- xen/include/xen/compat.h | 2 +- xen/include/xen/compiler.h | 2 ++ 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/xen/common/trace.c b/xen/common/trace.c index dde662f..fa5c6ae 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; u32 did:16, vid:16; u64 first_tsc; - } __attribute__((packed)) ed; + } ed; ed.vid = current->vcpu_id; ed.did = current->domain->domain_id; 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/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