]> git.ipfire.org Git - thirdparty/gcc.git/blob - libphobos/libdruntime/core/sys/dragonflybsd/sys/_bitset.d
Add D front-end, libphobos library, and D2 testsuite.
[thirdparty/gcc.git] / libphobos / libdruntime / core / sys / dragonflybsd / sys / _bitset.d
1 /**
2 * D header file for DragonFlyBSD.
3 *
4 * Authors: Martin Nowak, Diederik de Groot(port:DragonFlyBSD)
5 * Copied: From core/sys/freebsd/sys
6 */
7 module core.sys.dragonflybsd.sys._bitset;
8
9 version (DragonFlyBSD):
10 extern (C) pure nothrow @nogc @system:
11
12 import core.stdc.config : c_long;
13
14 enum NBBY = 8; // number of bits per byte
15
16 enum _BITSET_BITS = c_long.sizeof * NBBY;
17
18 enum __bitset_words(size_t s) = (s + _BITSET_BITS - 1) / _BITSET_BITS;
19
20 c_long __bitset_mask(size_t s)(size_t n)
21 {
22 static if (__bitset_words!s == 1)
23 return (cast(c_long)1) << n;
24 else
25 return (cast(c_long)1) << n % _BITSET_BITS;
26 }
27
28 size_t __bitset_word(size_t s)(size_t n)
29 {
30 static if (__bitset_words!s == 1)
31 return 0;
32 else
33 return n / _BITSET_BITS;
34 }
35
36 struct BITSET_DEFINE(size_t s)
37 {
38 c_long[__bitset_words!s] __bits;
39 }
40
41 // no idea how to translate those
42 //#define BITSET_T_INITIALIZER(x) \
43 // { .__bits = { x } }
44 //
45 //#define BITSET_FSET(n) \
46 // [ 0 ... ((n) - 1) ] = (-1L)