[BACK]Return to miscf.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / builtin

Annotation of OpenXM_contrib2/asir2000/builtin/miscf.c, Revision 1.19

1.7       noro        1: /*
                      2:  * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
                      3:  * All rights reserved.
                      4:  *
                      5:  * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
                      6:  * non-exclusive and royalty-free license to use, copy, modify and
                      7:  * redistribute, solely for non-commercial and non-profit purposes, the
                      8:  * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
                      9:  * conditions of this Agreement. For the avoidance of doubt, you acquire
                     10:  * only a limited right to use the SOFTWARE hereunder, and FLL or any
                     11:  * third party developer retains all rights, including but not limited to
                     12:  * copyrights, in and to the SOFTWARE.
                     13:  *
                     14:  * (1) FLL does not grant you a license in any way for commercial
                     15:  * purposes. You may use the SOFTWARE only for non-commercial and
                     16:  * non-profit purposes only, such as academic, research and internal
                     17:  * business use.
                     18:  * (2) The SOFTWARE is protected by the Copyright Law of Japan and
                     19:  * international copyright treaties. If you make copies of the SOFTWARE,
                     20:  * with or without modification, as permitted hereunder, you shall affix
                     21:  * to all such copies of the SOFTWARE the above copyright notice.
                     22:  * (3) An explicit reference to this SOFTWARE and its copyright owner
                     23:  * shall be made on your publication or presentation in any form of the
                     24:  * results obtained by use of the SOFTWARE.
                     25:  * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
1.8       noro       26:  * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.7       noro       27:  * for such modification or the source code of the modified part of the
                     28:  * SOFTWARE.
                     29:  *
                     30:  * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
                     31:  * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
                     32:  * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
                     33:  * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
                     34:  * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
                     35:  * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
                     36:  * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
                     37:  * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
                     38:  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
                     39:  * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
                     40:  * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
                     41:  * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
                     42:  * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
                     43:  * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
                     44:  * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
                     45:  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
                     46:  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
                     47:  *
1.19    ! takayama   48:  * $OpenXM: OpenXM_contrib2/asir2000/builtin/miscf.c,v 1.18 2003/05/16 07:56:14 noro Exp $
1.7       noro       49: */
1.1       noro       50: #include "ca.h"
                     51: #include "parse.h"
1.17      noro       52: #if !defined(VISUAL) && defined(DO_PLOT)
1.1       noro       53: #include <X11/Xlib.h>
                     54: #include <X11/cursorfont.h>
                     55: #endif
                     56:
1.12      noro       57: #if defined(VISUAL)
                     58: #include <stdlib.h>
                     59: #include <windows.h>
                     60: #endif
                     61:
1.1       noro       62: void Pquit(), Pdebug(), Pnmono(), Pnez(), Popt(), Pshell(), Pheap();
                     63: void Perror(), Perror3(), Pversion(), Pflist(), Pdelete_history(), Ppause(), Pxpause();
                     64: void Pr2g(), Pread_cmo(), Pwrite_cmo();
                     65: void Pgc(),Pbatch(),Psend_progress();
                     66: void Pnull_command();
                     67: void Pgetenv();
1.9       noro       68: void Pget_addr(),Phex_dump();
                     69: void Ppeek(),Ppoke();
1.12      noro       70: void Psleep();
1.18      noro       71: void Premove_module();
                     72: void Pmodule_list();
1.19    ! takayama   73: void Pmodule_definedp();
1.1       noro       74:
                     75: void delete_history(int,int);
                     76:
                     77: struct ftab misc_tab[] = {
1.18      noro       78:        {"module_list",Pmodule_list,0},
                     79:        {"remove_module",Premove_module,1},
1.19    ! takayama   80:        {"module_definedp",Pmodule_definedp,1},
1.12      noro       81:        {"sleep",Psleep,1},
1.1       noro       82:        {"null_command",Pnull_command,-99999},
                     83:        {"getenv",Pgetenv,1},
                     84:        {"end",Pquit,0},
                     85:        {"quit",Pquit,0},
                     86:        {"debug",Pdebug,0},
                     87:        {"shell",Pshell,-2},
                     88:        {"heap",Pheap,-1},
1.11      noro       89:        {"version",Pversion,-99999},
1.1       noro       90:        {"nmono",Pnmono,1},
                     91:        {"error",Perror,1},
                     92:        {"error3",Perror3,3},
                     93:        {"nez",Pnez,1},
1.18      noro       94:        {"flist",Pflist,-1},
1.1       noro       95:        {"delete_history",Pdelete_history,-2},
                     96:        {"pause",Ppause,0},
                     97:        {"gc",Pgc,0},
                     98:        {"batch",Pbatch,2},
                     99:        {"send_progress",Psend_progress,-2},
1.9       noro      100:        {"get_addr",Pget_addr,1},
                    101:        {"hex_dump",Phex_dump,2},
                    102:        {"peek",Ppeek,1},
                    103:        {"poke",Ppoke,2},
1.16      noro      104: #if !defined(VISUAL) && defined(DO_PLOT)
1.1       noro      105:        {"xpause",Pxpause,0},
                    106: #endif
                    107: #if 0
                    108:        {"opt",Popt,1},
                    109: #endif
                    110:        {0,0,0},
                    111: };
