/**************************************************************************** ** ** This file is part of GAP, a system for computational discrete algebra. ** ** Copyright of GAP belongs to its developers, whose names are too numerous ** to list here. Please refer to the COPYRIGHT file for details. ** ** SPDX-License-Identifier: GPL-2.0-or-later ** ** The files "system.c" and "sysfiles.c" contains all operating system ** dependent functions. This file contains all system dependent functions ** except file and stream operations, which are implemented in "sysfiles.c". ** The following labels determine which operating system is actually used.
*/
#ifdefined(__APPLE__) && defined(__MACH__) // Workaround: TRUE / FALSE are also defined by the macOS Mach-O headers #define ENUM_DYLD_BOOL #include <mach-o/dyld.h> #endif
/**************************************************************************** ** *V SyDebugLoading . . . . . . . . . output messages about loading of files
*/ Int SyDebugLoading;
/**************************************************************************** ** *V DotGapPath ** ** The path to the user's ~/.gap directory, if available.
*/ staticChar DotGapPath[GAP_PATH_MAX];
/**************************************************************************** ** *V SyLineEdit . . . . . . . . . . . . . . . . . . . . support line editing ** ** 0: no line editing ** 1: line editing if terminal ** 2: always line editing (EMACS)
*/
UInt SyLineEdit;
/**************************************************************************** ** *V SyUseReadline . . . . . . . . . . . . . . . . . . support line editing ** ** Switch for not using readline although GAP is compiled with libreadline
*/
UInt SyUseReadline;
/**************************************************************************** ** *V SyNrCols . . . . . . . . . . . . . . . . . . length of the output lines ** ** 'SyNrCols' is the length of the lines on the standard output device. ** ** Per default this is 80 characters which is the usual width of terminals. ** It can be changed by the '-x' options for larger terminals or printers. ** ** 'Pr' uses this to decide where to insert a <newline> on the output lines. ** 'SyRead' uses it to decide when to start scrolling the echoed input line. ** ** See also InitWindowSize().
*/
UInt SyNrCols;
UInt SyNrColsLocked;
/**************************************************************************** ** *V SyNrRows . . . . . . . . . . . . . . . . . number of lines on the screen ** ** 'SyNrRows' is the number of lines on the standard output device. ** ** Per default this is 24, which is the usual size of terminal screens. ** It can be changed with the '-y' option for larger terminals or printers. ** ** See also InitWindowSize().
*/
UInt SyNrRows;
UInt SyNrRowsLocked;
/**************************************************************************** ** *V SyQuiet . . . . . . . . . . . . . . . . . . . . . . . . . suppress prompt ** ** 'SyQuiet' determines whether GAP should print the prompt and the banner. ** ** Per default its false, i.e. GAP prints the prompt and the nice banner. ** It can be changed by the '-q' option to have GAP operate in silent mode. ** ** It is used by the functions in 'gap.c' to suppress printing the prompts. ** ** Put in this package because the command line processing takes place here.
*/
UInt SyQuiet;
/**************************************************************************** ** *V SyQuitOnBreak . . . . . . . . . . exit GAP instead of entering break loop ** ** 'SyQuitOnBreak' determines whether GAP should quit (with non-zero return ** value) instead of entering the break loop. ** ** False by default, can be changed with the '--quitonbreak' option. ** ** Put in this package because the command line processing takes place here.
*/
UInt SyQuitOnBreak;
/**************************************************************************** ** *V SyRestoring . . . . . . . . . . . . . . . . . . . . restoring a workspace ** ** 'SyRestoring' determines whether GAP is restoring a workspace or not. If ** it is zero no restoring should take place otherwise it holds the filename ** of a workspace to restore. **
*/ #ifdef GAP_ENABLE_SAVELOAD Char * SyRestoring; #endif
/**************************************************************************** ** *V SyInitializing set to 1 during library init ** ** 'SyInitializing' is set to 1 during the library initialization phase of ** startup. It suppresses some behaviours that may not be possible so early ** such as homogeneity tests in the plist code.
*/
UInt SyInitializing;
/**************************************************************************** ** *V SyUseModule . . . . . . . . . check for static modules in 'READ_GAP_ROOT'
*/ int SyUseModule;
/**************************************************************************** ** *V SyWindow . . . . . . . . . . . . . . . . running under a window handler ** ** 'SyWindow' is 1 if GAP is running under a window handler front end such ** as 'xgap', and 0 otherwise. ** ** If running under a window handler front end, GAP adds various commands ** starting with '@' to the output to let 'xgap' know what is going on.
*/
UInt SyWindow;
/**************************************************************************** ** *F SyExit( <ret> ) . . . . . . . . . . . . . exit GAP with return code <ret> ** ** 'SyExit' is the official way to exit GAP, bus errors are the unofficial. ** The function 'SyExit' must perform all the necessary cleanup operations. ** If ret is 0 'SyExit' should signal to a calling process that all is ok. ** If ret is 1 'SyExit' should signal a failure to the calling process.
*/ void SyExit(UInt ret)
{ #ifdef USE_JULIA_GC
jl_atexit_hook(ret); #endif exit((int)ret);
}
staticvoid usage(void)
{
fputs("usage: gap [OPTIONS] [FILES]\n", stderr);
fputs(" use '-h' option to get help.\n", stderr);
fputs("\n", stderr);
SyExit(1);
}
struct optInfo { int phase; char shortkey; char longkey[50]; int (*handler)(constchar * argv[], void *); void *otherArg;
UInt minargs;
};
#ifdef USE_GASMAN
SyMsgsFlagBags = 0;
SyStorMin = 16 * sizeof(Obj) * 1024; // in kB
SyStorMax = 256 * sizeof(Obj) * 1024; // in kB #ifdef SYS_IS_64_BIT // According to POSIX (at least since POSIX.1-2008) unistd.h always // provides _SC_PAGESIZE. However, _SC_PHYS_PAGES is not defined in POSIX // (up to at least POSIX.1-2024). But it is there (and has been for a long // time) in Linux, macOS, FreeBSD, OpenBSD, so we just use it. #ifdefined(HAVE_SYSCONF) // Set to 3/4 of memory size (in kB), if this is larger Int SyStorMaxFromMem =
(sysconf(_SC_PAGESIZE) * sysconf(_SC_PHYS_PAGES) * 3) / 4 / 1024;
SyStorMax = SyStorMaxFromMem > SyStorMax ? SyStorMaxFromMem : SyStorMax; #endif #endif// defined(SYS_IS_64_BIT)
#ifdef SYS_IS_64_BIT
SyAllocPool = 4096L*1024*1024; // Note this is in bytes! #else
SyAllocPool = 1536L*1024*1024; // Note this is in bytes! #endif// defined(SYS_IS_64_BIT)
SyStorOverrun = SY_STOR_OVERRUN_CLEAR;
SyStorKill = 0; #endif// defined(USE_GASMAN)
SyUseModule = 1;
SyWindow = 0;
}
staticvoid ParseCommandLineOptions(int argc, constchar * argv[], int phase)
{ // scan the command line for options that we have to process in the kernel // we just scan the whole command line looking for the keys for the // options we recognise anything else will presumably be dealt with in the // library while (argc > 1) {
argv++;
argc--; constchar * opt = *argv;
// look for an option starting with '-' and skip anything else if (opt[0] != '-') continue;
// all options should either have the short form `-x` or the // long form `--option`, reject anything else immediately if (strlen(opt) != 2 && opt[1] != '-') {
fputs("gap: sorry, options must not be grouped '", stderr);
fputs(opt, stderr);
fputs("'.\n", stderr);
usage();
}
// check our table of options for a match... int i = 0; while (options[i].handler != 0) {
GAP_ASSERT(options[i].shortkey != 0 ||
options[i].longkey[0] != 0);
// matching shortkey? if (options[i].shortkey == opt[1]) break;
// matching long key? if (opt[1] == '-' && opt[2] != 0 &&
!strcmp(options[i].longkey, opt + 2)) { break;
}
if (!IgnoreGapRC) {
SySetGapRootPath(DotGapPath);
} #endif
// get rid of trailing semicolon (which was added to ensure // SySetGapRootPath prepends the path to the list of root paths)
DotGapPath[strlen(DotGapPath) - 1] = '\0';
}
// second stage of command line options parsing: handle root paths
ParseCommandLineOptions(argc, argv, 1);
InitDotGapPath();
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.4Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.