Mercurial > hg > aim92
view stitch/ops.c @ 0:5242703e91d3 tip
Initial checkin for AIM92 aimR8.2 (last updated May 1997).
author | tomwalters |
---|---|
date | Fri, 20 May 2011 15:19:45 +0100 |
parents | |
children |
line wrap: on
line source
/* Copyright (c) Applied Psychology Unit, Medical Research Council. 1988, 1989 =========================================================================== Permission to use, copy, modify, and distribute this software without fee is hereby granted for research purposes, provided that this copyright notice appears in all copies and in all supporting documentation, and that the software is not redistributed for any fee (except for a nominal shipping charge). Anyone wanting to incorporate all or part of this software in a commercial product must obtain a license from the Medical Research Council. The MRC makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* ops.c ===== quickie operators for stitch */ typedef char *Pointer ; typedef char *Address ; /* a portable inteface to the system */ extern void stitch_error() ; extern Pointer stitch_malloc() ; extern Pointer stitch_copied_malloc() ; extern Pointer stitch_zeroed_malloc() ; extern Pointer stitch_ralloc() ; extern Pointer stitch_calloc() ; extern void stitch_free() ; extern void stitch_exit() ; /* beware these definitions, they are for speed and fail if stitch.h not included */ extern void (*stitch_bcopy)() ; extern void (*stitch_bzero)() ; extern char stitchStructStr[] ; typedef struct _buffer *Buffer ; struct _buffer { Pointer addr ; unsigned size, refs ; } ; extern Buffer NewBuffer( /* char where[] */ ) ; extern Buffer SharedBuffer( /* Buffer buffer */ ) ; extern Buffer ResizedBuffer( /* Buffer buffer, unsigned size */ ) ; extern void FreeBuffer( /* Buffer buffer */ ) ; /* basic types */ typedef struct _source *Source, *SourceArray[1] ; typedef Source CharSource, ShortSource, IntSource, FloatSource, DoubleSource, ComplexSource ; typedef SourceArray CharSourceArray, ShortSourceArray, IntSourceArray, FloatSourceArray, DoubleSourceArray, ComplexSourceArray ; typedef int ByteCount ; /* dependant on type of source */ struct _source { Pointer (*pull)(), (*fill)(), (*roll)(), returned ; char *name, *type ; int opened ; Source (*open)() ; } ; struct _source_operators { Source (*set)() ; Pointer (*delete)() ; Source (*setType)() ; char *(*getType)() ; char *(*getName)() ; } ; struct _pullable_source { struct _source parent ; } ; struct _fillable_source { struct _source parent ; Buffer buffer ; } ; extern Source setSource() ; extern Source typeSource() ; extern char *sourceType() ; extern char *sourceName() ; extern Pointer deleteSource() ; extern Pointer oldPull(), oldFill(), oldRoll() ; extern void sinkSource() ; extern void CloseSource() ; extern void sinkAndCloseSource() ; /* derived source types for different purposes */ extern Source newTappingSource() ; extern Source newRollableSource() ; extern Pointer nonRoller() ; /* fundamental active source types */ extern Source setPullableSource() ; extern Pointer deletePullableSource() ; /* simple assertive derived sources */ extern Source newSlaveSource() ; extern Source newStaticSource() ; extern Source newRetainingSource() ; extern Source newDelayingSource() ; extern Source newBlockingSource() ; /* derived higher level filling sources */ extern Source setFillableSource() ; extern Pointer deleteFillableSource() ; extern Source newSegmentingSource() ; extern Source setCallbackSource() ; extern Source newExternalSource() ; extern Source newThroughSource() ; extern Source newProcessingSource() ; extern Source newSimpleProcessingSource() ; extern Source newMultiplexedSource() ; extern Source newMergingSource() ; extern Source sharingSource() ; extern Source *BindSources() ; /* for compatability... for now */ extern Source stdStaticSource() ; extern Source stdSlaveSource() ; extern Source stdAutoSource() ; extern Source stdSelfSource() ; extern Source EmptySource ; /* stypes.h ====== defines types for sources operations */ typedef struct { char *ident ; int size ; Source (*maker)() ; } TypeInfo ; extern int typeEntryNumber() ; extern Source TypeConvertSource() ; extern Source SourceSource() ; extern char CharIdent[] ; extern char ShortIdent[] ; extern char IntIdent[] ; extern char LongIdent[] ; extern char FloatIdent[] ; extern char DoubleIdent[] ; /* basic data operations */ extern CharSource ConstantCharSource( ), IntegrateCharSource( ), CallingCharSource( ) ; extern ShortSource ConstantShortSource( ), IntegrateShortSource( ), CallingShortSource( ) ; extern IntSource ConstantIntSource( ), IntegrateIntSource( ), CallingIntSource( ) ; extern FloatSource ConstantFloatSource( ), IntegrateFloatSource( ), CallingFloatSource( ) ; extern DoubleSource ConstantDoubleSource( ), IntegrateDoubleSource( ), CallingDoubleSource( ) ; extern ComplexSource ConstantComplexSource( ), IntegrateComplexSource( ), CallingComplexSource( ) ; /* binary operators */ extern CharSource AddCharSources( ), SubtractCharSources( ), MultiplyCharSources( ), DivideCharSources( ) ; extern ShortSource AddShortSources( ), SubtractShortSources( ), MultiplyShortSources( ), DivideShortSources( ) ; extern IntSource AddIntSources( ), SubtractIntSources( ), MultiplyIntSources( ), DivideIntSources( ) ; extern FloatSource AddFloatSources( ), SubtractFloatSources( ), MultiplyFloatSources( ), DivideDoubleSources( ) ; extern DoubleSource AddDoubleSources( ), SubtractDoubleSources( ), MultiplyDoubleSources( ), DivideFloatSources( ) ; extern ComplexSource AddComplexSources( ), SubtractComplexSources( ), MultiplyComplexSources( ), DivideComplexSources( ) ; extern Source AddSources( ), SubtractSources( ), MultiplySources( ), DivideSources( ) ; /* convertors */ extern CharSource CharCharSource( ), ShortCharSource( ), IntCharSource( ), FloatCharSource( ), DoubleCharSource( ) ; extern ShortSource CharShortSource( ), ShortShortSource( ), IntShortSource( ), FloatShortSource( ), DoubleShortSource( ) ; extern IntSource CharIntSource( ), ShortIntSource( ), IntIntSource( ), FloatIntSource( ), DoubleIntSource( ) ; extern FloatSource CharFloatSource( ), ShortFloatSource( ), IntFloatSource( ), FloatFloatSource( ), DoubleFloatSource( ) ; extern DoubleSource CharDoubleSource( ), ShortDoubleSource( ), IntDoubleSource( ), FloatDoubleSource( ), DoubleDoubleSource( ) ; extern ComplexSource CharComplexSource( ), ShortComplexSource( ), IntComplexSource( ), FloatComplexSource( ), DoubleComplexSource( ) ; extern Source SourceCharSource( ), SourceShortSource( ), SourceIntSource( ), SourceFloatSource( ), SourceDoubleSource( ), SourceComplexSource( ) ; static void charConstantCallback( state, bytes, buffer, end ) char *state ; ByteCount *bytes ; char *buffer, *end ; { register char i, *optr = buffer, *eptr = end ; i = *state ; if( optr < eptr ) do *optr++ = i ; while( optr < eptr ) ; return ; } CharSource ConstantCharSource( constant ) char constant ; { char * state = ( char * ) stitch_malloc( (unsigned) ( ( sizeof * ( char * ) 0 ) ), stitchStructStr ) ; *state = constant ; return ( newExternalSource( (Pointer) ( (Pointer) state ), charConstantCallback, stitch_free, "ops.type constant" ) ) ; } static void charIntegralCallback( integral, bytes, buffer, end, input ) char *integral ; ByteCount *bytes ; char *buffer, *end, *input ; { register char *iptr = input ; register char *optr = buffer ; register char *eptr = end ; if( optr < eptr ) do { *optr++ = *integral ; *integral += *iptr++ ; } while( optr < eptr ) ; return ; } CharSource IntegrateCharSource( source, initial ) CharSource source ; char initial ; { char * integral = ( char * ) stitch_malloc( (unsigned) ( ( sizeof * ( char * ) 0 ) ), stitchStructStr ) ; *integral = initial ; return ( newProcessingSource( (Pointer) ( (Pointer) integral ), charIntegralCallback, stitch_free, source, "ops.type integrating" ) ) ; } static void charCallingCallback( function, bytes, buffer, end, input ) char (*function)() ; ByteCount *bytes ; char *buffer, *end, *input ; { register char *iptr = input ; register char *optr = buffer ; register char *eptr = end ; if( optr < eptr ) do *optr++ = function( *iptr++ ) ; while( optr < eptr ) ; return ; } CharSource CallingCharSource( source, function ) CharSource source ; char (*function)() ; { return ( newProcessingSource( (Pointer) ( (Pointer) function ), charCallingCallback, (void ( * )()) 0, source, "ops.type function" ) ) ; } /* do operators */ static void AddCharOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; char *output, *end, *input1, *input2 ; { register char *optr = output ; register char *ipt1 = input1 ; register char *ipt2 = input2 ; register char *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ + *ipt2++ ; while( optr < eptr ) ; return ; } Source AddCharSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddCharOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source AddCharSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddCharOp, (void ( * )()) 0, inputs, "operator" ) ) ; } static void SubtractCharOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; char *output, *end, *input1, *input2 ; { register char *optr = output ; register char *ipt1 = input1 ; register char *ipt2 = input2 ; register char *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ - *ipt2++ ; while( optr < eptr ) ; return ; } Source SubtractCharSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractCharOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source SubtractCharSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractCharOp, (void ( * )()) 0, inputs, "operator" ) ) ; } static void MultiplyCharOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; char *output, *end, *input1, *input2 ; { register char *optr = output ; register char *ipt1 = input1 ; register char *ipt2 = input2 ; register char *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ * *ipt2++ ; while( optr < eptr ) ; return ; } Source MultiplyCharSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyCharOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source MultiplyCharSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyCharOp, (void ( * )()) 0, inputs, "operator" ) ) ; } static void DivideCharOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; char *output, *end, *input1, *input2 ; { register char *optr = output ; register char *ipt1 = input1 ; register char *ipt2 = input2 ; register char *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ / *ipt2++ ; while( optr < eptr ) ; return ; } Source DivideCharSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideCharOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source DivideCharSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideCharOp, (void ( * )()) 0, inputs, "operator" ) ) ; } /* create convertors */ static void CharCharCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; char *buffer ; { register char *i = ( ( char *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( char *) 0l + ( ( ( bytes ) >> ( sizeof( char) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register char *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } CharSource CharCharSource( source ) CharSource source ; { return( stdAutoSource( ( Pointer ) source, CharCharCallback ) ) ; } static void ShortCharCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; char *buffer ; { register short *i = ( ( short *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( short *) 0l + ( ( ( bytes ) >> ( sizeof( char) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register char *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } CharSource ShortCharSource( source ) CharSource source ; { return( stdAutoSource( ( Pointer ) source, ShortCharCallback ) ) ; } static void IntCharCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; char *buffer ; { register int *i = ( ( int *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( int *) 0l + ( ( ( bytes ) >> ( sizeof( char) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register char *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } CharSource IntCharSource( source ) CharSource source ; { return( stdAutoSource( ( Pointer ) source, IntCharCallback ) ) ; } static void FloatCharCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; char *buffer ; { register float *i = ( ( float *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( float *) 0l + ( ( ( bytes ) >> ( sizeof( char) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register char *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } CharSource FloatCharSource( source ) CharSource source ; { return( stdAutoSource( ( Pointer ) source, FloatCharCallback ) ) ; } static void DoubleCharCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; char *buffer ; { register double *i = ( ( double *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( double *) 0l + ( ( ( bytes ) >> ( sizeof( char) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register char *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } CharSource DoubleCharSource( source ) CharSource source ; { return( stdAutoSource( ( Pointer ) source, DoubleCharCallback ) ) ; } Source SourceCharSource( source ) Source source ; { static Source (*converts[])() = { SourceSource, CharCharSource, ShortCharSource, IntCharSource, FloatCharSource, DoubleCharSource } ; return ( converts[ typeEntryNumber( sourceType( (struct _source *) source ) ) ]( source ) ) ; } static void shortConstantCallback( state, bytes, buffer, end ) short *state ; ByteCount *bytes ; short *buffer, *end ; { register short i, *optr = buffer, *eptr = end ; i = *state ; if( optr < eptr ) do *optr++ = i ; while( optr < eptr ) ; return ; } ShortSource ConstantShortSource( constant ) short constant ; { short * state = ( short * ) stitch_malloc( (unsigned) ( ( sizeof * ( short * ) 0 ) ), stitchStructStr ) ; *state = constant ; return ( newExternalSource( (Pointer) ( (Pointer) state ), shortConstantCallback, stitch_free, "ops.type constant" ) ) ; } static void shortIntegralCallback( integral, bytes, buffer, end, input ) short *integral ; ByteCount *bytes ; short *buffer, *end, *input ; { register short *iptr = input ; register short *optr = buffer ; register short *eptr = end ; if( optr < eptr ) do { *optr++ = *integral ; *integral += *iptr++ ; } while( optr < eptr ) ; return ; } ShortSource IntegrateShortSource( source, initial ) ShortSource source ; short initial ; { short * integral = ( short * ) stitch_malloc( (unsigned) ( ( sizeof * ( short * ) 0 ) ), stitchStructStr ) ; *integral = initial ; return ( newProcessingSource( (Pointer) ( (Pointer) integral ), shortIntegralCallback, stitch_free, source, "ops.type integrating" ) ) ; } static void shortCallingCallback( function, bytes, buffer, end, input ) short (*function)() ; ByteCount *bytes ; short *buffer, *end, *input ; { register short *iptr = input ; register short *optr = buffer ; register short *eptr = end ; if( optr < eptr ) do *optr++ = function( *iptr++ ) ; while( optr < eptr ) ; return ; } ShortSource CallingShortSource( source, function ) ShortSource source ; short (*function)() ; { return ( newProcessingSource( (Pointer) ( (Pointer) function ), shortCallingCallback, (void ( * )()) 0, source, "ops.type function" ) ) ; } /* do operators */ static void AddShortOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; short *output, *end, *input1, *input2 ; { register short *optr = output ; register short *ipt1 = input1 ; register short *ipt2 = input2 ; register short *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ + *ipt2++ ; while( optr < eptr ) ; return ; } Source AddShortSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddShortOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source AddShortSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddShortOp, (void ( * )()) 0, inputs, "operator" ) ) ; } static void SubtractShortOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; short *output, *end, *input1, *input2 ; { register short *optr = output ; register short *ipt1 = input1 ; register short *ipt2 = input2 ; register short *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ - *ipt2++ ; while( optr < eptr ) ; return ; } Source SubtractShortSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractShortOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source SubtractShortSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractShortOp, (void ( * )()) 0, inputs, "operator" ) ) ; } static void MultiplyShortOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; short *output, *end, *input1, *input2 ; { register short *optr = output ; register short *ipt1 = input1 ; register short *ipt2 = input2 ; register short *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ * *ipt2++ ; while( optr < eptr ) ; return ; } Source MultiplyShortSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyShortOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source MultiplyShortSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyShortOp, (void ( * )()) 0, inputs, "operator" ) ) ; } static void DivideShortOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; short *output, *end, *input1, *input2 ; { register short *optr = output ; register short *ipt1 = input1 ; register short *ipt2 = input2 ; register short *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ / *ipt2++ ; while( optr < eptr ) ; return ; } Source DivideShortSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideShortOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source DivideShortSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideShortOp, (void ( * )()) 0, inputs, "operator" ) ) ; } /* create convertors */ static void CharShortCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; short *buffer ; { register char *i = ( ( char *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( char *) 0l + ( ( ( bytes ) >> ( sizeof( short) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register short *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } ShortSource CharShortSource( source ) ShortSource source ; { return( stdAutoSource( ( Pointer ) source, CharShortCallback ) ) ; } static void ShortShortCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; short *buffer ; { register short *i = ( ( short *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( short *) 0l + ( ( ( bytes ) >> ( sizeof( short) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register short *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } ShortSource ShortShortSource( source ) ShortSource source ; { return( stdAutoSource( ( Pointer ) source, ShortShortCallback ) ) ; } static void IntShortCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; short *buffer ; { register int *i = ( ( int *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( int *) 0l + ( ( ( bytes ) >> ( sizeof( short) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register short *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } ShortSource IntShortSource( source ) ShortSource source ; { return( stdAutoSource( ( Pointer ) source, IntShortCallback ) ) ; } static void FloatShortCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; short *buffer ; { register float *i = ( ( float *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( float *) 0l + ( ( ( bytes ) >> ( sizeof( short) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register short *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } ShortSource FloatShortSource( source ) ShortSource source ; { return( stdAutoSource( ( Pointer ) source, FloatShortCallback ) ) ; } static void DoubleShortCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; short *buffer ; { register double *i = ( ( double *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( double *) 0l + ( ( ( bytes ) >> ( sizeof( short) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register short *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } ShortSource DoubleShortSource( source ) ShortSource source ; { return( stdAutoSource( ( Pointer ) source, DoubleShortCallback ) ) ; } Source SourceShortSource( source ) Source source ; { static Source (*converts[])() = { SourceSource, CharShortSource, ShortShortSource, IntShortSource, FloatShortSource, DoubleShortSource } ; return ( converts[ typeEntryNumber( sourceType( (struct _source *) source ) ) ]( source ) ) ; } static void intConstantCallback( state, bytes, buffer, end ) int *state ; ByteCount *bytes ; int *buffer, *end ; { register int i, *optr = buffer, *eptr = end ; i = *state ; if( optr < eptr ) do *optr++ = i ; while( optr < eptr ) ; return ; } IntSource ConstantIntSource( constant ) int constant ; { int * state = ( int * ) stitch_malloc( (unsigned) ( ( sizeof * ( int * ) 0 ) ), stitchStructStr ) ; *state = constant ; return ( newExternalSource( (Pointer) ( (Pointer) state ), intConstantCallback, stitch_free, "ops.type constant" ) ) ; } static void intIntegralCallback( integral, bytes, buffer, end, input ) int *integral ; ByteCount *bytes ; int *buffer, *end, *input ; { register int *iptr = input ; register int *optr = buffer ; register int *eptr = end ; if( optr < eptr ) do { *optr++ = *integral ; *integral += *iptr++ ; } while( optr < eptr ) ; return ; } IntSource IntegrateIntSource( source, initial ) IntSource source ; int initial ; { int * integral = ( int * ) stitch_malloc( (unsigned) ( ( sizeof * ( int * ) 0 ) ), stitchStructStr ) ; *integral = initial ; return ( newProcessingSource( (Pointer) ( (Pointer) integral ), intIntegralCallback, stitch_free, source, "ops.type integrating" ) ) ; } static void intCallingCallback( function, bytes, buffer, end, input ) int (*function)() ; ByteCount *bytes ; int *buffer, *end, *input ; { register int *iptr = input ; register int *optr = buffer ; register int *eptr = end ; if( optr < eptr ) do *optr++ = function( *iptr++ ) ; while( optr < eptr ) ; return ; } IntSource CallingIntSource( source, function ) IntSource source ; int (*function)() ; { return ( newProcessingSource( (Pointer) ( (Pointer) function ), intCallingCallback, (void ( * )()) 0, source, "ops.type function" ) ) ; } /* do operators */ static void AddIntOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; int *output, *end, *input1, *input2 ; { register int *optr = output ; register int *ipt1 = input1 ; register int *ipt2 = input2 ; register int *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ + *ipt2++ ; while( optr < eptr ) ; return ; } Source AddIntSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddIntOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source AddIntSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddIntOp, (void ( * )()) 0, inputs, "operator" ) ) ; } static void SubtractIntOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; int *output, *end, *input1, *input2 ; { register int *optr = output ; register int *ipt1 = input1 ; register int *ipt2 = input2 ; register int *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ - *ipt2++ ; while( optr < eptr ) ; return ; } Source SubtractIntSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractIntOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source SubtractIntSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractIntOp, (void ( * )()) 0, inputs, "operator" ) ) ; } static void MultiplyIntOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; int *output, *end, *input1, *input2 ; { register int *optr = output ; register int *ipt1 = input1 ; register int *ipt2 = input2 ; register int *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ * *ipt2++ ; while( optr < eptr ) ; return ; } Source MultiplyIntSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyIntOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source MultiplyIntSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyIntOp, (void ( * )()) 0, inputs, "operator" ) ) ; } static void DivideIntOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; int *output, *end, *input1, *input2 ; { register int *optr = output ; register int *ipt1 = input1 ; register int *ipt2 = input2 ; register int *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ / *ipt2++ ; while( optr < eptr ) ; return ; } Source DivideIntSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideIntOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source DivideIntSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideIntOp, (void ( * )()) 0, inputs, "operator" ) ) ; } /* create convertors */ static void CharIntCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; int *buffer ; { register char *i = ( ( char *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( char *) 0l + ( ( ( bytes ) >> ( sizeof( int) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register int *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } IntSource CharIntSource( source ) IntSource source ; { return( stdAutoSource( ( Pointer ) source, CharIntCallback ) ) ; } static void ShortIntCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; int *buffer ; { register short *i = ( ( short *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( short *) 0l + ( ( ( bytes ) >> ( sizeof( int) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register int *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } IntSource ShortIntSource( source ) IntSource source ; { return( stdAutoSource( ( Pointer ) source, ShortIntCallback ) ) ; } static void IntIntCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; int *buffer ; { register int *i = ( ( int *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( int *) 0l + ( ( ( bytes ) >> ( sizeof( int) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register int *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } IntSource IntIntSource( source ) IntSource source ; { return( stdAutoSource( ( Pointer ) source, IntIntCallback ) ) ; } static void FloatIntCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; int *buffer ; { register float *i = ( ( float *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( float *) 0l + ( ( ( bytes ) >> ( sizeof( int) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register int *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } IntSource FloatIntSource( source ) IntSource source ; { return( stdAutoSource( ( Pointer ) source, FloatIntCallback ) ) ; } static void DoubleIntCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; int *buffer ; { register double *i = ( ( double *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( double *) 0l + ( ( ( bytes ) >> ( sizeof( int) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register int *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } IntSource DoubleIntSource( source ) IntSource source ; { return( stdAutoSource( ( Pointer ) source, DoubleIntCallback ) ) ; } Source SourceIntSource( source ) Source source ; { static Source (*converts[])() = { SourceSource, CharIntSource, ShortIntSource, IntIntSource, FloatIntSource, DoubleIntSource } ; return ( converts[ typeEntryNumber( sourceType( (struct _source *) source ) ) ]( source ) ) ; } static void floatConstantCallback( state, bytes, buffer, end ) float *state ; ByteCount *bytes ; float *buffer, *end ; { register float i, *optr = buffer, *eptr = end ; i = *state ; if( optr < eptr ) do *optr++ = i ; while( optr < eptr ) ; return ; } FloatSource ConstantFloatSource( constant ) float constant ; { float * state = ( float * ) stitch_malloc( (unsigned) ( ( sizeof * ( float * ) 0 ) ), stitchStructStr ) ; *state = constant ; return ( newExternalSource( (Pointer) ( (Pointer) state ), floatConstantCallback, stitch_free, "ops.type constant" ) ) ; } static void floatIntegralCallback( integral, bytes, buffer, end, input ) float *integral ; ByteCount *bytes ; float *buffer, *end, *input ; { register float *iptr = input ; register float *optr = buffer ; register float *eptr = end ; if( optr < eptr ) do { *optr++ = *integral ; *integral += *iptr++ ; } while( optr < eptr ) ; return ; } FloatSource IntegrateFloatSource( source, initial ) FloatSource source ; float initial ; { float * integral = ( float * ) stitch_malloc( (unsigned) ( ( sizeof * ( float * ) 0 ) ), stitchStructStr ) ; *integral = initial ; return ( newProcessingSource( (Pointer) ( (Pointer) integral ), floatIntegralCallback, stitch_free, source, "ops.type integrating" ) ) ; } static void floatCallingCallback( function, bytes, buffer, end, input ) float (*function)() ; ByteCount *bytes ; float *buffer, *end, *input ; { register float *iptr = input ; register float *optr = buffer ; register float *eptr = end ; if( optr < eptr ) do *optr++ = function( *iptr++ ) ; while( optr < eptr ) ; return ; } FloatSource CallingFloatSource( source, function ) FloatSource source ; float (*function)() ; { return ( newProcessingSource( (Pointer) ( (Pointer) function ), floatCallingCallback, (void ( * )()) 0, source, "ops.type function" ) ) ; } /* do operators */ static void AddFloatOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; float *output, *end, *input1, *input2 ; { register float *optr = output ; register float *ipt1 = input1 ; register float *ipt2 = input2 ; register float *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ + *ipt2++ ; while( optr < eptr ) ; return ; } Source AddFloatSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddFloatOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source AddFloatSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddFloatOp, (void ( * )()) 0, inputs, "operator" ) ) ; } static void SubtractFloatOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; float *output, *end, *input1, *input2 ; { register float *optr = output ; register float *ipt1 = input1 ; register float *ipt2 = input2 ; register float *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ - *ipt2++ ; while( optr < eptr ) ; return ; } Source SubtractFloatSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractFloatOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source SubtractFloatSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractFloatOp, (void ( * )()) 0, inputs, "operator" ) ) ; } static void MultiplyFloatOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; float *output, *end, *input1, *input2 ; { register float *optr = output ; register float *ipt1 = input1 ; register float *ipt2 = input2 ; register float *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ * *ipt2++ ; while( optr < eptr ) ; return ; } Source MultiplyFloatSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyFloatOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source MultiplyFloatSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyFloatOp, (void ( * )()) 0, inputs, "operator" ) ) ; } static void DivideFloatOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; float *output, *end, *input1, *input2 ; { register float *optr = output ; register float *ipt1 = input1 ; register float *ipt2 = input2 ; register float *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ / *ipt2++ ; while( optr < eptr ) ; return ; } Source DivideFloatSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideFloatOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source DivideFloatSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideFloatOp, (void ( * )()) 0, inputs, "operator" ) ) ; } /* create convertors */ static void CharFloatCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; float *buffer ; { register char *i = ( ( char *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( char *) 0l + ( ( ( bytes ) >> ( sizeof( float) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register float *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } FloatSource CharFloatSource( source ) FloatSource source ; { return( stdAutoSource( ( Pointer ) source, CharFloatCallback ) ) ; } static void ShortFloatCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; float *buffer ; { register short *i = ( ( short *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( short *) 0l + ( ( ( bytes ) >> ( sizeof( float) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register float *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } FloatSource ShortFloatSource( source ) FloatSource source ; { return( stdAutoSource( ( Pointer ) source, ShortFloatCallback ) ) ; } static void IntFloatCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; float *buffer ; { register int *i = ( ( int *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( int *) 0l + ( ( ( bytes ) >> ( sizeof( float) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register float *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } FloatSource IntFloatSource( source ) FloatSource source ; { return( stdAutoSource( ( Pointer ) source, IntFloatCallback ) ) ; } static void FloatFloatCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; float *buffer ; { register float *i = ( ( float *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( float *) 0l + ( ( ( bytes ) >> ( sizeof( float) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register float *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } FloatSource FloatFloatSource( source ) FloatSource source ; { return( stdAutoSource( ( Pointer ) source, FloatFloatCallback ) ) ; } static void DoubleFloatCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; float *buffer ; { register double *i = ( ( double *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( double *) 0l + ( ( ( bytes ) >> ( sizeof( float) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register float *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } FloatSource DoubleFloatSource( source ) FloatSource source ; { return( stdAutoSource( ( Pointer ) source, DoubleFloatCallback ) ) ; } Source SourceFloatSource( source ) Source source ; { static Source (*converts[])() = { SourceSource, CharFloatSource, ShortFloatSource, IntFloatSource, FloatFloatSource, DoubleFloatSource } ; return ( converts[ typeEntryNumber( sourceType( (struct _source *) source ) ) ]( source ) ) ; } static void doubleConstantCallback( state, bytes, buffer, end ) double *state ; ByteCount *bytes ; double *buffer, *end ; { register double i, *optr = buffer, *eptr = end ; i = *state ; if( optr < eptr ) do *optr++ = i ; while( optr < eptr ) ; return ; } DoubleSource ConstantDoubleSource( constant ) double constant ; { double * state = ( double * ) stitch_malloc( (unsigned) ( ( sizeof * ( double * ) 0 ) ), stitchStructStr ) ; *state = constant ; return ( newExternalSource( (Pointer) ( (Pointer) state ), doubleConstantCallback, stitch_free, "ops.type constant" ) ) ; } static void doubleIntegralCallback( integral, bytes, buffer, end, input ) double *integral ; ByteCount *bytes ; double *buffer, *end, *input ; { register double *iptr = input ; register double *optr = buffer ; register double *eptr = end ; if( optr < eptr ) do { *optr++ = *integral ; *integral += *iptr++ ; } while( optr < eptr ) ; return ; } DoubleSource IntegrateDoubleSource( source, initial ) DoubleSource source ; double initial ; { double * integral = ( double * ) stitch_malloc( (unsigned) ( ( sizeof * ( double * ) 0 ) ), stitchStructStr ) ; *integral = initial ; return ( newProcessingSource( (Pointer) ( (Pointer) integral ), doubleIntegralCallback, stitch_free, source, "ops.type integrating" ) ) ; } static void doubleCallingCallback( function, bytes, buffer, end, input ) double (*function)() ; ByteCount *bytes ; double *buffer, *end, *input ; { register double *iptr = input ; register double *optr = buffer ; register double *eptr = end ; if( optr < eptr ) do *optr++ = function( *iptr++ ) ; while( optr < eptr ) ; return ; } DoubleSource CallingDoubleSource( source, function ) DoubleSource source ; double (*function)() ; { return ( newProcessingSource( (Pointer) ( (Pointer) function ), doubleCallingCallback, (void ( * )()) 0, source, "ops.type function" ) ) ; } /* do operators */ static void AddDoubleOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; double *output, *end, *input1, *input2 ; { register double *optr = output ; register double *ipt1 = input1 ; register double *ipt2 = input2 ; register double *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ + *ipt2++ ; while( optr < eptr ) ; return ; } Source AddDoubleSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddDoubleOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source AddDoubleSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddDoubleOp, (void ( * )()) 0, inputs, "operator" ) ) ; } static void SubtractDoubleOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; double *output, *end, *input1, *input2 ; { register double *optr = output ; register double *ipt1 = input1 ; register double *ipt2 = input2 ; register double *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ - *ipt2++ ; while( optr < eptr ) ; return ; } Source SubtractDoubleSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractDoubleOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source SubtractDoubleSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractDoubleOp, (void ( * )()) 0, inputs, "operator" ) ) ; } static void MultiplyDoubleOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; double *output, *end, *input1, *input2 ; { register double *optr = output ; register double *ipt1 = input1 ; register double *ipt2 = input2 ; register double *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ * *ipt2++ ; while( optr < eptr ) ; return ; } Source MultiplyDoubleSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyDoubleOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source MultiplyDoubleSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyDoubleOp, (void ( * )()) 0, inputs, "operator" ) ) ; } static void DivideDoubleOp( state, bytes, output, end, input1, input2 ) Pointer *state ; ByteCount *bytes ; double *output, *end, *input1, *input2 ; { register double *optr = output ; register double *ipt1 = input1 ; register double *ipt2 = input2 ; register double *eptr = end ; if( optr < eptr ) do *optr++ = *ipt1++ / *ipt2++ ; while( optr < eptr ) ; return ; } Source DivideDoubleSources( input1, input2 ) Source input1, input2 ; { Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ; inputs[0] = input1 ; inputs[1] = input2 ; inputs[2] = (struct _source *) 0 ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideDoubleOp, (void ( * )()) 0, inputs, "binary operator" ) ) ; } /* VARARGS2 */ Source DivideDoubleSourceArray( inputs ) Source *inputs ; { int count = 0 ; while( inputs[count] != (struct _source *) 0 ) count++ ; return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideDoubleOp, (void ( * )()) 0, inputs, "operator" ) ) ; } /* create convertors */ static void CharDoubleCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; double *buffer ; { register char *i = ( ( char *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( char *) 0l + ( ( ( bytes ) >> ( sizeof( double) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register double *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } DoubleSource CharDoubleSource( source ) DoubleSource source ; { return( stdAutoSource( ( Pointer ) source, CharDoubleCallback ) ) ; } static void ShortDoubleCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; double *buffer ; { register short *i = ( ( short *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( short *) 0l + ( ( ( bytes ) >> ( sizeof( double) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register double *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } DoubleSource ShortDoubleSource( source ) DoubleSource source ; { return( stdAutoSource( ( Pointer ) source, ShortDoubleCallback ) ) ; } static void IntDoubleCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; double *buffer ; { register int *i = ( ( int *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( int *) 0l + ( ( ( bytes ) >> ( sizeof( double) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register double *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } DoubleSource IntDoubleSource( source ) DoubleSource source ; { return( stdAutoSource( ( Pointer ) source, IntDoubleCallback ) ) ; } static void FloatDoubleCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; double *buffer ; { register float *i = ( ( float *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( float *) 0l + ( ( ( bytes ) >> ( sizeof( double) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register double *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } DoubleSource FloatDoubleSource( source ) DoubleSource source ; { return( stdAutoSource( ( Pointer ) source, FloatDoubleCallback ) ) ; } static void DoubleDoubleCallback( state, bytes, buffer ) Source state ; ByteCount bytes ; double *buffer ; { register double *i = ( ( double *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( double *) 0l + ( ( ( bytes ) >> ( sizeof( double) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ; register double *o = buffer ; register Pointer e = (Pointer) buffer + bytes ; if( (Pointer) o < e ) do *o++ = *i++ ; while( (Pointer) o < e ) ; return ; } DoubleSource DoubleDoubleSource( source ) DoubleSource source ; { return( stdAutoSource( ( Pointer ) source, DoubleDoubleCallback ) ) ; } Source SourceDoubleSource( source ) Source source ; { static Source (*converts[])() = { SourceSource, CharDoubleSource, ShortDoubleSource, IntDoubleSource, FloatDoubleSource, DoubleDoubleSource } ; return ( converts[ typeEntryNumber( sourceType( (struct _source *) source ) ) ]( source ) ) ; }