• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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) 1999-2011, Broadcom Corporation
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  *
32  * $Id: packed_section_start.h,v 1.4.124.1 2010-09-17 00:47:03 Exp $
33  */
34 
35 
36 
37 
38 #ifdef BWL_PACKED_SECTION
39 	#error "BWL_PACKED_SECTION is already defined!"
40 #else
41 	#define BWL_PACKED_SECTION
42 #endif
43 
44 
45 
46 
47 
48 #if defined(__GNUC__)
49 	#define	BWL_PRE_PACKED_STRUCT
50 	#define	BWL_POST_PACKED_STRUCT	__attribute__ ((packed))
51 #elif defined(__CC_ARM)
52 	#define	BWL_PRE_PACKED_STRUCT	__packed
53 	#define	BWL_POST_PACKED_STRUCT
54 #else
55 	#error "Unknown compiler!"
56 #endif
57