Fix compiler error due to uninitialized variable
[clumanager.git] / librhcm / platform.h
blob372009a94a1c9d5dbac3b53a38500a284452fcad
1 /*
2 Copyright Red Hat, Inc. 2002-2003
4 The Red Hat Cluster Manager API Library is free software; you can
5 redistribute it and/or modify it under the terms of the GNU Lesser
6 General Public License as published by the Free Software Foundation;
7 either version 2.1 of the License, or (at your option) any later
8 version.
10 The Red Hat Cluster Manager API Library is distributed in the hope
11 that it will be useful, but WITHOUT ANY WARRANTY; without even the
12 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 USA.
20 /** @file
21 * Defines for byte-swapping
23 #ifndef __PLATFORM_H
24 #define __PLATFORM_H
26 #include <endian.h>
27 #include <sys/param.h>
28 #include <byteswap.h>
29 #include <bits/wordsize.h>
30 #include <sizes.h>
32 /* No swapping on little-endian machines */
33 #if __BYTE_ORDER == __LITTLE_ENDIAN
34 #define le_swap16(x) (x)
35 #define le_swap32(x) (x)
36 #define le_swap64(x) (x)
37 #else
38 #define le_swap16(x) bswap_16(x)
39 #define le_swap32(x) bswap_32(x)
40 #define le_swap64(x) bswap_64(x)
41 #endif
43 /* No swapping on big-endian machines */
44 #if __BYTE_ORDER == __LITTLE_ENDIAN
45 #define be_swap16(x) bswap_16(x)
46 #define be_swap32(x) bswap_32(x)
47 #define be_swap64(x) bswap_64(x)
48 #else
49 #define be_swap16(x) (x)
50 #define be_swap32(x) (x)
51 #define be_swap64(x) (x)
52 #endif
55 #define swab16(x) x=be_swap16(x)
56 #define swab32(x) x=be_swap32(x)
57 #define swab64(x) x=be_swap64(x)
60 #if __PTR_SIZE == 4
61 #define ptrcast_uint64_t(ptr) ((uint64_t)((uint32_t)ptr))
62 #else
63 #if __PTR_SIZE == 8
64 #define ptrcast_uint64_t(ptr) ((uint64_t)ptr)
65 #else
66 #error "Unsupported architecture!"
67 #endif
68 #endif
71 #endif /* __PLATFORM_H */