My Project
Loading...
Searching...
No Matches
Functions | Variables
tesths.cc File Reference
#include "kernel/mod2.h"
#include "omalloc/omalloc.h"
#include "misc/options.h"
#include "factory/factory.h"
#include "kernel/oswrapper/feread.h"
#include "Singular/fevoices.h"
#include "kernel/oswrapper/timer.h"
#include "kernel/oswrapper/vspace.h"
#include "ipshell.h"
#include "cntrlc.h"
#include "links/silink.h"
#include "ipid.h"
#include "sdb.h"
#include "feOpt.h"
#include "misc/distrib.h"
#include "mmalloc.h"
#include "tok.h"
#include "resources/fegetopt.h"
#include "Singular/countedref.h"
#include "Singular/pyobject_setup.h"
#include <unistd.h>
#include <NTL/config.h>
#include "Singular/links/simpleipc.h"

Go to the source code of this file.

Functions

void siInit (char *)
 
int mmInit (void)
 
int main (int argc, char **argv)
 

Variables

EXTERN_VAR FILEFile_Log
 
EXTERN_VAR BOOLEAN FE_OPT_NO_SHELL_FLAG
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 66 of file tesths.cc.

69{
70 mmInit();
71 // Don't worry: ifdef OM_NDEBUG, then all these calls are undef'ed
74
75#ifdef PSINGULAR
76 global_argv0 = argv[0];
77#endif
78// how many processes ? -----------------------------------------------------
79 {
80 int cpus=1;
81 int cpu_n;
82 #ifdef _SC_NPROCESSORS_ONLN
84 #elif defined(_SC_NPROCESSORS_CONF)
86 #endif
87 #ifdef HAVE_SIMPLEIPC
89 #endif
91// how many threads ? -----------------------------------------------------
93 }
94 siInit(argv[0]);
96
97 // parse command line options
98 int optc, option_index;
99 const char* errormsg;
100 while((optc = fe_getopt_long(argc, argv,
102 != EOF)
103 {
104 if (optc == '?' || optc == 0)
105 {
106 fprintf(stderr, "Use '%s --help' for a complete list of options\n", feArgv0);
107 exit(1);
108 }
109
112
114
115 if (fe_optarg == NULL &&
116 (feOptSpec[option_index].type == feOptBool ||
119 else
121 // not more than MAX_PROCESS cpus
122
123 if (errormsg)
124 {
125 if (fe_optarg == NULL)
126 fprintf(stderr, "Error: Option '--%s' %s\n",
128 else
129 fprintf(stderr, "Error: Option '--%s=%s' %s\n",
131 fprintf(stderr, "Use '%s --help' for a complete list of options\n", feArgv0);
132 exit(1);
133 }
134 if (optc == 'h') exit(0);
135 switch(option_index)
136 {
138 exit(0);
139 break;
140 default: ;
141 }
142 }
144 #ifdef HAVE_VSPACE
146 {
149 }
150 #endif
151
152 /* say hello */
153
154 if (TEST_V_QUIET)
155 {
156 (printf)(
157" SINGULAR /"
159" Development"
160#endif
161"\n"
162" A Computer Algebra System for Polynomial Computations / version %s\n"
163" 0<\n"
164" by: W. Decker, G.-M. Greuel, G. Pfister, H. Schoenemann \\ %s\n"
165"FB Mathematik der Universitaet, D-67653 Kaiserslautern \\ Debian " DEB_PKG_VERSION "\n"
168 {
169 WarnS("running in restricted mode:"
170 " shell invocation and file links are disallowed");
172 }
173 }
174 else
175 {
178 dup2(1,2);
179 /* alternative:
180 * memcpy(stderr,stdout,sizeof(FILE));
181 */
182 }
184 {
185 int pid=getpid();
186 char *buf=(char*)malloc(10+strlen((char*) feOptSpec[FE_OPT_LOG].value));
187 snprintf(buf,10+strlen((char*) feOptSpec[FE_OPT_LOG].value),
188 "%s.%d",(char*) feOptSpec[FE_OPT_LOG].value,pid);
189 File_Log=fopen(buf,"w");
190 }
191
192#ifdef SINGULAR_PYOBJECT_SETUP_H
194#endif
195#ifdef SI_COUNTEDREF_AUTOLOAD
197#endif
198 errorreported = 0;
199
200 // -- example for "static" modules ------
201 //load_builtin("huhu.so",FALSE,(SModulFunc_t)huhu_mod_init);
202 //module_help_main("huhu.so","Help for huhu\nhaha\n");
203 //module_help_proc("huhu.so","p","Help for huhu::p\nhaha\n");
205
206 // Now, put things on the stack of stuff to do
207 // Last thing to do is to execute given scripts
208 if (fe_optind < argc)
209 {
210 int i = argc - 1;
211 FILE *fd;
212 while (i >= fe_optind)
213 {
214 if ((fd = feFopen(argv[i], "r")) == NULL)
215 {
216 Warn("Can not open %s", argv[i]);
217 }
218 else
219 {
220 fclose(fd);
221 newFile(argv[i]);
222 }
223 i--;
224 }
225 }
226 else
227 {
229 }
230
231 // before scripts, we execute -c, if it was given
234
235 // first thing, however, is to load .singularrc from Singularpath
236 // and cwd/$HOME (in that order).
238 {
239 char buf[MAXPATHLEN];
240 FILE * rc = feFopen("." DIR_SEPP ".singularrc", "r", buf);
241 if (rc == NULL) rc = feFopen("~" DIR_SEPP ".singularrc", "r", buf);
242 if (rc == NULL) rc = feFopen(".singularrc", "r", buf);
243
244 if (rc != NULL)
245 {
246 if (BVERBOSE(V_LOAD_LIB))
247 Print("// ** executing %s\n", buf);
248 fclose(rc);
249 newFile(buf);
250 }
251 }
252
253 /* start shell */
255 {
257 char *linkname=(char*) feOptValue(FE_OPT_LINK);
258 if((linkname!=NULL)&&(strcmp(linkname,"ssi")==0))
259 {
260 return ssiBatch((char*) feOptValue(FE_OPT_MPHOST),(char*) feOptValue(FE_OPT_MPPORT));
261 //Print("batch: p:%s, h:%s\n",(char*) feOptValue(FE_OPT_MPPORT),(char*) feOptValue(FE_OPT_MPHOST));
262 //exit(0);
263 }
264 else
265 {
266 Print("** missing arguments: -b requires --link/--MPhost/--MPport\n");
267 return 1;
268 }
269 }
271 yyparse();
272 m2_end(0);
273 return 0;
274}
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
void On(int sw)
switches
int i
Definition cfEzgcd.cc:132
static const int SW_USE_NTL_SORT
set to 1 to sort factors in a factorization
Definition cf_defs.h:39
VAR jmp_buf si_start_jmpbuf
Definition cntrlc.cc:98
VAR BOOLEAN singular_in_batchmode
Definition cntrlc.cc:62
void init_signals()
init signal handlers and error handling for libraries: NTL, factory
Definition cntrlc.cc:530
void countedref_init()
Definition countedref.h:458
#define Print
Definition emacs.cc:80
#define Warn
Definition emacs.cc:77
#define WarnS
Definition emacs.cc:78
char name(const Variable &v)
Definition factory.h:189
#define VERSION
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition feFopen.cc:47
VAR short errorreported
Definition feFopen.cc:23
feOptIndex
Definition feOptGen.h:15
@ FE_OPT_UNDEF
Definition feOptGen.h:15
#define LONG_OPTION_RETURN
Definition feOptTab.h:4
const char SHORT_OPTS_STRING[]
Definition feOpt.cc:29
feOptIndex feGetOptIndex(const char *name)
Definition feOpt.cc:104
const char * feSetOptValue(feOptIndex opt, char *optarg)
Definition feOpt.cc:154
static void * feOptValue(feOptIndex opt)
Definition feOpt.h:40
EXTERN_VAR struct fe_option feOptSpec[]
Definition feOpt.h:17
VAR char * feArgv0
Definition feResource.cc:19
#define DIR_SEPP
Definition feResource.h:7
int fe_getopt_long(int argc, char *const *argv, const char *options, const struct fe_option *long_options, int *opt_index)
Definition fegetopt.c:664
char * fe_optarg
Definition fegetopt.c:94
int fe_optind
Definition fegetopt.c:109
@ feOptBool
Definition fegetopt.h:77
#define optional_argument
Definition fegetopt.h:101
char * fe_fgets_dummy(const char *, char *, int)
Definition feread.cc:455
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
Definition feread.cc:32
void newBuffer(char *s, feBufferTypes t, procinfo *pi, int lineno)
Definition fevoices.cc:166
VAR Voice * currentVoice
Definition fevoices.cc:49
BOOLEAN newFile(char *fname)
Definition fevoices.cc:129
Voice * feInitStdin(Voice *pp)
Definition fevoices.cc:677
@ BT_execute
Definition fevoices.h:23
int yyparse(void)
Definition grammar.cc:2149
#define assume(x)
Definition mod2.h:389
void m2_end(int i)
Definition misc_ip.cc:1104
static const int MAX_PROCESS
Definition vspace.h:1419
#define omStrDup(s)
#define malloc
Definition omAllocFunc.c:12
#define omInitGetBackTrace()
#define NULL
Definition omList.c:12
#define MAXPATHLEN
Definition omRet2Info.c:22
#define BVERBOSE(a)
Definition options.h:35
#define TEST_V_QUIET
Definition options.h:135
#define V_LOAD_LIB
Definition options.h:47
void pyobject_setup()
initialize blackbox support for pyobject; functionilty os autoloaded on demand
int status int fd
Definition si_signals.h:69
int status int void * buf
Definition si_signals.h:69
#define SIPC_MAX_SEMAPHORES
Definition simpleipc.h:10
EXTERN_VAR FILE * File_Log
Definition tesths.cc:47
EXTERN_VAR BOOLEAN FE_OPT_NO_SHELL_FLAG
Definition tesths.cc:48
void siInit(char *)
Definition misc_ip.cc:1364
int mmInit(void)
Definition tesths.cc:50
#define omInitRet_2_Info(argv0)
Definition xalloc.h:274

◆ mmInit()

int mmInit ( void  )

Definition at line 50 of file tesths.cc.

51{
52#ifndef X_OMALLOC
53#if defined(OMALLOC_USES_MALLOC)
54 /* in mmstd.c, for some architectures freeSize() unconditionally uses the *system* free() */
55 /* sage ticket 5344: http://trac.sagemath.org/sage_trac/ticket/5344 */
56 /* do not rely on the default in Singular as libsingular may be different */
58#else
60#endif
61#endif
62 return 1;
63}
#define freeSize
Definition omAllocFunc.c:15
#define reallocSize
Definition omAllocFunc.c:17
#define omFreeSizeFunc
Definition xalloc.h:285
#define omReallocSizeFunc
Definition xalloc.h:286
#define omMallocFunc
Definition xalloc.h:284

◆ siInit()

void siInit ( char name)
extern

Definition at line 1364 of file misc_ip.cc.

1365{
1366// memory initialization: -----------------------------------------------
1367 om_Opts.OutOfMemoryFunc = omSingOutOfMemoryFunc;
1368#ifndef OM_NDEBUG
1369#ifndef __OPTIMIZE__
1370 #ifndef MAKE_DISTRUBTION
1371 om_Opts.ErrorHook = dErrorBreak;
1372 #endif
1373#else
1374 om_Opts.Keep = 0; /* !OM_NDEBUG, __OPTIMIZE__*/
1375#endif
1376#else
1377 om_Opts.Keep = 0; /* OM_NDEBUG */
1378#endif
1379 omInitInfo();
1380// factory
1381#ifndef HAVE_NTL
1382 extern void initPT();
1383 initPT();
1384#endif
1385 { // set cpus (in siInit), if SINGULAR_CPUS is set, set within the limits
1386 char *env_cpu=getenv("SINGULAR_CPUS");
1387 if (env_cpu!=NULL)
1388 {
1389 int cpu_n,cpus;
1390 #ifdef _SC_NPROCESSORS_ONLN
1392 #elif defined(_SC_NPROCESSORS_CONF)
1394 #endif
1395 #ifdef HAVE_SIMPLEIPC
1397 #endif
1398
1399 int t=atoi(env_cpu);
1400 if ((t>=0)&&(t<cpus)) cpus=t;
1402 // how many threads ? -----------------------------------------------------
1404 }
1405 }
1406// options ---------------------------------------------------------------
1407 si_opt_1=0;
1408// interpreter tables etc.: -----------------------------------------------
1409 memset(&sLastPrinted,0,sizeof(sleftv));
1411
1412 extern int iiInitArithmetic(); iiInitArithmetic(); // iparith.cc
1413
1414 basePack=(package)omAlloc0(sizeof(*basePack));
1416 idhdl h;
1417 h=enterid("Top", 0, PACKAGE_CMD, &IDROOT, FALSE);
1419 IDPACKAGE(h)->language = LANG_TOP;
1420 currPackHdl=h;
1421 basePackHdl=h;
1422
1423 coeffs_BIGINT = nInitChar(n_Q,(void*)1);
1424
1425#if 1
1426 // def HAVE_POLYEXTENSIONS
1427 if(TRUE)
1428 {
1429 n_coeffType type;
1430 #ifdef SINGULAR_4_2
1432 assume(type == n_polyExt);
1433 #endif
1434
1435 type = nRegister(n_algExt, naInitChar);
1436 assume(type == n_algExt);
1437
1439 assume(type == n_transExt);
1440
1441 (void)type;
1442 }
1443#endif
1444
1445// random generator: -----------------------------------------------
1446 {
1447 int t=startTimer();
1448 if (t==0) t=1;
1449 initRTimer();
1450 siSeed=t;
1451 factoryseed(t);
1452 siRandomStart=t;
1453 feOptSpec[FE_OPT_RANDOM].value = (void*) ((long)siRandomStart);
1454 }
1455
1456// ressource table: ----------------------------------------------------
1457 // Don't worry: ifdef OM_NDEBUG, then all these calls are undef'ed
1458 // hack such that all shared' libs in the bindir are loaded correctly
1460
1461// singular links: --------------------------------------------------
1463 myynest=0;
1464
1465// default coeffs
1466 {
1467 idhdl h;
1468 h=enterid("QQ",0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1469 IDDATA(h)=(char*)nInitChar(n_Q,NULL);
1470 h=enterid("ZZ",0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1471 IDDATA(h)=(char*)nInitChar(n_Z,NULL);
1473 iiAddCproc("kernel","crossprod",FALSE,iiCrossProd);
1474 iiAddCproc("kernel","Float",FALSE,iiFloat);
1475 //h=enterid("RR",0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1476 //IDDATA(h)=(char*)nInitChar(n_R,NULL);
1477 //h=enterid("CC",0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1478 //IDDATA(h)=(char*)nInitChar(n_long_C,NULL);
1479 }
1480// setting routines for PLURAL QRINGS:
1481// allowing to use libpolys without libSingular(kStd)
1482#ifdef HAVE_PLURAL
1483 nc_NF=k_NF;
1489#endif
1490// loading standard.lib -----------------------------------------------
1492 {
1495 si_opt_2 &= ~Sy_bit(V_LOAD_LIB);
1496 iiLibCmd("standard.lib", TRUE,TRUE,TRUE);
1498 }
1499 // interpreter error handling
1500 #ifndef __CYGWIN__
1501 factoryError=callWerrorS; // to honour later changes of variable WerrorS
1502 #endif
1503 errorreported = 0;
1504}
BOOLEAN naInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.
Definition algext.cc:1433
BOOLEAN n2pInitChar(coeffs cf, void *infoStruct)
Definition algext.cc:1687
#define BITSET
Definition auxiliary.h:85
void initPT()
void factoryseed(int s)
random seed initializer
Definition cf_random.cc:186
VAR void(* factoryError)(const char *s)
Definition cf_util.cc:80
Definition idrec.h:35
Class used for (list of) interpreter objects.
Definition subexpr.h:83
int rtyp
Definition subexpr.h:91
VAR int siRandomStart
Definition cntrlc.cc:99
n_coeffType
Definition coeffs.h:27
@ n_polyExt
used to represent polys as coefficients
Definition coeffs.h:34
@ n_Q
rational (GMP) numbers
Definition coeffs.h:30
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition coeffs.h:35
@ n_Zn
only used if HAVE_RINGS is defined
Definition coeffs.h:44
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition coeffs.h:38
@ n_Z
only used if HAVE_RINGS is defined
Definition coeffs.h:43
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:412
void feInitResources(const char *argv0)
VAR int myynest
Definition febase.cc:41
char * getenv()
EXTERN_VAR BBA_Proc gnc_gr_bba
Definition gb_hack.h:10
EXTERN_VAR BBA_Proc gnc_gr_mora
Definition gb_hack.h:10
EXTERN_VAR BBA_Proc sca_gr_bba
Definition gb_hack.h:10
EXTERN_VAR NF_Proc nc_NF
Definition gb_hack.h:9
EXTERN_VAR BBA_Proc sca_mora
Definition gb_hack.h:10
EXTERN_VAR BBA_Proc sca_bba
Definition gb_hack.h:10
ideal k_gnc_gr_bba(const ideal F, const ideal Q, const intvec *, const bigintmat *, kStrategy strat, const ring _currRing)
Definition gr_kstd2.cc:1030
ideal k_gnc_gr_mora(const ideal F, const ideal Q, const intvec *, const bigintmat *, kStrategy strat, const ring _currRing)
Definition gr_kstd2.cc:1283
int iiInitArithmetic()
initialisation of arithmetic structured data
Definition iparith.cc:9988
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition ipid.cc:279
VAR package basePack
Definition ipid.cc:56
VAR package currPack
Definition ipid.cc:55
VAR idhdl currPackHdl
Definition ipid.cc:53
VAR idhdl basePackHdl
Definition ipid.cc:54
#define IDDATA(a)
Definition ipid.h:126
#define IDROOT
Definition ipid.h:19
#define IDPACKAGE(a)
Definition ipid.h:139
int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition iplib.cc:1073
BOOLEAN iiLibCmd(const char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force)
Definition iplib.cc:894
STATIC_VAR Poly * h
Definition janet.cc:971
ideal k_sca_bba(const ideal F, const ideal Q, const intvec *, const bigintmat *, kStrategy strat, const ring _currRing)
Modified modern Sinuglar Buchberger's algorithm.
Definition sca.cc:368
ideal k_sca_gr_bba(const ideal F, const ideal Q, const intvec *, const bigintmat *, kStrategy strat, const ring _currRing)
Modified Plural's Buchberger's algorithmus.
Definition sca.cc:95
ideal k_sca_mora(const ideal F, const ideal Q, const intvec *, const bigintmat *, kStrategy strat, const ring _currRing)
Modified modern Sinuglar Mora's algorithm.
Definition sca.cc:878
poly k_NF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce, const ring _currRing)
NOTE: this is just a wrapper which sets currRing for the actual kNF call.
Definition kstd1.cc:3443
static BOOLEAN iiCrossProd(leftv res, leftv args)
Definition misc_ip.cc:1329
void omSingOutOfMemoryFunc()
Definition misc_ip.cc:1202
static BOOLEAN iiFloat(leftv res, leftv pnn)
Definition misc_ip.cc:1300
static void callWerrorS(const char *s)
Definition misc_ip.cc:1363
void dErrorBreak(void)
Definition dError.cc:140
void nRegisterCfByName(cfInitCfByNameProc p, n_coeffType n)
Definition numbers.cc:631
n_coeffType nRegister(n_coeffType n, cfInitCharProc p)
Definition numbers.cc:590
#define omAlloc0(size)
omOpts_t om_Opts
Definition omOpts.c:13
VAR unsigned si_opt_2
Definition options.c:6
VAR unsigned si_opt_1
Definition options.c:5
#define SI_SAVE_OPT(A, B)
Definition options.h:20
#define SI_RESTORE_OPT(A, B)
Definition options.h:23
VAR coeffs coeffs_BIGINT
Definition polys.cc:14
coeffs nrnInitCfByName(char *s, n_coeffType)
Definition rmodulon.cc:33
VAR int siSeed
Definition sirandom.c:30
ip_package * package
Definition structs.h:39
INST_VAR sleftv sLastPrinted
Definition subexpr.cc:46
@ LANG_TOP
Definition subexpr.h:22
int startTimer()
Definition timer.cc:66
void initRTimer()
Definition timer.cc:136
@ CRING_CMD
Definition tok.h:56
@ PACKAGE_CMD
Definition tok.h:150
#define NONE
Definition tok.h:223
BOOLEAN ntInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.
Definition transext.cc:2636
#define omInitInfo()
Definition xalloc.h:228

Variable Documentation

◆ FE_OPT_NO_SHELL_FLAG

EXTERN_VAR BOOLEAN FE_OPT_NO_SHELL_FLAG

Definition at line 48 of file tesths.cc.

◆ File_Log

EXTERN_VAR FILE* File_Log

Definition at line 47 of file tesths.cc.