Changeset 499

Show
Ignore:
Timestamp:
12/05/07 03:12:00 (10 months ago)
Author:
krobillard
Message:

Added ur_threadDestroy(). Removed ur_threadFree() from public API.
c_string.t should now handle all quotes properly.
Minor fix in GL boot
Documented stack.level.
Increased OpenAL music buffer size and now handle alutInit() failure.

Location:
trunk/thune
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/doc/UserManual

    r498 r499  
    333333---------- 
    334334 
    335 =======  =================  ================= 
    336 Word     Stack Usage        Function 
    337 =======  =================  ================= 
    338 .        (val -- )          Remove value on top of stack and print it. 
    339 .s       ()                 Show values on stack. 
    340 dup      (a -- a a)         Duplicate value on top of stack. 
    341 dup2     (a b -- a b a b)   Duplicate top 2 values. 
    342 drop     (a -- )            Remove value on top of stack. 
    343 swap     (a b -- b a)       Switch the two values on the top of stack. 
    344 over     (a b -- a b a)     Copy second item on stack to the top of the stack. 
    345 nip      (a b -- b)         Remove second value on stack. 
    346 tuck     (a b -- b a b)     Copy top value under second value. 
    347 rot      (a b c -- b c a)   Rotate third value to top. 
    348 rot.r    (a b c -- c a b)   Rotate top of stack to third position. 
    349 =======  =================  ================= 
     335===========  =================  ============================ 
     336Word         Stack Usage        Function 
     337===========  =================  ============================ 
     338.            (val -- )          Remove value on top of stack and print it. 
     339.s           ()                 Show values on stack. 
     340dup          (a -- a a)         Duplicate value on top of stack. 
     341dup2         (a b -- a b a b)   Duplicate top 2 values. 
     342drop         (a -- )            Remove value on top of stack. 
     343swap         (a b -- b a)       Switch the two values on the top of stack. 
     344over         (a b -- a b a)     Copy second item on stack to the top. 
     345nip          (a b -- b)         Remove second value on stack. 
     346tuck         (a b -- b a b)     Copy top value under second value. 
     347rot          (a b c -- b c a)   Rotate third value to top. 
     348rot.r        (a b c -- c a b)   Rotate top of stack to third position. 
     349stack.level  ( -- level)        Returns depth of data stack. 
     350===========  =================  ============================ 
    350351 
    351352 
  • trunk/thune/eval.c

    r495 r499  
    936936 
    937937 
     938// ( -- n) 
    938939UR_CALL( uc_stack_level ) 
    939940{ 
  • trunk/thune/gl/audio.c

    r458 r499  
    5555 
    5656static int _audioUp = 0; 
    57 #if 0 
     57//#define OPEN_DEVICE     1 
     58#ifdef OPEN_DEVICE 
    5859static ALCdevice*  _adevice  = 0; 
    5960static ALCcontext* _acontext = 0; 
     
    6263 
    6364 
    64 #define MUSIC_BUFFERS       2 
     65#define MUSIC_BUFFERS       3 
    6566static ALuint  _musicSource = 0; 
    6667static ALfloat _musicGain = 1.0f; 
     
    7677#define OGG_BIG_ENDIAN  1 
    7778#endif 
    78 #define OGG_BUFFER_SIZE  (4096 * 4) 
     79 
     80/*  
     81   OGG_BUFFER_SIZE is set to hold one second of data in each music buffer. 
     82   If aud_update() is not called before all buffers are played then OpenAL 
     83   will stop the sound source. 
     84*/ 
     85#define OGG_BUFFER_SIZE  (44100 * 2) 
    7986static char _oggPCM[ OGG_BUFFER_SIZE ]; 
    8087 
     
    141148int aud_startup() 
    142149{ 
    143 #if 0 
     150#ifdef OPEN_DEVICE 
    144151    _adevice = alcOpenDevice( 0 ); 
    145152    if( ! _adevice ) 
     
    150157    alutInitWithoutContext( 0, 0 ); 
    151158#else 
    152     alutInit( 0, 0 ); 
     159    if( alutInit( 0, 0 ) == AL_FALSE ) 
     160        return 0; 
    153161#endif 
    154162 
     
    175183        alDeleteBuffers( MUSIC_BUFFERS, _musicBuffers ); 
    176184 
    177 #if 0 
     185#ifdef OPEN_DEVICE 
    178186        // Could not use alutExit() on my box (FC3/Shuttle XPC) since 
    179187        // alcMakeContextCurrent(0) -> _alLockMixerPause() will hangup. 
    180188        alcDestroyContext( _acontext ); 
    181189        alcCloseDevice( _adevice ); 
    182 #endif 
     190#else 
    183191        alutExit(); 
     192#endif 
    184193    } 
    185194} 
  • trunk/thune/gl/boot.c

    r484 r499  
    156156  "    [display.area :wid/area]\n" 
    157157  "    either\n" 
    158   "    wid/resize ift (wid/area wid/resize do)\n" 
     158  "    wid/resize ift (wid/area wid/resize do drop)\n" 
    159159  "    wid\n" 
    160160  "]\n" 
  • trunk/thune/gl/gx.t

    r484 r499  
    233233    either 
    234234 
    235     wid/resize ift (wid/area wid/resize do) 
     235    wid/resize ift (wid/area wid/resize do drop) 
    236236 
    237237    wid 
  • trunk/thune/scripts/c_string.t

    r397 r499  
    33[str | a b] 
    44[ 
     5    str copy dup . {"} {\"} replace.all head 
     6    /* 
    57    str copy 
    68    [some [ 
     
    810    ]] 
    911    parse head 
     12    */ 
    1013] 
    1114func :replace-quotes  ; (str -- str) 
  • trunk/thune/thread.c

    r461 r499  
    5555        if( env->threads ) 
    5656        { 
    57 #if 0 
    5857            UThread* link = env->threads; 
    5958            ut->nextThread = link->nextThread; 
    6059            link->nextThread = ut; 
    61 #endif 
    6260        } 
    6361        else 
     
    9189 
    9290/* 
    93 void ur_threadUnlink( UThread* th ) 
     91   Free memory used by UThread. 
     92 
     93   This does NOT remove the thread from the environemnt thread list. 
     94   ur_threadDestroy() must be used for that. 
     95*/ 
     96void ur_threadFree( UThread* ut ) 
     97{ 
     98    _freeResources( ut->env, &ut->resources.arr ); 
     99 
     100    _freeArrayOfArray( &ut->blocks.arr ); 
     101    _freeArrayOfArray( &ut->bin.arr ); 
     102 
     103    memFree( ut ); 
     104} 
     105 
     106 
     107/** 
     108  Remove UThread from environment thread list and free memory. 
     109*/ 
     110void ur_threadDestroy( UThread* ut ) 
    94111{ 
    95112    UThread* it; 
    96     it = ((UrlanEnv*) th->env)->threads; 
    97     if( it == th ) 
    98         ((UrlanEnv*) th->env)->threads = (UThread*) th->nextTask; 
    99     while( it->nextTask != th ) 
    100         it = it->nextTask; 
    101     it->nextTask = th->nextTask; 
    102 } 
    103 */ 
     113    UrlanEnv* env = ut->env; 
     114 
     115    LOCK_GLOBAL 
     116 
     117    it = env->threads; 
     118    if( it == ut ) 
     119    { 
     120        if( ut == ut->nextThread ) 
     121        { 
     122            env->threads = 0; 
     123            goto done; 
     124        } 
     125        env->threads = (UThread*) ut->nextThread; 
     126    } 
     127    while( it->nextThread != ut ) 
     128        it = it->nextThread; 
     129    it->nextThread = ut->nextThread; 
     130 
     131done: 
     132    UNLOCK_GLOBAL 
     133 
     134    ur_threadFree( ut ); 
     135} 
     136 
     137 
     138/* 
     139   Return UThread to initial state with empty stacks. 
     140*/ 
     141void ur_threadReset( UThread* th ) 
     142{ 
     143    /* 
     144      Data Stack     [BOS --> TOS      eos [2 reserved]] 
     145      Control Stack  [BOC --> TOC    [<-- Local Frames]] 
     146    */ 
     147 
     148    th->state  = UR_TASK_READY; 
     149    th->callOp = 0; 
     150    th->tos = th->dstack; 
     151    // Eos reserves 2 cells for temporary call use & select! evaluation. 
     152    th->eos = th->dstack + UR_DSTACK_SIZE - 2; 
     153    th->toc = th->cstack; 
     154    th->localFT = (LocalFrame*) th->cstack + UR_CSTACK_SIZE; 
     155    ur_initType( th->tos, UT_UNSET ); 
     156 
     157    //th->localWordBlk = 0; 
     158    //th->localPos = 0; 
     159} 
    104160 
    105161 
     
    155211 
    156212 
    157 void ur_threadFree( UThread* ut ) 
    158 { 
    159     _freeResources( ut->env, &ut->resources.arr ); 
    160  
    161     _freeArrayOfArray( &ut->blocks.arr ); 
    162     _freeArrayOfArray( &ut->bin.arr ); 
    163  
    164     memFree( ut ); 
    165 } 
    166  
    167  
    168 void ur_threadReset( UThread* th ) 
    169 { 
    170     /* 
    171       Data Stack     [BOS --> TOS      eos [2 reserved]] 
    172       Control Stack  [BOC --> TOC    [<-- Local Frames]] 
    173     */ 
    174  
    175     th->state  = UR_TASK_READY; 
    176     th->callOp = 0; 
    177     th->tos = th->dstack; 
    178     // Eos reserves 2 cells for temporary call use & select! evaluation. 
    179     th->eos = th->dstack + UR_DSTACK_SIZE - 2; 
    180     th->toc = th->cstack; 
    181     th->localFT = (LocalFrame*) th->cstack + UR_CSTACK_SIZE; 
    182     ur_initType( th->tos, UT_UNSET ); 
    183  
    184     //th->localWordBlk = 0; 
    185     //th->localPos = 0; 
    186 } 
    187  
    188  
    189213void ur_pushContext( UThread* ut, UContext* ctx ) 
    190214{ 
  • trunk/thune/thune.c

    r498 r499  
    172172    UThread* ut = (UThread*) arg; 
    173173    ur_eval( ut, ut->tos[1].series.n, 0 ); 
    174     ur_threadFree( ut ); 
     174    ur_threadDestroy( ut ); 
    175175    return 0; 
    176176} 
     
    203203UR_CALL( uc_thread ) 
    204204{ 
    205     if( ur_is(tos, UT_BLOCK) || ur_is(tos, UT_STRING) ) 
     205    if( /*ur_is(tos, UT_BLOCK) ||*/ ur_is(tos, UT_STRING) ) 
    206206    { 
    207207        UThread* thr = ur_threadMake( ut->env, 64, 128 ); 
     
    217217                char* cpA; 
    218218                char* cpB; 
    219                 ur_seriesMem( ut, tos, &cpA, &cpB ); 
    220                 thr->tos[1].series.n = ur_tokenize( thr, cpA, cpB ); 
     219                UIndex blkN; 
     220 
     221                ur_binaryMem( ut, tos, &cpA, &cpB ); 
     222                blkN = ur_tokenize( thr, cpA, cpB ); 
     223                if( ! blkN ) 
     224                    return; 
     225                ur_infuseOpcodes( thr, blkN ); 
     226                thr->tos[1].series.n = blkN; 
    221227            } 
    222228 
     
    232238            } 
    233239 
    234 #if 1 
     240#if 0 
    235241            { 
    236242            void* status; 
  • trunk/thune/urlan.c

    r474 r499  
    696696 
    697697 
    698 void _freeResources( UrlanEnv* env, UArray* arr ) 
     698void _freeResources( const UrlanEnv* env, UArray* arr ) 
    699699{ 
    700700    if( arr->used ) 
     
    738738 
    739739 
     740extern void ur_threadFree( UThread* ); 
     741 
    740742/** 
    741743  Release all resources used by env. 
     
    749751        return; 
    750752 
    751     if( (thr = env->threads) ) 
    752     { 
     753    if( env->threads ) 
     754    { 
     755        mutexLock( env->mutex );        // LOCK_GLOBAL 
     756 
     757        thr = env->threads; 
    753758        do 
    754759        { 
     
    759764        while( thr != env->threads ); 
    760765 
     766        mutexUnlock( env->mutex );      // UNLOCK_GLOBAL 
    761767        mutexFree( env->mutex ); 
    762768    } 
  • trunk/thune/urlan.h

    r490 r499  
    520520UThread* ur_thread( UrlanEnv* ); 
    521521UThread* ur_threadMake( UrlanEnv*, int binCount, int blkCount ); 
    522 void     ur_threadFree( UThread* ); 
     522void     ur_threadDestroy( UThread* ); 
    523523void     ur_threadReset( UThread* ); 
    524524UBinary* ur_threadTmp( UThread* );