Changes to the mpls_fib_impl API:
[mpls-ldp-portable.git] / common / mpls_bitfield.h
blob71e5fbed30a1fea9ef4d8fe006123e6942e23872
1 /*
2 * Copyright (C) James R. Leu 2003
3 * jleu@mindspring.com
5 * This software is covered under the LGPL, for more
6 * info check out http://www.gnu.org/copyleft/lgpl.html
7 */
9 #ifndef MPLS_BITFIELD_H
10 #define MPLS_BITFILED_H
12 #include <endian.h>
14 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
15 #define LITTLE_ENDIAN_BYTE_ORDER 1
16 #endif
18 /* macros to handle different byte orders (little endian or big endian) */
19 #ifdef LITTLE_ENDIAN_BYTE_ORDER
20 #define BITFIELDS_ASCENDING_2(X, Y) Y; X;
21 #define BITFIELDS_ASCENDING_3(X, Y, Z) Z; Y; X;
22 #define BITFIELDS_ASCENDING_4(X, Y, Z, W) W; Z; Y; X;
23 #define BITFIELDS_ASCENDING_7(X, Y, Z, W, U, A, B) B; A; U; W; Z; Y; X;
24 # else
25 #define BITFIELDS_ASCENDING_2(X, Y) X; Y;
26 #define BITFIELDS_ASCENDING_3(X, Y, Z) X; Y; Z;
27 #define BITFIELDS_ASCENDING_4(X, Y, Z, W) X; Y; Z; W;
28 #define BITFIELDS_ASCENDING_7(X, Y, Z, W, U, A, B) X; Y; Z; W; U; A; B;
29 #endif /* LITTLE_ENDIAN_BYTE_ORDER */
31 #endif