Library: fix builds on systems not using gcc
authorAlan Cox <alan@linux.intel.com>
Sun, 8 Apr 2018 20:30:55 +0000 (21:30 +0100)
committerAlan Cox <alan@linux.intel.com>
Sun, 8 Apr 2018 20:30:55 +0000 (21:30 +0100)
Library/include/gpt.h
Library/include/mbr.h
Library/include/sys/compiler.h [new file with mode: 0644]

index db9d11d..d8c0e76 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __GPT_DOT_H__
 #define __GPT_DOT_H__
 
+#include <sys/compiler.h>
+
 /* Copyright 2018 Tormod Volden */
 
 #define MBR_GPT_PROTECTED_TYPE 0xEE
@@ -9,7 +11,7 @@
 #define GPT_FUZIX_ROOT_UUID 63ce1ba5-46ab-49bd-abf4-2859975849e1
 #define GPT_FUZIX_ROOT_UUID_16BIT 1ba5
 
-typedef struct __attribute((packed)) {
+typedef struct __packed {
        uint8_t signature[8];
        uint32_t        revision;
        uint32_t        header_size;
@@ -32,7 +34,7 @@ typedef struct __attribute((packed)) {
        /* reserved to end of block */
 } gpt_header_t;
 
-typedef struct __attribute((packed)) {
+typedef struct __packed {
        uint8_t type_guid[16];
        uint8_t uniq_part_guid[16];
        uint32_t        first_lba_lsb;
index d2f44d5..07aaafd 100644 (file)
@@ -1,9 +1,10 @@
 #ifndef __MBR_DOT_H__
 #define __MBR_DOT_H__
 
-/* 2015-01-04 Will Sowerbutts */
+#include <sys/compiler.h>
 
-typedef struct __attribute((packed)) {
+/* 2015-01-04 Will Sowerbutts */
+typedef struct __packed {
     /* Described this way so that it packs */
     uint8_t  status_chs_first[4];
     uint8_t  type_chs_last[4];
@@ -13,7 +14,7 @@ typedef struct __attribute((packed)) {
 
 #define MBR_ENTRY_COUNT 4
 #define MBR_SIGNATURE 0xAA55
-typedef struct __attribute((packed)) {
+typedef struct __packed {
     uint8_t bootcode[446];
     partition_table_entry_t partition[MBR_ENTRY_COUNT];
     uint16_t signature;
diff --git a/Library/include/sys/compiler.h b/Library/include/sys/compiler.h
new file mode 100644 (file)
index 0000000..78d0b4b
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __SYS_COMPILER_H
+#define __SYS_COMPILER_H
+#if defined(__GCC__)
+#define __packed __attribute((packed))
+#else
+#define __packed
+#endif
+#endif
+