BIT_FLAGS
signature
signature BIT_FLAGS
(* OPTIONAL *)
The BIT_FLAGS
signature defines a generic set of operations on an abstract representation of system flags. It is typically included as part of the interface of substructures which provide a set of options.
eqtype flags
val toWord : flags -> SysWord.word
val fromWord : SysWord.word -> flags
val all : flags
val flags : flags list -> flags
val intersect : flags list -> flags
val clear : flags * flags -> flags
val allSet : flags * flags -> bool
val anySet : flags * flags -> bool
eqtype flags
val toWord : flags -> SysWord.word
val fromWord : SysWord.word -> flags
flags
type and a bit-vector that is represented as a system word
. The interpretation of the bits is system-dependent, but follows the C language binding for the host operating system. Note that there is no error checking on the fromWord
function's argument.
all
flags
value defined in a matching structure. For example, BIT_FLAGS
is used to define the flags specified by the POSIX standard; a POSIX-conforming operating system may provide additional flags that will not be defined in the Posix
structure but could be set in the all
value.
flags l
flags []
denotes the empty set.
intersect l
intersect []
denotes all
.
clear (fl1, fl2)
fl2 \ fl1
. It is equivalent to:
fromWord(SysWord.andb(SysWord.notb (toWord fl1), toWord fl2))
allSet (fl1, fl2)
true
if all of the flags in fl1 are also in fl2 (i.e., this tests for inclusion of fl1 in fl2).
anySet (fl1, fl2)
true
if any of the flags in fl1 is also in fl2 (i.e., this tests for non-empty intersection).
Posix.FileSys
,Posix.IO
,Posix.Process
,Posix.TTY
,SysWord
,Windows
The number of distinct flags in an implementation of the BIT_FLAGS
interface must be less than or equal to the number of bits in the SysWord.word
type. In addition, fromWord o toWord
must be the identity function, and toWord o fromWord
must be equivalent to
fn w => SysWord.andb(w, toWord all)
Generated October 02, 2003
Last Modified July 1, 2002
Comments to John Reppy.
This document may be distributed freely over the internet as long as the copyright notice and license terms below are prominently displayed within every machine-readable copy.
Copyright © 2003 AT&T and Lucent Technologies. All rights reserved.
Permission is granted for internet users to make one paper copy for their
own personal use. Further hardcopy reproduction is strictly prohibited.
Permission to distribute the HTML document electronically on any medium
other than the internet must be requested from the copyright holders by
contacting the editors.
Printed versions of the SML Basis Manual are available from Cambridge
University Press.
To order, please visit
www.cup.org (North America) or
www.cup.cam.ac.uk (outside North America). |