1/*
2 * Declare directives for structure packing. No padding will be provided
3 * between the members of packed structures, and therefore, there is no
4 * guarantee that structure members will be aligned.
5 *
6 * Declaring packed structures is compiler specific. In order to handle all
7 * cases, packed structures should be delared as:
8 *
9 * #include <packed_section_start.h>
10 *
11 * typedef BWL_PRE_PACKED_STRUCT struct foobar_t {
12 *    some_struct_members;
13 * } BWL_POST_PACKED_STRUCT foobar_t;
14 *
15 * #include <packed_section_end.h>
16 *
17 *
18 * Copyright (C) 2013, Broadcom Corporation. All Rights Reserved.
19 *
20 * Permission to use, copy, modify, and/or distribute this software for any
21 * purpose with or without fee is hereby granted, provided that the above
22 * copyright notice and this permission notice appear in all copies.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
25 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
27 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
28 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
29 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
30 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
31 * $Id: packed_section_start.h 397846 2013-04-21 22:11:16Z $
32 */
33
34
35/* Error check - BWL_PACKED_SECTION is defined in packed_section_start.h
36 * and undefined in packed_section_end.h. If it is already defined at this
37 * point, then there is a missing include of packed_section_end.h.
38 */
39#ifdef BWL_PACKED_SECTION
40	#error "BWL_PACKED_SECTION is already defined!"
41#else
42	#define BWL_PACKED_SECTION
43#endif
44
45
46#if defined(_MSC_VER)
47	/* Disable compiler warning about pragma pack changing alignment. */
48	#pragma warning(disable:4103)
49
50	/* The Microsoft compiler uses pragmas for structure packing. Other
51	 * compilers use structure attribute modifiers. Refer to
52	 * BWL_PRE_PACKED_STRUCT and BWL_POST_PACKED_STRUCT defined below.
53	 */
54	#if defined(BWL_DEFAULT_PACKING)
55		/* Default structure packing */
56		#pragma pack(push, 8)
57	#else   /* BWL_PACKED_SECTION */
58		#pragma pack(1)
59	#endif   /* BWL_PACKED_SECTION */
60#endif   /* _MSC_VER */
61
62#if defined(__GNUC__) && defined(EFI)
63#pragma pack(push)
64#pragma pack(1)
65#endif
66
67/* Declare compiler-specific directives for structure packing. */
68#if defined(_MSC_VER)
69	#define	BWL_PRE_PACKED_STRUCT
70	#define	BWL_POST_PACKED_STRUCT
71#elif defined(__GNUC__) || defined(__lint)
72	#define	BWL_PRE_PACKED_STRUCT
73	#define	BWL_POST_PACKED_STRUCT	__attribute__ ((packed))
74#elif defined(__CC_ARM)
75	#define	BWL_PRE_PACKED_STRUCT	__packed
76	#define	BWL_POST_PACKED_STRUCT
77#else
78	#error "Unknown compiler!"
79#endif
80