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