1.12      noro      112:
                    113: void Psleep(arg,rp)
                    114: NODE arg;
                    115: Q *rp;
                    116: {
                    117:        int ms;
                    118:
                    119:        ms = QTOS((Q)ARG0(arg));
                    120: #if defined(VISUAL)
                    121:        Sleep(ms);
                    122: #else
                    123:        usleep(ms*1000);
                    124: #endif
                    125:        *rp = ONE;
                    126: }
1.1       noro      127:
1.18      noro      128: void Pmodule_list(rp)
                    129: LIST *rp;
                    130: {
                    131:        char *name;
                    132:        NODE r,r1,m;
                    133:        STRING s;
                    134:
                    135:        r = 0;
                    136:        for ( m = MODULE_LIST; m; m = NEXT(m) ) {
                    137:                MKSTR(s,((MODULE)BDY(m))->name);
                    138:                MKNODE(r1,s,r); r = r1;
                    139:        }
                    140:        MKLIST(*rp,r);
                    141: }
                    142:
                    143: void Premove_module(arg,rp)
                    144: NODE arg;
                    145: Q *rp;
                    146: {
                    147:        NODE pm,m;
                    148:        char *name;
                    149:
                    150:        asir_assert(ARG0(arg),O_STR,"remove_module");
                    151:        name = BDY((STRING)ARG0(arg));
                    152:        for ( pm = 0, m = MODULE_LIST; m; pm = m, m = NEXT(m) )
                    153:                if ( !strcmp(name,((MODULE)BDY(m))->name) ) {
                    154:                        if ( !pm )
                    155:                                MODULE_LIST = NEXT(MODULE_LIST);
                    156:                        else
                    157:                                NEXT(pm) = NEXT(m);
                    158:                        *rp = ONE;
                    159:                        return;
1.19    ! takayama  160:                }
        !           161:        *rp = 0;
        !           162: }
        !           163:
        !           164: void Pmodule_definedp(arg,rp)
        !           165: NODE arg;
        !           166: Q *rp;
        !           167: {
        !           168:        NODE m;
        !           169:        char *name;
        !           170:
        !           171:        asir_assert(ARG0(arg),O_STR,"module_definedp");
        !           172:        name = BDY((STRING)ARG0(arg));
        !           173:     /* bug: the linear search is used here. The list of module shoud be sorted
        !           174:        and cashed, and binary search should be used. */
        !           175:        for (m = MODULE_LIST; m; m = NEXT(m) )
        !           176:                if ( !strcmp(name,((MODULE)BDY(m))->name) ) {
        !           177:                        *rp = ONE;
        !           178:                        return ;
1.18      noro      179:                }
                    180:        *rp = 0;
                    181: }
                    182:
