1 (* Copyright (C
) 1999-2006 Henry Cejtin
, Matthew Fluet
, Suresh
2 * Jagannathan
, and Stephen Weeks
.
3 * Copyright (C
) 1997-2000 NEC Research Institute
.
5 * MLton is released under a BSD
-style license
.
6 * See the file MLton
-LICENSE for details
.
9 functor BitFlags(structure S
: sig
11 val castToSysWord
: t
-> SysWord
.word
12 val castFromSysWord
: SysWord
.word -> t
16 end): BIT_FLAGS_EXTRA
=
20 val all
: flags
= S
.castFromSysWord (SysWord
.~
0w1
)
21 val empty
: flags
= S
.castFromSysWord
0w0
23 fun toWord f
= S
.castToSysWord f
24 fun fromWord w
= S
.castFromSysWord (SysWord
.andb (w
, toWord all
))
26 val flags
: flags list
-> flags
= List.foldl S
.orb empty
28 val intersect
: flags list
-> flags
= List.foldl S
.andb all
30 fun clear (f
, f
') = S
.andb (S
.notb f
, f
')
32 fun allSet (f
, f
') = S
.andb (f
, f
') = f
'
34 fun anySet (f
, f
') = S
.andb (f
, f
') <> empty