//  Declarations for common BCPL library routines for Multics.
//  Last modified on 09/05/73 at 03:57:35 by R F Mabee.
//  Largely rewritten for 6180 Multics; installed in June 1973 by R F Mabee.
//  First version installed in September 1971 by R F Mabee.

external		//  Functions to perform mathematical operations not provided by the language.
     $(	MaxI = "bcpl_arithmetic_$MaxI"		//  i := MaxI (j, k)
	MaxR = "bcpl_arithmetic_$MaxR"		//  x := MaxR (y, z)
	MinI = "bcpl_arithmetic_$MinI"		//  i := MinI (j, k)
	MinR = "bcpl_arithmetic_$MinR"		//  x := MinR (y, z)
	AbsI = "bcpl_arithmetic_$AbsI"		//  i := AbsI (j)
	AbsR = "bcpl_arithmetic_$AbsR"		//  x := AbsR (y)
	SquareRoot = "bcpl_arithmetic_$SquareRoot"	//  x := SquareRoot (y)
	IpowerI = "bcpl_arithmetic_$IpowerI"		//  i := IpowerI (j, k)
	RpowerI = "bcpl_arithmetic_$RpowerI"		//  x := RpowerI (y, k)
	RpowerR = "bcpl_arithmetic_$RpowerR"		//  x := RpowerR (y, z)
	RandomI = "bcpl_arithmetic_$RandomI"		//  i := RandomI ()
	RandomR = "bcpl_arithmetic_$RandomR"		//  x := RandomR ()
	Logarithm = "bcpl_arithmetic_$Logarithm"	//  x := Logarithm (y)
	Exponential = "bcpl_arithmetic_$Exponential"	//  x := Exponential (y)
     $)
external		//  Routines to manipulate strings.  Caller must supply space to hold string results.
     $(	Packstring = "bcpl_machine_code_$Packstring"	//  Packstring (Unpacked, Space)
	Unpackstring = "bcpl_machine_code_$Unpackstring"	//  Unpackstring (String, Space)
	CopyString = "bcpl_strings_$CopyString"		//  CopyString (String, Space)
	EqualString = "bcpl_strings_$EqualString"	//  if EqualString (StringA, StringB) do ...
	CompareStrings = "bcpl_strings_$CompareStrings"	//  CollatingOrder := CompareStrings (StringA, StringB)
	Concatenate = "bcpl_strings_$Concatenate"	//  s := Concatenate (Space, Maxlen, StrA, StrB, ...)
	Substr = "bcpl_strings_$Substr"		//  s := Substr (Space, String, Index, [Length])
	Subch = "bcpl_machine_code_$Subch"		//  Ch := Subch (String, Index)
	Length = "bcpl_strings_$Length"		//  Len := Length (String)
	SetLength = "bcpl_strings_$SetLength"		//  SetLength (String, Len)
	LengthInWords = "bcpl_strings_$LengthInWords"	//  Len := LengthInWords (String)
	Index = "bcpl_strings_$Index"			//  i := Index (StringA, StringB)
	IndexCh = "bcpl_strings_$IndexCh"		//  i := IndexCh (String, Ch)
	StringToChar = "bcpl_strings_$StringToChar"	//  Char := StringToChar (String)
	CharToString = "bcpl_strings_$CharToString"	//  String := CharToString (Char, Space)
	MakePl1String = "bcpl_strings_$MakePl1String"	//  Pl1String := MakePl1String (BcplString, Space, Len)
	MakeBcplString = "bcpl_strings_$MakeBcplString"	//  s := MakeBcplString (Pl1String, Len, Space)
     $)
external		//  Functions to convert values from one representation to another.
     $(	RtoI = "bcpl_machine_code_$RtoI"		//  i := RtoI (x)
	ItoR = "bcpl_machine_code_$ItoR"		//  x := ItoR (i)
	ConvertStoN = "bcpl_conversions_$ConvertStoN"	//  r := ConvertStoN (String, [Base])
	ConvertNtoS = "bcpl_conversions_$ConvertNtoS"	//  String := ConvertNtoS (i, Space, [Base, [Digits]])
	ConvertFtoS = "bcpl_conversions_$ConvertFtoS"	//  String := ConvertFtoS (x, Space, [Digits])
	RemoveEscapes = "bcpl_conversions_$RemoveEscapes"	//  s := RemoveEscapes (String, Space)
	InsertEscapes = "bcpl_conversions_$InsertEscapes"	//  s := InsertEscapes (String, Space)
	FormDate = "bcpl_conversions_$FormDate"		//  FormDate (Seconds, Space10, GMTsw)
     $)
