versadac  1
versadac - Scalable Recorder Firmware
os_pck.h
1 /*---------------------------------------------------------------------------*/
2 /* Copyright (C) 2006 Woodhead Software & Electonics. All rights reserved. */
3 /*---------------------------------------------------------------------------*/
4 /* This program is protected by international copyright. */
5 /* */
6 /* The use of this software including but not limited to its Source Code */
7 /* is subject to restrictions as agreed in the license agreement between */
8 /* you and Woodhead. */
9 /* Copying or distribution is not allowed unless expressly permitted */
10 /* according to your license agreement with Woodhead. */
11 /*---------------------------------------------------------------------------*/
12 /* */
13 /* Project : STACK PROFINET Controller */
14 /* Component : Hardware Interface */
15 /* $Workfile:: os_pck.h $*/
16 /* $Revision:: 1 $*/
17 /* $Date:: 7/06/10 11:05 $*/
18 /* */
19 /*---------------------------------------------------------------------------*/
20 /* */
21 /* D e s c r i p t i o n : */
22 /* Network Abstraction Layer */
23 /* */
24 /*---------------------------------------------------------------------------*/
25 
26 #ifndef _OS_PACK_H
27 #define _OS_PACK_H
28 
29 /* Sanity check */
30 #ifdef PACK
31  #pragma message ("WARNING: Packing problem detected")
32 #endif
33 
34 #define PACK
35 
36 
37 #define PACK_ALIGNEMENT(p) p
38 #define STRUCT_ALIGNEMENT __attribute__ ((packed))
39 
40 /*substitute DWORDs with two WORDs for alignment request*/
41 #ifdef FIX_DWORD_ALIGNMENT
42  #define ALIGNED_DWORD_DECL(dw) APP_WORD dw##_w1; APP_WORD dw##_w2
43  #define APP_MEM_ALIGNMENT 4
44  #define APP_MEM_ALIGN_SIZE(size) (((size) + APP_MEM_ALIGNMENT - 1) & ~(APP_MEM_ALIGNMENT-1))
45 #else
46  #define ALIGNED_DWORD_DECL(dw) APP_DWORD dw
47  #define APP_MEM_ALIGN_SIZE(size) (size)
48 #endif
49 /*define check to make sure the structures have the correct size
50  it is recommended to enable for the first compilation and turn off if
51  no change to suppress many static char definition in object file*/
52 #ifndef STATIC_STRUCT_SIZE_CHECK
53 /*#define STATIC_STRUCT_SIZE_CHECK*/
54 #endif
55 
56 /*macro for compile-time structure size verification*/
57 #ifdef STATIC_STRUCT_SIZE_CHECK
58 #define STRUCT_SIZE_CHECK(s, l) static char* p_##s = (sizeof(s) != l);
59 #else
60 #define STRUCT_SIZE_CHECK(s, l)
61 #endif
62 
63 
64 #undef _OS_PACK_H
65 #endif