xref: /haiku/headers/private/drivers/lendian_bitfield.h (revision 1214ef1b2100f2b3299fc9d8d6142e46f70a4c3f)
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 #define B_HOST_IS_LENDIAN 1
11 
12 #if B_HOST_IS_BENDIAN
13 
14 #define  LBITFIELD8_2(b1,b2)					uint8 b2,b1
15 #define  LBITFIELD8_3(b1,b2,b3)					uint8 b3,b2,b1
16 #define  LBITFIELD8_4(b1,b2,b3,b4)				uint8 b4,b3,b2,b1
17 #define  LBITFIELD8_5(b1,b2,b3,b4,b5)			uint8 b5,b4,b3,b2,b1
18 #define  LBITFIELD8_6(b1,b2,b3,b4,b5,b6)		uint8 b6,b5,b4,b3,b2,b1
19 #define  LBITFIELD8_7(b1,b2,b3,b4,b5,b6,b7)		uint8 b7,b6,b5,b4,b3,b2,b1
20 #define  LBITFIELD8_8(b1,b2,b3,b4,b5,b6,b7,b8)	uint8 b8,b7,b6,b5,b4,b3,b2,b1
21 
22 
23 #define  LBITFIELD2(b1,b2)													uint16 b2,b1
24 #define  LBITFIELD3(b1,b2,b3)												uint16 b3,b2,b1
25 #define  LBITFIELD4(b1,b2,b3,b4)											uint16 b4,b3,b2,b1
26 #define  LBITFIELD5(b1,b2,b3,b4,b5)											uint16 b5,b4,b3,b2,b1
27 #define  LBITFIELD6(b1,b2,b3,b4,b5,b6)										uint16 b6,b5,b4,b3,b2,b1
28 #define  LBITFIELD7(b1,b2,b3,b4,b5,b6,b7)							 		uint16 b7,b6,b5,b4,b3,b2,b1
29 #define  LBITFIELD8(b1,b2,b3,b4,b5,b6,b7,b8)								uint16 b8,b7,b6,b5,b4,b3,b2,b1
30 #define  LBITFIELD9(b1,b2,b3,b4,b5,b6,b7,b8,b9)								uint16 b9,b8,b7,b6,b5,b4,b3,b2,b1
31 #define LBITFIELD10(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10)							uint16 b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
32 #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
33 #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
34 #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
35 #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
36 #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
37 #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
38 #elif B_HOST_IS_LENDIAN
39 
40 #define  LBITFIELD8_2(b1,b2)					uint8 b1,b2
41 #define  LBITFIELD8_3(b1,b2,b3)					uint8 b1,b2,b3
42 #define  LBITFIELD8_4(b1,b2,b3,b4)				uint8 b1,b2,b3,b4
43 #define  LBITFIELD8_5(b1,b2,b3,b4,b5)			uint8 b1,b2,b3,b4,b5
44 #define  LBITFIELD8_6(b1,b2,b3,b4,b5,b6)		uint8 b1,b2,b3,b4,b5,b6
45 #define  LBITFIELD8_7(b1,b2,b3,b4,b5,b6,b7)		uint8 b1,b2,b3,b4,b5,b6,b7
46 #define  LBITFIELD8_8(b1,b2,b3,b4,b5,b6,b7,b8)	uint8 b1,b2,b3,b4,b5,b6,b7,b8
47 
48 #define  LBITFIELD2(b1,b2)													uint16 b1,b2
49 #define  LBITFIELD3(b1,b2,b3)												uint16 b1,b2,b3
50 #define  LBITFIELD4(b1,b2,b3,b4)											uint16 b1,b2,b3,b4
51 #define  LBITFIELD5(b1,b2,b3,b4,b5)											uint16 b1,b2,b3,b4,b5
52 #define  LBITFIELD6(b1,b2,b3,b4,b5,b6)										uint16 b1,b2,b3,b4,b5,b6
53 #define  LBITFIELD7(b1,b2,b3,b4,b5,b6,b7)									uint16 b1,b2,b3,b4,b5,b6,b7
54 #define  LBITFIELD8(b1,b2,b3,b4,b5,b6,b7,b8)								uint16 b1,b2,b3,b4,b5,b6,b7,b8
55 #define  LBITFIELD9(b1,b2,b3,b4,b5,b6,b7,b8,b9) 							uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9
56 #define LBITFIELD10(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10)							uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10
57 #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
58 #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
59 #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
60 #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
61 #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
62 #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
63 
64 #else
65 #error "Unknown host endianness"
66 #endif
67 
68 #endif /* LENDIAN_BITFIELD_H */
69