external		//  Miscellaneous routines to extend the power of the language.
     $(	Longjump = "bcpl_machine_code_$Longjump"	//  Longjump (Label, Psaved)
	Level = "bcpl_machine_code_$Level"		//  Psaved := Level ()
	Bcall = "bcpl_machine_code_$Bcall"		//  r := Bcall (F, n, (list A1, A2, .. An))
	Pl1Call = "bcpl_machine_code_$Pl1Call"		//  Pl1Call (Routine, ArglistAddress)
	Move = "bcpl_machine_code_$Move"		//  Move (ToPtr, FromPtr, WordCount)
	MoveBits = "bcpl_machine_code_$MoveBits"	//  MoveBits (ToPtr, ToBit, FromPtr, FromBit, BitCount)
	ScanChar = "bcpl_machine_code_$ScanChar"	//  Offset := ScanChar (Ptr, Offset, Length, Ch)
	NumbArgs = "bcpl_machine_code_$NumbArgs"	//  Nargs := NumbArgs ()
	NewvecInit = "bcpl_filesys_lib_$NewvecInit"	//  NewvecInit (Space, Size)
	NewvecCleanup = "bcpl_filesys_lib_$NewvecCleanup"	//  NewvecCleanup ()
	Newvec = "bcpl_filesys_lib_$Newvec"		//  v := Newvec (Size - 1)
	Freevec = "bcpl_filesys_lib_$Freevec"		//  Freevec (v)
	Allocate = "bcpl_filesys_lib_$Allocate"		//  v := Allocate (Size)
	Findadr = "bcpl_filesys_lib_$Findadr"		//  Ptr := Findadr (Name)
     $)
external		//  BCPL stream I/O routines.
     $(	Open = "bcpl_stream_io_$Open"			//  Stream := Open (Options, Name, [Length, Delimiter])
	Close = "bcpl_stream_io_$Close"		//  Close (StreamA, StreamB, ...)
	Readch = "bcpl_machine_code_$Readch"		//  Readch (Stream, lv Ch)
	Writech = "bcpl_machine_code_$Writech"		//  Writech (Stream, Ch)
	WriteS = "bcpl_stream_io_$WriteS"		//  WriteS (Stream, String)
	WriteN = "bcpl_stream_io_$WriteN"		//  WriteN (Stream, i)
	Format = "bcpl_stream_io_$Format"		//  Format (Stream, ControlString, A1, A2, ...)
	FormatString = "bcpl_stream_io_$FormatString"	//  FormatString (Space, MaxLen, ControlString, A1, A2, ...)
	Writeout = "bcpl_stream_io_$Writeout"		//  Writeout (Stream)
	Flushinput = "bcpl_stream_io_$Flushinput"	//  Flushinput (Stream)
	ResetStream = "bcpl_stream_io_$ResetStream"	//  ResetStream (Stream, Offset)
	StreamOffset = "bcpl_stream_io_$StreamOffset"	//  Offset := StreamOffset (Stream)
	StreamLength = "bcpl_stream_io_$StreamLength"	//  Length := StreamLength (Stream)
	StreamPointer = "bcpl_stream_io_$StreamPointer"	//  Ptr := StreamPointer (Stream)
     $)
external		//  Interface to Multics file system.  Note: Dirname and Entryname are PL/I strings.
     $(	ExpandPathname = "bcpl_filesys_lib_$ExpandPathname" // s := ExpandPathname (RelativePath, Space)
	JoinPathname = "bcpl_filesys_lib_$JoinPathname"	//  s := JoinPathname (Dirname, Entryname, Space)
	SplitPathname = "bcpl_filesys_lib_$SplitPathname"	//  SplitPathname (AbsolutePath, Dirname, Entryname)
	FindSegment = "bcpl_filesys_lib_$FindSegment"	//  Ptr := FindSegment (Pathname, lv BitCount)
	MakeSegment = "bcpl_filesys_lib_$MakeSegment"	//  Ptr := MakeSegment (Pathname)
	GetPathname = "bcpl_filesys_lib_$GetPathname"	//  s := GetPathname (Pointer, Space)
	MakeTempSeg = "bcpl_filesys_lib_$MakeTempSeg"	//  Ptr := MakeTempSeg (Number, Purpose)
	DeleteTempSeg = "bcpl_filesys_lib_$DeleteTempSeg"	//  DeleteTempSeg (Number, Purpose)
	Terminate = "bcpl_filesys_lib_$Terminate"	//  Terminate (Pointer)
	SetBitCount = "bcpl_filesys_lib_$SetBitCount"	//  SetBitCount (Pointer, BitCount)
	RawClockTime = "bcpl_machine_code_$RawClockTime"	//  RawTime := RawClockTime (Space2)
	TimeToSeconds = "bcpl_machine_code_$TimeToSeconds" // TimeNow := TimeToSeconds (RawTime)
	GetCpuUsage = "bcpl_filesys_lib_$GetCpuUsage"	//  MicrosecondsUsed := GetCpuUsage ()
     $)
