From bf528f2071df7e005befa7a2d13051b30a07b772 Mon Sep 17 00:00:00 2001 From: Aleksandr Vyhovanec Date: Mon, 9 Jan 2017 14:17:49 +0300 Subject: [PATCH] packed_struct replaced by begin_packed_struct and end_packed_struct --- arch/x86/include/i486/arch.h | 18 +++++++++--------- drivers/contactless/pn532.h | 12 ++++++------ drivers/mtd/mtd_config.c | 6 +++--- include/nuttx/analog/adc.h | 6 +++--- include/nuttx/analog/dac.h | 5 +++-- include/nuttx/audio/audio.h | 5 +++-- include/nuttx/compiler.h | 19 ++++++++++++------- include/nuttx/drivers/can.h | 14 +++++++------- include/nuttx/usb/audio.h | 26 +++++++++++++------------- 9 files changed, 59 insertions(+), 52 deletions(-) diff --git a/arch/x86/include/i486/arch.h b/arch/x86/include/i486/arch.h index 1994e3fda3..44207e98d4 100644 --- a/arch/x86/include/i486/arch.h +++ b/arch/x86/include/i486/arch.h @@ -1,7 +1,7 @@ /**************************************************************************** * arch/x86/include/i486/arch.h * - * Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -317,7 +317,7 @@ /* This structure defines one segment */ -struct gdt_entry_s +begin_packed_struct struct gdt_entry_s { uint16_t lowlimit; /* The lower 16 bits of the limit */ uint16_t lowbase; /* The lower 16 bits of the base */ @@ -325,17 +325,17 @@ struct gdt_entry_s uint8_t access; /* Access flags, determine ring segment can be used in */ uint8_t granularity; uint8_t hibase; /* The last 8 bits of the base */ -} packed_struct; +} end_packed_struct; /* This structure refers to the array of GDT entries, and is in the format * required by the lgdt instruction. */ -struct gdt_ptr_s +begin_packed_struct struct gdt_ptr_s { uint16_t limit; /* The upper 16 bits of all selector limits */ uint32_t base; /* The address of the first GDT entry */ -} packed_struct; +} end_packed_struct; /* IDT data structures ****************************************************** * @@ -344,24 +344,24 @@ struct gdt_ptr_s * processor to determine the correct response to interrupts and exceptions. */ -struct idt_entry_s +begin_packed_struct struct idt_entry_s { uint16_t lobase; /* Lower 16-bits of vector address for interrupt */ uint16_t sel; /* Kernel segment selector */ uint8_t zero; /* This must always be zero */ uint8_t flags; /* (See documentation) */ uint16_t hibase; /* Upper 16-bits of vector address for interrupt */ -} packed_struct; +} end_packed_struct; /* A struct describing a pointer to an array of interrupt handlers. This is * in a format suitable for giving to 'lidt'. */ -struct idt_ptr_s +begin_packed_struct struct idt_ptr_s { uint16_t limit; uint32_t base; /* The address of the first GDT entry */ -} packed_struct; +} end_packed_struct; /**************************************************************************** * Inline functions diff --git a/drivers/contactless/pn532.h b/drivers/contactless/pn532.h index ee6980532b..87013f7dbe 100644 --- a/drivers/contactless/pn532.h +++ b/drivers/contactless/pn532.h @@ -119,7 +119,7 @@ * Public Types ****************************************************************************/ -struct pn532_frame +begin_packed_struct struct pn532_frame { uint8_t preamble; /* 0x00 */ uint16_t start_code; /* 0x00FF (BE) -> 0xFF00 (LE) */ @@ -130,22 +130,22 @@ struct pn532_frame uint8_t tfi; /* Frame idenfifier 0xD4, 0xD5 */ uint8_t data[]; /* LEN-1 bytes of Packet Data Information. * The first byte PD0 is the Command Code */ -} packed_struct; +} end_packed_struct; -struct pn_poll_response +begin_packed_struct struct pn_poll_response { uint8_t nbtg; uint8_t tg; uint8_t target_data[]; -} packed_struct; +} end_packed_struct; -struct pn_target_type_a +begin_packed_struct struct pn_target_type_a { uint16_t sens_res; uint8_t sel_res; uint8_t nfcid_len; uint8_t nfcid_data[]; -} packed_struct; +} end_packed_struct; struct pn_firmware_version { diff --git a/drivers/mtd/mtd_config.c b/drivers/mtd/mtd_config.c index 35131461c6..ca6654b0e6 100644 --- a/drivers/mtd/mtd_config.c +++ b/drivers/mtd/mtd_config.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/mtd/mtd_config.c * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved. * Copyright (C) 2013 Ken Pettit. All rights reserved. * Author: Ken Pettit * With Updates from Gregory Nutt @@ -101,13 +101,13 @@ struct mtdconfig_struct_s FAR uint8_t *buffer; /* Temp block read buffer */ }; -struct mtdconfig_header_s +begin_packed_struct struct mtdconfig_header_s { uint8_t flags; /* Entry control flags */ uint8_t instance; /* Instance of the item */ uint16_t id; /* ID of the config data item */ uint16_t len; /* Length of the data block */ -} packed_struct; +} end_packed_struct; /**************************************************************************** * Private Function Prototypes diff --git a/include/nuttx/analog/adc.h b/include/nuttx/analog/adc.h index 639eddc5cf..214143357a 100644 --- a/include/nuttx/analog/adc.h +++ b/include/nuttx/analog/adc.h @@ -1,7 +1,7 @@ /************************************************************************************ * include/nuttx/analog/adc.h * - * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2016-2017 Gregory Nutt. All rights reserved. * Copyright (C) 2011 Li Zhuoyi. All rights reserved. * Author: Li Zhuoyi * Gregory Nutt @@ -103,11 +103,11 @@ struct adc_callback_s /* This describes on ADC message */ -struct adc_msg_s +begin_packed_struct struct adc_msg_s { uint8_t am_channel; /* The 8-bit ADC Channel */ int32_t am_data; /* ADC convert result (4 bytes) */ -} packed_struct; +} end_packed_struct; /* This describes a FIFO of ADC messages */ diff --git a/include/nuttx/analog/dac.h b/include/nuttx/analog/dac.h index 4f34709a84..249100d89b 100644 --- a/include/nuttx/analog/dac.h +++ b/include/nuttx/analog/dac.h @@ -1,6 +1,7 @@ /************************************************************************************ * include/nuttx/analog/dac.h * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Copyright (C) 2011 Li Zhuoyi. All rights reserved. * Author: Li Zhuoyi * History: 0.1 2011-08-04 initial version @@ -74,11 +75,11 @@ * Public Types ************************************************************************************/ -struct dac_msg_s +begin_packed_struct struct dac_msg_s { uint8_t am_channel; /* The 8-bit DAC Channel */ int32_t am_data; /* DAC convert result (4 bytes) */ -} packed_struct; +} end_packed_struct; struct dac_fifo_s { diff --git a/include/nuttx/audio/audio.h b/include/nuttx/audio/audio.h index e955a4618b..d312a6f6d1 100644 --- a/include/nuttx/audio/audio.h +++ b/include/nuttx/audio/audio.h @@ -1,6 +1,7 @@ /**************************************************************************** * include/nuttx/audio/audio.h * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Copyright (C) 2013 Ken Pettit. All rights reserved. * Author: Ken Pettit * @@ -363,7 +364,7 @@ struct ap_buffer_info_s /* This structure describes an Audio Pipeline Buffer */ -struct ap_buffer_s +begin_packed_struct struct ap_buffer_s { struct dq_entry_s dq_entry; /* Double linked queue entry */ struct audio_info_s i; /* The info for samples in this buffer */ @@ -377,7 +378,7 @@ struct ap_buffer_s uint16_t flags; /* Buffer flags */ uint16_t crefs; /* Number of reference counts */ uint8_t samp[0]; /* Offset of the first sample */ -} packed_struct; +} end_packed_struct; /* Structure defining the messages passed to a listening audio thread * for dequeuing buffers and other operations. Also used to allocate diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h index d15bf0253e..5c5c25be29 100644 --- a/include/nuttx/compiler.h +++ b/include/nuttx/compiler.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/compiler.h * - * Copyright (C) 2007-2009, 2012-2013, 2015-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2012-2013, 2015-2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -81,7 +81,7 @@ # define weak_alias(name, aliasname) # define weak_function # define weak_const_function -#endif +# endif /* The noreturn attribute informs GCC that the function will not return. */ @@ -97,7 +97,8 @@ * ignoring other alignment rules. */ -# define packed_struct __attribute__ ((packed)) +# define begin_packed_struct +# define end_packed_struct __attribute__ ((packed)) /* GCC does not support the reentrant attribute */ @@ -279,7 +280,8 @@ /* SDCC does not support the noreturn or packed attributes */ # define noreturn_function -# define packed_struct +# define begin_packed_struct +# define end_packed_struct /* REVISIT: */ @@ -397,7 +399,8 @@ /* The Zilog compiler does not support the noreturn, packed, naked attributes */ # define noreturn_function -# define packed_struct +# define begin_packed_struct +# define end_packed_struct # define naked_function # define inline_function # define noinline_function @@ -489,7 +492,8 @@ # define weak_const_function # define noreturn_function # define farcall_function -# define packed_struct +# define begin_packed_struct __packed +# define end_packed_struct # define reentrant_function # define naked_function # define inline_function @@ -526,7 +530,8 @@ # define restrict # define noreturn_function # define farcall_function -# define packed_struct +# define begin_packed_struct +# define end_packed_struct # define reentrant_function # define naked_function # define inline_function diff --git a/include/nuttx/drivers/can.h b/include/nuttx/drivers/can.h index 725a9180f6..310822b0e0 100644 --- a/include/nuttx/drivers/can.h +++ b/include/nuttx/drivers/can.h @@ -1,7 +1,7 @@ /************************************************************************************ * include/nuttx/drivers/can.h * - * Copyright (C) 2008, 2009, 2011-2012, 2015-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2008, 2009, 2011-2012, 2015-2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -388,7 +388,7 @@ */ #ifdef CONFIG_CAN_EXTID -struct can_hdr_s +begin_packed_struct struct can_hdr_s { uint32_t ch_id; /* 11- or 29-bit ID (20- or 3-bits unused) */ uint8_t ch_dlc : 4; /* 4-bit DLC */ @@ -398,9 +398,9 @@ struct can_hdr_s #endif uint8_t ch_extid : 1; /* Extended ID indication */ uint8_t ch_unused : 1; /* Unused */ -} packed_struct; +} end_packed_struct; #else -struct can_hdr_s +begin_packed_struct struct can_hdr_s { uint16_t ch_id; /* 11-bit standard ID (5-bits unused) */ uint8_t ch_dlc : 4; /* 4-bit DLC. May be encoded in CAN_FD mode. */ @@ -409,14 +409,14 @@ struct can_hdr_s uint8_t ch_error : 1; /* 1=ch_id is an error report */ #endif uint8_t ch_unused : 2; /* Unused */ -} packed_struct; +} end_packed_struct; #endif -struct can_msg_s +begin_packed_struct struct can_msg_s { struct can_hdr_s cm_hdr; /* The CAN header */ uint8_t cm_data[CAN_MAXDATALEN]; /* CAN message data (0-8 byte) */ -} packed_struct; +} end_packed_struct; /* This structure defines a CAN message FIFO. */ diff --git a/include/nuttx/usb/audio.h b/include/nuttx/usb/audio.h index 8bec321225..ab1bb65282 100644 --- a/include/nuttx/usb/audio.h +++ b/include/nuttx/usb/audio.h @@ -2,7 +2,7 @@ * include/nuttx/usb/audio.h * Audio Device Class (ADC) definitions * - * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2013, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: This header file is based on information provided by the @@ -1321,18 +1321,18 @@ struct adc_l1_curparm_s /* Layout 1, Control RANGE Parameter Block */ -struct adc_l1_subrange_s +begin_packed_struct struct adc_l1_subrange_s { uint8_t l1_min; /* 0: MIN attribute */ uint8_t l1_max; /* 1: MAX attribute */ uint8_t l1_res; /* 2: RES attribute */ -} packed_struct; +} end_packed_struct; -struct adc_l1_rangeparm_s +begin_packed_struct struct adc_l1_rangeparm_s { uint8_t l1_nranges; /* 0: Number of sub-ranges */ struct adc_l1_subrange_s l1_subrange[1]; -} packed_struct; +} end_packed_struct; #define USB_SIZEOF_ADC_LI_RANGEPARM(nranges) (1+3*(nranges)) @@ -1422,18 +1422,18 @@ struct adc_equalizer_curparm_s /* Graphic Equalizer Control RANGE Parameter Block */ -struct adc_eq_subrange_s +begin_packed_struct struct adc_eq_subrange_s { uint8_t eq_min; /* 0: MIN attribute */ uint8_t eq_max; /* 1: MAX attribute */ uint8_t eq_res; /* 2: RES attribute */ -} packed_struct; +} end_packed_struct; -struct adc_equalizer_rangeparm_s +begin_packed_struct struct adc_equalizer_rangeparm_s { uint8_t eq_nranges; /* 0: Number of sub-ranges */ struct adc_eq_subrange_s eq_subrange[1]; -} packed_struct; +} end_packed_struct; #define USB_SIZEOF_ADC_EQUALIZER_RANGEPARM(nranges) (1+3*(nranges)) @@ -1457,18 +1457,18 @@ struct adc_hilo_curparm_s /* High/Low Scaling Control RANGE Parameter Block */ -struct adc_hl_subrange_s +begin_packed_struct struct adc_hl_subrange_s { uint8_t hl_min; /* 0: MIN attribute */ uint8_t hl_max; /* 1: MAX attribute */ uint8_t hl_res; /* 2: RES attribute */ -} packed_struct; +} end_packed_struct; -struct adc_hilo_rangeparm_s +begin_packed_struct struct adc_hilo_rangeparm_s { uint8_t hl_nranges[2]; /* 0: Number of sub-ranges */ struct adc_hl_subrange_s hl_subrange[1]; -} packed_struct; +} end_packed_struct; #define USB_SIZEOF_ADC_HILO_RANGEPARM(nranges) (2+3*(nranges))