Skip to content

Commit

Permalink
libinstaller: PACKED compatibility for MSVC
Browse files Browse the repository at this point in the history
MSVC requires prefix and suffix attributes for packing structures.

Signed-off-by: Pete Batard <pete@akeo.ie>
  • Loading branch information
pbatard authored and geneC committed Mar 9, 2016
1 parent b22a1fd commit 843180e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion libinstaller/syslxint.h
Expand Up @@ -17,7 +17,7 @@

#include "syslinux.h"

#if defined(__386__) || defined(__i386__) || defined(__x86_64__)
#if defined(__386__) || defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
# define X86_MEM 1 /* Littleendian and unaligned safe */
#else
# define X86_MEM 0
Expand All @@ -26,10 +26,15 @@
#ifdef __GNUC__
# ifdef __MINGW32__
/* gcc 4.7 miscompiles packed structures in MS-bitfield mode */
# define PACKME
# define PACKED __attribute__((packed,gcc_struct))
# else
# define PACKME
# define PACKED __attribute__((packed))
# endif
#elif defined(_MSC_VER)
# define PACKME __pragma(pack(push, 1))
# define PACKED __pragma(pack(pop))
#else
# error "Need to define PACKED for this compiler"
#endif
Expand Down Expand Up @@ -214,12 +219,14 @@ struct ext_patch_area {
};

/* Sector extent */
PACKME
struct syslinux_extent {
uint64_t lba;
uint16_t len;
} PACKED;

/* FAT bootsector format, also used by other disk-based derivatives */
PACKME
struct fat_boot_sector {
uint8_t bsJump[3];
char bsOemName[8];
Expand All @@ -236,7 +243,9 @@ struct fat_boot_sector {
uint32_t bsHiddenSecs;
uint32_t bsHugeSectors;

PACKME
union {
PACKME
struct {
uint8_t DriveNumber;
uint8_t Reserved1;
Expand All @@ -246,6 +255,7 @@ struct fat_boot_sector {
char FileSysType[8];
uint8_t Code[442];
} PACKED bs16;
PACKME
struct {
uint32_t FATSz32;
uint16_t ExtFlags;
Expand All @@ -270,6 +280,7 @@ struct fat_boot_sector {
} PACKED;

/* NTFS bootsector format */
PACKME
struct ntfs_boot_sector {
uint8_t bsJump[3];
char bsOemName[8];
Expand Down

0 comments on commit 843180e

Please sign in to comment.