xref: /illumos-gate/usr/src/uts/common/sys/bitext.h (revision fc910014e8a32a65612105835a10995f2c13d942)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2022 Oxide Computer Company
14  */
15 
16 #ifndef _SYS_BITEXT_H
17 #define	_SYS_BITEXT_H
18 
19 #include <sys/types.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 /*
26  * A bunch of routines to make working with bits and registers easier. This is
27  * designed to be a replacement for the BITX macro and provide additional error
28  * handling. See bitx64(9F), bitdel64(9F), and bitset64(9F) for more
29  * information.
30  */
31 
32 extern uint8_t bitx8(uint8_t, uint_t, uint_t);
33 extern uint16_t bitx16(uint16_t, uint_t, uint_t);
34 extern uint32_t bitx32(uint32_t, uint_t, uint_t);
35 extern uint64_t bitx64(uint64_t, uint_t, uint_t);
36 
37 extern uint8_t bitset8(uint8_t, uint_t, uint_t, uint8_t);
38 extern uint16_t bitset16(uint16_t, uint_t, uint_t, uint16_t);
39 extern uint32_t bitset32(uint32_t, uint_t, uint_t, uint32_t);
40 extern uint64_t bitset64(uint64_t, uint_t, uint_t, uint64_t);
41 
42 extern uint64_t bitdel64(uint64_t, uint_t, uint_t);
43 
44 #ifdef __cplusplus
45 }
46 #endif
47 
48 #endif /* _SYS_BITEXT_H */
49