[BACK]Return to init.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / pari-2.2 / src / language

Annotation of OpenXM_contrib/pari-2.2/src/language/init.c, Revision 1.1.1.1

1.1       noro        1: /* $Id: init.c,v 1.98 2001/10/01 12:11:32 karim Exp $
                      2:
                      3: Copyright (C) 2000  The PARI group.
                      4:
                      5: This file is part of the PARI/GP package.
                      6:
                      7: PARI/GP is free software; you can redistribute it and/or modify it under the
                      8: terms of the GNU General Public License as published by the Free Software
                      9: Foundation. It is distributed in the hope that it will be useful, but WITHOUT
                     10: ANY WARRANTY WHATSOEVER.
                     11:
                     12: Check the License for details. You should have received a copy of it, along
                     13: with the package; see the file 'COPYING'. If not, write to the Free Software
                     14: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
                     15:
                     16: /*******************************************************************/
                     17: /*                                                                 */
                     18: /*                INITIALIZING THE SYSTEM, ERRORS                  */
                     19: /*                                                                 */
                     20: /*******************************************************************/
                     21: #include <string.h>
                     22: #include "pari.h"
                     23: #include "anal.h"
                     24: #ifdef _WIN32
                     25: #  ifndef WINCE
                     26: #    include <process.h>
                     27: #  endif
                     28: #endif
                     29:
                     30: /*      Variables statiques communes :         */
                     31: FILE    *pari_outfile, *errfile, *logfile, *infile;
                     32: GEN     *polun, *polx;
                     33: GEN     gnil, gzero, gun, gdeux, ghalf, polvar, gi;
                     34: GEN     gpi=NULL, geuler=NULL, bernzone=NULL;
                     35: GEN     primetab; /* private primetable */
                     36: byteptr diffptr;
                     37: char    *current_logfile, *current_psfile;
                     38: int     gp_colors[c_LAST];
                     39: int     disable_color = 1, added_newline = 1;
                     40: int     under_emacs = 0, under_texmacs = 0;
                     41:
                     42: int     functions_tblsz = 135; /* size of functions_hash          */
                     43: entree  **varentries;
                     44:
                     45: void    *global_err_data;
                     46: jmp_buf environnement;
                     47: long    *ordvar;
                     48: long    DEBUGFILES,DEBUGLEVEL,DEBUGMEM,compatible;
                     49: long    prec,precdl;
                     50: ulong   init_opts = INIT_JMPm | INIT_SIGm;
                     51: ulong   top, bot, avma, memused;
                     52:
                     53: void *foreignHandler;                /* Handler for foreign commands.   */
                     54: char foreignExprSwitch = 3;          /* Just some unprobable char.      */
                     55: GEN  (*foreignExprHandler)(char*);    /* Handler for foreign expressions.*/
                     56: entree * (*foreignAutoload)(char*, long); /* Autoloader                      */
                     57: void (*foreignFuncFree)(entree *);    /* How to free external entree.    */
                     58:
                     59: int  (*default_exception_handler)(long);
                     60: GEN  (*gp_history_fun)(long, long, char *, char *);
                     61: int  (*whatnow_fun)(char *, int);
                     62: void (*output_fun)(GEN);
                     63:
                     64: extern void  initout(int initerr);
                     65: extern int   term_width(void);
                     66:
                     67: typedef struct cell {
                     68:   void *env;
                     69:   void *data;
                     70:   long flag;
                     71: } cell;
                     72:
                     73: static stack *err_catch_stack = NULL;
                     74: static long *err_catch_array;
                     75:
                     76: void
                     77: push_stack(stack **pts, void *a)
                     78: {
                     79:   stack *v = (stack*) gpmalloc(sizeof(stack));
                     80:   v->value = a;
                     81:   v->prev  = *pts; *pts = v;
                     82: }
                     83:
                     84: void *
                     85: pop_stack(stack **pts)
                     86: {
                     87:   stack *s = *pts, *v;
                     88:   void *a;
                     89:   if (!s) return NULL; /* initial value */
                     90:   v = s->prev; *pts = v;
                     91:   a = s->value; free((void*)s);
                     92:   return a;
                     93: }
                     94:
                     95: #ifdef STACK_CHECK
                     96: /*********************************************************************/
                     97: /*                                                                   */
                     98: /*                       C STACK SIZE CONTROL                        */
                     99: /*             (to avoid core dump on deep recursion)                */
                    100: /*                                                                   */
                    101: /*********************************************************************/
                    102:
                    103: /* adapted from Perl code written by Dominic Dunlop */
                    104: #include <sys/resource.h>
                    105: void *PARI_stack_limit = NULL;
                    106:
                    107: /* Set PARI_stack_limit to (a little above) the lowest safe address that can
                    108:  * be used on the stack. Leave PARI_stack_limit at its initial value (NULL)
                    109:  * to show no check should be made [init failed]. Assume stack grows downward.
                    110:  */
                    111: static void
                    112: pari_init_stackcheck(void *stack_base)
                    113: {
                    114:   struct rlimit rip;
                    115:
                    116:   if (getrlimit(RLIMIT_STACK, &rip) || rip.rlim_cur  == RLIM_INFINITY) return;
                    117: /* DEC cc doesn't like this line:
                    118:  * PARI_stack_limit = stack_base - ((rip.rlim_cur/16)*15); */
                    119:   PARI_stack_limit = (void*)((long)stack_base - (rip.rlim_cur/16)*15);
                    120: }
                    121: #endif /* STACK_CHECK */
                    122:
                    123: /*********************************************************************/
                    124: /*                                                                   */
                    125: /*                       SYSTEM INITIALIZATION                       */
                    126: /*                                                                   */
                    127: /*********************************************************************/
                    128: static int var_not_changed; /* altered in reorder() */
                    129: static int try_to_recover = 0;
                    130: static long next_bloc;
                    131: static GEN cur_bloc=NULL; /* current bloc in bloc list */
                    132: static long *universal_constants;
                    133:
                    134: static void
                    135: pari_handle_SIGINT()
                    136: {
                    137: #ifdef _WIN32
                    138:   if (++win32ctrlc >= 5) _exit(3);
                    139: #else
                    140:   err(talker, "user interrupt");
                    141: #endif
                    142: }
                    143:
                    144: static void
                    145: pari_sighandler(int sig)
                    146: {
                    147:   char *msg;
                    148:   os_signal(sig,pari_sighandler);
                    149:   switch(sig)
                    150:   {
                    151: #ifdef SIGBREAK
                    152:     case SIGBREAK: pari_handle_SIGINT(); return;
                    153: #endif
                    154: #ifdef SIGINT
                    155:     case SIGINT:   pari_handle_SIGINT(); return;
                    156: #endif
                    157:
                    158: #ifdef SIGSEGV
                    159:     case SIGSEGV:
                    160:       msg="segmentation fault: bug in PARI or calling program";
                    161:       break;
                    162: #endif
                    163:
                    164: #ifdef SIGBUS
                    165:     case SIGBUS:
                    166:       msg="bus error: bug in PARI or calling program";
                    167:       break;
                    168: #endif
                    169:
                    170: #ifdef SIGFPE
                    171:     case SIGFPE:
                    172:       msg="floating point exception: bug in PARI or calling program";
                    173:       break;
                    174: #endif
                    175:
                    176: #ifdef SIGPIPE
                    177:     case SIGPIPE:
                    178:       msg="broken pipe";
                    179:       break;
                    180: #endif
                    181:
                    182:     default:
                    183:       msg="unknown signal";
                    184:   }
                    185:   err(talker,msg);
                    186: }
                    187:
                    188: #ifdef _WIN32
                    189: int win32ctrlc = 0;
                    190:
                    191: void
                    192: dowin32ctrlc()
                    193: {
                    194:    win32ctrlc = 0;
                    195:    err(talker,"user interrupt");
                    196: }
                    197: #endif
                    198:
                    199: /* Initialize hashtable */
                    200: static void
                    201: init_hashtable(entree **table, int tblsz)
                    202: {
                    203:   entree *ep, *ep1, *last;
                    204:   long i, v;
                    205:
                    206:   for (i = 0; i < tblsz; i++)
                    207:   {
                    208:     last = NULL; ep = table[i]; table[i] = NULL;
                    209:     for ( ; ep; ep = ep1)
                    210:     {
                    211:       ep1 = ep->next; v = EpVALENCE(ep);
                    212:       if (v == EpVAR || v == EpINSTALL) /* keep this one */
                    213:       {
                    214:         if (last)
                    215:           last->next = ep;
                    216:         else
                    217:           table[i] = ep;
                    218:         last = ep; last->next = NULL;
                    219:       }
                    220:       else freeep(ep);
                    221:     }
                    222:   }
                    223: }
                    224:
                    225: static void
                    226: fill_hashtable(entree **table, entree *ep, char **helpmessage)
                    227: {
                    228:   long n;
                    229:
                    230:   for ( ; ep->name; ep++)
                    231:   {
                    232:     EpSETSTATIC(ep);
                    233:     ep->help = helpmessage? *helpmessage++: NULL;
                    234:     n = hashvalue(ep->name);
                    235:     ep->next = table[n]; table[n] = ep;
                    236:     ep->args = NULL;
                    237:   }
                    238: }
                    239:
                    240: void
                    241: init_defaults(int force)
                    242: {
                    243:   static int done=0;
                    244:
                    245:   if (done && !force) return;
                    246:   done = 1;
                    247:
                    248: #ifdef LONG_IS_64BIT
                    249:   prec=4;
                    250: #else
                    251:   prec=5;
                    252: #endif
                    253:
                    254:   precdl = 16;
                    255:   compatible = NONE;
                    256:   DEBUGFILES = DEBUGLEVEL = DEBUGMEM = 0;
                    257:
                    258:   current_psfile = pari_strdup("pari.ps");
                    259:   current_logfile= pari_strdup("pari.log");
                    260:   logfile = NULL;
                    261:   initout(1); next_bloc=0;
                    262: }
                    263:
                    264: /* does elt belong to list, after position start (excluded) ? */
                    265: static int
                    266: list_isin(void **list, void *elt, int start)
                    267: {
                    268:   long indelt=0;
                    269:
                    270:   if (list)
                    271:   {
                    272:     while (*list)
                    273:     {
                    274:       if (indelt>start && *list==elt) return indelt;
                    275:       list++; indelt++;
                    276:     }
                    277:   }
                    278:   return -1;
                    279: }
                    280:
                    281: static void
                    282: list_prepend(void ***listptr, void *elt)
                    283: {
                    284:   void **list=*listptr;
                    285:   long nbelt=0;
                    286:
                    287:   if (list)
                    288:     while (list[nbelt]) nbelt++;
                    289:   list = (void **) gpmalloc(sizeof(void *)*(nbelt+2));
                    290:   list[0]=elt;
                    291:   if (nbelt)
                    292:   {
                    293:     memcpy(list+1,*listptr,nbelt*sizeof(void *));
                    294:     free(*listptr);
                    295:   }
                    296:   list[nbelt+1]=NULL; *listptr=list;
                    297: }
                    298:
                    299: /* Load modlist in hashtable hash. If force == 0, do not load twice the
                    300:  * same list in the same hashtable, which would only destroy user variables.
                    301:  * As it stands keep a complete history (instead of most recent changes).
                    302:  */
                    303: int
                    304: gp_init_entrees(module *modlist, entree **hash, int force)
                    305: {
                    306:   static void **oldmodlist=NULL, **oldhash=NULL;
                    307:
                    308:   if (!force)
                    309:   {
                    310:     const long indhash = list_isin(oldhash,(void *)hash,-1);
                    311:     if (indhash != -1 && oldmodlist[indhash]==modlist) return 0;
                    312:   }
                    313:   /* record the new pair (hash,modlist) */
                    314:   list_prepend(&oldmodlist,(void *)modlist);
                    315:   list_prepend(&oldhash,(void *)hash);
                    316:
                    317:   init_hashtable(hash,functions_tblsz);
                    318:   while (modlist && modlist->func)
                    319:   {
                    320:     fill_hashtable(hash, modlist->func, modlist->help);
                    321:     modlist++;
                    322:   }
                    323:   return (hash == functions_hash);
                    324: }
                    325:
                    326: module *pari_modules    = NULL;
                    327: module *pari_oldmodules = NULL;
                    328: module *pari_membermodules = NULL;
                    329: entree **functions_hash = NULL;
                    330: entree **funct_old_hash = NULL;
                    331: entree **members_hash   = NULL;
                    332:
                    333: /* add to modlist the functions in func, with helpmsg help */
                    334: void
                    335: pari_addfunctions(module **modlist_p, entree *func, char **help)
                    336: {
                    337:   module *modlist = *modlist_p;
                    338:   int nbmodules = 0;
                    339:
                    340:   while (modlist && modlist->func) { nbmodules++; modlist++; }
                    341:   modlist = *modlist_p;
                    342:   *modlist_p = (module*) gpmalloc(sizeof(module)*(nbmodules+2));
                    343:   if (nbmodules)
                    344:   {
                    345:     memcpy(1+ *modlist_p, modlist, sizeof(module)*nbmodules);
                    346:     free(modlist);
                    347:   }
                    348:   modlist = *modlist_p;
                    349:   modlist->func = func;
                    350:   modlist->help = help;
                    351:
                    352:   modlist += nbmodules+1;
                    353:   modlist->func = NULL;
                    354:   modlist->help = NULL;
                    355: }
                    356:
                    357: static long
                    358: fix_size(long a)
                    359: {
                    360:   /* BYTES_IN_LONG*ceil(a/BYTES_IN_LONG) */
                    361:   ulong b = a+BYTES_IN_LONG - (((a-1) & (BYTES_IN_LONG-1)) + 1);
                    362:   if (b > VERYBIGINT) err(talker,"stack too large");
                    363:   return b;
                    364: }
                    365:
                    366: void
                    367: pari_sig_init(void (*f)(int))
                    368: {
                    369: #ifdef SIGBUS
                    370:   (void)os_signal(SIGBUS,f);
                    371: #endif
                    372: #ifdef SIGFPE
                    373:   (void)os_signal(SIGFPE,f);
                    374: #endif
                    375: #ifdef SIGINT
                    376:   (void)os_signal(SIGINT,f);
                    377: #endif
                    378: #ifdef SIGBREAK
                    379:   (void)os_signal(SIGBREAK,f);
                    380: #endif
                    381: #ifdef SIGPIPE
                    382:   (void)os_signal(SIGPIPE,f);
                    383: #endif
                    384: #ifdef SIGSEGV
                    385:   (void)os_signal(SIGSEGV,f);
                    386: #endif
                    387: }
                    388:
                    389: static void
                    390: reset_traps(int warn)
                    391: {
                    392:   long i;
                    393:   if (warn) err(warner,"missing cell in err_catch_stack. Resetting all traps");
                    394:   for (i=0; i <= noer; i++) err_catch_array[i] = 0;
                    395: }
                    396:
                    397: /* initialise les donnees de la bibliotheque PARI. Peut être précédée d'un
                    398:  * appel à pari_addfunctions si on ajoute d'autres fonctions au pool de base.
                    399:  */
                    400: void
                    401: pari_init(long parisize, long maxprime)
                    402: {
                    403:   long i, size;
                    404:   GEN p;
                    405:
                    406: #ifdef STACK_CHECK
                    407:   pari_init_stackcheck(&i);
                    408: #endif
                    409:   init_defaults(0);
                    410:   if (INIT_JMP && setjmp(environnement))
                    411:   {
                    412:     fprintferr("  ***   Error in the PARI system. End of program.\n");
                    413:     exit(1);
                    414:   }
                    415:   if (INIT_SIG) pari_sig_init(pari_sighandler);
                    416:   size = fix_size(parisize);
                    417: #if __MWERKS__
                    418:   {
                    419:     OSErr resultCode;
                    420:     Handle newHand = TempNewHandle(size,&resultCode);
                    421:
                    422:     if (!newHand) err(memer);
                    423:     HLock(newHand);
                    424:     bot = (long)*newHand;
                    425:   }
                    426: #else
                    427:   bot = (long) gpmalloc(size);
                    428: #endif
                    429:   top = avma = memused = bot+size;
                    430:   diffptr = initprimes(maxprime);
                    431:
                    432:   varentries = (entree**) gpmalloc((MAXVARN+1)*sizeof(entree*));
                    433:   polvar = (GEN) gpmalloc((MAXVARN+1)*sizeof(long));
                    434:   ordvar = (GEN) gpmalloc((MAXVARN+1)*sizeof(long));
                    435:   polx  = (GEN*) gpmalloc((MAXVARN+1)*sizeof(GEN));
                    436:   polun = (GEN*) gpmalloc((MAXVARN+1)*sizeof(GEN));
                    437:   polvar[0] = evaltyp(t_VEC) | evallg(1);
                    438:   for (i=0; i <= MAXVARN; i++) { ordvar[i] = i; varentries[i] = NULL; }
                    439:
                    440:   /* 2 (gnil) + 2 (gzero) + 3 (gun) + 3 (gdeux) + 3 (half) + 3 (gi) */
                    441:   p = universal_constants = (long *) gpmalloc(16*sizeof(long));
                    442:
                    443:   gzero = p; p+=2; gnil = p; p+=2;
                    444:   gzero[0] = gnil[0] = evaltyp(t_INT) | evallg(2);
                    445:   gzero[1] = gnil[1] = evallgefint(2);
                    446:
                    447:   gun = p; p+=3; gdeux = p; p+=3;
                    448:   gun[0] = gdeux[0] = evaltyp(t_INT) | evallg(3);
                    449:   gun[1] = gdeux[1] = evalsigne(1) | evallgefint(3);
                    450:   gun[2] = 1; gdeux[2]= 2;
                    451:
                    452:   ghalf = p; p+=3; gi = p; p+=3;
                    453:   ghalf[0] = evaltyp(t_FRAC) | evallg(3);
                    454:   ghalf[1] = un;
                    455:   ghalf[2] = deux;
                    456:   gi[0] = evaltyp(t_COMPLEX) | evallg(3);
                    457:   gi[1] = zero;
                    458:   gi[2] = un;
                    459:   fetch_var(); /* create polx/polun[MAXVARN] */
                    460:   primetab = (GEN) gpmalloc(1 * sizeof(long));
                    461:   primetab[0] = evaltyp(t_VEC) | evallg(1);
                    462:
                    463:   pari_addfunctions(&pari_modules, functions_basic,helpmessages_basic);
                    464:   functions_hash = (entree **) gpmalloc(sizeof(entree*)*functions_tblsz);
                    465:   for (i = 0; i < functions_tblsz; i++) functions_hash[i] = NULL;
                    466:
                    467:   pari_addfunctions(&pari_oldmodules, oldfonctions,oldhelpmessage);
                    468:   funct_old_hash = (entree **) gpmalloc(sizeof(entree*)*functions_tblsz);
                    469:   for (i = 0; i < functions_tblsz; i++) funct_old_hash[i] = NULL;
                    470:   gp_init_entrees(pari_oldmodules, funct_old_hash, 1);
                    471:
                    472:   if (new_fun_set)
                    473:     gp_init_entrees(pari_modules, functions_hash, 1);
                    474:   else
                    475:     gp_init_entrees(pari_oldmodules, functions_hash, 1);
                    476:
                    477:   pari_addfunctions(&pari_membermodules, gp_member_list, NULL);
                    478:   members_hash = (entree **) gpmalloc(sizeof(entree*)*functions_tblsz);
                    479:   for (i = 0; i < functions_tblsz; i++) members_hash[i] = NULL;
                    480:   gp_init_entrees(pari_membermodules, members_hash, 1);
                    481:
                    482:   gp_history_fun = NULL;
                    483:   whatnow_fun = NULL;
                    484:   output_fun = &outbrute;
                    485:   err_catch_array = (long *) gpmalloc((noer + 1) *sizeof(long));
                    486:   reset_traps(0);
                    487:   default_exception_handler = NULL;
                    488:
                    489:   (void)manage_var(2,NULL); /* init nvar */
                    490:   (void)get_timer(-1); /* init timers */
                    491:   var_not_changed = 1; fetch_named_var("x", 0);
                    492:   try_to_recover=1;
                    493: }
                    494:
                    495: void
                    496: freeall(void)
                    497: {
                    498:   long i;
                    499:   entree *ep,*ep1;
                    500:
                    501:   while (delete_var()) /* empty */;
                    502:   for (i = 0; i < functions_tblsz; i++)
                    503:   {
                    504:     for (ep = functions_hash[i]; ep; ep = ep1)
                    505:     {
                    506:       ep1 = ep->next; freeep(ep);
                    507:     }
                    508:     for (ep = members_hash[i]; ep; ep = ep1)
                    509:     {
                    510:       ep1 = ep->next; freeep(ep);
                    511:     }
                    512:   }
                    513:   free((void*)varentries); free((void*)ordvar); free((void*)polvar);
                    514:   free((void*)polx[MAXVARN]); free((void*)polx); free((void*)polun);
                    515:   free((void*)primetab);
                    516:   free((void*)universal_constants);
                    517:
                    518:   /* set first cell to 0 to inhibit recursion in all cases */
                    519:   while (cur_bloc) { *cur_bloc=0; killbloc(cur_bloc); }
                    520:   killallfiles(1);
                    521:   free((void *)functions_hash);
                    522:   free((void *)bot); free((void *)diffptr);
                    523:   free(current_logfile);
                    524:   free(current_psfile);
                    525:
                    526:   if (gp_history_fun)
                    527:     gp_history_fun(0,-1,NULL,NULL);
                    528: }
                    529:
                    530: GEN
                    531: getheap(void)
                    532: {
                    533:   long m=0,l=0;
                    534:   GEN x;
                    535:
                    536:   for (x = cur_bloc; x; x = (GEN)bl_prev(x))
                    537:   {
                    538:     m++; l+=4;
                    539:     if (! x[0]) /* user function */
                    540:       l += (strlen((char *)(x+2))) / sizeof(long);
                    541:     else if (x==bernzone)
                    542:       l += x[0];
                    543:     else /* GEN */
                    544:       l += taille(x);
                    545:   }
                    546:   x=cgetg(3,t_VEC); x[1]=lstoi(m); x[2]=lstoi(l);
                    547:   return x;
                    548: }
                    549:
                    550: /* Return x, where:
                    551:  * x[-3]: adress of next bloc
                    552:  * x[-2]: adress of preceding bloc.
                    553:  * x[-1]: number of allocated blocs.
                    554:  * x[0..n-1]: malloc-ed memory.
                    555:  */
                    556: GEN
                    557: newbloc(long n)
                    558: {
                    559:   long *x = (long *) gpmalloc((n + BL_HEAD)*sizeof(long)) + BL_HEAD;
                    560:
                    561:   bl_next(x) = 0; /* the NULL address */
                    562:   bl_prev(x) = (long)cur_bloc;
                    563:   bl_num(x)  = next_bloc++;
                    564:   if (n) *x = 0; /* initialize first cell to 0. See killbloc */
                    565:   if (cur_bloc) bl_next(cur_bloc) = (long)x;
                    566:   if (DEBUGMEM)
                    567:   {
                    568:     if (!n) err(warner,"mallocing NULL object in newbloc");
                    569:     if (DEBUGMEM > 2)
                    570:       fprintferr("new bloc, size %6ld (no %ld): %08lx\n", n, next_bloc-1, x);
                    571:   }
                    572:   return cur_bloc = x;
                    573: }
                    574:
                    575: void
                    576: killbloc0(GEN x, int inspect)
                    577: {
                    578:   long tx,lx,l,i,j;
                    579:   GEN p1;
                    580:
                    581:   if (!x || isonstack(x)) return;
                    582:   if (bl_next(x)) bl_prev(bl_next(x)) = bl_prev(x);
                    583:   else
                    584:   {
                    585:     cur_bloc = (GEN)bl_prev(x);
                    586:     next_bloc = bl_num(x);
                    587:   }
                    588:   if (bl_prev(x)) bl_next(bl_prev(x)) = bl_next(x);
                    589:   if (DEBUGMEM > 2)
                    590:     fprintferr("killing bloc (no %ld): %08lx\n", bl_num(x), x);
                    591:   if (inspect)
                    592:   {
                    593:     /* FIXME: SIGINT should be blocked at this point */
                    594:     tx=typ(x); /* if x is not a GEN, we will have tx=0 */
                    595:     if (is_vec_t(tx))
                    596:     {
                    597:       lx = lg(x);
                    598:       for (i=1;i<lx;i++)
                    599:       {
                    600:         p1=(GEN)x[i];
                    601:         if (isclone(p1)) killbloc(p1);
                    602:       }
                    603:     }
                    604:     else if (tx==t_MAT)
                    605:     {
                    606:       lx = lg(x);
                    607:       if (lx>1)
                    608:       {
                    609:         l=lg(x[1]);
                    610:         if (l>1)
                    611:           for (i=1;i<lx;i++)
                    612:             for (j=1;j<l;j++)
                    613:             {
                    614:               p1=gmael(x,i,j);
                    615:               if (isclone(p1)) killbloc(p1);
                    616:             }
                    617:       }
                    618:     }
                    619:     else if (tx==t_LIST)
                    620:     {
                    621:       lx = lgef(x);
                    622:       for (i=2;i<lx;i++)
                    623:       {
                    624:         p1=(GEN)x[i];
                    625:         if (isclone(p1)) killbloc(p1);
                    626:       }
                    627:     }
                    628:     unsetisclone(x);
                    629:     /* FIXME: SIGINT should be released here */
                    630:   }
                    631:   free((void *)bl_base(x));
                    632: }
                    633: void
                    634: killbloc(GEN x) { killbloc0(x,1); }
                    635: void
                    636: gunclone(GEN x) { killbloc0(x,0); }
                    637:
                    638: /********************************************************************/
                    639: /**                                                                **/
                    640: /**                       VARIABLE ORDERING                        **/
                    641: /**                                                                **/
                    642: /********************************************************************/
                    643:
                    644: /* Substitution globale des composantes du vecteur y aux variables de x */
                    645: GEN
                    646: changevar(GEN x, GEN y)
                    647: {
                    648:   long tx,ty,lx,vx,vy,i,av,tetpil;
                    649:   GEN  p1,p2,z;
                    650:
                    651:   if (var_not_changed && y==polvar) return x;
                    652:   tx=typ(x); if (!is_recursive_t(tx)) return gcopy(x);
                    653:   ty=typ(y); if (! is_vec_t(ty)) err(changer1);
                    654:   if (is_scalar_t(tx))
                    655:   {
                    656:     if (tx!=t_POLMOD) return gcopy(x);
                    657:     av=avma;
                    658:     p1=changevar((GEN)x[1],y);
                    659:     p2=changevar((GEN)x[2],y); tetpil=avma;
                    660:     return gerepile(av,tetpil, gmodulcp(p2,p1));
                    661:   }
                    662:   if (is_rfrac_t(tx))
                    663:   {
                    664:     av=avma;
                    665:     p1=changevar((GEN)x[1],y);
                    666:     p2=changevar((GEN)x[2],y); tetpil=avma;
                    667:     return gerepile(av,tetpil, gdiv(p1,p2));
                    668:   }
                    669:
                    670:   lx = (tx==t_POL)? lgef(x): lg(x);
                    671:   if (tx == t_POL || tx == t_SER)
                    672:   {
                    673:     vx=varn(x)+1; if (vx>=lg(y)) return gcopy(x);
                    674:     p1=(GEN)y[vx];
                    675:     if (!signe(x))
                    676:     {
                    677:       vy=gvar(p1); if (vy>MAXVARN) err(changer1);
                    678:       z=gcopy(x); setvarn(z,vy); return z;
                    679:     }
                    680:     av=avma; p2=changevar((GEN)x[lx-1],y);
                    681:     for (i=lx-2; i>=2; i--)
                    682:     {
                    683:       p2 = gmul(p2,p1);
                    684:       p2 = gadd(p2, changevar((GEN)x[i],y));
                    685:     }
                    686:     if (tx==t_SER)
                    687:     {
                    688:       p2 = gadd(p2, ggrando(p1,lx-2));
                    689:       if (valp(x))
                    690:         p2 = gmul(gpuigs(p1,valp(x)), p2);
                    691:     }
                    692:     return gerepileupto(av,p2);
                    693:   }
                    694:   z=cgetg(lx,tx);
                    695:   for (i=1; i<lx; i++) z[i]=lchangevar((GEN)x[i],y);
                    696:   return z;
                    697: }
                    698:
                    699: GEN
                    700: reorder(GEN x)
                    701: {
                    702:   long tx,lx,i,n, nvar = manage_var(3,NULL);
                    703:   int *var,*varsort,*t1;
                    704:
                    705:   if (!x) return polvar;
                    706:   tx=typ(x); lx=lg(x)-1;
                    707:   if (! is_vec_t(tx)) err(typeer,"reorder");
                    708:   if (! lx) return polvar;
                    709:
                    710:   varsort = (int *) gpmalloc(lx*sizeof(int));
                    711:   var = (int *) gpmalloc(lx*sizeof(int));
                    712:   t1 = (int *) gpmalloc(nvar*sizeof(int));
                    713:
                    714:   for (n=0; n<nvar; n++) t1[n] = 0;
                    715:   for (n=0; n<lx; n++)
                    716:   {
                    717:     var[n] = i = gvar((GEN)x[n+1]);
                    718:     varsort[n] = ordvar[var[n]]; /* position in polvar */
                    719:     if (i >= nvar) err(talker,"variable out of range in reorder");
                    720:     /* check if x is a permutation */
                    721:     if (t1[i]) err(talker,"duplicated indeterminates in reorder");
                    722:     t1[i] = 1;
                    723:   }
                    724:   qsort(varsort,lx,sizeof(int),(QSCOMP)pari_compare_int);
                    725:
                    726:   for (n=0; n<lx; n++)
                    727:   {
                    728:     /* variables are numbered 0,1 etc... while polvar starts at 1. */
                    729:     polvar[varsort[n]+1] = lpolx[var[n]];
                    730:     ordvar[var[n]] = varsort[n];
                    731:   }
                    732:
                    733:   var_not_changed=1;
                    734:   for (i=0; i<nvar; i++)
                    735:     if (ordvar[i]!=i) { var_not_changed=0; break; }
                    736:
                    737:   free(t1); free(var); free(varsort);
                    738:   return polvar;
                    739: }
                    740:
                    741: /*******************************************************************/
                    742: /*                                                                 */
                    743: /*                         ERROR RECOVERY                          */
                    744: /*                                                                 */
                    745: /*******************************************************************/
                    746: extern int pop_val_if_newer(entree *ep, long loc);
                    747: extern void kill_from_hashlist(entree *ep);
                    748:
                    749: /* if flag = 0: record address of next bloc allocated.
                    750:  * if flag = 1: (after an error) recover all memory allocated since last call
                    751:  */
                    752: void
                    753: recover(int flag)
                    754: {
                    755:   static long listloc;
                    756:   long n;
                    757:   entree *ep, *epnext;
                    758:   void (*sigfun)(int);
                    759:
                    760:   if (!flag) { listloc = next_bloc; return; }
                    761:
                    762:  /* disable recover() and SIGINT. Better: sigint_[block|release] as in
                    763:   * readline/rltty.c ? */
                    764:   try_to_recover=0;
                    765:   sigfun = os_signal(SIGINT, SIG_IGN);
                    766:
                    767:   for (n = 0; n < functions_tblsz; n++)
                    768:     for (ep = functions_hash[n]; ep; ep = epnext)
                    769:     {
                    770:       epnext = ep->next;
                    771:       switch(EpVALENCE(ep))
                    772:       {
                    773:         case EpVAR:
                    774:           while (pop_val_if_newer(ep,listloc)) /* empty */;
                    775:           break;
                    776:         case EpNEW:
                    777:           kill_from_hashlist(ep);
                    778:           break;
                    779:         case EpUSER:
                    780:         case EpALIAS:
                    781:         case EpMEMBER:
                    782:           if (bl_num(ep->value) >= listloc)
                    783:           {
                    784:             gunclone((GEN)ep->value);
                    785:             ep->value = (void*)initial_value(ep);
                    786:             kill_from_hashlist(ep);
                    787:           }
                    788:       }
                    789:     }
                    790: #if 0
                    791:  /* This causes SEGV on lists and GP-2.0 vectors: internal component is
                    792:   * destroyed while global object is not updated. Two solutions:
                    793:   *  - comment it out: should not be a big memory problem except for huge
                    794:   *  vec. components. Has the added advantadge that the results computed so
                    795:   *  far are not lost.
                    796:   *
                    797:   *  - tag every variable whose component has been modified in the last
                    798:   *  cycle. Untag it at the begining of each cycle. Maybe this should be
                    799:   *  done. But do we really want to destroy a huge global vector if one of
                    800:   *  its components was modified before the error ? (we don't copy the whole
                    801:   *  thing anymore). K.B.
                    802:   */
                    803:   {
                    804:     GEN y;
                    805:     for (x = cur_bloc; x && bl_num(x) >= listloc; x = y)
                    806:     {
                    807:       y = (GEN)bl_prev(x);
                    808:       if (x != gpi && x != geuler && x != bernzone) killbloc(x);
                    809:     }
                    810:   }
                    811: #endif
                    812:   try_to_recover=1;
                    813:   os_signal(SIGINT, sigfun);
                    814: }
                    815:
                    816: void
                    817: disable_dbg(long val)
                    818: {
                    819:   static long oldval = -1;
                    820:   if (val < 0)
                    821:   {
                    822:     if (oldval >= 0) { DEBUGLEVEL = oldval; oldval = -1; }
                    823:   }
                    824:   else if (DEBUGLEVEL)
                    825:     { oldval = DEBUGLEVEL; DEBUGLEVEL = val; }
                    826: }
                    827:
                    828: #define MAX_PAST 25
                    829: #define STR_LEN 20
                    830: /* Outputs a beautiful error message (not \n terminated)
                    831:  *   msg is errmessage to print.
                    832:  *   s points to the offending chars.
                    833:  *   entry tells how much we can go back from s[0].
                    834:  */
                    835: void
                    836: errcontext(char *msg, char *s, char *entry)
                    837: {
                    838:   int past = (s-entry);
                    839:   char str[STR_LEN + 2];
                    840:   char *buf, *t, *pre;
                    841:
                    842:   if (!s || !entry) { print_prefixed_text(msg,"  ***   ",NULL); return; }
                    843:
                    844:   t = buf = gpmalloc(strlen(msg) + MAX_PAST + 5 + 2 * 16);
                    845:   sprintf(t,"%s: ", msg);
                    846:   if (past <= 0) past = 0;
                    847:   else
                    848:   {
                    849:     t += strlen(t);
                    850:     if (past > MAX_PAST) { past=MAX_PAST; strcpy(t, "..."); t += 3; }
                    851:     strcpy(t, term_get_color(c_OUTPUT));
                    852:     t += strlen(t);
                    853:     strncpy(t, s - past, past); t[past] = 0;
                    854:   }
                    855:
                    856:   t = str; if (!past) *t++ = ' ';
                    857:   strncpy(t, s, STR_LEN); t[STR_LEN] = 0;
                    858:   pre = gpmalloc(2 * 16 + 1);
                    859:   strcpy(pre, term_get_color(c_ERR));
                    860:   strcat(pre, "  ***   ");
                    861:   print_prefixed_text(buf, pre, str);
                    862:   free(buf); free(pre);
                    863: }
                    864:
                    865: void *
                    866: err_catch(long errnum, jmp_buf env, void *data)
                    867: {
                    868:   cell *v = (cell*)gpmalloc(sizeof(cell));
                    869:   if (errnum < 0) errnum = noer;
                    870:   v->data = data;
                    871:   v->env  = env;
                    872:   v->flag = errnum;
                    873:   err_catch_array[errnum]++;
                    874:   push_stack(&err_catch_stack, (void*)v);
                    875:   return (void*)v;
                    876: }
                    877:
                    878: /* reset traps younger than V (included) */
                    879: void
                    880: err_leave(void **V)
                    881: {
                    882:   cell *t, *v = (cell*)*V;
                    883:
                    884:   for (;;)
                    885:   {
                    886:     t = (cell*)pop_stack(&err_catch_stack);
                    887:     if (t == v || !t) break;
                    888:     err_catch_array[t->flag]--;
                    889:     free(t);
                    890:   }
                    891:   if (!t) reset_traps(1);
                    892:   err_catch_array[v->flag]--;
                    893:   free(v);
                    894: }
                    895:
                    896: /* get last (most recent) handler for error n */
                    897: static cell *
                    898: err_seek(long n)
                    899: {
                    900:   stack *s = err_catch_stack;
                    901:   cell *t = NULL;
                    902:
                    903:   for (;s; s = s->prev)
                    904:   {
                    905:     t = (cell*)s->value;
                    906:     if (!t || t->flag == n) break;
                    907:   }
                    908:   if (!t) reset_traps(1);
                    909:   return t;
                    910: }
                    911:
                    912: /* kill last handler for error n */
                    913: void
                    914: err_leave_default(long n)
                    915: {
                    916:   stack *s = err_catch_stack, *lasts = NULL;
                    917:   cell *c;
                    918:
                    919:   if (n < 0) n = noer;
                    920:   if (!s || !err_catch_array[n]) return;
                    921:   for (;s; s = s->prev)
                    922:   {
                    923:     c = (cell*)s->value;
                    924:     if (c->flag == n)
                    925:     { /* kill */
                    926:       stack *v = s->prev;
                    927:       free((void*)s); s = v;
                    928:       if (lasts) lasts->prev = s;
                    929:       break;
                    930:     }
                    931:     else lasts = s;
                    932:   }
                    933:   if (!lasts)
                    934:   {
                    935:     err_catch_stack = s;
                    936:     if (!s) reset_traps(0);
                    937:   }
                    938: }
                    939:
                    940: /* untrapped error: remove all traps depending from a longjmp */
                    941: void
                    942: err_clean()
                    943: {
                    944:   stack *s = err_catch_stack, *lasts = NULL;
                    945:   cell *c;
                    946:
                    947:   if (!s) return;
                    948:   while (s)
                    949:   {
                    950:     c = (cell*)s->value;
                    951:     if (c->env)
                    952:     { /* kill */
                    953:       stack *v = s->prev;
                    954:       free((void*)s); s = v;
                    955:       if (lasts) lasts->prev = s;
                    956:     }
                    957:     else
                    958:     { /* preserve */
                    959:       if (lasts) lasts->prev = s; else err_catch_stack = s;
                    960:       lasts = s; s = s->prev;
                    961:     }
                    962:   }
                    963:   if (!lasts)
                    964:   {
                    965:     err_catch_stack = NULL;
                    966:     reset_traps(0);
                    967:   }
                    968: }
                    969:
                    970: static int
                    971: is_warn(long num)
                    972: {
                    973:   return num == warner || num == warnmem || num == warnfile || num == warnprec;
                    974: }
                    975:
                    976: void
                    977: err_recover(long numerr)
                    978: {
                    979:   initout(0);
                    980:   disable_dbg(-1);
                    981:   get_timer(-1);
                    982:   killallfiles(0);
                    983:
                    984:   if (pariErr->die) pariErr->die();    /* Caller wants to catch exceptions? */
                    985:   global_err_data = NULL;
                    986:   err_clean();
                    987:   fprintferr("\n"); flusherr();
                    988:   if (!environnement) exit(1);
                    989:
                    990:   /* reclaim memory stored in "blocs" */
                    991:   if (try_to_recover) recover(1);
                    992:   longjmp(environnement, numerr);
                    993: }
                    994:
                    995: void
                    996: err(long numerr, ...)
                    997: {
                    998:   char s[128], *ch1;
                    999:   int ret = 0;
                   1000:   PariOUT *out = pariOut;
                   1001:   va_list ap;
                   1002:   cell *trapped = NULL;
                   1003:
                   1004:   va_start(ap,numerr);
                   1005:
                   1006:   if (err_catch_stack && !is_warn(numerr))
                   1007:   {
                   1008:     int trap = 0;
                   1009:     if (numerr != memer)
                   1010:     { /* for fear of infinite recursion don't trap memory errors */
                   1011:       if (err_catch_array[numerr]) trap = numerr;
                   1012:       else if (err_catch_array[noer]) trap = noer;
                   1013:     }
                   1014:     if (trap) trapped = err_seek(trap); else err_clean();
                   1015:   }
                   1016:   if (trapped)
                   1017:   { /* all errors (noer), or numerr individually trapped */
                   1018:     void *e = trapped->env;
                   1019:     global_err_data = trapped->data;
                   1020:     if (e) longjmp(e, numerr);
                   1021:   }
                   1022:   else
                   1023:     global_err_data = NULL;
                   1024:
                   1025:   if (!added_newline) { pariputc('\n'); added_newline=1; }
                   1026:   pariflush(); pariOut = pariErr;
                   1027:   pariflush(); term_color(c_ERR);
                   1028:
                   1029:   if (numerr < talker)
                   1030:   {
                   1031:     strcpy(s, errmessage[numerr]);
                   1032:     switch (numerr)
                   1033:     {
                   1034:       case obsoler:
                   1035:         ch1 = va_arg(ap,char *);
                   1036:         errcontext(s,ch1,va_arg(ap,char *));
                   1037:         if (whatnow_fun)
                   1038:         {
                   1039:           term_color(c_NONE);
                   1040:           print_text("\nFor full compatibility with GP 1.39, type \"default(compatible,3)\" (you can also set \"compatible = 3\" in your GPRC file)");
                   1041:           pariputc('\n');
                   1042:           ch1 = va_arg(ap,char *);
                   1043:           (void)whatnow_fun(ch1, - va_arg(ap,int));
                   1044:         }
                   1045:         break;
                   1046:
                   1047:       case openfiler:
                   1048:         sprintf(s+strlen(s), "%s file", va_arg(ap,char*));
                   1049:         ch1 = va_arg(ap,char *);
                   1050:         errcontext(s,ch1,ch1); break;
                   1051:
                   1052:       case talker2:
                   1053:       case member:
                   1054:         strcat(s,va_arg(ap, char*)); /* fall through */
                   1055:       default:
                   1056:         ch1 = va_arg(ap,char *);
                   1057:         errcontext(s,ch1,va_arg(ap,char *));
                   1058:     }
                   1059:   }
                   1060:   else
                   1061:   {
                   1062:     pariputsf("  ***   %s", errmessage[numerr]);
                   1063:     switch (numerr)
                   1064:     {
                   1065:       case talker: case siginter: case invmoder:
                   1066:         ch1=va_arg(ap, char*);
                   1067:         vpariputs(ch1,ap); pariputc('.'); break;
                   1068:
                   1069:       case impl:
                   1070:         ch1=va_arg(ap, char*);
                   1071:         pariputsf(" %s is not yet implemented.",ch1); break;
                   1072:
                   1073:       case breaker: case typeer: case mattype1: case overwriter:
                   1074:       case accurer: case infprecer: case negexper: case polrationer:
                   1075:       case funder2: case constpoler: case notpoler: case redpoler:
                   1076:       case zeropoler: case consister: case flagerr: case precer:
                   1077:         pariputsf(" in %s.",va_arg(ap, char*)); break;
                   1078:
                   1079:       case bugparier:
                   1080:         pariputsf(" %s, please report",va_arg(ap, char*)); break;
                   1081:
                   1082:       case operi: case operf:
                   1083:       {
                   1084:         char *f, *op = va_arg(ap, char*);
                   1085:         long   x = va_arg(ap, long);
                   1086:         long   y = va_arg(ap, long);
                   1087:              if (*op == '+') f = "addition";
                   1088:         else if (*op == '*') f = "multiplication";
                   1089:         else if (*op == '/' || *op == '%') f = "division";
                   1090:         else if (*op == 'g') { op = ","; f = "gcd"; }
                   1091:         else { op = "-->"; f = "assignment"; }
                   1092:         pariputsf(" %s %s %s %s.",f,type_name(x),op,type_name(y));
                   1093:         break;
                   1094:       }
                   1095:
                   1096:       /* the following 4 are only warnings (they return) */
                   1097:       case warnmem: case warner:
                   1098:         pariputc(' '); ch1=va_arg(ap, char*);
                   1099:         vpariputs(ch1,ap); pariputs(".\n");
                   1100:         ret = 1; break;
                   1101:
                   1102:       case warnprec:
                   1103:         vpariputs(" in %s; new prec = %ld\n",ap);
                   1104:         ret = 1; break;
                   1105:
                   1106:       case warnfile:
                   1107:         ch1=va_arg(ap, char*);
                   1108:         pariputsf(" %s: %s", ch1, va_arg(ap, char*));
                   1109:         ret = 1; break;
                   1110:     }
                   1111:   }
                   1112:   term_color(c_NONE); va_end(ap);
                   1113:   if (numerr==errpile)
                   1114:   {
                   1115:     fprintferr("\n  current stack size: %ld (%.3f Mbytes)\n",
                   1116:       top-bot, (top-bot)/1048576.);
                   1117:     fprintferr("  [hint] you can increase GP stack with allocatemem()\n");
                   1118:   }
                   1119:   pariOut = out;
                   1120:   if (ret || (trapped && default_exception_handler &&
                   1121:               default_exception_handler(numerr))) { flusherr(); return; }
                   1122:   err_recover(numerr);
                   1123: }
                   1124:
                   1125: /*******************************************************************/
                   1126: /*                                                                 */
                   1127: /*                       CLONING & COPY                            */
                   1128: /*                  Replicate an existing GEN                      */
                   1129: /*                                                                 */
                   1130: /*******************************************************************/
                   1131: /* lontyp = 0 means non recursive type
                   1132:  * otherwise:
                   1133:  *   lontyp = number of codewords
                   1134:  *   if not in stack, we don't copy the words in [lontyp,lontyp2[
                   1135:  */
                   1136: const  long  lontyp[] = { 0,0,0,1,1,1,1,2,1,1, 2,2,0,1,1,1,1,1,1,1, 2,0,0 };
                   1137: static long lontyp2[] = { 0,0,0,2,1,1,1,3,2,2, 2,2,0,1,1,1,1,1,1,1, 2,0,0 };
                   1138:
                   1139: /* can't do a memcpy there: avma and x may overlap. memmove is slower */
                   1140: GEN
                   1141: gcopy(GEN x)
                   1142: {
                   1143:   long tx=typ(x),lx,i;
                   1144:   GEN y;
                   1145:
                   1146:   if (tx == t_SMALL) return x;
                   1147:   if (! is_recursive_t(tx))
                   1148:   {
                   1149:     if (tx == t_INT && !signe(x)) return gzero; /* very common case */
                   1150:     lx = lg(x); y = new_chunk(lx);
                   1151:     for (i=lx-1; i>=0; i--) y[i]=x[i];
                   1152:   }
                   1153:   else
                   1154:   {
                   1155:     lx = lg(x); y = new_chunk(lx);
                   1156:     if (tx==t_POL || tx==t_LIST) lx = lgef(x);
                   1157:     for (i=0; i<lontyp[tx];  i++) y[i]=x[i];
                   1158:     for (   ; i<lontyp2[tx]; i++) copyifstack(x[i],y[i]);
                   1159:     for (   ; i<lx;          i++) y[i]=lcopy((GEN)x[i]);
                   1160:   }
                   1161:   /* unsetisclone(y); useless because gunclone checks isonstack */
                   1162:   return y;
                   1163: }
                   1164:
                   1165: GEN
                   1166: gcopy_i(GEN x, long lx)
                   1167: {
                   1168:   long tx=typ(x),i;
                   1169:   GEN y;
                   1170:
                   1171:   if (tx == t_SMALL) return x;
                   1172:   y=cgetg(lx,tx);
                   1173:   if (! is_recursive_t(tx))
                   1174:     for (i=lx-1; i>0; i--) y[i]=x[i];
                   1175:   else
                   1176:   {
                   1177:     for (i=1; i<lontyp[tx];  i++) y[i]=x[i];
                   1178:     for (   ; i<lontyp2[tx]; i++) copyifstack(x[i],y[i]);
                   1179:     for (   ; i<lx;          i++) y[i]=lcopy((GEN)x[i]);
                   1180:   }
                   1181:   return y;
                   1182: }
                   1183:
                   1184: GEN
                   1185: forcecopy(GEN x)
                   1186: {
                   1187:   long tx=typ(x),lx,i;
                   1188:   GEN y;
                   1189:
                   1190:   if (tx == t_SMALL) return x;
                   1191:   if (! is_recursive_t(tx))
                   1192:   {
                   1193:     if (tx == t_INT && !signe(x)) return gzero; /* very common case */
                   1194:     lx = lg(x); y = new_chunk(lx);
                   1195:     for (i=lx-1; i>=0; i--) y[i]=x[i];
                   1196:   }
                   1197:   else
                   1198:   {
                   1199:     lx = lg(x); y = new_chunk(lx);
                   1200:     if (tx==t_POL || tx==t_LIST) lx = lgef(x);
                   1201:     for (i=0; i<lontyp[tx]; i++) y[i]=x[i];
                   1202:     for (   ; i<lx;         i++) y[i]=(long)forcecopy((GEN)x[i]);
                   1203:   }
                   1204:   unsetisclone(y); return y;
                   1205: }
                   1206:
                   1207: /* copy x as if avma = *AVMA, update *AVMA */
                   1208: GEN
                   1209: gcopy_av(GEN x, GEN *AVMA)
                   1210: {
                   1211:   long i,lx,tx=typ(x);
                   1212:   GEN y;
                   1213:
                   1214:   if (tx == t_SMALL) return (*--AVMA = x);
                   1215:   lx = lg(x); *AVMA = y = *AVMA - lx;
                   1216:   if (! is_recursive_t(tx))
                   1217:   {
                   1218:     for (i=0; i<lx; i++) y[i] = x[i];
                   1219:   }
                   1220:   else
                   1221:   {
                   1222:     if (tx==t_POL || tx==t_LIST) lx = lgef(x);
                   1223:     for (i=0; i<lontyp[tx]; i++) y[i] = x[i];
                   1224:     for (   ; i<lx; i++)         y[i] = (long)gcopy_av((GEN)x[i], AVMA);
                   1225:   }
                   1226:   unsetisclone(y); return y;
                   1227: }
                   1228:
                   1229: GEN
                   1230: dummycopy(GEN x)
                   1231: {
                   1232:   long tx=typ(x), lx=lg(x),i;
                   1233:   GEN y=new_chunk(lx);
                   1234:
                   1235:   switch(tx)
                   1236:   {
                   1237:     case t_POLMOD:
                   1238:       y[1]=x[1]; y[2]=(long)dummycopy((GEN)x[2]);
                   1239:       break;
                   1240:     case t_MAT:
                   1241:       for (i=lx-1;i;i--) y[i]=(long)dummycopy((GEN)x[i]);
                   1242:       break;
                   1243:     default:
                   1244:       for (i=lx-1;i;i--) y[i]=x[i];
                   1245:   }
                   1246:   y[0]=x[0]; return y;
                   1247: }
                   1248:
                   1249: GEN
                   1250: gclone(GEN x)
                   1251: {
                   1252:   long i,lx,tx = typ(x), t = taille(x);
                   1253:   GEN y = newbloc(t);
                   1254:   if (!is_recursive_t(tx))
                   1255:   {
                   1256:     lx = (tx==t_INT)? lgefint(x): lg(x);
                   1257:     for (i=0; i<lx; i++) y[i] = x[i];
                   1258:   }
                   1259:   else
                   1260:   {
                   1261:     GEN AVMA = y+t;
                   1262:     lx = (tx==t_POL || tx==t_LIST)? lgef(x): lg(x);
                   1263:     for (i=0; i<lontyp[tx]; i++) y[i] = x[i];
                   1264:     for (   ; i<lx; i++)         y[i] = (long)gcopy_av((GEN)x[i], &AVMA);
                   1265:   }
                   1266:   setisclone(y); return y;
                   1267: }
                   1268:
                   1269: void
                   1270: shiftaddress(GEN x, long dec)
                   1271: {
                   1272:   long i,lx, tx = typ(x);
                   1273:   if (is_recursive_t(tx))
                   1274:   {
                   1275:     lx = (tx==t_POL || tx==t_LIST)? lgef(x): lg(x);
                   1276:     for (i=lontyp[tx]; i<lx; i++) {
                   1277:       x[i] += dec;
                   1278:       shiftaddress((GEN)x[i], dec);
                   1279:     }
                   1280:   }
                   1281: }
                   1282:
                   1283: /* return a clone of x structured as a gcopy. To free it, free(*base).
                   1284:  * Can be copied via memcpy(, *base, ((x - *base)+lg(x)) * sizeof(long)) */
                   1285: GENbin*
                   1286: copy_bin(GEN x)
                   1287: {
                   1288:   long t = taille(x);
                   1289:   GENbin *p = (GENbin*)gpmalloc(sizeof(GENbin) + t*sizeof(long));
                   1290:   GEN AVMA = GENbase(p) + t;
                   1291:   p->len = t;
                   1292:   p->x   = gcopy_av(x, &AVMA);
                   1293:   p->base= AVMA; return p;
                   1294: }
                   1295:
                   1296: /* p from copy_bin. Copy p->x back to stack, then destroy p */
                   1297: GEN
                   1298: bin_copy(GENbin *p)
                   1299: {
                   1300:   GEN x,y,base;
                   1301:   long dx,len;
                   1302:
                   1303:   len = p->len;
                   1304:   x   = p->x;
                   1305:   base= p->base; dx = x - base;
                   1306:   y = (GEN)memcpy((void*)new_chunk(len), (void*)GENbase(p), len*sizeof(long));
                   1307:   if (dx) { y += dx; shiftaddress(y, (y-x)*sizeof(long)); }
                   1308:   free(p); return y;
                   1309: }
                   1310:
                   1311: /*******************************************************************/
                   1312: /*                                                                 */
                   1313: /*                         STACK MANAGEMENT                        */
                   1314: /*                                                                 */
                   1315: /*******************************************************************/
                   1316: /* Inhibit some area gerepile-wise: declare it to be a non recursive
                   1317:  * type, of length l. Thus gerepile won't inspect the zone, just copy it.
                   1318:  * For the following situation:
                   1319:  *   z = cgetg(t,a); garbage of length l;
                   1320:  *   for (i=1; i<HUGE; i++) z[i] = ...
                   1321:  *   stackdummy(z,l); z += l; We lose l words but save a costly gerepile.
                   1322:  */
                   1323: void
                   1324: stackdummy(GEN z, long l) { z[0] = evaltyp(t_STR) | evallg(l); }
                   1325:
                   1326: /* gerepileupto(av, forcecopy(x)) */
                   1327: GEN
                   1328: gerepilecopy(long av, GEN x)
                   1329: {
                   1330:   GENbin *p = copy_bin(x);
                   1331:   avma = av; return bin_copy(p);
                   1332: }
                   1333:
                   1334: /* Takes an array of pointers to GENs, of length n. Copies all
                   1335:  * objects to contiguous locations and cleans up the stack between
                   1336:  * av and avma. */
                   1337: void
                   1338: gerepilemany(long av, GEN* gptr[], long n)
                   1339: {
                   1340:   GENbin **l = (GENbin**)gpmalloc(n*sizeof(GENbin*));
                   1341:   long i;
                   1342:   for (i=0; i<n; i++) l[i] = copy_bin(*(gptr[i]));
                   1343:   avma = av;
                   1344:   for (i=0; i<n; i++) *(gptr[i]) = bin_copy(l[i]);
                   1345:   free(l);
                   1346: }
                   1347:
                   1348: void
                   1349: gerepilemanycoeffs(long av, GEN x, long n)
                   1350: {
                   1351:   long i;
                   1352:   for (i=0; i<n; i++) x[i] = (long)copy_bin((GEN)x[i]);
                   1353:   avma = av;
                   1354:   for (i=0; i<n; i++) x[i] = (long)bin_copy((GENbin*)x[i]);
                   1355: }
                   1356:
                   1357: void
                   1358: gerepilemanycoeffs2(long av, GEN x, long n, GEN y, long o)
                   1359: {
                   1360:   long i;
                   1361:   for (i=0; i<n; i++) x[i] = (long)copy_bin((GEN)x[i]);
                   1362:   for (i=0; i<o; i++) y[i] = (long)copy_bin((GEN)y[i]);
                   1363:   avma = av;
                   1364:   for (i=0; i<n; i++) x[i] = (long)bin_copy((GENbin*)x[i]);
                   1365:   for (i=0; i<o; i++) y[i] = (long)bin_copy((GENbin*)y[i]);
                   1366: }
                   1367:
                   1368: /* Takes an array of pointers to GENs, of length n.
                   1369:  * Cleans up the stack between av and tetpil, updating those GENs. */
                   1370: void
                   1371: gerepilemanysp(long av, long tetpil, GEN* gptr[], long n)
                   1372: {
                   1373:   const long av2 = avma, dec = av-tetpil;
                   1374:   long i;
                   1375:
                   1376:   (void)gerepile(av,tetpil,NULL);
                   1377:   for (i=0; i<n; i++)
                   1378:   {
                   1379:     ulong *g1 = (ulong*) gptr[i];
                   1380:     if (*g1 < (ulong)tetpil)
                   1381:     {
                   1382:       if (*g1 >= (ulong)av2) *g1 += dec; /* Update address if in stack */
                   1383:       else if (*g1 >=(ulong)av) err(gerper);
                   1384:     }
                   1385:   }
                   1386: }
                   1387:
                   1388: /* Takes an array of GENs (cast to longs), of length n.
                   1389:  * Cleans up the stack between av and tetpil, updating those GENs. */
                   1390: void
                   1391: gerepilemanyvec(long av, long tetpil, long *g, long n)
                   1392: {
                   1393:   const long av2 = avma, dec = av-tetpil;
                   1394:   long i;
                   1395:
                   1396:   (void)gerepile(av,tetpil,NULL);
                   1397:   for (i=0; i<n; i++,g++)
                   1398:     if ((ulong)*g < (ulong)tetpil)
                   1399:     {
                   1400:       if ((ulong)*g >= (ulong)av2) *g += dec;/* Update addresses if in stack */
                   1401:       else if ((ulong)*g >= (ulong)av) err(gerper);
                   1402:     }
                   1403: }
                   1404:
                   1405: GEN
                   1406: gerepileupto(long av, GEN q)
                   1407: {
                   1408:   if (!isonstack(q)) { avma=av; return q; } /* universal object */
                   1409:   /* empty garbage */
                   1410:   if ((ulong)av <= (ulong)q) return q;
                   1411:   /* The garbage is only empty when av==q. It's probably a mistake if
                   1412:    * av < q. But "temporary variables" from sumiter are a problem since
                   1413:    * ep->values are returned as-is by identifier() and they can be in the
                   1414:    * stack: if we put a gerepileupto in lisseq(), we get an error. Maybe add,
                   1415:    * if (DEBUGMEM) err(warner,"av>q in gerepileupto") ???
                   1416:    */
                   1417:
                   1418:   /* Beware: (long)(q+i) --> ((long)q)+i*sizeof(long) */
                   1419:   return gerepile(av, (long) (q+lg(q)), q);
                   1420: }
                   1421:
                   1422: /* internal */
                   1423: GEN
                   1424: gerepileuptoleaf(long av, GEN q)
                   1425: {
                   1426:   long i;
                   1427:   GEN q0;
                   1428:
                   1429:   if (!isonstack(q) || av==(long)q) { avma=av; return q; }
                   1430:   i=lg(q); avma = (long)(((GEN)av) -  i);
                   1431:   q0 = (GEN)avma; while (--i >= 0) q0[i]=q[i];
                   1432:   return q0;
                   1433: }
                   1434: /* internal */
                   1435: GEN
                   1436: gerepileuptoint(long av, GEN q)
                   1437: {
                   1438:   if (!isonstack(q) || av==(long)q) { avma=av; return q; }
                   1439:   avma = (long)icopy_av(q, (GEN)av);
                   1440:   return (GEN)avma;
                   1441: }
                   1442:
                   1443: static int
                   1444: _ok_gerepileupto(GEN av, GEN x)
                   1445: {
                   1446:   long i,lx,tx;
                   1447:   if (!isonstack(x)) return 1;
                   1448:   if (x > av)
                   1449:   {
                   1450:     err(warner,"bad object %Z",x);
                   1451:     return 0;
                   1452:   }
                   1453:   tx = typ(x);
                   1454:   if (! is_recursive_t(tx)) return 1;
                   1455:
                   1456:   lx = (tx==t_POL || tx==t_LIST)? lgef(x): lg(x);
                   1457:   for (i=lontyp[tx]; i<lx; i++)
                   1458:     if (!_ok_gerepileupto(av, (GEN)x[i]))
                   1459:     {
                   1460:       err(warner,"bad component %ld in object %Z",i,x);
                   1461:       return 0;
                   1462:     }
                   1463:   return 1;
                   1464: }
                   1465: /* check that x and all its components are out of stack, or have been
                   1466:  * created after av */
                   1467: int
                   1468: ok_gerepileupto(GEN x) { return _ok_gerepileupto(x, x); }
                   1469:
                   1470: GEN
                   1471: gerepile(long av, long tetpil, GEN q)
                   1472: {
                   1473:   long avmb, dec = av - tetpil;
                   1474:   GEN ll,a,b;
                   1475:
                   1476:   if (dec==0) return q;
                   1477:   if (dec<0) err(talker,"lbot>ltop in gerepile");
                   1478:
                   1479:   if ((ulong)q>=(ulong)avma && (ulong)q<(ulong)tetpil)
                   1480:     q = (GEN) (((long)q) + dec);
                   1481:
                   1482:   for (ll=(GEN)av, a=(GEN)tetpil; a > (GEN)avma; ) *--ll= *--a;
                   1483:   avmb = (long)ll;
                   1484:   while (ll < (GEN)av)
                   1485:   {
                   1486:     const long tl=typ(ll);
                   1487:
                   1488:     if (! is_recursive_t(tl)) { ll+=lg(ll); continue; }
                   1489:     a = ll+lontyp[tl];
                   1490:     if (tl==t_POL) { b=ll+lgef(ll); ll+=lg(ll); } else { ll+=lg(ll); b=ll; }
                   1491:     for (  ; a<b; a++)
                   1492:       if ((ulong)*a < (ulong)av && (ulong)*a >= (ulong)avma)
                   1493:       {
                   1494:        if ((ulong)*a < (ulong)tetpil) *a += dec; else err(gerper);
                   1495:       }
                   1496:   }
                   1497:   avma = avmb; return q;
                   1498: }
                   1499:
                   1500: long
                   1501: allocatemoremem(ulong newsize)
                   1502: {
                   1503:   long sizeold = top - bot, newbot;
                   1504:
                   1505:   if (!newsize)
                   1506:   {
                   1507:     newsize = sizeold << 1;
                   1508:     err(warner,"doubling stack size; new stack = %ld (%.3f Mbytes)",
                   1509:                 newsize, newsize/1048576.);
                   1510:   }
                   1511:   else if ((long)newsize < 1000L)
                   1512:     err(talker,"required stack memory too small");
                   1513:   /* can't do bot = malloc directly, in case we lack memory */
                   1514:   newsize = fix_size(newsize);
                   1515:   newbot = (long) gpmalloc(newsize);
                   1516:   free((void*)bot); bot = newbot;
                   1517:   memused = avma = top = bot + newsize;
                   1518:   return newsize;
                   1519: }
                   1520:
                   1521: /* alternate stack management routine */
                   1522: stackzone *
                   1523: switch_stack(stackzone *z, long n)
                   1524: {
                   1525:   if (!z)
                   1526:   { /* create parallel stack */
                   1527:     long size = n*sizeof(long) + sizeof(stackzone);
                   1528:     z = (stackzone*) gpmalloc(size);
                   1529:     z->zonetop = ((long)z) + size;
                   1530:     return z;
                   1531:   }
                   1532:
                   1533:   if (n)
                   1534:   { /* switch to parallel stack */
                   1535:     z->bot     = bot;
                   1536:     z->top     = top;
                   1537:     z->avma    = avma;
                   1538:     z->memused = memused;
                   1539:     bot     = (long) (z+1);
                   1540:     top     = z->zonetop;
                   1541:     avma    = top;
                   1542:     memused = (ulong)-1;
                   1543:   }
                   1544:   else
                   1545:   { /* back to normalcy */
                   1546:     bot     = z->bot;
                   1547:     top     = z->top;
                   1548:     avma    = z->avma;
                   1549:     memused = z->memused;
                   1550:   }
                   1551:   return NULL;
                   1552: }
                   1553:
                   1554: char*
                   1555: gpmalloc(size_t bytes)
                   1556: {
                   1557:   char *tmp;
                   1558:
                   1559:   if (bytes)
                   1560:   {
                   1561:     tmp = (char *) malloc(bytes);
                   1562:     if (!tmp) err(memer);
                   1563:     return tmp;
                   1564:   }
                   1565:   if (DEBUGMEM) err(warner,"mallocing NULL object");
                   1566:   return NULL;
                   1567: }
                   1568:
                   1569: #if __MWERKS__
                   1570: static void *
                   1571: macrealloc(void *p, size_t newsize, size_t oldsize)
                   1572: {
                   1573:   char *q = gpmalloc(newsize), *qq = q, *pp = p;
                   1574:   int l = newsize > oldsize ? oldsize : newsize;
                   1575:
                   1576:   while (l--) *qq++ = *pp++;
                   1577:   free(p); return q;
                   1578: }
                   1579: #endif
                   1580:
                   1581: char*
                   1582: gprealloc(void *pointer, size_t newsize, size_t oldsize)
                   1583: {
                   1584:   char *tmp;
                   1585:
                   1586:   if (!pointer) tmp = (char *) malloc(newsize);
                   1587: #if __MWERKS__
                   1588:   else tmp = (char *) macrealloc(pointer,newsize,oldsize);
                   1589: #else
                   1590:   else tmp = (char *) realloc(pointer,newsize);
                   1591: #endif
                   1592:   (void)oldsize;
                   1593:   if (!tmp) err(memer);
                   1594:   return tmp;
                   1595: }
                   1596:
                   1597: #ifdef MEMSTEP
                   1598: void
                   1599: checkmemory(GEN z)
                   1600: {
                   1601:   if (DEBUGMEM && memused != (ulong)-1 &&
                   1602:        ((GEN)memused > z + MEMSTEP || z > (GEN)memused + MEMSTEP))
                   1603:   {
                   1604:     memused=(ulong)z;
                   1605: #if MEMSTEP >= 1048576
                   1606:     fprintferr("...%4.0lf Mbytes used\n",(top-memused)/1048576.);
                   1607: #else
                   1608:     fprintferr("...%5.1lf Mbytes used\n",(top-memused)/1048576.);
                   1609: #endif
                   1610:   }
                   1611: }
                   1612: #endif
                   1613:
                   1614: void
                   1615: init_stack()
                   1616: {
                   1617:   GEN x = ((GEN)bot);
                   1618:   while (x < (GEN)avma) *x++ = 0xfefefefe;
                   1619: }
                   1620:
                   1621: /*******************************************************************/
                   1622: /*                                                                 */
                   1623: /*                               TIMER                             */
                   1624: /*                                                                 */
                   1625: /*******************************************************************/
                   1626: #define MAX_TIMER 32
                   1627: #define MIN_TIMER 3
                   1628:
                   1629: #ifdef WINCE
                   1630:   static long
                   1631:   timer_proto(int i)
                   1632:   {
                   1633:     static DWORD oldticks[MAX_TIMER];
                   1634:     DWORD ticks = GetTickCount();
                   1635:     DWORD delay = ticks - oldticks[i];
                   1636:     oldticks[i] = ticks;
                   1637:     return delay;
                   1638:   }
                   1639: #elif defined(macintosh)
                   1640: # include <Events.h>
                   1641:   static long
                   1642:   timer_proto(int i)
                   1643:   {
                   1644:     static long oldticks[MAX_TIMER];
                   1645:     long ticks = TickCount(), delay = ticks - oldticks[i];
                   1646:
                   1647:     oldticks[i] = ticks;
                   1648:     return 50 * delay / 3;
                   1649:   }
                   1650: #elif USE_TIMES
                   1651:
                   1652: # include <sys/times.h>
                   1653: # include <sys/time.h>
                   1654: # include <time.h>
                   1655:   static long
                   1656:   timer_proto(int i)
                   1657:   {
                   1658:     static clock_t oldticks[MAX_TIMER];
                   1659:     struct tms t;
                   1660:     long delay;
                   1661:
                   1662:     times(&t);
                   1663:     delay = (long)((t.tms_utime - oldticks[i]) * (1000. / CLK_TCK));
                   1664:     oldticks[i] = t.tms_utime;
                   1665:     return delay;
                   1666:   }
                   1667: #elif USE_GETRUSAGE
                   1668:
                   1669: # include <sys/time.h>
                   1670: # include <sys/resource.h>
                   1671:   static long
                   1672:   timer_proto(int i)
                   1673:   {
                   1674:     static long oldmusec[MAX_TIMER],oldsec[MAX_TIMER];
                   1675:     struct rusage r;
                   1676:     struct timeval t;
                   1677:     long delay;
                   1678:
                   1679:     getrusage(0,&r); t=r.ru_utime;
                   1680:     delay = 1000 * (t.tv_sec - oldsec[i]) + (t.tv_usec - oldmusec[i]) / 1000;
                   1681:     oldmusec[i] = t.tv_usec; oldsec[i] = t.tv_sec;
                   1682:     return delay;
                   1683:   }
                   1684: #elif USE_FTIME
                   1685:
                   1686: # include <sys/timeb.h>
                   1687:   static long
                   1688:   timer_proto(int i)
                   1689:   {
                   1690:     static long oldmsec[MAX_TIMER],oldsec[MAX_TIMER];
                   1691:     struct timeb t;
                   1692:     long delay;
                   1693:
                   1694:     ftime(&t);
                   1695:     delay = 1000 * (t.time - oldsec[i]) + (t.millitm - oldmsec[i]);
                   1696:     oldmsec[i] = t.millitm; oldsec[i] = t.time;
                   1697:     return delay;
                   1698:   }
                   1699: #else
                   1700:
                   1701: # include <time.h>
                   1702: # ifndef CLOCKS_PER_SEC
                   1703: #   define CLOCKS_PER_SEC 1000000 /* may be false on YOUR system */
                   1704: # endif
                   1705:   static long
                   1706:   timer_proto(int i)
                   1707:   {
                   1708:     static clock_t oldclocks[MAX_TIMER];
                   1709:     clock_t t = clock();
                   1710:     long delay = (long)((t-oldclocks[i]) * 1000. / CLOCKS_PER_SEC);
                   1711:
                   1712:     oldclocks[i] = t;
                   1713:     return delay;
                   1714:   }
                   1715: #endif
                   1716:
                   1717: #define is_valid_timer(t) ((t) < MAX_TIMER || (t) >= MIN_TIMER)
                   1718: long
                   1719: gptimer() {return timer_proto(0);}
                   1720: long
                   1721: timer(void)   {return timer_proto(1);}
                   1722: long
                   1723: timer2(void)  {return timer_proto(2);}
                   1724: long
                   1725: gentimer(long t)
                   1726: {
                   1727:   if (!is_valid_timer(t))
                   1728:     err(talker,"not an available timer (%ld)",t);
                   1729:   return timer_proto(t);
                   1730: }
                   1731:
                   1732: /* internal */
                   1733:
                   1734: long
                   1735: get_timer(long t)
                   1736: {
                   1737:   static int used[MAX_TIMER];
                   1738:   int i;
                   1739:   if (!t)
                   1740:   { /* get new timer */
                   1741:     for (i=MIN_TIMER; i < MAX_TIMER; i++)
                   1742:       if (!used[i]) { used[i] = 1; t = i; break; }
                   1743:     if (!t) { t = 2; err(warner, "no timers left! Using timer2()"); }
                   1744:     timer_proto(t); /* init timer */
                   1745:   }
                   1746:   else if (t < 0)
                   1747:   { /* initialize */
                   1748:     for (i=MIN_TIMER; i < MAX_TIMER; i++) used[i] = 0;
                   1749:   }
                   1750:   else
                   1751:   { /* delete */
                   1752:     if (!is_valid_timer(t) || !used[t])
                   1753:       err(warner, "timer %ld wasn't in use", t);
                   1754:     else
                   1755:       used[t] = 0;
                   1756:   }
                   1757:   return t;
                   1758: }
                   1759:
                   1760: void
                   1761: genmsgtimer(long t, char *format, ...)
                   1762: {
                   1763:   va_list args;
                   1764:   PariOUT *out = pariOut; pariOut = pariErr;
                   1765:
                   1766:   pariputs("Time "); va_start(args, format);
                   1767:   vpariputs(format,args); va_end(args);
                   1768:   pariputsf(": %ld\n", timer_proto(t)); pariflush();
                   1769:   pariOut = out;
                   1770: }
                   1771:
                   1772: void
                   1773: msgtimer(char *format, ...)
                   1774: {
                   1775:   va_list args;
                   1776:   PariOUT *out = pariOut; pariOut = pariErr;
                   1777:
                   1778:   pariputs("Time "); va_start(args, format);
                   1779:   vpariputs(format,args); va_end(args);
                   1780:   pariputsf(": %ld\n", timer_proto(2)); pariflush();
                   1781:   pariOut = out;
                   1782: }
                   1783:
                   1784: /*******************************************************************/
                   1785: /*                                                                 */
                   1786: /*                   FUNCTIONS KNOWN TO THE ANALYZER               */
                   1787: /*                                                                 */
                   1788: /*******************************************************************/
                   1789: extern void alias0(char *s, char *old);
                   1790: extern GEN break0(long n);
                   1791: extern GEN next0(long n);
                   1792: extern GEN return0(GEN x);
                   1793:
                   1794: GEN
                   1795: geni(void) { return gi; }
                   1796:
                   1797: /* List of GP functions:
                   1798:  * ---------------------
                   1799:  * Format (struct entree) :
                   1800:  *   char *name    : name (under GP).
                   1801:  *   ulong valence : used to form arg list, now often handled by code.
                   1802:  *   void *value   : For PREDEFINED FUNCTIONS: C function to call.
                   1803:  *                   For USER FUNCTIONS: pointer to defining data (bloc) =
                   1804:  *                    entree*: NULL, list of entree (arguments), NULL
                   1805:  *                    char*  : function text
                   1806:  *   long menu     : which help section do we belong to (See below).
                   1807:  *   char *code    : argument list (See below).
                   1808:  *   entree *next  : next entree (init to NULL, used in hashing code).
                   1809:  *   char *help    : short help text (init to NULL).
                   1810:  *   void *args    : For USER FUNCTIONS: default arguments (NULL terminated).
                   1811:  *                   For VARIABLES: (esp. loop indexes): push_val history.
                   1812:  *                   (while processing a loop, ep->value may not be a bloc)
                   1813:  * menu:
                   1814:  * -----
                   1815:  *  1: Standard monadic or dyadic OPERATORS
                   1816:  *  2: CONVERSIONS and similar elementary functions
                   1817:  *  3: TRANSCENDENTAL functions
                   1818:  *  4: NUMBER THEORETICAL functions
                   1819:  *  5: Functions related to ELLIPTIC CURVES
                   1820:  *  6: Functions related to general NUMBER FIELDS
                   1821:  *  7: POLYNOMIALS and power series
                   1822:  *  8: Vectors, matrices, LINEAR ALGEBRA and sets
                   1823:  *  9: SUMS, products, integrals and similar functions
                   1824:  *  10: GRAPHIC functions
                   1825:  *  11: PROGRAMMING under GP
                   1826:  *
                   1827:  * code: describe function prototype. NULL = use valence instead.
                   1828:  * -----
                   1829:  * Arguments:
                   1830:  *  I  input position (to be processed with lisseq) - a string with a
                   1831:  *     sequence of PARI expressions.
                   1832:  *  E  input position (to be processed with lisexpr) - a string with a
                   1833:  *     PARI expression.
                   1834:  *  G  GEN
                   1835:  *  L  long
                   1836:  *  S  symbol (i.e GP function name)
                   1837:  *  V  variable (same as S, but valence must equal EpVAR/EpGVAR)
                   1838:  *  n  variable number
                   1839:  *  &  *GEN
                   1840:  *  F  Fake *GEN (function requires a *GEN, but we don't use the resulting GEN)
                   1841:  *  f  Fake *long
                   1842:  *  p  real precision (prec for the C library)
                   1843:  *  P  series precision (precdl dor the C library)
                   1844:  *  r  raw input (treated as a string without quotes).
                   1845:  *     Quoted args are copied as strings. Stops at first unquoted ')' or ','.
                   1846:  *     Special chars can be quoted using '\'.  Ex : aa"b\n)"c => "aab\n)c".
                   1847:  *  s  expanded string. Example: pi"x"2 yields "3.142x2".
                   1848:  *     The unquoted components can be of any pari type (converted according to
                   1849:  *     the current output format)
                   1850:  *  s* any number of strings (see s)
                   1851:  *  s*p idem, setting prettyp=1
                   1852:  *  s*t idem, in TeX format.
                   1853:  *  D  Has a default value. Format is "Dvalue,type," (the ending comma is
                   1854:  *     mandatory). Ex: D0,L, (arg is long, 0 by default).
                   1855:  *     Special syntax:
                   1856:  *       if type = G, &, I or V:  D[G&IV] all send NULL.
                   1857:  *       if type = v: Dn sends -1.
                   1858:  *
                   1859:  *     The user-given args are read first, then completed by the defaults
                   1860:  *
                   1861:  * Return type (first char or immediately after 'x'): GEN by default, otherwise
                   1862:  *  l Return long
                   1863:  *  v Return void
                   1864:  *
                   1865:  * Syntax requirements:
                   1866:  *  = Separator '=' required.
                   1867:  *
                   1868:  * Origin:
                   1869:  *  x Installed foreign function. Put the ep of the function as the
                   1870:  *       first argument, fill the rest with PARI arguments,
                   1871:  *       then call installedHandler with these arguments.
                   1872:  *       Should be the first char in the code.
                   1873:  *
                   1874:  ****************************************************************************
                   1875:  * If new codes are added, change identifier and skipidentifier.
                   1876:  *
                   1877:  * Currently the following functions have no code word:
                   1878:  * 'O' 50, 'if' 80, 'until' 82, 'while' 81, 'global' 88,
                   1879:  *
                   1880:  * Valence 0 reserved for functions without mandatory args.
                   1881:  * Valence 99 reserved for codes which do not correspond 1-to-1 to valences.
                   1882:  * Any other valence (what to do with 0?) should correspond to exactly
                   1883:  *  one code.
                   1884:  */
                   1885: entree functions_basic[]={
                   1886: {"Euler",0,(void*)mpeuler,3,"p"},
                   1887: {"I",0,(void*)geni,3,""},
                   1888: {"List",0,(void*)gtolist,2,"DG"},
                   1889: {"Mat",0,(void*)gtomat,2,"DG"},
                   1890: {"Mod",25,(void*)Mod0,2,"GGD0,L,"},
                   1891: {"O",50,NULL,7,NULL},
                   1892: {"Pi",0,(void*)mppi,3,"p"},
                   1893: {"Pol",14,(void*)gtopoly,2,"GDn"},
                   1894: {"Polrev",14,(void*)gtopolyrev,2,"GDn"},
                   1895: {"Qfb",99,(void*)Qfb0,2,"GGGDGp"},
                   1896: {"Ser",14,(void*)gtoser,2,"GDn"},
                   1897: {"Set",0,(void*)gtoset,2,"DG"},
                   1898: {"Str",0,(void*)strtoGENstr,2,"D\"\",s,D0,L,"},
                   1899: {"Vec",0,(void*)gtovec,2,"DG"},
                   1900: {"Vecsmall",0,(void*)gtovecsmall,2,"DG"},
                   1901: {"abs",1,(void*)gabs,3,"Gp"},
                   1902: {"acos",1,(void*)gacos,3,"Gp"},
                   1903: {"acosh",1,(void*)gach,3,"Gp"},
                   1904: {"addprimes",0,(void*)addprimes,4,"DG"},
                   1905: {"agm",29,(void*)agm,3,"GGp"},
                   1906: {"algdep",99,(void*)algdep0,8,"GLD0,L,p"},
                   1907: {"alias",99,(void*)alias0,11,"vrr"},
                   1908: {"arg",1,(void*)garg,3,"Gp"},
                   1909: {"asin",1,(void*)gasin,3,"Gp"},
                   1910: {"asinh",1,(void*)gash,3,"Gp"},
                   1911: {"atan",1,(void*)gatan,3,"Gp"},
                   1912: {"atanh",1,(void*)gath,3,"Gp"},
                   1913: {"bernfrac",11,(void*)bernfrac,3,"L"},
                   1914: {"bernreal",99,(void*)bernreal,3,"Lp"},
                   1915: {"bernvec",11,(void*)bernvec,3,"L"},
                   1916: {"besseljh",29,(void*)jbesselh,3,"GGp"},
                   1917: {"besselk",99,(void*)kbessel0,3,"GGD0,L,p"},
                   1918: {"bestappr",99,(void*)bestappr0,4,"GGDG"},
                   1919: {"bezout",2,(void*)vecbezout,4,"GG"},
                   1920: {"bezoutres",2,(void*)vecbezoutres,4,"GG"},
                   1921: {"bigomega",18,(void*)gbigomega,4,"G"},
                   1922: {"binary",18,(void*)binaire,2,"G"},
                   1923: {"binomial",21,(void*)binome,4,"GL"},
                   1924: {"bitand",2,(void*)gbitand,2,"GG"},
                   1925: {"bitneg",99,(void*)gbitneg,2,"GD-1,L,"},
                   1926: {"bitnegimply",2,(void*)gbitnegimply,2,"GG"},
                   1927: {"bitor",2,(void*)gbitor,2,"GG"},
                   1928: {"bittest",2,(void*)gbittest,2,"GG"},
                   1929: {"bitxor",2,(void*)gbitxor,2,"GG"},
                   1930: {"bnfcertify",10,(void*)certifybuchall,6,"lG"},
                   1931: {"bnfclassunit",99,(void*)bnfclassunit0,6,"GD0,L,DGp"},
                   1932: {"bnfclgp",99,(void*)classgrouponly,6,"GDGp"},
                   1933: {"bnfdecodemodule",2,(void*)decodemodule,6,"GG"},
                   1934: {"bnfinit",91,(void*)bnfinit0,6,"GD0,L,DGp"},
                   1935: {"bnfisintnorm",99,(void*)bnfisintnorm,6,"GG"},
                   1936: {"bnfisnorm",99,(void*)bnfisnorm,6,"GGD1,L,p"},
                   1937: {"bnfisprincipal",99,(void*)isprincipalall,6,"GGD1,L,"},
                   1938: {"bnfissunit",99,(void*)bnfissunit,6,"GGG"},
                   1939: {"bnfisunit",2,(void*)isunit,6,"GG"},
                   1940: {"bnfmake",1,(void*)bnfmake,6,"Gp"},
                   1941: {"bnfnarrow",18,(void*)buchnarrow,6,"G"},
                   1942: {"bnfreg",99,(void*)regulator,6,"GDGp"},
                   1943: {"bnfsignunit",18,(void*)signunits,6,"G"},
                   1944: {"bnfsunit",99,(void*)bnfsunit,6,"GGp"},
                   1945: {"bnfunit",18,(void*)buchfu,6,"G"},
                   1946: {"bnrL1",99,(void*)bnrL1,6,"GGD0,L,p"},
                   1947: {"bnrclass",99,(void*)bnrclass0,6,"GGD0,L,"},
                   1948: {"bnrclassno",2,(void*)rayclassno,6,"GG"},
                   1949: {"bnrclassnolist",2,(void*)rayclassnolist,6,"GG"},
                   1950: {"bnrconductor",99,(void*)bnrconductor,6,"GDGDGD0,L,"},
                   1951: {"bnrconductorofchar",2,(void*)bnrconductorofchar,6,"GG"},
                   1952: {"bnrdisc",99,(void*)bnrdisc0,6,"GDGDGD0,L,"},
                   1953: {"bnrdisclist",99,(void*)bnrdisclist0,6,"GGDGD0,L,"},
                   1954: {"bnrinit",99,(void*)bnrinit0,6,"GGD0,L,"},
                   1955: {"bnrisconductor",99,(void*)bnrisconductor,6,"lGDGDG"},
                   1956: {"bnrisprincipal",99,(void*)isprincipalrayall,6,"GGD1,L,"},
                   1957: {"bnrrootnumber",99,(void*)bnrrootnumber,6,"GGD0,L,p"},
                   1958: {"bnrstark",99,(void*)bnrstark,6,"GGD0,L,p"},
                   1959: {"break",0,(void*)break0,11,"D1,L,"},
                   1960: {"ceil",18,(void*)gceil,2,"G"},
                   1961: {"centerlift",99,(void*)centerlift0,2,"GDn"},
                   1962: {"changevar",2,(void*)changevar,2,"GG"},
                   1963: {"charpoly",99,(void*)charpoly0,8,"GDnD0,L,"},
                   1964: {"chinese",99,(void*)chinese,4,"GDG"},
                   1965: {"component",21,(void*)compo,2,"GL"},
                   1966: {"concat",99,(void*)concat,8,"GDG"},
                   1967: {"conj",18,(void*)gconj,2,"G"},
                   1968: {"conjvec",1,(void*)conjvec,2,"Gp"},
                   1969: {"content",18,(void*)content,4,"G"},
                   1970: {"contfrac",99,(void*)contfrac0,4,"GDGD0,L,"},
                   1971: {"contfracpnqn",18,(void*)pnqn,4,"G"},
                   1972: {"core",99,(void*)core0,4,"GD0,L,"},
                   1973: {"coredisc",99,(void*)coredisc0,4,"GD0,L,"},
                   1974: {"cos",1,(void*)gcos,3,"Gp"},
                   1975: {"cosh",1,(void*)gch,3,"Gp"},
                   1976: {"cotan",1,(void*)gcotan,3,"Gp"},
                   1977: {"denominator",18,(void*)denom,2,"G"},
                   1978: {"deriv",14,(void*)deriv,7,"GDn"},
                   1979: {"dilog",1,(void*)dilog,3,"Gp"},
                   1980: {"dirdiv",2,(void*)dirdiv,4,"GG"},
                   1981: {"direuler",99,(void*)direulerall,4,"V=GGEDG"},
                   1982: {"dirmul",2,(void*)dirmul,4,"GG"},
                   1983: {"dirzetak",2,(void*)dirzetak,6,"GG"},
                   1984: {"divisors",18,(void*)divisors,4,"G"},
                   1985: {"divrem",2,(void*)gdiventres,1,"GG"},
                   1986: {"eint1",99,(void*)veceint1,3,"GDGp"},
                   1987: {"elladd",3,(void*)addell,5,"GGG"},
                   1988: {"ellak",2,(void*)akell,5,"GG"},
                   1989: {"ellan",23,(void*)anell,5,"GL"},
                   1990: {"ellap",25,(void*)ellap0,5,"GGD0,L,"},
                   1991: {"ellbil",99,(void*)bilhell,5,"GGGp"},
                   1992: {"ellchangecurve",2,(void*)coordch,5,"GG"},
                   1993: {"ellchangepoint",2,(void*)pointch,5,"GG"},
                   1994: {"elleisnum",99,(void*)elleisnum,5,"GLD0,L,p"},
                   1995: {"elleta",1,(void*)elleta,5,"Gp"},
                   1996: {"ellglobalred",18,(void*)globalreduction,5,"G"},
                   1997: {"ellheight",99,(void*)ellheight0,5,"GGD0,L,p"},
                   1998: {"ellheightmatrix",29,(void*)mathell,5,"GGp"},
                   1999: {"ellinit",99,(void*)ellinit0,5,"GD0,L,p"},
                   2000: {"ellisoncurve",20,(void*)oncurve,5,"lGG"},
                   2001: {"ellj",1,(void*)jell,5,"Gp"},
                   2002: {"elllocalred",2,(void*)localreduction,5,"GG"},
                   2003: {"elllseries",99,(void*)lseriesell,5,"GGDGp"},
                   2004: {"ellorder",2,(void*)orderell,5,"GG"},
                   2005: {"ellordinate",29,(void*)ordell,5,"GGp"},
                   2006: {"ellpointtoz",29,(void*)zell,5,"GGp"},
                   2007: {"ellpow",99,(void*)powell,5,"GGG"},
                   2008: {"ellrootno",99,(void*)ellrootno,5,"lGDG"},
                   2009: {"ellsigma",99,(void*)ellsigma,5,"GGD0,L,p"},
                   2010: {"ellsub",99,(void*)subell,5,"GGG"},
                   2011: {"elltaniyama",18,(void*)taniyama,5,"G"},
                   2012: {"elltors",99,(void*)elltors0,5,"GD0,L,"},
                   2013: {"ellwp",99,(void*)ellwp0,5,"GDGD0,L,pP"},
                   2014: {"ellzeta",99,(void*)ellzeta,5,"GGp"},
                   2015: {"ellztopoint",29,(void*)pointell,5,"GGp"},
                   2016: {"erfc",1,(void*)gerfc,3,"Gp"},
                   2017: {"eta",99,(void*)eta0,3,"GD0,L,p"},
                   2018: {"eulerphi",18,(void*)gphi,4,"G"},
                   2019: {"eval",18,(void*)geval,7,"G"},
                   2020: {"exp",1,(void*)gexp,3,"Gp"},
                   2021: {"factor",99,(void*)factor0,4,"GD-1,L,"},
                   2022: {"factorback",99,(void*)factorback,4,"GDG"},
                   2023: {"factorcantor",2,(void*)factcantor,4,"GG"},
                   2024: {"factorff",3,(void*)factmod9,4,"GGG"},
                   2025: {"factorial",99,(void*)mpfactr,4,"Lp"},
                   2026: {"factorint",99,(void*)factorint,4,"GD0,L,"},
                   2027: {"factormod",25,(void*)factormod0,4,"GGD0,L,"},
                   2028: {"factornf",2,(void*)polfnf,6,"GG"},
                   2029: {"factorpadic",99,(void*)factorpadic0,7,"GGLD0,L,"},
                   2030: {"ffinit",99,(void*)ffinit,4,"GLDn"},
                   2031: {"fibonacci",11,(void*)fibo,4,"L"},
                   2032: {"floor",18,(void*)gfloor,2,"G"},
                   2033: {"for",83,(void*)forpari,11,"vV=GGI"},
                   2034: {"fordiv",84,(void*)fordiv,11,"vGVI"},
                   2035: {"forprime",83,(void*)forprime,11,"vV=GGI"},
                   2036: {"forstep",86,(void*)forstep,11,"vV=GGGI"},
                   2037: {"forsubgroup",99,(void*)forsubgroup,11,"vV=GD0,L,I"},
                   2038: {"forvec",87,(void*)forvec,11,"vV=GID0,L,"},
                   2039: {"frac",18,(void*)gfrac,2,"G"},
                   2040: {"galoisfixedfield",99,(void*)galoisfixedfield,6,"GGD0,L,Dn"},
                   2041: {"galoisinit",99,(void*)galoisinit,6,"GDGD0,L,"},
                   2042: {"galoispermtopol",2,(void*)galoispermtopol,6,"GG"},
                   2043: {"galoissubcyclo",99,(void*)galoissubcyclo,6,"LGDGDnD0,L,"},
                   2044: {"gamma",1,(void*)ggamma,3,"Gp"},
                   2045: {"gammah",1,(void*)ggamd,3,"Gp"},
                   2046: {"gcd",99,(void*)gcd0,4,"GDGD0,L,"},
                   2047: {"getheap",0,(void*)getheap,11,""},
                   2048: {"getrand",0,(void*)getrand,11,"l"},
                   2049: {"getstack",0,(void*)getstack,11,"l"},
                   2050: {"gettime",0,(void*)gettime,11,"l"},
                   2051: {"hilbert",99,(void*)hil0,4,"lGGDG"},
                   2052: {"hyperu",99,(void*)hyperu,3,"GGGp"},
                   2053: {"idealadd",3,(void*)idealadd,6,"GGG"},
                   2054: {"idealaddtoone",99,(void*)idealaddtoone0,6,"GGDG"},
                   2055: {"idealappr",25,(void*)idealappr0,6,"GGD0,L,"},
                   2056: {"idealchinese",3,(void*)idealchinese,6,"GGG"},
                   2057: {"idealcoprime",3,(void*)idealcoprime,6,"GGG"},
                   2058: {"idealdiv",99,(void*)idealdiv0,6,"GGGD0,L,"},
                   2059: {"idealfactor",2,(void*)idealfactor,6,"GG"},
                   2060: {"idealhnf",99,(void*)idealhnf0,6,"GGDG"},
                   2061: {"idealintersect",3,(void*)idealintersect,6,"GGG"},
                   2062: {"idealinv",25,(void*)idealinv,6,"GG"},
                   2063: {"ideallist",99,(void*)ideallist0,6,"GLD4,L,"},
                   2064: {"ideallistarch",99,(void*)ideallistarch0,6,"GGDGD0,L,"},
                   2065: {"ideallog",3,(void*)zideallog,6,"GGG"},
                   2066: {"idealmin",99,(void*)minideal,6,"GGDGp"},
                   2067: {"idealmul",99,(void*)idealmul0,6,"GGGD0,L,p"},
                   2068: {"idealnorm",2,(void*)idealnorm,6,"GG"},
                   2069: {"idealpow",99,(void*)idealpow0,6,"GGGD0,L,p"},
                   2070: {"idealprimedec",29,(void*)primedec,6,"GG"},
                   2071: {"idealprincipal",2,(void*)principalideal,6,"GG"},
                   2072: {"idealred",99,(void*)ideallllred,6,"GGDGp"},
                   2073: {"idealstar",99,(void*)idealstar0,6,"GGD1,L,"},
                   2074: {"idealtwoelt",99,(void*)ideal_two_elt0,6,"GGDG"},
                   2075: {"idealval",30,(void*)idealval,6,"lGGG"},
                   2076: {"ideleprincipal",29,(void*)principalidele,6,"GGp"},
                   2077: {"if",80,NULL,11,NULL},
                   2078: {"imag",18,(void*)gimag,2,"G"},
                   2079: {"incgam",99,(void*)incgam0,3,"GGDGp"},
                   2080: {"incgamc",29,(void*)incgam3,3,"GGp"},
                   2081: {"intformal",14,(void*)integ,7,"GDn"},
                   2082: {"intnum",99,(void*)intnum0,9,"V=GGED0,L,p"},
                   2083: {"isfundamental",18,(void*)gisfundamental,4,"G"},
                   2084: {"isprime",99,(void*)gisprime,4,"GD0,L,"},
                   2085: {"ispseudoprime",18,(void*)gispsp,4,"G"},
                   2086: {"issquare",99,(void*)gcarrecomplet,4,"GD&"},
                   2087: {"issquarefree",18,(void*)gissquarefree,4,"G"},
                   2088: {"kronecker",2,(void*)gkronecker,4,"GG"},
                   2089: {"lcm",99,(void*)glcm0,4,"GDG"},
                   2090: {"length",10,(void*)glength,2,"lG"},
                   2091: {"lex",20,(void*)lexcmp,1,"lGG"},
                   2092: {"lift",99,(void*)lift0,2,"GDn"},
                   2093: {"lindep",99,(void*)lindep0,8,"GD0,L,p"},
                   2094: {"listcreate",11,(void*)listcreate,8,"L"},
                   2095: {"listinsert",99,(void*)listinsert,8,"GGL"},
                   2096: {"listkill",99,(void*)listkill,8,"vG"},
                   2097: {"listput",25,(void*)listput,8,"GGD0,L,"},
                   2098: {"listsort",99,(void*)listsort,8,"GD0,L,"},
                   2099: {"lngamma",1,(void*)glngamma,3,"Gp"},
                   2100: {"log",99,(void*)log0,3,"GD0,L,p"},
                   2101: {"matadjoint",18,(void*)adj,8,"G"},
                   2102: {"matalgtobasis",2,(void*)matalgtobasis,6,"GG"},
                   2103: {"matbasistoalg",2,(void*)matbasistoalg,6,"GG"},
                   2104: {"matcompanion",18,(void*)assmat,8,"G"},
                   2105: {"matdet",99,(void*)det0,8,"GD0,L,"},
                   2106: {"matdetint",18,(void*)detint,8,"G"},
                   2107: {"matdiagonal",18,(void*)diagonal,8,"G"},
                   2108: {"mateigen",1,(void*)eigen,8,"Gp"},
                   2109: {"mathess",18,(void*)hess,8,"G"},
                   2110: {"mathilbert",11,(void*)mathilbert,8,"L"},
                   2111: {"mathnf",99,(void*)mathnf0,8,"GD0,L,"},
                   2112: {"mathnfmod",2,(void*)hnfmod,8,"GG"},
                   2113: {"mathnfmodid",2,(void*)hnfmodid,8,"GG"},
                   2114: {"matid",11,(void*)idmat,8,"L"},
                   2115: {"matimage",99,(void*)matimage0,8,"GD0,L,"},
                   2116: {"matimagecompl",18,(void*)imagecompl,8,"G"},
                   2117: {"matindexrank",18,(void*)indexrank,8,"G"},
                   2118: {"matintersect",2,(void*)intersect,8,"GG"},
                   2119: {"matinverseimage",2,(void*)inverseimage,8,"GG"},
                   2120: {"matisdiagonal",10,(void*)isdiagonal,8,"lG"},
                   2121: {"matker",99,(void*)matker0,8,"GD0,L,"},
                   2122: {"matkerint",99,(void*)matkerint0,8,"GD0,L,"},
                   2123: {"matmuldiagonal",2,(void*)matmuldiagonal,8,"GG"},
                   2124: {"matmultodiagonal",2,(void*)matmultodiagonal,8,"GG"},
                   2125: {"matpascal",99,(void*)matqpascal,8,"LDG"},
                   2126: {"matrank",10,(void*)rank,8,"lG"},
                   2127: {"matrix",49,(void*)matrice,8,"GGDVDVDI"},
                   2128: {"matrixqz",2,(void*)matrixqz0,8,"GG"},
                   2129: {"matsize",18,(void*)matsize,8,"G"},
                   2130: {"matsnf",99,(void*)matsnf0,8,"GD0,L,"},
                   2131: {"matsolve",2,(void*)gauss,8,"GG"},
                   2132: {"matsolvemod",99,(void*)matsolvemod0,8,"GGGD0,L,"},
                   2133: {"matsupplement",18,(void*)suppl,8,"G"},
                   2134: {"mattranspose",18,(void*)gtrans,8,"G"},
                   2135: {"max",2,(void*)gmax,1,"GG"},
                   2136: {"min",2,(void*)gmin,1,"GG"},
                   2137: {"modreverse",18,(void*)polymodrecip,6,"G"},
                   2138: {"moebius",18,(void*)gmu,4,"G"},
                   2139: {"newtonpoly",2,(void*)newtonpoly,6,"GG"},
                   2140: {"next",0,(void*)next0,11,"D1,L,"},
                   2141: {"nextprime",18,(void*)gnextprime,4,"G"},
                   2142: {"nfalgtobasis",2,(void*)algtobasis,6,"GG"},
                   2143: {"nfbasis",99,(void*)nfbasis0,6,"GD0,L,DG"},
                   2144: {"nfbasistoalg",2,(void*)basistoalg,6,"GG"},
                   2145: {"nfdetint",2,(void*)nfdetint,6,"GG"},
                   2146: {"nfdisc",99,(void*)nfdiscf0,6,"GD0,L,DG"},
                   2147: {"nfeltdiv",3,(void*)element_div,6,"GGG"},
                   2148: {"nfeltdiveuc",3,(void*)nfdiveuc,6,"GGG"},
                   2149: {"nfeltdivmodpr",4,(void*)element_divmodpr,6,"GGGG"},
                   2150: {"nfeltdivrem",3,(void*)nfdivres,6,"GGG"},
                   2151: {"nfeltmod",3,(void*)nfmod,6,"GGG"},
                   2152: {"nfeltmul",3,(void*)element_mul,6,"GGG"},
                   2153: {"nfeltmulmodpr",4,(void*)element_mulmodpr2,6,"GGGG"},
                   2154: {"nfeltpow",3,(void*)element_pow,6,"GGG"},
                   2155: {"nfeltpowmodpr",4,(void*)element_powmodpr,6,"GGGG"},
                   2156: {"nfeltreduce",3,(void*)element_reduce,6,"GGG"},
                   2157: {"nfeltreducemodpr",3,(void*)nfreducemodpr2,6,"GGG"},
                   2158: {"nfeltval",30,(void*)element_val,6,"lGGG"},
                   2159: {"nffactor",99,(void*)nffactor,6,"GG"},
                   2160: {"nffactormod",99,(void*)nffactormod,6,"GGG"},
                   2161: {"nfgaloisapply",3,(void*)galoisapply,6,"GGG"},
                   2162: {"nfgaloisconj",99,(void*)galoisconj0,6,"GD0,L,DGp"},
                   2163: {"nfhilbert",99,(void*)nfhilbert0,6,"lGGGDG"},
                   2164: {"nfhnf",2,(void*)nfhermite,6,"GG"},
                   2165: {"nfhnfmod",3,(void*)nfhermitemod,6,"GGG"},
                   2166: {"nfinit",99,(void*)nfinit0,6,"GD0,L,p"},
                   2167: {"nfisideal",20,(void*)isideal,6,"lGG"},
                   2168: {"nfisincl",2,(void*)nfisincl,6,"GG"},
                   2169: {"nfisisom",2,(void*)nfisisom,6,"GG"},
                   2170: {"nfkermodpr",3,(void*)nfkermodpr,6,"GGG"},
                   2171: {"nfmodprinit",2,(void*)nfmodprinit,6,"GG"},
                   2172: {"nfnewprec",1,(void*)nfnewprec,6,"Gp"},
                   2173: {"nfroots",99,(void*)nfroots,6,"GG"},
                   2174: {"nfrootsof1",18,(void*)rootsof1,6,"G"},
                   2175: {"nfsnf",2,(void*)nfsmith,6,"GG"},
                   2176: {"nfsolvemodpr",4,(void*)nfsolvemodpr,6,"GGGG"},
                   2177: {"nfsubfields",99,(void*)subfields0,6,"GDG"},
                   2178: {"norm",18,(void*)gnorm,2,"G"},
                   2179: {"norml2",18,(void*)gnorml2,2,"G"},
                   2180: {"numdiv",18,(void*)gnumbdiv,4,"G"},
                   2181: {"numerator",18,(void*)numer,2,"G"},
                   2182: {"numtoperm",24,(void*)numtoperm,2,"LG"},
                   2183: {"omega",18,(void*)gomega,4,"G"},
                   2184: {"padicappr",2,(void*)apprgen9,7,"GG"},
                   2185: {"padicprec",20,(void*)padicprec,2,"lGG"},
                   2186: {"permtonum",18,(void*)permtonum,2,"G"},
                   2187: {"polcoeff",99,(void*)polcoeff0,7,"GLDn"},
                   2188: {"polcompositum",25,(void*)polcompositum0,6,"GGD0,L,"},
                   2189: {"polcyclo",99,(void*)cyclo,7,"LDn"},
                   2190: {"poldegree",99,(void*)poldegree,7,"lGDn"},
                   2191: {"poldisc",99,(void*)poldisc0,7,"GDn"},
                   2192: {"poldiscreduced",18,(void*)reduceddiscsmith,7,"G"},
                   2193: {"polgalois",99,(void*)galois,6,"Gp"},
                   2194: {"polhensellift",99,(void*)polhensellift,7,"GGGL"},
                   2195: {"polinterpolate",31,(void*)polint,7,"GDGDGD&"},
                   2196: {"polisirreducible",18,(void*)gisirreducible,7,"G"},
                   2197: {"pollead",99,(void*)pollead,7,"GDn"},
                   2198: {"pollegendre",99,(void*)legendre,7,"LDn"},
                   2199: {"polrecip",18,(void*)polrecip,7,"G"},
                   2200: {"polred",99,(void*)polred0,6,"GD0,L,DGp"},
                   2201: {"polredabs",99,(void*)polredabs0,6,"GD0,L,p"},
                   2202: {"polredord",1,(void*)ordred,6,"Gp"},
                   2203: {"polresultant",99,(void*)polresultant0,7,"GGDnD0,L,"},
                   2204: {"polroots",99,(void*)roots0,7,"GD0,L,p"},
                   2205: {"polrootsmod",25,(void*)rootmod0,7,"GGD0,L,"},
                   2206: {"polrootspadic",32,(void*)rootpadic,7,"GGL"},
                   2207: {"polsturm",99,(void*)sturmpart,7,"lGDGDG"},
                   2208: {"polsubcyclo",99,(void*)subcyclo,7,"GGDn"},
                   2209: {"polsylvestermatrix",2,(void*)sylvestermatrix,7,"GG"},
                   2210: {"polsym",21,(void*)polsym,7,"GL"},
                   2211: {"poltchebi",99,(void*)tchebi,7,"LDn"},
                   2212: {"poltschirnhaus",18,(void*)tschirnhaus,6,"G"},
                   2213: {"polylog",99,(void*)polylog0,3,"LGD0,L,p"},
                   2214: {"polzagier",99,(void*)polzag,7,"LL"},
                   2215: {"precision",99,(void*)precision0,2,"GD0,L,"},
                   2216: {"precprime",18,(void*)gprecprime,4,"G"},
                   2217: {"prime",11,(void*)prime,4,"L"},
                   2218: {"primes",11,(void*)primes,4,"L"},
                   2219: {"prod",47,(void*)produit,9,"V=GGEDG"},
                   2220: {"prodeuler",37,(void*)prodeuler,9,"V=GGEp"},
                   2221: {"prodinf",99,(void*)prodinf0,9,"V=GED0,L,p"},
                   2222: {"psi",1,(void*)gpsi,3,"Gp"},
                   2223: {"qfbclassno",99,(void*)qfbclassno0,4,"GD0,L,"},
                   2224: {"qfbcompraw",2,(void*)compraw,4,"GG"},
                   2225: {"qfbhclassno",18,(void*)hclassno,4,"G"},
                   2226: {"qfbnucomp",3,(void*)nucomp,4,"GGG"},
                   2227: {"qfbnupow",2,(void*)nupow,4,"GG"},
                   2228: {"qfbpowraw",23,(void*)powraw,4,"GL"},
                   2229: {"qfbprimeform",29,(void*)primeform,4,"GGp"},
                   2230: {"qfbred",99,(void*)qfbred0,4,"GD0,L,DGDGDG"},
                   2231: {"qfgaussred",18,(void*)sqred,8,"G"},
                   2232: {"qfjacobi",1,(void*)jacobi,8,"Gp"},
                   2233: {"qflll",99,(void*)qflll0,8,"GD0,L,p"},
                   2234: {"qflllgram",99,(void*)qflllgram0,8,"GD0,L,p"},
                   2235: {"qfminim",33,(void*)qfminim0,8,"GGGD0,L,p"},
                   2236: {"qfperfection",18,(void*)perf,8,"G"},
                   2237: {"qfsign",18,(void*)signat,8,"G"},
                   2238: {"quadclassunit",96,(void*)quadclassunit0,4,"GD0,L,DGp"},
                   2239: {"quaddisc",18,(void*)quaddisc,4,"G"},
                   2240: {"quadgen",18,(void*)quadgen,4,"G"},
                   2241: {"quadhilbert",99,(void*)quadhilbert,4,"GDGp"},
                   2242: {"quadpoly",99,(void*)quadpoly0,4,"GDn"},
                   2243: {"quadray",99,(void*)quadray,4,"GGDGp"},
                   2244: {"quadregulator",1,(void*)gregula,4,"Gp"},
                   2245: {"quadunit",1,(void*)gfundunit,4,"Gp"},
                   2246: {"random",0,(void*)genrand,2,"DG"},
                   2247: {"real",18,(void*)greal,2,"G"},
                   2248: {"removeprimes",0,(void*)removeprimes,4,"DG"},
                   2249: {"reorder",0,(void*)reorder,11,"DG"},
                   2250: {"return",0,(void*)return0,11,"DG"},
                   2251: {"rnfalgtobasis",2,(void*)rnfalgtobasis,6,"GG"},
                   2252: {"rnfbasis",2,(void*)rnfbasis,6,"GG"},
                   2253: {"rnfbasistoalg",2,(void*)rnfbasistoalg,6,"GG"},
                   2254: {"rnfcharpoly",99,(void*)rnfcharpoly,6,"GGGDn"},
                   2255: {"rnfconductor",99,(void*)rnfconductor,6,"GGD0,L,"},
                   2256: {"rnfdedekind",99,(void*)rnfdedekind,6,"GGG"},
                   2257: {"rnfdet",99,(void*)rnfdet0,6,"GGDG"},
                   2258: {"rnfdisc",2,(void*)rnfdiscf,6,"GG"},
                   2259: {"rnfeltabstorel",2,(void*)rnfelementabstorel,6,"GG"},
                   2260: {"rnfeltdown",2,(void*)rnfelementdown,6,"GG"},
                   2261: {"rnfeltreltoabs",2,(void*)rnfelementreltoabs,6,"GG"},
                   2262: {"rnfeltup",2,(void*)rnfelementup,6,"GG"},
                   2263: {"rnfequation",25,(void*)rnfequation0,6,"GGD0,L,"},
                   2264: {"rnfhnfbasis",2,(void*)rnfhermitebasis,6,"GG"},
                   2265: {"rnfidealabstorel",2,(void*)rnfidealabstorel,6,"GG"},
                   2266: {"rnfidealdown",2,(void*)rnfidealdown,6,"GG"},
                   2267: {"rnfidealhnf",2,(void*)rnfidealhermite,6,"GG"},
                   2268: {"rnfidealmul",3,(void*)rnfidealmul,6,"GGG"},
                   2269: {"rnfidealnormabs",2,(void*)rnfidealnormabs,6,"GG"},
                   2270: {"rnfidealnormrel",2,(void*)rnfidealnormrel,6,"GG"},
                   2271: {"rnfidealreltoabs",2,(void*)rnfidealreltoabs,6,"GG"},
                   2272: {"rnfidealtwoelt",2,(void*)rnfidealtwoelement,6,"GG"},
                   2273: {"rnfidealup",2,(void*)rnfidealup,6,"GG"},
                   2274: {"rnfinit",29,(void*)rnfinitalg,6,"GGp"},
                   2275: {"rnfisfree",20,(void*)rnfisfree,6,"lGG"},
                   2276: {"rnfisnorm",99,(void*)rnfisnorm,6,"GGGD1,L,p"},
                   2277: {"rnfkummer",99,(void*)rnfkummer,6,"GGD0,L,p"},
                   2278: {"rnflllgram",99,(void*)rnflllgram,6,"GGGp"},
                   2279: {"rnfnormgroup",2,(void*)rnfnormgroup,6,"GG"},
                   2280: {"rnfpolred",29,(void*)rnfpolred,6,"GGp"},
                   2281: {"rnfpolredabs",99,(void*)rnfpolredabs,6,"GGD0,L,p"},
                   2282: {"rnfpseudobasis",2,(void*)rnfpseudobasis,6,"GG"},
                   2283: {"rnfsteinitz",2,(void*)rnfsteinitz,6,"GG"},
                   2284: {"round",99,(void*)round0,2,"GD&"},
                   2285: {"serconvol",2,(void*)convol,7,"GG"},
                   2286: {"serlaplace",18,(void*)laplace,7,"G"},
                   2287: {"serreverse",18,(void*)recip,7,"G"},
                   2288: {"setintersect",2,(void*)setintersect,8,"GG"},
                   2289: {"setisset",10,(void*)setisset,8,"lG"},
                   2290: {"setminus",2,(void*)setminus,8,"GG"},
                   2291: {"setrand",99,(void*)setrand,11,"lL"},
                   2292: {"setsearch",99,(void*)setsearch,8,"lGGD0,L,"},
                   2293: {"setunion",2,(void*)setunion,8,"GG"},
                   2294: {"shift",99,(void*)gshift,1,"GL"},
                   2295: {"shiftmul",99,(void*)gmul2n,1,"GL"},
                   2296: {"sigma",99,(void*)gsumdivk,4,"GD1,L,"},
                   2297: {"sign",10,(void*)gsigne,1,"lG"},
                   2298: {"simplify",18,(void*)simplify,2,"G"},
                   2299: {"sin",1,(void*)gsin,3,"Gp"},
                   2300: {"sinh",1,(void*)gsh,3,"Gp"},
                   2301: {"sizebyte",10,(void*)taille2,2,"lG"},
                   2302: {"sizedigit",10,(void*)sizedigit,2,"lG"},
                   2303: {"solve",37,(void*)zbrent,9,"V=GGEp"},
                   2304: {"sqr",18,(void*)gsqr,3,"G"},
                   2305: {"sqrt",1,(void*)gsqrt,3,"Gp"},
                   2306: {"sqrtint",18,(void*)racine,4,"G"},
                   2307: {"sqrtn",99,(void*)gsqrtn,3,"GGD&p"},
                   2308: {"subgrouplist",99,(void*)subgrouplist0,6,"GD0,L,D0,L,p"},
                   2309: {"subst",99,(void*)gsubst0,7,"GGG"},
                   2310: {"sum",48,(void*)somme,9,"V=GGEDG"},
                   2311: {"sumalt",99,(void*)sumalt0,9,"V=GED0,L,p"},
                   2312: {"sumdiv",22,(void*)divsum,9,"GVE"},
                   2313: {"suminf",27,(void*)suminf,9,"V=GEp"},
                   2314: {"sumpos",99,(void*)sumpos0,9,"V=GED0,L,p"},
                   2315: {"tan",1,(void*)gtan,3,"Gp"},
                   2316: {"tanh",1,(void*)gth,3,"Gp"},
                   2317: {"taylor",12,(void*)tayl,7,"GnP"},
                   2318: {"teichmuller",18,(void*)teich,3,"G"},
                   2319: {"theta",29,(void*)theta,3,"GGp"},
                   2320: {"thetanullk",99,(void*)thetanullk,3,"GLp"},
                   2321: {"thue",99,(void*)thue,7,"GGDG"},
                   2322: {"thueinit",99,(void*)thueinit,7,"GD0,L,p"},
                   2323: {"trace",18,(void*)gtrace,8,"G"},
                   2324: {"truncate",99,(void*)trunc0,2,"GD&"},
                   2325: {"until",82,NULL,11,NULL},
                   2326: {"valuation",20,(void*)ggval,2,"lGG"},
                   2327: {"variable",18,(void*)gpolvar,2,"G"},
                   2328: {"vecextract",99,(void*)extract0,8,"GGDG"},
                   2329: {"vecmax",18,(void*)vecmax,1,"G"},
                   2330: {"vecmin",18,(void*)vecmin,1,"G"},
                   2331: {"vecsort",99,(void*)vecsort0,8,"GDGD0,L,"},
                   2332: {"vector",28,(void*)vecteur,8,"GDVDI"},
                   2333: {"vectorv",28,(void*)vvecteur,8,"GDVDI"},
                   2334: {"weber",99,(void*)weber0,3,"GD0,L,p"},
                   2335: {"while",81,NULL,11,NULL},
                   2336: {"zeta",1,(void*)gzeta,3,"Gp"},
                   2337: {"zetak",99,(void*)gzetakall,6,"GGD0,L,p"},
                   2338: {"zetakinit",1,(void*)initzeta,6,"Gp"},
                   2339: {"znlog",2,(void*)znlog,4,"GG"},
                   2340: {"znorder",18,(void*)order,4,"G"},
                   2341: {"znprimroot",18,(void*)ggener,4,"G"},
                   2342: {"znstar",18,(void*)znstar,4,"G"},
                   2343:
                   2344: /* DO NOT REMOVE THIS BLANK LINE: chname & helpsynchro depend on it */
                   2345: {NULL,0,NULL,0,NULL} /* sentinel */
                   2346: };

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>