1.1       noro      183: void Pgetenv(arg,rp)
                    184: NODE arg;
                    185: STRING *rp;
                    186: {
                    187:        char *e,*f;
                    188:        int len;
                    189:
                    190:        e = (char *)getenv(BDY((STRING)ARG0(arg)));
                    191:        if ( e ) {
                    192:                len = strlen(e);
                    193:                f = (char *)MALLOC_ATOMIC(len+1);
                    194:                strcpy(f,e);
                    195:                MKSTR(*rp,f);
                    196:        } else
                    197:                *rp = 0;
                    198: }
                    199:
                    200: void Pnull_command(arg,rp)
                    201: NODE arg;
                    202: Q *rp;
                    203: {
                    204:        *rp = 0;
                    205: }
                    206:
                    207: void Pquit(rp)
                    208: pointer *rp;
                    209: {
                    210:        if ( !NEXT(asir_infile) )
                    211:                asir_terminate(2);
                    212:        else {
                    213:                closecurrentinput();
1.5       noro      214:                if ( !asir_infile->fp && strcmp(asir_infile->name,"string") )
1.1       noro      215:                        asir_terminate(2);
                    216:        }
                    217:        *rp = 0;
                    218: }
                    219:
                    220: void Pdebug(rp)
                    221: pointer *rp;
                    222: {
                    223:        debug(0); *rp = 0;
                    224: }
                    225:
                    226: void Pshell(arg,rp)
                    227: NODE arg;
                    228: Q *rp;
                    229: {
                    230:        char *com = 0;
                    231:        char *pstr = 0;
                    232:        int status;
                    233:
                    234:        if ( arg ) {
                    235:                asir_assert(ARG0(arg),O_STR,"shell");
                    236:                com = BDY((STRING)ARG0(arg));
                    237:                if ( NEXT(arg) )
                    238:                        pstr = BDY((STRING)ARG1(arg));
                    239:        }
                    240:        status = system(com);
                    241:        STOQ(status,*rp);
                    242: }
                    243:
                    244: void Pnmono(arg,rp)
                    245: NODE arg;
                    246: Q *rp;
                    247: {
                    248:        Obj obj;
                    249:        int n;
                    250:
                    251:        obj = (Obj)ARG0(arg);
                    252:        if ( !obj || OID(obj) > O_R )
                    253:                *rp = 0;
                    254:        else
                    255:                switch (OID(obj)) {
                    256:                        case O_N: case O_P:
                    257:                                n = nmonop((P)obj); STOQ(n,*rp); break;
                    258:                        case O_R:
                    259:                                n = nmonop(NM((R)obj)) + nmonop(DN((R)obj));
                    260:                                STOQ(n,*rp); break;
                    261:                }
                    262: }
                    263:
                    264: void Pheap(arg,rp)
                    265: NODE arg;
                    266: Q *rp;
                    267: {
                    268:        int h0,h;
                    269:        void GC_expand_hp(int);
                    270:
                    271:        h0 = get_heapsize();
                    272:        if ( arg ) {
                    273:                h = QTOS((Q)ARG0(arg));
                    274:                if ( h > h0 )
                    275:                        GC_expand_hp(h-h0);
                    276:        }
                    277:        h = get_heapsize();
                    278:        STOQ(h,*rp);
                    279: }
                    280:
                    281: unsigned int get_asir_version();
1.11      noro      282: char *get_asir_distribution();
1.1       noro      283:
1.11      noro      284: void Pversion(arg,rp)
                    285: NODE arg;
                    286: Obj *rp;
1.1       noro      287: {
                    288:        unsigned int version;
1.11      noro      289:        char *distribution;
                    290:        Q q;
                    291:        STRING str;
                    292:        NODE n;
                    293:        LIST l;
1.1       noro      294:
                    295:        version = get_asir_version();
1.11      noro      296:        distribution = get_asir_distribution();
1.13      noro      297:        UTOQ(version,q);
1.11      noro      298:        if ( !argc(arg) )
                    299:                *rp = (Obj)q;
                    300:        else {
                    301:                MKSTR(str,distribution);
                    302:                n = mknode(2,q,str);
                    303:                MKLIST(l,n);
                    304:                *rp = (Obj)l;
                    305:        }
1.1       noro      306: }
                    307:
                    308: extern int nez;
                    309:
                    310: void Pnez(arg,rp)
                    311: NODE arg;
                    312: pointer *rp;
                    313: {
                    314:        nez = ARG0(arg) ? 1 : 0; *rp = 0;
                    315: }
                    316:
                    317: void Perror(arg,rp)
                    318: NODE arg;
                    319: Q *rp;
                    320: {
                    321:        char *s;
                    322:
                    323:        if ( !arg || !ARG0(arg) || (OID((Obj)ARG0(arg)) != O_STR) )
                    324:                s = "";
                    325:        else
                    326:                s = BDY((STRING)ARG0(arg));
                    327:        error(s);
                    328:        *rp = 0;
                    329: }
                    330:
                    331: void Perror3(arg,rp)
                    332: NODE arg;
                    333: Q *rp;
                    334: {
                    335:        int code;
                    336:        char *reason,*action;
                    337:
                    338:        asir_assert(ARG0(arg),O_N,"error3");
                    339:        asir_assert(ARG1(arg),O_STR,"error3");
                    340:        asir_assert(ARG2(arg),O_STR,"error3");
                    341:        code = QTOS((Q)ARG0(arg));
                    342:        reason = BDY((STRING)ARG1(arg));
                    343:        action = BDY((STRING)ARG2(arg));
1.3       noro      344: #if defined(VISUAL)
1.1       noro      345:        set_error(code,reason,action);
1.3       noro      346: #endif
1.1       noro      347:        error("");
                    348:        *rp = 0;
                    349: }
                    350:
1.18      noro      351: void Pflist(arg,rp)
                    352: NODE arg;
1.1       noro      353: LIST *rp;
                    354: {
                    355:        char *n;
                    356:        STRING name;
1.18      noro      357:        char *mname;
                    358:        NODE t,r,r0,m;
1.1       noro      359:        LIST l;
                    360:
1.18      noro      361:        if ( argc(arg) ) {
                    362:                /* module name is specified */
                    363:                asir_assert(ARG0(arg),O_STR,"flist");
                    364:                mname = BDY((STRING)ARG0(arg));
                    365:                r0 = 0;
                    366:                for ( m = MODULE_LIST; m; m = NEXT(m) ) {
                    367:                        if ( !strcmp(mname,((MODULE)BDY(m))->name) ) {
                    368:                                t = ((MODULE)BDY(m))->usrf_list;
                    369:                                for ( r0 = 0; t; t = NEXT(t) )
                    370:                                        if ( ((FUNC)BDY(t))->id != A_UNDEF ) {
                    371:                                                n = NAME((FUNC)BDY(t)); MKSTR(name,n);
                    372:                                                MKNODE(r,name,r0); r0 = r;
                    373:                                }
                    374:                        }
1.1       noro      375:                }
1.18      noro      376:        } else {
                    377:                for ( t = usrf, r0 = 0; t; t = NEXT(t) )
                    378:                        if ( ((FUNC)BDY(t))->id != A_UNDEF ) {
                    379:                                n = NAME((FUNC)BDY(t)); MKSTR(name,n);
                    380:                                MKNODE(r,name,r0); r0 = r;
                    381:                        }
                    382:                for ( t = ubinf; t; t = NEXT(t) )
                    383:                        if ( ((FUNC)BDY(t))->id != A_UNDEF ) {
                    384:                                n = NAME((FUNC)BDY(t)); MKSTR(name,n);
                    385:                                MKNODE(r,name,r0); r0 = r;
                    386:                        }
                    387:                for ( t = sysf; t; t = NEXT(t) )
                    388:                        if ( ((FUNC)BDY(t))->id != A_UNDEF ) {
                    389:                                n = NAME((FUNC)BDY(t)); MKSTR(name,n);
                    390:                                MKNODE(r,name,r0); r0 = r;
                    391:                        }
                    392:        }
1.1       noro      393:        MKLIST(l,r0); *rp = l;
                    394: }
                    395:
                    396: void Pdelete_history(arg,rp)
                    397: NODE arg;
                    398: Q *rp;
                    399: {
                    400:        switch ( argc(arg) ) {
                    401:                case 0: default:
                    402:                        delete_history(0,(int)APVS->n);
                    403:                        break;
                    404:                case 1:
                    405:                        delete_history(QTOS((Q)ARG0(arg)),1);
                    406:                        break;
                    407:        }
                    408:        *rp = 0;
                    409: }
                    410:
                    411: void delete_history(start,n)
                    412: int start,n;
                    413: {
                    414:        int i,max;
                    415:
                    416:        max = APVS->n;
                    417:        if ( start < 0 || start >= max )
                    418:                return;
                    419:        if ( start + n > max )
                    420:                n = max - start;
                    421:        for ( i = 0; i < n; i++ )
                    422:                APVS->va[start+i].priv = 0;
                    423: }
                    424:
                    425: void Ppause(rp)
                    426: LIST *rp;
                    427: {
                    428:        char buf[BUFSIZ];
                    429:
                    430:        fgets(buf,BUFSIZ,stdin);
                    431:        *rp = 0;
                    432: }
                    433:
                    434: void Pgc(rp)
                    435: LIST *rp;
                    436: {
                    437:        GC_gcollect();
                    438:        *rp = 0;
                    439: }
                    440:
                    441: int exec_file(char *,char *);
                    442:
                    443: void Pbatch(arg,rp)
                    444: NODE arg;
                    445: Q *rp;
                    446: {
                    447:        int ret;
                    448:
                    449:        ret = exec_file(BDY((STRING)ARG0(arg)),BDY((STRING)ARG1(arg)));
                    450:        STOQ(ret,*rp);
                    451: }
                    452:
1.16      noro      453: #if !defined(VISUAL) && defined(DO_PLOT)
1.1       noro      454: void Pxpause(rp)
                    455: Q *rp;
                    456: {
                    457:        if ( !init_display() )
                    458:                *rp = 0;
                    459:        else {
                    460:                grab_pointer(); *rp = ONE;
                    461:        }
                    462: }
                    463:
                    464: static Display *display;
                    465: static Window rootwin;
                    466:
                    467: init_display()
                    468: {
                    469:        char *dname;
                    470:        unsigned int tmp;
                    471:        static int initialized;
                    472:        int argc;
                    473:        char *argv[1];
                    474:
                    475:        if ( initialized )
                    476:                return 1;
                    477:        else
                    478:                initialized = 1;
                    479:        dname = (char *)getenv("DISPLAY");
                    480:
                    481:        display = XOpenDisplay(dname);
                    482:        if ( !display ) {
                    483:                fprintf(stderr,"Can't open display\n");
                    484:                return 0;
                    485:        }
                    486:        rootwin = RootWindow(display,DefaultScreen(display));
                    487: }
                    488:
                    489: grab_pointer()
                    490: {
                    491:        XEvent ev;
                    492:        static Cursor cursor;
                    493:
                    494:        if ( !cursor )
                    495:                cursor = XCreateFontCursor(display,XC_leftbutton);
                    496:        XGrabPointer(display,rootwin,True,ButtonPressMask,GrabModeAsync,GrabModeAsync,None,cursor,CurrentTime);
                    497:        while ( 1 ) {
                    498:                XNextEvent(display,&ev);
                    499:                if ( ev.xany.type == ButtonPress )
                    500:                        break;
                    501:        }
                    502:        XUngrabPointer(display,CurrentTime);
                    503:        XSync(display,False);
                    504:        return;
                    505: }
                    506: #endif
                    507:
                    508: void Psend_progress(NODE arg,Q *rp)
                    509: {
                    510: #if defined(VISUAL)
                    511:        short per;
                    512:        char *msg;
                    513:
                    514:        per = (short)QTOS((Q)BDY(arg)); arg = NEXT(arg);
                    515:        if ( arg )
                    516:                msg = BDY((STRING)BDY(arg));
                    517:        else
                    518:                msg = "";
                    519:        send_progress(per,msg);
                    520: #endif
1.9       noro      521:        *rp = 0;
                    522: }
                    523:
                    524: void Pget_addr(arg,rp)
                    525: NODE arg;
                    526: Q *rp;
                    527: {
                    528:        pointer obj;
                    529:        unsigned int u,l;
                    530:        N n;
                    531:
                    532:        obj = ARG0(arg);
                    533:        if ( sizeof(pointer) == sizeof(unsigned int) ) {
                    534:                UTOQ((unsigned int)obj,*rp);
                    535:        } else {
                    536:                /* a pointer must fit in long */
                    537:                u = ((unsigned long)obj)>>32;
                    538:                l = ((unsigned long)obj)&(unsigned long)0xffffffff;
                    539:                if ( u ) {
                    540:                        n = NALLOC(2); PL(n) = 2; BD(n)[0] = l; BD(n)[1] = u;
                    541:                        NTOQ(n,1,*rp);
                    542:                } else {
                    543:                        UTOQ(l,*rp);
                    544:                }
                    545:        }
                    546: }
                    547:
                    548: unsigned char *qtoaddr(q)
                    549: Q q;
                    550: {
                    551:        unsigned char *addr;
                    552:        N n;
                    553:
                    554:        if ( !q )
                    555:                return 0;
                    556:        n = NM(q);
                    557:        if ( (sizeof(pointer) == sizeof(unsigned int)) || (PL(n) == 1) )
                    558:                addr = (char *)BD(n)[0];
                    559:        else {
                    560:                /* a pointer must fit in long */
                    561:                addr = (char *)((((unsigned long)BD(n)[1])<<32)
                    562:                        | ((unsigned long)BD(n)[0]));
                    563:        }
                    564:        return addr;
                    565: }
                    566:
                    567: void Phex_dump(arg,rp)
                    568: NODE arg;
                    569: Q *rp;
                    570: {
                    571:        unsigned char *start;
                    572:        int len,i;
                    573:
                    574:        *rp = 0;
                    575:        start = qtoaddr((Q)ARG0(arg));
                    576:        len = QTOS((Q)ARG1(arg));
                    577:        for ( i = 0; i < len; i++ ) {
                    578:                if ( !(i%16) )
                    579:                        fprintf(asir_out,"%08x: ",start+i);
                    580:                fprintf(asir_out,"%02x",start[i]);
                    581:                if ( !((i+1)%16) )
                    582:                        fprintf(asir_out,"\n");
                    583:                else if ( !((i+1)%4) )
                    584:                        fprintf(asir_out," ");
                    585:        }
                    586:        if ( i%16 )
                    587:                fprintf(asir_out,"\n");
                    588: }
                    589:
                    590: void Ppeek(arg,rp)
                    591: NODE arg;
                    592: Q *rp;
                    593: {
                    594:        unsigned int b;
                    595:        unsigned char *a;
                    596:
                    597:        a = qtoaddr((Q)ARG0(arg));
                    598:        b = (unsigned int) (*a);
                    599:        UTOQ(b,*rp);
                    600: }
                    601:
                    602: void Ppoke(arg,rp)
                    603: NODE arg;
                    604: Q *rp;
                    605: {
                    606:        unsigned char *addr;
                    607:
                    608:        addr = qtoaddr((Q)ARG0(arg));
                    609:        *addr = (unsigned char)QTOS((Q)ARG1(arg));
1.1       noro      610:        *rp = 0;
                    611: }
                    612:
                    613: #if 0
                    614: static int optimize;
                    615: static struct oN oPSN[1000];
                    616: static struct oQ oPSZ[1000],oMSZ[1000];
                    617: static szinit = 0;
                    618:
                    619: void Popt(arg,rp)
                    620: NODE arg;
                    621: pointer *rp;
                    622: {
                    623:        optimize = ARG0(arg) ? 1 : 0; *rp = 0;
                    624: }
                    625:
                    626:
                    627: void sz_init() {
                    628:        int i;
                    629:        Q t;
                    630:
                    631:        for ( i = 1; i < 1000; i++ ) {
                    632:                oPSN[i].p = 1; oPSN[i].b[0] = i;
                    633:                t = &oPSZ[i];
                    634:                OID(t) = O_N; NID(t) = N_Q; SGN(t) = 1; NM(t) = &oPSN[i]; DN(t) = 0;
                    635:                t = &oMSZ[i];
                    636:                OID(t) = O_N; NID(t) = N_Q; SGN(t) = -1; NM(t) = &oPSN[i]; DN(t) = 0;
                    637:        }
                    638:        szinit = 1;
                    639: }
                    640:
                    641: optobj(p)
                    642: Obj *p;
                    643: {
                    644:        Obj t;
                    645:        int n;
                    646:        DCP dc;
                    647:
                    648:        if ( t = *p )
                    649:                switch ( OID(t) ) {
                    650:                        case O_N:
                    651:                                if ( (NID(t)==N_Q) && INT(t) && (PL(NM((Q)t))==1) ) {
                    652:                                        n = QTOS((Q)t);
                    653:                                        if ( !szinit )
                    654:                                                sz_init();
                    655:                                        if ( n < 1000 )
                    656:                                                *p = (Obj)(SGN((Q)t)>0?&oPSZ[n]:&oMSZ[n]);
                    657:                                }
                    658:                                break;
                    659:                        case O_P:
                    660:                                for ( dc = DC((P)t); dc; dc = NEXT(dc) ) {
                    661:                                        optobj(&DEG(dc)); optobj(&COEF(dc));
                    662:                                }
                    663:                                break;
                    664:                        case O_R:
                    665:                                optobj(&NM((R)t)); optobj(&DN((R)t)); break;
                    666:                        default:
                    667:                                break;
                    668:                }
                    669: }
                    670: #endif

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