xref: /haiku/headers/private/drivers/lendian_bitfield.h (revision 2b76973fa2401f7a5edf68e6470f3d3210cbcff3)
1 /*
2 ** Copyright 2002, Thomas Kurschel. All rights reserved.
3 ** Distributed under the terms of the OpenBeOS License.
4 */
5 
6 #ifndef LENDIAN_BITFIELD_H
7 #define LENDIAN_BITFIELD_H
8 
9 #include <ByteOrder.h>
10 
11 #if B_HOST_IS_BENDIAN
12 
13 #define  LBITFIELD8_2(b1,b2)					uint8 b2,b1
14 #define  LBITFIELD8_3(b1,b2,b3)					uint8 b3,b2,b1
15 #define  LBITFIELD8_4(b1,b2,b3,b4)				uint8 b4,b3,b2,b1
16 #define  LBITFIELD8_5(b1,b2,b3,b4,b5)			uint8 b5,b4,b3,b2,b1
17 #define  LBITFIELD8_6(b1,b2,b3,b4,b5,b6)		uint8 b6,b5,b4,b3,b2,b1
18 #define  LBITFIELD8_7(b1,b2,b3,b4,b5,b6,b7)		uint8 b7,b6,b5,b4,b3,b2,b1
19 #define  LBITFIELD8_8(b1,b2,b3,b4,b5,b6,b7,b8)	uint8 b8,b7,b6,b5,b4,b3,b2,b1
20 
21 
22 #define  LBITFIELD2(b1,b2)													uint16 b2,b1
23 #define  LBITFIELD3(b1,b2,b3)												uint16 b3,b2,b1
24 #define  LBITFIELD4(b1,b2,b3,b4)											uint16 b4,b3,b2,b1
25 #define  LBITFIELD5(b1,b2,b3,b4,b5)											uint16 b5,b4,b3,b2,b1
26 #define  LBITFIELD6(b1,b2,b3,b4,b5,b6)										uint16 b6,b5,b4,b3,b2,b1
27 #define  LBITFIELD7(b1,b2,b3,b4,b5,b6,b7)							 		uint16 b7,b6,b5,b4,b3,b2,b1
28 #define  LBITFIELD8(b1,b2,b3,b4,b5,b6,b7,b8)								uint16 b8,b7,b6,b5,b4,b3,b2,b1
29 #define  LBITFIELD9(b1,b2,b3,b4,b5,b6,b7,b8,b9)								uint16 b9,b8,b7,b6,b5,b4,b3,b2,b1
30 #define LBITFIELD10(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10)							uint16 b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
31 #define LBITFIELD11(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11)						uint16 b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
32 #define LBITFIELD12(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12)					uint16 b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
33 #define LBITFIELD13(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13)				uint16 b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
34 #define LBITFIELD14(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14)			uint16 b14,b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
35 #define LBITFIELD15(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15)		uint16 b15,b14,b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
36 #define LBITFIELD16(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16)	uint16 b16,b15,b14,b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
37 #elif B_HOST_IS_LENDIAN
38 
39 #define  LBITFIELD8_2(b1,b2)					uint8 b1,b2
40 #define  LBITFIELD8_3(b1,b2,b3)					uint8 b1,b2,b3
41 #define  LBITFIELD8_4(b1,b2,b3,b4)				uint8 b1,b2,b3,b4
42 #define  LBITFIELD8_5(b1,b2,b3,b4,b5)			uint8 b1,b2,b3,b4,b5
43 #define  LBITFIELD8_6(b1,b2,b3,b4,b5,b6)		uint8 b1,b2,b3,b4,b5,b6
44 #define  LBITFIELD8_7(b1,b2,b3,b4,b5,b6,b7)		uint8 b1,b2,b3,b4,b5,b6,b7
45 #define  LBITFIELD8_8(b1,b2,b3,b4,b5,b6,b7,b8)	uint8 b1,b2,b3,b4,b5,b6,b7,b8
46 
47 #define  LBITFIELD2(b1,b2)													uint16 b1,b2
48 #define  LBITFIELD3(b1,b2,b3)												uint16 b1,b2,b3
49 #define  LBITFIELD4(b1,b2,b3,b4)											uint16 b1,b2,b3,b4
50 #define  LBITFIELD5(b1,b2,b3,b4,b5)											uint16 b1,b2,b3,b4,b5
51 #define  LBITFIELD6(b1,b2,b3,b4,b5,b6)										uint16 b1,b2,b3,b4,b5,b6
52 #define  LBITFIELD7(b1,b2,b3,b4,b5,b6,b7)									uint16 b1,b2,b3,b4,b5,b6,b7
53 #define  LBITFIELD8(b1,b2,b3,b4,b5,b6,b7,b8)								uint16 b1,b2,b3,b4,b5,b6,b7,b8
54 #define  LBITFIELD9(b1,b2,b3,b4,b5,b6,b7,b8,b9) 							uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9
55 #define LBITFIELD10(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10)							uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10
56 #define LBITFIELD11(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11)						uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11
57 #define LBITFIELD12(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12)					uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12
58 #define LBITFIELD13(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13)				uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13
59 #define LBITFIELD14(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14)			uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14
60 #define LBITFIELD15(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15)		uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15
61 #define LBITFIELD16(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16)	uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16
62 
63 #else
64 #error "Unknown host endianness"
65 #endif
66 
67 #endif /* LENDIAN_BITFIELD_H */
68