Commit 7e47e27b authored by Vladimir Serbinenko's avatar Vladimir Serbinenko
Browse files

Add gcc_struct to all packed structures when compiling with mingw.

	Just "packed" doesn't always pack the way we expect.
parent ae8159b9
2013-12-15 Vladimir Serbinenko <phcoder@gmail.com>
Add gcc_struct to all packed structures when compiling with mingw.
Just "packed" doesn't always pack the way we expect.
2013-12-14 Vladimir Serbinenko <phcoder@gmail.com>
 
* include/grub/i386/coreboot/lbio.h: Add missing attribute (packed).
......@@ -47,7 +47,7 @@ struct grub_ohci_hcca
grub_uint32_t donehead;
grub_uint8_t reserved[116];
} __attribute__((packed));
} GRUB_PACKED;
/* OHCI General Transfer Descriptor */
struct grub_ohci_td
......@@ -64,7 +64,7 @@ struct grub_ohci_td
* physical address in CPU endian */
grub_uint32_t tr_index; /* index of TD in transfer */
grub_uint8_t pad[8 - sizeof (volatile struct grub_ohci_td *)]; /* padding to 32 bytes */
} __attribute__((packed));
} GRUB_PACKED;
/* OHCI Endpoint Descriptor. */
struct grub_ohci_ed
......@@ -73,7 +73,7 @@ struct grub_ohci_ed
grub_uint32_t td_tail;
grub_uint32_t td_head;
grub_uint32_t next_ed;
} __attribute__((packed));
} GRUB_PACKED;
typedef volatile struct grub_ohci_td *grub_ohci_td_t;
typedef volatile struct grub_ohci_ed *grub_ohci_ed_t;
......
......@@ -55,7 +55,7 @@ struct grub_pl2303_config
grub_uint8_t stop_bits;
grub_uint8_t parity;
grub_uint8_t word_len;
} __attribute__ ((packed));
} GRUB_PACKED;
static void
real_config (struct grub_serial_port *port)
......
......@@ -105,7 +105,7 @@ struct grub_uhci_qh
/* Queue heads are aligned on 16 bytes, pad so a queue head is 16
bytes so we can store many in a 4K page. */
grub_uint8_t pad[8];
} __attribute__ ((packed));
} GRUB_PACKED;
/* UHCI Transfer Descriptor. */
struct grub_uhci_td
......@@ -129,7 +129,7 @@ struct grub_uhci_td
/* 3 additional 32 bits words reserved for the Host Controller Driver. */
grub_uint32_t data[3];
} __attribute__ ((packed));
} GRUB_PACKED;
typedef volatile struct grub_uhci_td *grub_uhci_td_t;
typedef volatile struct grub_uhci_qh *grub_uhci_qh_t;
......
......@@ -74,7 +74,7 @@ typedef struct drivemap_node
grub_uint8_t redirto;
} drivemap_node_t;
typedef struct __attribute__ ((packed)) int13map_node
typedef struct GRUB_PACKED int13map_node
{
grub_uint8_t disknum;
grub_uint8_t mapto;
......
......@@ -133,7 +133,7 @@ struct signature_v4_header
grub_uint8_t pkeyalgo;
grub_uint8_t hash;
grub_uint16_t hashed_sub;
} __attribute__ ((packed));
} GRUB_PACKED;
const char *hashes[] = {
[0x01] = "md5",
......
......@@ -88,7 +88,7 @@ struct grub_nv_super
char prodrev[NV_PRODREV_LEN]; /* 0x2C - 0x2F Array product revision */
grub_uint32_t unit_flags; /* 0x30 - 0x33 Flags for this disk */
struct grub_nv_array array; /* Array information */
} __attribute__ ((packed));
} GRUB_PACKED;
static struct grub_diskfilter_vg *
grub_dmraid_nv_detect (grub_disk_t disk,
......
......@@ -95,7 +95,7 @@ struct grub_geli_key
grub_uint8_t iv_key[64];
grub_uint8_t cipher_key[64];
grub_uint8_t hmac[64];
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_geli_phdr
{
......@@ -111,7 +111,7 @@ struct grub_geli_phdr
grub_uint32_t niter;
grub_uint8_t salt[64];
struct grub_geli_key keys[2];
} __attribute__ ((packed));
} GRUB_PACKED;
enum
{
......@@ -144,7 +144,7 @@ geli_rekey (struct grub_cryptodisk *dev, grub_uint64_t zoneno)
const struct {
char magic[4];
grub_uint64_t zone;
} __attribute__ ((packed)) tohash
} GRUB_PACKED tohash
= { {'e', 'k', 'e', 'y'}, grub_cpu_to_le64 (zoneno) };
GRUB_PROPERLY_ALIGNED_ARRAY (key, GRUB_CRYPTO_MAX_MDLEN);
......
......@@ -49,7 +49,7 @@ struct grub_ldm_vblk {
grub_uint8_t type;
grub_uint32_t unused2;
grub_uint8_t dynamic[104];
} __attribute__ ((packed));
} GRUB_PACKED;
#define LDM_VBLK_MAGIC "VBLK"
enum
......@@ -83,7 +83,7 @@ struct grub_ldm_label
grub_uint64_t pv_size;
grub_uint64_t config_start;
grub_uint64_t config_size;
} __attribute__ ((packed));
} GRUB_PACKED;
#define LDM_MAGIC "PRIVHEAD"
......
......@@ -56,7 +56,7 @@ struct grub_luks_phdr
grub_uint32_t keyMaterialOffset;
grub_uint32_t stripes;
} keyblock[8];
} __attribute__ ((packed));
} GRUB_PACKED;
typedef struct grub_luks_phdr *grub_luks_phdr_t;
......
......@@ -97,7 +97,7 @@ struct grub_raid_super_1x
*/
grub_uint16_t dev_roles[0]; /* Role in array, or 0xffff for a spare, or 0xfffe for faulty. */
};
/* Could be __attribute__ ((packed)), but since all members in this struct
/* Could be GRUB_PACKED, but since all members in this struct
are already appropriately aligned, we can omit this and avoid suboptimal
assembly in some cases. */
......
......@@ -175,7 +175,7 @@ struct grub_raid_super_09
* Active descriptor
*/
struct grub_raid_disk_09 this_disk;
} __attribute__ ((packed));
} GRUB_PACKED;
static struct grub_diskfilter_vg *
grub_mdraid_detect (grub_disk_t disk,
......
......@@ -44,7 +44,7 @@ struct grub_usbms_cbw
grub_uint8_t lun;
grub_uint8_t length;
grub_uint8_t cbwcb[16];
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_usbms_csw
{
......@@ -52,7 +52,7 @@ struct grub_usbms_csw
grub_uint32_t tag;
grub_uint32_t residue;
grub_uint8_t status;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_usbms_dev
{
......
......@@ -36,7 +36,7 @@ struct grub_affs_bblock
grub_uint8_t flags;
grub_uint32_t checksum;
grub_uint32_t rootblock;
} __attribute__ ((packed));
} GRUB_PACKED;
/* Set if the filesystem is a AFFS filesystem. Otherwise this is an
OFS filesystem. */
......@@ -51,14 +51,14 @@ struct grub_affs_rblock
grub_uint32_t unused2;
grub_uint32_t checksum;
grub_uint32_t hashtable[1];
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_affs_time
{
grub_int32_t day;
grub_uint32_t min;
grub_uint32_t hz;
} __attribute__ ((packed));
} GRUB_PACKED;
/* The second part of a file header block. */
struct grub_affs_file
......@@ -76,7 +76,7 @@ struct grub_affs_file
grub_uint32_t parent;
grub_uint32_t extension;
grub_uint32_t type;
} __attribute__ ((packed));
} GRUB_PACKED;
/* The location of `struct grub_affs_file' relative to the end of a
file header block. */
......
......@@ -73,7 +73,7 @@ struct grub_bfs_extent
grub_uint32_t ag;
grub_uint16_t start;
grub_uint16_t len;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_bfs_superblock
{
......@@ -89,7 +89,7 @@ struct grub_bfs_superblock
grub_uint8_t unused3[32];
grub_uint32_t magic3;
struct grub_bfs_extent root_dir;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_bfs_inode
{
......@@ -118,11 +118,11 @@ struct grub_bfs_inode
grub_uint64_t max_double_indirect_range;
grub_uint64_t size;
grub_uint32_t pad[4];
} __attribute__ ((packed));
} GRUB_PACKED;
char inplace_link[144];
} __attribute__ ((packed));
} GRUB_PACKED;
grub_uint8_t small_data[0];
} __attribute__ ((packed));
} GRUB_PACKED;
enum
{
......@@ -134,7 +134,7 @@ struct grub_bfs_small_data_element_header
grub_uint32_t type;
grub_uint16_t name_len;
grub_uint16_t value_len;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_bfs_btree_header
{
......@@ -151,7 +151,7 @@ struct grub_bfs_btree_header
grub_uint64_t root;
#endif
grub_uint32_t unused2[2];
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_bfs_btree_node
{
......@@ -165,7 +165,7 @@ struct grub_bfs_btree_node
grub_uint16_t count_keys;
grub_uint16_t total_key_len;
#endif
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_bfs_data
{
......
......@@ -53,7 +53,7 @@ struct grub_btrfs_device
grub_uint64_t device_id;
grub_uint64_t size;
grub_uint8_t dummy[0x62 - 0x10];
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_btrfs_superblock
{
......@@ -71,7 +71,7 @@ struct grub_btrfs_superblock
char label[0x100];
grub_uint8_t dummy4[0x100];
grub_uint8_t bootstrap_mapping[0x800];
} __attribute__ ((packed));
} GRUB_PACKED;
struct btrfs_header
{
......@@ -80,7 +80,7 @@ struct btrfs_header
grub_uint8_t dummy[0x30];
grub_uint32_t nitems;
grub_uint8_t level;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_btrfs_device_desc
{
......@@ -122,28 +122,28 @@ struct grub_btrfs_chunk_item
grub_uint8_t dummy2[0xc];
grub_uint16_t nstripes;
grub_uint16_t nsubstripes;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_btrfs_chunk_stripe
{
grub_uint64_t device_id;
grub_uint64_t offset;
grub_btrfs_uuid_t device_uuid;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_btrfs_leaf_node
{
struct grub_btrfs_key key;
grub_uint32_t offset;
grub_uint32_t size;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_btrfs_internal_node
{
struct grub_btrfs_key key;
grub_uint64_t addr;
grub_uint64_t dummy;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_btrfs_dir_item
{
......@@ -156,7 +156,7 @@ struct grub_btrfs_dir_item
#define GRUB_BTRFS_DIR_ITEM_TYPE_SYMLINK 7
grub_uint8_t type;
char name[0];
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_btrfs_leaf_descriptor
{
......@@ -183,7 +183,7 @@ struct grub_btrfs_inode
grub_uint64_t size;
grub_uint8_t dummy2[0x70];
struct grub_btrfs_time mtime;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_btrfs_extent_data
{
......@@ -204,7 +204,7 @@ struct grub_btrfs_extent_data
grub_uint64_t filled;
};
};
} __attribute__ ((packed));
} GRUB_PACKED;
#define GRUB_BTRFS_EXTENT_INLINE 0
#define GRUB_BTRFS_EXTENT_REGULAR 1
......
......@@ -35,7 +35,7 @@ struct head
grub_uint16_t mtime[2];
grub_uint16_t namesize[1];
grub_uint16_t filesize[2];
} __attribute__ ((packed));
} GRUB_PACKED;
static inline unsigned long long
read_number (const grub_uint16_t *arr, grub_size_t size)
......
......@@ -35,7 +35,7 @@ struct head
grub_uint16_t mtime[2];
grub_uint16_t namesize[1];
grub_uint16_t filesize[2];
} __attribute__ ((packed));
} GRUB_PACKED;
static inline unsigned long long
read_number (const grub_uint16_t *arr, grub_size_t size)
......
......@@ -92,7 +92,7 @@ struct grub_fat_dir_entry
grub_uint8_t m_time_tenth;
grub_uint8_t a_time_tenth;
grub_uint8_t reserved2[9];
} __attribute__ ((packed)) file;
} GRUB_PACKED file;
struct {
grub_uint8_t flags;
grub_uint8_t reserved1;
......@@ -103,17 +103,17 @@ struct grub_fat_dir_entry
grub_uint32_t reserved3;
grub_uint32_t first_cluster;
grub_uint64_t file_size;
} __attribute__ ((packed)) stream_extension;
} GRUB_PACKED stream_extension;
struct {
grub_uint8_t flags;
grub_uint16_t str[15];
} __attribute__ ((packed)) file_name;
} GRUB_PACKED file_name;
struct {
grub_uint8_t character_count;
grub_uint16_t str[15];
} __attribute__ ((packed)) volume_label;
} __attribute__ ((packed)) type_specific;
} __attribute__ ((packed));
} GRUB_PACKED volume_label;
} GRUB_PACKED type_specific;
} GRUB_PACKED;
struct grub_fat_dir_node
{
......@@ -142,7 +142,7 @@ struct grub_fat_dir_entry
grub_uint16_t w_date;
grub_uint16_t first_cluster_low;
grub_uint32_t file_size;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_fat_long_name_entry
{
......@@ -154,7 +154,7 @@ struct grub_fat_long_name_entry
grub_uint16_t name2[6];
grub_uint16_t first_cluster;
grub_uint16_t name3[2];
} __attribute__ ((packed));
} GRUB_PACKED;
typedef struct grub_fat_dir_entry grub_fat_dir_node_t;
......
......@@ -65,7 +65,7 @@ struct grub_hfs_node
grub_uint8_t level;
grub_uint16_t reccnt;
grub_uint16_t unused;
} __attribute__ ((packed));
} GRUB_PACKED;
/* The head of the B*-Tree. */
struct grub_hfs_treeheader
......@@ -81,7 +81,7 @@ struct grub_hfs_treeheader
grub_uint32_t nodes;
grub_uint32_t free_nodes;
grub_uint8_t unused[76];
} __attribute__ ((packed));
} GRUB_PACKED;
/* The state of a mounted HFS filesystem. */
struct grub_hfs_data
......@@ -112,7 +112,7 @@ struct grub_hfs_catalog_key
/* Filename. */
grub_uint8_t str[31];
} __attribute__ ((packed));
} GRUB_PACKED;
/* The key as used on disk in a extent overflow tree. Using this key
the extents can be looked up using a fileid and logical start block
......@@ -125,7 +125,7 @@ struct grub_hfs_extent_key
grub_uint8_t forktype;
grub_uint32_t fileid;
grub_uint16_t first_block;
} __attribute__ ((packed));
} GRUB_PACKED;
/* A directory record. This is used to find out the directory ID. */
struct grub_hfs_dirrec
......@@ -136,7 +136,7 @@ struct grub_hfs_dirrec
grub_uint32_t dirid;
grub_uint32_t ctime;
grub_uint32_t mtime;
} __attribute__ ((packed));
} GRUB_PACKED;
/* Information about a file. */
struct grub_hfs_filerec
......@@ -154,7 +154,7 @@ struct grub_hfs_filerec
/* The first 3 extents of the file. The other extents can be found
in the extent overflow file. */
grub_hfs_datarecord_t extents;
} __attribute__ ((packed));
} GRUB_PACKED;
/* A record descriptor, both key and data, used to pass to call back
functions. */
......@@ -712,7 +712,7 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
{
grub_uint8_t keylen;
grub_uint8_t key;
} __attribute__ ((packed)) *pnt;
} GRUB_PACKED *pnt;
pnt = (struct pointer *) (grub_be_to_cpu16 (node->offsets[pos])
+ node->rawnode);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment