1219820Sjeff/*
2219820Sjeff * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
3219820Sjeff * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4219820Sjeff * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5219820Sjeff *
6219820Sjeff * This software is available to you under a choice of one of two
7219820Sjeff * licenses.  You may choose to be licensed under the terms of the GNU
8219820Sjeff * General Public License (GPL) Version 2, available from the file
9219820Sjeff * COPYING in the main directory of this source tree, or the
10219820Sjeff * OpenIB.org BSD license below:
11219820Sjeff *
12219820Sjeff *     Redistribution and use in source and binary forms, with or
13219820Sjeff *     without modification, are permitted provided that the following
14219820Sjeff *     conditions are met:
15219820Sjeff *
16219820Sjeff *      - Redistributions of source code must retain the above
17219820Sjeff *        copyright notice, this list of conditions and the following
18219820Sjeff *        disclaimer.
19219820Sjeff *
20219820Sjeff *      - Redistributions in binary form must reproduce the above
21219820Sjeff *        copyright notice, this list of conditions and the following
22219820Sjeff *        disclaimer in the documentation and/or other materials
23219820Sjeff *        provided with the distribution.
24219820Sjeff *
25219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32219820Sjeff * SOFTWARE.
33219820Sjeff *
34219820Sjeff */
35219820Sjeff
36219820Sjeff/*
37219820Sjeff * Abstract:
38219820Sjeff *  Turns on byte packing, which is necessary for passing information from
39219820Sjeff *	system to system over a network to ensure no padding by the compiler has
40219820Sjeff *	taken place.
41219820Sjeff */
42219820Sjeff
43219820Sjeff/****h* Component Library/Structure Packing
44219820Sjeff* NAME
45219820Sjeff*	Structure Packing
46219820Sjeff*
47219820Sjeff* DESCRIPTION
48219820Sjeff*	The structure packing header files allow packing structures on byte
49219820Sjeff*	boundaries.
50219820Sjeff*
51219820Sjeff*	Structure packing should be used whenever a structure is transmitted
52219820Sjeff*	between systems, as different platforms pad structures differently if
53219820Sjeff*	they are not packed.  Packing a structure that is not transmitted between
54219820Sjeff*	systems can be detrimental to performance, as fields in the structure may
55219820Sjeff*	not align properly for some platforms. Care must be taken when creating
56219820Sjeff*	packed structures that the alignment rules for all platforms are followed.
57219820Sjeff*
58219820Sjeff*	To pack a structure, include ipackon.h before defining the structure, and
59219820Sjeff*	include ipackoff.h after the structure definition.  Multiple structures
60219820Sjeff*	can be packed between the two include statements if desired.
61219820Sjeff*
62219820Sjeff*	The structure definition itself must use the PACK_SUFFIX keyword.
63219820Sjeff*
64219820Sjeff* EXAMPLE
65219820Sjeff*	#include <complib/ipackon.h>
66219820Sjeff*
67219820Sjeff*	typedef _my_struct_t
68219820Sjeff*	{
69219820Sjeff*	    uint64 large;
70219820Sjeff*	    uint32 medium;
71219820Sjeff*	    uint16 small;
72219820Sjeff*
73219820Sjeff*	} PACK_SUFFIX my_struct_t;
74219820Sjeff*	#include <complib/ipackoff.h>
75219820Sjeff*********/
76219820Sjeff
77219820Sjeff#ifndef PACK_SUFFIX
78219820Sjeff#define PACK_SUFFIX __attribute__((packed))
79219820Sjeff#endif
80219820Sjeff
81219820Sjeff#ifdef _MSC_VER
82219820Sjeff#pragma pack (push, 1)
83219820Sjeff#endif
84