comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:5242703e91d3
1 /*
2 Copyright (c) Applied Psychology Unit, Medical Research Council. 1988, 1989
3 ===========================================================================
4
5 Permission to use, copy, modify, and distribute this software without fee
6 is hereby granted for research purposes, provided that this copyright
7 notice appears in all copies and in all supporting documentation, and that
8 the software is not redistributed for any fee (except for a nominal shipping
9 charge). Anyone wanting to incorporate all or part of this software in a
10 commercial product must obtain a license from the Medical Research Council.
11
12 The MRC makes no representations about the suitability of this
13 software for any purpose. It is provided "as is" without express or implied
14 warranty.
15
16 THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
17 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE
18 A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
19 DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
20 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 */
23
24 /*
25 ops.c
26 =====
27
28 quickie operators for stitch
29
30 */
31
32
33
34 typedef char *Pointer ;
35
36 typedef char *Address ;
37
38
39 /* a portable inteface to the system */
40
41 extern void stitch_error() ;
42
43 extern Pointer stitch_malloc() ;
44 extern Pointer stitch_copied_malloc() ;
45 extern Pointer stitch_zeroed_malloc() ;
46 extern Pointer stitch_ralloc() ;
47 extern Pointer stitch_calloc() ;
48
49 extern void stitch_free() ;
50 extern void stitch_exit() ;
51
52 /* beware these definitions, they are for speed and fail if stitch.h not included */
53
54 extern void (*stitch_bcopy)() ;
55 extern void (*stitch_bzero)() ;
56
57 extern char stitchStructStr[] ;
58
59
60
61
62 typedef struct _buffer *Buffer ;
63
64
65 struct _buffer { Pointer addr ; unsigned size, refs ; } ;
66
67 extern Buffer NewBuffer( /* char where[] */ ) ;
68 extern Buffer SharedBuffer( /* Buffer buffer */ ) ;
69 extern Buffer ResizedBuffer( /* Buffer buffer, unsigned size */ ) ;
70 extern void FreeBuffer( /* Buffer buffer */ ) ;
71
72
73
74
75 /* basic types */
76
77 typedef struct _source *Source, *SourceArray[1] ;
78
79
80
81 typedef Source CharSource, ShortSource, IntSource, FloatSource, DoubleSource, ComplexSource ;
82 typedef SourceArray CharSourceArray, ShortSourceArray, IntSourceArray, FloatSourceArray, DoubleSourceArray, ComplexSourceArray ;
83
84 typedef int ByteCount ;
85
86 /* dependant on type of source */
87
88 struct _source { Pointer (*pull)(), (*fill)(), (*roll)(), returned ; char *name, *type ; int opened ; Source (*open)() ; } ;
89 struct _source_operators { Source (*set)() ; Pointer (*delete)() ; Source (*setType)() ; char *(*getType)() ; char *(*getName)() ; } ;
90
91 struct _pullable_source { struct _source parent ; } ;
92 struct _fillable_source { struct _source parent ; Buffer buffer ; } ;
93
94
95
96
97
98
99 extern Source setSource() ;
100 extern Source typeSource() ;
101 extern char *sourceType() ;
102 extern char *sourceName() ;
103 extern Pointer deleteSource() ;
104
105 extern Pointer oldPull(), oldFill(), oldRoll() ;
106
107
108 extern void sinkSource() ;
109 extern void CloseSource() ;
110 extern void sinkAndCloseSource() ;
111
112 /* derived source types for different purposes */
113
114 extern Source newTappingSource() ;
115 extern Source newRollableSource() ;
116
117 extern Pointer nonRoller() ;
118
119
120
121 /* fundamental active source types */
122
123 extern Source setPullableSource() ;
124 extern Pointer deletePullableSource() ;
125
126 /* simple assertive derived sources */
127
128 extern Source newSlaveSource() ;
129 extern Source newStaticSource() ;
130 extern Source newRetainingSource() ;
131 extern Source newDelayingSource() ;
132 extern Source newBlockingSource() ;
133
134
135
136 /* derived higher level filling sources */
137
138 extern Source setFillableSource() ;
139 extern Pointer deleteFillableSource() ;
140
141 extern Source newSegmentingSource() ;
142
143 extern Source setCallbackSource() ;
144 extern Source newExternalSource() ;
145 extern Source newThroughSource() ;
146
147 extern Source newProcessingSource() ;
148 extern Source newSimpleProcessingSource() ;
149 extern Source newMultiplexedSource() ;
150 extern Source newMergingSource() ;
151
152 extern Source sharingSource() ;
153
154 extern Source *BindSources() ;
155
156 /* for compatability... for now */
157
158 extern Source stdStaticSource() ;
159 extern Source stdSlaveSource() ;
160 extern Source stdAutoSource() ;
161 extern Source stdSelfSource() ;
162
163
164
165 extern Source EmptySource ;
166 /*
167 stypes.h
168 ======
169
170 defines types for sources operations
171
172
173 */
174
175 typedef struct { char *ident ; int size ; Source (*maker)() ; } TypeInfo ;
176
177 extern int typeEntryNumber() ;
178 extern Source TypeConvertSource() ;
179 extern Source SourceSource() ;
180
181 extern char CharIdent[] ;
182 extern char ShortIdent[] ;
183 extern char IntIdent[] ;
184 extern char LongIdent[] ;
185 extern char FloatIdent[] ;
186 extern char DoubleIdent[] ;
187
188
189
190 /* basic data operations */
191
192 extern CharSource ConstantCharSource( ), IntegrateCharSource( ), CallingCharSource( ) ;
193 extern ShortSource ConstantShortSource( ), IntegrateShortSource( ), CallingShortSource( ) ;
194 extern IntSource ConstantIntSource( ), IntegrateIntSource( ), CallingIntSource( ) ;
195 extern FloatSource ConstantFloatSource( ), IntegrateFloatSource( ), CallingFloatSource( ) ;
196 extern DoubleSource ConstantDoubleSource( ), IntegrateDoubleSource( ), CallingDoubleSource( ) ;
197 extern ComplexSource ConstantComplexSource( ), IntegrateComplexSource( ), CallingComplexSource( ) ;
198
199 /* binary operators */
200
201 extern CharSource AddCharSources( ), SubtractCharSources( ), MultiplyCharSources( ), DivideCharSources( ) ;
202 extern ShortSource AddShortSources( ), SubtractShortSources( ), MultiplyShortSources( ), DivideShortSources( ) ;
203 extern IntSource AddIntSources( ), SubtractIntSources( ), MultiplyIntSources( ), DivideIntSources( ) ;
204 extern FloatSource AddFloatSources( ), SubtractFloatSources( ), MultiplyFloatSources( ), DivideDoubleSources( ) ;
205 extern DoubleSource AddDoubleSources( ), SubtractDoubleSources( ), MultiplyDoubleSources( ), DivideFloatSources( ) ;
206 extern ComplexSource AddComplexSources( ), SubtractComplexSources( ), MultiplyComplexSources( ), DivideComplexSources( ) ;
207
208 extern Source AddSources( ), SubtractSources( ), MultiplySources( ), DivideSources( ) ;
209
210 /* convertors */
211
212 extern CharSource CharCharSource( ), ShortCharSource( ), IntCharSource( ), FloatCharSource( ), DoubleCharSource( ) ;
213 extern ShortSource CharShortSource( ), ShortShortSource( ), IntShortSource( ), FloatShortSource( ), DoubleShortSource( ) ;
214 extern IntSource CharIntSource( ), ShortIntSource( ), IntIntSource( ), FloatIntSource( ), DoubleIntSource( ) ;
215 extern FloatSource CharFloatSource( ), ShortFloatSource( ), IntFloatSource( ), FloatFloatSource( ), DoubleFloatSource( ) ;
216 extern DoubleSource CharDoubleSource( ), ShortDoubleSource( ), IntDoubleSource( ), FloatDoubleSource( ), DoubleDoubleSource( ) ;
217 extern ComplexSource CharComplexSource( ), ShortComplexSource( ), IntComplexSource( ), FloatComplexSource( ), DoubleComplexSource( ) ;
218
219 extern Source SourceCharSource( ), SourceShortSource( ), SourceIntSource( ), SourceFloatSource( ), SourceDoubleSource( ), SourceComplexSource( ) ;
220
221
222 static void charConstantCallback( state, bytes, buffer, end )
223 char *state ;
224 ByteCount *bytes ;
225 char *buffer, *end ;
226 {
227 register char i, *optr = buffer, *eptr = end ;
228
229 i = *state ;
230
231 if( optr < eptr )
232 do
233 *optr++ = i ;
234 while( optr < eptr ) ;
235
236 return ;
237 }
238
239 CharSource ConstantCharSource( constant )
240 char constant ;
241 {
242 char * state = ( char * ) stitch_malloc( (unsigned) ( ( sizeof * ( char * ) 0 ) ), stitchStructStr ) ;
243
244 *state = constant ;
245
246 return ( newExternalSource( (Pointer) ( (Pointer) state ), charConstantCallback, stitch_free, "ops.type constant" ) ) ;
247 }
248
249
250 static void charIntegralCallback( integral, bytes, buffer, end, input )
251 char *integral ;
252 ByteCount *bytes ;
253 char *buffer, *end, *input ;
254 {
255 register char *iptr = input ;
256 register char *optr = buffer ;
257 register char *eptr = end ;
258
259 if( optr < eptr )
260 do {
261 *optr++ = *integral ;
262 *integral += *iptr++ ;
263 } while( optr < eptr ) ;
264
265 return ;
266 }
267
268 CharSource IntegrateCharSource( source, initial )
269 CharSource source ;
270 char initial ;
271 {
272 char * integral = ( char * ) stitch_malloc( (unsigned) ( ( sizeof * ( char * ) 0 ) ), stitchStructStr ) ;
273
274 *integral = initial ;
275
276 return ( newProcessingSource( (Pointer) ( (Pointer) integral ), charIntegralCallback, stitch_free, source, "ops.type integrating" ) ) ;
277 }
278
279 static void charCallingCallback( function, bytes, buffer, end, input )
280 char (*function)() ;
281 ByteCount *bytes ;
282 char *buffer, *end, *input ;
283 {
284 register char *iptr = input ;
285 register char *optr = buffer ;
286 register char *eptr = end ;
287
288 if( optr < eptr )
289 do
290 *optr++ = function( *iptr++ ) ;
291 while( optr < eptr ) ;
292
293 return ;
294 }
295
296 CharSource CallingCharSource( source, function )
297 CharSource source ;
298 char (*function)() ;
299 {
300 return ( newProcessingSource( (Pointer) ( (Pointer) function ), charCallingCallback, (void ( * )()) 0, source, "ops.type function" ) ) ;
301 }
302
303 /* do operators */
304
305
306 static void AddCharOp( state, bytes, output, end, input1, input2 )
307 Pointer *state ;
308 ByteCount *bytes ;
309 char *output, *end, *input1, *input2 ;
310 {
311 register char *optr = output ;
312 register char *ipt1 = input1 ;
313 register char *ipt2 = input2 ;
314 register char *eptr = end ;
315
316 if( optr < eptr )
317 do
318 *optr++ = *ipt1++ + *ipt2++ ;
319 while( optr < eptr ) ;
320
321 return ;
322 }
323
324 Source AddCharSources( input1, input2 )
325 Source input1, input2 ;
326 {
327 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
328
329 inputs[0] = input1 ;
330 inputs[1] = input2 ;
331
332 inputs[2] = (struct _source *) 0 ;
333
334 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddCharOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
335 }
336
337 /* VARARGS2 */
338 Source AddCharSourceArray( inputs )
339 Source *inputs ;
340 {
341 int count = 0 ;
342
343 while( inputs[count] != (struct _source *) 0 )
344 count++ ;
345
346 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddCharOp, (void ( * )()) 0, inputs, "operator" ) ) ;
347 }
348
349
350 static void SubtractCharOp( state, bytes, output, end, input1, input2 )
351 Pointer *state ;
352 ByteCount *bytes ;
353 char *output, *end, *input1, *input2 ;
354 {
355 register char *optr = output ;
356 register char *ipt1 = input1 ;
357 register char *ipt2 = input2 ;
358 register char *eptr = end ;
359
360 if( optr < eptr )
361 do
362 *optr++ = *ipt1++ - *ipt2++ ;
363 while( optr < eptr ) ;
364
365 return ;
366 }
367
368 Source SubtractCharSources( input1, input2 )
369 Source input1, input2 ;
370 {
371 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
372
373 inputs[0] = input1 ;
374 inputs[1] = input2 ;
375
376 inputs[2] = (struct _source *) 0 ;
377
378 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractCharOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
379 }
380
381 /* VARARGS2 */
382 Source SubtractCharSourceArray( inputs )
383 Source *inputs ;
384 {
385 int count = 0 ;
386
387 while( inputs[count] != (struct _source *) 0 )
388 count++ ;
389
390 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractCharOp, (void ( * )()) 0, inputs, "operator" ) ) ;
391 }
392
393
394 static void MultiplyCharOp( state, bytes, output, end, input1, input2 )
395 Pointer *state ;
396 ByteCount *bytes ;
397 char *output, *end, *input1, *input2 ;
398 {
399 register char *optr = output ;
400 register char *ipt1 = input1 ;
401 register char *ipt2 = input2 ;
402 register char *eptr = end ;
403
404 if( optr < eptr )
405 do
406 *optr++ = *ipt1++ * *ipt2++ ;
407 while( optr < eptr ) ;
408
409 return ;
410 }
411
412 Source MultiplyCharSources( input1, input2 )
413 Source input1, input2 ;
414 {
415 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
416
417 inputs[0] = input1 ;
418 inputs[1] = input2 ;
419
420 inputs[2] = (struct _source *) 0 ;
421
422 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyCharOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
423 }
424
425 /* VARARGS2 */
426 Source MultiplyCharSourceArray( inputs )
427 Source *inputs ;
428 {
429 int count = 0 ;
430
431 while( inputs[count] != (struct _source *) 0 )
432 count++ ;
433
434 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyCharOp, (void ( * )()) 0, inputs, "operator" ) ) ;
435 }
436
437
438 static void DivideCharOp( state, bytes, output, end, input1, input2 )
439 Pointer *state ;
440 ByteCount *bytes ;
441 char *output, *end, *input1, *input2 ;
442 {
443 register char *optr = output ;
444 register char *ipt1 = input1 ;
445 register char *ipt2 = input2 ;
446 register char *eptr = end ;
447
448 if( optr < eptr )
449 do
450 *optr++ = *ipt1++ / *ipt2++ ;
451 while( optr < eptr ) ;
452
453 return ;
454 }
455
456 Source DivideCharSources( input1, input2 )
457 Source input1, input2 ;
458 {
459 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
460
461 inputs[0] = input1 ;
462 inputs[1] = input2 ;
463
464 inputs[2] = (struct _source *) 0 ;
465
466 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideCharOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
467 }
468
469 /* VARARGS2 */
470 Source DivideCharSourceArray( inputs )
471 Source *inputs ;
472 {
473 int count = 0 ;
474
475 while( inputs[count] != (struct _source *) 0 )
476 count++ ;
477
478 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideCharOp, (void ( * )()) 0, inputs, "operator" ) ) ;
479 }
480
481
482
483
484 /* create convertors */
485
486 static void CharCharCallback( state, bytes, buffer )
487 Source state ;
488 ByteCount bytes ;
489 char *buffer ;
490 {
491 register char *i = ( ( char *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( char *) 0l + ( ( ( bytes ) >> ( sizeof( char) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
492 register char *o = buffer ;
493 register Pointer e = (Pointer) buffer + bytes ;
494
495 if( (Pointer) o < e )
496 do
497 *o++ = *i++ ;
498 while( (Pointer) o < e ) ;
499
500 return ;
501 }
502
503 CharSource CharCharSource( source )
504 CharSource source ;
505 {
506 return( stdAutoSource( ( Pointer ) source, CharCharCallback ) ) ;
507 }
508
509
510 static void ShortCharCallback( state, bytes, buffer )
511 Source state ;
512 ByteCount bytes ;
513 char *buffer ;
514 {
515 register short *i = ( ( short *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( short *) 0l + ( ( ( bytes ) >> ( sizeof( char) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
516 register char *o = buffer ;
517 register Pointer e = (Pointer) buffer + bytes ;
518
519 if( (Pointer) o < e )
520 do
521 *o++ = *i++ ;
522 while( (Pointer) o < e ) ;
523
524 return ;
525 }
526
527 CharSource ShortCharSource( source )
528 CharSource source ;
529 {
530 return( stdAutoSource( ( Pointer ) source, ShortCharCallback ) ) ;
531 }
532
533
534
535
536 static void IntCharCallback( state, bytes, buffer )
537 Source state ;
538 ByteCount bytes ;
539 char *buffer ;
540 {
541 register int *i = ( ( int *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( int *) 0l + ( ( ( bytes ) >> ( sizeof( char) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
542 register char *o = buffer ;
543 register Pointer e = (Pointer) buffer + bytes ;
544
545 if( (Pointer) o < e )
546 do
547 *o++ = *i++ ;
548 while( (Pointer) o < e ) ;
549
550 return ;
551 }
552
553 CharSource IntCharSource( source )
554 CharSource source ;
555 {
556 return( stdAutoSource( ( Pointer ) source, IntCharCallback ) ) ;
557 }
558
559
560 static void FloatCharCallback( state, bytes, buffer )
561 Source state ;
562 ByteCount bytes ;
563 char *buffer ;
564 {
565 register float *i = ( ( float *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( float *) 0l + ( ( ( bytes ) >> ( sizeof( char) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
566 register char *o = buffer ;
567 register Pointer e = (Pointer) buffer + bytes ;
568
569 if( (Pointer) o < e )
570 do
571 *o++ = *i++ ;
572 while( (Pointer) o < e ) ;
573
574 return ;
575 }
576
577 CharSource FloatCharSource( source )
578 CharSource source ;
579 {
580 return( stdAutoSource( ( Pointer ) source, FloatCharCallback ) ) ;
581 }
582
583
584
585 static void DoubleCharCallback( state, bytes, buffer )
586 Source state ;
587 ByteCount bytes ;
588 char *buffer ;
589 {
590 register double *i = ( ( double *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( double *) 0l + ( ( ( bytes ) >> ( sizeof( char) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
591 register char *o = buffer ;
592 register Pointer e = (Pointer) buffer + bytes ;
593
594 if( (Pointer) o < e )
595 do
596 *o++ = *i++ ;
597 while( (Pointer) o < e ) ;
598
599 return ;
600 }
601
602 CharSource DoubleCharSource( source )
603 CharSource source ;
604 {
605 return( stdAutoSource( ( Pointer ) source, DoubleCharCallback ) ) ;
606 }
607
608
609
610
611 Source SourceCharSource( source )
612 Source source ;
613 {
614 static Source (*converts[])() = {
615 SourceSource,
616 CharCharSource,
617 ShortCharSource,
618 IntCharSource,
619 FloatCharSource,
620 DoubleCharSource
621 } ;
622
623 return ( converts[ typeEntryNumber( sourceType( (struct _source *) source ) ) ]( source ) ) ;
624 }
625
626
627 static void shortConstantCallback( state, bytes, buffer, end )
628 short *state ;
629 ByteCount *bytes ;
630 short *buffer, *end ;
631 {
632 register short i, *optr = buffer, *eptr = end ;
633
634 i = *state ;
635
636 if( optr < eptr )
637 do
638 *optr++ = i ;
639 while( optr < eptr ) ;
640
641 return ;
642 }
643
644 ShortSource ConstantShortSource( constant )
645 short constant ;
646 {
647 short * state = ( short * ) stitch_malloc( (unsigned) ( ( sizeof * ( short * ) 0 ) ), stitchStructStr ) ;
648
649 *state = constant ;
650
651 return ( newExternalSource( (Pointer) ( (Pointer) state ), shortConstantCallback, stitch_free, "ops.type constant" ) ) ;
652 }
653
654
655 static void shortIntegralCallback( integral, bytes, buffer, end, input )
656 short *integral ;
657 ByteCount *bytes ;
658 short *buffer, *end, *input ;
659 {
660 register short *iptr = input ;
661 register short *optr = buffer ;
662 register short *eptr = end ;
663
664 if( optr < eptr )
665 do {
666 *optr++ = *integral ;
667 *integral += *iptr++ ;
668 } while( optr < eptr ) ;
669
670 return ;
671 }
672
673 ShortSource IntegrateShortSource( source, initial )
674 ShortSource source ;
675 short initial ;
676 {
677 short * integral = ( short * ) stitch_malloc( (unsigned) ( ( sizeof * ( short * ) 0 ) ), stitchStructStr ) ;
678
679 *integral = initial ;
680
681 return ( newProcessingSource( (Pointer) ( (Pointer) integral ), shortIntegralCallback, stitch_free, source, "ops.type integrating" ) ) ;
682 }
683
684 static void shortCallingCallback( function, bytes, buffer, end, input )
685 short (*function)() ;
686 ByteCount *bytes ;
687 short *buffer, *end, *input ;
688 {
689 register short *iptr = input ;
690 register short *optr = buffer ;
691 register short *eptr = end ;
692
693 if( optr < eptr )
694 do
695 *optr++ = function( *iptr++ ) ;
696 while( optr < eptr ) ;
697
698 return ;
699 }
700
701 ShortSource CallingShortSource( source, function )
702 ShortSource source ;
703 short (*function)() ;
704 {
705 return ( newProcessingSource( (Pointer) ( (Pointer) function ), shortCallingCallback, (void ( * )()) 0, source, "ops.type function" ) ) ;
706 }
707
708 /* do operators */
709
710 static void AddShortOp( state, bytes, output, end, input1, input2 )
711 Pointer *state ;
712 ByteCount *bytes ;
713 short *output, *end, *input1, *input2 ;
714 {
715 register short *optr = output ;
716 register short *ipt1 = input1 ;
717 register short *ipt2 = input2 ;
718 register short *eptr = end ;
719
720 if( optr < eptr )
721 do
722 *optr++ = *ipt1++ + *ipt2++ ;
723 while( optr < eptr ) ;
724
725 return ;
726 }
727
728 Source AddShortSources( input1, input2 )
729 Source input1, input2 ;
730 {
731 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
732
733 inputs[0] = input1 ;
734 inputs[1] = input2 ;
735
736 inputs[2] = (struct _source *) 0 ;
737
738 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddShortOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
739 }
740
741 /* VARARGS2 */
742 Source AddShortSourceArray( inputs )
743 Source *inputs ;
744 {
745 int count = 0 ;
746
747 while( inputs[count] != (struct _source *) 0 )
748 count++ ;
749
750 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddShortOp, (void ( * )()) 0, inputs, "operator" ) ) ;
751 }
752
753
754 static void SubtractShortOp( state, bytes, output, end, input1, input2 )
755 Pointer *state ;
756 ByteCount *bytes ;
757 short *output, *end, *input1, *input2 ;
758 {
759 register short *optr = output ;
760 register short *ipt1 = input1 ;
761 register short *ipt2 = input2 ;
762 register short *eptr = end ;
763
764 if( optr < eptr )
765 do
766 *optr++ = *ipt1++ - *ipt2++ ;
767 while( optr < eptr ) ;
768
769 return ;
770 }
771
772 Source SubtractShortSources( input1, input2 )
773 Source input1, input2 ;
774 {
775 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
776
777 inputs[0] = input1 ;
778 inputs[1] = input2 ;
779
780 inputs[2] = (struct _source *) 0 ;
781
782 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractShortOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
783 }
784
785 /* VARARGS2 */
786 Source SubtractShortSourceArray( inputs )
787 Source *inputs ;
788 {
789 int count = 0 ;
790
791 while( inputs[count] != (struct _source *) 0 )
792 count++ ;
793
794 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractShortOp, (void ( * )()) 0, inputs, "operator" ) ) ;
795 }
796
797
798 static void MultiplyShortOp( state, bytes, output, end, input1, input2 )
799 Pointer *state ;
800 ByteCount *bytes ;
801 short *output, *end, *input1, *input2 ;
802 {
803 register short *optr = output ;
804 register short *ipt1 = input1 ;
805 register short *ipt2 = input2 ;
806 register short *eptr = end ;
807
808 if( optr < eptr )
809 do
810 *optr++ = *ipt1++ * *ipt2++ ;
811 while( optr < eptr ) ;
812
813 return ;
814 }
815
816 Source MultiplyShortSources( input1, input2 )
817 Source input1, input2 ;
818 {
819 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
820
821 inputs[0] = input1 ;
822 inputs[1] = input2 ;
823
824 inputs[2] = (struct _source *) 0 ;
825
826 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyShortOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
827 }
828
829 /* VARARGS2 */
830 Source MultiplyShortSourceArray( inputs )
831 Source *inputs ;
832 {
833 int count = 0 ;
834
835 while( inputs[count] != (struct _source *) 0 )
836 count++ ;
837
838 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyShortOp, (void ( * )()) 0, inputs, "operator" ) ) ;
839 }
840
841
842 static void DivideShortOp( state, bytes, output, end, input1, input2 )
843 Pointer *state ;
844 ByteCount *bytes ;
845 short *output, *end, *input1, *input2 ;
846 {
847 register short *optr = output ;
848 register short *ipt1 = input1 ;
849 register short *ipt2 = input2 ;
850 register short *eptr = end ;
851
852 if( optr < eptr )
853 do
854 *optr++ = *ipt1++ / *ipt2++ ;
855 while( optr < eptr ) ;
856
857 return ;
858 }
859
860 Source DivideShortSources( input1, input2 )
861 Source input1, input2 ;
862 {
863 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
864
865 inputs[0] = input1 ;
866 inputs[1] = input2 ;
867
868 inputs[2] = (struct _source *) 0 ;
869
870 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideShortOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
871 }
872
873 /* VARARGS2 */
874 Source DivideShortSourceArray( inputs )
875 Source *inputs ;
876 {
877 int count = 0 ;
878
879 while( inputs[count] != (struct _source *) 0 )
880 count++ ;
881
882 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideShortOp, (void ( * )()) 0, inputs, "operator" ) ) ;
883 }
884
885
886
887
888 /* create convertors */
889
890
891 static void CharShortCallback( state, bytes, buffer )
892 Source state ;
893 ByteCount bytes ;
894 short *buffer ;
895 {
896 register char *i = ( ( char *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( char *) 0l + ( ( ( bytes ) >> ( sizeof( short) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
897 register short *o = buffer ;
898 register Pointer e = (Pointer) buffer + bytes ;
899
900 if( (Pointer) o < e )
901 do
902 *o++ = *i++ ;
903 while( (Pointer) o < e ) ;
904
905 return ;
906 }
907
908 ShortSource CharShortSource( source )
909 ShortSource source ;
910 {
911 return( stdAutoSource( ( Pointer ) source, CharShortCallback ) ) ;
912 }
913
914
915
916 static void ShortShortCallback( state, bytes, buffer )
917 Source state ;
918 ByteCount bytes ;
919 short *buffer ;
920 {
921 register short *i = ( ( short *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( short *) 0l + ( ( ( bytes ) >> ( sizeof( short) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
922 register short *o = buffer ;
923 register Pointer e = (Pointer) buffer + bytes ;
924
925 if( (Pointer) o < e )
926 do
927 *o++ = *i++ ;
928 while( (Pointer) o < e ) ;
929
930 return ;
931 }
932
933 ShortSource ShortShortSource( source )
934 ShortSource source ;
935 {
936 return( stdAutoSource( ( Pointer ) source, ShortShortCallback ) ) ;
937 }
938
939
940 static void IntShortCallback( state, bytes, buffer )
941 Source state ;
942 ByteCount bytes ;
943 short *buffer ;
944 {
945 register int *i = ( ( int *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( int *) 0l + ( ( ( bytes ) >> ( sizeof( short) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
946 register short *o = buffer ;
947 register Pointer e = (Pointer) buffer + bytes ;
948
949 if( (Pointer) o < e )
950 do
951 *o++ = *i++ ;
952 while( (Pointer) o < e ) ;
953
954 return ;
955 }
956
957 ShortSource IntShortSource( source )
958 ShortSource source ;
959 {
960 return( stdAutoSource( ( Pointer ) source, IntShortCallback ) ) ;
961 }
962
963
964
965 static void FloatShortCallback( state, bytes, buffer )
966 Source state ;
967 ByteCount bytes ;
968 short *buffer ;
969 {
970 register float *i = ( ( float *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( float *) 0l + ( ( ( bytes ) >> ( sizeof( short) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
971 register short *o = buffer ;
972 register Pointer e = (Pointer) buffer + bytes ;
973
974 if( (Pointer) o < e )
975 do
976 *o++ = *i++ ;
977 while( (Pointer) o < e ) ;
978
979 return ;
980 }
981
982 ShortSource FloatShortSource( source )
983 ShortSource source ;
984 {
985 return( stdAutoSource( ( Pointer ) source, FloatShortCallback ) ) ;
986 }
987
988
989 static void DoubleShortCallback( state, bytes, buffer )
990 Source state ;
991 ByteCount bytes ;
992 short *buffer ;
993 {
994 register double *i = ( ( double *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( double *) 0l + ( ( ( bytes ) >> ( sizeof( short) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
995 register short *o = buffer ;
996 register Pointer e = (Pointer) buffer + bytes ;
997
998 if( (Pointer) o < e )
999 do
1000 *o++ = *i++ ;
1001 while( (Pointer) o < e ) ;
1002
1003 return ;
1004 }
1005
1006 ShortSource DoubleShortSource( source )
1007 ShortSource source ;
1008 {
1009 return( stdAutoSource( ( Pointer ) source, DoubleShortCallback ) ) ;
1010 }
1011
1012
1013
1014
1015 Source SourceShortSource( source )
1016 Source source ;
1017 {
1018 static Source (*converts[])() = {
1019 SourceSource,
1020 CharShortSource,
1021 ShortShortSource,
1022 IntShortSource,
1023 FloatShortSource,
1024 DoubleShortSource
1025 } ;
1026
1027 return ( converts[ typeEntryNumber( sourceType( (struct _source *) source ) ) ]( source ) ) ;
1028 }
1029
1030
1031
1032 static void intConstantCallback( state, bytes, buffer, end )
1033 int *state ;
1034 ByteCount *bytes ;
1035 int *buffer, *end ;
1036 {
1037 register int i, *optr = buffer, *eptr = end ;
1038
1039 i = *state ;
1040
1041 if( optr < eptr )
1042 do
1043 *optr++ = i ;
1044 while( optr < eptr ) ;
1045
1046 return ;
1047 }
1048
1049 IntSource ConstantIntSource( constant )
1050 int constant ;
1051 {
1052 int * state = ( int * ) stitch_malloc( (unsigned) ( ( sizeof * ( int * ) 0 ) ), stitchStructStr ) ;
1053
1054 *state = constant ;
1055
1056 return ( newExternalSource( (Pointer) ( (Pointer) state ), intConstantCallback, stitch_free, "ops.type constant" ) ) ;
1057 }
1058
1059
1060 static void intIntegralCallback( integral, bytes, buffer, end, input )
1061 int *integral ;
1062 ByteCount *bytes ;
1063 int *buffer, *end, *input ;
1064 {
1065 register int *iptr = input ;
1066 register int *optr = buffer ;
1067 register int *eptr = end ;
1068
1069 if( optr < eptr )
1070 do {
1071 *optr++ = *integral ;
1072 *integral += *iptr++ ;
1073 } while( optr < eptr ) ;
1074
1075 return ;
1076 }
1077
1078 IntSource IntegrateIntSource( source, initial )
1079 IntSource source ;
1080 int initial ;
1081 {
1082 int * integral = ( int * ) stitch_malloc( (unsigned) ( ( sizeof * ( int * ) 0 ) ), stitchStructStr ) ;
1083
1084 *integral = initial ;
1085
1086 return ( newProcessingSource( (Pointer) ( (Pointer) integral ), intIntegralCallback, stitch_free, source, "ops.type integrating" ) ) ;
1087 }
1088
1089 static void intCallingCallback( function, bytes, buffer, end, input )
1090 int (*function)() ;
1091 ByteCount *bytes ;
1092 int *buffer, *end, *input ;
1093 {
1094 register int *iptr = input ;
1095 register int *optr = buffer ;
1096 register int *eptr = end ;
1097
1098 if( optr < eptr )
1099 do
1100 *optr++ = function( *iptr++ ) ;
1101 while( optr < eptr ) ;
1102
1103 return ;
1104 }
1105
1106 IntSource CallingIntSource( source, function )
1107 IntSource source ;
1108 int (*function)() ;
1109 {
1110 return ( newProcessingSource( (Pointer) ( (Pointer) function ), intCallingCallback, (void ( * )()) 0, source, "ops.type function" ) ) ;
1111 }
1112
1113 /* do operators */
1114
1115
1116 static void AddIntOp( state, bytes, output, end, input1, input2 )
1117 Pointer *state ;
1118 ByteCount *bytes ;
1119 int *output, *end, *input1, *input2 ;
1120 {
1121 register int *optr = output ;
1122 register int *ipt1 = input1 ;
1123 register int *ipt2 = input2 ;
1124 register int *eptr = end ;
1125
1126 if( optr < eptr )
1127 do
1128 *optr++ = *ipt1++ + *ipt2++ ;
1129 while( optr < eptr ) ;
1130
1131 return ;
1132 }
1133
1134 Source AddIntSources( input1, input2 )
1135 Source input1, input2 ;
1136 {
1137 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
1138
1139 inputs[0] = input1 ;
1140 inputs[1] = input2 ;
1141
1142 inputs[2] = (struct _source *) 0 ;
1143
1144 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddIntOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
1145 }
1146
1147 /* VARARGS2 */
1148 Source AddIntSourceArray( inputs )
1149 Source *inputs ;
1150 {
1151 int count = 0 ;
1152
1153 while( inputs[count] != (struct _source *) 0 )
1154 count++ ;
1155
1156 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddIntOp, (void ( * )()) 0, inputs, "operator" ) ) ;
1157 }
1158
1159
1160
1161 static void SubtractIntOp( state, bytes, output, end, input1, input2 )
1162 Pointer *state ;
1163 ByteCount *bytes ;
1164 int *output, *end, *input1, *input2 ;
1165 {
1166 register int *optr = output ;
1167 register int *ipt1 = input1 ;
1168 register int *ipt2 = input2 ;
1169 register int *eptr = end ;
1170
1171 if( optr < eptr )
1172 do
1173 *optr++ = *ipt1++ - *ipt2++ ;
1174 while( optr < eptr ) ;
1175
1176 return ;
1177 }
1178
1179 Source SubtractIntSources( input1, input2 )
1180 Source input1, input2 ;
1181 {
1182 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
1183
1184 inputs[0] = input1 ;
1185 inputs[1] = input2 ;
1186
1187 inputs[2] = (struct _source *) 0 ;
1188
1189 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractIntOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
1190 }
1191
1192 /* VARARGS2 */
1193 Source SubtractIntSourceArray( inputs )
1194 Source *inputs ;
1195 {
1196 int count = 0 ;
1197
1198 while( inputs[count] != (struct _source *) 0 )
1199 count++ ;
1200
1201 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractIntOp, (void ( * )()) 0, inputs, "operator" ) ) ;
1202 }
1203
1204
1205
1206
1207 static void MultiplyIntOp( state, bytes, output, end, input1, input2 )
1208 Pointer *state ;
1209 ByteCount *bytes ;
1210 int *output, *end, *input1, *input2 ;
1211 {
1212 register int *optr = output ;
1213 register int *ipt1 = input1 ;
1214 register int *ipt2 = input2 ;
1215 register int *eptr = end ;
1216
1217 if( optr < eptr )
1218 do
1219 *optr++ = *ipt1++ * *ipt2++ ;
1220 while( optr < eptr ) ;
1221
1222 return ;
1223 }
1224
1225 Source MultiplyIntSources( input1, input2 )
1226 Source input1, input2 ;
1227 {
1228 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
1229
1230 inputs[0] = input1 ;
1231 inputs[1] = input2 ;
1232
1233 inputs[2] = (struct _source *) 0 ;
1234
1235 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyIntOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
1236 }
1237
1238 /* VARARGS2 */
1239 Source MultiplyIntSourceArray( inputs )
1240 Source *inputs ;
1241 {
1242 int count = 0 ;
1243
1244 while( inputs[count] != (struct _source *) 0 )
1245 count++ ;
1246
1247 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyIntOp, (void ( * )()) 0, inputs, "operator" ) ) ;
1248 }
1249
1250
1251
1252 static void DivideIntOp( state, bytes, output, end, input1, input2 )
1253 Pointer *state ;
1254 ByteCount *bytes ;
1255 int *output, *end, *input1, *input2 ;
1256 {
1257 register int *optr = output ;
1258 register int *ipt1 = input1 ;
1259 register int *ipt2 = input2 ;
1260 register int *eptr = end ;
1261
1262 if( optr < eptr )
1263 do
1264 *optr++ = *ipt1++ / *ipt2++ ;
1265 while( optr < eptr ) ;
1266
1267 return ;
1268 }
1269
1270 Source DivideIntSources( input1, input2 )
1271 Source input1, input2 ;
1272 {
1273 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
1274
1275 inputs[0] = input1 ;
1276 inputs[1] = input2 ;
1277
1278 inputs[2] = (struct _source *) 0 ;
1279
1280 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideIntOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
1281 }
1282
1283 /* VARARGS2 */
1284 Source DivideIntSourceArray( inputs )
1285 Source *inputs ;
1286 {
1287 int count = 0 ;
1288
1289 while( inputs[count] != (struct _source *) 0 )
1290 count++ ;
1291
1292 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideIntOp, (void ( * )()) 0, inputs, "operator" ) ) ;
1293 }
1294
1295
1296
1297
1298 /* create convertors */
1299
1300 static void CharIntCallback( state, bytes, buffer )
1301 Source state ;
1302 ByteCount bytes ;
1303 int *buffer ;
1304 {
1305 register char *i = ( ( char *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( char *) 0l + ( ( ( bytes ) >> ( sizeof( int) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
1306 register int *o = buffer ;
1307 register Pointer e = (Pointer) buffer + bytes ;
1308
1309 if( (Pointer) o < e )
1310 do
1311 *o++ = *i++ ;
1312 while( (Pointer) o < e ) ;
1313
1314 return ;
1315 }
1316
1317 IntSource CharIntSource( source )
1318 IntSource source ;
1319 {
1320 return( stdAutoSource( ( Pointer ) source, CharIntCallback ) ) ;
1321 }
1322
1323
1324
1325 static void ShortIntCallback( state, bytes, buffer )
1326 Source state ;
1327 ByteCount bytes ;
1328 int *buffer ;
1329 {
1330 register short *i = ( ( short *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( short *) 0l + ( ( ( bytes ) >> ( sizeof( int) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
1331 register int *o = buffer ;
1332 register Pointer e = (Pointer) buffer + bytes ;
1333
1334 if( (Pointer) o < e )
1335 do
1336 *o++ = *i++ ;
1337 while( (Pointer) o < e ) ;
1338
1339 return ;
1340 }
1341
1342 IntSource ShortIntSource( source )
1343 IntSource source ;
1344 {
1345 return( stdAutoSource( ( Pointer ) source, ShortIntCallback ) ) ;
1346 }
1347
1348
1349
1350 static void IntIntCallback( state, bytes, buffer )
1351 Source state ;
1352 ByteCount bytes ;
1353 int *buffer ;
1354 {
1355 register int *i = ( ( int *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( int *) 0l + ( ( ( bytes ) >> ( sizeof( int) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
1356 register int *o = buffer ;
1357 register Pointer e = (Pointer) buffer + bytes ;
1358
1359 if( (Pointer) o < e )
1360 do
1361 *o++ = *i++ ;
1362 while( (Pointer) o < e ) ;
1363
1364 return ;
1365 }
1366
1367 IntSource IntIntSource( source )
1368 IntSource source ;
1369 {
1370 return( stdAutoSource( ( Pointer ) source, IntIntCallback ) ) ;
1371 }
1372
1373
1374
1375 static void FloatIntCallback( state, bytes, buffer )
1376 Source state ;
1377 ByteCount bytes ;
1378 int *buffer ;
1379 {
1380 register float *i = ( ( float *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( float *) 0l + ( ( ( bytes ) >> ( sizeof( int) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
1381 register int *o = buffer ;
1382 register Pointer e = (Pointer) buffer + bytes ;
1383
1384 if( (Pointer) o < e )
1385 do
1386 *o++ = *i++ ;
1387 while( (Pointer) o < e ) ;
1388
1389 return ;
1390 }
1391
1392 IntSource FloatIntSource( source )
1393 IntSource source ;
1394 {
1395 return( stdAutoSource( ( Pointer ) source, FloatIntCallback ) ) ;
1396 }
1397
1398
1399
1400 static void DoubleIntCallback( state, bytes, buffer )
1401 Source state ;
1402 ByteCount bytes ;
1403 int *buffer ;
1404 {
1405 register double *i = ( ( double *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( double *) 0l + ( ( ( bytes ) >> ( sizeof( int) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
1406 register int *o = buffer ;
1407 register Pointer e = (Pointer) buffer + bytes ;
1408
1409 if( (Pointer) o < e )
1410 do
1411 *o++ = *i++ ;
1412 while( (Pointer) o < e ) ;
1413
1414 return ;
1415 }
1416
1417 IntSource DoubleIntSource( source )
1418 IntSource source ;
1419 {
1420 return( stdAutoSource( ( Pointer ) source, DoubleIntCallback ) ) ;
1421 }
1422
1423
1424
1425
1426 Source SourceIntSource( source )
1427 Source source ;
1428 {
1429 static Source (*converts[])() = {
1430 SourceSource,
1431 CharIntSource,
1432 ShortIntSource,
1433 IntIntSource,
1434 FloatIntSource,
1435 DoubleIntSource
1436 } ;
1437
1438 return ( converts[ typeEntryNumber( sourceType( (struct _source *) source ) ) ]( source ) ) ;
1439 }
1440
1441
1442 static void floatConstantCallback( state, bytes, buffer, end )
1443 float *state ;
1444 ByteCount *bytes ;
1445 float *buffer, *end ;
1446 {
1447 register float i, *optr = buffer, *eptr = end ;
1448
1449 i = *state ;
1450
1451 if( optr < eptr )
1452 do
1453 *optr++ = i ;
1454 while( optr < eptr ) ;
1455
1456 return ;
1457 }
1458
1459 FloatSource ConstantFloatSource( constant )
1460 float constant ;
1461 {
1462 float * state = ( float * ) stitch_malloc( (unsigned) ( ( sizeof * ( float * ) 0 ) ), stitchStructStr ) ;
1463
1464 *state = constant ;
1465
1466 return ( newExternalSource( (Pointer) ( (Pointer) state ), floatConstantCallback, stitch_free, "ops.type constant" ) ) ;
1467 }
1468
1469
1470 static void floatIntegralCallback( integral, bytes, buffer, end, input )
1471 float *integral ;
1472 ByteCount *bytes ;
1473 float *buffer, *end, *input ;
1474 {
1475 register float *iptr = input ;
1476 register float *optr = buffer ;
1477 register float *eptr = end ;
1478
1479 if( optr < eptr )
1480 do {
1481 *optr++ = *integral ;
1482 *integral += *iptr++ ;
1483 } while( optr < eptr ) ;
1484
1485 return ;
1486 }
1487
1488 FloatSource IntegrateFloatSource( source, initial )
1489 FloatSource source ;
1490 float initial ;
1491 {
1492 float * integral = ( float * ) stitch_malloc( (unsigned) ( ( sizeof * ( float * ) 0 ) ), stitchStructStr ) ;
1493
1494 *integral = initial ;
1495
1496 return ( newProcessingSource( (Pointer) ( (Pointer) integral ), floatIntegralCallback, stitch_free, source, "ops.type integrating" ) ) ;
1497 }
1498
1499 static void floatCallingCallback( function, bytes, buffer, end, input )
1500 float (*function)() ;
1501 ByteCount *bytes ;
1502 float *buffer, *end, *input ;
1503 {
1504 register float *iptr = input ;
1505 register float *optr = buffer ;
1506 register float *eptr = end ;
1507
1508 if( optr < eptr )
1509 do
1510 *optr++ = function( *iptr++ ) ;
1511 while( optr < eptr ) ;
1512
1513 return ;
1514 }
1515
1516 FloatSource CallingFloatSource( source, function )
1517 FloatSource source ;
1518 float (*function)() ;
1519 {
1520 return ( newProcessingSource( (Pointer) ( (Pointer) function ), floatCallingCallback, (void ( * )()) 0, source, "ops.type function" ) ) ;
1521 }
1522
1523 /* do operators */
1524
1525 static void AddFloatOp( state, bytes, output, end, input1, input2 )
1526 Pointer *state ;
1527 ByteCount *bytes ;
1528 float *output, *end, *input1, *input2 ;
1529 {
1530 register float *optr = output ;
1531 register float *ipt1 = input1 ;
1532 register float *ipt2 = input2 ;
1533 register float *eptr = end ;
1534
1535 if( optr < eptr )
1536 do
1537 *optr++ = *ipt1++ + *ipt2++ ;
1538 while( optr < eptr ) ;
1539
1540 return ;
1541 }
1542
1543 Source AddFloatSources( input1, input2 )
1544 Source input1, input2 ;
1545 {
1546 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
1547
1548 inputs[0] = input1 ;
1549 inputs[1] = input2 ;
1550
1551 inputs[2] = (struct _source *) 0 ;
1552
1553 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddFloatOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
1554 }
1555
1556 /* VARARGS2 */
1557 Source AddFloatSourceArray( inputs )
1558 Source *inputs ;
1559 {
1560 int count = 0 ;
1561
1562 while( inputs[count] != (struct _source *) 0 )
1563 count++ ;
1564
1565 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddFloatOp, (void ( * )()) 0, inputs, "operator" ) ) ;
1566 }
1567
1568
1569
1570 static void SubtractFloatOp( state, bytes, output, end, input1, input2 )
1571 Pointer *state ;
1572 ByteCount *bytes ;
1573 float *output, *end, *input1, *input2 ;
1574 {
1575 register float *optr = output ;
1576 register float *ipt1 = input1 ;
1577 register float *ipt2 = input2 ;
1578 register float *eptr = end ;
1579
1580 if( optr < eptr )
1581 do
1582 *optr++ = *ipt1++ - *ipt2++ ;
1583 while( optr < eptr ) ;
1584
1585 return ;
1586 }
1587
1588 Source SubtractFloatSources( input1, input2 )
1589 Source input1, input2 ;
1590 {
1591 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
1592
1593 inputs[0] = input1 ;
1594 inputs[1] = input2 ;
1595
1596 inputs[2] = (struct _source *) 0 ;
1597
1598 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractFloatOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
1599 }
1600
1601 /* VARARGS2 */
1602 Source SubtractFloatSourceArray( inputs )
1603 Source *inputs ;
1604 {
1605 int count = 0 ;
1606
1607 while( inputs[count] != (struct _source *) 0 )
1608 count++ ;
1609
1610 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractFloatOp, (void ( * )()) 0, inputs, "operator" ) ) ;
1611 }
1612
1613
1614 static void MultiplyFloatOp( state, bytes, output, end, input1, input2 )
1615 Pointer *state ;
1616 ByteCount *bytes ;
1617 float *output, *end, *input1, *input2 ;
1618 {
1619 register float *optr = output ;
1620 register float *ipt1 = input1 ;
1621 register float *ipt2 = input2 ;
1622 register float *eptr = end ;
1623
1624 if( optr < eptr )
1625 do
1626 *optr++ = *ipt1++ * *ipt2++ ;
1627 while( optr < eptr ) ;
1628
1629 return ;
1630 }
1631
1632 Source MultiplyFloatSources( input1, input2 )
1633 Source input1, input2 ;
1634 {
1635 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
1636
1637 inputs[0] = input1 ;
1638 inputs[1] = input2 ;
1639
1640 inputs[2] = (struct _source *) 0 ;
1641
1642 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyFloatOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
1643 }
1644
1645 /* VARARGS2 */
1646 Source MultiplyFloatSourceArray( inputs )
1647 Source *inputs ;
1648 {
1649 int count = 0 ;
1650
1651 while( inputs[count] != (struct _source *) 0 )
1652 count++ ;
1653
1654 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyFloatOp, (void ( * )()) 0, inputs, "operator" ) ) ;
1655 }
1656
1657
1658
1659 static void DivideFloatOp( state, bytes, output, end, input1, input2 )
1660 Pointer *state ;
1661 ByteCount *bytes ;
1662 float *output, *end, *input1, *input2 ;
1663 {
1664 register float *optr = output ;
1665 register float *ipt1 = input1 ;
1666 register float *ipt2 = input2 ;
1667 register float *eptr = end ;
1668
1669 if( optr < eptr )
1670 do
1671 *optr++ = *ipt1++ / *ipt2++ ;
1672 while( optr < eptr ) ;
1673
1674 return ;
1675 }
1676
1677 Source DivideFloatSources( input1, input2 )
1678 Source input1, input2 ;
1679 {
1680 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
1681
1682 inputs[0] = input1 ;
1683 inputs[1] = input2 ;
1684
1685 inputs[2] = (struct _source *) 0 ;
1686
1687 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideFloatOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
1688 }
1689
1690 /* VARARGS2 */
1691 Source DivideFloatSourceArray( inputs )
1692 Source *inputs ;
1693 {
1694 int count = 0 ;
1695
1696 while( inputs[count] != (struct _source *) 0 )
1697 count++ ;
1698
1699 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideFloatOp, (void ( * )()) 0, inputs, "operator" ) ) ;
1700 }
1701
1702
1703
1704
1705 /* create convertors */
1706
1707
1708 static void CharFloatCallback( state, bytes, buffer )
1709 Source state ;
1710 ByteCount bytes ;
1711 float *buffer ;
1712 {
1713 register char *i = ( ( char *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( char *) 0l + ( ( ( bytes ) >> ( sizeof( float) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
1714 register float *o = buffer ;
1715 register Pointer e = (Pointer) buffer + bytes ;
1716
1717 if( (Pointer) o < e )
1718 do
1719 *o++ = *i++ ;
1720 while( (Pointer) o < e ) ;
1721
1722 return ;
1723 }
1724
1725 FloatSource CharFloatSource( source )
1726 FloatSource source ;
1727 {
1728 return( stdAutoSource( ( Pointer ) source, CharFloatCallback ) ) ;
1729 }
1730
1731
1732 static void ShortFloatCallback( state, bytes, buffer )
1733 Source state ;
1734 ByteCount bytes ;
1735 float *buffer ;
1736 {
1737 register short *i = ( ( short *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( short *) 0l + ( ( ( bytes ) >> ( sizeof( float) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
1738 register float *o = buffer ;
1739 register Pointer e = (Pointer) buffer + bytes ;
1740
1741 if( (Pointer) o < e )
1742 do
1743 *o++ = *i++ ;
1744 while( (Pointer) o < e ) ;
1745
1746 return ;
1747 }
1748
1749 FloatSource ShortFloatSource( source )
1750 FloatSource source ;
1751 {
1752 return( stdAutoSource( ( Pointer ) source, ShortFloatCallback ) ) ;
1753 }
1754
1755
1756
1757 static void IntFloatCallback( state, bytes, buffer )
1758 Source state ;
1759 ByteCount bytes ;
1760 float *buffer ;
1761 {
1762 register int *i = ( ( int *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( int *) 0l + ( ( ( bytes ) >> ( sizeof( float) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
1763 register float *o = buffer ;
1764 register Pointer e = (Pointer) buffer + bytes ;
1765
1766 if( (Pointer) o < e )
1767 do
1768 *o++ = *i++ ;
1769 while( (Pointer) o < e ) ;
1770
1771 return ;
1772 }
1773
1774 FloatSource IntFloatSource( source )
1775 FloatSource source ;
1776 {
1777 return( stdAutoSource( ( Pointer ) source, IntFloatCallback ) ) ;
1778 }
1779
1780
1781
1782 static void FloatFloatCallback( state, bytes, buffer )
1783 Source state ;
1784 ByteCount bytes ;
1785 float *buffer ;
1786 {
1787 register float *i = ( ( float *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( float *) 0l + ( ( ( bytes ) >> ( sizeof( float) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
1788 register float *o = buffer ;
1789 register Pointer e = (Pointer) buffer + bytes ;
1790
1791 if( (Pointer) o < e )
1792 do
1793 *o++ = *i++ ;
1794 while( (Pointer) o < e ) ;
1795
1796 return ;
1797 }
1798
1799 FloatSource FloatFloatSource( source )
1800 FloatSource source ;
1801 {
1802 return( stdAutoSource( ( Pointer ) source, FloatFloatCallback ) ) ;
1803 }
1804
1805
1806
1807 static void DoubleFloatCallback( state, bytes, buffer )
1808 Source state ;
1809 ByteCount bytes ;
1810 float *buffer ;
1811 {
1812 register double *i = ( ( double *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( double *) 0l + ( ( ( bytes ) >> ( sizeof( float) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
1813 register float *o = buffer ;
1814 register Pointer e = (Pointer) buffer + bytes ;
1815
1816 if( (Pointer) o < e )
1817 do
1818 *o++ = *i++ ;
1819 while( (Pointer) o < e ) ;
1820
1821 return ;
1822 }
1823
1824 FloatSource DoubleFloatSource( source )
1825 FloatSource source ;
1826 {
1827 return( stdAutoSource( ( Pointer ) source, DoubleFloatCallback ) ) ;
1828 }
1829
1830
1831
1832
1833 Source SourceFloatSource( source )
1834 Source source ;
1835 {
1836 static Source (*converts[])() = {
1837 SourceSource,
1838 CharFloatSource,
1839 ShortFloatSource,
1840 IntFloatSource,
1841 FloatFloatSource,
1842 DoubleFloatSource
1843 } ;
1844
1845 return ( converts[ typeEntryNumber( sourceType( (struct _source *) source ) ) ]( source ) ) ;
1846 }
1847
1848
1849
1850
1851 static void doubleConstantCallback( state, bytes, buffer, end )
1852 double *state ;
1853 ByteCount *bytes ;
1854 double *buffer, *end ;
1855 {
1856 register double i, *optr = buffer, *eptr = end ;
1857
1858 i = *state ;
1859
1860 if( optr < eptr )
1861 do
1862 *optr++ = i ;
1863 while( optr < eptr ) ;
1864
1865 return ;
1866 }
1867
1868 DoubleSource ConstantDoubleSource( constant )
1869 double constant ;
1870 {
1871 double * state = ( double * ) stitch_malloc( (unsigned) ( ( sizeof * ( double * ) 0 ) ), stitchStructStr ) ;
1872
1873 *state = constant ;
1874
1875 return ( newExternalSource( (Pointer) ( (Pointer) state ), doubleConstantCallback, stitch_free, "ops.type constant" ) ) ;
1876 }
1877
1878
1879 static void doubleIntegralCallback( integral, bytes, buffer, end, input )
1880 double *integral ;
1881 ByteCount *bytes ;
1882 double *buffer, *end, *input ;
1883 {
1884 register double *iptr = input ;
1885 register double *optr = buffer ;
1886 register double *eptr = end ;
1887
1888 if( optr < eptr )
1889 do {
1890 *optr++ = *integral ;
1891 *integral += *iptr++ ;
1892 } while( optr < eptr ) ;
1893
1894 return ;
1895 }
1896
1897 DoubleSource IntegrateDoubleSource( source, initial )
1898 DoubleSource source ;
1899 double initial ;
1900 {
1901 double * integral = ( double * ) stitch_malloc( (unsigned) ( ( sizeof * ( double * ) 0 ) ), stitchStructStr ) ;
1902
1903 *integral = initial ;
1904
1905 return ( newProcessingSource( (Pointer) ( (Pointer) integral ), doubleIntegralCallback, stitch_free, source, "ops.type integrating" ) ) ;
1906 }
1907
1908 static void doubleCallingCallback( function, bytes, buffer, end, input )
1909 double (*function)() ;
1910 ByteCount *bytes ;
1911 double *buffer, *end, *input ;
1912 {
1913 register double *iptr = input ;
1914 register double *optr = buffer ;
1915 register double *eptr = end ;
1916
1917 if( optr < eptr )
1918 do
1919 *optr++ = function( *iptr++ ) ;
1920 while( optr < eptr ) ;
1921
1922 return ;
1923 }
1924
1925 DoubleSource CallingDoubleSource( source, function )
1926 DoubleSource source ;
1927 double (*function)() ;
1928 {
1929 return ( newProcessingSource( (Pointer) ( (Pointer) function ), doubleCallingCallback, (void ( * )()) 0, source, "ops.type function" ) ) ;
1930 }
1931
1932 /* do operators */
1933
1934
1935 static void AddDoubleOp( state, bytes, output, end, input1, input2 )
1936 Pointer *state ;
1937 ByteCount *bytes ;
1938 double *output, *end, *input1, *input2 ;
1939 {
1940 register double *optr = output ;
1941 register double *ipt1 = input1 ;
1942 register double *ipt2 = input2 ;
1943 register double *eptr = end ;
1944
1945 if( optr < eptr )
1946 do
1947 *optr++ = *ipt1++ + *ipt2++ ;
1948 while( optr < eptr ) ;
1949
1950 return ;
1951 }
1952
1953 Source AddDoubleSources( input1, input2 )
1954 Source input1, input2 ;
1955 {
1956 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
1957
1958 inputs[0] = input1 ;
1959 inputs[1] = input2 ;
1960
1961 inputs[2] = (struct _source *) 0 ;
1962
1963 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddDoubleOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
1964 }
1965
1966 /* VARARGS2 */
1967 Source AddDoubleSourceArray( inputs )
1968 Source *inputs ;
1969 {
1970 int count = 0 ;
1971
1972 while( inputs[count] != (struct _source *) 0 )
1973 count++ ;
1974
1975 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddDoubleOp, (void ( * )()) 0, inputs, "operator" ) ) ;
1976 }
1977
1978
1979
1980
1981 static void SubtractDoubleOp( state, bytes, output, end, input1, input2 )
1982 Pointer *state ;
1983 ByteCount *bytes ;
1984 double *output, *end, *input1, *input2 ;
1985 {
1986 register double *optr = output ;
1987 register double *ipt1 = input1 ;
1988 register double *ipt2 = input2 ;
1989 register double *eptr = end ;
1990
1991 if( optr < eptr )
1992 do
1993 *optr++ = *ipt1++ - *ipt2++ ;
1994 while( optr < eptr ) ;
1995
1996 return ;
1997 }
1998
1999 Source SubtractDoubleSources( input1, input2 )
2000 Source input1, input2 ;
2001 {
2002 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
2003
2004 inputs[0] = input1 ;
2005 inputs[1] = input2 ;
2006
2007 inputs[2] = (struct _source *) 0 ;
2008
2009 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractDoubleOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
2010 }
2011
2012 /* VARARGS2 */
2013 Source SubtractDoubleSourceArray( inputs )
2014 Source *inputs ;
2015 {
2016 int count = 0 ;
2017
2018 while( inputs[count] != (struct _source *) 0 )
2019 count++ ;
2020
2021 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractDoubleOp, (void ( * )()) 0, inputs, "operator" ) ) ;
2022 }
2023
2024
2025
2026
2027 static void MultiplyDoubleOp( state, bytes, output, end, input1, input2 )
2028 Pointer *state ;
2029 ByteCount *bytes ;
2030 double *output, *end, *input1, *input2 ;
2031 {
2032 register double *optr = output ;
2033 register double *ipt1 = input1 ;
2034 register double *ipt2 = input2 ;
2035 register double *eptr = end ;
2036
2037 if( optr < eptr )
2038 do
2039 *optr++ = *ipt1++ * *ipt2++ ;
2040 while( optr < eptr ) ;
2041
2042 return ;
2043 }
2044
2045 Source MultiplyDoubleSources( input1, input2 )
2046 Source input1, input2 ;
2047 {
2048 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
2049
2050 inputs[0] = input1 ;
2051 inputs[1] = input2 ;
2052
2053 inputs[2] = (struct _source *) 0 ;
2054
2055 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyDoubleOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
2056 }
2057
2058 /* VARARGS2 */
2059 Source MultiplyDoubleSourceArray( inputs )
2060 Source *inputs ;
2061 {
2062 int count = 0 ;
2063
2064 while( inputs[count] != (struct _source *) 0 )
2065 count++ ;
2066
2067 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyDoubleOp, (void ( * )()) 0, inputs, "operator" ) ) ;
2068 }
2069
2070
2071 static void DivideDoubleOp( state, bytes, output, end, input1, input2 )
2072 Pointer *state ;
2073 ByteCount *bytes ;
2074 double *output, *end, *input1, *input2 ;
2075 {
2076 register double *optr = output ;
2077 register double *ipt1 = input1 ;
2078 register double *ipt2 = input2 ;
2079 register double *eptr = end ;
2080
2081 if( optr < eptr )
2082 do
2083 *optr++ = *ipt1++ / *ipt2++ ;
2084 while( optr < eptr ) ;
2085
2086 return ;
2087 }
2088
2089 Source DivideDoubleSources( input1, input2 )
2090 Source input1, input2 ;
2091 {
2092 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
2093
2094 inputs[0] = input1 ;
2095 inputs[1] = input2 ;
2096
2097 inputs[2] = (struct _source *) 0 ;
2098
2099 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideDoubleOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
2100 }
2101
2102 /* VARARGS2 */
2103 Source DivideDoubleSourceArray( inputs )
2104 Source *inputs ;
2105 {
2106 int count = 0 ;
2107
2108 while( inputs[count] != (struct _source *) 0 )
2109 count++ ;
2110
2111 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideDoubleOp, (void ( * )()) 0, inputs, "operator" ) ) ;
2112 }
2113
2114
2115
2116
2117 /* create convertors */
2118
2119
2120 static void CharDoubleCallback( state, bytes, buffer )
2121 Source state ;
2122 ByteCount bytes ;
2123 double *buffer ;
2124 {
2125 register char *i = ( ( char *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( char *) 0l + ( ( ( bytes ) >> ( sizeof( double) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
2126 register double *o = buffer ;
2127 register Pointer e = (Pointer) buffer + bytes ;
2128
2129 if( (Pointer) o < e )
2130 do
2131 *o++ = *i++ ;
2132 while( (Pointer) o < e ) ;
2133
2134 return ;
2135 }
2136
2137 DoubleSource CharDoubleSource( source )
2138 DoubleSource source ;
2139 {
2140 return( stdAutoSource( ( Pointer ) source, CharDoubleCallback ) ) ;
2141 }
2142
2143
2144
2145
2146 static void ShortDoubleCallback( state, bytes, buffer )
2147 Source state ;
2148 ByteCount bytes ;
2149 double *buffer ;
2150 {
2151 register short *i = ( ( short *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( short *) 0l + ( ( ( bytes ) >> ( sizeof( double) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
2152 register double *o = buffer ;
2153 register Pointer e = (Pointer) buffer + bytes ;
2154
2155 if( (Pointer) o < e )
2156 do
2157 *o++ = *i++ ;
2158 while( (Pointer) o < e ) ;
2159
2160 return ;
2161 }
2162
2163 DoubleSource ShortDoubleSource( source )
2164 DoubleSource source ;
2165 {
2166 return( stdAutoSource( ( Pointer ) source, ShortDoubleCallback ) ) ;
2167 }
2168
2169
2170
2171 static void IntDoubleCallback( state, bytes, buffer )
2172 Source state ;
2173 ByteCount bytes ;
2174 double *buffer ;
2175 {
2176 register int *i = ( ( int *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( int *) 0l + ( ( ( bytes ) >> ( sizeof( double) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
2177 register double *o = buffer ;
2178 register Pointer e = (Pointer) buffer + bytes ;
2179
2180 if( (Pointer) o < e )
2181 do
2182 *o++ = *i++ ;
2183 while( (Pointer) o < e ) ;
2184
2185 return ;
2186 }
2187
2188 DoubleSource IntDoubleSource( source )
2189 DoubleSource source ;
2190 {
2191 return( stdAutoSource( ( Pointer ) source, IntDoubleCallback ) ) ;
2192 }
2193
2194
2195
2196
2197 static void FloatDoubleCallback( state, bytes, buffer )
2198 Source state ;
2199 ByteCount bytes ;
2200 double *buffer ;
2201 {
2202 register float *i = ( ( float *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( float *) 0l + ( ( ( bytes ) >> ( sizeof( double) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
2203 register double *o = buffer ;
2204 register Pointer e = (Pointer) buffer + bytes ;
2205
2206 if( (Pointer) o < e )
2207 do
2208 *o++ = *i++ ;
2209 while( (Pointer) o < e ) ;
2210
2211 return ;
2212 }
2213
2214 DoubleSource FloatDoubleSource( source )
2215 DoubleSource source ;
2216 {
2217 return( stdAutoSource( ( Pointer ) source, FloatDoubleCallback ) ) ;
2218 }
2219
2220
2221 static void DoubleDoubleCallback( state, bytes, buffer )
2222 Source state ;
2223 ByteCount bytes ;
2224 double *buffer ;
2225 {
2226 register double *i = ( ( double *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( double *) 0l + ( ( ( bytes ) >> ( sizeof( double) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
2227 register double *o = buffer ;
2228 register Pointer e = (Pointer) buffer + bytes ;
2229
2230 if( (Pointer) o < e )
2231 do
2232 *o++ = *i++ ;
2233 while( (Pointer) o < e ) ;
2234
2235 return ;
2236 }
2237
2238 DoubleSource DoubleDoubleSource( source )
2239 DoubleSource source ;
2240 {
2241 return( stdAutoSource( ( Pointer ) source, DoubleDoubleCallback ) ) ;
2242 }
2243
2244
2245
2246
2247 Source SourceDoubleSource( source )
2248 Source source ;
2249 {
2250 static Source (*converts[])() = {
2251 SourceSource,
2252 CharDoubleSource,
2253 ShortDoubleSource,
2254 IntDoubleSource,
2255 FloatDoubleSource,
2256 DoubleDoubleSource
2257 } ;
2258
2259 return ( converts[ typeEntryNumber( sourceType( (struct _source *) source ) ) ]( source ) ) ;
2260 }
2261
2262
2263
2264