/usr/share/gap/lib/system.g is in gap-libs 4r6p5-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | #############################################################################
##
#W system.g GAP Library Alexander Hulpke
##
##
#Y Copyright (C) 1996, Lehrstuhl D für Mathematik, RWTH Aachen, Germany
#Y (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland
#Y Copyright (C) 2002 The GAP Group
##
## This file contains functions that are architecture dependent,
## and the record `GAPInfo', which collects global variables that are needed
## internally.
##
## `GAPInfo' is initialized when GAP is started without a workspace,
## and various components are added and modified later on.
## When GAP is started with a workspace, the value of `GAPInfo' is kept,
## just some dedicated components are modified via the
## ``post restore functions'' mechanism.
##
BIND_GLOBAL( "GAPInfo", rec(
# do not edit the following three lines. Occurences of `4.6.5' and `20-Jul-2013'
# will be replaced by string matching by distribution wrapping scripts.
Version := "4.6.5",
Date := "20-Jul-2013",
NeedKernelVersion := "4.6.5",
# Without the needed packages, GAP does not start.
Dependencies := rec(
NeededOtherPackages := [
[ "gapdoc", ">= 1.2" ],
],
),
HasReadGAPRC:= false,
# list of all reserved keywords
Keywords:=ALL_KEYWORDS(),
# the maximal number of arguments a method can have
MaxNrArgsMethod:= 6,
# caches of functions that are needed also with a workspace
AtExitFuncs:= [],
PostRestoreFuncs:= [],
TestData:= rec(),
# admissible command line options
# (name of the option, default value, descr. strings for help page;
# if no help string appears then option is not advertised in the help)
CommandLineOptionData := [
[ "h", false, "print this help and exit" ],
[ "b", false, "disable/enable the banner" ],
[ "q", false, "enable/disable quiet mode" ],
[ "e", false, "disable/enable quitting on <ctr>-D" ],
[ "f", false, "force line editing" ],
[ "n", false, "prevent line editing" ],
[ "E", true, "disable/enable use of readline library (if possible)" ],
[ "x", "", "<num>", "set line width" ],
[ "y", "", "<num>", "set number of lines" ],
,
[ "g", 0, "show GASMAN messages (full/all/no garbage collections)" ],
[ "m", "128m", "<mem>", "set the initial workspace size" ],
[ "o", "2g", "<mem>", "set hint for maximal workspace size (GAP may allocate more)" ],
[ "K", "0", "<mem>", "set maximal workspace size (GAP never allocates more)" ],
[ "c", "0", "<mem>", "set the cache size value" ],
[ "a", "0", "<mem>", "set amount to pre-malloc-ate",
"postfix 'k' = *1024, 'm' = *1024*1024, 'g' = *1024*1024*1024" ],
,
[ "l", [], "<paths>", "set the GAP root paths" ],
[ "r", false, "disable/enable user GAP root dir GAPInfo.UserGapRoot" ],
[ "A", false, "disable/enable autoloading of suggested GAP packages" ],
[ "B", "", "<name>", "current architecture" ],
[ "D", false, "enable/disable debugging the loading of files" ],
[ "M", false, "disable/enable loading of compiled modules" ],
[ "N", false, "unused, for backward compatibility only" ],
[ "O", false, "disable/enable loading of obsolete files" ],
[ "X", false, "enable/disable CRC checking for compiled modules" ],
[ "T", false, "disable/enable break loop" ],
[ "i", "", "<file>", "change the name of the init file" ],
,
[ "L", "", "<file>", "restore a saved workspace" ],
[ "R", false, "prevent restoring of workspace (ignoring -L)" ],
,
[ "p", false, "enable/disable package output mode" ],
[ "E", false ],
[ "U", "" ], # -C -U undocumented options to the compiler
[ "s", "4g" ],
[ "z", "20" ],
],
) );
#############################################################################
##
#V GAPInfo.BytesPerVariable
#V DOUBLE_OBJLEN
##
## <ManSection>
## <Var Name="GAPInfo.BytesPerVariable"/>
## <Var Name="DOUBLE_OBJLEN"/>
##
## <Description>
## <Ref Var="GAPInfo.BytesPerVariable"/> is the number of bytes used for one
## <C>Obj</C> variable.
## </Description>
## </ManSection>
##
## These variables need not be recomputed when a workspace is loaded.
##
GAPInfo.BytesPerVariable := 4;
# are we a 64 (or more) bit system?
while TNUM_OBJ( 2^((GAPInfo.BytesPerVariable-1)*8) )
= TNUM_OBJ( 2^((GAPInfo.BytesPerVariable+1)*8) ) do
GAPInfo.BytesPerVariable:= GAPInfo.BytesPerVariable + 4;
od;
BIND_GLOBAL( "DOUBLE_OBJLEN", 2*GAPInfo.BytesPerVariable );
#############################################################################
##
#F CallAndInstallPostRestore( <func> )
##
## The argument <func> must be a function with no argument.
## This function is called,
## and it is added to the global list `GAPInfo.PostRestoreFuncs'.
## The effect of the latter is that the function will be called
## when GAP is started with a workspace (option `-L').
##
BIND_GLOBAL( "CallAndInstallPostRestore", function( func )
if not IS_FUNCTION( func ) then
Error( "<func> must be a function" );
elif CHECK_INSTALL_METHOD and not NARG_FUNC( func ) in [ -1, 0 ] then
Error( "<func> must accept zero arguments" );
fi;
func();
ADD_LIST( GAPInfo.PostRestoreFuncs, func );
end );
#############################################################################
##
#F InstallAndCallPostRestore( <func> )
##
## The argument <func> must be a function with no argument.
## This function is added to the global list `GAPInfo.PostRestoreFuncs',
## and afterwards it is called.
## The effect of the former is that the function will be called
## when GAP is started with a workspace (option `-L').
##
BIND_GLOBAL( "InstallAndCallPostRestore", function( func )
if not IS_FUNCTION( func ) then
Error( "<func> must be a function" );
elif CHECK_INSTALL_METHOD and not NARG_FUNC( func ) in [ -1, 0 ] then
Error( "<func> must accept zero arguments" );
fi;
ADD_LIST( GAPInfo.PostRestoreFuncs, func );
func();
end );
#############################################################################
##
## - Set/adjust the kernel specific components.
## - Compute `GAPInfo.DirectoriesSystemPrograms' from
## `GAPInfo.SystemEnvironment.PATH'.
## - Scan the command line.
## In case of `-h' print a help screen and exit.
##
CallAndInstallPostRestore( function()
local j, i, CommandLineOptions, opt, InitFiles, line, word, value;
GAPInfo.KernelInfo:= KERNEL_INFO();
GAPInfo.KernelVersion:= GAPInfo.KernelInfo.KERNEL_VERSION;
GAPInfo.Architecture:= GAPInfo.KernelInfo.GAP_ARCHITECTURE;
GAPInfo.ArchitectureBase:= GAPInfo.KernelInfo.GAP_ARCHITECTURE;
for i in [ 1 .. LENGTH( GAPInfo.Architecture ) ] do
if GAPInfo.Architecture[i] = '/' then
GAPInfo.ArchitectureBase:= GAPInfo.Architecture{ [ 1 .. i-1 ] };
break;
fi;
od;
# On 32-bit we have to adjust some values:
if GAPInfo.BytesPerVariable = 4 then
i := 1;
while not(IsBound(GAPInfo.CommandLineOptionData[i])) or
GAPInfo.CommandLineOptionData[i][1] <> "m" do i := i + 1; od;
GAPInfo.CommandLineOptionData[i][2] := "64m";
i := 1;
while not(IsBound(GAPInfo.CommandLineOptionData[i])) or
GAPInfo.CommandLineOptionData[i][1] <> "o" do i := i + 1; od;
GAPInfo.CommandLineOptionData[i][2] := "1g";
i := 1;
while not(IsBound(GAPInfo.CommandLineOptionData[i])) or
GAPInfo.CommandLineOptionData[i][1] <> "s" do i := i + 1; od;
GAPInfo.CommandLineOptionData[i][2] := "1500m";
fi;
# The exact command line which called GAP as list of strings;
# first entry is the executable followed by the options.
GAPInfo.SystemCommandLine:= GAPInfo.KernelInfo.COMMAND_LINE;
# The shell environment in which GAP was called as record
GAPInfo.SystemEnvironment:= GAPInfo.KernelInfo.ENVIRONMENT;
# paths
GAPInfo.RootPaths:= GAPInfo.KernelInfo.GAP_ROOT_PATHS;
GAPInfo.UserHome:= GAPInfo.SystemEnvironment.HOME;
if IsBound(GAPInfo.KernelInfo.DOT_GAP_PATH) then
GAPInfo.UserGapRoot := GAPInfo.KernelInfo.DOT_GAP_PATH;
else
GAPInfo.UserGapRoot := fail;
fi;
# directory caches
GAPInfo.DirectoriesLibrary:= rec();
GAPInfo.DirectoriesPrograms:= false;
GAPInfo.DirectoriesTemporary:= [];
GAPInfo.DirectoryCurrent:= false;
GAPInfo.DirectoriesSystemPrograms:= [];
j:= 1;
for i in [1..LENGTH(GAPInfo.SystemEnvironment.PATH)] do
if GAPInfo.SystemEnvironment.PATH[i] = ':' then
if i > j then
ADD_LIST_DEFAULT(GAPInfo.DirectoriesSystemPrograms,
GAPInfo.SystemEnvironment.PATH{[j..i-1]});
fi;
j := i+1;
fi;
od;
if j <= LENGTH( GAPInfo.SystemEnvironment.PATH ) then
ADD_LIST_DEFAULT( GAPInfo.DirectoriesSystemPrograms,
GAPInfo.SystemEnvironment.PATH{ [ j ..
LENGTH( GAPInfo.SystemEnvironment.PATH ) ] } );
fi;
# the command line options that were given for the current session
CommandLineOptions:= rec();
for opt in GAPInfo.CommandLineOptionData do
CommandLineOptions.( opt[1] ):= SHALLOW_COPY_OBJ( opt[2] );
od;
InitFiles:= [];
line:= GAPInfo.SystemCommandLine;
i:= 2;
while i <= LENGTH( line ) do
word:= line[i];
i:= i+1;
if word[1] = '-' and LENGTH( word ) = 2 then
opt:= word{[2]};
if not IsBound( CommandLineOptions.( opt ) ) then
PRINT_TO( "*errout*", "Unrecognised command line option: -",
word, "\n" );
else
value:= CommandLineOptions.( opt );
if IS_BOOL( value ) then
CommandLineOptions.( opt ):= not CommandLineOptions.( opt );
elif IS_INT( value ) then
CommandLineOptions.( opt ):= CommandLineOptions.( opt ) + 1;
elif i <= LENGTH( line ) then
if IS_STRING_REP( value ) then
# string
CommandLineOptions.( opt ):= line[i];
i := i+1;
elif IS_LIST( value ) then
# list of strings, starting from the empty list
ADD_LIST_DEFAULT( CommandLineOptions.( opt ), line[i] );
i := i+1;
fi;
else
PRINT_TO( "*errout*", "Command line option -", word, " needs an argument.\n" );
fi;
fi;
else
ADD_LIST_DEFAULT( InitFiles, word );
fi;
od;
CommandLineOptions.g:= CommandLineOptions.g mod 3;
# use the same as the kernel
CommandLineOptions.E:= GAPInfo.KernelInfo.HAVE_LIBREADLINE;
MakeImmutable( CommandLineOptions );
MakeImmutable( InitFiles );
if CommandLineOptions.L = "" or CommandLineOptions.R then
# start without a workspace
GAPInfo.CommandLineOptionsPrev:= [];
GAPInfo.InitFilesPrev:= [];
else
# start with a workspace
ADD_LIST_DEFAULT( GAPInfo.CommandLineOptionsPrev,
GAPInfo.CommandLineOptions );
ADD_LIST_DEFAULT( GAPInfo.InitFilesPrev, GAPInfo.InitFiles );
fi;
GAPInfo.CommandLineOptions:= CommandLineOptions;
GAPInfo.InitFiles:= InitFiles;
# Switch on debugging (`-D' option) when GAP is started with a workspace.
if GAPInfo.CommandLineOptions.D then
InfoRead1:= Print;
fi;
# Evaluate the `-h' option.
if GAPInfo.CommandLineOptions.h then
PRINT_TO( "*errout*",
"usage: gap [OPTIONS] [FILES]\n",
" run the Groups, Algorithms and Programming system, Version ",
GAPInfo.KernelVersion, "\n\n" );
for i in [ 1 .. LENGTH( GAPInfo.CommandLineOptionData ) ] do
if IsBound( GAPInfo.CommandLineOptionData[i] ) then
opt:= GAPInfo.CommandLineOptionData[i];
if LENGTH( opt ) > 2 then
PRINT_TO( "*errout*", " -", opt[1], " " );
if LENGTH( opt ) = 3 then
PRINT_TO( "*errout*", " ", opt[3], "\n" );
else
PRINT_TO( "*errout*", opt[3] );
for j in [ 1 .. 9 - LENGTH( opt[3] ) ] do
PRINT_TO( "*errout*", " " );
od;
PRINT_TO( "*errout*", opt[4], "\n" );
for j in [ 5 .. LENGTH( opt ) ] do
PRINT_TO( "*errout*", " ", opt[j], "\n" );
od;
fi;
fi;
else
PRINT_TO( "*errout*", "\n" );
fi;
od;
PRINT_TO("*errout*",
" Boolean options (b,q,e,r,A,D,E,M,N,T,X,Y) toggle the current value\n",
" each time they are called. Default actions are indicated first.\n",
"\n" );
QUIT_GAP();
fi;
end );
#############################################################################
##
#V GAPInfo.TestData
##
## <ManSection>
## <Var Name="GAPInfo.TestData"/>
##
## <Description>
## This is a mutable record used in files that are read via <C>ReadTest</C>.
## These files contain the commands <C>START_TEST</C> and <C>STOP_TEST</C>,
## which set, read, and unbind the components <C>START_TIME</C> and <C>START_NAME</C>.
## The function <C>RunStandardTests</C> also uses a component <C>results</C>.
## </Description>
## </ManSection>
##
#T the following functions eventually should be more clever. This however
#T will require kernel support and thus is something for later. AH
#############################################################################
##
#F ARCH_IS_WINDOWS()
##
## <#GAPDoc Label="ARCH_IS_WINDOWS">
## <ManSection>
## <Func Name="ARCH_IS_WINDOWS" Arg=''/>
##
## <Description>
## tests whether &GAP; is running on a Windows system.
## </Description>
## </ManSection>
## <#/GAPDoc>
##
BIND_GLOBAL("ARCH_IS_WINDOWS",function()
return POSITION_SUBSTRING (GAPInfo.Architecture, "cygwin", 0) <> fail;
end);
#############################################################################
##
#F ARCH_IS_MAC_OS_X()
##
## <#GAPDoc Label="ARCH_IS_MAC_OS_X">
## <ManSection>
## <Func Name="ARCH_IS_MAC_OS_X" Arg=''/>
##
## <Description>
## tests whether &GAP; is running on Mac OS X. Note that on Mac OS X, also
## <Ref Func="ARCH_IS_UNIX"/> will be <C>true</C>.
## </Description>
## </ManSection>
## <#/GAPDoc>
##
BIND_GLOBAL("ARCH_IS_MAC_OS_X",function()
return POSITION_SUBSTRING (GAPInfo.Architecture, "apple-darwin", 0) <> fail
and IsReadableFile ("/System/Library/CoreServices/Finder.app");
end);
#############################################################################
##
#F ARCH_IS_UNIX()
##
## <#GAPDoc Label="ARCH_IS_UNIX">
## <ManSection>
## <Func Name="ARCH_IS_UNIX" Arg=''/>
##
## <Description>
## tests whether &GAP; is running on a UNIX system (including Mac OS X).
## </Description>
## </ManSection>
## <#/GAPDoc>
##
BIND_GLOBAL("ARCH_IS_UNIX",function()
return not ARCH_IS_WINDOWS();
end);
#############################################################################
##
#V GAPInfo.InitFiles
#V GAPInfo.CommandLineArguments
##
## <ManSection>
## <Var Name="GAPInfo.InitFiles"/>
## <Var Name="GAPInfo.CommandLineArguments"/>
##
## <Description>
## <C>GAPInfo.InitFiles</C> is a list of strings containing the filenames
## specified on the command line to be read initially.
## <P/>
## <C>GAPInfo.CommandLineArguments</C> is a single string containing all
## the options and arguments passed to GAP at runtime (although not
## necessarily in the original order).
## </Description>
## </ManSection>
##
#T really ???
#############################################################################
##
#E
|