external		//  Interface to Multics command level features.
     $(	Pl1NumbArgs = "bcpl_command_lib_$Pl1NumbArgs"	//  Nargs := Pl1NumbArgs ()
	Pl1ArgPtr = "bcpl_command_lib_$Pl1ArgPtr"	//  Ptr := Pl1ArgPtr (ArgIndex)
	Pl1Descriptor = "bcpl_command_lib_$Pl1Descriptor"	//  D := Pl1Descriptor (ArgIndex)
	Pl1ArgString = "bcpl_command_lib_$Pl1ArgString"	//  s := Pl1ArgString (ArgIndex, Space, [MaxLen])
	Pl1ReturnString = "bcpl_command_lib_$Pl1ReturnString" // Pl1ReturnString (String)
	ConcatenateArgs = "bcpl_command_lib_$ConcatenateArgs" // s := ConcatenateArgs (FirstIndex, Space, MaxLen)
	OptionParse = "bcpl_command_lib_$OptionParse"	//  OptionParse (GetNextCommandArg, Nopts, OptionsList,
	GetNextCommandArg = "bcpl_command_lib_$GetNextCommandArg"	//	PointersList, FlagsList, PutName)
	Complain = "bcpl_command_lib_$Complain"		//  Complain (ControlString, [A1, A2, A3])
	BCPLaddr = "bcpl_machine_code_$BCPLaddr"	//  Pointer := BCPLaddr (ITSaddress)
	ITS = "bcpl_machine_code_$ITS"		//  ITSaddress := ITS (Pointer, Space, [BitOffset])
	SetOverflowMask = "bcpl_machine_code_$SetOverflowMask" // SetOverflowMask (true -> Inhibit, Enable)
	SetHandler = "bcpl_command_lib_$SetHandler"	//  SetHandler (Name, Handler, Space16)
	RevertHandler = "bcpl_command_lib_$RevertHandler"	//  RevertHandler (Name)
     $)

global		//  Library currently reserves all cells below 60 and may expand up to 99.
     $(	OUTPUT : 32; INPUT : 33
	MONITOR : 34; CONSOLE : 35
	Ch : 36
	ProgramID : 37		//  Must be set to name of program before calling Complain or MakeTempSeg.
	Errcode : 38; IOstatus : 39	//  Used by Complain; set by some library routines.
	ArgIndex : 40		//  Used by GetNextCommandArg.
     $)

manifest		//  Description of object machine, etc.
     $(	Machine = 6180
	WordSize = 36
	ByteSize = 9		//  Bits per character in strings.
	CountSize = 18		//  Bits for string length field.
	Left = 18; Right = $8777777
	Endofstreamch = $87777
	Null = $8007777000001	//  Multics uses this for empty pointer.
     $)
manifest		//  These are the options referred to in the declaration of Open.
     $(	Pointer = 1; Console = 2; StreamName = 3	//  Type.  Specify exactly one.
	PathName = 4; EntryName = 5; SearchName = 6
	Read = 16; Write = 32; Append = 48		//  Direction.  Logor into Type.
	MultiSegmentFile = 128			//  May be logor'ed into above.
     $)
manifest		//  These are the flags that appear in the list given to OptionParse.
     $(	OptNegatable = 1				//  Logor any combination of these values.
	OptNegate = 2
	OptGetNext = 4
	OptConvert = 8
	OptCallOut = 16
     $)
//
//
//                                          -----------------------------------------------------------
//
//
// Historical Background
//
// This edition of the Multics software materials and documentation is provided and donated
// to Massachusetts Institute of Technology by Group Bull including Bull HN Information Systems Inc. 
// as a contribution to computer science knowledge.  
// This donation is made also to give evidence of the common contributions of Massachusetts Institute of Technology,
// Bell Laboratories, General Electric, Honeywell Information Systems Inc., Honeywell Bull Inc., Groupe Bull
// and Bull HN Information Systems Inc. to the development of this operating system. 
// Multics development was initiated by Massachusetts Institute of Technology Project MAC (1963-1970),
// renamed the MIT Laboratory for Computer Science and Artificial Intelligence in the mid 1970s, under the leadership
// of Professor Fernando Jose Corbato. Users consider that Multics provided the best software architecture for 
// managing computer hardware properly and for executing programs. Many subsequent operating systems 
// incorporated Multics principles.
// Multics was distributed in 1975 to 2000 by Group Bull in Europe , and in the U.S. by Bull HN Information Systems Inc., 
// as successor in interest by change in name only to Honeywell Bull Inc. and Honeywell Information Systems Inc. .
//
//                                          -----------------------------------------------------------
//
// Permission to use, copy, modify, and distribute these programs and their documentation for any purpose and without
// fee is hereby granted,provided that the below copyright notice and historical background appear in all copies
// and that both the copyright notice and historical background and this permission notice appear in supporting
// documentation, and that the names of MIT, HIS, Bull or Bull HN not be used in advertising or publicity pertaining
// to distribution of the programs without specific prior written permission.
//    Copyright 1972 by Massachusetts Institute of Technology and Honeywell Information Systems Inc.
//    Copyright 2006 by Bull HN Information Systems Inc.
//    Copyright 2006 by Bull SAS
//    All Rights Reserved
//