Resync with broadcom drivers 5.100.138.20 and utilities.
[tomato.git] / release / src-rt / include / packed_section_start.h
blob2e0c72183fa8719bd56320d1de104eb4a5c39e31
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.
6 * Declaring packed structures is compiler specific. In order to handle all
7 * cases, packed structures should be delared as:
9 * #include <packed_section_start.h>
11 * typedef BWL_PRE_PACKED_STRUCT struct foobar_t {
12 * some_struct_members;
13 * } BWL_POST_PACKED_STRUCT foobar_t;
15 * #include <packed_section_end.h>
18 * Copyright (C) 2010, Broadcom Corporation. All Rights Reserved.
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.
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,v 1.4 2008-12-09 23:43:22 Exp $
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.
39 #ifdef BWL_PACKED_SECTION
40 #error "BWL_PACKED_SECTION is already defined!"
41 #else
42 #define BWL_PACKED_SECTION
43 #endif
46 #if defined(_MSC_VER)
47 /* Disable compiler warning about pragma pack changing alignment. */
48 #pragma warning(disable:4103)
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.
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 */
63 /* Declare compiler-specific directives for structure packing. */
64 #if defined(_MSC_VER)
65 #define BWL_PRE_PACKED_STRUCT
66 #define BWL_POST_PACKED_STRUCT
67 #elif defined(__GNUC__)
68 #define BWL_PRE_PACKED_STRUCT
69 #define BWL_POST_PACKED_STRUCT __attribute__((packed))
70 #elif defined(__CC_ARM)
71 #define BWL_PRE_PACKED_STRUCT __packed
72 #define BWL_POST_PACKED_STRUCT
73 #else
74 #error "Unknown compiler!"
75 #endif