From 6a00113de8b9060a7227bcfa79b3786e3e592a33 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Thu, 13 Jul 2017 02:20:27 +0200 Subject: Rename __attribute__((packed)) --> __packed Also unify __attribute__ ((..)) to __attribute__((..)) and handle ((__packed__)) like ((packed)) Change-Id: Ie60a51c3fa92b5009724a5b7c2932e361bf3490c Signed-off-by: Stefan Reinauer Reviewed-on: https://review.coreboot.org/15921 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- payloads/libpayload/include/arm/arch/exception.h | 2 +- payloads/libpayload/include/arm64/arch/exception.h | 2 +- payloads/libpayload/include/cbfs_core.h | 17 ++++++------- payloads/libpayload/include/compiler.h | 28 ++++++++++++++++++++++ payloads/libpayload/include/fmap_serialized.h | 4 ++-- payloads/libpayload/include/libpayload.h | 3 ++- payloads/libpayload/include/mips/arch/exception.h | 2 +- payloads/libpayload/include/stdio.h | 8 +++---- payloads/libpayload/include/stdlib.h | 4 ++-- payloads/libpayload/include/usb/usb.h | 22 ++++++++--------- payloads/libpayload/include/x86/arch/exception.h | 2 +- 11 files changed, 62 insertions(+), 32 deletions(-) create mode 100644 payloads/libpayload/include/compiler.h (limited to 'payloads/libpayload/include') diff --git a/payloads/libpayload/include/arm/arch/exception.h b/payloads/libpayload/include/arm/arch/exception.h index fbbce5ed3d..9a631e4614 100644 --- a/payloads/libpayload/include/arm/arch/exception.h +++ b/payloads/libpayload/include/arm/arch/exception.h @@ -39,7 +39,7 @@ struct exception_state { u32 regs[16]; u32 cpsr; -} __attribute__((packed)); +} __packed; extern struct exception_state exception_state; extern u32 exception_stack[]; diff --git a/payloads/libpayload/include/arm64/arch/exception.h b/payloads/libpayload/include/arm64/arch/exception.h index f5026f8402..8afe39103b 100644 --- a/payloads/libpayload/include/arm64/arch/exception.h +++ b/payloads/libpayload/include/arm64/arch/exception.h @@ -39,7 +39,7 @@ struct exception_state uint64_t elr; uint64_t esr; uint64_t regs[31]; -} __attribute__((packed)); +} __packed; extern struct exception_state *exception_state; diff --git a/payloads/libpayload/include/cbfs_core.h b/payloads/libpayload/include/cbfs_core.h index f45139e9aa..1f155df0ca 100644 --- a/payloads/libpayload/include/cbfs_core.h +++ b/payloads/libpayload/include/cbfs_core.h @@ -50,6 +50,7 @@ #include #include #include +#include /** These are standard values for the known compression alogrithms that coreboot knows about for stages and @@ -97,7 +98,7 @@ struct cbfs_header { uint32_t offset; uint32_t architecture; uint32_t pad[1]; -} __attribute__((packed)); +} __packed; /* this used to be flexible, but wasn't ever set to something different. */ #define CBFS_ALIGNMENT 64 @@ -134,7 +135,7 @@ struct cbfs_file { uint32_t attributes_offset; uint32_t offset; char filename[]; -} __attribute__((packed)); +} __packed; /* Depending on how the header was initialized, it may be backed with 0x00 or * 0xff. Support both. */ @@ -151,7 +152,7 @@ struct cbfs_file_attribute { /* len covers the whole structure, incl. tag and len */ uint32_t len; uint8_t data[0]; -} __attribute__((packed)); +} __packed; struct cbfs_file_attr_compression { uint32_t tag; @@ -159,7 +160,7 @@ struct cbfs_file_attr_compression { /* whole file compression format. 0 if no compression. */ uint32_t compression; uint32_t decompressed_size; -} __attribute__((packed)); +} __packed; struct cbfs_file_attr_hash { uint32_t tag; @@ -167,7 +168,7 @@ struct cbfs_file_attr_hash { uint32_t hash_type; /* hash_data is len - sizeof(struct) bytes */ uint8_t hash_data[]; -} __PACKED; +} __packed; /*** Component sub-headers ***/ @@ -183,7 +184,7 @@ struct cbfs_stage { uint64_t load; /** Where to load in memory */ uint32_t len; /** length of data to load */ uint32_t memlen; /** total length of object in memory */ -} __attribute__((packed)); +} __packed; /** this is the sub-header for payload components. Payloads are loaded by coreboot at the end of the boot process */ @@ -195,7 +196,7 @@ struct cbfs_payload_segment { uint64_t load_addr; uint32_t len; uint32_t mem_len; -} __attribute__((packed)); +} __packed; struct cbfs_payload { struct cbfs_payload_segment segments; @@ -210,7 +211,7 @@ struct cbfs_payload { struct cbfs_optionrom { uint32_t compression; uint32_t len; -} __attribute__((packed)); +} __packed; #define CBFS_MEDIA_INVALID_MAP_ADDRESS ((void*)(0xffffffff)) #define CBFS_DEFAULT_MEDIA ((void*)(0x0)) diff --git a/payloads/libpayload/include/compiler.h b/payloads/libpayload/include/compiler.h new file mode 100644 index 0000000000..f218725086 --- /dev/null +++ b/payloads/libpayload/include/compiler.h @@ -0,0 +1,28 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2017 Google Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __COMPILER_H__ +#define __COMPILER_H__ + +#if defined(__WIN32) || defined(__WIN64) +#define __packed __attribute__((gcc_struct, packed)) +#else +#define __packed __attribute__((packed)) +#endif + +#define __aligned(x) __attribute__((aligned(x))) +#define __always_unused __attribute__((unused)) + +#endif diff --git a/payloads/libpayload/include/fmap_serialized.h b/payloads/libpayload/include/fmap_serialized.h index 3585f0bc84..1e83760442 100644 --- a/payloads/libpayload/include/fmap_serialized.h +++ b/payloads/libpayload/include/fmap_serialized.h @@ -56,7 +56,7 @@ struct fmap_area { uint32_t size; /* size in bytes */ uint8_t name[FMAP_STRLEN]; /* descriptive name */ uint16_t flags; /* flags for this area */ -} __attribute__((packed)); +} __packed; struct fmap { uint8_t signature[8]; /* "__FMAP__" (0x5F5F464D41505F5F) */ @@ -68,6 +68,6 @@ struct fmap { uint16_t nareas; /* number of areas described by fmap_areas[] below */ struct fmap_area areas[]; -} __attribute__((packed)); +} __packed; #endif /* FLASHMAP_SERIALIZED_H__ */ diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h index 54e01623a1..83658d15b4 100644 --- a/payloads/libpayload/include/libpayload.h +++ b/payloads/libpayload/include/libpayload.h @@ -44,6 +44,7 @@ #define _LIBPAYLOAD_H #include +#include #include #include #include @@ -361,7 +362,7 @@ long long int llabs(long long int j); u8 bin2hex(u8 b); u8 hex2bin(u8 h); void hexdump(const void *memory, size_t length); -void fatal(const char *msg) __attribute__ ((noreturn)); +void fatal(const char *msg) __attribute__((noreturn)); /* Count Leading Zeroes: clz(0) == 32, clz(0xf) == 28, clz(1 << 31) == 0 */ static inline int clz(u32 x) { return x ? __builtin_clz(x) : sizeof(x) * 8; } diff --git a/payloads/libpayload/include/mips/arch/exception.h b/payloads/libpayload/include/mips/arch/exception.h index 6af5f8e793..27f0b6417b 100644 --- a/payloads/libpayload/include/mips/arch/exception.h +++ b/payloads/libpayload/include/mips/arch/exception.h @@ -70,7 +70,7 @@ struct exception_state_t { u32 ra; } regs; u32 vector; -} __attribute__((packed)); +} __packed; extern struct exception_state_t *exception_state_ptr; extern u32 *exception_stack_end; diff --git a/payloads/libpayload/include/stdio.h b/payloads/libpayload/include/stdio.h index d2db640118..431042c1ee 100644 --- a/payloads/libpayload/include/stdio.h +++ b/payloads/libpayload/include/stdio.h @@ -43,13 +43,13 @@ extern FILE *stdout, *stdin, *stderr; * @{ */ int snprintf(char *str, size_t size, const char *fmt, ...) - __attribute__ ((format (printf, 3, 4))); + __attribute__((format (printf, 3, 4))); int sprintf(char *str, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); + __attribute__((format (printf, 2, 3))); int printf(const char *fmt, ...) - __attribute__ ((format (printf, 1, 2))); + __attribute__((format (printf, 1, 2))); int fprintf(FILE *file, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); + __attribute__((format (printf, 2, 3))); /** @} */ void perror(const char *s); diff --git a/payloads/libpayload/include/stdlib.h b/payloads/libpayload/include/stdlib.h index 689bf01b68..658fe610d0 100644 --- a/payloads/libpayload/include/stdlib.h +++ b/payloads/libpayload/include/stdlib.h @@ -214,8 +214,8 @@ void srand(unsigned int seed); /** * Stop execution and halt the processor (this function does not return). */ -void halt(void) __attribute__ ((noreturn)); -void exit(int status) __attribute__ ((noreturn)); +void halt(void) __attribute__((noreturn)); +void exit(int status) __attribute__((noreturn)); #define abort() halt() /**< Alias for the halt() function */ #if IS_ENABLED(CONFIG_LP_REMOTEGDB) /* Override abort()/halt() to trap into GDB if it is enabled. */ diff --git a/payloads/libpayload/include/usb/usb.h b/payloads/libpayload/include/usb/usb.h index e93a11e616..ef1892661c 100644 --- a/payloads/libpayload/include/usb/usb.h +++ b/payloads/libpayload/include/usb/usb.h @@ -83,13 +83,13 @@ typedef struct { unsigned long ttThinkTime:2; unsigned long arePortIndicatorsSupported:1; unsigned long:8; - } __attribute__ ((packed)); + } __packed; unsigned short wHubCharacteristics; - } __attribute__ ((packed)); + } __packed; unsigned char bPowerOn2PwrGood; unsigned char bHubContrCurrent; char DeviceRemovable[]; -} __attribute__ ((packed)) hub_descriptor_t; +} __packed hub_descriptor_t; typedef struct { unsigned char bLength; @@ -106,7 +106,7 @@ typedef struct { unsigned char iProduct; unsigned char iSerialNumber; unsigned char bNumConfigurations; -} __attribute__ ((packed)) device_descriptor_t; +} __packed device_descriptor_t; typedef struct { unsigned char bLength; @@ -117,7 +117,7 @@ typedef struct { unsigned char iConfiguration; unsigned char bmAttributes; unsigned char bMaxPower; -} __attribute__ ((packed)) configuration_descriptor_t; +} __packed configuration_descriptor_t; typedef struct { unsigned char bLength; @@ -129,7 +129,7 @@ typedef struct { unsigned char bInterfaceSubClass; unsigned char bInterfaceProtocol; unsigned char iInterface; -} __attribute__ ((packed)) interface_descriptor_t; +} __packed interface_descriptor_t; typedef struct { unsigned char bLength; @@ -138,7 +138,7 @@ typedef struct { unsigned char bmAttributes; unsigned short wMaxPacketSize; unsigned char bInterval; -} __attribute__ ((packed)) endpoint_descriptor_t; +} __packed endpoint_descriptor_t; typedef struct { unsigned char bLength; @@ -148,7 +148,7 @@ typedef struct { unsigned char bNumDescriptors; unsigned char bReportDescriptorType; unsigned short wReportDescriptorLength; -} __attribute__ ((packed)) hid_descriptor_t; +} __packed hid_descriptor_t; typedef struct { union { @@ -156,14 +156,14 @@ typedef struct { dev_req_recp req_recp:5; dev_req_type req_type:2; dev_req_dir data_dir:1; - } __attribute__ ((packed)); + } __packed; unsigned char bmRequestType; - } __attribute__ ((packed)); + } __packed; unsigned char bRequest; unsigned short wValue; unsigned short wIndex; unsigned short wLength; -} __attribute__ ((packed)) dev_req_t; +} __packed dev_req_t; struct usbdev_hc; typedef struct usbdev_hc hci_t; diff --git a/payloads/libpayload/include/x86/arch/exception.h b/payloads/libpayload/include/x86/arch/exception.h index fe222aa4f2..8acdb09552 100644 --- a/payloads/libpayload/include/x86/arch/exception.h +++ b/payloads/libpayload/include/x86/arch/exception.h @@ -58,7 +58,7 @@ struct exception_state } regs; u32 error_code; u32 vector; -} __attribute__((packed)); +} __packed; extern struct exception_state *exception_state; extern u32 exception_stack[]; -- cgit v1.2.3