1 #line 6 "ncx.m4"
2 /* Do not edit this file. It is produced from the corresponding .m4 source */
3 #line 8
4 /*
5  *  Copyright (C) 2014, Northwestern University and Argonne National Laboratory
6  *  See COPYRIGHT notice in top-level directory.
7  */
8 /* $Id: ncx.m4 2601 2016-11-07 04:54:42Z wkliao $ */
9 
10 #ifdef __GNUC__
11 #pragma GCC diagnostic ignored "-Wunused-parameter"
12 #endif
13 
14 #line 22
15 
16 #line 26
17 
18 
19 #line 34
20 
21 #line 41
22 
23 #line 41
24 #if HAVE_CONFIG_H
25 #line 41
26 #include <config.h>
27 #line 41
28 #endif
29 
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <limits.h>
34 
35 #line 53
36 
37 #line 53
38 #pragma GCC diagnostic ignored "-Wdeprecated"
39 #line 53
40 #include "ncx.h"
41 #line 53
42 #include "nc3dispatch.h"
43 
44 #line 72
45 
46 
47 
48 
49 #ifdef HAVE_INTTYPES_H
50 #include <inttypes.h> /* uint16_t, uint32_t, uint64_t */
51 #elif defined(HAVE_STDINT_H)
52 #include <stdint.h>   /* uint16_t, uint32_t, uint64_t */
53 #endif
54 
55 #line 103
56 
57 #line 121
58 
59 /*
60  * The only error code returned from subroutines in this file is NC_ERANGE,
61  * if errors are detected.
62  */
63 
64 /*
65  * An external data representation interface.
66  */
67 
68 /* alias poorly named limits.h macros */
69 #define  SHORT_MAX  SHRT_MAX
70 #define  SHORT_MIN  SHRT_MIN
71 #define USHORT_MAX USHRT_MAX
72 #ifndef LLONG_MAX
73 #   define LLONG_MAX	9223372036854775807LL
74 #   define LLONG_MIN	(-LLONG_MAX - 1LL)
75 #   define ULLONG_MAX	18446744073709551615ULL
76 #endif
77 #ifndef LONG_LONG_MAX
78 #define LONG_LONG_MAX LLONG_MAX
79 #endif
80 #ifndef LONGLONG_MAX
81 #define LONGLONG_MAX LONG_LONG_MAX
82 #endif
83 #ifndef LONG_LONG_MIN
84 #define LONG_LONG_MIN LLONG_MIN
85 #endif
86 #ifndef LONGLONG_MIN
87 #define LONGLONG_MIN LONG_LONG_MIN
88 #endif
89 #ifndef ULONG_LONG_MAX
90 #define ULONG_LONG_MAX ULLONG_MAX
91 #endif
92 #ifndef ULONGLONG_MAX
93 #define ULONGLONG_MAX ULONG_LONG_MAX
94 #endif
95 #include <float.h>
96 #ifndef FLT_MAX /* This POSIX macro missing on some systems */
97 # ifndef NO_IEEE_FLOAT
98 # define FLT_MAX 3.40282347e+38f
99 # else
100 # error "You will need to define FLT_MAX"
101 # endif
102 #endif
103 /* alias poorly named float.h macros */
104 #define FLOAT_MAX FLT_MAX
105 #define FLOAT_MIN (-FLT_MAX)
106 #define DOUBLE_MAX DBL_MAX
107 #define DOUBLE_MIN (-DBL_MAX)
108 #define FLOAT_MAX_EXP FLT_MAX_EXP
109 #define DOUBLE_MAX_EXP DBL_MAX_EXP
110 #include <assert.h>
111 #define UCHAR_MIN 0
112 #define Min(a,b) ((a) < (b) ? (a) : (b))
113 #define Max(a,b) ((a) > (b) ? (a) : (b))
114 
115 #ifndef SIZEOF_UCHAR
116 #ifdef  SIZEOF_UNSIGNED_CHAR
117 #define SIZEOF_UCHAR SIZEOF_UNSIGNED_CHAR
118 #else
119 #error "unknown SIZEOF_UCHAR"
120 #endif
121 #endif
122 
123 #ifndef SIZEOF_USHORT
124 #ifdef  SIZEOF_UNSIGNED_SHORT_INT
125 #define SIZEOF_USHORT SIZEOF_UNSIGNED_SHORT_INT
126 #elif defined(SIZEOF_UNSIGNED_SHORT)
127 #define SIZEOF_USHORT SIZEOF_UNSIGNED_SHORT
128 #else
129 #error "unknown SIZEOF_USHORT"
130 #endif
131 #endif
132 
133 #ifndef SIZEOF_UINT
134 #ifdef  SIZEOF_UNSIGNED_INT
135 #define SIZEOF_UINT SIZEOF_UNSIGNED_INT
136 #else
137 #error "unknown SIZEOF_UINT"
138 #endif
139 #endif
140 
141 #ifndef SIZEOF_LONGLONG
142 #ifdef  SIZEOF_LONG_LONG
143 #define SIZEOF_LONGLONG SIZEOF_LONG_LONG
144 #else
145 #error "unknown SIZEOF_LONGLONG"
146 #endif
147 #endif
148 
149 #ifndef SIZEOF_INT64
150 #ifdef  SIZEOF_LONG_LONG
151 #define SIZEOF_INT64 SIZEOF_LONG_LONG
152 #elif defined(SIZEOF_LONGLONG)
153 #define SIZEOF_INT64 SIZEOF_LONGLONG
154 #else
155 #error "unknown SIZEOF_INT64"
156 #endif
157 #endif
158 
159 #ifndef SIZEOF_ULONGLONG
160 #ifdef  SIZEOF_UNSIGNED_LONG_LONG
161 #define SIZEOF_ULONGLONG SIZEOF_UNSIGNED_LONG_LONG
162 #else
163 #error "unknown SIZEOF_ULONGLONG"
164 #endif
165 #endif
166 
167 #ifndef SIZEOF_UINT64
168 #ifdef  SIZEOF_UNSIGNED_LONG_LONG
169 #define SIZEOF_UINT64 SIZEOF_UNSIGNED_LONG_LONG
170 #elif defined(SIZEOF_ULONGLONG)
171 #define SIZEOF_UINT64 SIZEOF_ULONGLONG
172 #else
173 #error "unknown SIZEOF_UINT64"
174 #endif
175 #endif
176 
177 /*
178  * If the machine's float domain is "smaller" than the external one
179  * use the machine domain
180  */
181 #if defined(FLT_MAX_EXP) && FLT_MAX_EXP < 128 /* 128 is X_FLT_MAX_EXP */
182 #undef X_FLOAT_MAX
183 # define X_FLOAT_MAX FLT_MAX
184 #undef X_FLOAT_MIN
185 # define X_FLOAT_MIN (-X_FLOAT_MAX)
186 #endif
187 
188 #if defined(_SX) && _SX != 0 /* NEC SUPER UX */
189 #define LOOPCNT 256    /* must be no longer than hardware vector length */
190 #if _INT64
191 #undef  INT_MAX /* workaround cpp bug */
192 #define INT_MAX  X_INT_MAX
193 #undef  INT_MIN /* workaround cpp bug */
194 #define INT_MIN  X_INT_MIN
195 #undef  LONG_MAX /* workaround cpp bug */
196 #define LONG_MAX  X_INT_MAX
197 #undef  LONG_MIN /* workaround cpp bug */
198 #define LONG_MIN  X_INT_MIN
199 #elif _LONG64
200 #undef  LONG_MAX /* workaround cpp bug */
201 #define LONG_MAX  4294967295L
202 #undef  LONG_MIN /* workaround cpp bug */
203 #define LONG_MIN -4294967295L
204 #endif
205 #if !_FLOAT0
206 #error "FLOAT1 and FLOAT2 not supported"
207 #endif
208 #endif /* _SX */
209 
210 static const char nada[X_ALIGN] = {0, 0, 0, 0};
211 
212 #ifndef WORDS_BIGENDIAN
213 /* LITTLE_ENDIAN: DEC and intel */
214 /*
215  * Routines to convert to BIG ENDIAN.
216  * Optimize the swapn?b() and swap?b() routines aggressively.
217  */
218 
219 #define SWAP2(a) ( (((a) & 0xff) << 8) | \
220                    (((a) >> 8) & 0xff) )
221 
222 #define SWAP4(a) ( ((a) << 24) | \
223                   (((a) <<  8) & 0x00ff0000) | \
224                   (((a) >>  8) & 0x0000ff00) | \
225                   (((a) >> 24) & 0x000000ff) )
226 
227 #define SWAP8(a) ( (((a) & 0x00000000000000FFULL) << 56) | \
228                    (((a) & 0x000000000000FF00ULL) << 40) | \
229                    (((a) & 0x0000000000FF0000ULL) << 24) | \
230                    (((a) & 0x00000000FF000000ULL) <<  8) | \
231                    (((a) & 0x000000FF00000000ULL) >>  8) | \
232                    (((a) & 0x0000FF0000000000ULL) >> 24) | \
233                    (((a) & 0x00FF000000000000ULL) >> 40) | \
234                    (((a) & 0xFF00000000000000ULL) >> 56) )
235 
236 #if defined(_MSC_VER) && _MSC_VER < 1900
237 #define inline __inline
238 #endif
239 
240 inline static void
swapn2b(void * dst,const void * src,size_t nn)241 swapn2b(void *dst, const void *src, size_t nn)
242 {
243     /* it is OK if dst == src */
244     int i;
245     uint16_t *op = (uint16_t*) dst;
246     uint16_t *ip = (uint16_t*) src;
247     for (i=0; i<nn; i++) {
248         op[i] = ip[i];
249         op[i] = (uint16_t)SWAP2(op[i]);
250     }
251 #if 0
252 	char *op = dst;
253 	const char *ip = src;
254 
255 /* unroll the following to reduce loop overhead
256  *
257  *	while (nn-- > 0)
258  *	{
259  *		*op++ = *(++ip);
260  *		*op++ = *(ip++ -1);
261  *	}
262  */
263 	while (nn > 3)
264 	{
265 		*op++ = *(++ip);
266 		*op++ = *(ip++ -1);
267 		*op++ = *(++ip);
268 		*op++ = *(ip++ -1);
269 		*op++ = *(++ip);
270 		*op++ = *(ip++ -1);
271 		*op++ = *(++ip);
272 		*op++ = *(ip++ -1);
273 		nn -= 4;
274 	}
275 	while (nn-- > 0)
276 	{
277 		*op++ = *(++ip);
278 		*op++ = *(ip++ -1);
279 	}
280 #endif
281 }
282 
283 # ifndef vax
284 inline static void
swap4b(void * dst,const void * src)285 swap4b(void *dst, const void *src)
286 {
287     /* copy over, make the below swap in-place */
288     uint32_t tmp = *(uint32_t*)src;
289     tmp = SWAP4(tmp);
290     memcpy(dst, &tmp, 4);
291 
292     /* Codes below will cause "break strict-aliasing rules" in gcc
293     uint32_t *op = (uint32_t*)dst;
294     *op = *(uint32_t*)src;
295     *op = SWAP4(*op);
296     */
297 
298     /* Below are copied from netCDF-4.
299      * See https://bugtracking.unidata.ucar.edu/browse/NCF-338
300      * Quote "One issue we are wrestling with is how compilers optimize this
301      * code.  For some reason, we are actually needing to add an artificial
302      * move to a 4 byte space to get it to work.  I think what is happening is
303      * that the optimizer is bit shifting within a double, which is incorrect.
304      * The following code actually does work correctly.
305      *  This is in Linux land, gcc.
306      *
307      * However, the above in-place byte-swap does not appear affected by this.
308      */
309 #if 0
310     uint32_t *ip = (uint32_t*)src;
311     uint32_t tempOut;  /* cannot use pointer when gcc O2 optimizer is used */
312     tempOut = SWAP4(*ip);
313 
314     *(float *)dst = *(float *)(&tempOut);
315 #endif
316 
317     /* OLD implementation that results in four load and four store CPU
318        instructions
319     char *op = dst;
320     const char *ip = src;
321     op[0] = ip[3];
322     op[1] = ip[2];
323     op[2] = ip[1];
324     op[3] = ip[0];
325     */
326 
327 }
328 # endif /* !vax */
329 
330 inline static void
swapn4b(void * dst,const void * src,size_t nn)331 swapn4b(void *dst, const void *src, size_t nn)
332 {
333     int i;
334     uint32_t *op = (uint32_t*) dst;
335     uint32_t *ip = (uint32_t*) src;
336     for (i=0; i<nn; i++) {
337         /* copy over, make the below swap in-place */
338         op[i] = ip[i];
339         op[i] = SWAP4(op[i]);
340     }
341 
342 #if 0
343 	char *op = dst;
344 	const char *ip = src;
345 
346 /* unroll the following to reduce loop overhead
347  *	while (nn-- > 0)
348  *	{
349  *		op[0] = ip[3];
350  *		op[1] = ip[2];
351  *		op[2] = ip[1];
352  *		op[3] = ip[0];
353  *		op += 4;
354  *		ip += 4;
355  *	}
356  */
357 	while (nn > 3)
358 	{
359 		op[0] = ip[3];
360 		op[1] = ip[2];
361 		op[2] = ip[1];
362 		op[3] = ip[0];
363 		op[4] = ip[7];
364 		op[5] = ip[6];
365 		op[6] = ip[5];
366 		op[7] = ip[4];
367 		op[8] = ip[11];
368 		op[9] = ip[10];
369 		op[10] = ip[9];
370 		op[11] = ip[8];
371 		op[12] = ip[15];
372 		op[13] = ip[14];
373 		op[14] = ip[13];
374 		op[15] = ip[12];
375 		op += 16;
376 		ip += 16;
377 		nn -= 4;
378 	}
379 	while (nn-- > 0)
380 	{
381 		op[0] = ip[3];
382 		op[1] = ip[2];
383 		op[2] = ip[1];
384 		op[3] = ip[0];
385 		op += 4;
386 		ip += 4;
387 	}
388 #endif
389 }
390 
391 # ifndef vax
392 inline static void
swap8b(void * dst,const void * src)393 swap8b(void *dst, const void *src)
394 {
395 #ifdef FLOAT_WORDS_BIGENDIAN
396     /* copy over, make the below swap in-place */
397     *(uint64_t*)dst = *(uint64_t*)src;
398 
399     uint32_t *op = (uint32_t*)dst;
400     *op = SWAP4(*op);
401     op = (uint32_t*)((char*)dst+4);
402     *op = SWAP4(*op);
403 #else
404     uint64_t tmp = *(uint64_t*)src;
405     tmp = SWAP8(tmp);
406     memcpy(dst, &tmp, 8);
407 
408     /* Codes below will cause "break strict-aliasing rules" in gcc
409     uint64_t *op = (uint64_t*)dst;
410     *op = *(uint64_t*)src;
411     *op = SWAP8(*op);
412     */
413 #endif
414 
415 #if 0
416 	char *op = dst;
417 	const char *ip = src;
418 #  ifndef FLOAT_WORDS_BIGENDIAN
419 	op[0] = ip[7];
420 	op[1] = ip[6];
421 	op[2] = ip[5];
422 	op[3] = ip[4];
423 	op[4] = ip[3];
424 	op[5] = ip[2];
425 	op[6] = ip[1];
426 	op[7] = ip[0];
427 #  else
428 	op[0] = ip[3];
429 	op[1] = ip[2];
430 	op[2] = ip[1];
431 	op[3] = ip[0];
432 	op[4] = ip[7];
433 	op[5] = ip[6];
434 	op[6] = ip[5];
435 	op[7] = ip[4];
436 #endif
437 #endif
438 }
439 # endif /* !vax */
440 
441 # ifndef vax
442 inline static void
swapn8b(void * dst,const void * src,size_t nn)443 swapn8b(void *dst, const void *src, size_t nn)
444 {
445 #ifdef FLOAT_WORDS_BIGENDIAN
446     int i;
447     uint64_t *dst_p = (uint64_t*) dst;
448     uint64_t *src_p = (uint64_t*) src;
449     for (i=0; i<nn; i++) {
450         /* copy over, make the below swap in-place */
451         dst_p[i] = src_p[i];
452         uint32_t *op = (uint32_t*)(&dst_p[i]);
453         *op = SWAP4(*op);
454         op = (uint32_t*)((char*)op+4);
455         *op = SWAP4(*op);
456     }
457 #else
458     int i;
459     uint64_t *op = (uint64_t*) dst;
460     uint64_t *ip = (uint64_t*) src;
461     for (i=0; i<nn; i++) {
462         /* copy over, make the below swap in-place */
463         op[i] = ip[i];
464         op[i] = SWAP8(op[i]);
465     }
466 #endif
467 
468 #if 0
469 	char *op = dst;
470 	const char *ip = src;
471 
472 /* unroll the following to reduce loop overhead
473  *	while (nn-- > 0)
474  *	{
475  *		op[0] = ip[7];
476  *		op[1] = ip[6];
477  *		op[2] = ip[5];
478  *		op[3] = ip[4];
479  *		op[4] = ip[3];
480  *		op[5] = ip[2];
481  *		op[6] = ip[1];
482  *		op[7] = ip[0];
483  *		op += 8;
484  *		ip += 8;
485  *	}
486  */
487 #  ifndef FLOAT_WORDS_BIGENDIAN
488 	while (nn > 1)
489 	{
490 		op[0] = ip[7];
491 		op[1] = ip[6];
492 		op[2] = ip[5];
493 		op[3] = ip[4];
494 		op[4] = ip[3];
495 		op[5] = ip[2];
496 		op[6] = ip[1];
497 		op[7] = ip[0];
498 		op[8] = ip[15];
499 		op[9] = ip[14];
500 		op[10] = ip[13];
501 		op[11] = ip[12];
502 		op[12] = ip[11];
503 		op[13] = ip[10];
504 		op[14] = ip[9];
505 		op[15] = ip[8];
506 		op += 16;
507 		ip += 16;
508 		nn -= 2;
509 	}
510 	while (nn-- > 0)
511 	{
512 		op[0] = ip[7];
513 		op[1] = ip[6];
514 		op[2] = ip[5];
515 		op[3] = ip[4];
516 		op[4] = ip[3];
517 		op[5] = ip[2];
518 		op[6] = ip[1];
519 		op[7] = ip[0];
520 		op += 8;
521 		ip += 8;
522 	}
523 #  else
524 	while (nn-- > 0)
525 	{
526 		op[0] = ip[3];
527 		op[1] = ip[2];
528 		op[2] = ip[1];
529 		op[3] = ip[0];
530 		op[4] = ip[7];
531 		op[5] = ip[6];
532 		op[6] = ip[5];
533 		op[7] = ip[4];
534 		op += 8;
535 		ip += 8;
536 	}
537 #endif
538 #endif
539 }
540 # endif /* !vax */
541 
542 #endif /* LITTLE_ENDIAN */
543 
544 #line 630
545 
546 #line 634
547 
548 #line 646
549 
550 #line 661
551 
552 
553 /*
554  * Primitive numeric conversion functions.
555  */
556 
557 #line 689
558 
559 #line 737
560 
561 #line 770
562 
563 #line 816
564 
565 /* x_schar */
566 /* x_uchar */
567 
568 /* We don't implement any x_schar and x_uchar primitives. */
569 
570 
571 /* external NC_SHORT --------------------------------------------------------*/
572 
573 #if SHORT_MAX == X_SHORT_MAX
574 typedef short ix_short;
575 #define SIZEOF_IX_SHORT SIZEOF_SHORT
576 #define IX_SHORT_MAX SHORT_MAX
577 #elif INT_MAX >= X_SHORT_MAX
578 typedef int ix_short;
579 #define SIZEOF_IX_SHORT SIZEOF_INT
580 #define IX_SHORT_MAX INT_MAX
581 #elif LONG_MAX >= X_SHORT_MAX
582 typedef long ix_short;
583 #define SIZEOF_IX_SHORT SIZEOF_LONG
584 #define IX_SHORT_MAX LONG_MAX
585 #elif LLONG_MAX >= X_SHORT_MAX
586 typedef long long ix_short;
587 #define SIZEOF_IX_SHORT SIZEOF_LONGLONG
588 #define IX_SHORT_MAX LLONG_MAX
589 #else
590 #error "ix_short implementation"
591 #endif
592 
593 static void
get_ix_short(const void * xp,ix_short * ip)594 get_ix_short(const void *xp, ix_short *ip)
595 {
596 	const uchar *cp = (const uchar *) xp;
597 	*ip = (ix_short)(*cp++ << 8);
598 #if SIZEOF_IX_SHORT > X_SIZEOF_SHORT
599 	if (*ip & 0x8000)
600 	{
601 		/* extern is negative */
602 		*ip |= (~(0xffff)); /* N.B. Assumes "twos complement" */
603 	}
604 #endif
605 	*ip = (ix_short)(*ip | *cp);
606 }
607 
608 static void
put_ix_short(void * xp,const ix_short * ip)609 put_ix_short(void *xp, const ix_short *ip)
610 {
611 	uchar *cp = (uchar *) xp;
612 	*cp++ = (uchar)((*ip) >> 8);
613 	*cp   = (uchar)((*ip) & 0xff);
614 }
615 
616 static int
617 #line 868
ncx_get_short_schar(const void * xp,schar * ip)618 ncx_get_short_schar(const void *xp, schar *ip)
619 #line 868
620 {
621 #line 868
622     int err=NC_NOERR;
623 #line 868
624     ix_short xx = 0;
625 #line 868
626     get_ix_short(xp, &xx);
627 #line 868
628 
629 #line 868
630 #if IX_SHORT_MAX > SCHAR_MAX
631 #line 868
632     if (xx > SCHAR_MAX || xx < SCHAR_MIN) {
633 #line 868
634 #ifdef ERANGE_FILL
635 #line 868
636         *ip = NC_FILL_BYTE;
637 #line 868
638         return NC_ERANGE;
639 #line 868
640 #else
641 #line 868
642         err = NC_ERANGE;
643 #line 868
644 #endif
645 #line 868
646     }
647 #line 868
648 #endif
649 #line 868
650 
651 #line 868
652 
653 #line 868
654     *ip = (schar) xx;
655 #line 868
656     return err;
657 #line 868
658 }
659 #line 868
660 
661 static int
662 #line 869
ncx_get_short_short(const void * xp,short * ip)663 ncx_get_short_short(const void *xp, short *ip)
664 #line 869
665 {
666 #line 869
667     int err=NC_NOERR;
668 #line 869
669 #if SIZEOF_IX_SHORT == SIZEOF_SHORT && IX_SHORT_MAX == SHORT_MAX
670 #line 869
671     get_ix_short(xp, (ix_short *)ip);
672 #line 869
673 #else
674 #line 869
675     ix_short xx = 0;
676 #line 869
677     get_ix_short(xp, &xx);
678 #line 869
679 
680 #line 869
681 #if IX_SHORT_MAX > SHORT_MAX
682 #line 869
683     if (xx > SHORT_MAX || xx < SHORT_MIN) {
684 #line 869
685 #ifdef ERANGE_FILL
686 #line 869
687         *ip = NC_FILL_SHORT;
688 #line 869
689         return NC_ERANGE;
690 #line 869
691 #else
692 #line 869
693         err = NC_ERANGE;
694 #line 869
695 #endif
696 #line 869
697     }
698 #line 869
699 #endif
700 #line 869
701 
702 #line 869
703 
704 #line 869
705     *ip = (short) xx;
706 #line 869
707 #endif
708 #line 869
709     return err;
710 #line 869
711 }
712 #line 869
713 
714 static int
715 #line 870
ncx_get_short_int(const void * xp,int * ip)716 ncx_get_short_int(const void *xp, int *ip)
717 #line 870
718 {
719 #line 870
720     int err=NC_NOERR;
721 #line 870
722 #if SIZEOF_IX_SHORT == SIZEOF_INT && IX_SHORT_MAX == INT_MAX
723 #line 870
724     get_ix_short(xp, (ix_short *)ip);
725 #line 870
726 #else
727 #line 870
728     ix_short xx = 0;
729 #line 870
730     get_ix_short(xp, &xx);
731 #line 870
732 
733 #line 870
734 #if IX_SHORT_MAX > INT_MAX
735 #line 870
736     if (xx > INT_MAX || xx < INT_MIN) {
737 #line 870
738 #ifdef ERANGE_FILL
739 #line 870
740         *ip = NC_FILL_INT;
741 #line 870
742         return NC_ERANGE;
743 #line 870
744 #else
745 #line 870
746         err = NC_ERANGE;
747 #line 870
748 #endif
749 #line 870
750     }
751 #line 870
752 #endif
753 #line 870
754 
755 #line 870
756 
757 #line 870
758     *ip = (int) xx;
759 #line 870
760 #endif
761 #line 870
762     return err;
763 #line 870
764 }
765 #line 870
766 
767 static int
768 #line 871
ncx_get_short_long(const void * xp,long * ip)769 ncx_get_short_long(const void *xp, long *ip)
770 #line 871
771 {
772 #line 871
773     int err=NC_NOERR;
774 #line 871
775 #if SIZEOF_IX_SHORT == SIZEOF_LONG && IX_SHORT_MAX == LONG_MAX
776 #line 871
777     get_ix_short(xp, (ix_short *)ip);
778 #line 871
779 #else
780 #line 871
781     ix_short xx = 0;
782 #line 871
783     get_ix_short(xp, &xx);
784 #line 871
785 
786 #line 871
787 #if IX_SHORT_MAX > LONG_MAX
788 #line 871
789     if (xx > LONG_MAX || xx < LONG_MIN) {
790 #line 871
791 #ifdef ERANGE_FILL
792 #line 871
793         *ip = NC_FILL_INT;
794 #line 871
795         return NC_ERANGE;
796 #line 871
797 #else
798 #line 871
799         err = NC_ERANGE;
800 #line 871
801 #endif
802 #line 871
803     }
804 #line 871
805 #endif
806 #line 871
807 
808 #line 871
809 
810 #line 871
811     *ip = (long) xx;
812 #line 871
813 #endif
814 #line 871
815     return err;
816 #line 871
817 }
818 #line 871
819 
820 static int
821 #line 872
ncx_get_short_longlong(const void * xp,longlong * ip)822 ncx_get_short_longlong(const void *xp, longlong *ip)
823 #line 872
824 {
825 #line 872
826     int err=NC_NOERR;
827 #line 872
828 #if SIZEOF_IX_SHORT == SIZEOF_LONGLONG && IX_SHORT_MAX == LONGLONG_MAX
829 #line 872
830     get_ix_short(xp, (ix_short *)ip);
831 #line 872
832 #else
833 #line 872
834     ix_short xx = 0;
835 #line 872
836     get_ix_short(xp, &xx);
837 #line 872
838 
839 #line 872
840 #if IX_SHORT_MAX > LONGLONG_MAX
841 #line 872
842     if (xx > LONGLONG_MAX || xx < LONGLONG_MIN) {
843 #line 872
844 #ifdef ERANGE_FILL
845 #line 872
846         *ip = NC_FILL_INT64;
847 #line 872
848         return NC_ERANGE;
849 #line 872
850 #else
851 #line 872
852         err = NC_ERANGE;
853 #line 872
854 #endif
855 #line 872
856     }
857 #line 872
858 #endif
859 #line 872
860 
861 #line 872
862 
863 #line 872
864     *ip = (longlong) xx;
865 #line 872
866 #endif
867 #line 872
868     return err;
869 #line 872
870 }
871 #line 872
872 
873 static int
874 #line 873
ncx_get_short_ushort(const void * xp,ushort * ip)875 ncx_get_short_ushort(const void *xp, ushort *ip)
876 #line 873
877 {
878 #line 873
879     int err=NC_NOERR;
880 #line 873
881     ix_short xx = 0;
882 #line 873
883     get_ix_short(xp, &xx);
884 #line 873
885 
886 #line 873
887 #if IX_SHORT_MAX > USHORT_MAX
888 #line 873
889     if (xx > USHORT_MAX) {
890 #line 873
891 #ifdef ERANGE_FILL
892 #line 873
893         *ip = NC_FILL_USHORT;
894 #line 873
895         return NC_ERANGE;
896 #line 873
897 #else
898 #line 873
899         err = NC_ERANGE;
900 #line 873
901 #endif
902 #line 873
903     }
904 #line 873
905 #endif
906 #line 873
907 
908 #line 873
909     if (xx < 0) {
910 #line 873
911 #ifdef ERANGE_FILL
912 #line 873
913         *ip = NC_FILL_USHORT;
914 #line 873
915         return NC_ERANGE;
916 #line 873
917 #else
918 #line 873
919         err = NC_ERANGE; /* because ip is unsigned */
920 #line 873
921 #endif
922 #line 873
923     }
924 #line 873
925     *ip = (ushort) xx;
926 #line 873
927     return err;
928 #line 873
929 }
930 #line 873
931 
932 static int
933 #line 874
ncx_get_short_uchar(const void * xp,uchar * ip)934 ncx_get_short_uchar(const void *xp, uchar *ip)
935 #line 874
936 {
937 #line 874
938     int err=NC_NOERR;
939 #line 874
940     ix_short xx = 0;
941 #line 874
942     get_ix_short(xp, &xx);
943 #line 874
944 
945 #line 874
946 #if IX_SHORT_MAX > UCHAR_MAX
947 #line 874
948     if (xx > UCHAR_MAX) {
949 #line 874
950 #ifdef ERANGE_FILL
951 #line 874
952         *ip = NC_FILL_UBYTE;
953 #line 874
954         return NC_ERANGE;
955 #line 874
956 #else
957 #line 874
958         err = NC_ERANGE;
959 #line 874
960 #endif
961 #line 874
962     }
963 #line 874
964 #endif
965 #line 874
966 
967 #line 874
968     if (xx < 0) {
969 #line 874
970 #ifdef ERANGE_FILL
971 #line 874
972         *ip = NC_FILL_UBYTE;
973 #line 874
974         return NC_ERANGE;
975 #line 874
976 #else
977 #line 874
978         err = NC_ERANGE; /* because ip is unsigned */
979 #line 874
980 #endif
981 #line 874
982     }
983 #line 874
984     *ip = (uchar) xx;
985 #line 874
986     return err;
987 #line 874
988 }
989 #line 874
990 
991 static int
992 #line 875
ncx_get_short_uint(const void * xp,uint * ip)993 ncx_get_short_uint(const void *xp, uint *ip)
994 #line 875
995 {
996 #line 875
997     int err=NC_NOERR;
998 #line 875
999     ix_short xx = 0;
1000 #line 875
1001     get_ix_short(xp, &xx);
1002 #line 875
1003 
1004 #line 875
1005 #if IX_SHORT_MAX > UINT_MAX
1006 #line 875
1007     if (xx > UINT_MAX) {
1008 #line 875
1009 #ifdef ERANGE_FILL
1010 #line 875
1011         *ip = NC_FILL_UINT;
1012 #line 875
1013         return NC_ERANGE;
1014 #line 875
1015 #else
1016 #line 875
1017         err = NC_ERANGE;
1018 #line 875
1019 #endif
1020 #line 875
1021     }
1022 #line 875
1023 #endif
1024 #line 875
1025 
1026 #line 875
1027     if (xx < 0) {
1028 #line 875
1029 #ifdef ERANGE_FILL
1030 #line 875
1031         *ip = NC_FILL_UINT;
1032 #line 875
1033         return NC_ERANGE;
1034 #line 875
1035 #else
1036 #line 875
1037         err = NC_ERANGE; /* because ip is unsigned */
1038 #line 875
1039 #endif
1040 #line 875
1041     }
1042 #line 875
1043     *ip = (uint) xx;
1044 #line 875
1045     return err;
1046 #line 875
1047 }
1048 #line 875
1049 
1050 static int
1051 #line 876
ncx_get_short_ulonglong(const void * xp,ulonglong * ip)1052 ncx_get_short_ulonglong(const void *xp, ulonglong *ip)
1053 #line 876
1054 {
1055 #line 876
1056     int err=NC_NOERR;
1057 #line 876
1058     ix_short xx = 0;
1059 #line 876
1060     get_ix_short(xp, &xx);
1061 #line 876
1062 
1063 #line 876
1064 #if IX_SHORT_MAX > ULONGLONG_MAX
1065 #line 876
1066     if (xx > ULONGLONG_MAX) {
1067 #line 876
1068 #ifdef ERANGE_FILL
1069 #line 876
1070         *ip = NC_FILL_UINT64;
1071 #line 876
1072         return NC_ERANGE;
1073 #line 876
1074 #else
1075 #line 876
1076         err = NC_ERANGE;
1077 #line 876
1078 #endif
1079 #line 876
1080     }
1081 #line 876
1082 #endif
1083 #line 876
1084 
1085 #line 876
1086     if (xx < 0) {
1087 #line 876
1088 #ifdef ERANGE_FILL
1089 #line 876
1090         *ip = NC_FILL_UINT64;
1091 #line 876
1092         return NC_ERANGE;
1093 #line 876
1094 #else
1095 #line 876
1096         err = NC_ERANGE; /* because ip is unsigned */
1097 #line 876
1098 #endif
1099 #line 876
1100     }
1101 #line 876
1102     *ip = (ulonglong) xx;
1103 #line 876
1104     return err;
1105 #line 876
1106 }
1107 #line 876
1108 
1109 static int
1110 #line 877
ncx_get_short_float(const void * xp,float * ip)1111 ncx_get_short_float(const void *xp, float *ip)
1112 #line 877
1113 {
1114 #line 877
1115 	ix_short xx = 0;
1116 #line 877
1117 	get_ix_short(xp, &xx);
1118 #line 877
1119 	*ip = (float)xx;
1120 #line 877
1121 	return NC_NOERR;
1122 #line 877
1123 }
1124 #line 877
1125 
1126 static int
1127 #line 878
ncx_get_short_double(const void * xp,double * ip)1128 ncx_get_short_double(const void *xp, double *ip)
1129 #line 878
1130 {
1131 #line 878
1132 	ix_short xx = 0;
1133 #line 878
1134 	get_ix_short(xp, &xx);
1135 #line 878
1136 	*ip = (double)xx;
1137 #line 878
1138 	return NC_NOERR;
1139 #line 878
1140 }
1141 #line 878
1142 
1143 
1144 static int
ncx_put_short_schar(void * xp,const schar * ip,void * fillp)1145 ncx_put_short_schar(void *xp, const schar *ip, void *fillp)
1146 {
1147 	uchar *cp = (uchar *) xp;
1148 	if (*ip & 0x80)
1149 		*cp++ = 0xff;
1150 	else
1151 		*cp++ = 0;
1152 	*cp = (uchar)*ip;
1153 	return NC_NOERR;
1154 }
1155 
1156 static int
ncx_put_short_uchar(void * xp,const uchar * ip,void * fillp)1157 ncx_put_short_uchar(void *xp, const uchar *ip, void *fillp)
1158 {
1159 	uchar *cp = (uchar *) xp;
1160 	*cp++ = 0;
1161 	*cp = *ip;
1162 	return NC_NOERR;
1163 }
1164 
1165 static int
1166 #line 901
ncx_put_short_short(void * xp,const short * ip,void * fillp)1167 ncx_put_short_short(void *xp, const short *ip, void *fillp)
1168 #line 901
1169 {
1170 #line 901
1171     int err=NC_NOERR;
1172 #line 901
1173 #if SIZEOF_IX_SHORT == SIZEOF_SHORT && IX_SHORT_MAX == SHORT_MAX
1174 #line 901
1175     put_ix_short(xp, (const ix_short *)ip);
1176 #line 901
1177 #else
1178 #line 901
1179     ix_short xx = NC_FILL_SHORT;
1180 #line 901
1181 
1182 #line 901
1183 #if IX_SHORT_MAX < SHORT_MAX
1184 #line 901
1185     if (*ip > IX_SHORT_MAX || *ip < X_SHORT_MIN) {
1186 #line 901
1187 
1188 #line 901
1189 #ifdef ERANGE_FILL
1190 #line 901
1191             if (fillp != NULL) memcpy(&xx, fillp, 2);
1192 #line 901
1193 #endif
1194 #line 901
1195         err = NC_ERANGE;
1196 #line 901
1197     }
1198 #line 901
1199 #ifdef ERANGE_FILL
1200 #line 901
1201     else
1202 #line 901
1203 #endif
1204 #line 901
1205 #endif
1206 #line 901
1207         xx = (ix_short)*ip;
1208 #line 901
1209 
1210 #line 901
1211     put_ix_short(xp, &xx);
1212 #line 901
1213 #endif
1214 #line 901
1215     return err;
1216 #line 901
1217 }
1218 #line 901
1219 
1220 static int
1221 #line 902
ncx_put_short_int(void * xp,const int * ip,void * fillp)1222 ncx_put_short_int(void *xp, const int *ip, void *fillp)
1223 #line 902
1224 {
1225 #line 902
1226     int err=NC_NOERR;
1227 #line 902
1228 #if SIZEOF_IX_SHORT == SIZEOF_INT && IX_SHORT_MAX == INT_MAX
1229 #line 902
1230     put_ix_short(xp, (const ix_short *)ip);
1231 #line 902
1232 #else
1233 #line 902
1234     ix_short xx = NC_FILL_SHORT;
1235 #line 902
1236 
1237 #line 902
1238 #if IX_SHORT_MAX < INT_MAX
1239 #line 902
1240     if (*ip > IX_SHORT_MAX || *ip < X_SHORT_MIN) {
1241 #line 902
1242 
1243 #line 902
1244 #ifdef ERANGE_FILL
1245 #line 902
1246             if (fillp != NULL) memcpy(&xx, fillp, 2);
1247 #line 902
1248 #endif
1249 #line 902
1250         err = NC_ERANGE;
1251 #line 902
1252     }
1253 #line 902
1254 #ifdef ERANGE_FILL
1255 #line 902
1256     else
1257 #line 902
1258 #endif
1259 #line 902
1260 #endif
1261 #line 902
1262         xx = (ix_short)*ip;
1263 #line 902
1264 
1265 #line 902
1266     put_ix_short(xp, &xx);
1267 #line 902
1268 #endif
1269 #line 902
1270     return err;
1271 #line 902
1272 }
1273 #line 902
1274 
1275 static int
1276 #line 903
ncx_put_short_long(void * xp,const long * ip,void * fillp)1277 ncx_put_short_long(void *xp, const long *ip, void *fillp)
1278 #line 903
1279 {
1280 #line 903
1281     int err=NC_NOERR;
1282 #line 903
1283 #if SIZEOF_IX_SHORT == SIZEOF_LONG && IX_SHORT_MAX == LONG_MAX
1284 #line 903
1285     put_ix_short(xp, (const ix_short *)ip);
1286 #line 903
1287 #else
1288 #line 903
1289     ix_short xx = NC_FILL_SHORT;
1290 #line 903
1291 
1292 #line 903
1293 #if IX_SHORT_MAX < LONG_MAX
1294 #line 903
1295     if (*ip > IX_SHORT_MAX || *ip < X_SHORT_MIN) {
1296 #line 903
1297 
1298 #line 903
1299 #ifdef ERANGE_FILL
1300 #line 903
1301             if (fillp != NULL) memcpy(&xx, fillp, 2);
1302 #line 903
1303 #endif
1304 #line 903
1305         err = NC_ERANGE;
1306 #line 903
1307     }
1308 #line 903
1309 #ifdef ERANGE_FILL
1310 #line 903
1311     else
1312 #line 903
1313 #endif
1314 #line 903
1315 #endif
1316 #line 903
1317         xx = (ix_short)*ip;
1318 #line 903
1319 
1320 #line 903
1321     put_ix_short(xp, &xx);
1322 #line 903
1323 #endif
1324 #line 903
1325     return err;
1326 #line 903
1327 }
1328 #line 903
1329 
1330 static int
1331 #line 904
ncx_put_short_longlong(void * xp,const longlong * ip,void * fillp)1332 ncx_put_short_longlong(void *xp, const longlong *ip, void *fillp)
1333 #line 904
1334 {
1335 #line 904
1336     int err=NC_NOERR;
1337 #line 904
1338 #if SIZEOF_IX_SHORT == SIZEOF_LONGLONG && IX_SHORT_MAX == LONGLONG_MAX
1339 #line 904
1340     put_ix_short(xp, (const ix_short *)ip);
1341 #line 904
1342 #else
1343 #line 904
1344     ix_short xx = NC_FILL_SHORT;
1345 #line 904
1346 
1347 #line 904
1348 #if IX_SHORT_MAX < LONGLONG_MAX
1349 #line 904
1350     if (*ip > IX_SHORT_MAX || *ip < X_SHORT_MIN) {
1351 #line 904
1352 
1353 #line 904
1354 #ifdef ERANGE_FILL
1355 #line 904
1356             if (fillp != NULL) memcpy(&xx, fillp, 2);
1357 #line 904
1358 #endif
1359 #line 904
1360         err = NC_ERANGE;
1361 #line 904
1362     }
1363 #line 904
1364 #ifdef ERANGE_FILL
1365 #line 904
1366     else
1367 #line 904
1368 #endif
1369 #line 904
1370 #endif
1371 #line 904
1372         xx = (ix_short)*ip;
1373 #line 904
1374 
1375 #line 904
1376     put_ix_short(xp, &xx);
1377 #line 904
1378 #endif
1379 #line 904
1380     return err;
1381 #line 904
1382 }
1383 #line 904
1384 
1385 static int
1386 #line 905
ncx_put_short_ushort(void * xp,const ushort * ip,void * fillp)1387 ncx_put_short_ushort(void *xp, const ushort *ip, void *fillp)
1388 #line 905
1389 {
1390 #line 905
1391     int err=NC_NOERR;
1392 #line 905
1393     ix_short xx = NC_FILL_SHORT;
1394 #line 905
1395 
1396 #line 905
1397 #if IX_SHORT_MAX < USHORT_MAX
1398 #line 905
1399     if (*ip > IX_SHORT_MAX) {
1400 #line 905
1401 
1402 #line 905
1403 #ifdef ERANGE_FILL
1404 #line 905
1405             if (fillp != NULL) memcpy(&xx, fillp, 2);
1406 #line 905
1407 #endif
1408 #line 905
1409         err = NC_ERANGE;
1410 #line 905
1411     }
1412 #line 905
1413 #ifdef ERANGE_FILL
1414 #line 905
1415     else
1416 #line 905
1417 #endif
1418 #line 905
1419 #endif
1420 #line 905
1421         xx = (ix_short)*ip;
1422 #line 905
1423 
1424 #line 905
1425     put_ix_short(xp, &xx);
1426 #line 905
1427     return err;
1428 #line 905
1429 }
1430 #line 905
1431 
1432 static int
1433 #line 906
ncx_put_short_uint(void * xp,const uint * ip,void * fillp)1434 ncx_put_short_uint(void *xp, const uint *ip, void *fillp)
1435 #line 906
1436 {
1437 #line 906
1438     int err=NC_NOERR;
1439 #line 906
1440     ix_short xx = NC_FILL_SHORT;
1441 #line 906
1442 
1443 #line 906
1444 #if IX_SHORT_MAX < UINT_MAX
1445 #line 906
1446     if (*ip > IX_SHORT_MAX) {
1447 #line 906
1448 
1449 #line 906
1450 #ifdef ERANGE_FILL
1451 #line 906
1452             if (fillp != NULL) memcpy(&xx, fillp, 2);
1453 #line 906
1454 #endif
1455 #line 906
1456         err = NC_ERANGE;
1457 #line 906
1458     }
1459 #line 906
1460 #ifdef ERANGE_FILL
1461 #line 906
1462     else
1463 #line 906
1464 #endif
1465 #line 906
1466 #endif
1467 #line 906
1468         xx = (ix_short)*ip;
1469 #line 906
1470 
1471 #line 906
1472     put_ix_short(xp, &xx);
1473 #line 906
1474     return err;
1475 #line 906
1476 }
1477 #line 906
1478 
1479 static int
1480 #line 907
ncx_put_short_ulonglong(void * xp,const ulonglong * ip,void * fillp)1481 ncx_put_short_ulonglong(void *xp, const ulonglong *ip, void *fillp)
1482 #line 907
1483 {
1484 #line 907
1485     int err=NC_NOERR;
1486 #line 907
1487     ix_short xx = NC_FILL_SHORT;
1488 #line 907
1489 
1490 #line 907
1491 #if IX_SHORT_MAX < ULONGLONG_MAX
1492 #line 907
1493     if (*ip > IX_SHORT_MAX) {
1494 #line 907
1495 
1496 #line 907
1497 #ifdef ERANGE_FILL
1498 #line 907
1499             if (fillp != NULL) memcpy(&xx, fillp, 2);
1500 #line 907
1501 #endif
1502 #line 907
1503         err = NC_ERANGE;
1504 #line 907
1505     }
1506 #line 907
1507 #ifdef ERANGE_FILL
1508 #line 907
1509     else
1510 #line 907
1511 #endif
1512 #line 907
1513 #endif
1514 #line 907
1515         xx = (ix_short)*ip;
1516 #line 907
1517 
1518 #line 907
1519     put_ix_short(xp, &xx);
1520 #line 907
1521     return err;
1522 #line 907
1523 }
1524 #line 907
1525 
1526 static int
1527 #line 908
ncx_put_short_float(void * xp,const float * ip,void * fillp)1528 ncx_put_short_float(void *xp, const float *ip, void *fillp)
1529 #line 908
1530 {
1531 #line 908
1532     int err=NC_NOERR;
1533 #line 908
1534     ix_short xx = NC_FILL_SHORT;
1535 #line 908
1536 
1537 #line 908
1538     if (*ip > (double)X_SHORT_MAX || *ip < (double)X_SHORT_MIN) {
1539 #line 908
1540 
1541 #line 908
1542 #ifdef ERANGE_FILL
1543 #line 908
1544             if (fillp != NULL) memcpy(&xx, fillp, 2);
1545 #line 908
1546 #endif
1547 #line 908
1548         err = NC_ERANGE;
1549 #line 908
1550     }
1551 #line 908
1552 #ifdef ERANGE_FILL
1553 #line 908
1554     else
1555 #line 908
1556 #endif
1557 #line 908
1558         xx = (ix_short)*ip;
1559 #line 908
1560 
1561 #line 908
1562     put_ix_short(xp, &xx);
1563 #line 908
1564     return err;
1565 #line 908
1566 }
1567 #line 908
1568 
1569 static int
1570 #line 909
ncx_put_short_double(void * xp,const double * ip,void * fillp)1571 ncx_put_short_double(void *xp, const double *ip, void *fillp)
1572 #line 909
1573 {
1574 #line 909
1575     int err=NC_NOERR;
1576 #line 909
1577     ix_short xx = NC_FILL_SHORT;
1578 #line 909
1579 
1580 #line 909
1581     if (*ip > X_SHORT_MAX || *ip < X_SHORT_MIN) {
1582 #line 909
1583 
1584 #line 909
1585 #ifdef ERANGE_FILL
1586 #line 909
1587             if (fillp != NULL) memcpy(&xx, fillp, 2);
1588 #line 909
1589 #endif
1590 #line 909
1591         err = NC_ERANGE;
1592 #line 909
1593     }
1594 #line 909
1595 #ifdef ERANGE_FILL
1596 #line 909
1597     else
1598 #line 909
1599 #endif
1600 #line 909
1601         xx = (ix_short)*ip;
1602 #line 909
1603 
1604 #line 909
1605     put_ix_short(xp, &xx);
1606 #line 909
1607     return err;
1608 #line 909
1609 }
1610 #line 909
1611 
1612 
1613 /* external NC_USHORT -------------------------------------------------------*/
1614 
1615 #if USHORT_MAX == X_USHORT_MAX
1616 typedef unsigned short ix_ushort;
1617 #define SIZEOF_IX_USHORT SIZEOF_USHORT
1618 #define IX_USHORT_MAX USHORT_MAX
1619 #elif UINT_MAX >= X_USHORT_MAX
1620 typedef unsigned int ix_ushort;
1621 #define SIZEOF_IX_USHORT SIZEOF_UINT
1622 #define IX_USHORT_MAX UINT_MAX
1623 #elif ULONG_MAX >= X_USHORT_MAX
1624 typedef unsigned long ix_ushort;
1625 #define SIZEOF_IX_USHORT SIZEOF_ULONG
1626 #define IX_USHORT_MAX ULONG_MAX
1627 #elif ULLONG_MAX >= X_USHORT_MAX
1628 typedef unsigned long long ix_ushort;
1629 #define SIZEOF_IX_USHORT SIZEOF_ULONGLONG
1630 #define IX_USHORT_MAX ULLONG_MAX
1631 #else
1632 #error "ix_ushort implementation"
1633 #endif
1634 
1635 static void
get_ix_ushort(const void * xp,ix_ushort * ip)1636 get_ix_ushort(const void *xp, ix_ushort *ip)
1637 {
1638 	const uchar *cp = (const uchar *) xp;
1639 	*ip = (ix_ushort)(*cp++ << 8);
1640 #if SIZEOF_IX_SHORT > X_SIZEOF_SHORT
1641 	if (*ip & 0x8000)
1642 	{
1643 		/* extern is negative */
1644 		*ip |= (~(0xffff)); /* N.B. Assumes "twos complement" */
1645 	}
1646 #endif
1647 	*ip = (ix_ushort)(*ip | *cp);
1648 }
1649 
1650 static void
put_ix_ushort(void * xp,const ix_ushort * ip)1651 put_ix_ushort(void *xp, const ix_ushort *ip)
1652 {
1653 	uchar *cp = (uchar *) xp;
1654 	*cp++ = (uchar)((*ip) >> 8);
1655 	*cp   = (uchar)((*ip) & 0xff);
1656 }
1657 
1658 static int
1659 #line 956
ncx_get_ushort_schar(const void * xp,schar * ip)1660 ncx_get_ushort_schar(const void *xp, schar *ip)
1661 #line 956
1662 {
1663 #line 956
1664     int err=NC_NOERR;
1665 #line 956
1666     ix_ushort xx = 0;
1667 #line 956
1668     get_ix_ushort(xp, &xx);
1669 #line 956
1670 
1671 #line 956
1672 #if IX_USHORT_MAX > SCHAR_MAX
1673 #line 956
1674     if (xx > SCHAR_MAX) {
1675 #line 956
1676 #ifdef ERANGE_FILL
1677 #line 956
1678         *ip = NC_FILL_BYTE;
1679 #line 956
1680         return NC_ERANGE;
1681 #line 956
1682 #else
1683 #line 956
1684         err = NC_ERANGE;
1685 #line 956
1686 #endif
1687 #line 956
1688     }
1689 #line 956
1690 #endif
1691 #line 956
1692 
1693 #line 956
1694 
1695 #line 956
1696     *ip = (schar) xx;
1697 #line 956
1698     return err;
1699 #line 956
1700 }
1701 #line 956
1702 
1703 static int
1704 #line 957
ncx_get_ushort_short(const void * xp,short * ip)1705 ncx_get_ushort_short(const void *xp, short *ip)
1706 #line 957
1707 {
1708 #line 957
1709     int err=NC_NOERR;
1710 #line 957
1711     ix_ushort xx = 0;
1712 #line 957
1713     get_ix_ushort(xp, &xx);
1714 #line 957
1715 
1716 #line 957
1717 #if IX_USHORT_MAX > SHORT_MAX
1718 #line 957
1719     if (xx > SHORT_MAX) {
1720 #line 957
1721 #ifdef ERANGE_FILL
1722 #line 957
1723         *ip = NC_FILL_SHORT;
1724 #line 957
1725         return NC_ERANGE;
1726 #line 957
1727 #else
1728 #line 957
1729         err = NC_ERANGE;
1730 #line 957
1731 #endif
1732 #line 957
1733     }
1734 #line 957
1735 #endif
1736 #line 957
1737 
1738 #line 957
1739 
1740 #line 957
1741     *ip = (short) xx;
1742 #line 957
1743     return err;
1744 #line 957
1745 }
1746 #line 957
1747 
1748 static int
1749 #line 958
ncx_get_ushort_int(const void * xp,int * ip)1750 ncx_get_ushort_int(const void *xp, int *ip)
1751 #line 958
1752 {
1753 #line 958
1754     int err=NC_NOERR;
1755 #line 958
1756     ix_ushort xx = 0;
1757 #line 958
1758     get_ix_ushort(xp, &xx);
1759 #line 958
1760 
1761 #line 958
1762 #if IX_USHORT_MAX > INT_MAX
1763 #line 958
1764     if (xx > INT_MAX) {
1765 #line 958
1766 #ifdef ERANGE_FILL
1767 #line 958
1768         *ip = NC_FILL_INT;
1769 #line 958
1770         return NC_ERANGE;
1771 #line 958
1772 #else
1773 #line 958
1774         err = NC_ERANGE;
1775 #line 958
1776 #endif
1777 #line 958
1778     }
1779 #line 958
1780 #endif
1781 #line 958
1782 
1783 #line 958
1784 
1785 #line 958
1786     *ip = (int) xx;
1787 #line 958
1788     return err;
1789 #line 958
1790 }
1791 #line 958
1792 
1793 static int
1794 #line 959
ncx_get_ushort_long(const void * xp,long * ip)1795 ncx_get_ushort_long(const void *xp, long *ip)
1796 #line 959
1797 {
1798 #line 959
1799     int err=NC_NOERR;
1800 #line 959
1801     ix_ushort xx = 0;
1802 #line 959
1803     get_ix_ushort(xp, &xx);
1804 #line 959
1805 
1806 #line 959
1807 #if IX_USHORT_MAX > LONG_MAX
1808 #line 959
1809     if (xx > LONG_MAX) {
1810 #line 959
1811 #ifdef ERANGE_FILL
1812 #line 959
1813         *ip = NC_FILL_INT;
1814 #line 959
1815         return NC_ERANGE;
1816 #line 959
1817 #else
1818 #line 959
1819         err = NC_ERANGE;
1820 #line 959
1821 #endif
1822 #line 959
1823     }
1824 #line 959
1825 #endif
1826 #line 959
1827 
1828 #line 959
1829 
1830 #line 959
1831     *ip = (long) xx;
1832 #line 959
1833     return err;
1834 #line 959
1835 }
1836 #line 959
1837 
1838 static int
1839 #line 960
ncx_get_ushort_longlong(const void * xp,longlong * ip)1840 ncx_get_ushort_longlong(const void *xp, longlong *ip)
1841 #line 960
1842 {
1843 #line 960
1844     int err=NC_NOERR;
1845 #line 960
1846     ix_ushort xx = 0;
1847 #line 960
1848     get_ix_ushort(xp, &xx);
1849 #line 960
1850 
1851 #line 960
1852 #if IX_USHORT_MAX > LONGLONG_MAX
1853 #line 960
1854     if (xx > LONGLONG_MAX) {
1855 #line 960
1856 #ifdef ERANGE_FILL
1857 #line 960
1858         *ip = NC_FILL_INT64;
1859 #line 960
1860         return NC_ERANGE;
1861 #line 960
1862 #else
1863 #line 960
1864         err = NC_ERANGE;
1865 #line 960
1866 #endif
1867 #line 960
1868     }
1869 #line 960
1870 #endif
1871 #line 960
1872 
1873 #line 960
1874 
1875 #line 960
1876     *ip = (longlong) xx;
1877 #line 960
1878     return err;
1879 #line 960
1880 }
1881 #line 960
1882 
1883 static int
1884 #line 961
ncx_get_ushort_ushort(const void * xp,ushort * ip)1885 ncx_get_ushort_ushort(const void *xp, ushort *ip)
1886 #line 961
1887 {
1888 #line 961
1889     int err=NC_NOERR;
1890 #line 961
1891 #if SIZEOF_IX_USHORT == SIZEOF_USHORT && IX_USHORT_MAX == USHORT_MAX
1892 #line 961
1893     get_ix_ushort(xp, (ix_ushort *)ip);
1894 #line 961
1895 #else
1896 #line 961
1897     ix_ushort xx = 0;
1898 #line 961
1899     get_ix_ushort(xp, &xx);
1900 #line 961
1901 
1902 #line 961
1903 #if IX_USHORT_MAX > USHORT_MAX
1904 #line 961
1905     if (xx > USHORT_MAX) {
1906 #line 961
1907 #ifdef ERANGE_FILL
1908 #line 961
1909         *ip = NC_FILL_USHORT;
1910 #line 961
1911         return NC_ERANGE;
1912 #line 961
1913 #else
1914 #line 961
1915         err = NC_ERANGE;
1916 #line 961
1917 #endif
1918 #line 961
1919     }
1920 #line 961
1921 #endif
1922 #line 961
1923 
1924 #line 961
1925 
1926 #line 961
1927     *ip = (ushort) xx;
1928 #line 961
1929 #endif
1930 #line 961
1931     return err;
1932 #line 961
1933 }
1934 #line 961
1935 
1936 static int
1937 #line 962
ncx_get_ushort_uchar(const void * xp,uchar * ip)1938 ncx_get_ushort_uchar(const void *xp, uchar *ip)
1939 #line 962
1940 {
1941 #line 962
1942     int err=NC_NOERR;
1943 #line 962
1944 #if SIZEOF_IX_USHORT == SIZEOF_UCHAR && IX_USHORT_MAX == UCHAR_MAX
1945 #line 962
1946     get_ix_ushort(xp, (ix_ushort *)ip);
1947 #line 962
1948 #else
1949 #line 962
1950     ix_ushort xx = 0;
1951 #line 962
1952     get_ix_ushort(xp, &xx);
1953 #line 962
1954 
1955 #line 962
1956 #if IX_USHORT_MAX > UCHAR_MAX
1957 #line 962
1958     if (xx > UCHAR_MAX) {
1959 #line 962
1960 #ifdef ERANGE_FILL
1961 #line 962
1962         *ip = NC_FILL_UBYTE;
1963 #line 962
1964         return NC_ERANGE;
1965 #line 962
1966 #else
1967 #line 962
1968         err = NC_ERANGE;
1969 #line 962
1970 #endif
1971 #line 962
1972     }
1973 #line 962
1974 #endif
1975 #line 962
1976 
1977 #line 962
1978 
1979 #line 962
1980     *ip = (uchar) xx;
1981 #line 962
1982 #endif
1983 #line 962
1984     return err;
1985 #line 962
1986 }
1987 #line 962
1988 
1989 static int
1990 #line 963
ncx_get_ushort_uint(const void * xp,uint * ip)1991 ncx_get_ushort_uint(const void *xp, uint *ip)
1992 #line 963
1993 {
1994 #line 963
1995     int err=NC_NOERR;
1996 #line 963
1997 #if SIZEOF_IX_USHORT == SIZEOF_UINT && IX_USHORT_MAX == UINT_MAX
1998 #line 963
1999     get_ix_ushort(xp, (ix_ushort *)ip);
2000 #line 963
2001 #else
2002 #line 963
2003     ix_ushort xx = 0;
2004 #line 963
2005     get_ix_ushort(xp, &xx);
2006 #line 963
2007 
2008 #line 963
2009 #if IX_USHORT_MAX > UINT_MAX
2010 #line 963
2011     if (xx > UINT_MAX) {
2012 #line 963
2013 #ifdef ERANGE_FILL
2014 #line 963
2015         *ip = NC_FILL_UINT;
2016 #line 963
2017         return NC_ERANGE;
2018 #line 963
2019 #else
2020 #line 963
2021         err = NC_ERANGE;
2022 #line 963
2023 #endif
2024 #line 963
2025     }
2026 #line 963
2027 #endif
2028 #line 963
2029 
2030 #line 963
2031 
2032 #line 963
2033     *ip = (uint) xx;
2034 #line 963
2035 #endif
2036 #line 963
2037     return err;
2038 #line 963
2039 }
2040 #line 963
2041 
2042 static int
2043 #line 964
ncx_get_ushort_ulonglong(const void * xp,ulonglong * ip)2044 ncx_get_ushort_ulonglong(const void *xp, ulonglong *ip)
2045 #line 964
2046 {
2047 #line 964
2048     int err=NC_NOERR;
2049 #line 964
2050 #if SIZEOF_IX_USHORT == SIZEOF_ULONGLONG && IX_USHORT_MAX == ULONGLONG_MAX
2051 #line 964
2052     get_ix_ushort(xp, (ix_ushort *)ip);
2053 #line 964
2054 #else
2055 #line 964
2056     ix_ushort xx = 0;
2057 #line 964
2058     get_ix_ushort(xp, &xx);
2059 #line 964
2060 
2061 #line 964
2062 #if IX_USHORT_MAX > ULONGLONG_MAX
2063 #line 964
2064     if (xx > ULONGLONG_MAX) {
2065 #line 964
2066 #ifdef ERANGE_FILL
2067 #line 964
2068         *ip = NC_FILL_UINT64;
2069 #line 964
2070         return NC_ERANGE;
2071 #line 964
2072 #else
2073 #line 964
2074         err = NC_ERANGE;
2075 #line 964
2076 #endif
2077 #line 964
2078     }
2079 #line 964
2080 #endif
2081 #line 964
2082 
2083 #line 964
2084 
2085 #line 964
2086     *ip = (ulonglong) xx;
2087 #line 964
2088 #endif
2089 #line 964
2090     return err;
2091 #line 964
2092 }
2093 #line 964
2094 
2095 static int
2096 #line 965
ncx_get_ushort_float(const void * xp,float * ip)2097 ncx_get_ushort_float(const void *xp, float *ip)
2098 #line 965
2099 {
2100 #line 965
2101 	ix_ushort xx = 0;
2102 #line 965
2103 	get_ix_ushort(xp, &xx);
2104 #line 965
2105 	*ip = (float)xx;
2106 #line 965
2107 	return NC_NOERR;
2108 #line 965
2109 }
2110 #line 965
2111 
2112 static int
2113 #line 966
ncx_get_ushort_double(const void * xp,double * ip)2114 ncx_get_ushort_double(const void *xp, double *ip)
2115 #line 966
2116 {
2117 #line 966
2118 	ix_ushort xx = 0;
2119 #line 966
2120 	get_ix_ushort(xp, &xx);
2121 #line 966
2122 	*ip = (double)xx;
2123 #line 966
2124 	return NC_NOERR;
2125 #line 966
2126 }
2127 #line 966
2128 
2129 
2130 static int
ncx_put_ushort_schar(void * xp,const schar * ip,void * fillp)2131 ncx_put_ushort_schar(void *xp, const schar *ip, void *fillp)
2132 {
2133     int err=NC_NOERR;
2134     uchar *cp;
2135     if (*ip < 0) {
2136 #ifdef ERANGE_FILL
2137         if (fillp != NULL) memcpy(xp, fillp, 2);
2138 #ifndef WORDS_BIGENDIAN
2139         swapn2b(xp, xp, 1);
2140 #endif
2141         return NC_ERANGE;
2142 #else
2143         err = NC_ERANGE;
2144 #endif
2145     }
2146 
2147     cp = (uchar *) xp;
2148     if (*ip & 0x80)
2149         *cp++ = 0xff;
2150     else
2151         *cp++ = 0;
2152     *cp = (uchar)*ip;
2153 
2154     return err;
2155 }
2156 
2157 static int
ncx_put_ushort_uchar(void * xp,const uchar * ip,void * fillp)2158 ncx_put_ushort_uchar(void *xp, const uchar *ip, void *fillp)
2159 {
2160 	uchar *cp = (uchar *) xp;
2161 	*cp++ = 0;
2162 	*cp = *ip;
2163 	return NC_NOERR;
2164 }
2165 
2166 static int
2167 #line 1004
ncx_put_ushort_short(void * xp,const short * ip,void * fillp)2168 ncx_put_ushort_short(void *xp, const short *ip, void *fillp)
2169 #line 1004
2170 {
2171 #line 1004
2172     int err=NC_NOERR;
2173 #line 1004
2174     ix_ushort xx = NC_FILL_USHORT;
2175 #line 1004
2176 
2177 #line 1004
2178 #if IX_USHORT_MAX < SHORT_MAX
2179 #line 1004
2180     if (*ip > IX_USHORT_MAX) {
2181 #line 1004
2182 
2183 #line 1004
2184 #ifdef ERANGE_FILL
2185 #line 1004
2186             if (fillp != NULL) memcpy(&xx, fillp, 2);
2187 #line 1004
2188 #endif
2189 #line 1004
2190         err = NC_ERANGE;
2191 #line 1004
2192     }
2193 #line 1004
2194 #ifdef ERANGE_FILL
2195 #line 1004
2196     else
2197 #line 1004
2198 #endif
2199 #line 1004
2200 #endif
2201 #line 1004
2202     if (*ip < 0) {
2203 #line 1004
2204 
2205 #line 1004
2206 #ifdef ERANGE_FILL
2207 #line 1004
2208             if (fillp != NULL) memcpy(&xx, fillp, 2);
2209 #line 1004
2210 #endif
2211 #line 1004
2212         err = NC_ERANGE; /* because xp is unsigned */
2213 #line 1004
2214     }
2215 #line 1004
2216 #ifdef ERANGE_FILL
2217 #line 1004
2218     else
2219 #line 1004
2220 #endif
2221 #line 1004
2222         xx = (ix_ushort)*ip;
2223 #line 1004
2224 
2225 #line 1004
2226     put_ix_ushort(xp, &xx);
2227 #line 1004
2228     return err;
2229 #line 1004
2230 }
2231 #line 1004
2232 
2233 static int
2234 #line 1005
ncx_put_ushort_int(void * xp,const int * ip,void * fillp)2235 ncx_put_ushort_int(void *xp, const int *ip, void *fillp)
2236 #line 1005
2237 {
2238 #line 1005
2239     int err=NC_NOERR;
2240 #line 1005
2241     ix_ushort xx = NC_FILL_USHORT;
2242 #line 1005
2243 
2244 #line 1005
2245 #if IX_USHORT_MAX < INT_MAX
2246 #line 1005
2247     if (*ip > IX_USHORT_MAX) {
2248 #line 1005
2249 
2250 #line 1005
2251 #ifdef ERANGE_FILL
2252 #line 1005
2253             if (fillp != NULL) memcpy(&xx, fillp, 2);
2254 #line 1005
2255 #endif
2256 #line 1005
2257         err = NC_ERANGE;
2258 #line 1005
2259     }
2260 #line 1005
2261 #ifdef ERANGE_FILL
2262 #line 1005
2263     else
2264 #line 1005
2265 #endif
2266 #line 1005
2267 #endif
2268 #line 1005
2269     if (*ip < 0) {
2270 #line 1005
2271 
2272 #line 1005
2273 #ifdef ERANGE_FILL
2274 #line 1005
2275             if (fillp != NULL) memcpy(&xx, fillp, 2);
2276 #line 1005
2277 #endif
2278 #line 1005
2279         err = NC_ERANGE; /* because xp is unsigned */
2280 #line 1005
2281     }
2282 #line 1005
2283 #ifdef ERANGE_FILL
2284 #line 1005
2285     else
2286 #line 1005
2287 #endif
2288 #line 1005
2289         xx = (ix_ushort)*ip;
2290 #line 1005
2291 
2292 #line 1005
2293     put_ix_ushort(xp, &xx);
2294 #line 1005
2295     return err;
2296 #line 1005
2297 }
2298 #line 1005
2299 
2300 static int
2301 #line 1006
ncx_put_ushort_long(void * xp,const long * ip,void * fillp)2302 ncx_put_ushort_long(void *xp, const long *ip, void *fillp)
2303 #line 1006
2304 {
2305 #line 1006
2306     int err=NC_NOERR;
2307 #line 1006
2308     ix_ushort xx = NC_FILL_USHORT;
2309 #line 1006
2310 
2311 #line 1006
2312 #if IX_USHORT_MAX < LONG_MAX
2313 #line 1006
2314     if (*ip > IX_USHORT_MAX) {
2315 #line 1006
2316 
2317 #line 1006
2318 #ifdef ERANGE_FILL
2319 #line 1006
2320             if (fillp != NULL) memcpy(&xx, fillp, 2);
2321 #line 1006
2322 #endif
2323 #line 1006
2324         err = NC_ERANGE;
2325 #line 1006
2326     }
2327 #line 1006
2328 #ifdef ERANGE_FILL
2329 #line 1006
2330     else
2331 #line 1006
2332 #endif
2333 #line 1006
2334 #endif
2335 #line 1006
2336     if (*ip < 0) {
2337 #line 1006
2338 
2339 #line 1006
2340 #ifdef ERANGE_FILL
2341 #line 1006
2342             if (fillp != NULL) memcpy(&xx, fillp, 2);
2343 #line 1006
2344 #endif
2345 #line 1006
2346         err = NC_ERANGE; /* because xp is unsigned */
2347 #line 1006
2348     }
2349 #line 1006
2350 #ifdef ERANGE_FILL
2351 #line 1006
2352     else
2353 #line 1006
2354 #endif
2355 #line 1006
2356         xx = (ix_ushort)*ip;
2357 #line 1006
2358 
2359 #line 1006
2360     put_ix_ushort(xp, &xx);
2361 #line 1006
2362     return err;
2363 #line 1006
2364 }
2365 #line 1006
2366 
2367 static int
2368 #line 1007
ncx_put_ushort_longlong(void * xp,const longlong * ip,void * fillp)2369 ncx_put_ushort_longlong(void *xp, const longlong *ip, void *fillp)
2370 #line 1007
2371 {
2372 #line 1007
2373     int err=NC_NOERR;
2374 #line 1007
2375     ix_ushort xx = NC_FILL_USHORT;
2376 #line 1007
2377 
2378 #line 1007
2379 #if IX_USHORT_MAX < LONGLONG_MAX
2380 #line 1007
2381     if (*ip > IX_USHORT_MAX) {
2382 #line 1007
2383 
2384 #line 1007
2385 #ifdef ERANGE_FILL
2386 #line 1007
2387             if (fillp != NULL) memcpy(&xx, fillp, 2);
2388 #line 1007
2389 #endif
2390 #line 1007
2391         err = NC_ERANGE;
2392 #line 1007
2393     }
2394 #line 1007
2395 #ifdef ERANGE_FILL
2396 #line 1007
2397     else
2398 #line 1007
2399 #endif
2400 #line 1007
2401 #endif
2402 #line 1007
2403     if (*ip < 0) {
2404 #line 1007
2405 
2406 #line 1007
2407 #ifdef ERANGE_FILL
2408 #line 1007
2409             if (fillp != NULL) memcpy(&xx, fillp, 2);
2410 #line 1007
2411 #endif
2412 #line 1007
2413         err = NC_ERANGE; /* because xp is unsigned */
2414 #line 1007
2415     }
2416 #line 1007
2417 #ifdef ERANGE_FILL
2418 #line 1007
2419     else
2420 #line 1007
2421 #endif
2422 #line 1007
2423         xx = (ix_ushort)*ip;
2424 #line 1007
2425 
2426 #line 1007
2427     put_ix_ushort(xp, &xx);
2428 #line 1007
2429     return err;
2430 #line 1007
2431 }
2432 #line 1007
2433 
2434 static int
2435 #line 1008
ncx_put_ushort_ushort(void * xp,const ushort * ip,void * fillp)2436 ncx_put_ushort_ushort(void *xp, const ushort *ip, void *fillp)
2437 #line 1008
2438 {
2439 #line 1008
2440     int err=NC_NOERR;
2441 #line 1008
2442 #if SIZEOF_IX_USHORT == SIZEOF_USHORT && IX_USHORT_MAX == USHORT_MAX
2443 #line 1008
2444     put_ix_ushort(xp, (const ix_ushort *)ip);
2445 #line 1008
2446 #else
2447 #line 1008
2448     ix_ushort xx = NC_FILL_USHORT;
2449 #line 1008
2450 
2451 #line 1008
2452 #if IX_USHORT_MAX < USHORT_MAX
2453 #line 1008
2454     if (*ip > IX_USHORT_MAX) {
2455 #line 1008
2456 
2457 #line 1008
2458 #ifdef ERANGE_FILL
2459 #line 1008
2460             if (fillp != NULL) memcpy(&xx, fillp, 2);
2461 #line 1008
2462 #endif
2463 #line 1008
2464         err = NC_ERANGE;
2465 #line 1008
2466     }
2467 #line 1008
2468 #ifdef ERANGE_FILL
2469 #line 1008
2470     else
2471 #line 1008
2472 #endif
2473 #line 1008
2474 #endif
2475 #line 1008
2476         xx = (ix_ushort)*ip;
2477 #line 1008
2478 
2479 #line 1008
2480     put_ix_ushort(xp, &xx);
2481 #line 1008
2482 #endif
2483 #line 1008
2484     return err;
2485 #line 1008
2486 }
2487 #line 1008
2488 
2489 static int
2490 #line 1009
ncx_put_ushort_uint(void * xp,const uint * ip,void * fillp)2491 ncx_put_ushort_uint(void *xp, const uint *ip, void *fillp)
2492 #line 1009
2493 {
2494 #line 1009
2495     int err=NC_NOERR;
2496 #line 1009
2497 #if SIZEOF_IX_USHORT == SIZEOF_UINT && IX_USHORT_MAX == UINT_MAX
2498 #line 1009
2499     put_ix_ushort(xp, (const ix_ushort *)ip);
2500 #line 1009
2501 #else
2502 #line 1009
2503     ix_ushort xx = NC_FILL_USHORT;
2504 #line 1009
2505 
2506 #line 1009
2507 #if IX_USHORT_MAX < UINT_MAX
2508 #line 1009
2509     if (*ip > IX_USHORT_MAX) {
2510 #line 1009
2511 
2512 #line 1009
2513 #ifdef ERANGE_FILL
2514 #line 1009
2515             if (fillp != NULL) memcpy(&xx, fillp, 2);
2516 #line 1009
2517 #endif
2518 #line 1009
2519         err = NC_ERANGE;
2520 #line 1009
2521     }
2522 #line 1009
2523 #ifdef ERANGE_FILL
2524 #line 1009
2525     else
2526 #line 1009
2527 #endif
2528 #line 1009
2529 #endif
2530 #line 1009
2531         xx = (ix_ushort)*ip;
2532 #line 1009
2533 
2534 #line 1009
2535     put_ix_ushort(xp, &xx);
2536 #line 1009
2537 #endif
2538 #line 1009
2539     return err;
2540 #line 1009
2541 }
2542 #line 1009
2543 
2544 static int
2545 #line 1010
ncx_put_ushort_ulonglong(void * xp,const ulonglong * ip,void * fillp)2546 ncx_put_ushort_ulonglong(void *xp, const ulonglong *ip, void *fillp)
2547 #line 1010
2548 {
2549 #line 1010
2550     int err=NC_NOERR;
2551 #line 1010
2552 #if SIZEOF_IX_USHORT == SIZEOF_ULONGLONG && IX_USHORT_MAX == ULONGLONG_MAX
2553 #line 1010
2554     put_ix_ushort(xp, (const ix_ushort *)ip);
2555 #line 1010
2556 #else
2557 #line 1010
2558     ix_ushort xx = NC_FILL_USHORT;
2559 #line 1010
2560 
2561 #line 1010
2562 #if IX_USHORT_MAX < ULONGLONG_MAX
2563 #line 1010
2564     if (*ip > IX_USHORT_MAX) {
2565 #line 1010
2566 
2567 #line 1010
2568 #ifdef ERANGE_FILL
2569 #line 1010
2570             if (fillp != NULL) memcpy(&xx, fillp, 2);
2571 #line 1010
2572 #endif
2573 #line 1010
2574         err = NC_ERANGE;
2575 #line 1010
2576     }
2577 #line 1010
2578 #ifdef ERANGE_FILL
2579 #line 1010
2580     else
2581 #line 1010
2582 #endif
2583 #line 1010
2584 #endif
2585 #line 1010
2586         xx = (ix_ushort)*ip;
2587 #line 1010
2588 
2589 #line 1010
2590     put_ix_ushort(xp, &xx);
2591 #line 1010
2592 #endif
2593 #line 1010
2594     return err;
2595 #line 1010
2596 }
2597 #line 1010
2598 
2599 static int
2600 #line 1011
ncx_put_ushort_float(void * xp,const float * ip,void * fillp)2601 ncx_put_ushort_float(void *xp, const float *ip, void *fillp)
2602 #line 1011
2603 {
2604 #line 1011
2605     int err=NC_NOERR;
2606 #line 1011
2607     ix_ushort xx = NC_FILL_USHORT;
2608 #line 1011
2609 
2610 #line 1011
2611     if (*ip > (double)X_USHORT_MAX || *ip < 0) {
2612 #line 1011
2613 
2614 #line 1011
2615 #ifdef ERANGE_FILL
2616 #line 1011
2617             if (fillp != NULL) memcpy(&xx, fillp, 2);
2618 #line 1011
2619 #endif
2620 #line 1011
2621         err = NC_ERANGE;
2622 #line 1011
2623     }
2624 #line 1011
2625 #ifdef ERANGE_FILL
2626 #line 1011
2627     else
2628 #line 1011
2629 #endif
2630 #line 1011
2631         xx = (ix_ushort)*ip;
2632 #line 1011
2633 
2634 #line 1011
2635     put_ix_ushort(xp, &xx);
2636 #line 1011
2637     return err;
2638 #line 1011
2639 }
2640 #line 1011
2641 
2642 static int
2643 #line 1012
ncx_put_ushort_double(void * xp,const double * ip,void * fillp)2644 ncx_put_ushort_double(void *xp, const double *ip, void *fillp)
2645 #line 1012
2646 {
2647 #line 1012
2648     int err=NC_NOERR;
2649 #line 1012
2650     ix_ushort xx = NC_FILL_USHORT;
2651 #line 1012
2652 
2653 #line 1012
2654     if (*ip > X_USHORT_MAX || *ip < 0) {
2655 #line 1012
2656 
2657 #line 1012
2658 #ifdef ERANGE_FILL
2659 #line 1012
2660             if (fillp != NULL) memcpy(&xx, fillp, 2);
2661 #line 1012
2662 #endif
2663 #line 1012
2664         err = NC_ERANGE;
2665 #line 1012
2666     }
2667 #line 1012
2668 #ifdef ERANGE_FILL
2669 #line 1012
2670     else
2671 #line 1012
2672 #endif
2673 #line 1012
2674         xx = (ix_ushort)*ip;
2675 #line 1012
2676 
2677 #line 1012
2678     put_ix_ushort(xp, &xx);
2679 #line 1012
2680     return err;
2681 #line 1012
2682 }
2683 #line 1012
2684 
2685 
2686 /* external NC_INT ----------------------------------------------------------*/
2687 
2688 #if SHORT_MAX == X_INT_MAX
2689 typedef short ix_int;
2690 #define SIZEOF_IX_INT SIZEOF_SHORT
2691 #define IX_INT_MAX SHORT_MAX
2692 #elif INT_MAX  >= X_INT_MAX
2693 typedef int ix_int;
2694 #define SIZEOF_IX_INT SIZEOF_INT
2695 #define IX_INT_MAX INT_MAX
2696 #elif LONG_MAX  >= X_INT_MAX
2697 typedef long ix_int;
2698 #define SIZEOF_IX_INT SIZEOF_LONG
2699 #define IX_INT_MAX LONG_MAX
2700 #else
2701 #error "ix_int implementation"
2702 #endif
2703 
2704 
2705 static void
get_ix_int(const void * xp,ix_int * ip)2706 get_ix_int(const void *xp, ix_int *ip)
2707 {
2708 	const uchar *cp = (const uchar *) xp;
2709 
2710 #if INT_MAX  >= X_INT_MAX
2711 	*ip = (ix_int)((unsigned)(*cp++) << 24);
2712 #else
2713 	*ip = *cp++ << 24;
2714 #endif
2715 #if SIZEOF_IX_INT > X_SIZEOF_INT
2716 	if (*ip & 0x80000000)
2717 	{
2718 		/* extern is negative */
2719 		*ip |= (~(0xffffffff)); /* N.B. Assumes "twos complement" */
2720 	}
2721 #endif
2722 	*ip |= (*cp++ << 16);
2723 	*ip |= (*cp++ << 8);
2724 	*ip |= *cp;
2725 }
2726 
2727 static void
put_ix_int(void * xp,const ix_int * ip)2728 put_ix_int(void *xp, const ix_int *ip)
2729 {
2730 	uchar *cp = (uchar *) xp;
2731 
2732 	*cp++ = (uchar)( (*ip) >> 24);
2733 	*cp++ = (uchar)(((*ip) & 0x00ff0000) >> 16);
2734 	*cp++ = (uchar)(((*ip) & 0x0000ff00) >>  8);
2735 	*cp   = (uchar)( (*ip) & 0x000000ff);
2736 }
2737 
2738 #if X_SIZEOF_INT != SIZEOF_INT
2739 static int
2740 #line 1067
ncx_get_int_int(const void * xp,int * ip)2741 ncx_get_int_int(const void *xp, int *ip)
2742 #line 1067
2743 {
2744 #line 1067
2745     int err=NC_NOERR;
2746 #line 1067
2747 #if SIZEOF_IX_INT == SIZEOF_INT && IX_INT_MAX == INT_MAX
2748 #line 1067
2749     get_ix_int(xp, (ix_int *)ip);
2750 #line 1067
2751 #else
2752 #line 1067
2753     ix_int xx = 0;
2754 #line 1067
2755     get_ix_int(xp, &xx);
2756 #line 1067
2757 
2758 #line 1067
2759 #if IX_INT_MAX > INT_MAX
2760 #line 1067
2761     if (xx > INT_MAX || xx < INT_MIN) {
2762 #line 1067
2763 #ifdef ERANGE_FILL
2764 #line 1067
2765         *ip = NC_FILL_INT;
2766 #line 1067
2767         return NC_ERANGE;
2768 #line 1067
2769 #else
2770 #line 1067
2771         err = NC_ERANGE;
2772 #line 1067
2773 #endif
2774 #line 1067
2775     }
2776 #line 1067
2777 #endif
2778 #line 1067
2779 
2780 #line 1067
2781 
2782 #line 1067
2783     *ip = (int) xx;
2784 #line 1067
2785 #endif
2786 #line 1067
2787     return err;
2788 #line 1067
2789 }
2790 #line 1067
2791 
2792 #endif
2793 static int
2794 #line 1069
ncx_get_int_schar(const void * xp,schar * ip)2795 ncx_get_int_schar(const void *xp, schar *ip)
2796 #line 1069
2797 {
2798 #line 1069
2799     int err=NC_NOERR;
2800 #line 1069
2801     ix_int xx = 0;
2802 #line 1069
2803     get_ix_int(xp, &xx);
2804 #line 1069
2805 
2806 #line 1069
2807 #if IX_INT_MAX > SCHAR_MAX
2808 #line 1069
2809     if (xx > SCHAR_MAX || xx < SCHAR_MIN) {
2810 #line 1069
2811 #ifdef ERANGE_FILL
2812 #line 1069
2813         *ip = NC_FILL_BYTE;
2814 #line 1069
2815         return NC_ERANGE;
2816 #line 1069
2817 #else
2818 #line 1069
2819         err = NC_ERANGE;
2820 #line 1069
2821 #endif
2822 #line 1069
2823     }
2824 #line 1069
2825 #endif
2826 #line 1069
2827 
2828 #line 1069
2829 
2830 #line 1069
2831     *ip = (schar) xx;
2832 #line 1069
2833     return err;
2834 #line 1069
2835 }
2836 #line 1069
2837 
2838 static int
2839 #line 1070
ncx_get_int_short(const void * xp,short * ip)2840 ncx_get_int_short(const void *xp, short *ip)
2841 #line 1070
2842 {
2843 #line 1070
2844     int err=NC_NOERR;
2845 #line 1070
2846 #if SIZEOF_IX_INT == SIZEOF_SHORT && IX_INT_MAX == SHORT_MAX
2847 #line 1070
2848     get_ix_int(xp, (ix_int *)ip);
2849 #line 1070
2850 #else
2851 #line 1070
2852     ix_int xx = 0;
2853 #line 1070
2854     get_ix_int(xp, &xx);
2855 #line 1070
2856 
2857 #line 1070
2858 #if IX_INT_MAX > SHORT_MAX
2859 #line 1070
2860     if (xx > SHORT_MAX || xx < SHORT_MIN) {
2861 #line 1070
2862 #ifdef ERANGE_FILL
2863 #line 1070
2864         *ip = NC_FILL_SHORT;
2865 #line 1070
2866         return NC_ERANGE;
2867 #line 1070
2868 #else
2869 #line 1070
2870         err = NC_ERANGE;
2871 #line 1070
2872 #endif
2873 #line 1070
2874     }
2875 #line 1070
2876 #endif
2877 #line 1070
2878 
2879 #line 1070
2880 
2881 #line 1070
2882     *ip = (short) xx;
2883 #line 1070
2884 #endif
2885 #line 1070
2886     return err;
2887 #line 1070
2888 }
2889 #line 1070
2890 
2891 static int
2892 #line 1071
ncx_get_int_long(const void * xp,long * ip)2893 ncx_get_int_long(const void *xp, long *ip)
2894 #line 1071
2895 {
2896 #line 1071
2897     int err=NC_NOERR;
2898 #line 1071
2899 #if SIZEOF_IX_INT == SIZEOF_LONG && IX_INT_MAX == LONG_MAX
2900 #line 1071
2901     get_ix_int(xp, (ix_int *)ip);
2902 #line 1071
2903 #else
2904 #line 1071
2905     ix_int xx = 0;
2906 #line 1071
2907     get_ix_int(xp, &xx);
2908 #line 1071
2909 
2910 #line 1071
2911 #if IX_INT_MAX > LONG_MAX
2912 #line 1071
2913     if (xx > LONG_MAX || xx < LONG_MIN) {
2914 #line 1071
2915 #ifdef ERANGE_FILL
2916 #line 1071
2917         *ip = NC_FILL_INT;
2918 #line 1071
2919         return NC_ERANGE;
2920 #line 1071
2921 #else
2922 #line 1071
2923         err = NC_ERANGE;
2924 #line 1071
2925 #endif
2926 #line 1071
2927     }
2928 #line 1071
2929 #endif
2930 #line 1071
2931 
2932 #line 1071
2933 
2934 #line 1071
2935     *ip = (long) xx;
2936 #line 1071
2937 #endif
2938 #line 1071
2939     return err;
2940 #line 1071
2941 }
2942 #line 1071
2943 
2944 static int
2945 #line 1072
ncx_get_int_longlong(const void * xp,longlong * ip)2946 ncx_get_int_longlong(const void *xp, longlong *ip)
2947 #line 1072
2948 {
2949 #line 1072
2950     int err=NC_NOERR;
2951 #line 1072
2952 #if SIZEOF_IX_INT == SIZEOF_LONGLONG && IX_INT_MAX == LONGLONG_MAX
2953 #line 1072
2954     get_ix_int(xp, (ix_int *)ip);
2955 #line 1072
2956 #else
2957 #line 1072
2958     ix_int xx = 0;
2959 #line 1072
2960     get_ix_int(xp, &xx);
2961 #line 1072
2962 
2963 #line 1072
2964 #if IX_INT_MAX > LONGLONG_MAX
2965 #line 1072
2966     if (xx > LONGLONG_MAX || xx < LONGLONG_MIN) {
2967 #line 1072
2968 #ifdef ERANGE_FILL
2969 #line 1072
2970         *ip = NC_FILL_INT64;
2971 #line 1072
2972         return NC_ERANGE;
2973 #line 1072
2974 #else
2975 #line 1072
2976         err = NC_ERANGE;
2977 #line 1072
2978 #endif
2979 #line 1072
2980     }
2981 #line 1072
2982 #endif
2983 #line 1072
2984 
2985 #line 1072
2986 
2987 #line 1072
2988     *ip = (longlong) xx;
2989 #line 1072
2990 #endif
2991 #line 1072
2992     return err;
2993 #line 1072
2994 }
2995 #line 1072
2996 
2997 static int
2998 #line 1073
ncx_get_int_ushort(const void * xp,ushort * ip)2999 ncx_get_int_ushort(const void *xp, ushort *ip)
3000 #line 1073
3001 {
3002 #line 1073
3003     int err=NC_NOERR;
3004 #line 1073
3005     ix_int xx = 0;
3006 #line 1073
3007     get_ix_int(xp, &xx);
3008 #line 1073
3009 
3010 #line 1073
3011 #if IX_INT_MAX > USHORT_MAX
3012 #line 1073
3013     if (xx > USHORT_MAX) {
3014 #line 1073
3015 #ifdef ERANGE_FILL
3016 #line 1073
3017         *ip = NC_FILL_USHORT;
3018 #line 1073
3019         return NC_ERANGE;
3020 #line 1073
3021 #else
3022 #line 1073
3023         err = NC_ERANGE;
3024 #line 1073
3025 #endif
3026 #line 1073
3027     }
3028 #line 1073
3029 #endif
3030 #line 1073
3031 
3032 #line 1073
3033     if (xx < 0) {
3034 #line 1073
3035 #ifdef ERANGE_FILL
3036 #line 1073
3037         *ip = NC_FILL_USHORT;
3038 #line 1073
3039         return NC_ERANGE;
3040 #line 1073
3041 #else
3042 #line 1073
3043         err = NC_ERANGE; /* because ip is unsigned */
3044 #line 1073
3045 #endif
3046 #line 1073
3047     }
3048 #line 1073
3049     *ip = (ushort) xx;
3050 #line 1073
3051     return err;
3052 #line 1073
3053 }
3054 #line 1073
3055 
3056 static int
3057 #line 1074
ncx_get_int_uchar(const void * xp,uchar * ip)3058 ncx_get_int_uchar(const void *xp, uchar *ip)
3059 #line 1074
3060 {
3061 #line 1074
3062     int err=NC_NOERR;
3063 #line 1074
3064     ix_int xx = 0;
3065 #line 1074
3066     get_ix_int(xp, &xx);
3067 #line 1074
3068 
3069 #line 1074
3070 #if IX_INT_MAX > UCHAR_MAX
3071 #line 1074
3072     if (xx > UCHAR_MAX) {
3073 #line 1074
3074 #ifdef ERANGE_FILL
3075 #line 1074
3076         *ip = NC_FILL_UBYTE;
3077 #line 1074
3078         return NC_ERANGE;
3079 #line 1074
3080 #else
3081 #line 1074
3082         err = NC_ERANGE;
3083 #line 1074
3084 #endif
3085 #line 1074
3086     }
3087 #line 1074
3088 #endif
3089 #line 1074
3090 
3091 #line 1074
3092     if (xx < 0) {
3093 #line 1074
3094 #ifdef ERANGE_FILL
3095 #line 1074
3096         *ip = NC_FILL_UBYTE;
3097 #line 1074
3098         return NC_ERANGE;
3099 #line 1074
3100 #else
3101 #line 1074
3102         err = NC_ERANGE; /* because ip is unsigned */
3103 #line 1074
3104 #endif
3105 #line 1074
3106     }
3107 #line 1074
3108     *ip = (uchar) xx;
3109 #line 1074
3110     return err;
3111 #line 1074
3112 }
3113 #line 1074
3114 
3115 static int
3116 #line 1075
ncx_get_int_uint(const void * xp,uint * ip)3117 ncx_get_int_uint(const void *xp, uint *ip)
3118 #line 1075
3119 {
3120 #line 1075
3121     int err=NC_NOERR;
3122 #line 1075
3123     ix_int xx = 0;
3124 #line 1075
3125     get_ix_int(xp, &xx);
3126 #line 1075
3127 
3128 #line 1075
3129 #if IX_INT_MAX > UINT_MAX
3130 #line 1075
3131     if (xx > UINT_MAX) {
3132 #line 1075
3133 #ifdef ERANGE_FILL
3134 #line 1075
3135         *ip = NC_FILL_UINT;
3136 #line 1075
3137         return NC_ERANGE;
3138 #line 1075
3139 #else
3140 #line 1075
3141         err = NC_ERANGE;
3142 #line 1075
3143 #endif
3144 #line 1075
3145     }
3146 #line 1075
3147 #endif
3148 #line 1075
3149 
3150 #line 1075
3151     if (xx < 0) {
3152 #line 1075
3153 #ifdef ERANGE_FILL
3154 #line 1075
3155         *ip = NC_FILL_UINT;
3156 #line 1075
3157         return NC_ERANGE;
3158 #line 1075
3159 #else
3160 #line 1075
3161         err = NC_ERANGE; /* because ip is unsigned */
3162 #line 1075
3163 #endif
3164 #line 1075
3165     }
3166 #line 1075
3167     *ip = (uint) xx;
3168 #line 1075
3169     return err;
3170 #line 1075
3171 }
3172 #line 1075
3173 
3174 static int
3175 #line 1076
ncx_get_int_ulonglong(const void * xp,ulonglong * ip)3176 ncx_get_int_ulonglong(const void *xp, ulonglong *ip)
3177 #line 1076
3178 {
3179 #line 1076
3180     int err=NC_NOERR;
3181 #line 1076
3182     ix_int xx = 0;
3183 #line 1076
3184     get_ix_int(xp, &xx);
3185 #line 1076
3186 
3187 #line 1076
3188 #if IX_INT_MAX > ULONGLONG_MAX
3189 #line 1076
3190     if (xx > ULONGLONG_MAX) {
3191 #line 1076
3192 #ifdef ERANGE_FILL
3193 #line 1076
3194         *ip = NC_FILL_UINT64;
3195 #line 1076
3196         return NC_ERANGE;
3197 #line 1076
3198 #else
3199 #line 1076
3200         err = NC_ERANGE;
3201 #line 1076
3202 #endif
3203 #line 1076
3204     }
3205 #line 1076
3206 #endif
3207 #line 1076
3208 
3209 #line 1076
3210     if (xx < 0) {
3211 #line 1076
3212 #ifdef ERANGE_FILL
3213 #line 1076
3214         *ip = NC_FILL_UINT64;
3215 #line 1076
3216         return NC_ERANGE;
3217 #line 1076
3218 #else
3219 #line 1076
3220         err = NC_ERANGE; /* because ip is unsigned */
3221 #line 1076
3222 #endif
3223 #line 1076
3224     }
3225 #line 1076
3226     *ip = (ulonglong) xx;
3227 #line 1076
3228     return err;
3229 #line 1076
3230 }
3231 #line 1076
3232 
3233 static int
3234 #line 1077
ncx_get_int_float(const void * xp,float * ip)3235 ncx_get_int_float(const void *xp, float *ip)
3236 #line 1077
3237 {
3238 #line 1077
3239 	ix_int xx = 0;
3240 #line 1077
3241 	get_ix_int(xp, &xx);
3242 #line 1077
3243 	*ip = (float)xx;
3244 #line 1077
3245 	return NC_NOERR;
3246 #line 1077
3247 }
3248 #line 1077
3249 
3250 static int
3251 #line 1078
ncx_get_int_double(const void * xp,double * ip)3252 ncx_get_int_double(const void *xp, double *ip)
3253 #line 1078
3254 {
3255 #line 1078
3256 	ix_int xx = 0;
3257 #line 1078
3258 	get_ix_int(xp, &xx);
3259 #line 1078
3260 	*ip = (double)xx;
3261 #line 1078
3262 	return NC_NOERR;
3263 #line 1078
3264 }
3265 #line 1078
3266 
3267 
3268 static int
ncx_put_int_schar(void * xp,const schar * ip,void * fillp)3269 ncx_put_int_schar(void *xp, const schar *ip, void *fillp)
3270 {
3271 	uchar *cp = (uchar *) xp;
3272 	if (*ip & 0x80)
3273 	{
3274 		*cp++ = 0xff;
3275 		*cp++ = 0xff;
3276 		*cp++ = 0xff;
3277 	}
3278 	else
3279 	{
3280 		*cp++ = 0x00;
3281 		*cp++ = 0x00;
3282 		*cp++ = 0x00;
3283 	}
3284 	*cp = (uchar)*ip;
3285 	return NC_NOERR;
3286 }
3287 
3288 static int
ncx_put_int_uchar(void * xp,const uchar * ip,void * fillp)3289 ncx_put_int_uchar(void *xp, const uchar *ip, void *fillp)
3290 {
3291 	uchar *cp = (uchar *) xp;
3292 	*cp++ = 0x00;
3293 	*cp++ = 0x00;
3294 	*cp++ = 0x00;
3295 	*cp   = *ip;
3296 	return NC_NOERR;
3297 }
3298 
3299 #if X_SIZEOF_INT != SIZEOF_INT
3300 static int
3301 #line 1112
ncx_put_int_int(void * xp,const int * ip,void * fillp)3302 ncx_put_int_int(void *xp, const int *ip, void *fillp)
3303 #line 1112
3304 {
3305 #line 1112
3306     int err=NC_NOERR;
3307 #line 1112
3308 #if SIZEOF_IX_INT == SIZEOF_INT && IX_INT_MAX == INT_MAX
3309 #line 1112
3310     put_ix_int(xp, (const ix_int *)ip);
3311 #line 1112
3312 #else
3313 #line 1112
3314     ix_int xx = NC_FILL_INT;
3315 #line 1112
3316 
3317 #line 1112
3318 #if IX_INT_MAX < INT_MAX
3319 #line 1112
3320     if (*ip > IX_INT_MAX || *ip < X_INT_MIN) {
3321 #line 1112
3322 
3323 #line 1112
3324 #ifdef ERANGE_FILL
3325 #line 1112
3326             if (fillp != NULL) memcpy(&xx, fillp, 4);
3327 #line 1112
3328 #endif
3329 #line 1112
3330         err = NC_ERANGE;
3331 #line 1112
3332     }
3333 #line 1112
3334 #ifdef ERANGE_FILL
3335 #line 1112
3336     else
3337 #line 1112
3338 #endif
3339 #line 1112
3340 #endif
3341 #line 1112
3342         xx = (ix_int)*ip;
3343 #line 1112
3344 
3345 #line 1112
3346     put_ix_int(xp, &xx);
3347 #line 1112
3348 #endif
3349 #line 1112
3350     return err;
3351 #line 1112
3352 }
3353 #line 1112
3354 
3355 #endif
3356 static int
3357 #line 1114
ncx_put_int_short(void * xp,const short * ip,void * fillp)3358 ncx_put_int_short(void *xp, const short *ip, void *fillp)
3359 #line 1114
3360 {
3361 #line 1114
3362     int err=NC_NOERR;
3363 #line 1114
3364 #if SIZEOF_IX_INT == SIZEOF_SHORT && IX_INT_MAX == SHORT_MAX
3365 #line 1114
3366     put_ix_int(xp, (const ix_int *)ip);
3367 #line 1114
3368 #else
3369 #line 1114
3370     ix_int xx = NC_FILL_INT;
3371 #line 1114
3372 
3373 #line 1114
3374 #if IX_INT_MAX < SHORT_MAX
3375 #line 1114
3376     if (*ip > IX_INT_MAX || *ip < X_INT_MIN) {
3377 #line 1114
3378 
3379 #line 1114
3380 #ifdef ERANGE_FILL
3381 #line 1114
3382             if (fillp != NULL) memcpy(&xx, fillp, 4);
3383 #line 1114
3384 #endif
3385 #line 1114
3386         err = NC_ERANGE;
3387 #line 1114
3388     }
3389 #line 1114
3390 #ifdef ERANGE_FILL
3391 #line 1114
3392     else
3393 #line 1114
3394 #endif
3395 #line 1114
3396 #endif
3397 #line 1114
3398         xx = (ix_int)*ip;
3399 #line 1114
3400 
3401 #line 1114
3402     put_ix_int(xp, &xx);
3403 #line 1114
3404 #endif
3405 #line 1114
3406     return err;
3407 #line 1114
3408 }
3409 #line 1114
3410 
3411 static int
3412 #line 1115
ncx_put_int_long(void * xp,const long * ip,void * fillp)3413 ncx_put_int_long(void *xp, const long *ip, void *fillp)
3414 #line 1115
3415 {
3416 #line 1115
3417     int err=NC_NOERR;
3418 #line 1115
3419 #if SIZEOF_IX_INT == SIZEOF_LONG && IX_INT_MAX == LONG_MAX
3420 #line 1115
3421     put_ix_int(xp, (const ix_int *)ip);
3422 #line 1115
3423 #else
3424 #line 1115
3425     ix_int xx = NC_FILL_INT;
3426 #line 1115
3427 
3428 #line 1115
3429 #if IX_INT_MAX < LONG_MAX
3430 #line 1115
3431     if (*ip > IX_INT_MAX || *ip < X_INT_MIN) {
3432 #line 1115
3433 
3434 #line 1115
3435 #ifdef ERANGE_FILL
3436 #line 1115
3437             if (fillp != NULL) memcpy(&xx, fillp, 4);
3438 #line 1115
3439 #endif
3440 #line 1115
3441         err = NC_ERANGE;
3442 #line 1115
3443     }
3444 #line 1115
3445 #ifdef ERANGE_FILL
3446 #line 1115
3447     else
3448 #line 1115
3449 #endif
3450 #line 1115
3451 #endif
3452 #line 1115
3453         xx = (ix_int)*ip;
3454 #line 1115
3455 
3456 #line 1115
3457     put_ix_int(xp, &xx);
3458 #line 1115
3459 #endif
3460 #line 1115
3461     return err;
3462 #line 1115
3463 }
3464 #line 1115
3465 
3466 static int
3467 #line 1116
ncx_put_int_longlong(void * xp,const longlong * ip,void * fillp)3468 ncx_put_int_longlong(void *xp, const longlong *ip, void *fillp)
3469 #line 1116
3470 {
3471 #line 1116
3472     int err=NC_NOERR;
3473 #line 1116
3474 #if SIZEOF_IX_INT == SIZEOF_LONGLONG && IX_INT_MAX == LONGLONG_MAX
3475 #line 1116
3476     put_ix_int(xp, (const ix_int *)ip);
3477 #line 1116
3478 #else
3479 #line 1116
3480     ix_int xx = NC_FILL_INT;
3481 #line 1116
3482 
3483 #line 1116
3484 #if IX_INT_MAX < LONGLONG_MAX
3485 #line 1116
3486     if (*ip > IX_INT_MAX || *ip < X_INT_MIN) {
3487 #line 1116
3488 
3489 #line 1116
3490 #ifdef ERANGE_FILL
3491 #line 1116
3492             if (fillp != NULL) memcpy(&xx, fillp, 4);
3493 #line 1116
3494 #endif
3495 #line 1116
3496         err = NC_ERANGE;
3497 #line 1116
3498     }
3499 #line 1116
3500 #ifdef ERANGE_FILL
3501 #line 1116
3502     else
3503 #line 1116
3504 #endif
3505 #line 1116
3506 #endif
3507 #line 1116
3508         xx = (ix_int)*ip;
3509 #line 1116
3510 
3511 #line 1116
3512     put_ix_int(xp, &xx);
3513 #line 1116
3514 #endif
3515 #line 1116
3516     return err;
3517 #line 1116
3518 }
3519 #line 1116
3520 
3521 static int
3522 #line 1117
ncx_put_int_ushort(void * xp,const ushort * ip,void * fillp)3523 ncx_put_int_ushort(void *xp, const ushort *ip, void *fillp)
3524 #line 1117
3525 {
3526 #line 1117
3527     int err=NC_NOERR;
3528 #line 1117
3529     ix_int xx = NC_FILL_INT;
3530 #line 1117
3531 
3532 #line 1117
3533 #if IX_INT_MAX < USHORT_MAX
3534 #line 1117
3535     if (*ip > IX_INT_MAX) {
3536 #line 1117
3537 
3538 #line 1117
3539 #ifdef ERANGE_FILL
3540 #line 1117
3541             if (fillp != NULL) memcpy(&xx, fillp, 4);
3542 #line 1117
3543 #endif
3544 #line 1117
3545         err = NC_ERANGE;
3546 #line 1117
3547     }
3548 #line 1117
3549 #ifdef ERANGE_FILL
3550 #line 1117
3551     else
3552 #line 1117
3553 #endif
3554 #line 1117
3555 #endif
3556 #line 1117
3557         xx = (ix_int)*ip;
3558 #line 1117
3559 
3560 #line 1117
3561     put_ix_int(xp, &xx);
3562 #line 1117
3563     return err;
3564 #line 1117
3565 }
3566 #line 1117
3567 
3568 static int
3569 #line 1118
ncx_put_int_uint(void * xp,const uint * ip,void * fillp)3570 ncx_put_int_uint(void *xp, const uint *ip, void *fillp)
3571 #line 1118
3572 {
3573 #line 1118
3574     int err=NC_NOERR;
3575 #line 1118
3576     ix_int xx = NC_FILL_INT;
3577 #line 1118
3578 
3579 #line 1118
3580 #if IX_INT_MAX < UINT_MAX
3581 #line 1118
3582     if (*ip > IX_INT_MAX) {
3583 #line 1118
3584 
3585 #line 1118
3586 #ifdef ERANGE_FILL
3587 #line 1118
3588             if (fillp != NULL) memcpy(&xx, fillp, 4);
3589 #line 1118
3590 #endif
3591 #line 1118
3592         err = NC_ERANGE;
3593 #line 1118
3594     }
3595 #line 1118
3596 #ifdef ERANGE_FILL
3597 #line 1118
3598     else
3599 #line 1118
3600 #endif
3601 #line 1118
3602 #endif
3603 #line 1118
3604         xx = (ix_int)*ip;
3605 #line 1118
3606 
3607 #line 1118
3608     put_ix_int(xp, &xx);
3609 #line 1118
3610     return err;
3611 #line 1118
3612 }
3613 #line 1118
3614 
3615 static int
3616 #line 1119
ncx_put_int_ulonglong(void * xp,const ulonglong * ip,void * fillp)3617 ncx_put_int_ulonglong(void *xp, const ulonglong *ip, void *fillp)
3618 #line 1119
3619 {
3620 #line 1119
3621     int err=NC_NOERR;
3622 #line 1119
3623     ix_int xx = NC_FILL_INT;
3624 #line 1119
3625 
3626 #line 1119
3627 #if IX_INT_MAX < ULONGLONG_MAX
3628 #line 1119
3629     if (*ip > IX_INT_MAX) {
3630 #line 1119
3631 
3632 #line 1119
3633 #ifdef ERANGE_FILL
3634 #line 1119
3635             if (fillp != NULL) memcpy(&xx, fillp, 4);
3636 #line 1119
3637 #endif
3638 #line 1119
3639         err = NC_ERANGE;
3640 #line 1119
3641     }
3642 #line 1119
3643 #ifdef ERANGE_FILL
3644 #line 1119
3645     else
3646 #line 1119
3647 #endif
3648 #line 1119
3649 #endif
3650 #line 1119
3651         xx = (ix_int)*ip;
3652 #line 1119
3653 
3654 #line 1119
3655     put_ix_int(xp, &xx);
3656 #line 1119
3657     return err;
3658 #line 1119
3659 }
3660 #line 1119
3661 
3662 static int
3663 #line 1120
ncx_put_int_float(void * xp,const float * ip,void * fillp)3664 ncx_put_int_float(void *xp, const float *ip, void *fillp)
3665 #line 1120
3666 {
3667 #line 1120
3668     int err=NC_NOERR;
3669 #line 1120
3670     ix_int xx = NC_FILL_INT;
3671 #line 1120
3672 
3673 #line 1120
3674     if (*ip > (double)X_INT_MAX || *ip < (double)X_INT_MIN) {
3675 #line 1120
3676 
3677 #line 1120
3678 #ifdef ERANGE_FILL
3679 #line 1120
3680             if (fillp != NULL) memcpy(&xx, fillp, 4);
3681 #line 1120
3682 #endif
3683 #line 1120
3684         err = NC_ERANGE;
3685 #line 1120
3686     }
3687 #line 1120
3688 #ifdef ERANGE_FILL
3689 #line 1120
3690     else
3691 #line 1120
3692 #endif
3693 #line 1120
3694         xx = (ix_int)*ip;
3695 #line 1120
3696 
3697 #line 1120
3698     put_ix_int(xp, &xx);
3699 #line 1120
3700     return err;
3701 #line 1120
3702 }
3703 #line 1120
3704 
3705 static int
3706 #line 1121
ncx_put_int_double(void * xp,const double * ip,void * fillp)3707 ncx_put_int_double(void *xp, const double *ip, void *fillp)
3708 #line 1121
3709 {
3710 #line 1121
3711     int err=NC_NOERR;
3712 #line 1121
3713     ix_int xx = NC_FILL_INT;
3714 #line 1121
3715 
3716 #line 1121
3717     if (*ip > X_INT_MAX || *ip < X_INT_MIN) {
3718 #line 1121
3719 
3720 #line 1121
3721 #ifdef ERANGE_FILL
3722 #line 1121
3723             if (fillp != NULL) memcpy(&xx, fillp, 4);
3724 #line 1121
3725 #endif
3726 #line 1121
3727         err = NC_ERANGE;
3728 #line 1121
3729     }
3730 #line 1121
3731 #ifdef ERANGE_FILL
3732 #line 1121
3733     else
3734 #line 1121
3735 #endif
3736 #line 1121
3737         xx = (ix_int)*ip;
3738 #line 1121
3739 
3740 #line 1121
3741     put_ix_int(xp, &xx);
3742 #line 1121
3743     return err;
3744 #line 1121
3745 }
3746 #line 1121
3747 
3748 
3749 
3750 /* external NC_UINT ---------------------------------------------------------*/
3751 
3752 #if USHORT_MAX == X_UINT_MAX
3753 typedef ushort ix_uint;
3754 #define SIZEOF_IX_UINT SIZEOF_USHORT
3755 #define IX_UINT_MAX USHORT_MAX
3756 #elif UINT_MAX  >= X_UINT_MAX
3757 typedef uint ix_uint;
3758 #define SIZEOF_IX_UINT SIZEOF_UINT
3759 #define IX_UINT_MAX UINT_MAX
3760 #elif ULONG_MAX  >= X_UINT_MAX
3761 typedef ulong ix_uint;
3762 #define SIZEOF_IX_UINT SIZEOF_ULONG
3763 #define IX_UINT_MAX ULONG_MAX
3764 #else
3765 #error "ix_uint implementation"
3766 #endif
3767 
3768 
3769 static void
get_ix_uint(const void * xp,ix_uint * ip)3770 get_ix_uint(const void *xp, ix_uint *ip)
3771 {
3772 	const uchar *cp = (const uchar *) xp;
3773 
3774 	*ip = (ix_uint)(*cp++ << 24);
3775 	*ip = (ix_uint)(*ip | (ix_uint)(*cp++ << 16));
3776 	*ip = (ix_uint)(*ip | (ix_uint)(*cp++ << 8));
3777 	*ip = (ix_uint)(*ip | *cp);
3778 }
3779 
3780 static void
put_ix_uint(void * xp,const ix_uint * ip)3781 put_ix_uint(void *xp, const ix_uint *ip)
3782 {
3783 	uchar *cp = (uchar *) xp;
3784 
3785 	*cp++ = (uchar)((*ip) >> 24);
3786 	*cp++ = (uchar)(((*ip) & 0x00ff0000) >> 16);
3787 	*cp++ = (uchar)(((*ip) & 0x0000ff00) >>  8);
3788 	*cp   = (uchar)( (*ip) & 0x000000ff);
3789 }
3790 
3791 #if X_SIZEOF_UINT != SIZEOF_UINT
3792 static int
3793 #line 1166
ncx_get_uint_uint(const void * xp,uint * ip)3794 ncx_get_uint_uint(const void *xp, uint *ip)
3795 #line 1166
3796 {
3797 #line 1166
3798     int err=NC_NOERR;
3799 #line 1166
3800 #if SIZEOF_IX_UINT == SIZEOF_UINT && IX_UINT_MAX == UINT_MAX
3801 #line 1166
3802     get_ix_uint(xp, (ix_uint *)ip);
3803 #line 1166
3804 #else
3805 #line 1166
3806     ix_uint xx = 0;
3807 #line 1166
3808     get_ix_uint(xp, &xx);
3809 #line 1166
3810 
3811 #line 1166
3812 #if IX_UINT_MAX > UINT_MAX
3813 #line 1166
3814     if (xx > UINT_MAX) {
3815 #line 1166
3816 #ifdef ERANGE_FILL
3817 #line 1166
3818         *ip = NC_FILL_UINT;
3819 #line 1166
3820         return NC_ERANGE;
3821 #line 1166
3822 #else
3823 #line 1166
3824         err = NC_ERANGE;
3825 #line 1166
3826 #endif
3827 #line 1166
3828     }
3829 #line 1166
3830 #endif
3831 #line 1166
3832 
3833 #line 1166
3834 
3835 #line 1166
3836     *ip = (uint) xx;
3837 #line 1166
3838 #endif
3839 #line 1166
3840     return err;
3841 #line 1166
3842 }
3843 #line 1166
3844 
3845 #endif
3846 
3847 static int
3848 #line 1169
ncx_get_uint_schar(const void * xp,schar * ip)3849 ncx_get_uint_schar(const void *xp, schar *ip)
3850 #line 1169
3851 {
3852 #line 1169
3853     int err=NC_NOERR;
3854 #line 1169
3855     ix_uint xx = 0;
3856 #line 1169
3857     get_ix_uint(xp, &xx);
3858 #line 1169
3859 
3860 #line 1169
3861 #if IX_UINT_MAX > SCHAR_MAX
3862 #line 1169
3863     if (xx > SCHAR_MAX) {
3864 #line 1169
3865 #ifdef ERANGE_FILL
3866 #line 1169
3867         *ip = NC_FILL_BYTE;
3868 #line 1169
3869         return NC_ERANGE;
3870 #line 1169
3871 #else
3872 #line 1169
3873         err = NC_ERANGE;
3874 #line 1169
3875 #endif
3876 #line 1169
3877     }
3878 #line 1169
3879 #endif
3880 #line 1169
3881 
3882 #line 1169
3883 
3884 #line 1169
3885     *ip = (schar) xx;
3886 #line 1169
3887     return err;
3888 #line 1169
3889 }
3890 #line 1169
3891 
3892 static int
3893 #line 1170
ncx_get_uint_short(const void * xp,short * ip)3894 ncx_get_uint_short(const void *xp, short *ip)
3895 #line 1170
3896 {
3897 #line 1170
3898     int err=NC_NOERR;
3899 #line 1170
3900     ix_uint xx = 0;
3901 #line 1170
3902     get_ix_uint(xp, &xx);
3903 #line 1170
3904 
3905 #line 1170
3906 #if IX_UINT_MAX > SHORT_MAX
3907 #line 1170
3908     if (xx > SHORT_MAX) {
3909 #line 1170
3910 #ifdef ERANGE_FILL
3911 #line 1170
3912         *ip = NC_FILL_SHORT;
3913 #line 1170
3914         return NC_ERANGE;
3915 #line 1170
3916 #else
3917 #line 1170
3918         err = NC_ERANGE;
3919 #line 1170
3920 #endif
3921 #line 1170
3922     }
3923 #line 1170
3924 #endif
3925 #line 1170
3926 
3927 #line 1170
3928 
3929 #line 1170
3930     *ip = (short) xx;
3931 #line 1170
3932     return err;
3933 #line 1170
3934 }
3935 #line 1170
3936 
3937 static int
3938 #line 1171
ncx_get_uint_int(const void * xp,int * ip)3939 ncx_get_uint_int(const void *xp, int *ip)
3940 #line 1171
3941 {
3942 #line 1171
3943     int err=NC_NOERR;
3944 #line 1171
3945     ix_uint xx = 0;
3946 #line 1171
3947     get_ix_uint(xp, &xx);
3948 #line 1171
3949 
3950 #line 1171
3951 #if IX_UINT_MAX > INT_MAX
3952 #line 1171
3953     if (xx > INT_MAX) {
3954 #line 1171
3955 #ifdef ERANGE_FILL
3956 #line 1171
3957         *ip = NC_FILL_INT;
3958 #line 1171
3959         return NC_ERANGE;
3960 #line 1171
3961 #else
3962 #line 1171
3963         err = NC_ERANGE;
3964 #line 1171
3965 #endif
3966 #line 1171
3967     }
3968 #line 1171
3969 #endif
3970 #line 1171
3971 
3972 #line 1171
3973 
3974 #line 1171
3975     *ip = (int) xx;
3976 #line 1171
3977     return err;
3978 #line 1171
3979 }
3980 #line 1171
3981 
3982 static int
3983 #line 1172
ncx_get_uint_long(const void * xp,long * ip)3984 ncx_get_uint_long(const void *xp, long *ip)
3985 #line 1172
3986 {
3987 #line 1172
3988     int err=NC_NOERR;
3989 #line 1172
3990     ix_uint xx = 0;
3991 #line 1172
3992     get_ix_uint(xp, &xx);
3993 #line 1172
3994 
3995 #line 1172
3996 #if IX_UINT_MAX > LONG_MAX
3997 #line 1172
3998     if (xx > LONG_MAX) {
3999 #line 1172
4000 #ifdef ERANGE_FILL
4001 #line 1172
4002         *ip = NC_FILL_INT;
4003 #line 1172
4004         return NC_ERANGE;
4005 #line 1172
4006 #else
4007 #line 1172
4008         err = NC_ERANGE;
4009 #line 1172
4010 #endif
4011 #line 1172
4012     }
4013 #line 1172
4014 #endif
4015 #line 1172
4016 
4017 #line 1172
4018 
4019 #line 1172
4020     *ip = (long) xx;
4021 #line 1172
4022     return err;
4023 #line 1172
4024 }
4025 #line 1172
4026 
4027 static int
4028 #line 1173
ncx_get_uint_longlong(const void * xp,longlong * ip)4029 ncx_get_uint_longlong(const void *xp, longlong *ip)
4030 #line 1173
4031 {
4032 #line 1173
4033     int err=NC_NOERR;
4034 #line 1173
4035     ix_uint xx = 0;
4036 #line 1173
4037     get_ix_uint(xp, &xx);
4038 #line 1173
4039 
4040 #line 1173
4041 #if IX_UINT_MAX > LONGLONG_MAX
4042 #line 1173
4043     if (xx > LONGLONG_MAX) {
4044 #line 1173
4045 #ifdef ERANGE_FILL
4046 #line 1173
4047         *ip = NC_FILL_INT64;
4048 #line 1173
4049         return NC_ERANGE;
4050 #line 1173
4051 #else
4052 #line 1173
4053         err = NC_ERANGE;
4054 #line 1173
4055 #endif
4056 #line 1173
4057     }
4058 #line 1173
4059 #endif
4060 #line 1173
4061 
4062 #line 1173
4063 
4064 #line 1173
4065     *ip = (longlong) xx;
4066 #line 1173
4067     return err;
4068 #line 1173
4069 }
4070 #line 1173
4071 
4072 static int
4073 #line 1174
ncx_get_uint_ushort(const void * xp,ushort * ip)4074 ncx_get_uint_ushort(const void *xp, ushort *ip)
4075 #line 1174
4076 {
4077 #line 1174
4078     int err=NC_NOERR;
4079 #line 1174
4080 #if SIZEOF_IX_UINT == SIZEOF_USHORT && IX_UINT_MAX == USHORT_MAX
4081 #line 1174
4082     get_ix_uint(xp, (ix_uint *)ip);
4083 #line 1174
4084 #else
4085 #line 1174
4086     ix_uint xx = 0;
4087 #line 1174
4088     get_ix_uint(xp, &xx);
4089 #line 1174
4090 
4091 #line 1174
4092 #if IX_UINT_MAX > USHORT_MAX
4093 #line 1174
4094     if (xx > USHORT_MAX) {
4095 #line 1174
4096 #ifdef ERANGE_FILL
4097 #line 1174
4098         *ip = NC_FILL_USHORT;
4099 #line 1174
4100         return NC_ERANGE;
4101 #line 1174
4102 #else
4103 #line 1174
4104         err = NC_ERANGE;
4105 #line 1174
4106 #endif
4107 #line 1174
4108     }
4109 #line 1174
4110 #endif
4111 #line 1174
4112 
4113 #line 1174
4114 
4115 #line 1174
4116     *ip = (ushort) xx;
4117 #line 1174
4118 #endif
4119 #line 1174
4120     return err;
4121 #line 1174
4122 }
4123 #line 1174
4124 
4125 static int
4126 #line 1175
ncx_get_uint_uchar(const void * xp,uchar * ip)4127 ncx_get_uint_uchar(const void *xp, uchar *ip)
4128 #line 1175
4129 {
4130 #line 1175
4131     int err=NC_NOERR;
4132 #line 1175
4133 #if SIZEOF_IX_UINT == SIZEOF_UCHAR && IX_UINT_MAX == UCHAR_MAX
4134 #line 1175
4135     get_ix_uint(xp, (ix_uint *)ip);
4136 #line 1175
4137 #else
4138 #line 1175
4139     ix_uint xx = 0;
4140 #line 1175
4141     get_ix_uint(xp, &xx);
4142 #line 1175
4143 
4144 #line 1175
4145 #if IX_UINT_MAX > UCHAR_MAX
4146 #line 1175
4147     if (xx > UCHAR_MAX) {
4148 #line 1175
4149 #ifdef ERANGE_FILL
4150 #line 1175
4151         *ip = NC_FILL_UBYTE;
4152 #line 1175
4153         return NC_ERANGE;
4154 #line 1175
4155 #else
4156 #line 1175
4157         err = NC_ERANGE;
4158 #line 1175
4159 #endif
4160 #line 1175
4161     }
4162 #line 1175
4163 #endif
4164 #line 1175
4165 
4166 #line 1175
4167 
4168 #line 1175
4169     *ip = (uchar) xx;
4170 #line 1175
4171 #endif
4172 #line 1175
4173     return err;
4174 #line 1175
4175 }
4176 #line 1175
4177 
4178 static int
4179 #line 1176
ncx_get_uint_ulonglong(const void * xp,ulonglong * ip)4180 ncx_get_uint_ulonglong(const void *xp, ulonglong *ip)
4181 #line 1176
4182 {
4183 #line 1176
4184     int err=NC_NOERR;
4185 #line 1176
4186 #if SIZEOF_IX_UINT == SIZEOF_ULONGLONG && IX_UINT_MAX == ULONGLONG_MAX
4187 #line 1176
4188     get_ix_uint(xp, (ix_uint *)ip);
4189 #line 1176
4190 #else
4191 #line 1176
4192     ix_uint xx = 0;
4193 #line 1176
4194     get_ix_uint(xp, &xx);
4195 #line 1176
4196 
4197 #line 1176
4198 #if IX_UINT_MAX > ULONGLONG_MAX
4199 #line 1176
4200     if (xx > ULONGLONG_MAX) {
4201 #line 1176
4202 #ifdef ERANGE_FILL
4203 #line 1176
4204         *ip = NC_FILL_UINT64;
4205 #line 1176
4206         return NC_ERANGE;
4207 #line 1176
4208 #else
4209 #line 1176
4210         err = NC_ERANGE;
4211 #line 1176
4212 #endif
4213 #line 1176
4214     }
4215 #line 1176
4216 #endif
4217 #line 1176
4218 
4219 #line 1176
4220 
4221 #line 1176
4222     *ip = (ulonglong) xx;
4223 #line 1176
4224 #endif
4225 #line 1176
4226     return err;
4227 #line 1176
4228 }
4229 #line 1176
4230 
4231 static int
4232 #line 1177
ncx_get_uint_float(const void * xp,float * ip)4233 ncx_get_uint_float(const void *xp, float *ip)
4234 #line 1177
4235 {
4236 #line 1177
4237 	ix_uint xx = 0;
4238 #line 1177
4239 	get_ix_uint(xp, &xx);
4240 #line 1177
4241 	*ip = (float)xx;
4242 #line 1177
4243 	return NC_NOERR;
4244 #line 1177
4245 }
4246 #line 1177
4247 
4248 static int
4249 #line 1178
ncx_get_uint_double(const void * xp,double * ip)4250 ncx_get_uint_double(const void *xp, double *ip)
4251 #line 1178
4252 {
4253 #line 1178
4254 	ix_uint xx = 0;
4255 #line 1178
4256 	get_ix_uint(xp, &xx);
4257 #line 1178
4258 	*ip = (double)xx;
4259 #line 1178
4260 	return NC_NOERR;
4261 #line 1178
4262 }
4263 #line 1178
4264 
4265 
4266 static int
ncx_put_uint_schar(void * xp,const schar * ip,void * fillp)4267 ncx_put_uint_schar(void *xp, const schar *ip, void *fillp)
4268 {
4269     uchar *cp;
4270     if (*ip < 0) {
4271 #ifdef ERANGE_FILL
4272         if (fillp != NULL) memcpy(xp, fillp, 4);
4273 #ifndef WORDS_BIGENDIAN
4274         swapn4b(xp, xp, 1);
4275 #endif
4276 #endif
4277         return NC_ERANGE;
4278     }
4279 
4280     cp = (uchar *) xp;
4281     *cp++ = 0x00;
4282     *cp++ = 0x00;
4283     *cp++ = 0x00;
4284     *cp = (uchar)*ip;
4285 
4286     return NC_NOERR;
4287 }
4288 
4289 static int
ncx_put_uint_uchar(void * xp,const uchar * ip,void * fillp)4290 ncx_put_uint_uchar(void *xp, const uchar *ip, void *fillp)
4291 {
4292 	uchar *cp = (uchar *) xp;
4293 	*cp++ = 0x00;
4294 	*cp++ = 0x00;
4295 	*cp++ = 0x00;
4296 	*cp   = *ip;
4297 	return NC_NOERR;
4298 }
4299 
4300 #if X_SIZEOF_UINT != SIZEOF_UINT
4301 static int
4302 #line 1215
ncx_put_uint_uint(void * xp,const uint * ip,void * fillp)4303 ncx_put_uint_uint(void *xp, const uint *ip, void *fillp)
4304 #line 1215
4305 {
4306 #line 1215
4307     int err=NC_NOERR;
4308 #line 1215
4309 #if SIZEOF_IX_UINT == SIZEOF_UINT && IX_UINT_MAX == UINT_MAX
4310 #line 1215
4311     put_ix_uint(xp, (const ix_uint *)ip);
4312 #line 1215
4313 #else
4314 #line 1215
4315     ix_uint xx = NC_FILL_UINT;
4316 #line 1215
4317 
4318 #line 1215
4319 #if IX_UINT_MAX < UINT_MAX
4320 #line 1215
4321     if (*ip > IX_UINT_MAX) {
4322 #line 1215
4323 
4324 #line 1215
4325 #ifdef ERANGE_FILL
4326 #line 1215
4327             if (fillp != NULL) memcpy(&xx, fillp, 4);
4328 #line 1215
4329 #endif
4330 #line 1215
4331         err = NC_ERANGE;
4332 #line 1215
4333     }
4334 #line 1215
4335 #ifdef ERANGE_FILL
4336 #line 1215
4337     else
4338 #line 1215
4339 #endif
4340 #line 1215
4341 #endif
4342 #line 1215
4343         xx = (ix_uint)*ip;
4344 #line 1215
4345 
4346 #line 1215
4347     put_ix_uint(xp, &xx);
4348 #line 1215
4349 #endif
4350 #line 1215
4351     return err;
4352 #line 1215
4353 }
4354 #line 1215
4355 
4356 #endif
4357 
4358 static int
4359 #line 1218
ncx_put_uint_short(void * xp,const short * ip,void * fillp)4360 ncx_put_uint_short(void *xp, const short *ip, void *fillp)
4361 #line 1218
4362 {
4363 #line 1218
4364     int err=NC_NOERR;
4365 #line 1218
4366     ix_uint xx = NC_FILL_UINT;
4367 #line 1218
4368 
4369 #line 1218
4370 #if IX_UINT_MAX < SHORT_MAX
4371 #line 1218
4372     if (*ip > IX_UINT_MAX) {
4373 #line 1218
4374 
4375 #line 1218
4376 #ifdef ERANGE_FILL
4377 #line 1218
4378             if (fillp != NULL) memcpy(&xx, fillp, 4);
4379 #line 1218
4380 #endif
4381 #line 1218
4382         err = NC_ERANGE;
4383 #line 1218
4384     }
4385 #line 1218
4386 #ifdef ERANGE_FILL
4387 #line 1218
4388     else
4389 #line 1218
4390 #endif
4391 #line 1218
4392 #endif
4393 #line 1218
4394     if (*ip < 0) {
4395 #line 1218
4396 
4397 #line 1218
4398 #ifdef ERANGE_FILL
4399 #line 1218
4400             if (fillp != NULL) memcpy(&xx, fillp, 4);
4401 #line 1218
4402 #endif
4403 #line 1218
4404         err = NC_ERANGE; /* because xp is unsigned */
4405 #line 1218
4406     }
4407 #line 1218
4408 #ifdef ERANGE_FILL
4409 #line 1218
4410     else
4411 #line 1218
4412 #endif
4413 #line 1218
4414         xx = (ix_uint)*ip;
4415 #line 1218
4416 
4417 #line 1218
4418     put_ix_uint(xp, &xx);
4419 #line 1218
4420     return err;
4421 #line 1218
4422 }
4423 #line 1218
4424 
4425 static int
4426 #line 1219
ncx_put_uint_int(void * xp,const int * ip,void * fillp)4427 ncx_put_uint_int(void *xp, const int *ip, void *fillp)
4428 #line 1219
4429 {
4430 #line 1219
4431     int err=NC_NOERR;
4432 #line 1219
4433     ix_uint xx = NC_FILL_UINT;
4434 #line 1219
4435 
4436 #line 1219
4437 #if IX_UINT_MAX < INT_MAX
4438 #line 1219
4439     if (*ip > IX_UINT_MAX) {
4440 #line 1219
4441 
4442 #line 1219
4443 #ifdef ERANGE_FILL
4444 #line 1219
4445             if (fillp != NULL) memcpy(&xx, fillp, 4);
4446 #line 1219
4447 #endif
4448 #line 1219
4449         err = NC_ERANGE;
4450 #line 1219
4451     }
4452 #line 1219
4453 #ifdef ERANGE_FILL
4454 #line 1219
4455     else
4456 #line 1219
4457 #endif
4458 #line 1219
4459 #endif
4460 #line 1219
4461     if (*ip < 0) {
4462 #line 1219
4463 
4464 #line 1219
4465 #ifdef ERANGE_FILL
4466 #line 1219
4467             if (fillp != NULL) memcpy(&xx, fillp, 4);
4468 #line 1219
4469 #endif
4470 #line 1219
4471         err = NC_ERANGE; /* because xp is unsigned */
4472 #line 1219
4473     }
4474 #line 1219
4475 #ifdef ERANGE_FILL
4476 #line 1219
4477     else
4478 #line 1219
4479 #endif
4480 #line 1219
4481         xx = (ix_uint)*ip;
4482 #line 1219
4483 
4484 #line 1219
4485     put_ix_uint(xp, &xx);
4486 #line 1219
4487     return err;
4488 #line 1219
4489 }
4490 #line 1219
4491 
4492 static int
4493 #line 1220
ncx_put_uint_long(void * xp,const long * ip,void * fillp)4494 ncx_put_uint_long(void *xp, const long *ip, void *fillp)
4495 #line 1220
4496 {
4497 #line 1220
4498     int err=NC_NOERR;
4499 #line 1220
4500     ix_uint xx = NC_FILL_UINT;
4501 #line 1220
4502 
4503 #line 1220
4504 #if IX_UINT_MAX < LONG_MAX
4505 #line 1220
4506     if (*ip > IX_UINT_MAX) {
4507 #line 1220
4508 
4509 #line 1220
4510 #ifdef ERANGE_FILL
4511 #line 1220
4512             if (fillp != NULL) memcpy(&xx, fillp, 4);
4513 #line 1220
4514 #endif
4515 #line 1220
4516         err = NC_ERANGE;
4517 #line 1220
4518     }
4519 #line 1220
4520 #ifdef ERANGE_FILL
4521 #line 1220
4522     else
4523 #line 1220
4524 #endif
4525 #line 1220
4526 #endif
4527 #line 1220
4528     if (*ip < 0) {
4529 #line 1220
4530 
4531 #line 1220
4532 #ifdef ERANGE_FILL
4533 #line 1220
4534             if (fillp != NULL) memcpy(&xx, fillp, 4);
4535 #line 1220
4536 #endif
4537 #line 1220
4538         err = NC_ERANGE; /* because xp is unsigned */
4539 #line 1220
4540     }
4541 #line 1220
4542 #ifdef ERANGE_FILL
4543 #line 1220
4544     else
4545 #line 1220
4546 #endif
4547 #line 1220
4548         xx = (ix_uint)*ip;
4549 #line 1220
4550 
4551 #line 1220
4552     put_ix_uint(xp, &xx);
4553 #line 1220
4554     return err;
4555 #line 1220
4556 }
4557 #line 1220
4558 
4559 static int
4560 #line 1221
ncx_put_uint_longlong(void * xp,const longlong * ip,void * fillp)4561 ncx_put_uint_longlong(void *xp, const longlong *ip, void *fillp)
4562 #line 1221
4563 {
4564 #line 1221
4565     int err=NC_NOERR;
4566 #line 1221
4567     ix_uint xx = NC_FILL_UINT;
4568 #line 1221
4569 
4570 #line 1221
4571 #if IX_UINT_MAX < LONGLONG_MAX
4572 #line 1221
4573     if (*ip > IX_UINT_MAX) {
4574 #line 1221
4575 
4576 #line 1221
4577 #ifdef ERANGE_FILL
4578 #line 1221
4579             if (fillp != NULL) memcpy(&xx, fillp, 4);
4580 #line 1221
4581 #endif
4582 #line 1221
4583         err = NC_ERANGE;
4584 #line 1221
4585     }
4586 #line 1221
4587 #ifdef ERANGE_FILL
4588 #line 1221
4589     else
4590 #line 1221
4591 #endif
4592 #line 1221
4593 #endif
4594 #line 1221
4595     if (*ip < 0) {
4596 #line 1221
4597 
4598 #line 1221
4599 #ifdef ERANGE_FILL
4600 #line 1221
4601             if (fillp != NULL) memcpy(&xx, fillp, 4);
4602 #line 1221
4603 #endif
4604 #line 1221
4605         err = NC_ERANGE; /* because xp is unsigned */
4606 #line 1221
4607     }
4608 #line 1221
4609 #ifdef ERANGE_FILL
4610 #line 1221
4611     else
4612 #line 1221
4613 #endif
4614 #line 1221
4615         xx = (ix_uint)*ip;
4616 #line 1221
4617 
4618 #line 1221
4619     put_ix_uint(xp, &xx);
4620 #line 1221
4621     return err;
4622 #line 1221
4623 }
4624 #line 1221
4625 
4626 static int
4627 #line 1222
ncx_put_uint_ushort(void * xp,const ushort * ip,void * fillp)4628 ncx_put_uint_ushort(void *xp, const ushort *ip, void *fillp)
4629 #line 1222
4630 {
4631 #line 1222
4632     int err=NC_NOERR;
4633 #line 1222
4634 #if SIZEOF_IX_UINT == SIZEOF_USHORT && IX_UINT_MAX == USHORT_MAX
4635 #line 1222
4636     put_ix_uint(xp, (const ix_uint *)ip);
4637 #line 1222
4638 #else
4639 #line 1222
4640     ix_uint xx = NC_FILL_UINT;
4641 #line 1222
4642 
4643 #line 1222
4644 #if IX_UINT_MAX < USHORT_MAX
4645 #line 1222
4646     if (*ip > IX_UINT_MAX) {
4647 #line 1222
4648 
4649 #line 1222
4650 #ifdef ERANGE_FILL
4651 #line 1222
4652             if (fillp != NULL) memcpy(&xx, fillp, 4);
4653 #line 1222
4654 #endif
4655 #line 1222
4656         err = NC_ERANGE;
4657 #line 1222
4658     }
4659 #line 1222
4660 #ifdef ERANGE_FILL
4661 #line 1222
4662     else
4663 #line 1222
4664 #endif
4665 #line 1222
4666 #endif
4667 #line 1222
4668         xx = (ix_uint)*ip;
4669 #line 1222
4670 
4671 #line 1222
4672     put_ix_uint(xp, &xx);
4673 #line 1222
4674 #endif
4675 #line 1222
4676     return err;
4677 #line 1222
4678 }
4679 #line 1222
4680 
4681 static int
4682 #line 1223
ncx_put_uint_ulonglong(void * xp,const ulonglong * ip,void * fillp)4683 ncx_put_uint_ulonglong(void *xp, const ulonglong *ip, void *fillp)
4684 #line 1223
4685 {
4686 #line 1223
4687     int err=NC_NOERR;
4688 #line 1223
4689 #if SIZEOF_IX_UINT == SIZEOF_ULONGLONG && IX_UINT_MAX == ULONGLONG_MAX
4690 #line 1223
4691     put_ix_uint(xp, (const ix_uint *)ip);
4692 #line 1223
4693 #else
4694 #line 1223
4695     ix_uint xx = NC_FILL_UINT;
4696 #line 1223
4697 
4698 #line 1223
4699 #if IX_UINT_MAX < ULONGLONG_MAX
4700 #line 1223
4701     if (*ip > IX_UINT_MAX) {
4702 #line 1223
4703 
4704 #line 1223
4705 #ifdef ERANGE_FILL
4706 #line 1223
4707             if (fillp != NULL) memcpy(&xx, fillp, 4);
4708 #line 1223
4709 #endif
4710 #line 1223
4711         err = NC_ERANGE;
4712 #line 1223
4713     }
4714 #line 1223
4715 #ifdef ERANGE_FILL
4716 #line 1223
4717     else
4718 #line 1223
4719 #endif
4720 #line 1223
4721 #endif
4722 #line 1223
4723         xx = (ix_uint)*ip;
4724 #line 1223
4725 
4726 #line 1223
4727     put_ix_uint(xp, &xx);
4728 #line 1223
4729 #endif
4730 #line 1223
4731     return err;
4732 #line 1223
4733 }
4734 #line 1223
4735 
4736 static int
4737 #line 1224
ncx_put_uint_float(void * xp,const float * ip,void * fillp)4738 ncx_put_uint_float(void *xp, const float *ip, void *fillp)
4739 #line 1224
4740 {
4741 #line 1224
4742     int err=NC_NOERR;
4743 #line 1224
4744     ix_uint xx = NC_FILL_UINT;
4745 #line 1224
4746 
4747 #line 1224
4748     if (*ip > (double)X_UINT_MAX || *ip < 0) {
4749 #line 1224
4750 
4751 #line 1224
4752 #ifdef ERANGE_FILL
4753 #line 1224
4754             if (fillp != NULL) memcpy(&xx, fillp, 4);
4755 #line 1224
4756 #endif
4757 #line 1224
4758         err = NC_ERANGE;
4759 #line 1224
4760     }
4761 #line 1224
4762 #ifdef ERANGE_FILL
4763 #line 1224
4764     else
4765 #line 1224
4766 #endif
4767 #line 1224
4768         xx = (ix_uint)*ip;
4769 #line 1224
4770 
4771 #line 1224
4772     put_ix_uint(xp, &xx);
4773 #line 1224
4774     return err;
4775 #line 1224
4776 }
4777 #line 1224
4778 
4779 static int
4780 #line 1225
ncx_put_uint_double(void * xp,const double * ip,void * fillp)4781 ncx_put_uint_double(void *xp, const double *ip, void *fillp)
4782 #line 1225
4783 {
4784 #line 1225
4785     int err=NC_NOERR;
4786 #line 1225
4787     ix_uint xx = NC_FILL_UINT;
4788 #line 1225
4789 
4790 #line 1225
4791     if (*ip > X_UINT_MAX || *ip < 0) {
4792 #line 1225
4793 
4794 #line 1225
4795 #ifdef ERANGE_FILL
4796 #line 1225
4797             if (fillp != NULL) memcpy(&xx, fillp, 4);
4798 #line 1225
4799 #endif
4800 #line 1225
4801         err = NC_ERANGE;
4802 #line 1225
4803     }
4804 #line 1225
4805 #ifdef ERANGE_FILL
4806 #line 1225
4807     else
4808 #line 1225
4809 #endif
4810 #line 1225
4811         xx = (ix_uint)*ip;
4812 #line 1225
4813 
4814 #line 1225
4815     put_ix_uint(xp, &xx);
4816 #line 1225
4817     return err;
4818 #line 1225
4819 }
4820 #line 1225
4821 
4822 
4823 
4824 /* external NC_FLOAT --------------------------------------------------------*/
4825 
4826 #if X_SIZEOF_FLOAT == SIZEOF_FLOAT && !defined(NO_IEEE_FLOAT)
4827 
4828 inline static void
get_ix_float(const void * xp,float * ip)4829 get_ix_float(const void *xp, float *ip)
4830 {
4831 #ifdef WORDS_BIGENDIAN
4832 	(void) memcpy(ip, xp, SIZEOF_FLOAT);
4833 #else
4834 	swap4b(ip, xp);
4835 #endif
4836 }
4837 
4838 inline static void
put_ix_float(void * xp,const float * ip)4839 put_ix_float(void *xp, const float *ip)
4840 {
4841 #ifdef WORDS_BIGENDIAN
4842 	(void) memcpy(xp, ip, X_SIZEOF_FLOAT);
4843 #else
4844 	swap4b(xp, ip);
4845 #endif
4846 }
4847 
4848 #elif defined(vax) && vax != 0
4849 
4850 /* What IEEE single precision floating point looks like on a Vax */
4851 struct	ieee_single {
4852 	unsigned int	exp_hi       : 7;
4853 	unsigned int	sign         : 1;
4854 	unsigned int 	mant_hi      : 7;
4855 	unsigned int	exp_lo       : 1;
4856 	unsigned int	mant_lo_hi   : 8;
4857 	unsigned int	mant_lo_lo   : 8;
4858 };
4859 
4860 /* Vax single precision floating point */
4861 struct	vax_single {
4862 	unsigned int	mantissa1 : 7;
4863 	unsigned int	exp       : 8;
4864 	unsigned int	sign      : 1;
4865 	unsigned int	mantissa2 : 16;
4866 };
4867 
4868 #define VAX_SNG_BIAS	0x81
4869 #define IEEE_SNG_BIAS	0x7f
4870 
4871 static struct sgl_limits {
4872 	struct vax_single s;
4873 	struct ieee_single ieee;
4874 } max = {
4875 	{ 0x7f, 0xff, 0x0, 0xffff },	/* Max Vax */
4876 	{ 0x7f, 0x0, 0x0, 0x1, 0x0, 0x0 }		/* Max IEEE */
4877 };
4878 static struct sgl_limits min = {
4879 	{ 0x0, 0x0, 0x0, 0x0 },	/* Min Vax */
4880 	{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }		/* Min IEEE */
4881 };
4882 
4883 #line 1339
4884 static void
get_ix_float(const void * xp,float * ip)4885 get_ix_float(const void *xp, float *ip)
4886 {
4887 		struct vax_single *const vsp = (struct vax_single *) ip;
4888 #line 1342
4889 		const struct ieee_single *const isp =
4890 #line 1342
4891 			 (const struct ieee_single *) xp;
4892 #line 1342
4893 		unsigned exp = isp->exp_hi << 1 | isp->exp_lo;
4894 #line 1342
4895 
4896 #line 1342
4897 		switch(exp) {
4898 #line 1342
4899 		case 0 :
4900 #line 1342
4901 			/* ieee subnormal */
4902 #line 1342
4903 			if (isp->mant_hi == min.ieee.mant_hi
4904 #line 1342
4905 				&& isp->mant_lo_hi == min.ieee.mant_lo_hi
4906 #line 1342
4907 				&& isp->mant_lo_lo == min.ieee.mant_lo_lo)
4908 #line 1342
4909 			{
4910 #line 1342
4911 				*vsp = min.s;
4912 #line 1342
4913 			}
4914 #line 1342
4915 			else
4916 #line 1342
4917 			{
4918 #line 1342
4919 				unsigned mantissa = (isp->mant_hi << 16)
4920 #line 1342
4921 					 | isp->mant_lo_hi << 8
4922 #line 1342
4923 					 | isp->mant_lo_lo;
4924 #line 1342
4925 				unsigned tmp = mantissa >> 20;
4926 #line 1342
4927 				if (tmp >= 4) {
4928 #line 1342
4929 					vsp->exp = 2;
4930 #line 1342
4931 				} else if (tmp >= 2) {
4932 #line 1342
4933 					vsp->exp = 1;
4934 #line 1342
4935 				} else {
4936 #line 1342
4937 					*vsp = min.s;
4938 #line 1342
4939 					break;
4940 #line 1342
4941 				} /* else */
4942 #line 1342
4943 				tmp = mantissa - (1 << (20 + vsp->exp ));
4944 #line 1342
4945 				tmp <<= 3 - vsp->exp;
4946 #line 1342
4947 				vsp->mantissa2 = tmp;
4948 #line 1342
4949 				vsp->mantissa1 = (tmp >> 16);
4950 #line 1342
4951 			}
4952 #line 1342
4953 			break;
4954 #line 1342
4955 		case 0xfe :
4956 #line 1342
4957 		case 0xff :
4958 #line 1342
4959 			*vsp = max.s;
4960 #line 1342
4961 			break;
4962 #line 1342
4963 		default :
4964 #line 1342
4965 			vsp->exp = exp - IEEE_SNG_BIAS + VAX_SNG_BIAS;
4966 #line 1342
4967 			vsp->mantissa2 = isp->mant_lo_hi << 8 | isp->mant_lo_lo;
4968 #line 1342
4969 			vsp->mantissa1 = isp->mant_hi;
4970 #line 1342
4971 		}
4972 #line 1342
4973 
4974 #line 1342
4975 		vsp->sign = isp->sign;
4976 #line 1342
4977 
4978 }
4979 
4980 #line 1396
4981 
4982 static void
put_ix_float(void * xp,const float * ip)4983 put_ix_float(void *xp, const float *ip)
4984 {
4985 		const struct vax_single *const vsp =
4986 #line 1400
4987 			 (const struct vax_single *)ip;
4988 #line 1400
4989 		struct ieee_single *const isp = (struct ieee_single *) xp;
4990 #line 1400
4991 
4992 #line 1400
4993 		switch(vsp->exp){
4994 #line 1400
4995 		case 0 :
4996 #line 1400
4997 			/* all vax float with zero exponent map to zero */
4998 #line 1400
4999 			*isp = min.ieee;
5000 #line 1400
5001 			break;
5002 #line 1400
5003 		case 2 :
5004 #line 1400
5005 		case 1 :
5006 #line 1400
5007 		{
5008 #line 1400
5009 			/* These will map to subnormals */
5010 #line 1400
5011 			unsigned mantissa = (vsp->mantissa1 << 16)
5012 #line 1400
5013 					 | vsp->mantissa2;
5014 #line 1400
5015 			mantissa >>= 3 - vsp->exp;
5016 #line 1400
5017 			mantissa += (1 << (20 + vsp->exp));
5018 #line 1400
5019 			isp->mant_lo_lo = mantissa;
5020 #line 1400
5021 			isp->mant_lo_hi = mantissa >> 8;
5022 #line 1400
5023 			isp->mant_hi = mantissa >> 16;
5024 #line 1400
5025 			isp->exp_lo = 0;
5026 #line 1400
5027 			isp->exp_hi = 0;
5028 #line 1400
5029 		}
5030 #line 1400
5031 			break;
5032 #line 1400
5033 		case 0xff : /* max.s.exp */
5034 #line 1400
5035 			if (vsp->mantissa2 == max.s.mantissa2 &&
5036 #line 1400
5037 			    vsp->mantissa1 == max.s.mantissa1)
5038 #line 1400
5039 			{
5040 #line 1400
5041 				/* map largest vax float to ieee infinity */
5042 #line 1400
5043 				*isp = max.ieee;
5044 #line 1400
5045 				break;
5046 #line 1400
5047 			} /* else, fall thru */
5048 #line 1400
5049 		default :
5050 #line 1400
5051 		{
5052 #line 1400
5053 			unsigned exp = vsp->exp - VAX_SNG_BIAS + IEEE_SNG_BIAS;
5054 #line 1400
5055 			isp->exp_hi = exp >> 1;
5056 #line 1400
5057 			isp->exp_lo = exp;
5058 #line 1400
5059 			isp->mant_lo_lo = vsp->mantissa2;
5060 #line 1400
5061 			isp->mant_lo_hi = vsp->mantissa2 >> 8;
5062 #line 1400
5063 			isp->mant_hi = vsp->mantissa1;
5064 #line 1400
5065 		}
5066 #line 1400
5067 		}
5068 #line 1400
5069 
5070 #line 1400
5071 		isp->sign = vsp->sign;
5072 #line 1400
5073 
5074 }
5075 
5076 	/* vax */
5077 #elif defined(_CRAY) && !defined(__crayx1)
5078 
5079 /*
5080  * Return the number of bytes until the next "word" boundary
5081  * N.B. This is based on the very weird YMP address structure,
5082  * which puts the address within a word in the leftmost 3 bits
5083  * of the address.
5084  */
5085 static size_t
word_align(const void * vp)5086 word_align(const void *vp)
5087 {
5088 	const size_t rem = ((size_t)vp >> (64 - 3)) & 0x7;
5089 	return (rem != 0);
5090 }
5091 
5092 struct ieee_single_hi {
5093 	unsigned int	sign	: 1;
5094 	unsigned int	 exp	: 8;
5095 	unsigned int	mant	:23;
5096 	unsigned int	pad	:32;
5097 };
5098 typedef struct ieee_single_hi ieee_single_hi;
5099 
5100 struct ieee_single_lo {
5101 	unsigned int	pad	:32;
5102 	unsigned int	sign	: 1;
5103 	unsigned int	 exp	: 8;
5104 	unsigned int	mant	:23;
5105 };
5106 typedef struct ieee_single_lo ieee_single_lo;
5107 
5108 static const int ieee_single_bias = 0x7f;
5109 
5110 struct ieee_double {
5111 	unsigned int	sign	: 1;
5112 	unsigned int	 exp	:11;
5113 	unsigned int	mant	:52;
5114 };
5115 typedef struct ieee_double ieee_double;
5116 
5117 static const int ieee_double_bias = 0x3ff;
5118 
5119 #if defined(NO_IEEE_FLOAT)
5120 
5121 struct cray_single {
5122 	unsigned int	sign	: 1;
5123 	unsigned int	 exp	:15;
5124 	unsigned int	mant	:48;
5125 };
5126 typedef struct cray_single cray_single;
5127 
5128 static const int cs_ieis_bias = 0x4000 - 0x7f;
5129 
5130 static const int cs_id_bias = 0x4000 - 0x3ff;
5131 
5132 #line 1535
5133 
5134 static void
get_ix_float(const void * xp,float * ip)5135 get_ix_float(const void *xp, float *ip)
5136 {
5137 
5138 	if (word_align(xp) == 0)
5139 	{
5140 		const ieee_single_hi *isp = (const ieee_single_hi *) xp;
5141 		cray_single *csp = (cray_single *) ip;
5142 #line 1543
5143 
5144 #line 1543
5145 		if (isp->exp == 0)
5146 #line 1543
5147 		{
5148 #line 1543
5149 			/* ieee subnormal */
5150 #line 1543
5151 			*ip = (double)isp->mant;
5152 #line 1543
5153 			if (isp->mant != 0)
5154 #line 1543
5155 			{
5156 #line 1543
5157 				csp->exp -= (ieee_single_bias + 22);
5158 #line 1543
5159 			}
5160 #line 1543
5161 		}
5162 #line 1543
5163 		else
5164 #line 1543
5165 		{
5166 #line 1543
5167 			csp->exp  = isp->exp + cs_ieis_bias + 1;
5168 #line 1543
5169 			csp->mant = isp->mant << (48 - 1 - 23);
5170 #line 1543
5171 			csp->mant |= (1 << (48 - 1));
5172 #line 1543
5173 		}
5174 #line 1543
5175 		csp->sign = isp->sign;
5176 #line 1543
5177 
5178 #line 1543
5179 
5180 	}
5181 	else
5182 	{
5183 		const ieee_single_lo *isp = (const ieee_single_lo *) xp;
5184 		cray_single *csp = (cray_single *) ip;
5185 #line 1548
5186 
5187 #line 1548
5188 		if (isp->exp == 0)
5189 #line 1548
5190 		{
5191 #line 1548
5192 			/* ieee subnormal */
5193 #line 1548
5194 			*ip = (double)isp->mant;
5195 #line 1548
5196 			if (isp->mant != 0)
5197 #line 1548
5198 			{
5199 #line 1548
5200 				csp->exp -= (ieee_single_bias + 22);
5201 #line 1548
5202 			}
5203 #line 1548
5204 		}
5205 #line 1548
5206 		else
5207 #line 1548
5208 		{
5209 #line 1548
5210 			csp->exp  = isp->exp + cs_ieis_bias + 1;
5211 #line 1548
5212 			csp->mant = isp->mant << (48 - 1 - 23);
5213 #line 1548
5214 			csp->mant |= (1 << (48 - 1));
5215 #line 1548
5216 		}
5217 #line 1548
5218 		csp->sign = isp->sign;
5219 #line 1548
5220 
5221 #line 1548
5222 
5223 	}
5224 }
5225 
5226 static void
put_ix_float(void * xp,const float * ip)5227 put_ix_float(void *xp, const float *ip)
5228 {
5229 	if (word_align(xp) == 0)
5230 	{
5231 		ieee_single_hi *isp = (ieee_single_hi*)xp;
5232 	const cray_single *csp = (const cray_single *) ip;
5233 #line 1558
5234 	int ieee_exp = csp->exp - cs_ieis_bias -1;
5235 #line 1558
5236 
5237 #line 1558
5238 	isp->sign = csp->sign;
5239 #line 1558
5240 
5241 #line 1558
5242 	if (ieee_exp >= 0xff)
5243 #line 1558
5244 	{
5245 #line 1558
5246 		/* NC_ERANGE => ieee Inf */
5247 #line 1558
5248 		isp->exp = 0xff;
5249 #line 1558
5250 		isp->mant = 0x0;
5251 #line 1558
5252 	}
5253 #line 1558
5254 	else if (ieee_exp > 0)
5255 #line 1558
5256 	{
5257 #line 1558
5258 		/* normal ieee representation */
5259 #line 1558
5260 		isp->exp  = ieee_exp;
5261 #line 1558
5262 		/* assumes cray rep is in normal form */
5263 #line 1558
5264 		assert(csp->mant & 0x800000000000);
5265 #line 1558
5266 		isp->mant = (((csp->mant << 1) &
5267 #line 1558
5268 				0xffffffffffff) >> (48 - 23));
5269 #line 1558
5270 	}
5271 #line 1558
5272 	else if (ieee_exp > -23)
5273 #line 1558
5274 	{
5275 #line 1558
5276 		/* ieee subnormal, right shift */
5277 #line 1558
5278 		const int rshift = (48 - 23 - ieee_exp);
5279 #line 1558
5280 
5281 #line 1558
5282 		isp->mant = csp->mant >> rshift;
5283 #line 1558
5284 
5285 #line 1558
5286 #if 0
5287 #line 1558
5288 		if (csp->mant & (1 << (rshift -1)))
5289 #line 1558
5290 		{
5291 #line 1558
5292 			/* round up */
5293 #line 1558
5294 			isp->mant++;
5295 #line 1558
5296 		}
5297 #line 1558
5298 #endif
5299 #line 1558
5300 
5301 #line 1558
5302 		isp->exp  = 0;
5303 #line 1558
5304 	}
5305 #line 1558
5306 	else
5307 #line 1558
5308 	{
5309 #line 1558
5310 		/* smaller than ieee can represent */
5311 #line 1558
5312 		isp->exp = 0;
5313 #line 1558
5314 		isp->mant = 0;
5315 #line 1558
5316 	}
5317 #line 1558
5318 
5319 	}
5320 	else
5321 	{
5322 		ieee_single_lo *isp = (ieee_single_lo*)xp;
5323 	const cray_single *csp = (const cray_single *) ip;
5324 #line 1563
5325 	int ieee_exp = csp->exp - cs_ieis_bias -1;
5326 #line 1563
5327 
5328 #line 1563
5329 	isp->sign = csp->sign;
5330 #line 1563
5331 
5332 #line 1563
5333 	if (ieee_exp >= 0xff)
5334 #line 1563
5335 	{
5336 #line 1563
5337 		/* NC_ERANGE => ieee Inf */
5338 #line 1563
5339 		isp->exp = 0xff;
5340 #line 1563
5341 		isp->mant = 0x0;
5342 #line 1563
5343 	}
5344 #line 1563
5345 	else if (ieee_exp > 0)
5346 #line 1563
5347 	{
5348 #line 1563
5349 		/* normal ieee representation */
5350 #line 1563
5351 		isp->exp  = ieee_exp;
5352 #line 1563
5353 		/* assumes cray rep is in normal form */
5354 #line 1563
5355 		assert(csp->mant & 0x800000000000);
5356 #line 1563
5357 		isp->mant = (((csp->mant << 1) &
5358 #line 1563
5359 				0xffffffffffff) >> (48 - 23));
5360 #line 1563
5361 	}
5362 #line 1563
5363 	else if (ieee_exp > -23)
5364 #line 1563
5365 	{
5366 #line 1563
5367 		/* ieee subnormal, right shift */
5368 #line 1563
5369 		const int rshift = (48 - 23 - ieee_exp);
5370 #line 1563
5371 
5372 #line 1563
5373 		isp->mant = csp->mant >> rshift;
5374 #line 1563
5375 
5376 #line 1563
5377 #if 0
5378 #line 1563
5379 		if (csp->mant & (1 << (rshift -1)))
5380 #line 1563
5381 		{
5382 #line 1563
5383 			/* round up */
5384 #line 1563
5385 			isp->mant++;
5386 #line 1563
5387 		}
5388 #line 1563
5389 #endif
5390 #line 1563
5391 
5392 #line 1563
5393 		isp->exp  = 0;
5394 #line 1563
5395 	}
5396 #line 1563
5397 	else
5398 #line 1563
5399 	{
5400 #line 1563
5401 		/* smaller than ieee can represent */
5402 #line 1563
5403 		isp->exp = 0;
5404 #line 1563
5405 		isp->mant = 0;
5406 #line 1563
5407 	}
5408 #line 1563
5409 
5410 	}
5411 }
5412 
5413 #else
5414 	/* IEEE Cray with only doubles */
5415 static void
get_ix_float(const void * xp,float * ip)5416 get_ix_float(const void *xp, float *ip)
5417 {
5418 
5419 	ieee_double *idp = (ieee_double *) ip;
5420 
5421 	if (word_align(xp) == 0)
5422 	{
5423 		const ieee_single_hi *isp = (const ieee_single_hi *) xp;
5424 		if (isp->exp == 0 && isp->mant == 0)
5425 		{
5426 			idp->exp = 0;
5427 			idp->mant = 0;
5428 		}
5429 		else
5430 		{
5431 			idp->exp = isp->exp + (ieee_double_bias - ieee_single_bias);
5432 			idp->mant = isp->mant << (52 - 23);
5433 		}
5434 		idp->sign = isp->sign;
5435 	}
5436 	else
5437 	{
5438 		const ieee_single_lo *isp = (const ieee_single_lo *) xp;
5439 		if (isp->exp == 0 && isp->mant == 0)
5440 		{
5441 			idp->exp = 0;
5442 			idp->mant = 0;
5443 		}
5444 		else
5445 		{
5446 			idp->exp = isp->exp + (ieee_double_bias - ieee_single_bias);
5447 			idp->mant = isp->mant << (52 - 23);
5448 		}
5449 		idp->sign = isp->sign;
5450 	}
5451 }
5452 
5453 static void
put_ix_float(void * xp,const float * ip)5454 put_ix_float(void *xp, const float *ip)
5455 {
5456 	const ieee_double *idp = (const ieee_double *) ip;
5457 	if (word_align(xp) == 0)
5458 	{
5459 		ieee_single_hi *isp = (ieee_single_hi*)xp;
5460 		if (idp->exp > (ieee_double_bias - ieee_single_bias))
5461 			isp->exp = idp->exp - (ieee_double_bias - ieee_single_bias);
5462 		else
5463 			isp->exp = 0;
5464 		isp->mant = idp->mant >> (52 - 23);
5465 		isp->sign = idp->sign;
5466 	}
5467 	else
5468 	{
5469 		ieee_single_lo *isp = (ieee_single_lo*)xp;
5470 		if (idp->exp > (ieee_double_bias - ieee_single_bias))
5471 			isp->exp = idp->exp - (ieee_double_bias - ieee_single_bias);
5472 		else
5473 			isp->exp = 0;
5474 		isp->mant = idp->mant >> (52 - 23);
5475 		isp->sign = idp->sign;
5476 	}
5477 }
5478 #endif
5479 
5480 #else
5481 #error "ix_float implementation"
5482 #endif
5483 
5484 #if X_SIZEOF_FLOAT != SIZEOF_FLOAT || defined(NO_IEEE_FLOAT)
5485 static int
ncx_get_float_float(const void * xp,float * ip,void * fillp)5486 ncx_get_float_float(const void *xp, float *ip, void *fillp)
5487 {
5488 	/* TODO */
5489 	get_ix_float(xp, ip);
5490 	return NC_NOERR;
5491 }
5492 #endif
5493 
5494 #define ix_float float
5495 
5496 static int
5497 #line 1650
ncx_get_float_schar(const void * xp,schar * ip)5498 ncx_get_float_schar(const void *xp, schar *ip)
5499 #line 1650
5500 {
5501 #line 1650
5502 	ix_float xx = 0;
5503 #line 1650
5504 	get_ix_float(xp, &xx);
5505 #line 1650
5506 	if (xx > (double)SCHAR_MAX || xx < (double)SCHAR_MIN) {
5507 #line 1650
5508 #ifdef ERANGE_FILL
5509 #line 1650
5510             *ip = NC_FILL_BYTE;
5511 #line 1650
5512 #endif
5513 #line 1650
5514             return NC_ERANGE;
5515 #line 1650
5516         }
5517 #line 1650
5518 	*ip = (schar)xx;
5519 #line 1650
5520 	return NC_NOERR;
5521 #line 1650
5522 }
5523 #line 1650
5524 
5525 static int
5526 #line 1651
ncx_get_float_short(const void * xp,short * ip)5527 ncx_get_float_short(const void *xp, short *ip)
5528 #line 1651
5529 {
5530 #line 1651
5531 	ix_float xx = 0;
5532 #line 1651
5533 	get_ix_float(xp, &xx);
5534 #line 1651
5535 	if (xx > (double)SHORT_MAX || xx < (double)SHORT_MIN) {
5536 #line 1651
5537 #ifdef ERANGE_FILL
5538 #line 1651
5539             *ip = NC_FILL_SHORT;
5540 #line 1651
5541 #endif
5542 #line 1651
5543             return NC_ERANGE;
5544 #line 1651
5545         }
5546 #line 1651
5547 	*ip = (short)xx;
5548 #line 1651
5549 	return NC_NOERR;
5550 #line 1651
5551 }
5552 #line 1651
5553 
5554 static int
5555 #line 1652
ncx_get_float_int(const void * xp,int * ip)5556 ncx_get_float_int(const void *xp, int *ip)
5557 #line 1652
5558 {
5559 #line 1652
5560 	ix_float xx = 0;
5561 #line 1652
5562 	get_ix_float(xp, &xx);
5563 #line 1652
5564 	if (xx > (double)INT_MAX || xx < (double)INT_MIN) {
5565 #line 1652
5566 #ifdef ERANGE_FILL
5567 #line 1652
5568             *ip = NC_FILL_INT;
5569 #line 1652
5570 #endif
5571 #line 1652
5572             return NC_ERANGE;
5573 #line 1652
5574         }
5575 #line 1652
5576 	*ip = (int)xx;
5577 #line 1652
5578 	return NC_NOERR;
5579 #line 1652
5580 }
5581 #line 1652
5582 
5583 static int
5584 #line 1653
ncx_get_float_long(const void * xp,long * ip)5585 ncx_get_float_long(const void *xp, long *ip)
5586 #line 1653
5587 {
5588 #line 1653
5589 	ix_float xx = 0;
5590 #line 1653
5591 	get_ix_float(xp, &xx);
5592 #line 1653
5593 	if (xx > (double)LONG_MAX || xx < (double)LONG_MIN) {
5594 #line 1653
5595 #ifdef ERANGE_FILL
5596 #line 1653
5597             *ip = NC_FILL_INT;
5598 #line 1653
5599 #endif
5600 #line 1653
5601             return NC_ERANGE;
5602 #line 1653
5603         }
5604 #line 1653
5605 	*ip = (long)xx;
5606 #line 1653
5607 	return NC_NOERR;
5608 #line 1653
5609 }
5610 #line 1653
5611 
5612 static int
5613 #line 1654
ncx_get_float_double(const void * xp,double * ip)5614 ncx_get_float_double(const void *xp, double *ip)
5615 #line 1654
5616 {
5617 #line 1654
5618 	ix_float xx = 0;
5619 #line 1654
5620 	get_ix_float(xp, &xx);
5621 #line 1654
5622 	*ip = (double)xx;
5623 #line 1654
5624 	return NC_NOERR;
5625 #line 1654
5626 }
5627 #line 1654
5628 
5629 static int
5630 #line 1655
ncx_get_float_longlong(const void * xp,longlong * ip)5631 ncx_get_float_longlong(const void *xp, longlong *ip)
5632 #line 1655
5633 {
5634 #line 1655
5635 	ix_float xx = 0;
5636 #line 1655
5637 	get_ix_float(xp, &xx);
5638 #line 1655
5639 	if (xx == LONGLONG_MAX)      *ip = LONGLONG_MAX;
5640 #line 1655
5641 	else if (xx == LONGLONG_MIN) *ip = LONGLONG_MIN;
5642 #line 1655
5643 	else if (xx > (double)LONGLONG_MAX || xx < (double)LONGLONG_MIN) {
5644 #line 1655
5645 #ifdef ERANGE_FILL
5646 #line 1655
5647             *ip = NC_FILL_INT64;
5648 #line 1655
5649 #endif
5650 #line 1655
5651             return NC_ERANGE;
5652 #line 1655
5653         }
5654 #line 1655
5655 	else *ip = (longlong)xx;
5656 #line 1655
5657 	return NC_NOERR;
5658 #line 1655
5659 }
5660 #line 1655
5661 
5662 static int
5663 #line 1656
ncx_get_float_uchar(const void * xp,uchar * ip)5664 ncx_get_float_uchar(const void *xp, uchar *ip)
5665 #line 1656
5666 {
5667 #line 1656
5668 	ix_float xx = 0;
5669 #line 1656
5670 	get_ix_float(xp, &xx);
5671 #line 1656
5672 	if (xx > (double)UCHAR_MAX || xx < 0) {
5673 #line 1656
5674 #ifdef ERANGE_FILL
5675 #line 1656
5676             *ip = NC_FILL_UBYTE;
5677 #line 1656
5678 #endif
5679 #line 1656
5680             return NC_ERANGE;
5681 #line 1656
5682         }
5683 #line 1656
5684 	*ip = (uchar)xx;
5685 #line 1656
5686 	return NC_NOERR;
5687 #line 1656
5688 }
5689 #line 1656
5690 
5691 static int
5692 #line 1657
ncx_get_float_ushort(const void * xp,ushort * ip)5693 ncx_get_float_ushort(const void *xp, ushort *ip)
5694 #line 1657
5695 {
5696 #line 1657
5697 	ix_float xx = 0;
5698 #line 1657
5699 	get_ix_float(xp, &xx);
5700 #line 1657
5701 	if (xx > (double)USHORT_MAX || xx < 0) {
5702 #line 1657
5703 #ifdef ERANGE_FILL
5704 #line 1657
5705             *ip = NC_FILL_USHORT;
5706 #line 1657
5707 #endif
5708 #line 1657
5709             return NC_ERANGE;
5710 #line 1657
5711         }
5712 #line 1657
5713 	*ip = (ushort)xx;
5714 #line 1657
5715 	return NC_NOERR;
5716 #line 1657
5717 }
5718 #line 1657
5719 
5720 static int
5721 #line 1658
ncx_get_float_uint(const void * xp,uint * ip)5722 ncx_get_float_uint(const void *xp, uint *ip)
5723 #line 1658
5724 {
5725 #line 1658
5726 	ix_float xx = 0;
5727 #line 1658
5728 	get_ix_float(xp, &xx);
5729 #line 1658
5730 	if (xx > (double)UINT_MAX || xx < 0) {
5731 #line 1658
5732 #ifdef ERANGE_FILL
5733 #line 1658
5734             *ip = NC_FILL_UINT;
5735 #line 1658
5736 #endif
5737 #line 1658
5738             return NC_ERANGE;
5739 #line 1658
5740         }
5741 #line 1658
5742 	*ip = (uint)xx;
5743 #line 1658
5744 	return NC_NOERR;
5745 #line 1658
5746 }
5747 #line 1658
5748 
5749 static int
5750 #line 1659
ncx_get_float_ulonglong(const void * xp,ulonglong * ip)5751 ncx_get_float_ulonglong(const void *xp, ulonglong *ip)
5752 #line 1659
5753 {
5754 #line 1659
5755 	ix_float xx = 0;
5756 #line 1659
5757 	get_ix_float(xp, &xx);
5758 #line 1659
5759 	if (xx == ULONGLONG_MAX)      *ip = ULONGLONG_MAX;
5760 #line 1659
5761 	else if (xx > (double)ULONGLONG_MAX || xx < 0) {
5762 #line 1659
5763 #ifdef ERANGE_FILL
5764 #line 1659
5765             *ip = NC_FILL_UINT64;
5766 #line 1659
5767 #endif
5768 #line 1659
5769             return NC_ERANGE;
5770 #line 1659
5771         }
5772 #line 1659
5773 	else *ip = (ulonglong)xx;
5774 #line 1659
5775 	return NC_NOERR;
5776 #line 1659
5777 }
5778 #line 1659
5779 
5780 
5781 #if X_SIZEOF_FLOAT != SIZEOF_FLOAT || defined(NO_IEEE_FLOAT)
5782 static int
ncx_put_float_float(void * xp,const float * ip,void * fillp)5783 ncx_put_float_float(void *xp, const float *ip, void *fillp)
5784 {
5785     int err=NC_NOERR;
5786     float *_ip=ip;
5787 #ifdef NO_IEEE_FLOAT
5788 #ifdef ERANGE_FILL
5789     float tmp;
5790 #endif
5791     if (*ip > X_FLOAT_MAX || *ip < X_FLOAT_MIN) {
5792 
5793 #line 1672
5794 #ifdef ERANGE_FILL
5795 #line 1672
5796             if (fillp != NULL) memcpy(&tmp, fillp, 4);
5797 #line 1672
5798 #endif
5799 #ifdef ERANGE_FILL
5800         _ip = &tmp;
5801 #endif
5802         err = NC_ERANGE;
5803     }
5804 #endif
5805     put_ix_float(xp, _ip);
5806     return err;
5807 }
5808 #endif
5809 
5810 static int
5811 #line 1684
ncx_put_float_schar(void * xp,const schar * ip,void * fillp)5812 ncx_put_float_schar(void *xp, const schar *ip, void *fillp)
5813 #line 1684
5814 {
5815 #line 1684
5816     int err=NC_NOERR;
5817 #line 1684
5818     ix_float xx = NC_FILL_FLOAT;
5819 #line 1684
5820 
5821 #line 1684
5822 
5823 #line 1684
5824         xx = (ix_float)*ip;
5825 #line 1684
5826 
5827 #line 1684
5828     put_ix_float(xp, &xx);
5829 #line 1684
5830     return err;
5831 #line 1684
5832 }
5833 #line 1684
5834 
5835 static int
5836 #line 1685
ncx_put_float_short(void * xp,const short * ip,void * fillp)5837 ncx_put_float_short(void *xp, const short *ip, void *fillp)
5838 #line 1685
5839 {
5840 #line 1685
5841     int err=NC_NOERR;
5842 #line 1685
5843     ix_float xx = NC_FILL_FLOAT;
5844 #line 1685
5845 
5846 #line 1685
5847 
5848 #line 1685
5849         xx = (ix_float)*ip;
5850 #line 1685
5851 
5852 #line 1685
5853     put_ix_float(xp, &xx);
5854 #line 1685
5855     return err;
5856 #line 1685
5857 }
5858 #line 1685
5859 
5860 static int
5861 #line 1686
ncx_put_float_int(void * xp,const int * ip,void * fillp)5862 ncx_put_float_int(void *xp, const int *ip, void *fillp)
5863 #line 1686
5864 {
5865 #line 1686
5866     int err=NC_NOERR;
5867 #line 1686
5868     ix_float xx = NC_FILL_FLOAT;
5869 #line 1686
5870 
5871 #line 1686
5872 
5873 #line 1686
5874         xx = (ix_float)*ip;
5875 #line 1686
5876 
5877 #line 1686
5878     put_ix_float(xp, &xx);
5879 #line 1686
5880     return err;
5881 #line 1686
5882 }
5883 #line 1686
5884 
5885 static int
5886 #line 1687
ncx_put_float_long(void * xp,const long * ip,void * fillp)5887 ncx_put_float_long(void *xp, const long *ip, void *fillp)
5888 #line 1687
5889 {
5890 #line 1687
5891     int err=NC_NOERR;
5892 #line 1687
5893     ix_float xx = NC_FILL_FLOAT;
5894 #line 1687
5895 
5896 #line 1687
5897 
5898 #line 1687
5899         xx = (ix_float)*ip;
5900 #line 1687
5901 
5902 #line 1687
5903     put_ix_float(xp, &xx);
5904 #line 1687
5905     return err;
5906 #line 1687
5907 }
5908 #line 1687
5909 
5910 static int
5911 #line 1688
ncx_put_float_double(void * xp,const double * ip,void * fillp)5912 ncx_put_float_double(void *xp, const double *ip, void *fillp)
5913 #line 1688
5914 {
5915 #line 1688
5916     int err=NC_NOERR;
5917 #line 1688
5918     ix_float xx = NC_FILL_FLOAT;
5919 #line 1688
5920 
5921 #line 1688
5922     if (*ip > X_FLOAT_MAX || *ip < X_FLOAT_MIN) {
5923 #line 1688
5924 
5925 #line 1688
5926 #ifdef ERANGE_FILL
5927 #line 1688
5928             if (fillp != NULL) memcpy(&xx, fillp, 4);
5929 #line 1688
5930 #endif
5931 #line 1688
5932         err = NC_ERANGE;
5933 #line 1688
5934     }
5935 #line 1688
5936 #ifdef ERANGE_FILL
5937 #line 1688
5938     else
5939 #line 1688
5940 #endif
5941 #line 1688
5942         xx = (ix_float)*ip;
5943 #line 1688
5944 
5945 #line 1688
5946     put_ix_float(xp, &xx);
5947 #line 1688
5948     return err;
5949 #line 1688
5950 }
5951 #line 1688
5952 
5953 static int
5954 #line 1689
ncx_put_float_longlong(void * xp,const longlong * ip,void * fillp)5955 ncx_put_float_longlong(void *xp, const longlong *ip, void *fillp)
5956 #line 1689
5957 {
5958 #line 1689
5959     int err=NC_NOERR;
5960 #line 1689
5961     ix_float xx = NC_FILL_FLOAT;
5962 #line 1689
5963 
5964 #line 1689
5965 
5966 #line 1689
5967         xx = (ix_float)*ip;
5968 #line 1689
5969 
5970 #line 1689
5971     put_ix_float(xp, &xx);
5972 #line 1689
5973     return err;
5974 #line 1689
5975 }
5976 #line 1689
5977 
5978 static int
5979 #line 1690
ncx_put_float_uchar(void * xp,const uchar * ip,void * fillp)5980 ncx_put_float_uchar(void *xp, const uchar *ip, void *fillp)
5981 #line 1690
5982 {
5983 #line 1690
5984     int err=NC_NOERR;
5985 #line 1690
5986     ix_float xx = NC_FILL_FLOAT;
5987 #line 1690
5988 
5989 #line 1690
5990 
5991 #line 1690
5992         xx = (ix_float)*ip;
5993 #line 1690
5994 
5995 #line 1690
5996     put_ix_float(xp, &xx);
5997 #line 1690
5998     return err;
5999 #line 1690
6000 }
6001 #line 1690
6002 
6003 static int
6004 #line 1691
ncx_put_float_ushort(void * xp,const ushort * ip,void * fillp)6005 ncx_put_float_ushort(void *xp, const ushort *ip, void *fillp)
6006 #line 1691
6007 {
6008 #line 1691
6009     int err=NC_NOERR;
6010 #line 1691
6011     ix_float xx = NC_FILL_FLOAT;
6012 #line 1691
6013 
6014 #line 1691
6015 
6016 #line 1691
6017         xx = (ix_float)*ip;
6018 #line 1691
6019 
6020 #line 1691
6021     put_ix_float(xp, &xx);
6022 #line 1691
6023     return err;
6024 #line 1691
6025 }
6026 #line 1691
6027 
6028 static int
6029 #line 1692
ncx_put_float_uint(void * xp,const uint * ip,void * fillp)6030 ncx_put_float_uint(void *xp, const uint *ip, void *fillp)
6031 #line 1692
6032 {
6033 #line 1692
6034     int err=NC_NOERR;
6035 #line 1692
6036     ix_float xx = NC_FILL_FLOAT;
6037 #line 1692
6038 
6039 #line 1692
6040 
6041 #line 1692
6042         xx = (ix_float)*ip;
6043 #line 1692
6044 
6045 #line 1692
6046     put_ix_float(xp, &xx);
6047 #line 1692
6048     return err;
6049 #line 1692
6050 }
6051 #line 1692
6052 
6053 static int
6054 #line 1693
ncx_put_float_ulonglong(void * xp,const ulonglong * ip,void * fillp)6055 ncx_put_float_ulonglong(void *xp, const ulonglong *ip, void *fillp)
6056 #line 1693
6057 {
6058 #line 1693
6059     int err=NC_NOERR;
6060 #line 1693
6061     ix_float xx = NC_FILL_FLOAT;
6062 #line 1693
6063 
6064 #line 1693
6065 
6066 #line 1693
6067         xx = (ix_float)*ip;
6068 #line 1693
6069 
6070 #line 1693
6071     put_ix_float(xp, &xx);
6072 #line 1693
6073     return err;
6074 #line 1693
6075 }
6076 #line 1693
6077 
6078 
6079 
6080 /* external NC_DOUBLE -------------------------------------------------------*/
6081 
6082 #if X_SIZEOF_DOUBLE == SIZEOF_DOUBLE  && !defined(NO_IEEE_FLOAT)
6083 
6084 static void
get_ix_double(const void * xp,double * ip)6085 get_ix_double(const void *xp, double *ip)
6086 {
6087 #ifdef WORDS_BIGENDIAN
6088 	(void) memcpy(ip, xp, SIZEOF_DOUBLE);
6089 #else
6090 	swap8b(ip, xp);
6091 #endif
6092 }
6093 
6094 static void
put_ix_double(void * xp,const double * ip)6095 put_ix_double(void *xp, const double *ip)
6096 {
6097 #ifdef WORDS_BIGENDIAN
6098 	(void) memcpy(xp, ip, X_SIZEOF_DOUBLE);
6099 #else
6100 	swap8b(xp, ip);
6101 #endif
6102 }
6103 
6104 #elif defined(vax) && vax != 0
6105 
6106 /* What IEEE double precision floating point looks like on a Vax */
6107 struct	ieee_double {
6108 	unsigned int	exp_hi   : 7;
6109 	unsigned int	sign     : 1;
6110 	unsigned int 	mant_6   : 4;
6111 	unsigned int	exp_lo   : 4;
6112 	unsigned int	mant_5   : 8;
6113 	unsigned int	mant_4   : 8;
6114 
6115 	unsigned int	mant_lo  : 32;
6116 };
6117 
6118 /* Vax double precision floating point */
6119 struct  vax_double {
6120 	unsigned int	mantissa1 : 7;
6121 	unsigned int	exp       : 8;
6122 	unsigned int	sign      : 1;
6123 	unsigned int	mantissa2 : 16;
6124 	unsigned int	mantissa3 : 16;
6125 	unsigned int	mantissa4 : 16;
6126 };
6127 
6128 #define VAX_DBL_BIAS	0x81
6129 #define IEEE_DBL_BIAS	0x3ff
6130 #define MASK(nbits)	((1 << nbits) - 1)
6131 
6132 static const struct dbl_limits {
6133 	struct	vax_double d;
6134 	struct	ieee_double ieee;
6135 } dbl_limits[2] = {
6136 	{{ 0x7f, 0xff, 0x0, 0xffff, 0xffff, 0xffff },	/* Max Vax */
6137 	{ 0x7f, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0}}, /* Max IEEE */
6138 	{{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},		/* Min Vax */
6139 	{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}, /* Min IEEE */
6140 };
6141 
6142 
6143 #line 1807
6144 static void
get_ix_double(const void * xp,double * ip)6145 get_ix_double(const void *xp, double *ip)
6146 {
6147 	struct vax_double *const vdp =
6148 #line 1810
6149 			 (struct vax_double *)ip;
6150 #line 1810
6151 	const struct ieee_double *const idp =
6152 #line 1810
6153 			 (const struct ieee_double *) xp;
6154 #line 1810
6155 	{
6156 #line 1810
6157 		const struct dbl_limits *lim;
6158 #line 1810
6159 		int ii;
6160 #line 1810
6161 		for (ii = 0, lim = dbl_limits;
6162 #line 1810
6163 			ii < sizeof(dbl_limits)/sizeof(struct dbl_limits);
6164 #line 1810
6165 			ii++, lim++)
6166 #line 1810
6167 		{
6168 #line 1810
6169 			if ((idp->mant_lo == lim->ieee.mant_lo)
6170 #line 1810
6171 				&& (idp->mant_4 == lim->ieee.mant_4)
6172 #line 1810
6173 				&& (idp->mant_5 == lim->ieee.mant_5)
6174 #line 1810
6175 				&& (idp->mant_6 == lim->ieee.mant_6)
6176 #line 1810
6177 				&& (idp->exp_lo == lim->ieee.exp_lo)
6178 #line 1810
6179 				&& (idp->exp_hi == lim->ieee.exp_hi)
6180 #line 1810
6181 				)
6182 #line 1810
6183 			{
6184 #line 1810
6185 				*vdp = lim->d;
6186 #line 1810
6187 				goto doneit;
6188 #line 1810
6189 			}
6190 #line 1810
6191 		}
6192 #line 1810
6193 	}
6194 #line 1810
6195 	{
6196 #line 1810
6197 		unsigned exp = idp->exp_hi << 4 | idp->exp_lo;
6198 #line 1810
6199 		vdp->exp = exp - IEEE_DBL_BIAS + VAX_DBL_BIAS;
6200 #line 1810
6201 	}
6202 #line 1810
6203 	{
6204 #line 1810
6205 		unsigned mant_hi = ((idp->mant_6 << 16)
6206 #line 1810
6207 				 | (idp->mant_5 << 8)
6208 #line 1810
6209 				 | idp->mant_4);
6210 #line 1810
6211 		unsigned mant_lo = SWAP4(idp->mant_lo);
6212 #line 1810
6213 		vdp->mantissa1 = (mant_hi >> 13);
6214 #line 1810
6215 		vdp->mantissa2 = ((mant_hi & MASK(13)) << 3)
6216 #line 1810
6217 				| (mant_lo >> 29);
6218 #line 1810
6219 		vdp->mantissa3 = (mant_lo >> 13);
6220 #line 1810
6221 		vdp->mantissa4 = (mant_lo << 3);
6222 #line 1810
6223 	}
6224 #line 1810
6225 	doneit:
6226 #line 1810
6227 		vdp->sign = idp->sign;
6228 #line 1810
6229 
6230 }
6231 
6232 
6233 #line 1880
6234 static void
put_ix_double(void * xp,const double * ip)6235 put_ix_double(void *xp, const double *ip)
6236 {
6237 	const struct vax_double *const vdp =
6238 #line 1883
6239 			(const struct vax_double *)ip;
6240 #line 1883
6241 	struct ieee_double *const idp =
6242 #line 1883
6243 			 (struct ieee_double *) xp;
6244 #line 1883
6245 
6246 #line 1883
6247 	if ((vdp->mantissa4 > (dbl_limits[0].d.mantissa4 - 3)) &&
6248 #line 1883
6249 		(vdp->mantissa3 == dbl_limits[0].d.mantissa3) &&
6250 #line 1883
6251 		(vdp->mantissa2 == dbl_limits[0].d.mantissa2) &&
6252 #line 1883
6253 		(vdp->mantissa1 == dbl_limits[0].d.mantissa1) &&
6254 #line 1883
6255 		(vdp->exp == dbl_limits[0].d.exp))
6256 #line 1883
6257 	{
6258 #line 1883
6259 		*idp = dbl_limits[0].ieee;
6260 #line 1883
6261 		goto shipit;
6262 #line 1883
6263 	}
6264 #line 1883
6265 	if ((vdp->mantissa4 == dbl_limits[1].d.mantissa4) &&
6266 #line 1883
6267 		(vdp->mantissa3 == dbl_limits[1].d.mantissa3) &&
6268 #line 1883
6269 		(vdp->mantissa2 == dbl_limits[1].d.mantissa2) &&
6270 #line 1883
6271 		(vdp->mantissa1 == dbl_limits[1].d.mantissa1) &&
6272 #line 1883
6273 		(vdp->exp == dbl_limits[1].d.exp))
6274 #line 1883
6275 	{
6276 #line 1883
6277 		*idp = dbl_limits[1].ieee;
6278 #line 1883
6279 		goto shipit;
6280 #line 1883
6281 	}
6282 #line 1883
6283 
6284 #line 1883
6285 	{
6286 #line 1883
6287 		unsigned exp = vdp->exp - VAX_DBL_BIAS + IEEE_DBL_BIAS;
6288 #line 1883
6289 
6290 #line 1883
6291 		unsigned mant_lo = ((vdp->mantissa2 & MASK(3)) << 29) |
6292 #line 1883
6293 			(vdp->mantissa3 << 13) |
6294 #line 1883
6295 			((vdp->mantissa4 >> 3) & MASK(13));
6296 #line 1883
6297 
6298 #line 1883
6299 		unsigned mant_hi = (vdp->mantissa1 << 13)
6300 #line 1883
6301 				 | (vdp->mantissa2 >> 3);
6302 #line 1883
6303 
6304 #line 1883
6305 		if ((vdp->mantissa4 & 7) > 4)
6306 #line 1883
6307 		{
6308 #line 1883
6309 			/* round up */
6310 #line 1883
6311 			mant_lo++;
6312 #line 1883
6313 			if (mant_lo == 0)
6314 #line 1883
6315 			{
6316 #line 1883
6317 				mant_hi++;
6318 #line 1883
6319 				if (mant_hi > 0xffffff)
6320 #line 1883
6321 				{
6322 #line 1883
6323 					mant_hi = 0;
6324 #line 1883
6325 					exp++;
6326 #line 1883
6327 				}
6328 #line 1883
6329 			}
6330 #line 1883
6331 		}
6332 #line 1883
6333 
6334 #line 1883
6335 		idp->mant_lo = SWAP4(mant_lo);
6336 #line 1883
6337 		idp->mant_6 = mant_hi >> 16;
6338 #line 1883
6339 		idp->mant_5 = (mant_hi & 0xff00) >> 8;
6340 #line 1883
6341 		idp->mant_4 = mant_hi;
6342 #line 1883
6343 		idp->exp_hi = exp >> 4;
6344 #line 1883
6345 		idp->exp_lo = exp;
6346 #line 1883
6347 	}
6348 #line 1883
6349 
6350 #line 1883
6351 	shipit:
6352 #line 1883
6353 		idp->sign = vdp->sign;
6354 #line 1883
6355 
6356 }
6357 
6358 	/* vax */
6359 #elif defined(_CRAY) && !defined(__crayx1)
6360 
6361 static void
get_ix_double(const void * xp,double * ip)6362 get_ix_double(const void *xp, double *ip)
6363 {
6364 	const ieee_double *idp = (const ieee_double *) xp;
6365 	cray_single *csp = (cray_single *) ip;
6366 
6367 	if (idp->exp == 0)
6368 	{
6369 		/* ieee subnormal */
6370 		*ip = (double)idp->mant;
6371 		if (idp->mant != 0)
6372 		{
6373 			csp->exp -= (ieee_double_bias + 51);
6374 		}
6375 	}
6376 	else
6377 	{
6378 		csp->exp  = idp->exp + cs_id_bias + 1;
6379 		csp->mant = idp->mant >> (52 - 48 + 1);
6380 		csp->mant |= (1 << (48 - 1));
6381 	}
6382 	csp->sign = idp->sign;
6383 }
6384 
6385 static void
put_ix_double(void * xp,const double * ip)6386 put_ix_double(void *xp, const double *ip)
6387 {
6388 	ieee_double *idp = (ieee_double *) xp;
6389 	const cray_single *csp = (const cray_single *) ip;
6390 
6391 	int ieee_exp = csp->exp - cs_id_bias -1;
6392 
6393 	idp->sign = csp->sign;
6394 
6395 	if (ieee_exp >= 0x7ff)
6396 	{
6397 		/* NC_ERANGE => ieee Inf */
6398 		idp->exp = 0x7ff;
6399 		idp->mant = 0x0;
6400 	}
6401 	else if (ieee_exp > 0)
6402 	{
6403 		/* normal ieee representation */
6404 		idp->exp  = ieee_exp;
6405 		/* assumes cray rep is in normal form */
6406 		assert(csp->mant & 0x800000000000);
6407 		idp->mant = (((csp->mant << 1) &
6408 				0xffffffffffff) << (52 - 48));
6409 	}
6410 	else if (ieee_exp >= (-(52 -48)))
6411 	{
6412 		/* ieee subnormal, left shift */
6413 		const int lshift = (52 - 48) + ieee_exp;
6414 		idp->mant = csp->mant << lshift;
6415 		idp->exp  = 0;
6416 	}
6417 	else if (ieee_exp >= -52)
6418 	{
6419 		/* ieee subnormal, right shift */
6420 		const int rshift = (- (52 - 48) - ieee_exp);
6421 
6422 		idp->mant = csp->mant >> rshift;
6423 
6424 #if 0
6425 		if (csp->mant & (1 << (rshift -1)))
6426 		{
6427 			/* round up */
6428 			idp->mant++;
6429 		}
6430 #endif
6431 
6432 		idp->exp  = 0;
6433 	}
6434 	else
6435 	{
6436 		/* smaller than ieee can represent */
6437 		idp->exp = 0;
6438 		idp->mant = 0;
6439 	}
6440 }
6441 #else
6442 #error "ix_double implementation"
6443 #endif
6444 
6445 #define ix_double double
6446 
6447 static int
6448 #line 1975
ncx_get_double_schar(const void * xp,schar * ip)6449 ncx_get_double_schar(const void *xp, schar *ip)
6450 #line 1975
6451 {
6452 #line 1975
6453 	ix_double xx = 0;
6454 #line 1975
6455 	get_ix_double(xp, &xx);
6456 #line 1975
6457 	if (xx > (double)SCHAR_MAX || xx < (double)SCHAR_MIN) {
6458 #line 1975
6459 #ifdef ERANGE_FILL
6460 #line 1975
6461             *ip = NC_FILL_BYTE;
6462 #line 1975
6463 #endif
6464 #line 1975
6465             return NC_ERANGE;
6466 #line 1975
6467         }
6468 #line 1975
6469 	*ip = (schar)xx;
6470 #line 1975
6471 	return NC_NOERR;
6472 #line 1975
6473 }
6474 #line 1975
6475 
6476 static int
6477 #line 1976
ncx_get_double_short(const void * xp,short * ip)6478 ncx_get_double_short(const void *xp, short *ip)
6479 #line 1976
6480 {
6481 #line 1976
6482 	ix_double xx = 0;
6483 #line 1976
6484 	get_ix_double(xp, &xx);
6485 #line 1976
6486 	if (xx > (double)SHORT_MAX || xx < (double)SHORT_MIN) {
6487 #line 1976
6488 #ifdef ERANGE_FILL
6489 #line 1976
6490             *ip = NC_FILL_SHORT;
6491 #line 1976
6492 #endif
6493 #line 1976
6494             return NC_ERANGE;
6495 #line 1976
6496         }
6497 #line 1976
6498 	*ip = (short)xx;
6499 #line 1976
6500 	return NC_NOERR;
6501 #line 1976
6502 }
6503 #line 1976
6504 
6505 static int
6506 #line 1977
ncx_get_double_int(const void * xp,int * ip)6507 ncx_get_double_int(const void *xp, int *ip)
6508 #line 1977
6509 {
6510 #line 1977
6511 	ix_double xx = 0;
6512 #line 1977
6513 	get_ix_double(xp, &xx);
6514 #line 1977
6515 	if (xx > (double)INT_MAX || xx < (double)INT_MIN) {
6516 #line 1977
6517 #ifdef ERANGE_FILL
6518 #line 1977
6519             *ip = NC_FILL_INT;
6520 #line 1977
6521 #endif
6522 #line 1977
6523             return NC_ERANGE;
6524 #line 1977
6525         }
6526 #line 1977
6527 	*ip = (int)xx;
6528 #line 1977
6529 	return NC_NOERR;
6530 #line 1977
6531 }
6532 #line 1977
6533 
6534 static int
6535 #line 1978
ncx_get_double_long(const void * xp,long * ip)6536 ncx_get_double_long(const void *xp, long *ip)
6537 #line 1978
6538 {
6539 #line 1978
6540 	ix_double xx = 0;
6541 #line 1978
6542 	get_ix_double(xp, &xx);
6543 #line 1978
6544 	if (xx > (double)LONG_MAX || xx < (double)LONG_MIN) {
6545 #line 1978
6546 #ifdef ERANGE_FILL
6547 #line 1978
6548             *ip = NC_FILL_INT;
6549 #line 1978
6550 #endif
6551 #line 1978
6552             return NC_ERANGE;
6553 #line 1978
6554         }
6555 #line 1978
6556 	*ip = (long)xx;
6557 #line 1978
6558 	return NC_NOERR;
6559 #line 1978
6560 }
6561 #line 1978
6562 
6563 static int
6564 #line 1979
ncx_get_double_longlong(const void * xp,longlong * ip)6565 ncx_get_double_longlong(const void *xp, longlong *ip)
6566 #line 1979
6567 {
6568 #line 1979
6569 	ix_double xx = 0;
6570 #line 1979
6571 	get_ix_double(xp, &xx);
6572 #line 1979
6573 	if (xx == LONGLONG_MAX)      *ip = LONGLONG_MAX;
6574 #line 1979
6575 	else if (xx == LONGLONG_MIN) *ip = LONGLONG_MIN;
6576 #line 1979
6577 	else if (xx > (double)LONGLONG_MAX || xx < (double)LONGLONG_MIN) {
6578 #line 1979
6579 #ifdef ERANGE_FILL
6580 #line 1979
6581             *ip = NC_FILL_INT64;
6582 #line 1979
6583 #endif
6584 #line 1979
6585             return NC_ERANGE;
6586 #line 1979
6587         }
6588 #line 1979
6589 	else *ip = (longlong)xx;
6590 #line 1979
6591 	return NC_NOERR;
6592 #line 1979
6593 }
6594 #line 1979
6595 
6596 static int
6597 #line 1980
ncx_get_double_uchar(const void * xp,uchar * ip)6598 ncx_get_double_uchar(const void *xp, uchar *ip)
6599 #line 1980
6600 {
6601 #line 1980
6602 	ix_double xx = 0;
6603 #line 1980
6604 	get_ix_double(xp, &xx);
6605 #line 1980
6606 	if (xx > (double)UCHAR_MAX || xx < 0) {
6607 #line 1980
6608 #ifdef ERANGE_FILL
6609 #line 1980
6610             *ip = NC_FILL_UBYTE;
6611 #line 1980
6612 #endif
6613 #line 1980
6614             return NC_ERANGE;
6615 #line 1980
6616         }
6617 #line 1980
6618 	*ip = (uchar)xx;
6619 #line 1980
6620 	return NC_NOERR;
6621 #line 1980
6622 }
6623 #line 1980
6624 
6625 static int
6626 #line 1981
ncx_get_double_ushort(const void * xp,ushort * ip)6627 ncx_get_double_ushort(const void *xp, ushort *ip)
6628 #line 1981
6629 {
6630 #line 1981
6631 	ix_double xx = 0;
6632 #line 1981
6633 	get_ix_double(xp, &xx);
6634 #line 1981
6635 	if (xx > (double)USHORT_MAX || xx < 0) {
6636 #line 1981
6637 #ifdef ERANGE_FILL
6638 #line 1981
6639             *ip = NC_FILL_USHORT;
6640 #line 1981
6641 #endif
6642 #line 1981
6643             return NC_ERANGE;
6644 #line 1981
6645         }
6646 #line 1981
6647 	*ip = (ushort)xx;
6648 #line 1981
6649 	return NC_NOERR;
6650 #line 1981
6651 }
6652 #line 1981
6653 
6654 static int
6655 #line 1982
ncx_get_double_uint(const void * xp,uint * ip)6656 ncx_get_double_uint(const void *xp, uint *ip)
6657 #line 1982
6658 {
6659 #line 1982
6660 	ix_double xx = 0;
6661 #line 1982
6662 	get_ix_double(xp, &xx);
6663 #line 1982
6664 	if (xx > (double)UINT_MAX || xx < 0) {
6665 #line 1982
6666 #ifdef ERANGE_FILL
6667 #line 1982
6668             *ip = NC_FILL_UINT;
6669 #line 1982
6670 #endif
6671 #line 1982
6672             return NC_ERANGE;
6673 #line 1982
6674         }
6675 #line 1982
6676 	*ip = (uint)xx;
6677 #line 1982
6678 	return NC_NOERR;
6679 #line 1982
6680 }
6681 #line 1982
6682 
6683 static int
6684 #line 1983
ncx_get_double_ulonglong(const void * xp,ulonglong * ip)6685 ncx_get_double_ulonglong(const void *xp, ulonglong *ip)
6686 #line 1983
6687 {
6688 #line 1983
6689 	ix_double xx = 0;
6690 #line 1983
6691 	get_ix_double(xp, &xx);
6692 #line 1983
6693 	if (xx == ULONGLONG_MAX)      *ip = ULONGLONG_MAX;
6694 #line 1983
6695 	else if (xx > (double)ULONGLONG_MAX || xx < 0) {
6696 #line 1983
6697 #ifdef ERANGE_FILL
6698 #line 1983
6699             *ip = NC_FILL_UINT64;
6700 #line 1983
6701 #endif
6702 #line 1983
6703             return NC_ERANGE;
6704 #line 1983
6705         }
6706 #line 1983
6707 	else *ip = (ulonglong)xx;
6708 #line 1983
6709 	return NC_NOERR;
6710 #line 1983
6711 }
6712 #line 1983
6713 
6714 
6715 static int
ncx_get_double_float(const void * xp,float * ip)6716 ncx_get_double_float(const void *xp, float *ip)
6717 {
6718     double xx = 0.0;
6719     get_ix_double(xp, &xx);
6720     if (xx > FLT_MAX) {
6721 #ifdef ERANGE_FILL
6722         *ip = NC_FILL_FLOAT;
6723 #else
6724         *ip = FLT_MAX;
6725 #endif
6726         return NC_ERANGE;
6727     }
6728     if (xx < (-FLT_MAX)) {
6729 #ifdef ERANGE_FILL
6730         *ip = NC_FILL_FLOAT;
6731 #else
6732         *ip = (-FLT_MAX);
6733 #endif
6734         return NC_ERANGE;
6735     }
6736     *ip = (float) xx;
6737     return NC_NOERR;
6738 }
6739 
6740 #if X_SIZEOF_DOUBLE != SIZEOF_DOUBLE  || defined(NO_IEEE_FLOAT)
6741 static int
ncx_get_double_double(const void * xp,double * ip,void * fillp)6742 ncx_get_double_double(const void *xp, double *ip, void *fillp)
6743 {
6744 	/* TODO */
6745 	get_ix_double(xp, ip);
6746 	return NC_NOERR;
6747 }
6748 #endif
6749 
6750 static int
6751 #line 2020
ncx_put_double_schar(void * xp,const schar * ip,void * fillp)6752 ncx_put_double_schar(void *xp, const schar *ip, void *fillp)
6753 #line 2020
6754 {
6755 #line 2020
6756     int err=NC_NOERR;
6757 #line 2020
6758     ix_double xx = NC_FILL_DOUBLE;
6759 #line 2020
6760 
6761 #line 2020
6762 
6763 #line 2020
6764         xx = (ix_double)*ip;
6765 #line 2020
6766 
6767 #line 2020
6768     put_ix_double(xp, &xx);
6769 #line 2020
6770     return err;
6771 #line 2020
6772 }
6773 #line 2020
6774 
6775 static int
6776 #line 2021
ncx_put_double_uchar(void * xp,const uchar * ip,void * fillp)6777 ncx_put_double_uchar(void *xp, const uchar *ip, void *fillp)
6778 #line 2021
6779 {
6780 #line 2021
6781     int err=NC_NOERR;
6782 #line 2021
6783     ix_double xx = NC_FILL_DOUBLE;
6784 #line 2021
6785 
6786 #line 2021
6787 
6788 #line 2021
6789         xx = (ix_double)*ip;
6790 #line 2021
6791 
6792 #line 2021
6793     put_ix_double(xp, &xx);
6794 #line 2021
6795     return err;
6796 #line 2021
6797 }
6798 #line 2021
6799 
6800 static int
6801 #line 2022
ncx_put_double_short(void * xp,const short * ip,void * fillp)6802 ncx_put_double_short(void *xp, const short *ip, void *fillp)
6803 #line 2022
6804 {
6805 #line 2022
6806     int err=NC_NOERR;
6807 #line 2022
6808     ix_double xx = NC_FILL_DOUBLE;
6809 #line 2022
6810 
6811 #line 2022
6812 
6813 #line 2022
6814         xx = (ix_double)*ip;
6815 #line 2022
6816 
6817 #line 2022
6818     put_ix_double(xp, &xx);
6819 #line 2022
6820     return err;
6821 #line 2022
6822 }
6823 #line 2022
6824 
6825 static int
6826 #line 2023
ncx_put_double_ushort(void * xp,const ushort * ip,void * fillp)6827 ncx_put_double_ushort(void *xp, const ushort *ip, void *fillp)
6828 #line 2023
6829 {
6830 #line 2023
6831     int err=NC_NOERR;
6832 #line 2023
6833     ix_double xx = NC_FILL_DOUBLE;
6834 #line 2023
6835 
6836 #line 2023
6837 
6838 #line 2023
6839         xx = (ix_double)*ip;
6840 #line 2023
6841 
6842 #line 2023
6843     put_ix_double(xp, &xx);
6844 #line 2023
6845     return err;
6846 #line 2023
6847 }
6848 #line 2023
6849 
6850 static int
6851 #line 2024
ncx_put_double_int(void * xp,const int * ip,void * fillp)6852 ncx_put_double_int(void *xp, const int *ip, void *fillp)
6853 #line 2024
6854 {
6855 #line 2024
6856     int err=NC_NOERR;
6857 #line 2024
6858     ix_double xx = NC_FILL_DOUBLE;
6859 #line 2024
6860 
6861 #line 2024
6862 
6863 #line 2024
6864         xx = (ix_double)*ip;
6865 #line 2024
6866 
6867 #line 2024
6868     put_ix_double(xp, &xx);
6869 #line 2024
6870     return err;
6871 #line 2024
6872 }
6873 #line 2024
6874 
6875 static int
6876 #line 2025
ncx_put_double_long(void * xp,const long * ip,void * fillp)6877 ncx_put_double_long(void *xp, const long *ip, void *fillp)
6878 #line 2025
6879 {
6880 #line 2025
6881     int err=NC_NOERR;
6882 #line 2025
6883     ix_double xx = NC_FILL_DOUBLE;
6884 #line 2025
6885 
6886 #line 2025
6887 
6888 #line 2025
6889         xx = (ix_double)*ip;
6890 #line 2025
6891 
6892 #line 2025
6893     put_ix_double(xp, &xx);
6894 #line 2025
6895     return err;
6896 #line 2025
6897 }
6898 #line 2025
6899 
6900 static int
6901 #line 2026
ncx_put_double_uint(void * xp,const uint * ip,void * fillp)6902 ncx_put_double_uint(void *xp, const uint *ip, void *fillp)
6903 #line 2026
6904 {
6905 #line 2026
6906     int err=NC_NOERR;
6907 #line 2026
6908     ix_double xx = NC_FILL_DOUBLE;
6909 #line 2026
6910 
6911 #line 2026
6912 
6913 #line 2026
6914         xx = (ix_double)*ip;
6915 #line 2026
6916 
6917 #line 2026
6918     put_ix_double(xp, &xx);
6919 #line 2026
6920     return err;
6921 #line 2026
6922 }
6923 #line 2026
6924 
6925 static int
6926 #line 2027
ncx_put_double_longlong(void * xp,const longlong * ip,void * fillp)6927 ncx_put_double_longlong(void *xp, const longlong *ip, void *fillp)
6928 #line 2027
6929 {
6930 #line 2027
6931     int err=NC_NOERR;
6932 #line 2027
6933     ix_double xx = NC_FILL_DOUBLE;
6934 #line 2027
6935 
6936 #line 2027
6937 
6938 #line 2027
6939         xx = (ix_double)*ip;
6940 #line 2027
6941 
6942 #line 2027
6943     put_ix_double(xp, &xx);
6944 #line 2027
6945     return err;
6946 #line 2027
6947 }
6948 #line 2027
6949 
6950 static int
6951 #line 2028
ncx_put_double_ulonglong(void * xp,const ulonglong * ip,void * fillp)6952 ncx_put_double_ulonglong(void *xp, const ulonglong *ip, void *fillp)
6953 #line 2028
6954 {
6955 #line 2028
6956     int err=NC_NOERR;
6957 #line 2028
6958     ix_double xx = NC_FILL_DOUBLE;
6959 #line 2028
6960 
6961 #line 2028
6962 
6963 #line 2028
6964         xx = (ix_double)*ip;
6965 #line 2028
6966 
6967 #line 2028
6968     put_ix_double(xp, &xx);
6969 #line 2028
6970     return err;
6971 #line 2028
6972 }
6973 #line 2028
6974 
6975 
6976 static int
ncx_put_double_float(void * xp,const float * ip,void * fillp)6977 ncx_put_double_float(void *xp, const float *ip, void *fillp)
6978 {
6979     int err=NC_NOERR;
6980     double xx = NC_FILL_DOUBLE;
6981 #if 1	/* TODO: figure this out (if condition below will never be true)*/
6982     if ((double)(*ip) > X_DOUBLE_MAX || (double)(*ip) < X_DOUBLE_MIN) {
6983 
6984 #line 2037
6985 #ifdef ERANGE_FILL
6986 #line 2037
6987             if (fillp != NULL) memcpy(&xx, fillp, 8);
6988 #line 2037
6989 #endif
6990         err = NC_ERANGE;
6991     }
6992 #ifdef ERANGE_FILL
6993     else
6994 #endif
6995 #endif
6996         xx = (double) *ip;
6997 
6998     put_ix_double(xp, &xx);
6999     return err;
7000 }
7001 
7002 #if X_SIZEOF_DOUBLE != SIZEOF_DOUBLE  || defined(NO_IEEE_FLOAT)
7003 static int
ncx_put_double_double(void * xp,const double * ip,void * fillp)7004 ncx_put_double_double(void *xp, const double *ip, void *fillp)
7005 {
7006     int err=NC_NOERR;
7007     double *_ip = ip;
7008 #ifdef NO_IEEE_FLOAT
7009 #ifdef ERANGE_FILL
7010     double tmp=NC_FILL_DOUBLE;
7011 #endif
7012     if (*ip > X_DOUBLE_MAX || *ip < X_DOUBLE_MIN) {
7013 
7014 #line 2061
7015 #ifdef ERANGE_FILL
7016 #line 2061
7017             if (fillp != NULL) memcpy(&tmp, fillp, 8);
7018 #line 2061
7019 #endif
7020 #ifdef ERANGE_FILL
7021         _ip = &tmp;
7022 #endif
7023         err = NC_ERANGE;
7024     }
7025 #endif
7026     put_ix_double(xp, _ip);
7027     return err;
7028 }
7029 #endif
7030 
7031 
7032 /* external NC_INT64 --------------------------------------------------------*/
7033 
7034 #if SHORT_MAX == X_INT64_MAX
7035 typedef short ix_int64;
7036 #define SIZEOF_IX_INT64 SIZEOF_SHORT
7037 #define IX_INT64_MAX SHORT_MAX
7038 #elif LONG_LONG_MAX  >= X_INT64_MAX
7039 typedef longlong ix_int64;
7040 #define SIZEOF_IX_INT64 SIZEOF_LONGLONG
7041 #define IX_INT64_MAX LONG_LONG_MAX
7042 #elif LONG_MAX  >= X_INT64_MAX
7043 typedef long ix_int64;
7044 #define SIZEOF_IX_INT64 SIZEOF_LONG
7045 #define IX_INT64_MAX LONG_MAX
7046 #else
7047 #error "ix_int64 implementation"
7048 #endif
7049 
7050 
7051 static void
get_ix_int64(const void * xp,ix_int64 * ip)7052 get_ix_int64(const void *xp, ix_int64 *ip)
7053 {
7054     const uchar *cp = (const uchar *) xp;
7055 
7056     *ip  = ((ix_int64)(*cp++) << 56);
7057     *ip |= ((ix_int64)(*cp++) << 48);
7058     *ip |= ((ix_int64)(*cp++) << 40);
7059     *ip |= ((ix_int64)(*cp++) << 32);
7060     *ip |= ((ix_int64)(*cp++) << 24);
7061     *ip |= ((ix_int64)(*cp++) << 16);
7062     *ip |= ((ix_int64)(*cp++) <<  8);
7063     *ip |=  (ix_int64)*cp;
7064 }
7065 
7066 static void
put_ix_int64(void * xp,const ix_int64 * ip)7067 put_ix_int64(void *xp, const ix_int64 *ip)
7068 {
7069     uchar *cp = (uchar *) xp;
7070 
7071     *cp++ = (uchar)((*ip) >> 56);
7072     *cp++ = (uchar)(((*ip) & 0x00ff000000000000LL) >> 48);
7073     *cp++ = (uchar)(((*ip) & 0x0000ff0000000000LL) >> 40);
7074     *cp++ = (uchar)(((*ip) & 0x000000ff00000000LL) >> 32);
7075     *cp++ = (uchar)(((*ip) & 0x00000000ff000000LL) >> 24);
7076     *cp++ = (uchar)(((*ip) & 0x0000000000ff0000LL) >> 16);
7077     *cp++ = (uchar)(((*ip) & 0x000000000000ff00LL) >>  8);
7078     *cp   = (uchar)( (*ip) & 0x00000000000000ffLL);
7079 }
7080 
7081 #if X_SIZEOF_INT64 != SIZEOF_LONGLONG
7082 static int
7083 #line 2124
ncx_get_longlong_longlong(const void * xp,longlong * ip)7084 ncx_get_longlong_longlong(const void *xp, longlong *ip)
7085 #line 2124
7086 {
7087 #line 2124
7088     int err=NC_NOERR;
7089 #line 2124
7090 #if SIZEOF_IX_INT64 == SIZEOF_LONGLONG && IX_INT64_MAX == LONGLONG_MAX
7091 #line 2124
7092     get_ix_int64(xp, (ix_int64 *)ip);
7093 #line 2124
7094 #else
7095 #line 2124
7096     ix_int64 xx = 0;
7097 #line 2124
7098     get_ix_int64(xp, &xx);
7099 #line 2124
7100 
7101 #line 2124
7102 #if IX_INT64_MAX > LONGLONG_MAX
7103 #line 2124
7104     if (xx > LONGLONG_MAX || xx < LONGLONG_MIN) {
7105 #line 2124
7106 #ifdef ERANGE_FILL
7107 #line 2124
7108         *ip = NC_FILL_INT64;
7109 #line 2124
7110         return NC_ERANGE;
7111 #line 2124
7112 #else
7113 #line 2124
7114         err = NC_ERANGE;
7115 #line 2124
7116 #endif
7117 #line 2124
7118     }
7119 #line 2124
7120 #endif
7121 #line 2124
7122 
7123 #line 2124
7124 
7125 #line 2124
7126     *ip = (longlong) xx;
7127 #line 2124
7128 #endif
7129 #line 2124
7130     return err;
7131 #line 2124
7132 }
7133 #line 2124
7134 
7135 #endif
7136 static int
7137 #line 2126
ncx_get_longlong_schar(const void * xp,schar * ip)7138 ncx_get_longlong_schar(const void *xp, schar *ip)
7139 #line 2126
7140 {
7141 #line 2126
7142     int err=NC_NOERR;
7143 #line 2126
7144     ix_int64 xx = 0;
7145 #line 2126
7146     get_ix_int64(xp, &xx);
7147 #line 2126
7148 
7149 #line 2126
7150 #if IX_INT64_MAX > SCHAR_MAX
7151 #line 2126
7152     if (xx > SCHAR_MAX || xx < SCHAR_MIN) {
7153 #line 2126
7154 #ifdef ERANGE_FILL
7155 #line 2126
7156         *ip = NC_FILL_BYTE;
7157 #line 2126
7158         return NC_ERANGE;
7159 #line 2126
7160 #else
7161 #line 2126
7162         err = NC_ERANGE;
7163 #line 2126
7164 #endif
7165 #line 2126
7166     }
7167 #line 2126
7168 #endif
7169 #line 2126
7170 
7171 #line 2126
7172 
7173 #line 2126
7174     *ip = (schar) xx;
7175 #line 2126
7176     return err;
7177 #line 2126
7178 }
7179 #line 2126
7180 
7181 static int
7182 #line 2127
ncx_get_longlong_short(const void * xp,short * ip)7183 ncx_get_longlong_short(const void *xp, short *ip)
7184 #line 2127
7185 {
7186 #line 2127
7187     int err=NC_NOERR;
7188 #line 2127
7189 #if SIZEOF_IX_INT64 == SIZEOF_SHORT && IX_INT64_MAX == SHORT_MAX
7190 #line 2127
7191     get_ix_int64(xp, (ix_int64 *)ip);
7192 #line 2127
7193 #else
7194 #line 2127
7195     ix_int64 xx = 0;
7196 #line 2127
7197     get_ix_int64(xp, &xx);
7198 #line 2127
7199 
7200 #line 2127
7201 #if IX_INT64_MAX > SHORT_MAX
7202 #line 2127
7203     if (xx > SHORT_MAX || xx < SHORT_MIN) {
7204 #line 2127
7205 #ifdef ERANGE_FILL
7206 #line 2127
7207         *ip = NC_FILL_SHORT;
7208 #line 2127
7209         return NC_ERANGE;
7210 #line 2127
7211 #else
7212 #line 2127
7213         err = NC_ERANGE;
7214 #line 2127
7215 #endif
7216 #line 2127
7217     }
7218 #line 2127
7219 #endif
7220 #line 2127
7221 
7222 #line 2127
7223 
7224 #line 2127
7225     *ip = (short) xx;
7226 #line 2127
7227 #endif
7228 #line 2127
7229     return err;
7230 #line 2127
7231 }
7232 #line 2127
7233 
7234 static int
7235 #line 2128
ncx_get_longlong_int(const void * xp,int * ip)7236 ncx_get_longlong_int(const void *xp, int *ip)
7237 #line 2128
7238 {
7239 #line 2128
7240     int err=NC_NOERR;
7241 #line 2128
7242 #if SIZEOF_IX_INT64 == SIZEOF_INT && IX_INT64_MAX == INT_MAX
7243 #line 2128
7244     get_ix_int64(xp, (ix_int64 *)ip);
7245 #line 2128
7246 #else
7247 #line 2128
7248     ix_int64 xx = 0;
7249 #line 2128
7250     get_ix_int64(xp, &xx);
7251 #line 2128
7252 
7253 #line 2128
7254 #if IX_INT64_MAX > INT_MAX
7255 #line 2128
7256     if (xx > INT_MAX || xx < INT_MIN) {
7257 #line 2128
7258 #ifdef ERANGE_FILL
7259 #line 2128
7260         *ip = NC_FILL_INT;
7261 #line 2128
7262         return NC_ERANGE;
7263 #line 2128
7264 #else
7265 #line 2128
7266         err = NC_ERANGE;
7267 #line 2128
7268 #endif
7269 #line 2128
7270     }
7271 #line 2128
7272 #endif
7273 #line 2128
7274 
7275 #line 2128
7276 
7277 #line 2128
7278     *ip = (int) xx;
7279 #line 2128
7280 #endif
7281 #line 2128
7282     return err;
7283 #line 2128
7284 }
7285 #line 2128
7286 
7287 static int
7288 #line 2129
ncx_get_longlong_long(const void * xp,long * ip)7289 ncx_get_longlong_long(const void *xp, long *ip)
7290 #line 2129
7291 {
7292 #line 2129
7293     int err=NC_NOERR;
7294 #line 2129
7295 #if SIZEOF_IX_INT64 == SIZEOF_LONG && IX_INT64_MAX == LONG_MAX
7296 #line 2129
7297     get_ix_int64(xp, (ix_int64 *)ip);
7298 #line 2129
7299 #else
7300 #line 2129
7301     ix_int64 xx = 0;
7302 #line 2129
7303     get_ix_int64(xp, &xx);
7304 #line 2129
7305 
7306 #line 2129
7307 #if IX_INT64_MAX > LONG_MAX
7308 #line 2129
7309     if (xx > LONG_MAX || xx < LONG_MIN) {
7310 #line 2129
7311 #ifdef ERANGE_FILL
7312 #line 2129
7313         *ip = NC_FILL_INT;
7314 #line 2129
7315         return NC_ERANGE;
7316 #line 2129
7317 #else
7318 #line 2129
7319         err = NC_ERANGE;
7320 #line 2129
7321 #endif
7322 #line 2129
7323     }
7324 #line 2129
7325 #endif
7326 #line 2129
7327 
7328 #line 2129
7329 
7330 #line 2129
7331     *ip = (long) xx;
7332 #line 2129
7333 #endif
7334 #line 2129
7335     return err;
7336 #line 2129
7337 }
7338 #line 2129
7339 
7340 static int
7341 #line 2130
ncx_get_longlong_ushort(const void * xp,ushort * ip)7342 ncx_get_longlong_ushort(const void *xp, ushort *ip)
7343 #line 2130
7344 {
7345 #line 2130
7346     int err=NC_NOERR;
7347 #line 2130
7348     ix_int64 xx = 0;
7349 #line 2130
7350     get_ix_int64(xp, &xx);
7351 #line 2130
7352 
7353 #line 2130
7354 #if IX_INT64_MAX > USHORT_MAX
7355 #line 2130
7356     if (xx > USHORT_MAX) {
7357 #line 2130
7358 #ifdef ERANGE_FILL
7359 #line 2130
7360         *ip = NC_FILL_USHORT;
7361 #line 2130
7362         return NC_ERANGE;
7363 #line 2130
7364 #else
7365 #line 2130
7366         err = NC_ERANGE;
7367 #line 2130
7368 #endif
7369 #line 2130
7370     }
7371 #line 2130
7372 #endif
7373 #line 2130
7374 
7375 #line 2130
7376     if (xx < 0) {
7377 #line 2130
7378 #ifdef ERANGE_FILL
7379 #line 2130
7380         *ip = NC_FILL_USHORT;
7381 #line 2130
7382         return NC_ERANGE;
7383 #line 2130
7384 #else
7385 #line 2130
7386         err = NC_ERANGE; /* because ip is unsigned */
7387 #line 2130
7388 #endif
7389 #line 2130
7390     }
7391 #line 2130
7392     *ip = (ushort) xx;
7393 #line 2130
7394     return err;
7395 #line 2130
7396 }
7397 #line 2130
7398 
7399 static int
7400 #line 2131
ncx_get_longlong_uchar(const void * xp,uchar * ip)7401 ncx_get_longlong_uchar(const void *xp, uchar *ip)
7402 #line 2131
7403 {
7404 #line 2131
7405     int err=NC_NOERR;
7406 #line 2131
7407     ix_int64 xx = 0;
7408 #line 2131
7409     get_ix_int64(xp, &xx);
7410 #line 2131
7411 
7412 #line 2131
7413 #if IX_INT64_MAX > UCHAR_MAX
7414 #line 2131
7415     if (xx > UCHAR_MAX) {
7416 #line 2131
7417 #ifdef ERANGE_FILL
7418 #line 2131
7419         *ip = NC_FILL_UBYTE;
7420 #line 2131
7421         return NC_ERANGE;
7422 #line 2131
7423 #else
7424 #line 2131
7425         err = NC_ERANGE;
7426 #line 2131
7427 #endif
7428 #line 2131
7429     }
7430 #line 2131
7431 #endif
7432 #line 2131
7433 
7434 #line 2131
7435     if (xx < 0) {
7436 #line 2131
7437 #ifdef ERANGE_FILL
7438 #line 2131
7439         *ip = NC_FILL_UBYTE;
7440 #line 2131
7441         return NC_ERANGE;
7442 #line 2131
7443 #else
7444 #line 2131
7445         err = NC_ERANGE; /* because ip is unsigned */
7446 #line 2131
7447 #endif
7448 #line 2131
7449     }
7450 #line 2131
7451     *ip = (uchar) xx;
7452 #line 2131
7453     return err;
7454 #line 2131
7455 }
7456 #line 2131
7457 
7458 static int
7459 #line 2132
ncx_get_longlong_uint(const void * xp,uint * ip)7460 ncx_get_longlong_uint(const void *xp, uint *ip)
7461 #line 2132
7462 {
7463 #line 2132
7464     int err=NC_NOERR;
7465 #line 2132
7466     ix_int64 xx = 0;
7467 #line 2132
7468     get_ix_int64(xp, &xx);
7469 #line 2132
7470 
7471 #line 2132
7472 #if IX_INT64_MAX > UINT_MAX
7473 #line 2132
7474     if (xx > UINT_MAX) {
7475 #line 2132
7476 #ifdef ERANGE_FILL
7477 #line 2132
7478         *ip = NC_FILL_UINT;
7479 #line 2132
7480         return NC_ERANGE;
7481 #line 2132
7482 #else
7483 #line 2132
7484         err = NC_ERANGE;
7485 #line 2132
7486 #endif
7487 #line 2132
7488     }
7489 #line 2132
7490 #endif
7491 #line 2132
7492 
7493 #line 2132
7494     if (xx < 0) {
7495 #line 2132
7496 #ifdef ERANGE_FILL
7497 #line 2132
7498         *ip = NC_FILL_UINT;
7499 #line 2132
7500         return NC_ERANGE;
7501 #line 2132
7502 #else
7503 #line 2132
7504         err = NC_ERANGE; /* because ip is unsigned */
7505 #line 2132
7506 #endif
7507 #line 2132
7508     }
7509 #line 2132
7510     *ip = (uint) xx;
7511 #line 2132
7512     return err;
7513 #line 2132
7514 }
7515 #line 2132
7516 
7517 static int
7518 #line 2133
ncx_get_longlong_ulonglong(const void * xp,ulonglong * ip)7519 ncx_get_longlong_ulonglong(const void *xp, ulonglong *ip)
7520 #line 2133
7521 {
7522 #line 2133
7523     int err=NC_NOERR;
7524 #line 2133
7525     ix_int64 xx = 0;
7526 #line 2133
7527     get_ix_int64(xp, &xx);
7528 #line 2133
7529 
7530 #line 2133
7531 #if IX_INT64_MAX > ULONGLONG_MAX
7532 #line 2133
7533     if (xx > ULONGLONG_MAX) {
7534 #line 2133
7535 #ifdef ERANGE_FILL
7536 #line 2133
7537         *ip = NC_FILL_UINT64;
7538 #line 2133
7539         return NC_ERANGE;
7540 #line 2133
7541 #else
7542 #line 2133
7543         err = NC_ERANGE;
7544 #line 2133
7545 #endif
7546 #line 2133
7547     }
7548 #line 2133
7549 #endif
7550 #line 2133
7551 
7552 #line 2133
7553     if (xx < 0) {
7554 #line 2133
7555 #ifdef ERANGE_FILL
7556 #line 2133
7557         *ip = NC_FILL_UINT64;
7558 #line 2133
7559         return NC_ERANGE;
7560 #line 2133
7561 #else
7562 #line 2133
7563         err = NC_ERANGE; /* because ip is unsigned */
7564 #line 2133
7565 #endif
7566 #line 2133
7567     }
7568 #line 2133
7569     *ip = (ulonglong) xx;
7570 #line 2133
7571     return err;
7572 #line 2133
7573 }
7574 #line 2133
7575 
7576 static int
7577 #line 2134
ncx_get_longlong_float(const void * xp,float * ip)7578 ncx_get_longlong_float(const void *xp, float *ip)
7579 #line 2134
7580 {
7581 #line 2134
7582 	ix_int64 xx = 0;
7583 #line 2134
7584 	get_ix_int64(xp, &xx);
7585 #line 2134
7586 	*ip = (float)xx;
7587 #line 2134
7588 	return NC_NOERR;
7589 #line 2134
7590 }
7591 #line 2134
7592 
7593 static int
7594 #line 2135
ncx_get_longlong_double(const void * xp,double * ip)7595 ncx_get_longlong_double(const void *xp, double *ip)
7596 #line 2135
7597 {
7598 #line 2135
7599 	ix_int64 xx = 0;
7600 #line 2135
7601 	get_ix_int64(xp, &xx);
7602 #line 2135
7603 	*ip = (double)xx;
7604 #line 2135
7605 	return NC_NOERR;
7606 #line 2135
7607 }
7608 #line 2135
7609 
7610 
7611 #if X_SIZEOF_INT64 != SIZEOF_LONGLONG
7612 static int
7613 #line 2138
ncx_put_longlong_longlong(void * xp,const longlong * ip,void * fillp)7614 ncx_put_longlong_longlong(void *xp, const longlong *ip, void *fillp)
7615 #line 2138
7616 {
7617 #line 2138
7618     int err=NC_NOERR;
7619 #line 2138
7620 #if SIZEOF_IX_INT64 == SIZEOF_LONGLONG && IX_INT64_MAX == LONGLONG_MAX
7621 #line 2138
7622     put_ix_int64(xp, (const ix_int64 *)ip);
7623 #line 2138
7624 #else
7625 #line 2138
7626     ix_int64 xx = NC_FILL_INT64;
7627 #line 2138
7628 
7629 #line 2138
7630 #if IX_INT64_MAX < LONGLONG_MAX
7631 #line 2138
7632     if (*ip > IX_INT64_MAX || *ip < X_INT64_MIN) {
7633 #line 2138
7634 
7635 #line 2138
7636 #ifdef ERANGE_FILL
7637 #line 2138
7638             if (fillp != NULL) memcpy(&xx, fillp, 8);
7639 #line 2138
7640 #endif
7641 #line 2138
7642         err = NC_ERANGE;
7643 #line 2138
7644     }
7645 #line 2138
7646 #ifdef ERANGE_FILL
7647 #line 2138
7648     else
7649 #line 2138
7650 #endif
7651 #line 2138
7652 #endif
7653 #line 2138
7654         xx = (ix_int64)*ip;
7655 #line 2138
7656 
7657 #line 2138
7658     put_ix_int64(xp, &xx);
7659 #line 2138
7660 #endif
7661 #line 2138
7662     return err;
7663 #line 2138
7664 }
7665 #line 2138
7666 
7667 #endif
7668 static int
7669 #line 2140
ncx_put_longlong_schar(void * xp,const schar * ip,void * fillp)7670 ncx_put_longlong_schar(void *xp, const schar *ip, void *fillp)
7671 #line 2140
7672 {
7673 #line 2140
7674     int err=NC_NOERR;
7675 #line 2140
7676     ix_int64 xx = NC_FILL_INT64;
7677 #line 2140
7678 
7679 #line 2140
7680 #if IX_INT64_MAX < SCHAR_MAX
7681 #line 2140
7682     if (*ip > IX_INT64_MAX || *ip < X_INT64_MIN) {
7683 #line 2140
7684 
7685 #line 2140
7686 #ifdef ERANGE_FILL
7687 #line 2140
7688             if (fillp != NULL) memcpy(&xx, fillp, 8);
7689 #line 2140
7690 #endif
7691 #line 2140
7692         err = NC_ERANGE;
7693 #line 2140
7694     }
7695 #line 2140
7696 #ifdef ERANGE_FILL
7697 #line 2140
7698     else
7699 #line 2140
7700 #endif
7701 #line 2140
7702 #endif
7703 #line 2140
7704         xx = (ix_int64)*ip;
7705 #line 2140
7706 
7707 #line 2140
7708     put_ix_int64(xp, &xx);
7709 #line 2140
7710     return err;
7711 #line 2140
7712 }
7713 #line 2140
7714 
7715 static int
7716 #line 2141
ncx_put_longlong_short(void * xp,const short * ip,void * fillp)7717 ncx_put_longlong_short(void *xp, const short *ip, void *fillp)
7718 #line 2141
7719 {
7720 #line 2141
7721     int err=NC_NOERR;
7722 #line 2141
7723 #if SIZEOF_IX_INT64 == SIZEOF_SHORT && IX_INT64_MAX == SHORT_MAX
7724 #line 2141
7725     put_ix_int64(xp, (const ix_int64 *)ip);
7726 #line 2141
7727 #else
7728 #line 2141
7729     ix_int64 xx = NC_FILL_INT64;
7730 #line 2141
7731 
7732 #line 2141
7733 #if IX_INT64_MAX < SHORT_MAX
7734 #line 2141
7735     if (*ip > IX_INT64_MAX || *ip < X_INT64_MIN) {
7736 #line 2141
7737 
7738 #line 2141
7739 #ifdef ERANGE_FILL
7740 #line 2141
7741             if (fillp != NULL) memcpy(&xx, fillp, 8);
7742 #line 2141
7743 #endif
7744 #line 2141
7745         err = NC_ERANGE;
7746 #line 2141
7747     }
7748 #line 2141
7749 #ifdef ERANGE_FILL
7750 #line 2141
7751     else
7752 #line 2141
7753 #endif
7754 #line 2141
7755 #endif
7756 #line 2141
7757         xx = (ix_int64)*ip;
7758 #line 2141
7759 
7760 #line 2141
7761     put_ix_int64(xp, &xx);
7762 #line 2141
7763 #endif
7764 #line 2141
7765     return err;
7766 #line 2141
7767 }
7768 #line 2141
7769 
7770 static int
7771 #line 2142
ncx_put_longlong_int(void * xp,const int * ip,void * fillp)7772 ncx_put_longlong_int(void *xp, const int *ip, void *fillp)
7773 #line 2142
7774 {
7775 #line 2142
7776     int err=NC_NOERR;
7777 #line 2142
7778 #if SIZEOF_IX_INT64 == SIZEOF_INT && IX_INT64_MAX == INT_MAX
7779 #line 2142
7780     put_ix_int64(xp, (const ix_int64 *)ip);
7781 #line 2142
7782 #else
7783 #line 2142
7784     ix_int64 xx = NC_FILL_INT64;
7785 #line 2142
7786 
7787 #line 2142
7788 #if IX_INT64_MAX < INT_MAX
7789 #line 2142
7790     if (*ip > IX_INT64_MAX || *ip < X_INT64_MIN) {
7791 #line 2142
7792 
7793 #line 2142
7794 #ifdef ERANGE_FILL
7795 #line 2142
7796             if (fillp != NULL) memcpy(&xx, fillp, 8);
7797 #line 2142
7798 #endif
7799 #line 2142
7800         err = NC_ERANGE;
7801 #line 2142
7802     }
7803 #line 2142
7804 #ifdef ERANGE_FILL
7805 #line 2142
7806     else
7807 #line 2142
7808 #endif
7809 #line 2142
7810 #endif
7811 #line 2142
7812         xx = (ix_int64)*ip;
7813 #line 2142
7814 
7815 #line 2142
7816     put_ix_int64(xp, &xx);
7817 #line 2142
7818 #endif
7819 #line 2142
7820     return err;
7821 #line 2142
7822 }
7823 #line 2142
7824 
7825 static int
7826 #line 2143
ncx_put_longlong_long(void * xp,const long * ip,void * fillp)7827 ncx_put_longlong_long(void *xp, const long *ip, void *fillp)
7828 #line 2143
7829 {
7830 #line 2143
7831     int err=NC_NOERR;
7832 #line 2143
7833 #if SIZEOF_IX_INT64 == SIZEOF_LONG && IX_INT64_MAX == LONG_MAX
7834 #line 2143
7835     put_ix_int64(xp, (const ix_int64 *)ip);
7836 #line 2143
7837 #else
7838 #line 2143
7839     ix_int64 xx = NC_FILL_INT64;
7840 #line 2143
7841 
7842 #line 2143
7843 #if IX_INT64_MAX < LONG_MAX
7844 #line 2143
7845     if (*ip > IX_INT64_MAX || *ip < X_INT64_MIN) {
7846 #line 2143
7847 
7848 #line 2143
7849 #ifdef ERANGE_FILL
7850 #line 2143
7851             if (fillp != NULL) memcpy(&xx, fillp, 8);
7852 #line 2143
7853 #endif
7854 #line 2143
7855         err = NC_ERANGE;
7856 #line 2143
7857     }
7858 #line 2143
7859 #ifdef ERANGE_FILL
7860 #line 2143
7861     else
7862 #line 2143
7863 #endif
7864 #line 2143
7865 #endif
7866 #line 2143
7867         xx = (ix_int64)*ip;
7868 #line 2143
7869 
7870 #line 2143
7871     put_ix_int64(xp, &xx);
7872 #line 2143
7873 #endif
7874 #line 2143
7875     return err;
7876 #line 2143
7877 }
7878 #line 2143
7879 
7880 static int
7881 #line 2144
ncx_put_longlong_ushort(void * xp,const ushort * ip,void * fillp)7882 ncx_put_longlong_ushort(void *xp, const ushort *ip, void *fillp)
7883 #line 2144
7884 {
7885 #line 2144
7886     int err=NC_NOERR;
7887 #line 2144
7888     ix_int64 xx = NC_FILL_INT64;
7889 #line 2144
7890 
7891 #line 2144
7892 #if IX_INT64_MAX < USHORT_MAX
7893 #line 2144
7894     if (*ip > IX_INT64_MAX) {
7895 #line 2144
7896 
7897 #line 2144
7898 #ifdef ERANGE_FILL
7899 #line 2144
7900             if (fillp != NULL) memcpy(&xx, fillp, 8);
7901 #line 2144
7902 #endif
7903 #line 2144
7904         err = NC_ERANGE;
7905 #line 2144
7906     }
7907 #line 2144
7908 #ifdef ERANGE_FILL
7909 #line 2144
7910     else
7911 #line 2144
7912 #endif
7913 #line 2144
7914 #endif
7915 #line 2144
7916         xx = (ix_int64)*ip;
7917 #line 2144
7918 
7919 #line 2144
7920     put_ix_int64(xp, &xx);
7921 #line 2144
7922     return err;
7923 #line 2144
7924 }
7925 #line 2144
7926 
7927 static int
7928 #line 2145
ncx_put_longlong_uchar(void * xp,const uchar * ip,void * fillp)7929 ncx_put_longlong_uchar(void *xp, const uchar *ip, void *fillp)
7930 #line 2145
7931 {
7932 #line 2145
7933     int err=NC_NOERR;
7934 #line 2145
7935     ix_int64 xx = NC_FILL_INT64;
7936 #line 2145
7937 
7938 #line 2145
7939 #if IX_INT64_MAX < UCHAR_MAX
7940 #line 2145
7941     if (*ip > IX_INT64_MAX) {
7942 #line 2145
7943 
7944 #line 2145
7945 #ifdef ERANGE_FILL
7946 #line 2145
7947             if (fillp != NULL) memcpy(&xx, fillp, 8);
7948 #line 2145
7949 #endif
7950 #line 2145
7951         err = NC_ERANGE;
7952 #line 2145
7953     }
7954 #line 2145
7955 #ifdef ERANGE_FILL
7956 #line 2145
7957     else
7958 #line 2145
7959 #endif
7960 #line 2145
7961 #endif
7962 #line 2145
7963         xx = (ix_int64)*ip;
7964 #line 2145
7965 
7966 #line 2145
7967     put_ix_int64(xp, &xx);
7968 #line 2145
7969     return err;
7970 #line 2145
7971 }
7972 #line 2145
7973 
7974 static int
7975 #line 2146
ncx_put_longlong_uint(void * xp,const uint * ip,void * fillp)7976 ncx_put_longlong_uint(void *xp, const uint *ip, void *fillp)
7977 #line 2146
7978 {
7979 #line 2146
7980     int err=NC_NOERR;
7981 #line 2146
7982     ix_int64 xx = NC_FILL_INT64;
7983 #line 2146
7984 
7985 #line 2146
7986 #if IX_INT64_MAX < UINT_MAX
7987 #line 2146
7988     if (*ip > IX_INT64_MAX) {
7989 #line 2146
7990 
7991 #line 2146
7992 #ifdef ERANGE_FILL
7993 #line 2146
7994             if (fillp != NULL) memcpy(&xx, fillp, 8);
7995 #line 2146
7996 #endif
7997 #line 2146
7998         err = NC_ERANGE;
7999 #line 2146
8000     }
8001 #line 2146
8002 #ifdef ERANGE_FILL
8003 #line 2146
8004     else
8005 #line 2146
8006 #endif
8007 #line 2146
8008 #endif
8009 #line 2146
8010         xx = (ix_int64)*ip;
8011 #line 2146
8012 
8013 #line 2146
8014     put_ix_int64(xp, &xx);
8015 #line 2146
8016     return err;
8017 #line 2146
8018 }
8019 #line 2146
8020 
8021 static int
8022 #line 2147
ncx_put_longlong_ulonglong(void * xp,const ulonglong * ip,void * fillp)8023 ncx_put_longlong_ulonglong(void *xp, const ulonglong *ip, void *fillp)
8024 #line 2147
8025 {
8026 #line 2147
8027     int err=NC_NOERR;
8028 #line 2147
8029     ix_int64 xx = NC_FILL_INT64;
8030 #line 2147
8031 
8032 #line 2147
8033 #if IX_INT64_MAX < ULONGLONG_MAX
8034 #line 2147
8035     if (*ip > IX_INT64_MAX) {
8036 #line 2147
8037 
8038 #line 2147
8039 #ifdef ERANGE_FILL
8040 #line 2147
8041             if (fillp != NULL) memcpy(&xx, fillp, 8);
8042 #line 2147
8043 #endif
8044 #line 2147
8045         err = NC_ERANGE;
8046 #line 2147
8047     }
8048 #line 2147
8049 #ifdef ERANGE_FILL
8050 #line 2147
8051     else
8052 #line 2147
8053 #endif
8054 #line 2147
8055 #endif
8056 #line 2147
8057         xx = (ix_int64)*ip;
8058 #line 2147
8059 
8060 #line 2147
8061     put_ix_int64(xp, &xx);
8062 #line 2147
8063     return err;
8064 #line 2147
8065 }
8066 #line 2147
8067 
8068 static int
8069 #line 2148
ncx_put_longlong_float(void * xp,const float * ip,void * fillp)8070 ncx_put_longlong_float(void *xp, const float *ip, void *fillp)
8071 #line 2148
8072 {
8073 #line 2148
8074     int err=NC_NOERR;
8075 #line 2148
8076     ix_int64 xx = NC_FILL_INT64;
8077 #line 2148
8078 
8079 #line 2148
8080     if (*ip > (double)X_INT64_MAX || *ip < (double)X_INT64_MIN) {
8081 #line 2148
8082 
8083 #line 2148
8084 #ifdef ERANGE_FILL
8085 #line 2148
8086             if (fillp != NULL) memcpy(&xx, fillp, 8);
8087 #line 2148
8088 #endif
8089 #line 2148
8090         err = NC_ERANGE;
8091 #line 2148
8092     }
8093 #line 2148
8094 #ifdef ERANGE_FILL
8095 #line 2148
8096     else
8097 #line 2148
8098 #endif
8099 #line 2148
8100         xx = (ix_int64)*ip;
8101 #line 2148
8102 
8103 #line 2148
8104     put_ix_int64(xp, &xx);
8105 #line 2148
8106     return err;
8107 #line 2148
8108 }
8109 #line 2148
8110 
8111 static int
8112 #line 2149
ncx_put_longlong_double(void * xp,const double * ip,void * fillp)8113 ncx_put_longlong_double(void *xp, const double *ip, void *fillp)
8114 #line 2149
8115 {
8116 #line 2149
8117     int err=NC_NOERR;
8118 #line 2149
8119     ix_int64 xx = NC_FILL_INT64;
8120 #line 2149
8121 
8122 #line 2149
8123     if (*ip > X_INT64_MAX || *ip < X_INT64_MIN) {
8124 #line 2149
8125 
8126 #line 2149
8127 #ifdef ERANGE_FILL
8128 #line 2149
8129             if (fillp != NULL) memcpy(&xx, fillp, 8);
8130 #line 2149
8131 #endif
8132 #line 2149
8133         err = NC_ERANGE;
8134 #line 2149
8135     }
8136 #line 2149
8137 #ifdef ERANGE_FILL
8138 #line 2149
8139     else
8140 #line 2149
8141 #endif
8142 #line 2149
8143         xx = (ix_int64)*ip;
8144 #line 2149
8145 
8146 #line 2149
8147     put_ix_int64(xp, &xx);
8148 #line 2149
8149     return err;
8150 #line 2149
8151 }
8152 #line 2149
8153 
8154 
8155 
8156 /* external NC_UINT64 -------------------------------------------------------*/
8157 
8158 #if USHORT_MAX == X_UINT64_MAX
8159 typedef ushort ix_uint64;
8160 #define SIZEOF_IX_UINT64 SIZEOF_USHORT
8161 #define IX_UINT64_MAX USHORT_MAX
8162 #elif ULONG_LONG_MAX  >= X_UINT64_MAX
8163 typedef ulonglong ix_uint64;
8164 #define SIZEOF_IX_UINT64 SIZEOF_ULONGLONG
8165 #define IX_UINT64_MAX ULONG_LONG_MAX
8166 #elif ULONG_MAX  >= X_UINT64_MAX
8167 typedef ulong ix_uint64;
8168 #define SIZEOF_IX_UINT64 SIZEOF_ULONG
8169 #define IX_UINT64_MAX ULONG_MAX
8170 #else
8171 #error "ix_uint64 implementation"
8172 #endif
8173 
8174 
8175 static void
get_ix_uint64(const void * xp,ix_uint64 * ip)8176 get_ix_uint64(const void *xp, ix_uint64 *ip)
8177 {
8178     const uchar *cp = (const uchar *) xp;
8179 
8180     *ip  = ((ix_uint64)(*cp++) << 56);
8181     *ip |= ((ix_uint64)(*cp++) << 48);
8182     *ip |= ((ix_uint64)(*cp++) << 40);
8183     *ip |= ((ix_uint64)(*cp++) << 32);
8184     *ip |= ((ix_uint64)(*cp++) << 24);
8185     *ip |= ((ix_uint64)(*cp++) << 16);
8186     *ip |= ((ix_uint64)(*cp++) <<  8);
8187     *ip |=  (ix_uint64)*cp;
8188 }
8189 
8190 static void
put_ix_uint64(void * xp,const ix_uint64 * ip)8191 put_ix_uint64(void *xp, const ix_uint64 *ip)
8192 {
8193     uchar *cp = (uchar *) xp;
8194 
8195     *cp++ = (uchar)((*ip) >> 56);
8196     *cp++ = (uchar)(((*ip) & 0x00ff000000000000ULL) >> 48);
8197     *cp++ = (uchar)(((*ip) & 0x0000ff0000000000ULL) >> 40);
8198     *cp++ = (uchar)(((*ip) & 0x000000ff00000000ULL) >> 32);
8199     *cp++ = (uchar)(((*ip) & 0x00000000ff000000ULL) >> 24);
8200     *cp++ = (uchar)(((*ip) & 0x0000000000ff0000ULL) >> 16);
8201     *cp++ = (uchar)(((*ip) & 0x000000000000ff00ULL) >>  8);
8202     *cp   = (uchar)( (*ip) & 0x00000000000000ffULL);
8203 }
8204 
8205 #if X_SIZEOF_UINT64 != SIZEOF_ULONGLONG
8206 static int
8207 #line 2202
ncx_get_ulonglong_ulonglong(const void * xp,ulonglong * ip)8208 ncx_get_ulonglong_ulonglong(const void *xp, ulonglong *ip)
8209 #line 2202
8210 {
8211 #line 2202
8212     int err=NC_NOERR;
8213 #line 2202
8214 #if SIZEOF_IX_UINT64 == SIZEOF_ULONGLONG && IX_UINT64_MAX == ULONGLONG_MAX
8215 #line 2202
8216     get_ix_uint64(xp, (ix_uint64 *)ip);
8217 #line 2202
8218 #else
8219 #line 2202
8220     ix_uint64 xx = 0;
8221 #line 2202
8222     get_ix_uint64(xp, &xx);
8223 #line 2202
8224 
8225 #line 2202
8226 #if IX_UINT64_MAX > ULONGLONG_MAX
8227 #line 2202
8228     if (xx > ULONGLONG_MAX) {
8229 #line 2202
8230 #ifdef ERANGE_FILL
8231 #line 2202
8232         *ip = NC_FILL_UINT64;
8233 #line 2202
8234         return NC_ERANGE;
8235 #line 2202
8236 #else
8237 #line 2202
8238         err = NC_ERANGE;
8239 #line 2202
8240 #endif
8241 #line 2202
8242     }
8243 #line 2202
8244 #endif
8245 #line 2202
8246 
8247 #line 2202
8248 
8249 #line 2202
8250     *ip = (ulonglong) xx;
8251 #line 2202
8252 #endif
8253 #line 2202
8254     return err;
8255 #line 2202
8256 }
8257 #line 2202
8258 
8259 #endif
8260 static int
8261 #line 2204
ncx_get_ulonglong_schar(const void * xp,schar * ip)8262 ncx_get_ulonglong_schar(const void *xp, schar *ip)
8263 #line 2204
8264 {
8265 #line 2204
8266     int err=NC_NOERR;
8267 #line 2204
8268     ix_uint64 xx = 0;
8269 #line 2204
8270     get_ix_uint64(xp, &xx);
8271 #line 2204
8272 
8273 #line 2204
8274 #if IX_UINT64_MAX > SCHAR_MAX
8275 #line 2204
8276     if (xx > SCHAR_MAX) {
8277 #line 2204
8278 #ifdef ERANGE_FILL
8279 #line 2204
8280         *ip = NC_FILL_BYTE;
8281 #line 2204
8282         return NC_ERANGE;
8283 #line 2204
8284 #else
8285 #line 2204
8286         err = NC_ERANGE;
8287 #line 2204
8288 #endif
8289 #line 2204
8290     }
8291 #line 2204
8292 #endif
8293 #line 2204
8294 
8295 #line 2204
8296 
8297 #line 2204
8298     *ip = (schar) xx;
8299 #line 2204
8300     return err;
8301 #line 2204
8302 }
8303 #line 2204
8304 
8305 static int
8306 #line 2205
ncx_get_ulonglong_short(const void * xp,short * ip)8307 ncx_get_ulonglong_short(const void *xp, short *ip)
8308 #line 2205
8309 {
8310 #line 2205
8311     int err=NC_NOERR;
8312 #line 2205
8313     ix_uint64 xx = 0;
8314 #line 2205
8315     get_ix_uint64(xp, &xx);
8316 #line 2205
8317 
8318 #line 2205
8319 #if IX_UINT64_MAX > SHORT_MAX
8320 #line 2205
8321     if (xx > SHORT_MAX) {
8322 #line 2205
8323 #ifdef ERANGE_FILL
8324 #line 2205
8325         *ip = NC_FILL_SHORT;
8326 #line 2205
8327         return NC_ERANGE;
8328 #line 2205
8329 #else
8330 #line 2205
8331         err = NC_ERANGE;
8332 #line 2205
8333 #endif
8334 #line 2205
8335     }
8336 #line 2205
8337 #endif
8338 #line 2205
8339 
8340 #line 2205
8341 
8342 #line 2205
8343     *ip = (short) xx;
8344 #line 2205
8345     return err;
8346 #line 2205
8347 }
8348 #line 2205
8349 
8350 static int
8351 #line 2206
ncx_get_ulonglong_int(const void * xp,int * ip)8352 ncx_get_ulonglong_int(const void *xp, int *ip)
8353 #line 2206
8354 {
8355 #line 2206
8356     int err=NC_NOERR;
8357 #line 2206
8358     ix_uint64 xx = 0;
8359 #line 2206
8360     get_ix_uint64(xp, &xx);
8361 #line 2206
8362 
8363 #line 2206
8364 #if IX_UINT64_MAX > INT_MAX
8365 #line 2206
8366     if (xx > INT_MAX) {
8367 #line 2206
8368 #ifdef ERANGE_FILL
8369 #line 2206
8370         *ip = NC_FILL_INT;
8371 #line 2206
8372         return NC_ERANGE;
8373 #line 2206
8374 #else
8375 #line 2206
8376         err = NC_ERANGE;
8377 #line 2206
8378 #endif
8379 #line 2206
8380     }
8381 #line 2206
8382 #endif
8383 #line 2206
8384 
8385 #line 2206
8386 
8387 #line 2206
8388     *ip = (int) xx;
8389 #line 2206
8390     return err;
8391 #line 2206
8392 }
8393 #line 2206
8394 
8395 static int
8396 #line 2207
ncx_get_ulonglong_long(const void * xp,long * ip)8397 ncx_get_ulonglong_long(const void *xp, long *ip)
8398 #line 2207
8399 {
8400 #line 2207
8401     int err=NC_NOERR;
8402 #line 2207
8403     ix_uint64 xx = 0;
8404 #line 2207
8405     get_ix_uint64(xp, &xx);
8406 #line 2207
8407 
8408 #line 2207
8409 #if IX_UINT64_MAX > LONG_MAX
8410 #line 2207
8411     if (xx > LONG_MAX) {
8412 #line 2207
8413 #ifdef ERANGE_FILL
8414 #line 2207
8415         *ip = NC_FILL_INT;
8416 #line 2207
8417         return NC_ERANGE;
8418 #line 2207
8419 #else
8420 #line 2207
8421         err = NC_ERANGE;
8422 #line 2207
8423 #endif
8424 #line 2207
8425     }
8426 #line 2207
8427 #endif
8428 #line 2207
8429 
8430 #line 2207
8431 
8432 #line 2207
8433     *ip = (long) xx;
8434 #line 2207
8435     return err;
8436 #line 2207
8437 }
8438 #line 2207
8439 
8440 static int
8441 #line 2208
ncx_get_ulonglong_longlong(const void * xp,longlong * ip)8442 ncx_get_ulonglong_longlong(const void *xp, longlong *ip)
8443 #line 2208
8444 {
8445 #line 2208
8446     int err=NC_NOERR;
8447 #line 2208
8448     ix_uint64 xx = 0;
8449 #line 2208
8450     get_ix_uint64(xp, &xx);
8451 #line 2208
8452 
8453 #line 2208
8454 #if IX_UINT64_MAX > LONGLONG_MAX
8455 #line 2208
8456     if (xx > LONGLONG_MAX) {
8457 #line 2208
8458 #ifdef ERANGE_FILL
8459 #line 2208
8460         *ip = NC_FILL_INT64;
8461 #line 2208
8462         return NC_ERANGE;
8463 #line 2208
8464 #else
8465 #line 2208
8466         err = NC_ERANGE;
8467 #line 2208
8468 #endif
8469 #line 2208
8470     }
8471 #line 2208
8472 #endif
8473 #line 2208
8474 
8475 #line 2208
8476 
8477 #line 2208
8478     *ip = (longlong) xx;
8479 #line 2208
8480     return err;
8481 #line 2208
8482 }
8483 #line 2208
8484 
8485 static int
8486 #line 2209
ncx_get_ulonglong_ushort(const void * xp,ushort * ip)8487 ncx_get_ulonglong_ushort(const void *xp, ushort *ip)
8488 #line 2209
8489 {
8490 #line 2209
8491     int err=NC_NOERR;
8492 #line 2209
8493 #if SIZEOF_IX_UINT64 == SIZEOF_USHORT && IX_UINT64_MAX == USHORT_MAX
8494 #line 2209
8495     get_ix_uint64(xp, (ix_uint64 *)ip);
8496 #line 2209
8497 #else
8498 #line 2209
8499     ix_uint64 xx = 0;
8500 #line 2209
8501     get_ix_uint64(xp, &xx);
8502 #line 2209
8503 
8504 #line 2209
8505 #if IX_UINT64_MAX > USHORT_MAX
8506 #line 2209
8507     if (xx > USHORT_MAX) {
8508 #line 2209
8509 #ifdef ERANGE_FILL
8510 #line 2209
8511         *ip = NC_FILL_USHORT;
8512 #line 2209
8513         return NC_ERANGE;
8514 #line 2209
8515 #else
8516 #line 2209
8517         err = NC_ERANGE;
8518 #line 2209
8519 #endif
8520 #line 2209
8521     }
8522 #line 2209
8523 #endif
8524 #line 2209
8525 
8526 #line 2209
8527 
8528 #line 2209
8529     *ip = (ushort) xx;
8530 #line 2209
8531 #endif
8532 #line 2209
8533     return err;
8534 #line 2209
8535 }
8536 #line 2209
8537 
8538 static int
8539 #line 2210
ncx_get_ulonglong_uchar(const void * xp,uchar * ip)8540 ncx_get_ulonglong_uchar(const void *xp, uchar *ip)
8541 #line 2210
8542 {
8543 #line 2210
8544     int err=NC_NOERR;
8545 #line 2210
8546 #if SIZEOF_IX_UINT64 == SIZEOF_UCHAR && IX_UINT64_MAX == UCHAR_MAX
8547 #line 2210
8548     get_ix_uint64(xp, (ix_uint64 *)ip);
8549 #line 2210
8550 #else
8551 #line 2210
8552     ix_uint64 xx = 0;
8553 #line 2210
8554     get_ix_uint64(xp, &xx);
8555 #line 2210
8556 
8557 #line 2210
8558 #if IX_UINT64_MAX > UCHAR_MAX
8559 #line 2210
8560     if (xx > UCHAR_MAX) {
8561 #line 2210
8562 #ifdef ERANGE_FILL
8563 #line 2210
8564         *ip = NC_FILL_UBYTE;
8565 #line 2210
8566         return NC_ERANGE;
8567 #line 2210
8568 #else
8569 #line 2210
8570         err = NC_ERANGE;
8571 #line 2210
8572 #endif
8573 #line 2210
8574     }
8575 #line 2210
8576 #endif
8577 #line 2210
8578 
8579 #line 2210
8580 
8581 #line 2210
8582     *ip = (uchar) xx;
8583 #line 2210
8584 #endif
8585 #line 2210
8586     return err;
8587 #line 2210
8588 }
8589 #line 2210
8590 
8591 static int
8592 #line 2211
ncx_get_ulonglong_uint(const void * xp,uint * ip)8593 ncx_get_ulonglong_uint(const void *xp, uint *ip)
8594 #line 2211
8595 {
8596 #line 2211
8597     int err=NC_NOERR;
8598 #line 2211
8599 #if SIZEOF_IX_UINT64 == SIZEOF_UINT && IX_UINT64_MAX == UINT_MAX
8600 #line 2211
8601     get_ix_uint64(xp, (ix_uint64 *)ip);
8602 #line 2211
8603 #else
8604 #line 2211
8605     ix_uint64 xx = 0;
8606 #line 2211
8607     get_ix_uint64(xp, &xx);
8608 #line 2211
8609 
8610 #line 2211
8611 #if IX_UINT64_MAX > UINT_MAX
8612 #line 2211
8613     if (xx > UINT_MAX) {
8614 #line 2211
8615 #ifdef ERANGE_FILL
8616 #line 2211
8617         *ip = NC_FILL_UINT;
8618 #line 2211
8619         return NC_ERANGE;
8620 #line 2211
8621 #else
8622 #line 2211
8623         err = NC_ERANGE;
8624 #line 2211
8625 #endif
8626 #line 2211
8627     }
8628 #line 2211
8629 #endif
8630 #line 2211
8631 
8632 #line 2211
8633 
8634 #line 2211
8635     *ip = (uint) xx;
8636 #line 2211
8637 #endif
8638 #line 2211
8639     return err;
8640 #line 2211
8641 }
8642 #line 2211
8643 
8644 static int
8645 #line 2212
ncx_get_ulonglong_float(const void * xp,float * ip)8646 ncx_get_ulonglong_float(const void *xp, float *ip)
8647 #line 2212
8648 {
8649 #line 2212
8650 	ix_uint64 xx = 0;
8651 #line 2212
8652 	get_ix_uint64(xp, &xx);
8653 #line 2212
8654 	*ip = (float)xx;
8655 #line 2212
8656 	return NC_NOERR;
8657 #line 2212
8658 }
8659 #line 2212
8660 
8661 static int
8662 #line 2213
ncx_get_ulonglong_double(const void * xp,double * ip)8663 ncx_get_ulonglong_double(const void *xp, double *ip)
8664 #line 2213
8665 {
8666 #line 2213
8667 	ix_uint64 xx = 0;
8668 #line 2213
8669 	get_ix_uint64(xp, &xx);
8670 #line 2213
8671 	*ip = (double)xx;
8672 #line 2213
8673 	return NC_NOERR;
8674 #line 2213
8675 }
8676 #line 2213
8677 
8678 
8679 #if X_SIZEOF_UINT64 != SIZEOF_ULONGLONG
8680 static int
8681 #line 2216
ncx_put_ulonglong_ulonglong(void * xp,const ulonglong * ip,void * fillp)8682 ncx_put_ulonglong_ulonglong(void *xp, const ulonglong *ip, void *fillp)
8683 #line 2216
8684 {
8685 #line 2216
8686     int err=NC_NOERR;
8687 #line 2216
8688 #if SIZEOF_IX_UINT64 == SIZEOF_ULONGLONG && IX_UINT64_MAX == ULONGLONG_MAX
8689 #line 2216
8690     put_ix_uint64(xp, (const ix_uint64 *)ip);
8691 #line 2216
8692 #else
8693 #line 2216
8694     ix_uint64 xx = NC_FILL_UINT64;
8695 #line 2216
8696 
8697 #line 2216
8698 #if IX_UINT64_MAX < ULONGLONG_MAX
8699 #line 2216
8700     if (*ip > IX_UINT64_MAX) {
8701 #line 2216
8702 
8703 #line 2216
8704 #ifdef ERANGE_FILL
8705 #line 2216
8706             if (fillp != NULL) memcpy(&xx, fillp, 8);
8707 #line 2216
8708 #endif
8709 #line 2216
8710         err = NC_ERANGE;
8711 #line 2216
8712     }
8713 #line 2216
8714 #ifdef ERANGE_FILL
8715 #line 2216
8716     else
8717 #line 2216
8718 #endif
8719 #line 2216
8720 #endif
8721 #line 2216
8722         xx = (ix_uint64)*ip;
8723 #line 2216
8724 
8725 #line 2216
8726     put_ix_uint64(xp, &xx);
8727 #line 2216
8728 #endif
8729 #line 2216
8730     return err;
8731 #line 2216
8732 }
8733 #line 2216
8734 
8735 #endif
8736 static int
8737 #line 2218
ncx_put_ulonglong_schar(void * xp,const schar * ip,void * fillp)8738 ncx_put_ulonglong_schar(void *xp, const schar *ip, void *fillp)
8739 #line 2218
8740 {
8741 #line 2218
8742     int err=NC_NOERR;
8743 #line 2218
8744     ix_uint64 xx = NC_FILL_UINT64;
8745 #line 2218
8746 
8747 #line 2218
8748 #if IX_UINT64_MAX < SCHAR_MAX
8749 #line 2218
8750     if (*ip > IX_UINT64_MAX) {
8751 #line 2218
8752 
8753 #line 2218
8754 #ifdef ERANGE_FILL
8755 #line 2218
8756             if (fillp != NULL) memcpy(&xx, fillp, 8);
8757 #line 2218
8758 #endif
8759 #line 2218
8760         err = NC_ERANGE;
8761 #line 2218
8762     }
8763 #line 2218
8764 #ifdef ERANGE_FILL
8765 #line 2218
8766     else
8767 #line 2218
8768 #endif
8769 #line 2218
8770 #endif
8771 #line 2218
8772     if (*ip < 0) {
8773 #line 2218
8774 
8775 #line 2218
8776 #ifdef ERANGE_FILL
8777 #line 2218
8778             if (fillp != NULL) memcpy(&xx, fillp, 8);
8779 #line 2218
8780 #endif
8781 #line 2218
8782         err = NC_ERANGE; /* because xp is unsigned */
8783 #line 2218
8784     }
8785 #line 2218
8786 #ifdef ERANGE_FILL
8787 #line 2218
8788     else
8789 #line 2218
8790 #endif
8791 #line 2218
8792         xx = (ix_uint64)*ip;
8793 #line 2218
8794 
8795 #line 2218
8796     put_ix_uint64(xp, &xx);
8797 #line 2218
8798     return err;
8799 #line 2218
8800 }
8801 #line 2218
8802 
8803 static int
8804 #line 2219
ncx_put_ulonglong_short(void * xp,const short * ip,void * fillp)8805 ncx_put_ulonglong_short(void *xp, const short *ip, void *fillp)
8806 #line 2219
8807 {
8808 #line 2219
8809     int err=NC_NOERR;
8810 #line 2219
8811     ix_uint64 xx = NC_FILL_UINT64;
8812 #line 2219
8813 
8814 #line 2219
8815 #if IX_UINT64_MAX < SHORT_MAX
8816 #line 2219
8817     if (*ip > IX_UINT64_MAX) {
8818 #line 2219
8819 
8820 #line 2219
8821 #ifdef ERANGE_FILL
8822 #line 2219
8823             if (fillp != NULL) memcpy(&xx, fillp, 8);
8824 #line 2219
8825 #endif
8826 #line 2219
8827         err = NC_ERANGE;
8828 #line 2219
8829     }
8830 #line 2219
8831 #ifdef ERANGE_FILL
8832 #line 2219
8833     else
8834 #line 2219
8835 #endif
8836 #line 2219
8837 #endif
8838 #line 2219
8839     if (*ip < 0) {
8840 #line 2219
8841 
8842 #line 2219
8843 #ifdef ERANGE_FILL
8844 #line 2219
8845             if (fillp != NULL) memcpy(&xx, fillp, 8);
8846 #line 2219
8847 #endif
8848 #line 2219
8849         err = NC_ERANGE; /* because xp is unsigned */
8850 #line 2219
8851     }
8852 #line 2219
8853 #ifdef ERANGE_FILL
8854 #line 2219
8855     else
8856 #line 2219
8857 #endif
8858 #line 2219
8859         xx = (ix_uint64)*ip;
8860 #line 2219
8861 
8862 #line 2219
8863     put_ix_uint64(xp, &xx);
8864 #line 2219
8865     return err;
8866 #line 2219
8867 }
8868 #line 2219
8869 
8870 static int
8871 #line 2220
ncx_put_ulonglong_int(void * xp,const int * ip,void * fillp)8872 ncx_put_ulonglong_int(void *xp, const int *ip, void *fillp)
8873 #line 2220
8874 {
8875 #line 2220
8876     int err=NC_NOERR;
8877 #line 2220
8878     ix_uint64 xx = NC_FILL_UINT64;
8879 #line 2220
8880 
8881 #line 2220
8882 #if IX_UINT64_MAX < INT_MAX
8883 #line 2220
8884     if (*ip > IX_UINT64_MAX) {
8885 #line 2220
8886 
8887 #line 2220
8888 #ifdef ERANGE_FILL
8889 #line 2220
8890             if (fillp != NULL) memcpy(&xx, fillp, 8);
8891 #line 2220
8892 #endif
8893 #line 2220
8894         err = NC_ERANGE;
8895 #line 2220
8896     }
8897 #line 2220
8898 #ifdef ERANGE_FILL
8899 #line 2220
8900     else
8901 #line 2220
8902 #endif
8903 #line 2220
8904 #endif
8905 #line 2220
8906     if (*ip < 0) {
8907 #line 2220
8908 
8909 #line 2220
8910 #ifdef ERANGE_FILL
8911 #line 2220
8912             if (fillp != NULL) memcpy(&xx, fillp, 8);
8913 #line 2220
8914 #endif
8915 #line 2220
8916         err = NC_ERANGE; /* because xp is unsigned */
8917 #line 2220
8918     }
8919 #line 2220
8920 #ifdef ERANGE_FILL
8921 #line 2220
8922     else
8923 #line 2220
8924 #endif
8925 #line 2220
8926         xx = (ix_uint64)*ip;
8927 #line 2220
8928 
8929 #line 2220
8930     put_ix_uint64(xp, &xx);
8931 #line 2220
8932     return err;
8933 #line 2220
8934 }
8935 #line 2220
8936 
8937 static int
8938 #line 2221
ncx_put_ulonglong_long(void * xp,const long * ip,void * fillp)8939 ncx_put_ulonglong_long(void *xp, const long *ip, void *fillp)
8940 #line 2221
8941 {
8942 #line 2221
8943     int err=NC_NOERR;
8944 #line 2221
8945     ix_uint64 xx = NC_FILL_UINT64;
8946 #line 2221
8947 
8948 #line 2221
8949 #if IX_UINT64_MAX < LONG_MAX
8950 #line 2221
8951     if (*ip > IX_UINT64_MAX) {
8952 #line 2221
8953 
8954 #line 2221
8955 #ifdef ERANGE_FILL
8956 #line 2221
8957             if (fillp != NULL) memcpy(&xx, fillp, 8);
8958 #line 2221
8959 #endif
8960 #line 2221
8961         err = NC_ERANGE;
8962 #line 2221
8963     }
8964 #line 2221
8965 #ifdef ERANGE_FILL
8966 #line 2221
8967     else
8968 #line 2221
8969 #endif
8970 #line 2221
8971 #endif
8972 #line 2221
8973     if (*ip < 0) {
8974 #line 2221
8975 
8976 #line 2221
8977 #ifdef ERANGE_FILL
8978 #line 2221
8979             if (fillp != NULL) memcpy(&xx, fillp, 8);
8980 #line 2221
8981 #endif
8982 #line 2221
8983         err = NC_ERANGE; /* because xp is unsigned */
8984 #line 2221
8985     }
8986 #line 2221
8987 #ifdef ERANGE_FILL
8988 #line 2221
8989     else
8990 #line 2221
8991 #endif
8992 #line 2221
8993         xx = (ix_uint64)*ip;
8994 #line 2221
8995 
8996 #line 2221
8997     put_ix_uint64(xp, &xx);
8998 #line 2221
8999     return err;
9000 #line 2221
9001 }
9002 #line 2221
9003 
9004 static int
9005 #line 2222
ncx_put_ulonglong_longlong(void * xp,const longlong * ip,void * fillp)9006 ncx_put_ulonglong_longlong(void *xp, const longlong *ip, void *fillp)
9007 #line 2222
9008 {
9009 #line 2222
9010     int err=NC_NOERR;
9011 #line 2222
9012     ix_uint64 xx = NC_FILL_UINT64;
9013 #line 2222
9014 
9015 #line 2222
9016 #if IX_UINT64_MAX < LONGLONG_MAX
9017 #line 2222
9018     if (*ip > IX_UINT64_MAX) {
9019 #line 2222
9020 
9021 #line 2222
9022 #ifdef ERANGE_FILL
9023 #line 2222
9024             if (fillp != NULL) memcpy(&xx, fillp, 8);
9025 #line 2222
9026 #endif
9027 #line 2222
9028         err = NC_ERANGE;
9029 #line 2222
9030     }
9031 #line 2222
9032 #ifdef ERANGE_FILL
9033 #line 2222
9034     else
9035 #line 2222
9036 #endif
9037 #line 2222
9038 #endif
9039 #line 2222
9040     if (*ip < 0) {
9041 #line 2222
9042 
9043 #line 2222
9044 #ifdef ERANGE_FILL
9045 #line 2222
9046             if (fillp != NULL) memcpy(&xx, fillp, 8);
9047 #line 2222
9048 #endif
9049 #line 2222
9050         err = NC_ERANGE; /* because xp is unsigned */
9051 #line 2222
9052     }
9053 #line 2222
9054 #ifdef ERANGE_FILL
9055 #line 2222
9056     else
9057 #line 2222
9058 #endif
9059 #line 2222
9060         xx = (ix_uint64)*ip;
9061 #line 2222
9062 
9063 #line 2222
9064     put_ix_uint64(xp, &xx);
9065 #line 2222
9066     return err;
9067 #line 2222
9068 }
9069 #line 2222
9070 
9071 static int
9072 #line 2223
ncx_put_ulonglong_uchar(void * xp,const uchar * ip,void * fillp)9073 ncx_put_ulonglong_uchar(void *xp, const uchar *ip, void *fillp)
9074 #line 2223
9075 {
9076 #line 2223
9077     int err=NC_NOERR;
9078 #line 2223
9079 #if SIZEOF_IX_UINT64 == SIZEOF_UCHAR && IX_UINT64_MAX == UCHAR_MAX
9080 #line 2223
9081     put_ix_uint64(xp, (const ix_uint64 *)ip);
9082 #line 2223
9083 #else
9084 #line 2223
9085     ix_uint64 xx = NC_FILL_UINT64;
9086 #line 2223
9087 
9088 #line 2223
9089 #if IX_UINT64_MAX < UCHAR_MAX
9090 #line 2223
9091     if (*ip > IX_UINT64_MAX) {
9092 #line 2223
9093 
9094 #line 2223
9095 #ifdef ERANGE_FILL
9096 #line 2223
9097             if (fillp != NULL) memcpy(&xx, fillp, 8);
9098 #line 2223
9099 #endif
9100 #line 2223
9101         err = NC_ERANGE;
9102 #line 2223
9103     }
9104 #line 2223
9105 #ifdef ERANGE_FILL
9106 #line 2223
9107     else
9108 #line 2223
9109 #endif
9110 #line 2223
9111 #endif
9112 #line 2223
9113         xx = (ix_uint64)*ip;
9114 #line 2223
9115 
9116 #line 2223
9117     put_ix_uint64(xp, &xx);
9118 #line 2223
9119 #endif
9120 #line 2223
9121     return err;
9122 #line 2223
9123 }
9124 #line 2223
9125 
9126 static int
9127 #line 2224
ncx_put_ulonglong_ushort(void * xp,const ushort * ip,void * fillp)9128 ncx_put_ulonglong_ushort(void *xp, const ushort *ip, void *fillp)
9129 #line 2224
9130 {
9131 #line 2224
9132     int err=NC_NOERR;
9133 #line 2224
9134 #if SIZEOF_IX_UINT64 == SIZEOF_USHORT && IX_UINT64_MAX == USHORT_MAX
9135 #line 2224
9136     put_ix_uint64(xp, (const ix_uint64 *)ip);
9137 #line 2224
9138 #else
9139 #line 2224
9140     ix_uint64 xx = NC_FILL_UINT64;
9141 #line 2224
9142 
9143 #line 2224
9144 #if IX_UINT64_MAX < USHORT_MAX
9145 #line 2224
9146     if (*ip > IX_UINT64_MAX) {
9147 #line 2224
9148 
9149 #line 2224
9150 #ifdef ERANGE_FILL
9151 #line 2224
9152             if (fillp != NULL) memcpy(&xx, fillp, 8);
9153 #line 2224
9154 #endif
9155 #line 2224
9156         err = NC_ERANGE;
9157 #line 2224
9158     }
9159 #line 2224
9160 #ifdef ERANGE_FILL
9161 #line 2224
9162     else
9163 #line 2224
9164 #endif
9165 #line 2224
9166 #endif
9167 #line 2224
9168         xx = (ix_uint64)*ip;
9169 #line 2224
9170 
9171 #line 2224
9172     put_ix_uint64(xp, &xx);
9173 #line 2224
9174 #endif
9175 #line 2224
9176     return err;
9177 #line 2224
9178 }
9179 #line 2224
9180 
9181 static int
9182 #line 2225
ncx_put_ulonglong_uint(void * xp,const uint * ip,void * fillp)9183 ncx_put_ulonglong_uint(void *xp, const uint *ip, void *fillp)
9184 #line 2225
9185 {
9186 #line 2225
9187     int err=NC_NOERR;
9188 #line 2225
9189 #if SIZEOF_IX_UINT64 == SIZEOF_UINT && IX_UINT64_MAX == UINT_MAX
9190 #line 2225
9191     put_ix_uint64(xp, (const ix_uint64 *)ip);
9192 #line 2225
9193 #else
9194 #line 2225
9195     ix_uint64 xx = NC_FILL_UINT64;
9196 #line 2225
9197 
9198 #line 2225
9199 #if IX_UINT64_MAX < UINT_MAX
9200 #line 2225
9201     if (*ip > IX_UINT64_MAX) {
9202 #line 2225
9203 
9204 #line 2225
9205 #ifdef ERANGE_FILL
9206 #line 2225
9207             if (fillp != NULL) memcpy(&xx, fillp, 8);
9208 #line 2225
9209 #endif
9210 #line 2225
9211         err = NC_ERANGE;
9212 #line 2225
9213     }
9214 #line 2225
9215 #ifdef ERANGE_FILL
9216 #line 2225
9217     else
9218 #line 2225
9219 #endif
9220 #line 2225
9221 #endif
9222 #line 2225
9223         xx = (ix_uint64)*ip;
9224 #line 2225
9225 
9226 #line 2225
9227     put_ix_uint64(xp, &xx);
9228 #line 2225
9229 #endif
9230 #line 2225
9231     return err;
9232 #line 2225
9233 }
9234 #line 2225
9235 
9236 static int
9237 #line 2226
ncx_put_ulonglong_float(void * xp,const float * ip,void * fillp)9238 ncx_put_ulonglong_float(void *xp, const float *ip, void *fillp)
9239 #line 2226
9240 {
9241 #line 2226
9242     int err=NC_NOERR;
9243 #line 2226
9244     ix_uint64 xx = NC_FILL_UINT64;
9245 #line 2226
9246 
9247 #line 2226
9248     if (*ip > (double)X_UINT64_MAX || *ip < 0) {
9249 #line 2226
9250 
9251 #line 2226
9252 #ifdef ERANGE_FILL
9253 #line 2226
9254             if (fillp != NULL) memcpy(&xx, fillp, 8);
9255 #line 2226
9256 #endif
9257 #line 2226
9258         err = NC_ERANGE;
9259 #line 2226
9260     }
9261 #line 2226
9262 #ifdef ERANGE_FILL
9263 #line 2226
9264     else
9265 #line 2226
9266 #endif
9267 #line 2226
9268         xx = (ix_uint64)*ip;
9269 #line 2226
9270 
9271 #line 2226
9272     put_ix_uint64(xp, &xx);
9273 #line 2226
9274     return err;
9275 #line 2226
9276 }
9277 #line 2226
9278 
9279 static int
9280 #line 2227
ncx_put_ulonglong_double(void * xp,const double * ip,void * fillp)9281 ncx_put_ulonglong_double(void *xp, const double *ip, void *fillp)
9282 #line 2227
9283 {
9284 #line 2227
9285     int err=NC_NOERR;
9286 #line 2227
9287     ix_uint64 xx = NC_FILL_UINT64;
9288 #line 2227
9289 
9290 #line 2227
9291     if (*ip > X_UINT64_MAX || *ip < 0) {
9292 #line 2227
9293 
9294 #line 2227
9295 #ifdef ERANGE_FILL
9296 #line 2227
9297             if (fillp != NULL) memcpy(&xx, fillp, 8);
9298 #line 2227
9299 #endif
9300 #line 2227
9301         err = NC_ERANGE;
9302 #line 2227
9303     }
9304 #line 2227
9305 #ifdef ERANGE_FILL
9306 #line 2227
9307     else
9308 #line 2227
9309 #endif
9310 #line 2227
9311         xx = (ix_uint64)*ip;
9312 #line 2227
9313 
9314 #line 2227
9315     put_ix_uint64(xp, &xx);
9316 #line 2227
9317     return err;
9318 #line 2227
9319 }
9320 #line 2227
9321 
9322 
9323 
9324 /* x_size_t */
9325 
9326 #if SIZEOF_SIZE_T < X_SIZEOF_SIZE_T
9327 #error "x_size_t implementation"
9328 /* netcdf requires size_t which can hold a values from 0 to 2^32 -1 */
9329 #endif
9330 
9331 int
ncx_put_size_t(void ** xpp,const size_t * ulp)9332 ncx_put_size_t(void **xpp, const size_t *ulp)
9333 {
9334 	/* similar to put_ix_int() */
9335 	uchar *cp = (uchar *) *xpp;
9336 	assert(*ulp <= X_SIZE_MAX);
9337 
9338 	*cp++ = (uchar)((*ulp) >> 24);
9339 	*cp++ = (uchar)(((*ulp) & 0x00ff0000) >> 16);
9340 	*cp++ = (uchar)(((*ulp) & 0x0000ff00) >>  8);
9341 	*cp   = (uchar)((*ulp) & 0x000000ff);
9342 
9343 	*xpp = (void *)((char *)(*xpp) + X_SIZEOF_SIZE_T);
9344 	return NC_NOERR;
9345 }
9346 
9347 int
ncx_get_size_t(const void ** xpp,size_t * ulp)9348 ncx_get_size_t(const void **xpp,  size_t *ulp)
9349 {
9350 	/* similar to get_ix_int */
9351 	const uchar *cp = (const uchar *) *xpp;
9352 
9353 	*ulp  = (unsigned)(*cp++) << 24;
9354 	*ulp |= (*cp++ << 16);
9355 	*ulp |= (*cp++ << 8);
9356 	*ulp |= *cp;
9357 
9358 	*xpp = (const void *)((const char *)(*xpp) + X_SIZEOF_SIZE_T);
9359 	return NC_NOERR;
9360 }
9361 
9362 /* x_off_t */
9363 
9364 int
ncx_put_off_t(void ** xpp,const off_t * lp,size_t sizeof_off_t)9365 ncx_put_off_t(void **xpp, const off_t *lp, size_t sizeof_off_t)
9366 {
9367 	/* similar to put_ix_int() */
9368 	uchar *cp = (uchar *) *xpp;
9369 
9370 	/* No negative offsets stored in netcdf */
9371 	if (*lp < 0) {
9372 	  /* Assume this is an overflow of a 32-bit int... */
9373 	  return NC_ERANGE;
9374 	}
9375 
9376 	assert(sizeof_off_t == 4 || sizeof_off_t == 8);
9377 
9378 	if (sizeof_off_t == 4) {
9379 		*cp++ = (uchar) ((*lp)               >> 24);
9380 		*cp++ = (uchar)(((*lp) & 0x00ff0000) >> 16);
9381 		*cp++ = (uchar)(((*lp) & 0x0000ff00) >>  8);
9382 		*cp   = (uchar)( (*lp) & 0x000000ff);
9383 	} else {
9384 #if SIZEOF_OFF_T == 4
9385 /* Write a 64-bit offset on a system with only a 32-bit offset */
9386 		*cp++ = (uchar)0;
9387 		*cp++ = (uchar)0;
9388 		*cp++ = (uchar)0;
9389 		*cp++ = (uchar)0;
9390 
9391 		*cp++ = (uchar)(((*lp) & 0xff000000) >> 24);
9392 		*cp++ = (uchar)(((*lp) & 0x00ff0000) >> 16);
9393 		*cp++ = (uchar)(((*lp) & 0x0000ff00) >>  8);
9394 		*cp   = (uchar)( (*lp) & 0x000000ff);
9395 #else
9396 		*cp++ = (uchar) ((*lp)                          >> 56);
9397 		*cp++ = (uchar)(((*lp) & 0x00ff000000000000LL) >> 48);
9398 		*cp++ = (uchar)(((*lp) & 0x0000ff0000000000LL) >> 40);
9399 		*cp++ = (uchar)(((*lp) & 0x000000ff00000000LL) >> 32);
9400 		*cp++ = (uchar)(((*lp) & 0x00000000ff000000LL) >> 24);
9401 		*cp++ = (uchar)(((*lp) & 0x0000000000ff0000LL) >> 16);
9402 		*cp++ = (uchar)(((*lp) & 0x000000000000ff00LL) >>  8);
9403 		*cp   = (uchar)( (*lp) & 0x00000000000000ffLL);
9404 #endif
9405 	}
9406 	*xpp = (void *)((char *)(*xpp) + sizeof_off_t);
9407 	return NC_NOERR;
9408 }
9409 
9410 int
ncx_get_off_t(const void ** xpp,off_t * lp,size_t sizeof_off_t)9411 ncx_get_off_t(const void **xpp, off_t *lp, size_t sizeof_off_t)
9412 {
9413 	/* similar to get_ix_int() */
9414 	const uchar *cp = (const uchar *) *xpp;
9415 	assert(sizeof_off_t == 4 || sizeof_off_t == 8);
9416 
9417  	if (sizeof_off_t == 4) {
9418 		*lp =  (off_t)(*cp++ << 24);
9419 		*lp |= (off_t)(*cp++ << 16);
9420 		*lp |= (off_t)(*cp++ <<  8);
9421 		*lp |= (off_t)*cp;
9422 	} else {
9423 #if SIZEOF_OFF_T == 4
9424 /* Read a 64-bit offset on a system with only a 32-bit offset */
9425 /* If the offset overflows, set an error code and return */
9426 		*lp =  ((off_t)(*cp++) << 24);
9427 		*lp |= ((off_t)(*cp++) << 16);
9428 		*lp |= ((off_t)(*cp++) <<  8);
9429 		*lp |= ((off_t)(*cp++));
9430 /*
9431  * lp now contains the upper 32-bits of the 64-bit offset.  if lp is
9432  * not zero, then the dataset is larger than can be represented
9433  * on this system.  Set an error code and return.
9434  */
9435 		if (*lp != 0) {
9436 		  return NC_ERANGE;
9437 		}
9438 
9439 		*lp  = ((off_t)(*cp++) << 24);
9440 		*lp |= ((off_t)(*cp++) << 16);
9441 		*lp |= ((off_t)(*cp++) <<  8);
9442 		*lp |=  (off_t)*cp;
9443 
9444 		if (*lp < 0) {
9445 		  /*
9446 		   * If this fails, then the offset is >2^31, but less
9447 		   * than 2^32 which is not allowed, but is not caught
9448 		   * by the previous check
9449 		   */
9450 		  return NC_ERANGE;
9451 		}
9452 #else
9453 		*lp =  ((off_t)(*cp++) << 56);
9454 		*lp |= ((off_t)(*cp++) << 48);
9455 		*lp |= ((off_t)(*cp++) << 40);
9456 		*lp |= ((off_t)(*cp++) << 32);
9457 		*lp |= ((off_t)(*cp++) << 24);
9458 		*lp |= ((off_t)(*cp++) << 16);
9459 		*lp |= ((off_t)(*cp++) <<  8);
9460 		*lp |=  (off_t)*cp;
9461 #endif
9462 	}
9463 	*xpp = (const void *)((const char *)(*xpp) + sizeof_off_t);
9464 	return NC_NOERR;
9465 }
9466 
9467 /*----< ncx_get_uint32() >------------------------------------------*/
9468 int
ncx_get_uint32(const void ** xpp,uint * ip)9469 ncx_get_uint32(const void **xpp, uint *ip)
9470 {
9471 #ifdef WORDS_BIGENDIAN
9472     /* use memcpy instead of assignment to avoid BUS_ADRALN alignment error on
9473      * some system, such as HPUX */
9474     (void) memcpy(ip, *xpp, SIZEOF_UINT);
9475 #else
9476     const uchar *cp = (const uchar *) *xpp;
9477 
9478     *ip = (uint)(*cp++ << 24);
9479     *ip = (uint)(*ip | (uint)(*cp++ << 16));
9480     *ip = (uint)(*ip | (uint)(*cp++ <<  8));
9481     *ip = (uint)(*ip | *cp);
9482 #endif
9483     /* advance *xpp 4 bytes */
9484     *xpp = (void *)((const char *)(*xpp) + 4);
9485 
9486     return NC_NOERR;
9487 }
9488 
9489 /*----< ncx_get_uint64() >------------------------------------------*/
9490 int
ncx_get_uint64(const void ** xpp,unsigned long long * ullp)9491 ncx_get_uint64(const void **xpp, unsigned long long *ullp)
9492 {
9493 #ifdef WORDS_BIGENDIAN
9494     /* use memcpy instead of assignment to avoid BUS_ADRALN alignment error on
9495      * some system, such as HPUX */
9496     (void) memcpy(ullp, *xpp, SIZEOF_UINT64);
9497 #else
9498     const uchar *cp = (const uchar *) *xpp;
9499 
9500     /* below is the same as calling swap8b(ullp, *xpp) */
9501     *ullp = (unsigned long long)(*cp++) << 56;
9502     *ullp = (unsigned long long)(*ullp | (unsigned long long)(*cp++) << 48);
9503     *ullp = (unsigned long long)(*ullp | (unsigned long long)(*cp++) << 40);
9504     *ullp = (unsigned long long)(*ullp | (unsigned long long)(*cp++) << 32);
9505     *ullp = (unsigned long long)(*ullp | (unsigned long long)(*cp++) << 24);
9506     *ullp = (unsigned long long)(*ullp | (unsigned long long)(*cp++) << 16);
9507     *ullp = (unsigned long long)(*ullp | (unsigned long long)(*cp++) <<  8);
9508     *ullp = (unsigned long long)(*ullp | (unsigned long long)(*cp));
9509 #endif
9510     /* advance *xpp 8 bytes */
9511     *xpp = (void *)((const char *)(*xpp) + 8);
9512 
9513     return NC_NOERR;
9514 }
9515 
9516 /*---< ncx_put_uint32() >-------------------------------------------*/
9517 /* copy the contents of ip (an unsigned 32-bit integer) to xpp in Big Endian
9518  * form and advance *xpp 4 bytes
9519  */
9520 int
ncx_put_uint32(void ** xpp,const unsigned int ip)9521 ncx_put_uint32(void **xpp, const unsigned int ip)
9522 {
9523 #ifdef WORDS_BIGENDIAN
9524     /* use memcpy instead of assignment to avoid BUS_ADRALN alignment error on
9525      * some system, such as HPUX */
9526     (void) memcpy(*xpp, &ip, X_SIZEOF_UINT);
9527 #else
9528     /* bitwise shifts below are to produce an integer in Big Endian */
9529     uchar *cp = (uchar *) *xpp;
9530     *cp++ = (uchar)((ip & 0xff000000) >> 24);
9531     *cp++ = (uchar)((ip & 0x00ff0000) >> 16);
9532     *cp++ = (uchar)((ip & 0x0000ff00) >>  8);
9533     *cp   = (uchar)( ip & 0x000000ff);
9534 #endif
9535     /* advance *xpp 4 bytes */
9536     *xpp  = (void *)((char *)(*xpp) + 4);
9537 
9538     return NC_NOERR;
9539 }
9540 
9541 /*---< ncx_put_uint64() >-------------------------------------------*/
9542 /* copy the contents of ip (an unsigned 64-bit integer) to xpp in Big Endian
9543  * form and advance *xpp 8 bytes
9544  */
9545 int
ncx_put_uint64(void ** xpp,const unsigned long long ip)9546 ncx_put_uint64(void **xpp, const unsigned long long ip)
9547 {
9548 #ifdef WORDS_BIGENDIAN
9549     /* use memcpy instead of assignment to avoid BUS_ADRALN alignment error on
9550      * some system, such as HPUX */
9551     (void) memcpy(*xpp, &ip, X_SIZEOF_UINT64);
9552 #else
9553     uchar *cp = (uchar *) *xpp;
9554     /* below is the same as calling swap8b(*xpp, &ip) */
9555     *cp++ = (uchar) (ip                         >> 56);
9556     *cp++ = (uchar)((ip & 0x00ff000000000000LL) >> 48);
9557     *cp++ = (uchar)((ip & 0x0000ff0000000000LL) >> 40);
9558     *cp++ = (uchar)((ip & 0x000000ff00000000LL) >> 32);
9559     *cp++ = (uchar)((ip & 0x00000000ff000000LL) >> 24);
9560     *cp++ = (uchar)((ip & 0x0000000000ff0000LL) >> 16);
9561     *cp++ = (uchar)((ip & 0x000000000000ff00LL) >>  8);
9562     *cp   = (uchar) (ip & 0x00000000000000ffLL);
9563 #endif
9564     /* advance *xpp 8 bytes */
9565     *xpp  = (void *)((char *)(*xpp) + 8);
9566 
9567     return NC_NOERR;
9568 }
9569 
9570 
9571 /*
9572  * Aggregate numeric conversion functions.
9573  */
9574 #line 2483
9575 
9576 #line 2886
9577 
9578 #line 2892
9579 
9580 /* schar ---------------------------------------------------------------------*/
9581 
9582 #line 2896
9583 int
ncx_getn_schar_schar(const void ** xpp,size_t nelems,schar * tp)9584 ncx_getn_schar_schar(const void **xpp, size_t nelems, schar *tp)
9585 {
9586 		(void) memcpy(tp, *xpp, (size_t)nelems);
9587 #line 2899
9588 	*xpp = (void *)((char *)(*xpp) + nelems);
9589 #line 2899
9590 	return NC_NOERR;
9591 #line 2899
9592 
9593 }
9594 int
9595 #line 2901
ncx_getn_schar_uchar(const void ** xpp,size_t nelems,uchar * tp)9596 ncx_getn_schar_uchar(const void **xpp, size_t nelems, uchar *tp)
9597 #line 2901
9598 {
9599 #line 2901
9600     int status = NC_NOERR;
9601 #line 2901
9602     schar *xp = (schar *)(*xpp);
9603 #line 2901
9604 
9605 #line 2901
9606     while (nelems-- != 0) {
9607 #line 2901
9608 
9609 #line 2901
9610         if (*xp < 0) {
9611 #line 2901
9612 #ifdef ERANGE_FILL
9613 #line 2901
9614             *tp = NC_FILL_UBYTE;
9615 #line 2901
9616 #endif
9617 #line 2901
9618             status = NC_ERANGE; /* because tp is unsigned */
9619 #line 2901
9620 
9621 #line 2901
9622 #ifdef ERANGE_FILL
9623 #line 2901
9624             xp++; tp++; continue;
9625 #line 2901
9626 #endif
9627 #line 2901
9628         }
9629 #line 2901
9630         *tp++ = (uchar) (signed) (*xp++);  /* type cast from schar to uchar */
9631 #line 2901
9632     }
9633 #line 2901
9634 
9635 #line 2901
9636     *xpp = (const void *)xp;
9637 #line 2901
9638     return status;
9639 #line 2901
9640 }
9641 #line 2901
9642 
9643 int
9644 #line 2902
ncx_getn_schar_short(const void ** xpp,size_t nelems,short * tp)9645 ncx_getn_schar_short(const void **xpp, size_t nelems, short *tp)
9646 #line 2902
9647 {
9648 #line 2902
9649     int status = NC_NOERR;
9650 #line 2902
9651     schar *xp = (schar *)(*xpp);
9652 #line 2902
9653 
9654 #line 2902
9655     while (nelems-- != 0) {
9656 #line 2902
9657 
9658 #line 2902
9659         *tp++ = (short)  (*xp++);  /* type cast from schar to short */
9660 #line 2902
9661     }
9662 #line 2902
9663 
9664 #line 2902
9665     *xpp = (const void *)xp;
9666 #line 2902
9667     return status;
9668 #line 2902
9669 }
9670 #line 2902
9671 
9672 int
9673 #line 2903
ncx_getn_schar_int(const void ** xpp,size_t nelems,int * tp)9674 ncx_getn_schar_int(const void **xpp, size_t nelems, int *tp)
9675 #line 2903
9676 {
9677 #line 2903
9678     int status = NC_NOERR;
9679 #line 2903
9680     schar *xp = (schar *)(*xpp);
9681 #line 2903
9682 
9683 #line 2903
9684     while (nelems-- != 0) {
9685 #line 2903
9686 
9687 #line 2903
9688         *tp++ = (int)  (*xp++);  /* type cast from schar to int */
9689 #line 2903
9690     }
9691 #line 2903
9692 
9693 #line 2903
9694     *xpp = (const void *)xp;
9695 #line 2903
9696     return status;
9697 #line 2903
9698 }
9699 #line 2903
9700 
9701 int
9702 #line 2904
ncx_getn_schar_long(const void ** xpp,size_t nelems,long * tp)9703 ncx_getn_schar_long(const void **xpp, size_t nelems, long *tp)
9704 #line 2904
9705 {
9706 #line 2904
9707     int status = NC_NOERR;
9708 #line 2904
9709     schar *xp = (schar *)(*xpp);
9710 #line 2904
9711 
9712 #line 2904
9713     while (nelems-- != 0) {
9714 #line 2904
9715 
9716 #line 2904
9717         *tp++ = (long)  (*xp++);  /* type cast from schar to long */
9718 #line 2904
9719     }
9720 #line 2904
9721 
9722 #line 2904
9723     *xpp = (const void *)xp;
9724 #line 2904
9725     return status;
9726 #line 2904
9727 }
9728 #line 2904
9729 
9730 int
9731 #line 2905
ncx_getn_schar_float(const void ** xpp,size_t nelems,float * tp)9732 ncx_getn_schar_float(const void **xpp, size_t nelems, float *tp)
9733 #line 2905
9734 {
9735 #line 2905
9736     int status = NC_NOERR;
9737 #line 2905
9738     schar *xp = (schar *)(*xpp);
9739 #line 2905
9740 
9741 #line 2905
9742     while (nelems-- != 0) {
9743 #line 2905
9744 
9745 #line 2905
9746         *tp++ = (float)  (*xp++);  /* type cast from schar to float */
9747 #line 2905
9748     }
9749 #line 2905
9750 
9751 #line 2905
9752     *xpp = (const void *)xp;
9753 #line 2905
9754     return status;
9755 #line 2905
9756 }
9757 #line 2905
9758 
9759 int
9760 #line 2906
ncx_getn_schar_double(const void ** xpp,size_t nelems,double * tp)9761 ncx_getn_schar_double(const void **xpp, size_t nelems, double *tp)
9762 #line 2906
9763 {
9764 #line 2906
9765     int status = NC_NOERR;
9766 #line 2906
9767     schar *xp = (schar *)(*xpp);
9768 #line 2906
9769 
9770 #line 2906
9771     while (nelems-- != 0) {
9772 #line 2906
9773 
9774 #line 2906
9775         *tp++ = (double)  (*xp++);  /* type cast from schar to double */
9776 #line 2906
9777     }
9778 #line 2906
9779 
9780 #line 2906
9781     *xpp = (const void *)xp;
9782 #line 2906
9783     return status;
9784 #line 2906
9785 }
9786 #line 2906
9787 
9788 int
9789 #line 2907
ncx_getn_schar_longlong(const void ** xpp,size_t nelems,longlong * tp)9790 ncx_getn_schar_longlong(const void **xpp, size_t nelems, longlong *tp)
9791 #line 2907
9792 {
9793 #line 2907
9794     int status = NC_NOERR;
9795 #line 2907
9796     schar *xp = (schar *)(*xpp);
9797 #line 2907
9798 
9799 #line 2907
9800     while (nelems-- != 0) {
9801 #line 2907
9802 
9803 #line 2907
9804         *tp++ = (longlong)  (*xp++);  /* type cast from schar to longlong */
9805 #line 2907
9806     }
9807 #line 2907
9808 
9809 #line 2907
9810     *xpp = (const void *)xp;
9811 #line 2907
9812     return status;
9813 #line 2907
9814 }
9815 #line 2907
9816 
9817 int
9818 #line 2908
ncx_getn_schar_ushort(const void ** xpp,size_t nelems,ushort * tp)9819 ncx_getn_schar_ushort(const void **xpp, size_t nelems, ushort *tp)
9820 #line 2908
9821 {
9822 #line 2908
9823     int status = NC_NOERR;
9824 #line 2908
9825     schar *xp = (schar *)(*xpp);
9826 #line 2908
9827 
9828 #line 2908
9829     while (nelems-- != 0) {
9830 #line 2908
9831 
9832 #line 2908
9833         if (*xp < 0) {
9834 #line 2908
9835 #ifdef ERANGE_FILL
9836 #line 2908
9837             *tp = NC_FILL_USHORT;
9838 #line 2908
9839 #endif
9840 #line 2908
9841             status = NC_ERANGE; /* because tp is unsigned */
9842 #line 2908
9843 
9844 #line 2908
9845 #ifdef ERANGE_FILL
9846 #line 2908
9847             xp++; tp++; continue;
9848 #line 2908
9849 #endif
9850 #line 2908
9851         }
9852 #line 2908
9853         *tp++ = (ushort) (signed) (*xp++);  /* type cast from schar to ushort */
9854 #line 2908
9855     }
9856 #line 2908
9857 
9858 #line 2908
9859     *xpp = (const void *)xp;
9860 #line 2908
9861     return status;
9862 #line 2908
9863 }
9864 #line 2908
9865 
9866 int
9867 #line 2909
ncx_getn_schar_uint(const void ** xpp,size_t nelems,uint * tp)9868 ncx_getn_schar_uint(const void **xpp, size_t nelems, uint *tp)
9869 #line 2909
9870 {
9871 #line 2909
9872     int status = NC_NOERR;
9873 #line 2909
9874     schar *xp = (schar *)(*xpp);
9875 #line 2909
9876 
9877 #line 2909
9878     while (nelems-- != 0) {
9879 #line 2909
9880 
9881 #line 2909
9882         if (*xp < 0) {
9883 #line 2909
9884 #ifdef ERANGE_FILL
9885 #line 2909
9886             *tp = NC_FILL_UINT;
9887 #line 2909
9888 #endif
9889 #line 2909
9890             status = NC_ERANGE; /* because tp is unsigned */
9891 #line 2909
9892 
9893 #line 2909
9894 #ifdef ERANGE_FILL
9895 #line 2909
9896             xp++; tp++; continue;
9897 #line 2909
9898 #endif
9899 #line 2909
9900         }
9901 #line 2909
9902         *tp++ = (uint) (signed) (*xp++);  /* type cast from schar to uint */
9903 #line 2909
9904     }
9905 #line 2909
9906 
9907 #line 2909
9908     *xpp = (const void *)xp;
9909 #line 2909
9910     return status;
9911 #line 2909
9912 }
9913 #line 2909
9914 
9915 int
9916 #line 2910
ncx_getn_schar_ulonglong(const void ** xpp,size_t nelems,ulonglong * tp)9917 ncx_getn_schar_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
9918 #line 2910
9919 {
9920 #line 2910
9921     int status = NC_NOERR;
9922 #line 2910
9923     schar *xp = (schar *)(*xpp);
9924 #line 2910
9925 
9926 #line 2910
9927     while (nelems-- != 0) {
9928 #line 2910
9929 
9930 #line 2910
9931         if (*xp < 0) {
9932 #line 2910
9933 #ifdef ERANGE_FILL
9934 #line 2910
9935             *tp = NC_FILL_UINT64;
9936 #line 2910
9937 #endif
9938 #line 2910
9939             status = NC_ERANGE; /* because tp is unsigned */
9940 #line 2910
9941 
9942 #line 2910
9943 #ifdef ERANGE_FILL
9944 #line 2910
9945             xp++; tp++; continue;
9946 #line 2910
9947 #endif
9948 #line 2910
9949         }
9950 #line 2910
9951         *tp++ = (ulonglong) (signed) (*xp++);  /* type cast from schar to ulonglong */
9952 #line 2910
9953     }
9954 #line 2910
9955 
9956 #line 2910
9957     *xpp = (const void *)xp;
9958 #line 2910
9959     return status;
9960 #line 2910
9961 }
9962 #line 2910
9963 
9964 
9965 #line 2913
9966 int
ncx_pad_getn_schar_schar(const void ** xpp,size_t nelems,schar * tp)9967 ncx_pad_getn_schar_schar(const void **xpp, size_t nelems, schar *tp)
9968 {
9969 		size_t rndup = nelems % X_ALIGN;
9970 #line 2916
9971 
9972 #line 2916
9973 	if (rndup)
9974 #line 2916
9975 		rndup = X_ALIGN - rndup;
9976 #line 2916
9977 
9978 #line 2916
9979 	(void) memcpy(tp, *xpp, (size_t)nelems);
9980 #line 2916
9981 	*xpp = (void *)((char *)(*xpp) + nelems + rndup);
9982 #line 2916
9983 
9984 #line 2916
9985 	return NC_NOERR;
9986 #line 2916
9987 
9988 }
9989 int
9990 #line 2918
ncx_pad_getn_schar_uchar(const void ** xpp,size_t nelems,uchar * tp)9991 ncx_pad_getn_schar_uchar(const void **xpp, size_t nelems, uchar *tp)
9992 #line 2918
9993 {
9994 #line 2918
9995     int status = NC_NOERR;
9996 #line 2918
9997     size_t rndup = nelems % X_ALIGN;
9998 #line 2918
9999     schar *xp = (schar *) *xpp;
10000 #line 2918
10001 
10002 #line 2918
10003     if (rndup)
10004 #line 2918
10005         rndup = X_ALIGN - rndup;
10006 #line 2918
10007 
10008 #line 2918
10009     while (nelems-- != 0) {
10010 #line 2918
10011 
10012 #line 2918
10013         if (*xp < 0) {
10014 #line 2918
10015 #ifdef ERANGE_FILL
10016 #line 2918
10017             *tp = NC_FILL_UBYTE;
10018 #line 2918
10019 #endif
10020 #line 2918
10021             status = NC_ERANGE; /* because tp is unsigned */
10022 #line 2918
10023 
10024 #line 2918
10025 #ifdef ERANGE_FILL
10026 #line 2918
10027             xp++; tp++; continue;
10028 #line 2918
10029 #endif
10030 #line 2918
10031         }
10032 #line 2918
10033         *tp++ = (uchar) (signed) (*xp++);  /* type cast from schar to uchar */
10034 #line 2918
10035     }
10036 #line 2918
10037 
10038 #line 2918
10039     *xpp = (void *)(xp + rndup);
10040 #line 2918
10041     return status;
10042 #line 2918
10043 }
10044 #line 2918
10045 
10046 int
10047 #line 2919
ncx_pad_getn_schar_short(const void ** xpp,size_t nelems,short * tp)10048 ncx_pad_getn_schar_short(const void **xpp, size_t nelems, short *tp)
10049 #line 2919
10050 {
10051 #line 2919
10052     int status = NC_NOERR;
10053 #line 2919
10054     size_t rndup = nelems % X_ALIGN;
10055 #line 2919
10056     schar *xp = (schar *) *xpp;
10057 #line 2919
10058 
10059 #line 2919
10060     if (rndup)
10061 #line 2919
10062         rndup = X_ALIGN - rndup;
10063 #line 2919
10064 
10065 #line 2919
10066     while (nelems-- != 0) {
10067 #line 2919
10068 
10069 #line 2919
10070         *tp++ = (short)  (*xp++);  /* type cast from schar to short */
10071 #line 2919
10072     }
10073 #line 2919
10074 
10075 #line 2919
10076     *xpp = (void *)(xp + rndup);
10077 #line 2919
10078     return status;
10079 #line 2919
10080 }
10081 #line 2919
10082 
10083 int
10084 #line 2920
ncx_pad_getn_schar_int(const void ** xpp,size_t nelems,int * tp)10085 ncx_pad_getn_schar_int(const void **xpp, size_t nelems, int *tp)
10086 #line 2920
10087 {
10088 #line 2920
10089     int status = NC_NOERR;
10090 #line 2920
10091     size_t rndup = nelems % X_ALIGN;
10092 #line 2920
10093     schar *xp = (schar *) *xpp;
10094 #line 2920
10095 
10096 #line 2920
10097     if (rndup)
10098 #line 2920
10099         rndup = X_ALIGN - rndup;
10100 #line 2920
10101 
10102 #line 2920
10103     while (nelems-- != 0) {
10104 #line 2920
10105 
10106 #line 2920
10107         *tp++ = (int)  (*xp++);  /* type cast from schar to int */
10108 #line 2920
10109     }
10110 #line 2920
10111 
10112 #line 2920
10113     *xpp = (void *)(xp + rndup);
10114 #line 2920
10115     return status;
10116 #line 2920
10117 }
10118 #line 2920
10119 
10120 int
10121 #line 2921
ncx_pad_getn_schar_long(const void ** xpp,size_t nelems,long * tp)10122 ncx_pad_getn_schar_long(const void **xpp, size_t nelems, long *tp)
10123 #line 2921
10124 {
10125 #line 2921
10126     int status = NC_NOERR;
10127 #line 2921
10128     size_t rndup = nelems % X_ALIGN;
10129 #line 2921
10130     schar *xp = (schar *) *xpp;
10131 #line 2921
10132 
10133 #line 2921
10134     if (rndup)
10135 #line 2921
10136         rndup = X_ALIGN - rndup;
10137 #line 2921
10138 
10139 #line 2921
10140     while (nelems-- != 0) {
10141 #line 2921
10142 
10143 #line 2921
10144         *tp++ = (long)  (*xp++);  /* type cast from schar to long */
10145 #line 2921
10146     }
10147 #line 2921
10148 
10149 #line 2921
10150     *xpp = (void *)(xp + rndup);
10151 #line 2921
10152     return status;
10153 #line 2921
10154 }
10155 #line 2921
10156 
10157 int
10158 #line 2922
ncx_pad_getn_schar_float(const void ** xpp,size_t nelems,float * tp)10159 ncx_pad_getn_schar_float(const void **xpp, size_t nelems, float *tp)
10160 #line 2922
10161 {
10162 #line 2922
10163     int status = NC_NOERR;
10164 #line 2922
10165     size_t rndup = nelems % X_ALIGN;
10166 #line 2922
10167     schar *xp = (schar *) *xpp;
10168 #line 2922
10169 
10170 #line 2922
10171     if (rndup)
10172 #line 2922
10173         rndup = X_ALIGN - rndup;
10174 #line 2922
10175 
10176 #line 2922
10177     while (nelems-- != 0) {
10178 #line 2922
10179 
10180 #line 2922
10181         *tp++ = (float)  (*xp++);  /* type cast from schar to float */
10182 #line 2922
10183     }
10184 #line 2922
10185 
10186 #line 2922
10187     *xpp = (void *)(xp + rndup);
10188 #line 2922
10189     return status;
10190 #line 2922
10191 }
10192 #line 2922
10193 
10194 int
10195 #line 2923
ncx_pad_getn_schar_double(const void ** xpp,size_t nelems,double * tp)10196 ncx_pad_getn_schar_double(const void **xpp, size_t nelems, double *tp)
10197 #line 2923
10198 {
10199 #line 2923
10200     int status = NC_NOERR;
10201 #line 2923
10202     size_t rndup = nelems % X_ALIGN;
10203 #line 2923
10204     schar *xp = (schar *) *xpp;
10205 #line 2923
10206 
10207 #line 2923
10208     if (rndup)
10209 #line 2923
10210         rndup = X_ALIGN - rndup;
10211 #line 2923
10212 
10213 #line 2923
10214     while (nelems-- != 0) {
10215 #line 2923
10216 
10217 #line 2923
10218         *tp++ = (double)  (*xp++);  /* type cast from schar to double */
10219 #line 2923
10220     }
10221 #line 2923
10222 
10223 #line 2923
10224     *xpp = (void *)(xp + rndup);
10225 #line 2923
10226     return status;
10227 #line 2923
10228 }
10229 #line 2923
10230 
10231 int
10232 #line 2924
ncx_pad_getn_schar_longlong(const void ** xpp,size_t nelems,longlong * tp)10233 ncx_pad_getn_schar_longlong(const void **xpp, size_t nelems, longlong *tp)
10234 #line 2924
10235 {
10236 #line 2924
10237     int status = NC_NOERR;
10238 #line 2924
10239     size_t rndup = nelems % X_ALIGN;
10240 #line 2924
10241     schar *xp = (schar *) *xpp;
10242 #line 2924
10243 
10244 #line 2924
10245     if (rndup)
10246 #line 2924
10247         rndup = X_ALIGN - rndup;
10248 #line 2924
10249 
10250 #line 2924
10251     while (nelems-- != 0) {
10252 #line 2924
10253 
10254 #line 2924
10255         *tp++ = (longlong)  (*xp++);  /* type cast from schar to longlong */
10256 #line 2924
10257     }
10258 #line 2924
10259 
10260 #line 2924
10261     *xpp = (void *)(xp + rndup);
10262 #line 2924
10263     return status;
10264 #line 2924
10265 }
10266 #line 2924
10267 
10268 int
10269 #line 2925
ncx_pad_getn_schar_ushort(const void ** xpp,size_t nelems,ushort * tp)10270 ncx_pad_getn_schar_ushort(const void **xpp, size_t nelems, ushort *tp)
10271 #line 2925
10272 {
10273 #line 2925
10274     int status = NC_NOERR;
10275 #line 2925
10276     size_t rndup = nelems % X_ALIGN;
10277 #line 2925
10278     schar *xp = (schar *) *xpp;
10279 #line 2925
10280 
10281 #line 2925
10282     if (rndup)
10283 #line 2925
10284         rndup = X_ALIGN - rndup;
10285 #line 2925
10286 
10287 #line 2925
10288     while (nelems-- != 0) {
10289 #line 2925
10290 
10291 #line 2925
10292         if (*xp < 0) {
10293 #line 2925
10294 #ifdef ERANGE_FILL
10295 #line 2925
10296             *tp = NC_FILL_USHORT;
10297 #line 2925
10298 #endif
10299 #line 2925
10300             status = NC_ERANGE; /* because tp is unsigned */
10301 #line 2925
10302 
10303 #line 2925
10304 #ifdef ERANGE_FILL
10305 #line 2925
10306             xp++; tp++; continue;
10307 #line 2925
10308 #endif
10309 #line 2925
10310         }
10311 #line 2925
10312         *tp++ = (ushort) (signed) (*xp++);  /* type cast from schar to ushort */
10313 #line 2925
10314     }
10315 #line 2925
10316 
10317 #line 2925
10318     *xpp = (void *)(xp + rndup);
10319 #line 2925
10320     return status;
10321 #line 2925
10322 }
10323 #line 2925
10324 
10325 int
10326 #line 2926
ncx_pad_getn_schar_uint(const void ** xpp,size_t nelems,uint * tp)10327 ncx_pad_getn_schar_uint(const void **xpp, size_t nelems, uint *tp)
10328 #line 2926
10329 {
10330 #line 2926
10331     int status = NC_NOERR;
10332 #line 2926
10333     size_t rndup = nelems % X_ALIGN;
10334 #line 2926
10335     schar *xp = (schar *) *xpp;
10336 #line 2926
10337 
10338 #line 2926
10339     if (rndup)
10340 #line 2926
10341         rndup = X_ALIGN - rndup;
10342 #line 2926
10343 
10344 #line 2926
10345     while (nelems-- != 0) {
10346 #line 2926
10347 
10348 #line 2926
10349         if (*xp < 0) {
10350 #line 2926
10351 #ifdef ERANGE_FILL
10352 #line 2926
10353             *tp = NC_FILL_UINT;
10354 #line 2926
10355 #endif
10356 #line 2926
10357             status = NC_ERANGE; /* because tp is unsigned */
10358 #line 2926
10359 
10360 #line 2926
10361 #ifdef ERANGE_FILL
10362 #line 2926
10363             xp++; tp++; continue;
10364 #line 2926
10365 #endif
10366 #line 2926
10367         }
10368 #line 2926
10369         *tp++ = (uint) (signed) (*xp++);  /* type cast from schar to uint */
10370 #line 2926
10371     }
10372 #line 2926
10373 
10374 #line 2926
10375     *xpp = (void *)(xp + rndup);
10376 #line 2926
10377     return status;
10378 #line 2926
10379 }
10380 #line 2926
10381 
10382 int
10383 #line 2927
ncx_pad_getn_schar_ulonglong(const void ** xpp,size_t nelems,ulonglong * tp)10384 ncx_pad_getn_schar_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
10385 #line 2927
10386 {
10387 #line 2927
10388     int status = NC_NOERR;
10389 #line 2927
10390     size_t rndup = nelems % X_ALIGN;
10391 #line 2927
10392     schar *xp = (schar *) *xpp;
10393 #line 2927
10394 
10395 #line 2927
10396     if (rndup)
10397 #line 2927
10398         rndup = X_ALIGN - rndup;
10399 #line 2927
10400 
10401 #line 2927
10402     while (nelems-- != 0) {
10403 #line 2927
10404 
10405 #line 2927
10406         if (*xp < 0) {
10407 #line 2927
10408 #ifdef ERANGE_FILL
10409 #line 2927
10410             *tp = NC_FILL_UINT64;
10411 #line 2927
10412 #endif
10413 #line 2927
10414             status = NC_ERANGE; /* because tp is unsigned */
10415 #line 2927
10416 
10417 #line 2927
10418 #ifdef ERANGE_FILL
10419 #line 2927
10420             xp++; tp++; continue;
10421 #line 2927
10422 #endif
10423 #line 2927
10424         }
10425 #line 2927
10426         *tp++ = (ulonglong) (signed) (*xp++);  /* type cast from schar to ulonglong */
10427 #line 2927
10428     }
10429 #line 2927
10430 
10431 #line 2927
10432     *xpp = (void *)(xp + rndup);
10433 #line 2927
10434     return status;
10435 #line 2927
10436 }
10437 #line 2927
10438 
10439 
10440 #line 2930
10441 int
ncx_putn_schar_schar(void ** xpp,size_t nelems,const schar * tp,void * fillp)10442 ncx_putn_schar_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
10443 {
10444 		(void) memcpy(*xpp, tp, (size_t)nelems);
10445 #line 2933
10446 	*xpp = (void *)((char *)(*xpp) + nelems);
10447 #line 2933
10448 
10449 #line 2933
10450 	return NC_NOERR;
10451 #line 2933
10452 
10453 }
10454 int
10455 #line 2935
ncx_putn_schar_uchar(void ** xpp,size_t nelems,const uchar * tp,void * fillp)10456 ncx_putn_schar_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
10457 #line 2935
10458 {
10459 #line 2935
10460     int status = NC_NOERR;
10461 #line 2935
10462     schar *xp = (schar *) *xpp;
10463 #line 2935
10464 
10465 #line 2935
10466     while (nelems-- != 0) {
10467 #line 2935
10468         if (*tp > (uchar)X_SCHAR_MAX ) {
10469 #line 2935
10470 
10471 #line 2935
10472 #ifdef ERANGE_FILL
10473 #line 2935
10474             if (fillp != NULL) memcpy(xp, fillp, 1);
10475 #line 2935
10476 #endif
10477 #line 2935
10478             status = NC_ERANGE;
10479 #line 2935
10480 
10481 #line 2935
10482 #ifdef ERANGE_FILL
10483 #line 2935
10484             xp++; tp++; continue;
10485 #line 2935
10486 #endif
10487 #line 2935
10488         }
10489 #line 2935
10490         *xp++ = (schar)  *tp++; /* type cast from uchar to schar */
10491 #line 2935
10492     }
10493 #line 2935
10494 
10495 #line 2935
10496     *xpp = (void *)xp;
10497 #line 2935
10498     return status;
10499 #line 2935
10500 }
10501 #line 2935
10502 
10503 int
10504 #line 2936
ncx_putn_schar_short(void ** xpp,size_t nelems,const short * tp,void * fillp)10505 ncx_putn_schar_short(void **xpp, size_t nelems, const short *tp, void *fillp)
10506 #line 2936
10507 {
10508 #line 2936
10509     int status = NC_NOERR;
10510 #line 2936
10511     schar *xp = (schar *) *xpp;
10512 #line 2936
10513 
10514 #line 2936
10515     while (nelems-- != 0) {
10516 #line 2936
10517         if (*tp > (short)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
10518 #line 2936
10519 
10520 #line 2936
10521 #ifdef ERANGE_FILL
10522 #line 2936
10523             if (fillp != NULL) memcpy(xp, fillp, 1);
10524 #line 2936
10525 #endif
10526 #line 2936
10527             status = NC_ERANGE;
10528 #line 2936
10529 
10530 #line 2936
10531 #ifdef ERANGE_FILL
10532 #line 2936
10533             xp++; tp++; continue;
10534 #line 2936
10535 #endif
10536 #line 2936
10537         }
10538 #line 2936
10539         *xp++ = (schar)  *tp++; /* type cast from short to schar */
10540 #line 2936
10541     }
10542 #line 2936
10543 
10544 #line 2936
10545     *xpp = (void *)xp;
10546 #line 2936
10547     return status;
10548 #line 2936
10549 }
10550 #line 2936
10551 
10552 int
10553 #line 2937
ncx_putn_schar_int(void ** xpp,size_t nelems,const int * tp,void * fillp)10554 ncx_putn_schar_int(void **xpp, size_t nelems, const int *tp, void *fillp)
10555 #line 2937
10556 {
10557 #line 2937
10558     int status = NC_NOERR;
10559 #line 2937
10560     schar *xp = (schar *) *xpp;
10561 #line 2937
10562 
10563 #line 2937
10564     while (nelems-- != 0) {
10565 #line 2937
10566         if (*tp > (int)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
10567 #line 2937
10568 
10569 #line 2937
10570 #ifdef ERANGE_FILL
10571 #line 2937
10572             if (fillp != NULL) memcpy(xp, fillp, 1);
10573 #line 2937
10574 #endif
10575 #line 2937
10576             status = NC_ERANGE;
10577 #line 2937
10578 
10579 #line 2937
10580 #ifdef ERANGE_FILL
10581 #line 2937
10582             xp++; tp++; continue;
10583 #line 2937
10584 #endif
10585 #line 2937
10586         }
10587 #line 2937
10588         *xp++ = (schar)  *tp++; /* type cast from int to schar */
10589 #line 2937
10590     }
10591 #line 2937
10592 
10593 #line 2937
10594     *xpp = (void *)xp;
10595 #line 2937
10596     return status;
10597 #line 2937
10598 }
10599 #line 2937
10600 
10601 int
10602 #line 2938
ncx_putn_schar_long(void ** xpp,size_t nelems,const long * tp,void * fillp)10603 ncx_putn_schar_long(void **xpp, size_t nelems, const long *tp, void *fillp)
10604 #line 2938
10605 {
10606 #line 2938
10607     int status = NC_NOERR;
10608 #line 2938
10609     schar *xp = (schar *) *xpp;
10610 #line 2938
10611 
10612 #line 2938
10613     while (nelems-- != 0) {
10614 #line 2938
10615         if (*tp > (long)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
10616 #line 2938
10617 
10618 #line 2938
10619 #ifdef ERANGE_FILL
10620 #line 2938
10621             if (fillp != NULL) memcpy(xp, fillp, 1);
10622 #line 2938
10623 #endif
10624 #line 2938
10625             status = NC_ERANGE;
10626 #line 2938
10627 
10628 #line 2938
10629 #ifdef ERANGE_FILL
10630 #line 2938
10631             xp++; tp++; continue;
10632 #line 2938
10633 #endif
10634 #line 2938
10635         }
10636 #line 2938
10637         *xp++ = (schar)  *tp++; /* type cast from long to schar */
10638 #line 2938
10639     }
10640 #line 2938
10641 
10642 #line 2938
10643     *xpp = (void *)xp;
10644 #line 2938
10645     return status;
10646 #line 2938
10647 }
10648 #line 2938
10649 
10650 int
10651 #line 2939
ncx_putn_schar_float(void ** xpp,size_t nelems,const float * tp,void * fillp)10652 ncx_putn_schar_float(void **xpp, size_t nelems, const float *tp, void *fillp)
10653 #line 2939
10654 {
10655 #line 2939
10656     int status = NC_NOERR;
10657 #line 2939
10658     schar *xp = (schar *) *xpp;
10659 #line 2939
10660 
10661 #line 2939
10662     while (nelems-- != 0) {
10663 #line 2939
10664         if (*tp > (float)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
10665 #line 2939
10666 
10667 #line 2939
10668 #ifdef ERANGE_FILL
10669 #line 2939
10670             if (fillp != NULL) memcpy(xp, fillp, 1);
10671 #line 2939
10672 #endif
10673 #line 2939
10674             status = NC_ERANGE;
10675 #line 2939
10676 
10677 #line 2939
10678 #ifdef ERANGE_FILL
10679 #line 2939
10680             xp++; tp++; continue;
10681 #line 2939
10682 #endif
10683 #line 2939
10684         }
10685 #line 2939
10686         *xp++ = (schar)  *tp++; /* type cast from float to schar */
10687 #line 2939
10688     }
10689 #line 2939
10690 
10691 #line 2939
10692     *xpp = (void *)xp;
10693 #line 2939
10694     return status;
10695 #line 2939
10696 }
10697 #line 2939
10698 
10699 int
10700 #line 2940
ncx_putn_schar_double(void ** xpp,size_t nelems,const double * tp,void * fillp)10701 ncx_putn_schar_double(void **xpp, size_t nelems, const double *tp, void *fillp)
10702 #line 2940
10703 {
10704 #line 2940
10705     int status = NC_NOERR;
10706 #line 2940
10707     schar *xp = (schar *) *xpp;
10708 #line 2940
10709 
10710 #line 2940
10711     while (nelems-- != 0) {
10712 #line 2940
10713         if (*tp > (double)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
10714 #line 2940
10715 
10716 #line 2940
10717 #ifdef ERANGE_FILL
10718 #line 2940
10719             if (fillp != NULL) memcpy(xp, fillp, 1);
10720 #line 2940
10721 #endif
10722 #line 2940
10723             status = NC_ERANGE;
10724 #line 2940
10725 
10726 #line 2940
10727 #ifdef ERANGE_FILL
10728 #line 2940
10729             xp++; tp++; continue;
10730 #line 2940
10731 #endif
10732 #line 2940
10733         }
10734 #line 2940
10735         *xp++ = (schar)  *tp++; /* type cast from double to schar */
10736 #line 2940
10737     }
10738 #line 2940
10739 
10740 #line 2940
10741     *xpp = (void *)xp;
10742 #line 2940
10743     return status;
10744 #line 2940
10745 }
10746 #line 2940
10747 
10748 int
10749 #line 2941
ncx_putn_schar_longlong(void ** xpp,size_t nelems,const longlong * tp,void * fillp)10750 ncx_putn_schar_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
10751 #line 2941
10752 {
10753 #line 2941
10754     int status = NC_NOERR;
10755 #line 2941
10756     schar *xp = (schar *) *xpp;
10757 #line 2941
10758 
10759 #line 2941
10760     while (nelems-- != 0) {
10761 #line 2941
10762         if (*tp > (longlong)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
10763 #line 2941
10764 
10765 #line 2941
10766 #ifdef ERANGE_FILL
10767 #line 2941
10768             if (fillp != NULL) memcpy(xp, fillp, 1);
10769 #line 2941
10770 #endif
10771 #line 2941
10772             status = NC_ERANGE;
10773 #line 2941
10774 
10775 #line 2941
10776 #ifdef ERANGE_FILL
10777 #line 2941
10778             xp++; tp++; continue;
10779 #line 2941
10780 #endif
10781 #line 2941
10782         }
10783 #line 2941
10784         *xp++ = (schar)  *tp++; /* type cast from longlong to schar */
10785 #line 2941
10786     }
10787 #line 2941
10788 
10789 #line 2941
10790     *xpp = (void *)xp;
10791 #line 2941
10792     return status;
10793 #line 2941
10794 }
10795 #line 2941
10796 
10797 int
10798 #line 2942
ncx_putn_schar_ushort(void ** xpp,size_t nelems,const ushort * tp,void * fillp)10799 ncx_putn_schar_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
10800 #line 2942
10801 {
10802 #line 2942
10803     int status = NC_NOERR;
10804 #line 2942
10805     schar *xp = (schar *) *xpp;
10806 #line 2942
10807 
10808 #line 2942
10809     while (nelems-- != 0) {
10810 #line 2942
10811         if (*tp > (ushort)X_SCHAR_MAX ) {
10812 #line 2942
10813 
10814 #line 2942
10815 #ifdef ERANGE_FILL
10816 #line 2942
10817             if (fillp != NULL) memcpy(xp, fillp, 1);
10818 #line 2942
10819 #endif
10820 #line 2942
10821             status = NC_ERANGE;
10822 #line 2942
10823 
10824 #line 2942
10825 #ifdef ERANGE_FILL
10826 #line 2942
10827             xp++; tp++; continue;
10828 #line 2942
10829 #endif
10830 #line 2942
10831         }
10832 #line 2942
10833         *xp++ = (schar)  *tp++; /* type cast from ushort to schar */
10834 #line 2942
10835     }
10836 #line 2942
10837 
10838 #line 2942
10839     *xpp = (void *)xp;
10840 #line 2942
10841     return status;
10842 #line 2942
10843 }
10844 #line 2942
10845 
10846 int
10847 #line 2943
ncx_putn_schar_uint(void ** xpp,size_t nelems,const uint * tp,void * fillp)10848 ncx_putn_schar_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
10849 #line 2943
10850 {
10851 #line 2943
10852     int status = NC_NOERR;
10853 #line 2943
10854     schar *xp = (schar *) *xpp;
10855 #line 2943
10856 
10857 #line 2943
10858     while (nelems-- != 0) {
10859 #line 2943
10860         if (*tp > (uint)X_SCHAR_MAX ) {
10861 #line 2943
10862 
10863 #line 2943
10864 #ifdef ERANGE_FILL
10865 #line 2943
10866             if (fillp != NULL) memcpy(xp, fillp, 1);
10867 #line 2943
10868 #endif
10869 #line 2943
10870             status = NC_ERANGE;
10871 #line 2943
10872 
10873 #line 2943
10874 #ifdef ERANGE_FILL
10875 #line 2943
10876             xp++; tp++; continue;
10877 #line 2943
10878 #endif
10879 #line 2943
10880         }
10881 #line 2943
10882         *xp++ = (schar)  *tp++; /* type cast from uint to schar */
10883 #line 2943
10884     }
10885 #line 2943
10886 
10887 #line 2943
10888     *xpp = (void *)xp;
10889 #line 2943
10890     return status;
10891 #line 2943
10892 }
10893 #line 2943
10894 
10895 int
10896 #line 2944
ncx_putn_schar_ulonglong(void ** xpp,size_t nelems,const ulonglong * tp,void * fillp)10897 ncx_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
10898 #line 2944
10899 {
10900 #line 2944
10901     int status = NC_NOERR;
10902 #line 2944
10903     schar *xp = (schar *) *xpp;
10904 #line 2944
10905 
10906 #line 2944
10907     while (nelems-- != 0) {
10908 #line 2944
10909         if (*tp > (ulonglong)X_SCHAR_MAX ) {
10910 #line 2944
10911 
10912 #line 2944
10913 #ifdef ERANGE_FILL
10914 #line 2944
10915             if (fillp != NULL) memcpy(xp, fillp, 1);
10916 #line 2944
10917 #endif
10918 #line 2944
10919             status = NC_ERANGE;
10920 #line 2944
10921 
10922 #line 2944
10923 #ifdef ERANGE_FILL
10924 #line 2944
10925             xp++; tp++; continue;
10926 #line 2944
10927 #endif
10928 #line 2944
10929         }
10930 #line 2944
10931         *xp++ = (schar)  *tp++; /* type cast from ulonglong to schar */
10932 #line 2944
10933     }
10934 #line 2944
10935 
10936 #line 2944
10937     *xpp = (void *)xp;
10938 #line 2944
10939     return status;
10940 #line 2944
10941 }
10942 #line 2944
10943 
10944 
10945 #line 2947
10946 int
ncx_pad_putn_schar_schar(void ** xpp,size_t nelems,const schar * tp,void * fillp)10947 ncx_pad_putn_schar_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
10948 {
10949 		size_t rndup = nelems % X_ALIGN;
10950 #line 2950
10951 
10952 #line 2950
10953 	if (rndup)
10954 #line 2950
10955 		rndup = X_ALIGN - rndup;
10956 #line 2950
10957 
10958 #line 2950
10959 	(void) memcpy(*xpp, tp, (size_t)nelems);
10960 #line 2950
10961 	*xpp = (void *)((char *)(*xpp) + nelems);
10962 #line 2950
10963 
10964 #line 2950
10965 	if (rndup)
10966 #line 2950
10967 	{
10968 #line 2950
10969 		(void) memcpy(*xpp, nada, (size_t)rndup);
10970 #line 2950
10971 		*xpp = (void *)((char *)(*xpp) + rndup);
10972 #line 2950
10973 	}
10974 #line 2950
10975 
10976 #line 2950
10977 	return NC_NOERR;
10978 #line 2950
10979 
10980 }
10981 int
10982 #line 2952
ncx_pad_putn_schar_uchar(void ** xpp,size_t nelems,const uchar * tp,void * fillp)10983 ncx_pad_putn_schar_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
10984 #line 2952
10985 {
10986 #line 2952
10987     int status = NC_NOERR;
10988 #line 2952
10989     size_t rndup = nelems % X_ALIGN;
10990 #line 2952
10991     schar *xp = (schar *) *xpp;
10992 #line 2952
10993 
10994 #line 2952
10995     if (rndup) rndup = X_ALIGN - rndup;
10996 #line 2952
10997 
10998 #line 2952
10999     while (nelems-- != 0) {
11000 #line 2952
11001         if (*tp > (uchar)X_SCHAR_MAX ) {
11002 #line 2952
11003 
11004 #line 2952
11005 #ifdef ERANGE_FILL
11006 #line 2952
11007             if (fillp != NULL) memcpy(xp, fillp, 1);
11008 #line 2952
11009 #endif
11010 #line 2952
11011             status = NC_ERANGE;
11012 #line 2952
11013 
11014 #line 2952
11015 #ifdef ERANGE_FILL
11016 #line 2952
11017             xp++; tp++; continue;
11018 #line 2952
11019 #endif
11020 #line 2952
11021         }
11022 #line 2952
11023         *xp++ = (schar)  *tp++; /* type cast from uchar to schar */
11024 #line 2952
11025     }
11026 #line 2952
11027 
11028 #line 2952
11029 
11030 #line 2952
11031     if (rndup) {
11032 #line 2952
11033         (void) memcpy(xp, nada, (size_t)rndup);
11034 #line 2952
11035         xp += rndup;
11036 #line 2952
11037     }
11038 #line 2952
11039 
11040 #line 2952
11041     *xpp = (void *)xp;
11042 #line 2952
11043     return status;
11044 #line 2952
11045 }
11046 #line 2952
11047 
11048 int
11049 #line 2953
ncx_pad_putn_schar_short(void ** xpp,size_t nelems,const short * tp,void * fillp)11050 ncx_pad_putn_schar_short(void **xpp, size_t nelems, const short *tp, void *fillp)
11051 #line 2953
11052 {
11053 #line 2953
11054     int status = NC_NOERR;
11055 #line 2953
11056     size_t rndup = nelems % X_ALIGN;
11057 #line 2953
11058     schar *xp = (schar *) *xpp;
11059 #line 2953
11060 
11061 #line 2953
11062     if (rndup) rndup = X_ALIGN - rndup;
11063 #line 2953
11064 
11065 #line 2953
11066     while (nelems-- != 0) {
11067 #line 2953
11068         if (*tp > (short)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
11069 #line 2953
11070 
11071 #line 2953
11072 #ifdef ERANGE_FILL
11073 #line 2953
11074             if (fillp != NULL) memcpy(xp, fillp, 1);
11075 #line 2953
11076 #endif
11077 #line 2953
11078             status = NC_ERANGE;
11079 #line 2953
11080 
11081 #line 2953
11082 #ifdef ERANGE_FILL
11083 #line 2953
11084             xp++; tp++; continue;
11085 #line 2953
11086 #endif
11087 #line 2953
11088         }
11089 #line 2953
11090         *xp++ = (schar)  *tp++; /* type cast from short to schar */
11091 #line 2953
11092     }
11093 #line 2953
11094 
11095 #line 2953
11096 
11097 #line 2953
11098     if (rndup) {
11099 #line 2953
11100         (void) memcpy(xp, nada, (size_t)rndup);
11101 #line 2953
11102         xp += rndup;
11103 #line 2953
11104     }
11105 #line 2953
11106 
11107 #line 2953
11108     *xpp = (void *)xp;
11109 #line 2953
11110     return status;
11111 #line 2953
11112 }
11113 #line 2953
11114 
11115 int
11116 #line 2954
ncx_pad_putn_schar_int(void ** xpp,size_t nelems,const int * tp,void * fillp)11117 ncx_pad_putn_schar_int(void **xpp, size_t nelems, const int *tp, void *fillp)
11118 #line 2954
11119 {
11120 #line 2954
11121     int status = NC_NOERR;
11122 #line 2954
11123     size_t rndup = nelems % X_ALIGN;
11124 #line 2954
11125     schar *xp = (schar *) *xpp;
11126 #line 2954
11127 
11128 #line 2954
11129     if (rndup) rndup = X_ALIGN - rndup;
11130 #line 2954
11131 
11132 #line 2954
11133     while (nelems-- != 0) {
11134 #line 2954
11135         if (*tp > (int)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
11136 #line 2954
11137 
11138 #line 2954
11139 #ifdef ERANGE_FILL
11140 #line 2954
11141             if (fillp != NULL) memcpy(xp, fillp, 1);
11142 #line 2954
11143 #endif
11144 #line 2954
11145             status = NC_ERANGE;
11146 #line 2954
11147 
11148 #line 2954
11149 #ifdef ERANGE_FILL
11150 #line 2954
11151             xp++; tp++; continue;
11152 #line 2954
11153 #endif
11154 #line 2954
11155         }
11156 #line 2954
11157         *xp++ = (schar)  *tp++; /* type cast from int to schar */
11158 #line 2954
11159     }
11160 #line 2954
11161 
11162 #line 2954
11163 
11164 #line 2954
11165     if (rndup) {
11166 #line 2954
11167         (void) memcpy(xp, nada, (size_t)rndup);
11168 #line 2954
11169         xp += rndup;
11170 #line 2954
11171     }
11172 #line 2954
11173 
11174 #line 2954
11175     *xpp = (void *)xp;
11176 #line 2954
11177     return status;
11178 #line 2954
11179 }
11180 #line 2954
11181 
11182 int
11183 #line 2955
ncx_pad_putn_schar_long(void ** xpp,size_t nelems,const long * tp,void * fillp)11184 ncx_pad_putn_schar_long(void **xpp, size_t nelems, const long *tp, void *fillp)
11185 #line 2955
11186 {
11187 #line 2955
11188     int status = NC_NOERR;
11189 #line 2955
11190     size_t rndup = nelems % X_ALIGN;
11191 #line 2955
11192     schar *xp = (schar *) *xpp;
11193 #line 2955
11194 
11195 #line 2955
11196     if (rndup) rndup = X_ALIGN - rndup;
11197 #line 2955
11198 
11199 #line 2955
11200     while (nelems-- != 0) {
11201 #line 2955
11202         if (*tp > (long)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
11203 #line 2955
11204 
11205 #line 2955
11206 #ifdef ERANGE_FILL
11207 #line 2955
11208             if (fillp != NULL) memcpy(xp, fillp, 1);
11209 #line 2955
11210 #endif
11211 #line 2955
11212             status = NC_ERANGE;
11213 #line 2955
11214 
11215 #line 2955
11216 #ifdef ERANGE_FILL
11217 #line 2955
11218             xp++; tp++; continue;
11219 #line 2955
11220 #endif
11221 #line 2955
11222         }
11223 #line 2955
11224         *xp++ = (schar)  *tp++; /* type cast from long to schar */
11225 #line 2955
11226     }
11227 #line 2955
11228 
11229 #line 2955
11230 
11231 #line 2955
11232     if (rndup) {
11233 #line 2955
11234         (void) memcpy(xp, nada, (size_t)rndup);
11235 #line 2955
11236         xp += rndup;
11237 #line 2955
11238     }
11239 #line 2955
11240 
11241 #line 2955
11242     *xpp = (void *)xp;
11243 #line 2955
11244     return status;
11245 #line 2955
11246 }
11247 #line 2955
11248 
11249 int
11250 #line 2956
ncx_pad_putn_schar_float(void ** xpp,size_t nelems,const float * tp,void * fillp)11251 ncx_pad_putn_schar_float(void **xpp, size_t nelems, const float *tp, void *fillp)
11252 #line 2956
11253 {
11254 #line 2956
11255     int status = NC_NOERR;
11256 #line 2956
11257     size_t rndup = nelems % X_ALIGN;
11258 #line 2956
11259     schar *xp = (schar *) *xpp;
11260 #line 2956
11261 
11262 #line 2956
11263     if (rndup) rndup = X_ALIGN - rndup;
11264 #line 2956
11265 
11266 #line 2956
11267     while (nelems-- != 0) {
11268 #line 2956
11269         if (*tp > (float)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
11270 #line 2956
11271 
11272 #line 2956
11273 #ifdef ERANGE_FILL
11274 #line 2956
11275             if (fillp != NULL) memcpy(xp, fillp, 1);
11276 #line 2956
11277 #endif
11278 #line 2956
11279             status = NC_ERANGE;
11280 #line 2956
11281 
11282 #line 2956
11283 #ifdef ERANGE_FILL
11284 #line 2956
11285             xp++; tp++; continue;
11286 #line 2956
11287 #endif
11288 #line 2956
11289         }
11290 #line 2956
11291         *xp++ = (schar)  *tp++; /* type cast from float to schar */
11292 #line 2956
11293     }
11294 #line 2956
11295 
11296 #line 2956
11297 
11298 #line 2956
11299     if (rndup) {
11300 #line 2956
11301         (void) memcpy(xp, nada, (size_t)rndup);
11302 #line 2956
11303         xp += rndup;
11304 #line 2956
11305     }
11306 #line 2956
11307 
11308 #line 2956
11309     *xpp = (void *)xp;
11310 #line 2956
11311     return status;
11312 #line 2956
11313 }
11314 #line 2956
11315 
11316 int
11317 #line 2957
ncx_pad_putn_schar_double(void ** xpp,size_t nelems,const double * tp,void * fillp)11318 ncx_pad_putn_schar_double(void **xpp, size_t nelems, const double *tp, void *fillp)
11319 #line 2957
11320 {
11321 #line 2957
11322     int status = NC_NOERR;
11323 #line 2957
11324     size_t rndup = nelems % X_ALIGN;
11325 #line 2957
11326     schar *xp = (schar *) *xpp;
11327 #line 2957
11328 
11329 #line 2957
11330     if (rndup) rndup = X_ALIGN - rndup;
11331 #line 2957
11332 
11333 #line 2957
11334     while (nelems-- != 0) {
11335 #line 2957
11336         if (*tp > (double)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
11337 #line 2957
11338 
11339 #line 2957
11340 #ifdef ERANGE_FILL
11341 #line 2957
11342             if (fillp != NULL) memcpy(xp, fillp, 1);
11343 #line 2957
11344 #endif
11345 #line 2957
11346             status = NC_ERANGE;
11347 #line 2957
11348 
11349 #line 2957
11350 #ifdef ERANGE_FILL
11351 #line 2957
11352             xp++; tp++; continue;
11353 #line 2957
11354 #endif
11355 #line 2957
11356         }
11357 #line 2957
11358         *xp++ = (schar)  *tp++; /* type cast from double to schar */
11359 #line 2957
11360     }
11361 #line 2957
11362 
11363 #line 2957
11364 
11365 #line 2957
11366     if (rndup) {
11367 #line 2957
11368         (void) memcpy(xp, nada, (size_t)rndup);
11369 #line 2957
11370         xp += rndup;
11371 #line 2957
11372     }
11373 #line 2957
11374 
11375 #line 2957
11376     *xpp = (void *)xp;
11377 #line 2957
11378     return status;
11379 #line 2957
11380 }
11381 #line 2957
11382 
11383 int
11384 #line 2958
ncx_pad_putn_schar_longlong(void ** xpp,size_t nelems,const longlong * tp,void * fillp)11385 ncx_pad_putn_schar_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
11386 #line 2958
11387 {
11388 #line 2958
11389     int status = NC_NOERR;
11390 #line 2958
11391     size_t rndup = nelems % X_ALIGN;
11392 #line 2958
11393     schar *xp = (schar *) *xpp;
11394 #line 2958
11395 
11396 #line 2958
11397     if (rndup) rndup = X_ALIGN - rndup;
11398 #line 2958
11399 
11400 #line 2958
11401     while (nelems-- != 0) {
11402 #line 2958
11403         if (*tp > (longlong)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
11404 #line 2958
11405 
11406 #line 2958
11407 #ifdef ERANGE_FILL
11408 #line 2958
11409             if (fillp != NULL) memcpy(xp, fillp, 1);
11410 #line 2958
11411 #endif
11412 #line 2958
11413             status = NC_ERANGE;
11414 #line 2958
11415 
11416 #line 2958
11417 #ifdef ERANGE_FILL
11418 #line 2958
11419             xp++; tp++; continue;
11420 #line 2958
11421 #endif
11422 #line 2958
11423         }
11424 #line 2958
11425         *xp++ = (schar)  *tp++; /* type cast from longlong to schar */
11426 #line 2958
11427     }
11428 #line 2958
11429 
11430 #line 2958
11431 
11432 #line 2958
11433     if (rndup) {
11434 #line 2958
11435         (void) memcpy(xp, nada, (size_t)rndup);
11436 #line 2958
11437         xp += rndup;
11438 #line 2958
11439     }
11440 #line 2958
11441 
11442 #line 2958
11443     *xpp = (void *)xp;
11444 #line 2958
11445     return status;
11446 #line 2958
11447 }
11448 #line 2958
11449 
11450 int
11451 #line 2959
ncx_pad_putn_schar_ushort(void ** xpp,size_t nelems,const ushort * tp,void * fillp)11452 ncx_pad_putn_schar_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
11453 #line 2959
11454 {
11455 #line 2959
11456     int status = NC_NOERR;
11457 #line 2959
11458     size_t rndup = nelems % X_ALIGN;
11459 #line 2959
11460     schar *xp = (schar *) *xpp;
11461 #line 2959
11462 
11463 #line 2959
11464     if (rndup) rndup = X_ALIGN - rndup;
11465 #line 2959
11466 
11467 #line 2959
11468     while (nelems-- != 0) {
11469 #line 2959
11470         if (*tp > (ushort)X_SCHAR_MAX ) {
11471 #line 2959
11472 
11473 #line 2959
11474 #ifdef ERANGE_FILL
11475 #line 2959
11476             if (fillp != NULL) memcpy(xp, fillp, 1);
11477 #line 2959
11478 #endif
11479 #line 2959
11480             status = NC_ERANGE;
11481 #line 2959
11482 
11483 #line 2959
11484 #ifdef ERANGE_FILL
11485 #line 2959
11486             xp++; tp++; continue;
11487 #line 2959
11488 #endif
11489 #line 2959
11490         }
11491 #line 2959
11492         *xp++ = (schar)  *tp++; /* type cast from ushort to schar */
11493 #line 2959
11494     }
11495 #line 2959
11496 
11497 #line 2959
11498 
11499 #line 2959
11500     if (rndup) {
11501 #line 2959
11502         (void) memcpy(xp, nada, (size_t)rndup);
11503 #line 2959
11504         xp += rndup;
11505 #line 2959
11506     }
11507 #line 2959
11508 
11509 #line 2959
11510     *xpp = (void *)xp;
11511 #line 2959
11512     return status;
11513 #line 2959
11514 }
11515 #line 2959
11516 
11517 int
11518 #line 2960
ncx_pad_putn_schar_uint(void ** xpp,size_t nelems,const uint * tp,void * fillp)11519 ncx_pad_putn_schar_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
11520 #line 2960
11521 {
11522 #line 2960
11523     int status = NC_NOERR;
11524 #line 2960
11525     size_t rndup = nelems % X_ALIGN;
11526 #line 2960
11527     schar *xp = (schar *) *xpp;
11528 #line 2960
11529 
11530 #line 2960
11531     if (rndup) rndup = X_ALIGN - rndup;
11532 #line 2960
11533 
11534 #line 2960
11535     while (nelems-- != 0) {
11536 #line 2960
11537         if (*tp > (uint)X_SCHAR_MAX ) {
11538 #line 2960
11539 
11540 #line 2960
11541 #ifdef ERANGE_FILL
11542 #line 2960
11543             if (fillp != NULL) memcpy(xp, fillp, 1);
11544 #line 2960
11545 #endif
11546 #line 2960
11547             status = NC_ERANGE;
11548 #line 2960
11549 
11550 #line 2960
11551 #ifdef ERANGE_FILL
11552 #line 2960
11553             xp++; tp++; continue;
11554 #line 2960
11555 #endif
11556 #line 2960
11557         }
11558 #line 2960
11559         *xp++ = (schar)  *tp++; /* type cast from uint to schar */
11560 #line 2960
11561     }
11562 #line 2960
11563 
11564 #line 2960
11565 
11566 #line 2960
11567     if (rndup) {
11568 #line 2960
11569         (void) memcpy(xp, nada, (size_t)rndup);
11570 #line 2960
11571         xp += rndup;
11572 #line 2960
11573     }
11574 #line 2960
11575 
11576 #line 2960
11577     *xpp = (void *)xp;
11578 #line 2960
11579     return status;
11580 #line 2960
11581 }
11582 #line 2960
11583 
11584 int
11585 #line 2961
ncx_pad_putn_schar_ulonglong(void ** xpp,size_t nelems,const ulonglong * tp,void * fillp)11586 ncx_pad_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
11587 #line 2961
11588 {
11589 #line 2961
11590     int status = NC_NOERR;
11591 #line 2961
11592     size_t rndup = nelems % X_ALIGN;
11593 #line 2961
11594     schar *xp = (schar *) *xpp;
11595 #line 2961
11596 
11597 #line 2961
11598     if (rndup) rndup = X_ALIGN - rndup;
11599 #line 2961
11600 
11601 #line 2961
11602     while (nelems-- != 0) {
11603 #line 2961
11604         if (*tp > (ulonglong)X_SCHAR_MAX ) {
11605 #line 2961
11606 
11607 #line 2961
11608 #ifdef ERANGE_FILL
11609 #line 2961
11610             if (fillp != NULL) memcpy(xp, fillp, 1);
11611 #line 2961
11612 #endif
11613 #line 2961
11614             status = NC_ERANGE;
11615 #line 2961
11616 
11617 #line 2961
11618 #ifdef ERANGE_FILL
11619 #line 2961
11620             xp++; tp++; continue;
11621 #line 2961
11622 #endif
11623 #line 2961
11624         }
11625 #line 2961
11626         *xp++ = (schar)  *tp++; /* type cast from ulonglong to schar */
11627 #line 2961
11628     }
11629 #line 2961
11630 
11631 #line 2961
11632 
11633 #line 2961
11634     if (rndup) {
11635 #line 2961
11636         (void) memcpy(xp, nada, (size_t)rndup);
11637 #line 2961
11638         xp += rndup;
11639 #line 2961
11640     }
11641 #line 2961
11642 
11643 #line 2961
11644     *xpp = (void *)xp;
11645 #line 2961
11646     return status;
11647 #line 2961
11648 }
11649 #line 2961
11650 
11651 
11652 
11653 /* uchar ---------------------------------------------------------------------*/
11654 #line 2967
11655 int
ncx_getn_uchar_schar(const void ** xpp,size_t nelems,schar * tp)11656 ncx_getn_uchar_schar(const void **xpp, size_t nelems, schar *tp)
11657 {
11658     int status = NC_NOERR;
11659     uchar *xp = (uchar *)(*xpp);
11660 
11661     while (nelems-- != 0) {
11662         if (*xp > SCHAR_MAX) {
11663             *tp = NC_FILL_BYTE;
11664        	    status = NC_ERANGE;
11665 
11666 #line 2977
11667 #ifdef ERANGE_FILL
11668 #line 2977
11669             xp++; tp++; continue;
11670 #line 2977
11671 #endif
11672         }
11673 	*tp++ = (schar) *xp++; /* type cast from uchar to schar */
11674     }
11675 
11676     *xpp = (const void *)xp;
11677     return status;
11678 }
11679 #line 2986
11680 int
ncx_getn_uchar_uchar(const void ** xpp,size_t nelems,uchar * tp)11681 ncx_getn_uchar_uchar(const void **xpp, size_t nelems, uchar *tp)
11682 {
11683 		(void) memcpy(tp, *xpp, (size_t)nelems);
11684 #line 2989
11685 	*xpp = (void *)((char *)(*xpp) + nelems);
11686 #line 2989
11687 	return NC_NOERR;
11688 #line 2989
11689 
11690 }
11691 int
11692 #line 2991
ncx_getn_uchar_short(const void ** xpp,size_t nelems,short * tp)11693 ncx_getn_uchar_short(const void **xpp, size_t nelems, short *tp)
11694 #line 2991
11695 {
11696 #line 2991
11697     int status = NC_NOERR;
11698 #line 2991
11699     uchar *xp = (uchar *)(*xpp);
11700 #line 2991
11701 
11702 #line 2991
11703     while (nelems-- != 0) {
11704 #line 2991
11705 
11706 #line 2991
11707         *tp++ = (short)  (*xp++);  /* type cast from uchar to short */
11708 #line 2991
11709     }
11710 #line 2991
11711 
11712 #line 2991
11713     *xpp = (const void *)xp;
11714 #line 2991
11715     return status;
11716 #line 2991
11717 }
11718 #line 2991
11719 
11720 int
11721 #line 2992
ncx_getn_uchar_int(const void ** xpp,size_t nelems,int * tp)11722 ncx_getn_uchar_int(const void **xpp, size_t nelems, int *tp)
11723 #line 2992
11724 {
11725 #line 2992
11726     int status = NC_NOERR;
11727 #line 2992
11728     uchar *xp = (uchar *)(*xpp);
11729 #line 2992
11730 
11731 #line 2992
11732     while (nelems-- != 0) {
11733 #line 2992
11734 
11735 #line 2992
11736         *tp++ = (int)  (*xp++);  /* type cast from uchar to int */
11737 #line 2992
11738     }
11739 #line 2992
11740 
11741 #line 2992
11742     *xpp = (const void *)xp;
11743 #line 2992
11744     return status;
11745 #line 2992
11746 }
11747 #line 2992
11748 
11749 int
11750 #line 2993
ncx_getn_uchar_long(const void ** xpp,size_t nelems,long * tp)11751 ncx_getn_uchar_long(const void **xpp, size_t nelems, long *tp)
11752 #line 2993
11753 {
11754 #line 2993
11755     int status = NC_NOERR;
11756 #line 2993
11757     uchar *xp = (uchar *)(*xpp);
11758 #line 2993
11759 
11760 #line 2993
11761     while (nelems-- != 0) {
11762 #line 2993
11763 
11764 #line 2993
11765         *tp++ = (long)  (*xp++);  /* type cast from uchar to long */
11766 #line 2993
11767     }
11768 #line 2993
11769 
11770 #line 2993
11771     *xpp = (const void *)xp;
11772 #line 2993
11773     return status;
11774 #line 2993
11775 }
11776 #line 2993
11777 
11778 int
11779 #line 2994
ncx_getn_uchar_float(const void ** xpp,size_t nelems,float * tp)11780 ncx_getn_uchar_float(const void **xpp, size_t nelems, float *tp)
11781 #line 2994
11782 {
11783 #line 2994
11784     int status = NC_NOERR;
11785 #line 2994
11786     uchar *xp = (uchar *)(*xpp);
11787 #line 2994
11788 
11789 #line 2994
11790     while (nelems-- != 0) {
11791 #line 2994
11792 
11793 #line 2994
11794         *tp++ = (float)  (*xp++);  /* type cast from uchar to float */
11795 #line 2994
11796     }
11797 #line 2994
11798 
11799 #line 2994
11800     *xpp = (const void *)xp;
11801 #line 2994
11802     return status;
11803 #line 2994
11804 }
11805 #line 2994
11806 
11807 int
11808 #line 2995
ncx_getn_uchar_double(const void ** xpp,size_t nelems,double * tp)11809 ncx_getn_uchar_double(const void **xpp, size_t nelems, double *tp)
11810 #line 2995
11811 {
11812 #line 2995
11813     int status = NC_NOERR;
11814 #line 2995
11815     uchar *xp = (uchar *)(*xpp);
11816 #line 2995
11817 
11818 #line 2995
11819     while (nelems-- != 0) {
11820 #line 2995
11821 
11822 #line 2995
11823         *tp++ = (double)  (*xp++);  /* type cast from uchar to double */
11824 #line 2995
11825     }
11826 #line 2995
11827 
11828 #line 2995
11829     *xpp = (const void *)xp;
11830 #line 2995
11831     return status;
11832 #line 2995
11833 }
11834 #line 2995
11835 
11836 int
11837 #line 2996
ncx_getn_uchar_longlong(const void ** xpp,size_t nelems,longlong * tp)11838 ncx_getn_uchar_longlong(const void **xpp, size_t nelems, longlong *tp)
11839 #line 2996
11840 {
11841 #line 2996
11842     int status = NC_NOERR;
11843 #line 2996
11844     uchar *xp = (uchar *)(*xpp);
11845 #line 2996
11846 
11847 #line 2996
11848     while (nelems-- != 0) {
11849 #line 2996
11850 
11851 #line 2996
11852         *tp++ = (longlong)  (*xp++);  /* type cast from uchar to longlong */
11853 #line 2996
11854     }
11855 #line 2996
11856 
11857 #line 2996
11858     *xpp = (const void *)xp;
11859 #line 2996
11860     return status;
11861 #line 2996
11862 }
11863 #line 2996
11864 
11865 int
11866 #line 2997
ncx_getn_uchar_ushort(const void ** xpp,size_t nelems,ushort * tp)11867 ncx_getn_uchar_ushort(const void **xpp, size_t nelems, ushort *tp)
11868 #line 2997
11869 {
11870 #line 2997
11871     int status = NC_NOERR;
11872 #line 2997
11873     uchar *xp = (uchar *)(*xpp);
11874 #line 2997
11875 
11876 #line 2997
11877     while (nelems-- != 0) {
11878 #line 2997
11879 
11880 #line 2997
11881         *tp++ = (ushort)  (*xp++);  /* type cast from uchar to ushort */
11882 #line 2997
11883     }
11884 #line 2997
11885 
11886 #line 2997
11887     *xpp = (const void *)xp;
11888 #line 2997
11889     return status;
11890 #line 2997
11891 }
11892 #line 2997
11893 
11894 int
11895 #line 2998
ncx_getn_uchar_uint(const void ** xpp,size_t nelems,uint * tp)11896 ncx_getn_uchar_uint(const void **xpp, size_t nelems, uint *tp)
11897 #line 2998
11898 {
11899 #line 2998
11900     int status = NC_NOERR;
11901 #line 2998
11902     uchar *xp = (uchar *)(*xpp);
11903 #line 2998
11904 
11905 #line 2998
11906     while (nelems-- != 0) {
11907 #line 2998
11908 
11909 #line 2998
11910         *tp++ = (uint)  (*xp++);  /* type cast from uchar to uint */
11911 #line 2998
11912     }
11913 #line 2998
11914 
11915 #line 2998
11916     *xpp = (const void *)xp;
11917 #line 2998
11918     return status;
11919 #line 2998
11920 }
11921 #line 2998
11922 
11923 int
11924 #line 2999
ncx_getn_uchar_ulonglong(const void ** xpp,size_t nelems,ulonglong * tp)11925 ncx_getn_uchar_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
11926 #line 2999
11927 {
11928 #line 2999
11929     int status = NC_NOERR;
11930 #line 2999
11931     uchar *xp = (uchar *)(*xpp);
11932 #line 2999
11933 
11934 #line 2999
11935     while (nelems-- != 0) {
11936 #line 2999
11937 
11938 #line 2999
11939         *tp++ = (ulonglong)  (*xp++);  /* type cast from uchar to ulonglong */
11940 #line 2999
11941     }
11942 #line 2999
11943 
11944 #line 2999
11945     *xpp = (const void *)xp;
11946 #line 2999
11947     return status;
11948 #line 2999
11949 }
11950 #line 2999
11951 
11952 
11953 #line 3002
11954 int
ncx_pad_getn_uchar_schar(const void ** xpp,size_t nelems,schar * tp)11955 ncx_pad_getn_uchar_schar(const void **xpp, size_t nelems, schar *tp)
11956 {
11957     int status = NC_NOERR;
11958     size_t rndup = nelems % X_ALIGN;
11959     uchar *xp = (uchar *) *xpp;
11960 
11961     if (rndup) rndup = X_ALIGN - rndup;
11962 
11963     while (nelems-- != 0) {
11964         if (*xp > SCHAR_MAX) {
11965             *tp = NC_FILL_BYTE;
11966             status = NC_ERANGE;
11967 
11968 #line 3015
11969 #ifdef ERANGE_FILL
11970 #line 3015
11971             xp++; tp++; continue;
11972 #line 3015
11973 #endif
11974         }
11975         *tp++ = (schar) *xp++; /* type cast from uchar to schar */
11976     }
11977 
11978     *xpp = (void *)(xp + rndup);
11979     return status;
11980 }
11981 #line 3024
11982 int
ncx_pad_getn_uchar_uchar(const void ** xpp,size_t nelems,uchar * tp)11983 ncx_pad_getn_uchar_uchar(const void **xpp, size_t nelems, uchar *tp)
11984 {
11985 		size_t rndup = nelems % X_ALIGN;
11986 #line 3027
11987 
11988 #line 3027
11989 	if (rndup)
11990 #line 3027
11991 		rndup = X_ALIGN - rndup;
11992 #line 3027
11993 
11994 #line 3027
11995 	(void) memcpy(tp, *xpp, (size_t)nelems);
11996 #line 3027
11997 	*xpp = (void *)((char *)(*xpp) + nelems + rndup);
11998 #line 3027
11999 
12000 #line 3027
12001 	return NC_NOERR;
12002 #line 3027
12003 
12004 }
12005 int
12006 #line 3029
ncx_pad_getn_uchar_short(const void ** xpp,size_t nelems,short * tp)12007 ncx_pad_getn_uchar_short(const void **xpp, size_t nelems, short *tp)
12008 #line 3029
12009 {
12010 #line 3029
12011     int status = NC_NOERR;
12012 #line 3029
12013     size_t rndup = nelems % X_ALIGN;
12014 #line 3029
12015     uchar *xp = (uchar *) *xpp;
12016 #line 3029
12017 
12018 #line 3029
12019     if (rndup)
12020 #line 3029
12021         rndup = X_ALIGN - rndup;
12022 #line 3029
12023 
12024 #line 3029
12025     while (nelems-- != 0) {
12026 #line 3029
12027 
12028 #line 3029
12029         *tp++ = (short)  (*xp++);  /* type cast from uchar to short */
12030 #line 3029
12031     }
12032 #line 3029
12033 
12034 #line 3029
12035     *xpp = (void *)(xp + rndup);
12036 #line 3029
12037     return status;
12038 #line 3029
12039 }
12040 #line 3029
12041 
12042 int
12043 #line 3030
ncx_pad_getn_uchar_int(const void ** xpp,size_t nelems,int * tp)12044 ncx_pad_getn_uchar_int(const void **xpp, size_t nelems, int *tp)
12045 #line 3030
12046 {
12047 #line 3030
12048     int status = NC_NOERR;
12049 #line 3030
12050     size_t rndup = nelems % X_ALIGN;
12051 #line 3030
12052     uchar *xp = (uchar *) *xpp;
12053 #line 3030
12054 
12055 #line 3030
12056     if (rndup)
12057 #line 3030
12058         rndup = X_ALIGN - rndup;
12059 #line 3030
12060 
12061 #line 3030
12062     while (nelems-- != 0) {
12063 #line 3030
12064 
12065 #line 3030
12066         *tp++ = (int)  (*xp++);  /* type cast from uchar to int */
12067 #line 3030
12068     }
12069 #line 3030
12070 
12071 #line 3030
12072     *xpp = (void *)(xp + rndup);
12073 #line 3030
12074     return status;
12075 #line 3030
12076 }
12077 #line 3030
12078 
12079 int
12080 #line 3031
ncx_pad_getn_uchar_long(const void ** xpp,size_t nelems,long * tp)12081 ncx_pad_getn_uchar_long(const void **xpp, size_t nelems, long *tp)
12082 #line 3031
12083 {
12084 #line 3031
12085     int status = NC_NOERR;
12086 #line 3031
12087     size_t rndup = nelems % X_ALIGN;
12088 #line 3031
12089     uchar *xp = (uchar *) *xpp;
12090 #line 3031
12091 
12092 #line 3031
12093     if (rndup)
12094 #line 3031
12095         rndup = X_ALIGN - rndup;
12096 #line 3031
12097 
12098 #line 3031
12099     while (nelems-- != 0) {
12100 #line 3031
12101 
12102 #line 3031
12103         *tp++ = (long)  (*xp++);  /* type cast from uchar to long */
12104 #line 3031
12105     }
12106 #line 3031
12107 
12108 #line 3031
12109     *xpp = (void *)(xp + rndup);
12110 #line 3031
12111     return status;
12112 #line 3031
12113 }
12114 #line 3031
12115 
12116 int
12117 #line 3032
ncx_pad_getn_uchar_float(const void ** xpp,size_t nelems,float * tp)12118 ncx_pad_getn_uchar_float(const void **xpp, size_t nelems, float *tp)
12119 #line 3032
12120 {
12121 #line 3032
12122     int status = NC_NOERR;
12123 #line 3032
12124     size_t rndup = nelems % X_ALIGN;
12125 #line 3032
12126     uchar *xp = (uchar *) *xpp;
12127 #line 3032
12128 
12129 #line 3032
12130     if (rndup)
12131 #line 3032
12132         rndup = X_ALIGN - rndup;
12133 #line 3032
12134 
12135 #line 3032
12136     while (nelems-- != 0) {
12137 #line 3032
12138 
12139 #line 3032
12140         *tp++ = (float)  (*xp++);  /* type cast from uchar to float */
12141 #line 3032
12142     }
12143 #line 3032
12144 
12145 #line 3032
12146     *xpp = (void *)(xp + rndup);
12147 #line 3032
12148     return status;
12149 #line 3032
12150 }
12151 #line 3032
12152 
12153 int
12154 #line 3033
ncx_pad_getn_uchar_double(const void ** xpp,size_t nelems,double * tp)12155 ncx_pad_getn_uchar_double(const void **xpp, size_t nelems, double *tp)
12156 #line 3033
12157 {
12158 #line 3033
12159     int status = NC_NOERR;
12160 #line 3033
12161     size_t rndup = nelems % X_ALIGN;
12162 #line 3033
12163     uchar *xp = (uchar *) *xpp;
12164 #line 3033
12165 
12166 #line 3033
12167     if (rndup)
12168 #line 3033
12169         rndup = X_ALIGN - rndup;
12170 #line 3033
12171 
12172 #line 3033
12173     while (nelems-- != 0) {
12174 #line 3033
12175 
12176 #line 3033
12177         *tp++ = (double)  (*xp++);  /* type cast from uchar to double */
12178 #line 3033
12179     }
12180 #line 3033
12181 
12182 #line 3033
12183     *xpp = (void *)(xp + rndup);
12184 #line 3033
12185     return status;
12186 #line 3033
12187 }
12188 #line 3033
12189 
12190 int
12191 #line 3034
ncx_pad_getn_uchar_longlong(const void ** xpp,size_t nelems,longlong * tp)12192 ncx_pad_getn_uchar_longlong(const void **xpp, size_t nelems, longlong *tp)
12193 #line 3034
12194 {
12195 #line 3034
12196     int status = NC_NOERR;
12197 #line 3034
12198     size_t rndup = nelems % X_ALIGN;
12199 #line 3034
12200     uchar *xp = (uchar *) *xpp;
12201 #line 3034
12202 
12203 #line 3034
12204     if (rndup)
12205 #line 3034
12206         rndup = X_ALIGN - rndup;
12207 #line 3034
12208 
12209 #line 3034
12210     while (nelems-- != 0) {
12211 #line 3034
12212 
12213 #line 3034
12214         *tp++ = (longlong)  (*xp++);  /* type cast from uchar to longlong */
12215 #line 3034
12216     }
12217 #line 3034
12218 
12219 #line 3034
12220     *xpp = (void *)(xp + rndup);
12221 #line 3034
12222     return status;
12223 #line 3034
12224 }
12225 #line 3034
12226 
12227 int
12228 #line 3035
ncx_pad_getn_uchar_ushort(const void ** xpp,size_t nelems,ushort * tp)12229 ncx_pad_getn_uchar_ushort(const void **xpp, size_t nelems, ushort *tp)
12230 #line 3035
12231 {
12232 #line 3035
12233     int status = NC_NOERR;
12234 #line 3035
12235     size_t rndup = nelems % X_ALIGN;
12236 #line 3035
12237     uchar *xp = (uchar *) *xpp;
12238 #line 3035
12239 
12240 #line 3035
12241     if (rndup)
12242 #line 3035
12243         rndup = X_ALIGN - rndup;
12244 #line 3035
12245 
12246 #line 3035
12247     while (nelems-- != 0) {
12248 #line 3035
12249 
12250 #line 3035
12251         *tp++ = (ushort)  (*xp++);  /* type cast from uchar to ushort */
12252 #line 3035
12253     }
12254 #line 3035
12255 
12256 #line 3035
12257     *xpp = (void *)(xp + rndup);
12258 #line 3035
12259     return status;
12260 #line 3035
12261 }
12262 #line 3035
12263 
12264 int
12265 #line 3036
ncx_pad_getn_uchar_uint(const void ** xpp,size_t nelems,uint * tp)12266 ncx_pad_getn_uchar_uint(const void **xpp, size_t nelems, uint *tp)
12267 #line 3036
12268 {
12269 #line 3036
12270     int status = NC_NOERR;
12271 #line 3036
12272     size_t rndup = nelems % X_ALIGN;
12273 #line 3036
12274     uchar *xp = (uchar *) *xpp;
12275 #line 3036
12276 
12277 #line 3036
12278     if (rndup)
12279 #line 3036
12280         rndup = X_ALIGN - rndup;
12281 #line 3036
12282 
12283 #line 3036
12284     while (nelems-- != 0) {
12285 #line 3036
12286 
12287 #line 3036
12288         *tp++ = (uint)  (*xp++);  /* type cast from uchar to uint */
12289 #line 3036
12290     }
12291 #line 3036
12292 
12293 #line 3036
12294     *xpp = (void *)(xp + rndup);
12295 #line 3036
12296     return status;
12297 #line 3036
12298 }
12299 #line 3036
12300 
12301 int
12302 #line 3037
ncx_pad_getn_uchar_ulonglong(const void ** xpp,size_t nelems,ulonglong * tp)12303 ncx_pad_getn_uchar_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
12304 #line 3037
12305 {
12306 #line 3037
12307     int status = NC_NOERR;
12308 #line 3037
12309     size_t rndup = nelems % X_ALIGN;
12310 #line 3037
12311     uchar *xp = (uchar *) *xpp;
12312 #line 3037
12313 
12314 #line 3037
12315     if (rndup)
12316 #line 3037
12317         rndup = X_ALIGN - rndup;
12318 #line 3037
12319 
12320 #line 3037
12321     while (nelems-- != 0) {
12322 #line 3037
12323 
12324 #line 3037
12325         *tp++ = (ulonglong)  (*xp++);  /* type cast from uchar to ulonglong */
12326 #line 3037
12327     }
12328 #line 3037
12329 
12330 #line 3037
12331     *xpp = (void *)(xp + rndup);
12332 #line 3037
12333     return status;
12334 #line 3037
12335 }
12336 #line 3037
12337 
12338 
12339 #line 3040
12340 int
ncx_putn_uchar_schar(void ** xpp,size_t nelems,const schar * tp,void * fillp)12341 ncx_putn_uchar_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
12342 {
12343     int status = NC_NOERR;
12344     uchar *xp = (uchar *) *xpp;
12345 
12346     while (nelems-- != 0) {
12347         if (*tp < 0) {
12348 
12349 #line 3048
12350 #ifdef ERANGE_FILL
12351 #line 3048
12352             if (fillp != NULL) memcpy(xp, fillp, 1);
12353 #line 3048
12354 #endif
12355             status = NC_ERANGE;
12356 
12357 #line 3050
12358 #ifdef ERANGE_FILL
12359 #line 3050
12360             xp++; tp++; continue;
12361 #line 3050
12362 #endif
12363         }
12364         *xp++ = (uchar) (signed) *tp++; /* type cast from schar to uchar */
12365     }
12366 
12367     *xpp = (void *)xp;
12368     return status;
12369 }
12370 #line 3059
12371 int
ncx_putn_uchar_uchar(void ** xpp,size_t nelems,const uchar * tp,void * fillp)12372 ncx_putn_uchar_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
12373 {
12374 		(void) memcpy(*xpp, tp, (size_t)nelems);
12375 #line 3062
12376 	*xpp = (void *)((char *)(*xpp) + nelems);
12377 #line 3062
12378 
12379 #line 3062
12380 	return NC_NOERR;
12381 #line 3062
12382 
12383 }
12384 int
12385 #line 3064
ncx_putn_uchar_short(void ** xpp,size_t nelems,const short * tp,void * fillp)12386 ncx_putn_uchar_short(void **xpp, size_t nelems, const short *tp, void *fillp)
12387 #line 3064
12388 {
12389 #line 3064
12390     int status = NC_NOERR;
12391 #line 3064
12392     uchar *xp = (uchar *) *xpp;
12393 #line 3064
12394 
12395 #line 3064
12396     while (nelems-- != 0) {
12397 #line 3064
12398         if (*tp > (short)X_UCHAR_MAX || *tp < 0) {
12399 #line 3064
12400 
12401 #line 3064
12402 #ifdef ERANGE_FILL
12403 #line 3064
12404             if (fillp != NULL) memcpy(xp, fillp, 1);
12405 #line 3064
12406 #endif
12407 #line 3064
12408             status = NC_ERANGE;
12409 #line 3064
12410 
12411 #line 3064
12412 #ifdef ERANGE_FILL
12413 #line 3064
12414             xp++; tp++; continue;
12415 #line 3064
12416 #endif
12417 #line 3064
12418         }
12419 #line 3064
12420         *xp++ = (uchar) (signed) *tp++; /* type cast from short to uchar */
12421 #line 3064
12422     }
12423 #line 3064
12424 
12425 #line 3064
12426     *xpp = (void *)xp;
12427 #line 3064
12428     return status;
12429 #line 3064
12430 }
12431 #line 3064
12432 
12433 int
12434 #line 3065
ncx_putn_uchar_int(void ** xpp,size_t nelems,const int * tp,void * fillp)12435 ncx_putn_uchar_int(void **xpp, size_t nelems, const int *tp, void *fillp)
12436 #line 3065
12437 {
12438 #line 3065
12439     int status = NC_NOERR;
12440 #line 3065
12441     uchar *xp = (uchar *) *xpp;
12442 #line 3065
12443 
12444 #line 3065
12445     while (nelems-- != 0) {
12446 #line 3065
12447         if (*tp > (int)X_UCHAR_MAX || *tp < 0) {
12448 #line 3065
12449 
12450 #line 3065
12451 #ifdef ERANGE_FILL
12452 #line 3065
12453             if (fillp != NULL) memcpy(xp, fillp, 1);
12454 #line 3065
12455 #endif
12456 #line 3065
12457             status = NC_ERANGE;
12458 #line 3065
12459 
12460 #line 3065
12461 #ifdef ERANGE_FILL
12462 #line 3065
12463             xp++; tp++; continue;
12464 #line 3065
12465 #endif
12466 #line 3065
12467         }
12468 #line 3065
12469         *xp++ = (uchar) (signed) *tp++; /* type cast from int to uchar */
12470 #line 3065
12471     }
12472 #line 3065
12473 
12474 #line 3065
12475     *xpp = (void *)xp;
12476 #line 3065
12477     return status;
12478 #line 3065
12479 }
12480 #line 3065
12481 
12482 int
12483 #line 3066
ncx_putn_uchar_long(void ** xpp,size_t nelems,const long * tp,void * fillp)12484 ncx_putn_uchar_long(void **xpp, size_t nelems, const long *tp, void *fillp)
12485 #line 3066
12486 {
12487 #line 3066
12488     int status = NC_NOERR;
12489 #line 3066
12490     uchar *xp = (uchar *) *xpp;
12491 #line 3066
12492 
12493 #line 3066
12494     while (nelems-- != 0) {
12495 #line 3066
12496         if (*tp > (long)X_UCHAR_MAX || *tp < 0) {
12497 #line 3066
12498 
12499 #line 3066
12500 #ifdef ERANGE_FILL
12501 #line 3066
12502             if (fillp != NULL) memcpy(xp, fillp, 1);
12503 #line 3066
12504 #endif
12505 #line 3066
12506             status = NC_ERANGE;
12507 #line 3066
12508 
12509 #line 3066
12510 #ifdef ERANGE_FILL
12511 #line 3066
12512             xp++; tp++; continue;
12513 #line 3066
12514 #endif
12515 #line 3066
12516         }
12517 #line 3066
12518         *xp++ = (uchar) (signed) *tp++; /* type cast from long to uchar */
12519 #line 3066
12520     }
12521 #line 3066
12522 
12523 #line 3066
12524     *xpp = (void *)xp;
12525 #line 3066
12526     return status;
12527 #line 3066
12528 }
12529 #line 3066
12530 
12531 int
12532 #line 3067
ncx_putn_uchar_float(void ** xpp,size_t nelems,const float * tp,void * fillp)12533 ncx_putn_uchar_float(void **xpp, size_t nelems, const float *tp, void *fillp)
12534 #line 3067
12535 {
12536 #line 3067
12537     int status = NC_NOERR;
12538 #line 3067
12539     uchar *xp = (uchar *) *xpp;
12540 #line 3067
12541 
12542 #line 3067
12543     while (nelems-- != 0) {
12544 #line 3067
12545         if (*tp > (float)X_UCHAR_MAX || *tp < 0) {
12546 #line 3067
12547 
12548 #line 3067
12549 #ifdef ERANGE_FILL
12550 #line 3067
12551             if (fillp != NULL) memcpy(xp, fillp, 1);
12552 #line 3067
12553 #endif
12554 #line 3067
12555             status = NC_ERANGE;
12556 #line 3067
12557 
12558 #line 3067
12559 #ifdef ERANGE_FILL
12560 #line 3067
12561             xp++; tp++; continue;
12562 #line 3067
12563 #endif
12564 #line 3067
12565         }
12566 #line 3067
12567         *xp++ = (uchar) (signed) *tp++; /* type cast from float to uchar */
12568 #line 3067
12569     }
12570 #line 3067
12571 
12572 #line 3067
12573     *xpp = (void *)xp;
12574 #line 3067
12575     return status;
12576 #line 3067
12577 }
12578 #line 3067
12579 
12580 int
12581 #line 3068
ncx_putn_uchar_double(void ** xpp,size_t nelems,const double * tp,void * fillp)12582 ncx_putn_uchar_double(void **xpp, size_t nelems, const double *tp, void *fillp)
12583 #line 3068
12584 {
12585 #line 3068
12586     int status = NC_NOERR;
12587 #line 3068
12588     uchar *xp = (uchar *) *xpp;
12589 #line 3068
12590 
12591 #line 3068
12592     while (nelems-- != 0) {
12593 #line 3068
12594         if (*tp > (double)X_UCHAR_MAX || *tp < 0) {
12595 #line 3068
12596 
12597 #line 3068
12598 #ifdef ERANGE_FILL
12599 #line 3068
12600             if (fillp != NULL) memcpy(xp, fillp, 1);
12601 #line 3068
12602 #endif
12603 #line 3068
12604             status = NC_ERANGE;
12605 #line 3068
12606 
12607 #line 3068
12608 #ifdef ERANGE_FILL
12609 #line 3068
12610             xp++; tp++; continue;
12611 #line 3068
12612 #endif
12613 #line 3068
12614         }
12615 #line 3068
12616         *xp++ = (uchar) (signed) *tp++; /* type cast from double to uchar */
12617 #line 3068
12618     }
12619 #line 3068
12620 
12621 #line 3068
12622     *xpp = (void *)xp;
12623 #line 3068
12624     return status;
12625 #line 3068
12626 }
12627 #line 3068
12628 
12629 int
12630 #line 3069
ncx_putn_uchar_longlong(void ** xpp,size_t nelems,const longlong * tp,void * fillp)12631 ncx_putn_uchar_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
12632 #line 3069
12633 {
12634 #line 3069
12635     int status = NC_NOERR;
12636 #line 3069
12637     uchar *xp = (uchar *) *xpp;
12638 #line 3069
12639 
12640 #line 3069
12641     while (nelems-- != 0) {
12642 #line 3069
12643         if (*tp > (longlong)X_UCHAR_MAX || *tp < 0) {
12644 #line 3069
12645 
12646 #line 3069
12647 #ifdef ERANGE_FILL
12648 #line 3069
12649             if (fillp != NULL) memcpy(xp, fillp, 1);
12650 #line 3069
12651 #endif
12652 #line 3069
12653             status = NC_ERANGE;
12654 #line 3069
12655 
12656 #line 3069
12657 #ifdef ERANGE_FILL
12658 #line 3069
12659             xp++; tp++; continue;
12660 #line 3069
12661 #endif
12662 #line 3069
12663         }
12664 #line 3069
12665         *xp++ = (uchar) (signed) *tp++; /* type cast from longlong to uchar */
12666 #line 3069
12667     }
12668 #line 3069
12669 
12670 #line 3069
12671     *xpp = (void *)xp;
12672 #line 3069
12673     return status;
12674 #line 3069
12675 }
12676 #line 3069
12677 
12678 int
12679 #line 3070
ncx_putn_uchar_ushort(void ** xpp,size_t nelems,const ushort * tp,void * fillp)12680 ncx_putn_uchar_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
12681 #line 3070
12682 {
12683 #line 3070
12684     int status = NC_NOERR;
12685 #line 3070
12686     uchar *xp = (uchar *) *xpp;
12687 #line 3070
12688 
12689 #line 3070
12690     while (nelems-- != 0) {
12691 #line 3070
12692         if (*tp > (ushort)X_UCHAR_MAX ) {
12693 #line 3070
12694 
12695 #line 3070
12696 #ifdef ERANGE_FILL
12697 #line 3070
12698             if (fillp != NULL) memcpy(xp, fillp, 1);
12699 #line 3070
12700 #endif
12701 #line 3070
12702             status = NC_ERANGE;
12703 #line 3070
12704 
12705 #line 3070
12706 #ifdef ERANGE_FILL
12707 #line 3070
12708             xp++; tp++; continue;
12709 #line 3070
12710 #endif
12711 #line 3070
12712         }
12713 #line 3070
12714         *xp++ = (uchar)  *tp++; /* type cast from ushort to uchar */
12715 #line 3070
12716     }
12717 #line 3070
12718 
12719 #line 3070
12720     *xpp = (void *)xp;
12721 #line 3070
12722     return status;
12723 #line 3070
12724 }
12725 #line 3070
12726 
12727 int
12728 #line 3071
ncx_putn_uchar_uint(void ** xpp,size_t nelems,const uint * tp,void * fillp)12729 ncx_putn_uchar_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
12730 #line 3071
12731 {
12732 #line 3071
12733     int status = NC_NOERR;
12734 #line 3071
12735     uchar *xp = (uchar *) *xpp;
12736 #line 3071
12737 
12738 #line 3071
12739     while (nelems-- != 0) {
12740 #line 3071
12741         if (*tp > (uint)X_UCHAR_MAX ) {
12742 #line 3071
12743 
12744 #line 3071
12745 #ifdef ERANGE_FILL
12746 #line 3071
12747             if (fillp != NULL) memcpy(xp, fillp, 1);
12748 #line 3071
12749 #endif
12750 #line 3071
12751             status = NC_ERANGE;
12752 #line 3071
12753 
12754 #line 3071
12755 #ifdef ERANGE_FILL
12756 #line 3071
12757             xp++; tp++; continue;
12758 #line 3071
12759 #endif
12760 #line 3071
12761         }
12762 #line 3071
12763         *xp++ = (uchar)  *tp++; /* type cast from uint to uchar */
12764 #line 3071
12765     }
12766 #line 3071
12767 
12768 #line 3071
12769     *xpp = (void *)xp;
12770 #line 3071
12771     return status;
12772 #line 3071
12773 }
12774 #line 3071
12775 
12776 int
12777 #line 3072
ncx_putn_uchar_ulonglong(void ** xpp,size_t nelems,const ulonglong * tp,void * fillp)12778 ncx_putn_uchar_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
12779 #line 3072
12780 {
12781 #line 3072
12782     int status = NC_NOERR;
12783 #line 3072
12784     uchar *xp = (uchar *) *xpp;
12785 #line 3072
12786 
12787 #line 3072
12788     while (nelems-- != 0) {
12789 #line 3072
12790         if (*tp > (ulonglong)X_UCHAR_MAX ) {
12791 #line 3072
12792 
12793 #line 3072
12794 #ifdef ERANGE_FILL
12795 #line 3072
12796             if (fillp != NULL) memcpy(xp, fillp, 1);
12797 #line 3072
12798 #endif
12799 #line 3072
12800             status = NC_ERANGE;
12801 #line 3072
12802 
12803 #line 3072
12804 #ifdef ERANGE_FILL
12805 #line 3072
12806             xp++; tp++; continue;
12807 #line 3072
12808 #endif
12809 #line 3072
12810         }
12811 #line 3072
12812         *xp++ = (uchar)  *tp++; /* type cast from ulonglong to uchar */
12813 #line 3072
12814     }
12815 #line 3072
12816 
12817 #line 3072
12818     *xpp = (void *)xp;
12819 #line 3072
12820     return status;
12821 #line 3072
12822 }
12823 #line 3072
12824 
12825 
12826 #line 3075
12827 int
ncx_pad_putn_uchar_schar(void ** xpp,size_t nelems,const schar * tp,void * fillp)12828 ncx_pad_putn_uchar_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
12829 {
12830     int status = NC_NOERR;
12831     size_t rndup = nelems % X_ALIGN;
12832     uchar *xp = (uchar *) *xpp;
12833 
12834     if (rndup) rndup = X_ALIGN - rndup;
12835 
12836     while (nelems-- != 0) {
12837         if (*tp < 0) {
12838 
12839 #line 3086
12840 #ifdef ERANGE_FILL
12841 #line 3086
12842             if (fillp != NULL) memcpy(xp, fillp, 1);
12843 #line 3086
12844 #endif
12845             status = NC_ERANGE;
12846 
12847 #line 3088
12848 #ifdef ERANGE_FILL
12849 #line 3088
12850             xp++; tp++; continue;
12851 #line 3088
12852 #endif
12853         }
12854         *xp++ = (uchar) (signed) *tp++; /* type cast from schar to uchar */
12855     }
12856 
12857     if (rndup) {
12858         (void) memcpy(xp, nada, (size_t)rndup);
12859         xp += rndup;
12860     }
12861 
12862     *xpp = (void *)xp;
12863     return status;
12864 }
12865 #line 3102
12866 int
ncx_pad_putn_uchar_uchar(void ** xpp,size_t nelems,const uchar * tp,void * fillp)12867 ncx_pad_putn_uchar_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
12868 {
12869 		size_t rndup = nelems % X_ALIGN;
12870 #line 3105
12871 
12872 #line 3105
12873 	if (rndup)
12874 #line 3105
12875 		rndup = X_ALIGN - rndup;
12876 #line 3105
12877 
12878 #line 3105
12879 	(void) memcpy(*xpp, tp, (size_t)nelems);
12880 #line 3105
12881 	*xpp = (void *)((char *)(*xpp) + nelems);
12882 #line 3105
12883 
12884 #line 3105
12885 	if (rndup)
12886 #line 3105
12887 	{
12888 #line 3105
12889 		(void) memcpy(*xpp, nada, (size_t)rndup);
12890 #line 3105
12891 		*xpp = (void *)((char *)(*xpp) + rndup);
12892 #line 3105
12893 	}
12894 #line 3105
12895 
12896 #line 3105
12897 	return NC_NOERR;
12898 #line 3105
12899 
12900 }
12901 int
12902 #line 3107
ncx_pad_putn_uchar_short(void ** xpp,size_t nelems,const short * tp,void * fillp)12903 ncx_pad_putn_uchar_short(void **xpp, size_t nelems, const short *tp, void *fillp)
12904 #line 3107
12905 {
12906 #line 3107
12907     int status = NC_NOERR;
12908 #line 3107
12909     size_t rndup = nelems % X_ALIGN;
12910 #line 3107
12911     uchar *xp = (uchar *) *xpp;
12912 #line 3107
12913 
12914 #line 3107
12915     if (rndup) rndup = X_ALIGN - rndup;
12916 #line 3107
12917 
12918 #line 3107
12919     while (nelems-- != 0) {
12920 #line 3107
12921         if (*tp > (short)X_UCHAR_MAX || *tp < 0) {
12922 #line 3107
12923 
12924 #line 3107
12925 #ifdef ERANGE_FILL
12926 #line 3107
12927             if (fillp != NULL) memcpy(xp, fillp, 1);
12928 #line 3107
12929 #endif
12930 #line 3107
12931             status = NC_ERANGE;
12932 #line 3107
12933 
12934 #line 3107
12935 #ifdef ERANGE_FILL
12936 #line 3107
12937             xp++; tp++; continue;
12938 #line 3107
12939 #endif
12940 #line 3107
12941         }
12942 #line 3107
12943         *xp++ = (uchar) (signed) *tp++; /* type cast from short to uchar */
12944 #line 3107
12945     }
12946 #line 3107
12947 
12948 #line 3107
12949 
12950 #line 3107
12951     if (rndup) {
12952 #line 3107
12953         (void) memcpy(xp, nada, (size_t)rndup);
12954 #line 3107
12955         xp += rndup;
12956 #line 3107
12957     }
12958 #line 3107
12959 
12960 #line 3107
12961     *xpp = (void *)xp;
12962 #line 3107
12963     return status;
12964 #line 3107
12965 }
12966 #line 3107
12967 
12968 int
12969 #line 3108
ncx_pad_putn_uchar_int(void ** xpp,size_t nelems,const int * tp,void * fillp)12970 ncx_pad_putn_uchar_int(void **xpp, size_t nelems, const int *tp, void *fillp)
12971 #line 3108
12972 {
12973 #line 3108
12974     int status = NC_NOERR;
12975 #line 3108
12976     size_t rndup = nelems % X_ALIGN;
12977 #line 3108
12978     uchar *xp = (uchar *) *xpp;
12979 #line 3108
12980 
12981 #line 3108
12982     if (rndup) rndup = X_ALIGN - rndup;
12983 #line 3108
12984 
12985 #line 3108
12986     while (nelems-- != 0) {
12987 #line 3108
12988         if (*tp > (int)X_UCHAR_MAX || *tp < 0) {
12989 #line 3108
12990 
12991 #line 3108
12992 #ifdef ERANGE_FILL
12993 #line 3108
12994             if (fillp != NULL) memcpy(xp, fillp, 1);
12995 #line 3108
12996 #endif
12997 #line 3108
12998             status = NC_ERANGE;
12999 #line 3108
13000 
13001 #line 3108
13002 #ifdef ERANGE_FILL
13003 #line 3108
13004             xp++; tp++; continue;
13005 #line 3108
13006 #endif
13007 #line 3108
13008         }
13009 #line 3108
13010         *xp++ = (uchar) (signed) *tp++; /* type cast from int to uchar */
13011 #line 3108
13012     }
13013 #line 3108
13014 
13015 #line 3108
13016 
13017 #line 3108
13018     if (rndup) {
13019 #line 3108
13020         (void) memcpy(xp, nada, (size_t)rndup);
13021 #line 3108
13022         xp += rndup;
13023 #line 3108
13024     }
13025 #line 3108
13026 
13027 #line 3108
13028     *xpp = (void *)xp;
13029 #line 3108
13030     return status;
13031 #line 3108
13032 }
13033 #line 3108
13034 
13035 int
13036 #line 3109
ncx_pad_putn_uchar_long(void ** xpp,size_t nelems,const long * tp,void * fillp)13037 ncx_pad_putn_uchar_long(void **xpp, size_t nelems, const long *tp, void *fillp)
13038 #line 3109
13039 {
13040 #line 3109
13041     int status = NC_NOERR;
13042 #line 3109
13043     size_t rndup = nelems % X_ALIGN;
13044 #line 3109
13045     uchar *xp = (uchar *) *xpp;
13046 #line 3109
13047 
13048 #line 3109
13049     if (rndup) rndup = X_ALIGN - rndup;
13050 #line 3109
13051 
13052 #line 3109
13053     while (nelems-- != 0) {
13054 #line 3109
13055         if (*tp > (long)X_UCHAR_MAX || *tp < 0) {
13056 #line 3109
13057 
13058 #line 3109
13059 #ifdef ERANGE_FILL
13060 #line 3109
13061             if (fillp != NULL) memcpy(xp, fillp, 1);
13062 #line 3109
13063 #endif
13064 #line 3109
13065             status = NC_ERANGE;
13066 #line 3109
13067 
13068 #line 3109
13069 #ifdef ERANGE_FILL
13070 #line 3109
13071             xp++; tp++; continue;
13072 #line 3109
13073 #endif
13074 #line 3109
13075         }
13076 #line 3109
13077         *xp++ = (uchar) (signed) *tp++; /* type cast from long to uchar */
13078 #line 3109
13079     }
13080 #line 3109
13081 
13082 #line 3109
13083 
13084 #line 3109
13085     if (rndup) {
13086 #line 3109
13087         (void) memcpy(xp, nada, (size_t)rndup);
13088 #line 3109
13089         xp += rndup;
13090 #line 3109
13091     }
13092 #line 3109
13093 
13094 #line 3109
13095     *xpp = (void *)xp;
13096 #line 3109
13097     return status;
13098 #line 3109
13099 }
13100 #line 3109
13101 
13102 int
13103 #line 3110
ncx_pad_putn_uchar_float(void ** xpp,size_t nelems,const float * tp,void * fillp)13104 ncx_pad_putn_uchar_float(void **xpp, size_t nelems, const float *tp, void *fillp)
13105 #line 3110
13106 {
13107 #line 3110
13108     int status = NC_NOERR;
13109 #line 3110
13110     size_t rndup = nelems % X_ALIGN;
13111 #line 3110
13112     uchar *xp = (uchar *) *xpp;
13113 #line 3110
13114 
13115 #line 3110
13116     if (rndup) rndup = X_ALIGN - rndup;
13117 #line 3110
13118 
13119 #line 3110
13120     while (nelems-- != 0) {
13121 #line 3110
13122         if (*tp > (float)X_UCHAR_MAX || *tp < 0) {
13123 #line 3110
13124 
13125 #line 3110
13126 #ifdef ERANGE_FILL
13127 #line 3110
13128             if (fillp != NULL) memcpy(xp, fillp, 1);
13129 #line 3110
13130 #endif
13131 #line 3110
13132             status = NC_ERANGE;
13133 #line 3110
13134 
13135 #line 3110
13136 #ifdef ERANGE_FILL
13137 #line 3110
13138             xp++; tp++; continue;
13139 #line 3110
13140 #endif
13141 #line 3110
13142         }
13143 #line 3110
13144         *xp++ = (uchar) (signed) *tp++; /* type cast from float to uchar */
13145 #line 3110
13146     }
13147 #line 3110
13148 
13149 #line 3110
13150 
13151 #line 3110
13152     if (rndup) {
13153 #line 3110
13154         (void) memcpy(xp, nada, (size_t)rndup);
13155 #line 3110
13156         xp += rndup;
13157 #line 3110
13158     }
13159 #line 3110
13160 
13161 #line 3110
13162     *xpp = (void *)xp;
13163 #line 3110
13164     return status;
13165 #line 3110
13166 }
13167 #line 3110
13168 
13169 int
13170 #line 3111
ncx_pad_putn_uchar_double(void ** xpp,size_t nelems,const double * tp,void * fillp)13171 ncx_pad_putn_uchar_double(void **xpp, size_t nelems, const double *tp, void *fillp)
13172 #line 3111
13173 {
13174 #line 3111
13175     int status = NC_NOERR;
13176 #line 3111
13177     size_t rndup = nelems % X_ALIGN;
13178 #line 3111
13179     uchar *xp = (uchar *) *xpp;
13180 #line 3111
13181 
13182 #line 3111
13183     if (rndup) rndup = X_ALIGN - rndup;
13184 #line 3111
13185 
13186 #line 3111
13187     while (nelems-- != 0) {
13188 #line 3111
13189         if (*tp > (double)X_UCHAR_MAX || *tp < 0) {
13190 #line 3111
13191 
13192 #line 3111
13193 #ifdef ERANGE_FILL
13194 #line 3111
13195             if (fillp != NULL) memcpy(xp, fillp, 1);
13196 #line 3111
13197 #endif
13198 #line 3111
13199             status = NC_ERANGE;
13200 #line 3111
13201 
13202 #line 3111
13203 #ifdef ERANGE_FILL
13204 #line 3111
13205             xp++; tp++; continue;
13206 #line 3111
13207 #endif
13208 #line 3111
13209         }
13210 #line 3111
13211         *xp++ = (uchar) (signed) *tp++; /* type cast from double to uchar */
13212 #line 3111
13213     }
13214 #line 3111
13215 
13216 #line 3111
13217 
13218 #line 3111
13219     if (rndup) {
13220 #line 3111
13221         (void) memcpy(xp, nada, (size_t)rndup);
13222 #line 3111
13223         xp += rndup;
13224 #line 3111
13225     }
13226 #line 3111
13227 
13228 #line 3111
13229     *xpp = (void *)xp;
13230 #line 3111
13231     return status;
13232 #line 3111
13233 }
13234 #line 3111
13235 
13236 int
13237 #line 3112
ncx_pad_putn_uchar_longlong(void ** xpp,size_t nelems,const longlong * tp,void * fillp)13238 ncx_pad_putn_uchar_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
13239 #line 3112
13240 {
13241 #line 3112
13242     int status = NC_NOERR;
13243 #line 3112
13244     size_t rndup = nelems % X_ALIGN;
13245 #line 3112
13246     uchar *xp = (uchar *) *xpp;
13247 #line 3112
13248 
13249 #line 3112
13250     if (rndup) rndup = X_ALIGN - rndup;
13251 #line 3112
13252 
13253 #line 3112
13254     while (nelems-- != 0) {
13255 #line 3112
13256         if (*tp > (longlong)X_UCHAR_MAX || *tp < 0) {
13257 #line 3112
13258 
13259 #line 3112
13260 #ifdef ERANGE_FILL
13261 #line 3112
13262             if (fillp != NULL) memcpy(xp, fillp, 1);
13263 #line 3112
13264 #endif
13265 #line 3112
13266             status = NC_ERANGE;
13267 #line 3112
13268 
13269 #line 3112
13270 #ifdef ERANGE_FILL
13271 #line 3112
13272             xp++; tp++; continue;
13273 #line 3112
13274 #endif
13275 #line 3112
13276         }
13277 #line 3112
13278         *xp++ = (uchar) (signed) *tp++; /* type cast from longlong to uchar */
13279 #line 3112
13280     }
13281 #line 3112
13282 
13283 #line 3112
13284 
13285 #line 3112
13286     if (rndup) {
13287 #line 3112
13288         (void) memcpy(xp, nada, (size_t)rndup);
13289 #line 3112
13290         xp += rndup;
13291 #line 3112
13292     }
13293 #line 3112
13294 
13295 #line 3112
13296     *xpp = (void *)xp;
13297 #line 3112
13298     return status;
13299 #line 3112
13300 }
13301 #line 3112
13302 
13303 int
13304 #line 3113
ncx_pad_putn_uchar_ushort(void ** xpp,size_t nelems,const ushort * tp,void * fillp)13305 ncx_pad_putn_uchar_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
13306 #line 3113
13307 {
13308 #line 3113
13309     int status = NC_NOERR;
13310 #line 3113
13311     size_t rndup = nelems % X_ALIGN;
13312 #line 3113
13313     uchar *xp = (uchar *) *xpp;
13314 #line 3113
13315 
13316 #line 3113
13317     if (rndup) rndup = X_ALIGN - rndup;
13318 #line 3113
13319 
13320 #line 3113
13321     while (nelems-- != 0) {
13322 #line 3113
13323         if (*tp > (ushort)X_UCHAR_MAX ) {
13324 #line 3113
13325 
13326 #line 3113
13327 #ifdef ERANGE_FILL
13328 #line 3113
13329             if (fillp != NULL) memcpy(xp, fillp, 1);
13330 #line 3113
13331 #endif
13332 #line 3113
13333             status = NC_ERANGE;
13334 #line 3113
13335 
13336 #line 3113
13337 #ifdef ERANGE_FILL
13338 #line 3113
13339             xp++; tp++; continue;
13340 #line 3113
13341 #endif
13342 #line 3113
13343         }
13344 #line 3113
13345         *xp++ = (uchar)  *tp++; /* type cast from ushort to uchar */
13346 #line 3113
13347     }
13348 #line 3113
13349 
13350 #line 3113
13351 
13352 #line 3113
13353     if (rndup) {
13354 #line 3113
13355         (void) memcpy(xp, nada, (size_t)rndup);
13356 #line 3113
13357         xp += rndup;
13358 #line 3113
13359     }
13360 #line 3113
13361 
13362 #line 3113
13363     *xpp = (void *)xp;
13364 #line 3113
13365     return status;
13366 #line 3113
13367 }
13368 #line 3113
13369 
13370 int
13371 #line 3114
ncx_pad_putn_uchar_uint(void ** xpp,size_t nelems,const uint * tp,void * fillp)13372 ncx_pad_putn_uchar_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
13373 #line 3114
13374 {
13375 #line 3114
13376     int status = NC_NOERR;
13377 #line 3114
13378     size_t rndup = nelems % X_ALIGN;
13379 #line 3114
13380     uchar *xp = (uchar *) *xpp;
13381 #line 3114
13382 
13383 #line 3114
13384     if (rndup) rndup = X_ALIGN - rndup;
13385 #line 3114
13386 
13387 #line 3114
13388     while (nelems-- != 0) {
13389 #line 3114
13390         if (*tp > (uint)X_UCHAR_MAX ) {
13391 #line 3114
13392 
13393 #line 3114
13394 #ifdef ERANGE_FILL
13395 #line 3114
13396             if (fillp != NULL) memcpy(xp, fillp, 1);
13397 #line 3114
13398 #endif
13399 #line 3114
13400             status = NC_ERANGE;
13401 #line 3114
13402 
13403 #line 3114
13404 #ifdef ERANGE_FILL
13405 #line 3114
13406             xp++; tp++; continue;
13407 #line 3114
13408 #endif
13409 #line 3114
13410         }
13411 #line 3114
13412         *xp++ = (uchar)  *tp++; /* type cast from uint to uchar */
13413 #line 3114
13414     }
13415 #line 3114
13416 
13417 #line 3114
13418 
13419 #line 3114
13420     if (rndup) {
13421 #line 3114
13422         (void) memcpy(xp, nada, (size_t)rndup);
13423 #line 3114
13424         xp += rndup;
13425 #line 3114
13426     }
13427 #line 3114
13428 
13429 #line 3114
13430     *xpp = (void *)xp;
13431 #line 3114
13432     return status;
13433 #line 3114
13434 }
13435 #line 3114
13436 
13437 int
13438 #line 3115
ncx_pad_putn_uchar_ulonglong(void ** xpp,size_t nelems,const ulonglong * tp,void * fillp)13439 ncx_pad_putn_uchar_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
13440 #line 3115
13441 {
13442 #line 3115
13443     int status = NC_NOERR;
13444 #line 3115
13445     size_t rndup = nelems % X_ALIGN;
13446 #line 3115
13447     uchar *xp = (uchar *) *xpp;
13448 #line 3115
13449 
13450 #line 3115
13451     if (rndup) rndup = X_ALIGN - rndup;
13452 #line 3115
13453 
13454 #line 3115
13455     while (nelems-- != 0) {
13456 #line 3115
13457         if (*tp > (ulonglong)X_UCHAR_MAX ) {
13458 #line 3115
13459 
13460 #line 3115
13461 #ifdef ERANGE_FILL
13462 #line 3115
13463             if (fillp != NULL) memcpy(xp, fillp, 1);
13464 #line 3115
13465 #endif
13466 #line 3115
13467             status = NC_ERANGE;
13468 #line 3115
13469 
13470 #line 3115
13471 #ifdef ERANGE_FILL
13472 #line 3115
13473             xp++; tp++; continue;
13474 #line 3115
13475 #endif
13476 #line 3115
13477         }
13478 #line 3115
13479         *xp++ = (uchar)  *tp++; /* type cast from ulonglong to uchar */
13480 #line 3115
13481     }
13482 #line 3115
13483 
13484 #line 3115
13485 
13486 #line 3115
13487     if (rndup) {
13488 #line 3115
13489         (void) memcpy(xp, nada, (size_t)rndup);
13490 #line 3115
13491         xp += rndup;
13492 #line 3115
13493     }
13494 #line 3115
13495 
13496 #line 3115
13497     *xpp = (void *)xp;
13498 #line 3115
13499     return status;
13500 #line 3115
13501 }
13502 #line 3115
13503 
13504 
13505 /* short ---------------------------------------------------------------------*/
13506 
13507 #if X_SIZEOF_SHORT == SIZEOF_SHORT
13508 /* optimized version */
13509 int
ncx_getn_short_short(const void ** xpp,size_t nelems,short * tp)13510 ncx_getn_short_short(const void **xpp, size_t nelems, short *tp)
13511 {
13512 #ifdef WORDS_BIGENDIAN
13513 	(void) memcpy(tp, *xpp, (size_t)nelems * SIZEOF_SHORT);
13514 # else
13515 	swapn2b(tp, *xpp, nelems);
13516 # endif
13517 	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_SHORT);
13518 	return NC_NOERR;
13519 }
13520 #else
13521 int
13522 #line 3133
ncx_getn_short_short(const void ** xpp,size_t nelems,short * tp)13523 ncx_getn_short_short(const void **xpp, size_t nelems, short *tp)
13524 #line 3133
13525 {
13526 #line 3133
13527 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
13528 #line 3133
13529 
13530 #line 3133
13531  /* basic algorithm is:
13532 #line 3133
13533   *   - ensure sane alignment of input data
13534 #line 3133
13535   *   - copy (conversion happens automatically) input data
13536 #line 3133
13537   *     to output
13538 #line 3133
13539   *   - update xpp to point at next unconverted input, and tp to point
13540 #line 3133
13541   *     at next location for converted output
13542 #line 3133
13543   */
13544 #line 3133
13545   long i, j, ni;
13546 #line 3133
13547   short tmp[LOOPCNT];        /* in case input is misaligned */
13548 #line 3133
13549   short *xp;
13550 #line 3133
13551   int nrange = 0;         /* number of range errors */
13552 #line 3133
13553   int realign = 0;        /* "do we need to fix input data alignment?" */
13554 #line 3133
13555   long cxp = (long) *((char**)xpp);
13556 #line 3133
13557 
13558 #line 3133
13559   realign = (cxp & 7) % SIZEOF_SHORT;
13560 #line 3133
13561   /* sjl: manually stripmine so we can limit amount of
13562 #line 3133
13563    * vector work space reserved to LOOPCNT elements. Also
13564 #line 3133
13565    * makes vectorisation easy */
13566 #line 3133
13567   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
13568 #line 3133
13569     ni=Min(nelems-j,LOOPCNT);
13570 #line 3133
13571     if (realign) {
13572 #line 3133
13573       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
13574 #line 3133
13575       xp = tmp;
13576 #line 3133
13577     } else {
13578 #line 3133
13579       xp = (short *) *xpp;
13580 #line 3133
13581     }
13582 #line 3133
13583    /* copy the next block */
13584 #line 3133
13585 #pragma cdir loopcnt=LOOPCNT
13586 #line 3133
13587 #pragma cdir shortloop
13588 #line 3133
13589     for (i=0; i<ni; i++) {
13590 #line 3133
13591       tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
13592 #line 3133
13593      /* test for range errors (not always needed but do it anyway) */
13594 #line 3133
13595      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
13596 #line 3133
13597      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
13598 #line 3133
13599       nrange += xp[i] > SHORT_MAX || xp[i] < SHORT_MIN;
13600 #line 3133
13601     }
13602 #line 3133
13603    /* update xpp and tp */
13604 #line 3133
13605     if (realign) xp = (short *) *xpp;
13606 #line 3133
13607     xp += ni;
13608 #line 3133
13609     tp += ni;
13610 #line 3133
13611     *xpp = (void*)xp;
13612 #line 3133
13613   }
13614 #line 3133
13615   return nrange == 0 ? NC_NOERR : NC_ERANGE;
13616 #line 3133
13617 
13618 #line 3133
13619 #else   /* not SX */
13620 #line 3133
13621 	const char *xp = (const char *) *xpp;
13622 #line 3133
13623 	int status = NC_NOERR;
13624 #line 3133
13625 
13626 #line 3133
13627 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
13628 #line 3133
13629 	{
13630 #line 3133
13631 		const int lstatus = ncx_get_short_short(xp, tp);
13632 #line 3133
13633 		if (status == NC_NOERR) /* report the first encountered error */
13634 #line 3133
13635 			status = lstatus;
13636 #line 3133
13637 	}
13638 #line 3133
13639 
13640 #line 3133
13641 	*xpp = (const void *)xp;
13642 #line 3133
13643 	return status;
13644 #line 3133
13645 #endif
13646 #line 3133
13647 }
13648 #line 3133
13649 
13650 #endif
13651 int
13652 #line 3135
ncx_getn_short_schar(const void ** xpp,size_t nelems,schar * tp)13653 ncx_getn_short_schar(const void **xpp, size_t nelems, schar *tp)
13654 #line 3135
13655 {
13656 #line 3135
13657 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
13658 #line 3135
13659 
13660 #line 3135
13661  /* basic algorithm is:
13662 #line 3135
13663   *   - ensure sane alignment of input data
13664 #line 3135
13665   *   - copy (conversion happens automatically) input data
13666 #line 3135
13667   *     to output
13668 #line 3135
13669   *   - update xpp to point at next unconverted input, and tp to point
13670 #line 3135
13671   *     at next location for converted output
13672 #line 3135
13673   */
13674 #line 3135
13675   long i, j, ni;
13676 #line 3135
13677   short tmp[LOOPCNT];        /* in case input is misaligned */
13678 #line 3135
13679   short *xp;
13680 #line 3135
13681   int nrange = 0;         /* number of range errors */
13682 #line 3135
13683   int realign = 0;        /* "do we need to fix input data alignment?" */
13684 #line 3135
13685   long cxp = (long) *((char**)xpp);
13686 #line 3135
13687 
13688 #line 3135
13689   realign = (cxp & 7) % SIZEOF_SHORT;
13690 #line 3135
13691   /* sjl: manually stripmine so we can limit amount of
13692 #line 3135
13693    * vector work space reserved to LOOPCNT elements. Also
13694 #line 3135
13695    * makes vectorisation easy */
13696 #line 3135
13697   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
13698 #line 3135
13699     ni=Min(nelems-j,LOOPCNT);
13700 #line 3135
13701     if (realign) {
13702 #line 3135
13703       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
13704 #line 3135
13705       xp = tmp;
13706 #line 3135
13707     } else {
13708 #line 3135
13709       xp = (short *) *xpp;
13710 #line 3135
13711     }
13712 #line 3135
13713    /* copy the next block */
13714 #line 3135
13715 #pragma cdir loopcnt=LOOPCNT
13716 #line 3135
13717 #pragma cdir shortloop
13718 #line 3135
13719     for (i=0; i<ni; i++) {
13720 #line 3135
13721       tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
13722 #line 3135
13723      /* test for range errors (not always needed but do it anyway) */
13724 #line 3135
13725      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
13726 #line 3135
13727      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
13728 #line 3135
13729       nrange += xp[i] > SCHAR_MAX || xp[i] < SCHAR_MIN;
13730 #line 3135
13731     }
13732 #line 3135
13733    /* update xpp and tp */
13734 #line 3135
13735     if (realign) xp = (short *) *xpp;
13736 #line 3135
13737     xp += ni;
13738 #line 3135
13739     tp += ni;
13740 #line 3135
13741     *xpp = (void*)xp;
13742 #line 3135
13743   }
13744 #line 3135
13745   return nrange == 0 ? NC_NOERR : NC_ERANGE;
13746 #line 3135
13747 
13748 #line 3135
13749 #else   /* not SX */
13750 #line 3135
13751 	const char *xp = (const char *) *xpp;
13752 #line 3135
13753 	int status = NC_NOERR;
13754 #line 3135
13755 
13756 #line 3135
13757 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
13758 #line 3135
13759 	{
13760 #line 3135
13761 		const int lstatus = ncx_get_short_schar(xp, tp);
13762 #line 3135
13763 		if (status == NC_NOERR) /* report the first encountered error */
13764 #line 3135
13765 			status = lstatus;
13766 #line 3135
13767 	}
13768 #line 3135
13769 
13770 #line 3135
13771 	*xpp = (const void *)xp;
13772 #line 3135
13773 	return status;
13774 #line 3135
13775 #endif
13776 #line 3135
13777 }
13778 #line 3135
13779 
13780 int
13781 #line 3136
ncx_getn_short_int(const void ** xpp,size_t nelems,int * tp)13782 ncx_getn_short_int(const void **xpp, size_t nelems, int *tp)
13783 #line 3136
13784 {
13785 #line 3136
13786 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
13787 #line 3136
13788 
13789 #line 3136
13790  /* basic algorithm is:
13791 #line 3136
13792   *   - ensure sane alignment of input data
13793 #line 3136
13794   *   - copy (conversion happens automatically) input data
13795 #line 3136
13796   *     to output
13797 #line 3136
13798   *   - update xpp to point at next unconverted input, and tp to point
13799 #line 3136
13800   *     at next location for converted output
13801 #line 3136
13802   */
13803 #line 3136
13804   long i, j, ni;
13805 #line 3136
13806   short tmp[LOOPCNT];        /* in case input is misaligned */
13807 #line 3136
13808   short *xp;
13809 #line 3136
13810   int nrange = 0;         /* number of range errors */
13811 #line 3136
13812   int realign = 0;        /* "do we need to fix input data alignment?" */
13813 #line 3136
13814   long cxp = (long) *((char**)xpp);
13815 #line 3136
13816 
13817 #line 3136
13818   realign = (cxp & 7) % SIZEOF_SHORT;
13819 #line 3136
13820   /* sjl: manually stripmine so we can limit amount of
13821 #line 3136
13822    * vector work space reserved to LOOPCNT elements. Also
13823 #line 3136
13824    * makes vectorisation easy */
13825 #line 3136
13826   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
13827 #line 3136
13828     ni=Min(nelems-j,LOOPCNT);
13829 #line 3136
13830     if (realign) {
13831 #line 3136
13832       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
13833 #line 3136
13834       xp = tmp;
13835 #line 3136
13836     } else {
13837 #line 3136
13838       xp = (short *) *xpp;
13839 #line 3136
13840     }
13841 #line 3136
13842    /* copy the next block */
13843 #line 3136
13844 #pragma cdir loopcnt=LOOPCNT
13845 #line 3136
13846 #pragma cdir shortloop
13847 #line 3136
13848     for (i=0; i<ni; i++) {
13849 #line 3136
13850       tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
13851 #line 3136
13852      /* test for range errors (not always needed but do it anyway) */
13853 #line 3136
13854      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
13855 #line 3136
13856      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
13857 #line 3136
13858       nrange += xp[i] > INT_MAX || xp[i] < INT_MIN;
13859 #line 3136
13860     }
13861 #line 3136
13862    /* update xpp and tp */
13863 #line 3136
13864     if (realign) xp = (short *) *xpp;
13865 #line 3136
13866     xp += ni;
13867 #line 3136
13868     tp += ni;
13869 #line 3136
13870     *xpp = (void*)xp;
13871 #line 3136
13872   }
13873 #line 3136
13874   return nrange == 0 ? NC_NOERR : NC_ERANGE;
13875 #line 3136
13876 
13877 #line 3136
13878 #else   /* not SX */
13879 #line 3136
13880 	const char *xp = (const char *) *xpp;
13881 #line 3136
13882 	int status = NC_NOERR;
13883 #line 3136
13884 
13885 #line 3136
13886 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
13887 #line 3136
13888 	{
13889 #line 3136
13890 		const int lstatus = ncx_get_short_int(xp, tp);
13891 #line 3136
13892 		if (status == NC_NOERR) /* report the first encountered error */
13893 #line 3136
13894 			status = lstatus;
13895 #line 3136
13896 	}
13897 #line 3136
13898 
13899 #line 3136
13900 	*xpp = (const void *)xp;
13901 #line 3136
13902 	return status;
13903 #line 3136
13904 #endif
13905 #line 3136
13906 }
13907 #line 3136
13908 
13909 int
13910 #line 3137
ncx_getn_short_long(const void ** xpp,size_t nelems,long * tp)13911 ncx_getn_short_long(const void **xpp, size_t nelems, long *tp)
13912 #line 3137
13913 {
13914 #line 3137
13915 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
13916 #line 3137
13917 
13918 #line 3137
13919  /* basic algorithm is:
13920 #line 3137
13921   *   - ensure sane alignment of input data
13922 #line 3137
13923   *   - copy (conversion happens automatically) input data
13924 #line 3137
13925   *     to output
13926 #line 3137
13927   *   - update xpp to point at next unconverted input, and tp to point
13928 #line 3137
13929   *     at next location for converted output
13930 #line 3137
13931   */
13932 #line 3137
13933   long i, j, ni;
13934 #line 3137
13935   short tmp[LOOPCNT];        /* in case input is misaligned */
13936 #line 3137
13937   short *xp;
13938 #line 3137
13939   int nrange = 0;         /* number of range errors */
13940 #line 3137
13941   int realign = 0;        /* "do we need to fix input data alignment?" */
13942 #line 3137
13943   long cxp = (long) *((char**)xpp);
13944 #line 3137
13945 
13946 #line 3137
13947   realign = (cxp & 7) % SIZEOF_SHORT;
13948 #line 3137
13949   /* sjl: manually stripmine so we can limit amount of
13950 #line 3137
13951    * vector work space reserved to LOOPCNT elements. Also
13952 #line 3137
13953    * makes vectorisation easy */
13954 #line 3137
13955   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
13956 #line 3137
13957     ni=Min(nelems-j,LOOPCNT);
13958 #line 3137
13959     if (realign) {
13960 #line 3137
13961       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
13962 #line 3137
13963       xp = tmp;
13964 #line 3137
13965     } else {
13966 #line 3137
13967       xp = (short *) *xpp;
13968 #line 3137
13969     }
13970 #line 3137
13971    /* copy the next block */
13972 #line 3137
13973 #pragma cdir loopcnt=LOOPCNT
13974 #line 3137
13975 #pragma cdir shortloop
13976 #line 3137
13977     for (i=0; i<ni; i++) {
13978 #line 3137
13979       tp[i] = (long) Max( LONG_MIN, Min(LONG_MAX, (long) xp[i]));
13980 #line 3137
13981      /* test for range errors (not always needed but do it anyway) */
13982 #line 3137
13983      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
13984 #line 3137
13985      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
13986 #line 3137
13987       nrange += xp[i] > LONG_MAX || xp[i] < LONG_MIN;
13988 #line 3137
13989     }
13990 #line 3137
13991    /* update xpp and tp */
13992 #line 3137
13993     if (realign) xp = (short *) *xpp;
13994 #line 3137
13995     xp += ni;
13996 #line 3137
13997     tp += ni;
13998 #line 3137
13999     *xpp = (void*)xp;
14000 #line 3137
14001   }
14002 #line 3137
14003   return nrange == 0 ? NC_NOERR : NC_ERANGE;
14004 #line 3137
14005 
14006 #line 3137
14007 #else   /* not SX */
14008 #line 3137
14009 	const char *xp = (const char *) *xpp;
14010 #line 3137
14011 	int status = NC_NOERR;
14012 #line 3137
14013 
14014 #line 3137
14015 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
14016 #line 3137
14017 	{
14018 #line 3137
14019 		const int lstatus = ncx_get_short_long(xp, tp);
14020 #line 3137
14021 		if (status == NC_NOERR) /* report the first encountered error */
14022 #line 3137
14023 			status = lstatus;
14024 #line 3137
14025 	}
14026 #line 3137
14027 
14028 #line 3137
14029 	*xpp = (const void *)xp;
14030 #line 3137
14031 	return status;
14032 #line 3137
14033 #endif
14034 #line 3137
14035 }
14036 #line 3137
14037 
14038 int
14039 #line 3138
ncx_getn_short_float(const void ** xpp,size_t nelems,float * tp)14040 ncx_getn_short_float(const void **xpp, size_t nelems, float *tp)
14041 #line 3138
14042 {
14043 #line 3138
14044 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
14045 #line 3138
14046 
14047 #line 3138
14048  /* basic algorithm is:
14049 #line 3138
14050   *   - ensure sane alignment of input data
14051 #line 3138
14052   *   - copy (conversion happens automatically) input data
14053 #line 3138
14054   *     to output
14055 #line 3138
14056   *   - update xpp to point at next unconverted input, and tp to point
14057 #line 3138
14058   *     at next location for converted output
14059 #line 3138
14060   */
14061 #line 3138
14062   long i, j, ni;
14063 #line 3138
14064   short tmp[LOOPCNT];        /* in case input is misaligned */
14065 #line 3138
14066   short *xp;
14067 #line 3138
14068   int nrange = 0;         /* number of range errors */
14069 #line 3138
14070   int realign = 0;        /* "do we need to fix input data alignment?" */
14071 #line 3138
14072   long cxp = (long) *((char**)xpp);
14073 #line 3138
14074 
14075 #line 3138
14076   realign = (cxp & 7) % SIZEOF_SHORT;
14077 #line 3138
14078   /* sjl: manually stripmine so we can limit amount of
14079 #line 3138
14080    * vector work space reserved to LOOPCNT elements. Also
14081 #line 3138
14082    * makes vectorisation easy */
14083 #line 3138
14084   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
14085 #line 3138
14086     ni=Min(nelems-j,LOOPCNT);
14087 #line 3138
14088     if (realign) {
14089 #line 3138
14090       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
14091 #line 3138
14092       xp = tmp;
14093 #line 3138
14094     } else {
14095 #line 3138
14096       xp = (short *) *xpp;
14097 #line 3138
14098     }
14099 #line 3138
14100    /* copy the next block */
14101 #line 3138
14102 #pragma cdir loopcnt=LOOPCNT
14103 #line 3138
14104 #pragma cdir shortloop
14105 #line 3138
14106     for (i=0; i<ni; i++) {
14107 #line 3138
14108       tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
14109 #line 3138
14110      /* test for range errors (not always needed but do it anyway) */
14111 #line 3138
14112      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
14113 #line 3138
14114      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
14115 #line 3138
14116       nrange += xp[i] > FLOAT_MAX || xp[i] < FLOAT_MIN;
14117 #line 3138
14118     }
14119 #line 3138
14120    /* update xpp and tp */
14121 #line 3138
14122     if (realign) xp = (short *) *xpp;
14123 #line 3138
14124     xp += ni;
14125 #line 3138
14126     tp += ni;
14127 #line 3138
14128     *xpp = (void*)xp;
14129 #line 3138
14130   }
14131 #line 3138
14132   return nrange == 0 ? NC_NOERR : NC_ERANGE;
14133 #line 3138
14134 
14135 #line 3138
14136 #else   /* not SX */
14137 #line 3138
14138 	const char *xp = (const char *) *xpp;
14139 #line 3138
14140 	int status = NC_NOERR;
14141 #line 3138
14142 
14143 #line 3138
14144 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
14145 #line 3138
14146 	{
14147 #line 3138
14148 		const int lstatus = ncx_get_short_float(xp, tp);
14149 #line 3138
14150 		if (status == NC_NOERR) /* report the first encountered error */
14151 #line 3138
14152 			status = lstatus;
14153 #line 3138
14154 	}
14155 #line 3138
14156 
14157 #line 3138
14158 	*xpp = (const void *)xp;
14159 #line 3138
14160 	return status;
14161 #line 3138
14162 #endif
14163 #line 3138
14164 }
14165 #line 3138
14166 
14167 int
14168 #line 3139
ncx_getn_short_double(const void ** xpp,size_t nelems,double * tp)14169 ncx_getn_short_double(const void **xpp, size_t nelems, double *tp)
14170 #line 3139
14171 {
14172 #line 3139
14173 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
14174 #line 3139
14175 
14176 #line 3139
14177  /* basic algorithm is:
14178 #line 3139
14179   *   - ensure sane alignment of input data
14180 #line 3139
14181   *   - copy (conversion happens automatically) input data
14182 #line 3139
14183   *     to output
14184 #line 3139
14185   *   - update xpp to point at next unconverted input, and tp to point
14186 #line 3139
14187   *     at next location for converted output
14188 #line 3139
14189   */
14190 #line 3139
14191   long i, j, ni;
14192 #line 3139
14193   short tmp[LOOPCNT];        /* in case input is misaligned */
14194 #line 3139
14195   short *xp;
14196 #line 3139
14197   int nrange = 0;         /* number of range errors */
14198 #line 3139
14199   int realign = 0;        /* "do we need to fix input data alignment?" */
14200 #line 3139
14201   long cxp = (long) *((char**)xpp);
14202 #line 3139
14203 
14204 #line 3139
14205   realign = (cxp & 7) % SIZEOF_SHORT;
14206 #line 3139
14207   /* sjl: manually stripmine so we can limit amount of
14208 #line 3139
14209    * vector work space reserved to LOOPCNT elements. Also
14210 #line 3139
14211    * makes vectorisation easy */
14212 #line 3139
14213   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
14214 #line 3139
14215     ni=Min(nelems-j,LOOPCNT);
14216 #line 3139
14217     if (realign) {
14218 #line 3139
14219       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
14220 #line 3139
14221       xp = tmp;
14222 #line 3139
14223     } else {
14224 #line 3139
14225       xp = (short *) *xpp;
14226 #line 3139
14227     }
14228 #line 3139
14229    /* copy the next block */
14230 #line 3139
14231 #pragma cdir loopcnt=LOOPCNT
14232 #line 3139
14233 #pragma cdir shortloop
14234 #line 3139
14235     for (i=0; i<ni; i++) {
14236 #line 3139
14237       tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
14238 #line 3139
14239      /* test for range errors (not always needed but do it anyway) */
14240 #line 3139
14241      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
14242 #line 3139
14243      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
14244 #line 3139
14245       nrange += xp[i] > DOUBLE_MAX || xp[i] < DOUBLE_MIN;
14246 #line 3139
14247     }
14248 #line 3139
14249    /* update xpp and tp */
14250 #line 3139
14251     if (realign) xp = (short *) *xpp;
14252 #line 3139
14253     xp += ni;
14254 #line 3139
14255     tp += ni;
14256 #line 3139
14257     *xpp = (void*)xp;
14258 #line 3139
14259   }
14260 #line 3139
14261   return nrange == 0 ? NC_NOERR : NC_ERANGE;
14262 #line 3139
14263 
14264 #line 3139
14265 #else   /* not SX */
14266 #line 3139
14267 	const char *xp = (const char *) *xpp;
14268 #line 3139
14269 	int status = NC_NOERR;
14270 #line 3139
14271 
14272 #line 3139
14273 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
14274 #line 3139
14275 	{
14276 #line 3139
14277 		const int lstatus = ncx_get_short_double(xp, tp);
14278 #line 3139
14279 		if (status == NC_NOERR) /* report the first encountered error */
14280 #line 3139
14281 			status = lstatus;
14282 #line 3139
14283 	}
14284 #line 3139
14285 
14286 #line 3139
14287 	*xpp = (const void *)xp;
14288 #line 3139
14289 	return status;
14290 #line 3139
14291 #endif
14292 #line 3139
14293 }
14294 #line 3139
14295 
14296 int
14297 #line 3140
ncx_getn_short_longlong(const void ** xpp,size_t nelems,longlong * tp)14298 ncx_getn_short_longlong(const void **xpp, size_t nelems, longlong *tp)
14299 #line 3140
14300 {
14301 #line 3140
14302 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
14303 #line 3140
14304 
14305 #line 3140
14306  /* basic algorithm is:
14307 #line 3140
14308   *   - ensure sane alignment of input data
14309 #line 3140
14310   *   - copy (conversion happens automatically) input data
14311 #line 3140
14312   *     to output
14313 #line 3140
14314   *   - update xpp to point at next unconverted input, and tp to point
14315 #line 3140
14316   *     at next location for converted output
14317 #line 3140
14318   */
14319 #line 3140
14320   long i, j, ni;
14321 #line 3140
14322   short tmp[LOOPCNT];        /* in case input is misaligned */
14323 #line 3140
14324   short *xp;
14325 #line 3140
14326   int nrange = 0;         /* number of range errors */
14327 #line 3140
14328   int realign = 0;        /* "do we need to fix input data alignment?" */
14329 #line 3140
14330   long cxp = (long) *((char**)xpp);
14331 #line 3140
14332 
14333 #line 3140
14334   realign = (cxp & 7) % SIZEOF_SHORT;
14335 #line 3140
14336   /* sjl: manually stripmine so we can limit amount of
14337 #line 3140
14338    * vector work space reserved to LOOPCNT elements. Also
14339 #line 3140
14340    * makes vectorisation easy */
14341 #line 3140
14342   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
14343 #line 3140
14344     ni=Min(nelems-j,LOOPCNT);
14345 #line 3140
14346     if (realign) {
14347 #line 3140
14348       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
14349 #line 3140
14350       xp = tmp;
14351 #line 3140
14352     } else {
14353 #line 3140
14354       xp = (short *) *xpp;
14355 #line 3140
14356     }
14357 #line 3140
14358    /* copy the next block */
14359 #line 3140
14360 #pragma cdir loopcnt=LOOPCNT
14361 #line 3140
14362 #pragma cdir shortloop
14363 #line 3140
14364     for (i=0; i<ni; i++) {
14365 #line 3140
14366       tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
14367 #line 3140
14368      /* test for range errors (not always needed but do it anyway) */
14369 #line 3140
14370      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
14371 #line 3140
14372      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
14373 #line 3140
14374       nrange += xp[i] > LONGLONG_MAX || xp[i] < LONGLONG_MIN;
14375 #line 3140
14376     }
14377 #line 3140
14378    /* update xpp and tp */
14379 #line 3140
14380     if (realign) xp = (short *) *xpp;
14381 #line 3140
14382     xp += ni;
14383 #line 3140
14384     tp += ni;
14385 #line 3140
14386     *xpp = (void*)xp;
14387 #line 3140
14388   }
14389 #line 3140
14390   return nrange == 0 ? NC_NOERR : NC_ERANGE;
14391 #line 3140
14392 
14393 #line 3140
14394 #else   /* not SX */
14395 #line 3140
14396 	const char *xp = (const char *) *xpp;
14397 #line 3140
14398 	int status = NC_NOERR;
14399 #line 3140
14400 
14401 #line 3140
14402 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
14403 #line 3140
14404 	{
14405 #line 3140
14406 		const int lstatus = ncx_get_short_longlong(xp, tp);
14407 #line 3140
14408 		if (status == NC_NOERR) /* report the first encountered error */
14409 #line 3140
14410 			status = lstatus;
14411 #line 3140
14412 	}
14413 #line 3140
14414 
14415 #line 3140
14416 	*xpp = (const void *)xp;
14417 #line 3140
14418 	return status;
14419 #line 3140
14420 #endif
14421 #line 3140
14422 }
14423 #line 3140
14424 
14425 int
14426 #line 3141
ncx_getn_short_uchar(const void ** xpp,size_t nelems,uchar * tp)14427 ncx_getn_short_uchar(const void **xpp, size_t nelems, uchar *tp)
14428 #line 3141
14429 {
14430 #line 3141
14431 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
14432 #line 3141
14433 
14434 #line 3141
14435  /* basic algorithm is:
14436 #line 3141
14437   *   - ensure sane alignment of input data
14438 #line 3141
14439   *   - copy (conversion happens automatically) input data
14440 #line 3141
14441   *     to output
14442 #line 3141
14443   *   - update xpp to point at next unconverted input, and tp to point
14444 #line 3141
14445   *     at next location for converted output
14446 #line 3141
14447   */
14448 #line 3141
14449   long i, j, ni;
14450 #line 3141
14451   short tmp[LOOPCNT];        /* in case input is misaligned */
14452 #line 3141
14453   short *xp;
14454 #line 3141
14455   int nrange = 0;         /* number of range errors */
14456 #line 3141
14457   int realign = 0;        /* "do we need to fix input data alignment?" */
14458 #line 3141
14459   long cxp = (long) *((char**)xpp);
14460 #line 3141
14461 
14462 #line 3141
14463   realign = (cxp & 7) % SIZEOF_SHORT;
14464 #line 3141
14465   /* sjl: manually stripmine so we can limit amount of
14466 #line 3141
14467    * vector work space reserved to LOOPCNT elements. Also
14468 #line 3141
14469    * makes vectorisation easy */
14470 #line 3141
14471   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
14472 #line 3141
14473     ni=Min(nelems-j,LOOPCNT);
14474 #line 3141
14475     if (realign) {
14476 #line 3141
14477       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
14478 #line 3141
14479       xp = tmp;
14480 #line 3141
14481     } else {
14482 #line 3141
14483       xp = (short *) *xpp;
14484 #line 3141
14485     }
14486 #line 3141
14487    /* copy the next block */
14488 #line 3141
14489 #pragma cdir loopcnt=LOOPCNT
14490 #line 3141
14491 #pragma cdir shortloop
14492 #line 3141
14493     for (i=0; i<ni; i++) {
14494 #line 3141
14495       tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
14496 #line 3141
14497      /* test for range errors (not always needed but do it anyway) */
14498 #line 3141
14499      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
14500 #line 3141
14501      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
14502 #line 3141
14503       nrange += xp[i] > UCHAR_MAX || xp[i] < 0;
14504 #line 3141
14505     }
14506 #line 3141
14507    /* update xpp and tp */
14508 #line 3141
14509     if (realign) xp = (short *) *xpp;
14510 #line 3141
14511     xp += ni;
14512 #line 3141
14513     tp += ni;
14514 #line 3141
14515     *xpp = (void*)xp;
14516 #line 3141
14517   }
14518 #line 3141
14519   return nrange == 0 ? NC_NOERR : NC_ERANGE;
14520 #line 3141
14521 
14522 #line 3141
14523 #else   /* not SX */
14524 #line 3141
14525 	const char *xp = (const char *) *xpp;
14526 #line 3141
14527 	int status = NC_NOERR;
14528 #line 3141
14529 
14530 #line 3141
14531 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
14532 #line 3141
14533 	{
14534 #line 3141
14535 		const int lstatus = ncx_get_short_uchar(xp, tp);
14536 #line 3141
14537 		if (status == NC_NOERR) /* report the first encountered error */
14538 #line 3141
14539 			status = lstatus;
14540 #line 3141
14541 	}
14542 #line 3141
14543 
14544 #line 3141
14545 	*xpp = (const void *)xp;
14546 #line 3141
14547 	return status;
14548 #line 3141
14549 #endif
14550 #line 3141
14551 }
14552 #line 3141
14553 
14554 int
14555 #line 3142
ncx_getn_short_ushort(const void ** xpp,size_t nelems,ushort * tp)14556 ncx_getn_short_ushort(const void **xpp, size_t nelems, ushort *tp)
14557 #line 3142
14558 {
14559 #line 3142
14560 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
14561 #line 3142
14562 
14563 #line 3142
14564  /* basic algorithm is:
14565 #line 3142
14566   *   - ensure sane alignment of input data
14567 #line 3142
14568   *   - copy (conversion happens automatically) input data
14569 #line 3142
14570   *     to output
14571 #line 3142
14572   *   - update xpp to point at next unconverted input, and tp to point
14573 #line 3142
14574   *     at next location for converted output
14575 #line 3142
14576   */
14577 #line 3142
14578   long i, j, ni;
14579 #line 3142
14580   short tmp[LOOPCNT];        /* in case input is misaligned */
14581 #line 3142
14582   short *xp;
14583 #line 3142
14584   int nrange = 0;         /* number of range errors */
14585 #line 3142
14586   int realign = 0;        /* "do we need to fix input data alignment?" */
14587 #line 3142
14588   long cxp = (long) *((char**)xpp);
14589 #line 3142
14590 
14591 #line 3142
14592   realign = (cxp & 7) % SIZEOF_SHORT;
14593 #line 3142
14594   /* sjl: manually stripmine so we can limit amount of
14595 #line 3142
14596    * vector work space reserved to LOOPCNT elements. Also
14597 #line 3142
14598    * makes vectorisation easy */
14599 #line 3142
14600   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
14601 #line 3142
14602     ni=Min(nelems-j,LOOPCNT);
14603 #line 3142
14604     if (realign) {
14605 #line 3142
14606       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
14607 #line 3142
14608       xp = tmp;
14609 #line 3142
14610     } else {
14611 #line 3142
14612       xp = (short *) *xpp;
14613 #line 3142
14614     }
14615 #line 3142
14616    /* copy the next block */
14617 #line 3142
14618 #pragma cdir loopcnt=LOOPCNT
14619 #line 3142
14620 #pragma cdir shortloop
14621 #line 3142
14622     for (i=0; i<ni; i++) {
14623 #line 3142
14624       tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
14625 #line 3142
14626      /* test for range errors (not always needed but do it anyway) */
14627 #line 3142
14628      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
14629 #line 3142
14630      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
14631 #line 3142
14632       nrange += xp[i] > USHORT_MAX || xp[i] < 0;
14633 #line 3142
14634     }
14635 #line 3142
14636    /* update xpp and tp */
14637 #line 3142
14638     if (realign) xp = (short *) *xpp;
14639 #line 3142
14640     xp += ni;
14641 #line 3142
14642     tp += ni;
14643 #line 3142
14644     *xpp = (void*)xp;
14645 #line 3142
14646   }
14647 #line 3142
14648   return nrange == 0 ? NC_NOERR : NC_ERANGE;
14649 #line 3142
14650 
14651 #line 3142
14652 #else   /* not SX */
14653 #line 3142
14654 	const char *xp = (const char *) *xpp;
14655 #line 3142
14656 	int status = NC_NOERR;
14657 #line 3142
14658 
14659 #line 3142
14660 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
14661 #line 3142
14662 	{
14663 #line 3142
14664 		const int lstatus = ncx_get_short_ushort(xp, tp);
14665 #line 3142
14666 		if (status == NC_NOERR) /* report the first encountered error */
14667 #line 3142
14668 			status = lstatus;
14669 #line 3142
14670 	}
14671 #line 3142
14672 
14673 #line 3142
14674 	*xpp = (const void *)xp;
14675 #line 3142
14676 	return status;
14677 #line 3142
14678 #endif
14679 #line 3142
14680 }
14681 #line 3142
14682 
14683 int
14684 #line 3143
ncx_getn_short_uint(const void ** xpp,size_t nelems,uint * tp)14685 ncx_getn_short_uint(const void **xpp, size_t nelems, uint *tp)
14686 #line 3143
14687 {
14688 #line 3143
14689 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
14690 #line 3143
14691 
14692 #line 3143
14693  /* basic algorithm is:
14694 #line 3143
14695   *   - ensure sane alignment of input data
14696 #line 3143
14697   *   - copy (conversion happens automatically) input data
14698 #line 3143
14699   *     to output
14700 #line 3143
14701   *   - update xpp to point at next unconverted input, and tp to point
14702 #line 3143
14703   *     at next location for converted output
14704 #line 3143
14705   */
14706 #line 3143
14707   long i, j, ni;
14708 #line 3143
14709   short tmp[LOOPCNT];        /* in case input is misaligned */
14710 #line 3143
14711   short *xp;
14712 #line 3143
14713   int nrange = 0;         /* number of range errors */
14714 #line 3143
14715   int realign = 0;        /* "do we need to fix input data alignment?" */
14716 #line 3143
14717   long cxp = (long) *((char**)xpp);
14718 #line 3143
14719 
14720 #line 3143
14721   realign = (cxp & 7) % SIZEOF_SHORT;
14722 #line 3143
14723   /* sjl: manually stripmine so we can limit amount of
14724 #line 3143
14725    * vector work space reserved to LOOPCNT elements. Also
14726 #line 3143
14727    * makes vectorisation easy */
14728 #line 3143
14729   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
14730 #line 3143
14731     ni=Min(nelems-j,LOOPCNT);
14732 #line 3143
14733     if (realign) {
14734 #line 3143
14735       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
14736 #line 3143
14737       xp = tmp;
14738 #line 3143
14739     } else {
14740 #line 3143
14741       xp = (short *) *xpp;
14742 #line 3143
14743     }
14744 #line 3143
14745    /* copy the next block */
14746 #line 3143
14747 #pragma cdir loopcnt=LOOPCNT
14748 #line 3143
14749 #pragma cdir shortloop
14750 #line 3143
14751     for (i=0; i<ni; i++) {
14752 #line 3143
14753       tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
14754 #line 3143
14755      /* test for range errors (not always needed but do it anyway) */
14756 #line 3143
14757      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
14758 #line 3143
14759      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
14760 #line 3143
14761       nrange += xp[i] > UINT_MAX || xp[i] < 0;
14762 #line 3143
14763     }
14764 #line 3143
14765    /* update xpp and tp */
14766 #line 3143
14767     if (realign) xp = (short *) *xpp;
14768 #line 3143
14769     xp += ni;
14770 #line 3143
14771     tp += ni;
14772 #line 3143
14773     *xpp = (void*)xp;
14774 #line 3143
14775   }
14776 #line 3143
14777   return nrange == 0 ? NC_NOERR : NC_ERANGE;
14778 #line 3143
14779 
14780 #line 3143
14781 #else   /* not SX */
14782 #line 3143
14783 	const char *xp = (const char *) *xpp;
14784 #line 3143
14785 	int status = NC_NOERR;
14786 #line 3143
14787 
14788 #line 3143
14789 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
14790 #line 3143
14791 	{
14792 #line 3143
14793 		const int lstatus = ncx_get_short_uint(xp, tp);
14794 #line 3143
14795 		if (status == NC_NOERR) /* report the first encountered error */
14796 #line 3143
14797 			status = lstatus;
14798 #line 3143
14799 	}
14800 #line 3143
14801 
14802 #line 3143
14803 	*xpp = (const void *)xp;
14804 #line 3143
14805 	return status;
14806 #line 3143
14807 #endif
14808 #line 3143
14809 }
14810 #line 3143
14811 
14812 int
14813 #line 3144
ncx_getn_short_ulonglong(const void ** xpp,size_t nelems,ulonglong * tp)14814 ncx_getn_short_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
14815 #line 3144
14816 {
14817 #line 3144
14818 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
14819 #line 3144
14820 
14821 #line 3144
14822  /* basic algorithm is:
14823 #line 3144
14824   *   - ensure sane alignment of input data
14825 #line 3144
14826   *   - copy (conversion happens automatically) input data
14827 #line 3144
14828   *     to output
14829 #line 3144
14830   *   - update xpp to point at next unconverted input, and tp to point
14831 #line 3144
14832   *     at next location for converted output
14833 #line 3144
14834   */
14835 #line 3144
14836   long i, j, ni;
14837 #line 3144
14838   short tmp[LOOPCNT];        /* in case input is misaligned */
14839 #line 3144
14840   short *xp;
14841 #line 3144
14842   int nrange = 0;         /* number of range errors */
14843 #line 3144
14844   int realign = 0;        /* "do we need to fix input data alignment?" */
14845 #line 3144
14846   long cxp = (long) *((char**)xpp);
14847 #line 3144
14848 
14849 #line 3144
14850   realign = (cxp & 7) % SIZEOF_SHORT;
14851 #line 3144
14852   /* sjl: manually stripmine so we can limit amount of
14853 #line 3144
14854    * vector work space reserved to LOOPCNT elements. Also
14855 #line 3144
14856    * makes vectorisation easy */
14857 #line 3144
14858   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
14859 #line 3144
14860     ni=Min(nelems-j,LOOPCNT);
14861 #line 3144
14862     if (realign) {
14863 #line 3144
14864       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
14865 #line 3144
14866       xp = tmp;
14867 #line 3144
14868     } else {
14869 #line 3144
14870       xp = (short *) *xpp;
14871 #line 3144
14872     }
14873 #line 3144
14874    /* copy the next block */
14875 #line 3144
14876 #pragma cdir loopcnt=LOOPCNT
14877 #line 3144
14878 #pragma cdir shortloop
14879 #line 3144
14880     for (i=0; i<ni; i++) {
14881 #line 3144
14882       tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
14883 #line 3144
14884      /* test for range errors (not always needed but do it anyway) */
14885 #line 3144
14886      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
14887 #line 3144
14888      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
14889 #line 3144
14890       nrange += xp[i] > ULONGLONG_MAX || xp[i] < 0;
14891 #line 3144
14892     }
14893 #line 3144
14894    /* update xpp and tp */
14895 #line 3144
14896     if (realign) xp = (short *) *xpp;
14897 #line 3144
14898     xp += ni;
14899 #line 3144
14900     tp += ni;
14901 #line 3144
14902     *xpp = (void*)xp;
14903 #line 3144
14904   }
14905 #line 3144
14906   return nrange == 0 ? NC_NOERR : NC_ERANGE;
14907 #line 3144
14908 
14909 #line 3144
14910 #else   /* not SX */
14911 #line 3144
14912 	const char *xp = (const char *) *xpp;
14913 #line 3144
14914 	int status = NC_NOERR;
14915 #line 3144
14916 
14917 #line 3144
14918 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
14919 #line 3144
14920 	{
14921 #line 3144
14922 		const int lstatus = ncx_get_short_ulonglong(xp, tp);
14923 #line 3144
14924 		if (status == NC_NOERR) /* report the first encountered error */
14925 #line 3144
14926 			status = lstatus;
14927 #line 3144
14928 	}
14929 #line 3144
14930 
14931 #line 3144
14932 	*xpp = (const void *)xp;
14933 #line 3144
14934 	return status;
14935 #line 3144
14936 #endif
14937 #line 3144
14938 }
14939 #line 3144
14940 
14941 
14942 int
14943 #line 3146
ncx_pad_getn_short_schar(const void ** xpp,size_t nelems,schar * tp)14944 ncx_pad_getn_short_schar(const void **xpp, size_t nelems, schar *tp)
14945 #line 3146
14946 {
14947 #line 3146
14948 	const size_t rndup = nelems % X_SIZEOF_SHORT;
14949 #line 3146
14950 
14951 #line 3146
14952 	const char *xp = (const char *) *xpp;
14953 #line 3146
14954 	int status = NC_NOERR;
14955 #line 3146
14956 
14957 #line 3146
14958 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
14959 #line 3146
14960 	{
14961 #line 3146
14962 		const int lstatus = ncx_get_short_schar(xp, tp);
14963 #line 3146
14964 		if (status == NC_NOERR) /* report the first encountered error */
14965 #line 3146
14966 			status = lstatus;
14967 #line 3146
14968 	}
14969 #line 3146
14970 
14971 #line 3146
14972 	if (rndup != 0)
14973 #line 3146
14974 		xp += X_SIZEOF_SHORT;
14975 #line 3146
14976 
14977 #line 3146
14978 	*xpp = (void *)xp;
14979 #line 3146
14980 	return status;
14981 #line 3146
14982 }
14983 #line 3146
14984 
14985 int
14986 #line 3147
ncx_pad_getn_short_uchar(const void ** xpp,size_t nelems,uchar * tp)14987 ncx_pad_getn_short_uchar(const void **xpp, size_t nelems, uchar *tp)
14988 #line 3147
14989 {
14990 #line 3147
14991 	const size_t rndup = nelems % X_SIZEOF_SHORT;
14992 #line 3147
14993 
14994 #line 3147
14995 	const char *xp = (const char *) *xpp;
14996 #line 3147
14997 	int status = NC_NOERR;
14998 #line 3147
14999 
15000 #line 3147
15001 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
15002 #line 3147
15003 	{
15004 #line 3147
15005 		const int lstatus = ncx_get_short_uchar(xp, tp);
15006 #line 3147
15007 		if (status == NC_NOERR) /* report the first encountered error */
15008 #line 3147
15009 			status = lstatus;
15010 #line 3147
15011 	}
15012 #line 3147
15013 
15014 #line 3147
15015 	if (rndup != 0)
15016 #line 3147
15017 		xp += X_SIZEOF_SHORT;
15018 #line 3147
15019 
15020 #line 3147
15021 	*xpp = (void *)xp;
15022 #line 3147
15023 	return status;
15024 #line 3147
15025 }
15026 #line 3147
15027 
15028 int
15029 #line 3148
ncx_pad_getn_short_short(const void ** xpp,size_t nelems,short * tp)15030 ncx_pad_getn_short_short(const void **xpp, size_t nelems, short *tp)
15031 #line 3148
15032 {
15033 #line 3148
15034 	const size_t rndup = nelems % X_SIZEOF_SHORT;
15035 #line 3148
15036 
15037 #line 3148
15038 	const char *xp = (const char *) *xpp;
15039 #line 3148
15040 	int status = NC_NOERR;
15041 #line 3148
15042 
15043 #line 3148
15044 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
15045 #line 3148
15046 	{
15047 #line 3148
15048 		const int lstatus = ncx_get_short_short(xp, tp);
15049 #line 3148
15050 		if (status == NC_NOERR) /* report the first encountered error */
15051 #line 3148
15052 			status = lstatus;
15053 #line 3148
15054 	}
15055 #line 3148
15056 
15057 #line 3148
15058 	if (rndup != 0)
15059 #line 3148
15060 		xp += X_SIZEOF_SHORT;
15061 #line 3148
15062 
15063 #line 3148
15064 	*xpp = (void *)xp;
15065 #line 3148
15066 	return status;
15067 #line 3148
15068 }
15069 #line 3148
15070 
15071 int
15072 #line 3149
ncx_pad_getn_short_int(const void ** xpp,size_t nelems,int * tp)15073 ncx_pad_getn_short_int(const void **xpp, size_t nelems, int *tp)
15074 #line 3149
15075 {
15076 #line 3149
15077 	const size_t rndup = nelems % X_SIZEOF_SHORT;
15078 #line 3149
15079 
15080 #line 3149
15081 	const char *xp = (const char *) *xpp;
15082 #line 3149
15083 	int status = NC_NOERR;
15084 #line 3149
15085 
15086 #line 3149
15087 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
15088 #line 3149
15089 	{
15090 #line 3149
15091 		const int lstatus = ncx_get_short_int(xp, tp);
15092 #line 3149
15093 		if (status == NC_NOERR) /* report the first encountered error */
15094 #line 3149
15095 			status = lstatus;
15096 #line 3149
15097 	}
15098 #line 3149
15099 
15100 #line 3149
15101 	if (rndup != 0)
15102 #line 3149
15103 		xp += X_SIZEOF_SHORT;
15104 #line 3149
15105 
15106 #line 3149
15107 	*xpp = (void *)xp;
15108 #line 3149
15109 	return status;
15110 #line 3149
15111 }
15112 #line 3149
15113 
15114 int
15115 #line 3150
ncx_pad_getn_short_long(const void ** xpp,size_t nelems,long * tp)15116 ncx_pad_getn_short_long(const void **xpp, size_t nelems, long *tp)
15117 #line 3150
15118 {
15119 #line 3150
15120 	const size_t rndup = nelems % X_SIZEOF_SHORT;
15121 #line 3150
15122 
15123 #line 3150
15124 	const char *xp = (const char *) *xpp;
15125 #line 3150
15126 	int status = NC_NOERR;
15127 #line 3150
15128 
15129 #line 3150
15130 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
15131 #line 3150
15132 	{
15133 #line 3150
15134 		const int lstatus = ncx_get_short_long(xp, tp);
15135 #line 3150
15136 		if (status == NC_NOERR) /* report the first encountered error */
15137 #line 3150
15138 			status = lstatus;
15139 #line 3150
15140 	}
15141 #line 3150
15142 
15143 #line 3150
15144 	if (rndup != 0)
15145 #line 3150
15146 		xp += X_SIZEOF_SHORT;
15147 #line 3150
15148 
15149 #line 3150
15150 	*xpp = (void *)xp;
15151 #line 3150
15152 	return status;
15153 #line 3150
15154 }
15155 #line 3150
15156 
15157 int
15158 #line 3151
ncx_pad_getn_short_float(const void ** xpp,size_t nelems,float * tp)15159 ncx_pad_getn_short_float(const void **xpp, size_t nelems, float *tp)
15160 #line 3151
15161 {
15162 #line 3151
15163 	const size_t rndup = nelems % X_SIZEOF_SHORT;
15164 #line 3151
15165 
15166 #line 3151
15167 	const char *xp = (const char *) *xpp;
15168 #line 3151
15169 	int status = NC_NOERR;
15170 #line 3151
15171 
15172 #line 3151
15173 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
15174 #line 3151
15175 	{
15176 #line 3151
15177 		const int lstatus = ncx_get_short_float(xp, tp);
15178 #line 3151
15179 		if (status == NC_NOERR) /* report the first encountered error */
15180 #line 3151
15181 			status = lstatus;
15182 #line 3151
15183 	}
15184 #line 3151
15185 
15186 #line 3151
15187 	if (rndup != 0)
15188 #line 3151
15189 		xp += X_SIZEOF_SHORT;
15190 #line 3151
15191 
15192 #line 3151
15193 	*xpp = (void *)xp;
15194 #line 3151
15195 	return status;
15196 #line 3151
15197 }
15198 #line 3151
15199 
15200 int
15201 #line 3152
ncx_pad_getn_short_double(const void ** xpp,size_t nelems,double * tp)15202 ncx_pad_getn_short_double(const void **xpp, size_t nelems, double *tp)
15203 #line 3152
15204 {
15205 #line 3152
15206 	const size_t rndup = nelems % X_SIZEOF_SHORT;
15207 #line 3152
15208 
15209 #line 3152
15210 	const char *xp = (const char *) *xpp;
15211 #line 3152
15212 	int status = NC_NOERR;
15213 #line 3152
15214 
15215 #line 3152
15216 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
15217 #line 3152
15218 	{
15219 #line 3152
15220 		const int lstatus = ncx_get_short_double(xp, tp);
15221 #line 3152
15222 		if (status == NC_NOERR) /* report the first encountered error */
15223 #line 3152
15224 			status = lstatus;
15225 #line 3152
15226 	}
15227 #line 3152
15228 
15229 #line 3152
15230 	if (rndup != 0)
15231 #line 3152
15232 		xp += X_SIZEOF_SHORT;
15233 #line 3152
15234 
15235 #line 3152
15236 	*xpp = (void *)xp;
15237 #line 3152
15238 	return status;
15239 #line 3152
15240 }
15241 #line 3152
15242 
15243 int
15244 #line 3153
ncx_pad_getn_short_uint(const void ** xpp,size_t nelems,uint * tp)15245 ncx_pad_getn_short_uint(const void **xpp, size_t nelems, uint *tp)
15246 #line 3153
15247 {
15248 #line 3153
15249 	const size_t rndup = nelems % X_SIZEOF_SHORT;
15250 #line 3153
15251 
15252 #line 3153
15253 	const char *xp = (const char *) *xpp;
15254 #line 3153
15255 	int status = NC_NOERR;
15256 #line 3153
15257 
15258 #line 3153
15259 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
15260 #line 3153
15261 	{
15262 #line 3153
15263 		const int lstatus = ncx_get_short_uint(xp, tp);
15264 #line 3153
15265 		if (status == NC_NOERR) /* report the first encountered error */
15266 #line 3153
15267 			status = lstatus;
15268 #line 3153
15269 	}
15270 #line 3153
15271 
15272 #line 3153
15273 	if (rndup != 0)
15274 #line 3153
15275 		xp += X_SIZEOF_SHORT;
15276 #line 3153
15277 
15278 #line 3153
15279 	*xpp = (void *)xp;
15280 #line 3153
15281 	return status;
15282 #line 3153
15283 }
15284 #line 3153
15285 
15286 int
15287 #line 3154
ncx_pad_getn_short_longlong(const void ** xpp,size_t nelems,longlong * tp)15288 ncx_pad_getn_short_longlong(const void **xpp, size_t nelems, longlong *tp)
15289 #line 3154
15290 {
15291 #line 3154
15292 	const size_t rndup = nelems % X_SIZEOF_SHORT;
15293 #line 3154
15294 
15295 #line 3154
15296 	const char *xp = (const char *) *xpp;
15297 #line 3154
15298 	int status = NC_NOERR;
15299 #line 3154
15300 
15301 #line 3154
15302 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
15303 #line 3154
15304 	{
15305 #line 3154
15306 		const int lstatus = ncx_get_short_longlong(xp, tp);
15307 #line 3154
15308 		if (status == NC_NOERR) /* report the first encountered error */
15309 #line 3154
15310 			status = lstatus;
15311 #line 3154
15312 	}
15313 #line 3154
15314 
15315 #line 3154
15316 	if (rndup != 0)
15317 #line 3154
15318 		xp += X_SIZEOF_SHORT;
15319 #line 3154
15320 
15321 #line 3154
15322 	*xpp = (void *)xp;
15323 #line 3154
15324 	return status;
15325 #line 3154
15326 }
15327 #line 3154
15328 
15329 int
15330 #line 3155
ncx_pad_getn_short_ulonglong(const void ** xpp,size_t nelems,ulonglong * tp)15331 ncx_pad_getn_short_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
15332 #line 3155
15333 {
15334 #line 3155
15335 	const size_t rndup = nelems % X_SIZEOF_SHORT;
15336 #line 3155
15337 
15338 #line 3155
15339 	const char *xp = (const char *) *xpp;
15340 #line 3155
15341 	int status = NC_NOERR;
15342 #line 3155
15343 
15344 #line 3155
15345 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
15346 #line 3155
15347 	{
15348 #line 3155
15349 		const int lstatus = ncx_get_short_ulonglong(xp, tp);
15350 #line 3155
15351 		if (status == NC_NOERR) /* report the first encountered error */
15352 #line 3155
15353 			status = lstatus;
15354 #line 3155
15355 	}
15356 #line 3155
15357 
15358 #line 3155
15359 	if (rndup != 0)
15360 #line 3155
15361 		xp += X_SIZEOF_SHORT;
15362 #line 3155
15363 
15364 #line 3155
15365 	*xpp = (void *)xp;
15366 #line 3155
15367 	return status;
15368 #line 3155
15369 }
15370 #line 3155
15371 
15372 int
15373 #line 3156
ncx_pad_getn_short_ushort(const void ** xpp,size_t nelems,ushort * tp)15374 ncx_pad_getn_short_ushort(const void **xpp, size_t nelems, ushort *tp)
15375 #line 3156
15376 {
15377 #line 3156
15378 	const size_t rndup = nelems % X_SIZEOF_SHORT;
15379 #line 3156
15380 
15381 #line 3156
15382 	const char *xp = (const char *) *xpp;
15383 #line 3156
15384 	int status = NC_NOERR;
15385 #line 3156
15386 
15387 #line 3156
15388 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
15389 #line 3156
15390 	{
15391 #line 3156
15392 		const int lstatus = ncx_get_short_ushort(xp, tp);
15393 #line 3156
15394 		if (status == NC_NOERR) /* report the first encountered error */
15395 #line 3156
15396 			status = lstatus;
15397 #line 3156
15398 	}
15399 #line 3156
15400 
15401 #line 3156
15402 	if (rndup != 0)
15403 #line 3156
15404 		xp += X_SIZEOF_SHORT;
15405 #line 3156
15406 
15407 #line 3156
15408 	*xpp = (void *)xp;
15409 #line 3156
15410 	return status;
15411 #line 3156
15412 }
15413 #line 3156
15414 
15415 
15416 #if X_SIZEOF_SHORT == SIZEOF_SHORT
15417 /* optimized version */
15418 int
ncx_putn_short_short(void ** xpp,size_t nelems,const short * tp,void * fillp)15419 ncx_putn_short_short(void **xpp, size_t nelems, const short *tp, void *fillp)
15420 {
15421 #ifdef WORDS_BIGENDIAN
15422 	(void) memcpy(*xpp, tp, (size_t)nelems * X_SIZEOF_SHORT);
15423 # else
15424 	swapn2b(*xpp, tp, nelems);
15425 # endif
15426 	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_SHORT);
15427 	return NC_NOERR;
15428 }
15429 #else
15430 int
15431 #line 3172
ncx_putn_short_short(void ** xpp,size_t nelems,const short * tp,void * fillp)15432 ncx_putn_short_short(void **xpp, size_t nelems, const short *tp, void *fillp)
15433 #line 3172
15434 {
15435 #line 3172
15436 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
15437 #line 3172
15438 
15439 #line 3172
15440  /* basic algorithm is:
15441 #line 3172
15442   *   - ensure sane alignment of output data
15443 #line 3172
15444   *   - copy (conversion happens automatically) input data
15445 #line 3172
15446   *     to output
15447 #line 3172
15448   *   - update tp to point at next unconverted input, and xpp to point
15449 #line 3172
15450   *     at next location for converted output
15451 #line 3172
15452   */
15453 #line 3172
15454   long i, j, ni;
15455 #line 3172
15456   short tmp[LOOPCNT];        /* in case input is misaligned */
15457 #line 3172
15458   short *xp;
15459 #line 3172
15460   int nrange = 0;         /* number of range errors */
15461 #line 3172
15462   int realign = 0;        /* "do we need to fix input data alignment?" */
15463 #line 3172
15464   long cxp = (long) *((char**)xpp);
15465 #line 3172
15466 
15467 #line 3172
15468   realign = (cxp & 7) % SIZEOF_SHORT;
15469 #line 3172
15470   /* sjl: manually stripmine so we can limit amount of
15471 #line 3172
15472    * vector work space reserved to LOOPCNT elements. Also
15473 #line 3172
15474    * makes vectorisation easy */
15475 #line 3172
15476   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
15477 #line 3172
15478     ni=Min(nelems-j,LOOPCNT);
15479 #line 3172
15480     if (realign) {
15481 #line 3172
15482       xp = tmp;
15483 #line 3172
15484     } else {
15485 #line 3172
15486       xp = (short *) *xpp;
15487 #line 3172
15488     }
15489 #line 3172
15490    /* copy the next block */
15491 #line 3172
15492 #pragma cdir loopcnt=LOOPCNT
15493 #line 3172
15494 #pragma cdir shortloop
15495 #line 3172
15496     for (i=0; i<ni; i++) {
15497 #line 3172
15498       /* the normal case: */
15499 #line 3172
15500       xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
15501 #line 3172
15502      /* test for range errors (not always needed but do it anyway) */
15503 #line 3172
15504      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
15505 #line 3172
15506      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
15507 #line 3172
15508       nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
15509 #line 3172
15510     }
15511 #line 3172
15512    /* copy workspace back if necessary */
15513 #line 3172
15514     if (realign) {
15515 #line 3172
15516       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
15517 #line 3172
15518       xp = (short *) *xpp;
15519 #line 3172
15520     }
15521 #line 3172
15522    /* update xpp and tp */
15523 #line 3172
15524     xp += ni;
15525 #line 3172
15526     tp += ni;
15527 #line 3172
15528     *xpp = (void*)xp;
15529 #line 3172
15530   }
15531 #line 3172
15532   return nrange == 0 ? NC_NOERR : NC_ERANGE;
15533 #line 3172
15534 
15535 #line 3172
15536 #else   /* not SX */
15537 #line 3172
15538 
15539 #line 3172
15540 	char *xp = (char *) *xpp;
15541 #line 3172
15542 	int status = NC_NOERR;
15543 #line 3172
15544 
15545 #line 3172
15546 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
15547 #line 3172
15548 	{
15549 #line 3172
15550 		int lstatus = ncx_put_short_short(xp, tp, fillp);
15551 #line 3172
15552 		if (status == NC_NOERR) /* report the first encountered error */
15553 #line 3172
15554 			status = lstatus;
15555 #line 3172
15556 	}
15557 #line 3172
15558 
15559 #line 3172
15560 	*xpp = (void *)xp;
15561 #line 3172
15562 	return status;
15563 #line 3172
15564 #endif
15565 #line 3172
15566 }
15567 #line 3172
15568 
15569 #endif
15570 int
15571 #line 3174
ncx_putn_short_schar(void ** xpp,size_t nelems,const schar * tp,void * fillp)15572 ncx_putn_short_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
15573 #line 3174
15574 {
15575 #line 3174
15576 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
15577 #line 3174
15578 
15579 #line 3174
15580  /* basic algorithm is:
15581 #line 3174
15582   *   - ensure sane alignment of output data
15583 #line 3174
15584   *   - copy (conversion happens automatically) input data
15585 #line 3174
15586   *     to output
15587 #line 3174
15588   *   - update tp to point at next unconverted input, and xpp to point
15589 #line 3174
15590   *     at next location for converted output
15591 #line 3174
15592   */
15593 #line 3174
15594   long i, j, ni;
15595 #line 3174
15596   short tmp[LOOPCNT];        /* in case input is misaligned */
15597 #line 3174
15598   short *xp;
15599 #line 3174
15600   int nrange = 0;         /* number of range errors */
15601 #line 3174
15602   int realign = 0;        /* "do we need to fix input data alignment?" */
15603 #line 3174
15604   long cxp = (long) *((char**)xpp);
15605 #line 3174
15606 
15607 #line 3174
15608   realign = (cxp & 7) % SIZEOF_SHORT;
15609 #line 3174
15610   /* sjl: manually stripmine so we can limit amount of
15611 #line 3174
15612    * vector work space reserved to LOOPCNT elements. Also
15613 #line 3174
15614    * makes vectorisation easy */
15615 #line 3174
15616   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
15617 #line 3174
15618     ni=Min(nelems-j,LOOPCNT);
15619 #line 3174
15620     if (realign) {
15621 #line 3174
15622       xp = tmp;
15623 #line 3174
15624     } else {
15625 #line 3174
15626       xp = (short *) *xpp;
15627 #line 3174
15628     }
15629 #line 3174
15630    /* copy the next block */
15631 #line 3174
15632 #pragma cdir loopcnt=LOOPCNT
15633 #line 3174
15634 #pragma cdir shortloop
15635 #line 3174
15636     for (i=0; i<ni; i++) {
15637 #line 3174
15638       /* the normal case: */
15639 #line 3174
15640       xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
15641 #line 3174
15642      /* test for range errors (not always needed but do it anyway) */
15643 #line 3174
15644      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
15645 #line 3174
15646      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
15647 #line 3174
15648       nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
15649 #line 3174
15650     }
15651 #line 3174
15652    /* copy workspace back if necessary */
15653 #line 3174
15654     if (realign) {
15655 #line 3174
15656       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
15657 #line 3174
15658       xp = (short *) *xpp;
15659 #line 3174
15660     }
15661 #line 3174
15662    /* update xpp and tp */
15663 #line 3174
15664     xp += ni;
15665 #line 3174
15666     tp += ni;
15667 #line 3174
15668     *xpp = (void*)xp;
15669 #line 3174
15670   }
15671 #line 3174
15672   return nrange == 0 ? NC_NOERR : NC_ERANGE;
15673 #line 3174
15674 
15675 #line 3174
15676 #else   /* not SX */
15677 #line 3174
15678 
15679 #line 3174
15680 	char *xp = (char *) *xpp;
15681 #line 3174
15682 	int status = NC_NOERR;
15683 #line 3174
15684 
15685 #line 3174
15686 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
15687 #line 3174
15688 	{
15689 #line 3174
15690 		int lstatus = ncx_put_short_schar(xp, tp, fillp);
15691 #line 3174
15692 		if (status == NC_NOERR) /* report the first encountered error */
15693 #line 3174
15694 			status = lstatus;
15695 #line 3174
15696 	}
15697 #line 3174
15698 
15699 #line 3174
15700 	*xpp = (void *)xp;
15701 #line 3174
15702 	return status;
15703 #line 3174
15704 #endif
15705 #line 3174
15706 }
15707 #line 3174
15708 
15709 int
15710 #line 3175
ncx_putn_short_int(void ** xpp,size_t nelems,const int * tp,void * fillp)15711 ncx_putn_short_int(void **xpp, size_t nelems, const int *tp, void *fillp)
15712 #line 3175
15713 {
15714 #line 3175
15715 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
15716 #line 3175
15717 
15718 #line 3175
15719  /* basic algorithm is:
15720 #line 3175
15721   *   - ensure sane alignment of output data
15722 #line 3175
15723   *   - copy (conversion happens automatically) input data
15724 #line 3175
15725   *     to output
15726 #line 3175
15727   *   - update tp to point at next unconverted input, and xpp to point
15728 #line 3175
15729   *     at next location for converted output
15730 #line 3175
15731   */
15732 #line 3175
15733   long i, j, ni;
15734 #line 3175
15735   short tmp[LOOPCNT];        /* in case input is misaligned */
15736 #line 3175
15737   short *xp;
15738 #line 3175
15739   int nrange = 0;         /* number of range errors */
15740 #line 3175
15741   int realign = 0;        /* "do we need to fix input data alignment?" */
15742 #line 3175
15743   long cxp = (long) *((char**)xpp);
15744 #line 3175
15745 
15746 #line 3175
15747   realign = (cxp & 7) % SIZEOF_SHORT;
15748 #line 3175
15749   /* sjl: manually stripmine so we can limit amount of
15750 #line 3175
15751    * vector work space reserved to LOOPCNT elements. Also
15752 #line 3175
15753    * makes vectorisation easy */
15754 #line 3175
15755   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
15756 #line 3175
15757     ni=Min(nelems-j,LOOPCNT);
15758 #line 3175
15759     if (realign) {
15760 #line 3175
15761       xp = tmp;
15762 #line 3175
15763     } else {
15764 #line 3175
15765       xp = (short *) *xpp;
15766 #line 3175
15767     }
15768 #line 3175
15769    /* copy the next block */
15770 #line 3175
15771 #pragma cdir loopcnt=LOOPCNT
15772 #line 3175
15773 #pragma cdir shortloop
15774 #line 3175
15775     for (i=0; i<ni; i++) {
15776 #line 3175
15777       /* the normal case: */
15778 #line 3175
15779       xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
15780 #line 3175
15781      /* test for range errors (not always needed but do it anyway) */
15782 #line 3175
15783      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
15784 #line 3175
15785      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
15786 #line 3175
15787       nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
15788 #line 3175
15789     }
15790 #line 3175
15791    /* copy workspace back if necessary */
15792 #line 3175
15793     if (realign) {
15794 #line 3175
15795       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
15796 #line 3175
15797       xp = (short *) *xpp;
15798 #line 3175
15799     }
15800 #line 3175
15801    /* update xpp and tp */
15802 #line 3175
15803     xp += ni;
15804 #line 3175
15805     tp += ni;
15806 #line 3175
15807     *xpp = (void*)xp;
15808 #line 3175
15809   }
15810 #line 3175
15811   return nrange == 0 ? NC_NOERR : NC_ERANGE;
15812 #line 3175
15813 
15814 #line 3175
15815 #else   /* not SX */
15816 #line 3175
15817 
15818 #line 3175
15819 	char *xp = (char *) *xpp;
15820 #line 3175
15821 	int status = NC_NOERR;
15822 #line 3175
15823 
15824 #line 3175
15825 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
15826 #line 3175
15827 	{
15828 #line 3175
15829 		int lstatus = ncx_put_short_int(xp, tp, fillp);
15830 #line 3175
15831 		if (status == NC_NOERR) /* report the first encountered error */
15832 #line 3175
15833 			status = lstatus;
15834 #line 3175
15835 	}
15836 #line 3175
15837 
15838 #line 3175
15839 	*xpp = (void *)xp;
15840 #line 3175
15841 	return status;
15842 #line 3175
15843 #endif
15844 #line 3175
15845 }
15846 #line 3175
15847 
15848 int
15849 #line 3176
ncx_putn_short_long(void ** xpp,size_t nelems,const long * tp,void * fillp)15850 ncx_putn_short_long(void **xpp, size_t nelems, const long *tp, void *fillp)
15851 #line 3176
15852 {
15853 #line 3176
15854 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
15855 #line 3176
15856 
15857 #line 3176
15858  /* basic algorithm is:
15859 #line 3176
15860   *   - ensure sane alignment of output data
15861 #line 3176
15862   *   - copy (conversion happens automatically) input data
15863 #line 3176
15864   *     to output
15865 #line 3176
15866   *   - update tp to point at next unconverted input, and xpp to point
15867 #line 3176
15868   *     at next location for converted output
15869 #line 3176
15870   */
15871 #line 3176
15872   long i, j, ni;
15873 #line 3176
15874   short tmp[LOOPCNT];        /* in case input is misaligned */
15875 #line 3176
15876   short *xp;
15877 #line 3176
15878   int nrange = 0;         /* number of range errors */
15879 #line 3176
15880   int realign = 0;        /* "do we need to fix input data alignment?" */
15881 #line 3176
15882   long cxp = (long) *((char**)xpp);
15883 #line 3176
15884 
15885 #line 3176
15886   realign = (cxp & 7) % SIZEOF_SHORT;
15887 #line 3176
15888   /* sjl: manually stripmine so we can limit amount of
15889 #line 3176
15890    * vector work space reserved to LOOPCNT elements. Also
15891 #line 3176
15892    * makes vectorisation easy */
15893 #line 3176
15894   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
15895 #line 3176
15896     ni=Min(nelems-j,LOOPCNT);
15897 #line 3176
15898     if (realign) {
15899 #line 3176
15900       xp = tmp;
15901 #line 3176
15902     } else {
15903 #line 3176
15904       xp = (short *) *xpp;
15905 #line 3176
15906     }
15907 #line 3176
15908    /* copy the next block */
15909 #line 3176
15910 #pragma cdir loopcnt=LOOPCNT
15911 #line 3176
15912 #pragma cdir shortloop
15913 #line 3176
15914     for (i=0; i<ni; i++) {
15915 #line 3176
15916       /* the normal case: */
15917 #line 3176
15918       xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
15919 #line 3176
15920      /* test for range errors (not always needed but do it anyway) */
15921 #line 3176
15922      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
15923 #line 3176
15924      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
15925 #line 3176
15926       nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
15927 #line 3176
15928     }
15929 #line 3176
15930    /* copy workspace back if necessary */
15931 #line 3176
15932     if (realign) {
15933 #line 3176
15934       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
15935 #line 3176
15936       xp = (short *) *xpp;
15937 #line 3176
15938     }
15939 #line 3176
15940    /* update xpp and tp */
15941 #line 3176
15942     xp += ni;
15943 #line 3176
15944     tp += ni;
15945 #line 3176
15946     *xpp = (void*)xp;
15947 #line 3176
15948   }
15949 #line 3176
15950   return nrange == 0 ? NC_NOERR : NC_ERANGE;
15951 #line 3176
15952 
15953 #line 3176
15954 #else   /* not SX */
15955 #line 3176
15956 
15957 #line 3176
15958 	char *xp = (char *) *xpp;
15959 #line 3176
15960 	int status = NC_NOERR;
15961 #line 3176
15962 
15963 #line 3176
15964 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
15965 #line 3176
15966 	{
15967 #line 3176
15968 		int lstatus = ncx_put_short_long(xp, tp, fillp);
15969 #line 3176
15970 		if (status == NC_NOERR) /* report the first encountered error */
15971 #line 3176
15972 			status = lstatus;
15973 #line 3176
15974 	}
15975 #line 3176
15976 
15977 #line 3176
15978 	*xpp = (void *)xp;
15979 #line 3176
15980 	return status;
15981 #line 3176
15982 #endif
15983 #line 3176
15984 }
15985 #line 3176
15986 
15987 int
15988 #line 3177
ncx_putn_short_float(void ** xpp,size_t nelems,const float * tp,void * fillp)15989 ncx_putn_short_float(void **xpp, size_t nelems, const float *tp, void *fillp)
15990 #line 3177
15991 {
15992 #line 3177
15993 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
15994 #line 3177
15995 
15996 #line 3177
15997  /* basic algorithm is:
15998 #line 3177
15999   *   - ensure sane alignment of output data
16000 #line 3177
16001   *   - copy (conversion happens automatically) input data
16002 #line 3177
16003   *     to output
16004 #line 3177
16005   *   - update tp to point at next unconverted input, and xpp to point
16006 #line 3177
16007   *     at next location for converted output
16008 #line 3177
16009   */
16010 #line 3177
16011   long i, j, ni;
16012 #line 3177
16013   short tmp[LOOPCNT];        /* in case input is misaligned */
16014 #line 3177
16015   short *xp;
16016 #line 3177
16017   int nrange = 0;         /* number of range errors */
16018 #line 3177
16019   int realign = 0;        /* "do we need to fix input data alignment?" */
16020 #line 3177
16021   long cxp = (long) *((char**)xpp);
16022 #line 3177
16023 
16024 #line 3177
16025   realign = (cxp & 7) % SIZEOF_SHORT;
16026 #line 3177
16027   /* sjl: manually stripmine so we can limit amount of
16028 #line 3177
16029    * vector work space reserved to LOOPCNT elements. Also
16030 #line 3177
16031    * makes vectorisation easy */
16032 #line 3177
16033   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
16034 #line 3177
16035     ni=Min(nelems-j,LOOPCNT);
16036 #line 3177
16037     if (realign) {
16038 #line 3177
16039       xp = tmp;
16040 #line 3177
16041     } else {
16042 #line 3177
16043       xp = (short *) *xpp;
16044 #line 3177
16045     }
16046 #line 3177
16047    /* copy the next block */
16048 #line 3177
16049 #pragma cdir loopcnt=LOOPCNT
16050 #line 3177
16051 #pragma cdir shortloop
16052 #line 3177
16053     for (i=0; i<ni; i++) {
16054 #line 3177
16055       /* the normal case: */
16056 #line 3177
16057       xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
16058 #line 3177
16059      /* test for range errors (not always needed but do it anyway) */
16060 #line 3177
16061      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
16062 #line 3177
16063      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
16064 #line 3177
16065       nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
16066 #line 3177
16067     }
16068 #line 3177
16069    /* copy workspace back if necessary */
16070 #line 3177
16071     if (realign) {
16072 #line 3177
16073       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
16074 #line 3177
16075       xp = (short *) *xpp;
16076 #line 3177
16077     }
16078 #line 3177
16079    /* update xpp and tp */
16080 #line 3177
16081     xp += ni;
16082 #line 3177
16083     tp += ni;
16084 #line 3177
16085     *xpp = (void*)xp;
16086 #line 3177
16087   }
16088 #line 3177
16089   return nrange == 0 ? NC_NOERR : NC_ERANGE;
16090 #line 3177
16091 
16092 #line 3177
16093 #else   /* not SX */
16094 #line 3177
16095 
16096 #line 3177
16097 	char *xp = (char *) *xpp;
16098 #line 3177
16099 	int status = NC_NOERR;
16100 #line 3177
16101 
16102 #line 3177
16103 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
16104 #line 3177
16105 	{
16106 #line 3177
16107 		int lstatus = ncx_put_short_float(xp, tp, fillp);
16108 #line 3177
16109 		if (status == NC_NOERR) /* report the first encountered error */
16110 #line 3177
16111 			status = lstatus;
16112 #line 3177
16113 	}
16114 #line 3177
16115 
16116 #line 3177
16117 	*xpp = (void *)xp;
16118 #line 3177
16119 	return status;
16120 #line 3177
16121 #endif
16122 #line 3177
16123 }
16124 #line 3177
16125 
16126 int
16127 #line 3178
ncx_putn_short_double(void ** xpp,size_t nelems,const double * tp,void * fillp)16128 ncx_putn_short_double(void **xpp, size_t nelems, const double *tp, void *fillp)
16129 #line 3178
16130 {
16131 #line 3178
16132 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
16133 #line 3178
16134 
16135 #line 3178
16136  /* basic algorithm is:
16137 #line 3178
16138   *   - ensure sane alignment of output data
16139 #line 3178
16140   *   - copy (conversion happens automatically) input data
16141 #line 3178
16142   *     to output
16143 #line 3178
16144   *   - update tp to point at next unconverted input, and xpp to point
16145 #line 3178
16146   *     at next location for converted output
16147 #line 3178
16148   */
16149 #line 3178
16150   long i, j, ni;
16151 #line 3178
16152   short tmp[LOOPCNT];        /* in case input is misaligned */
16153 #line 3178
16154   short *xp;
16155 #line 3178
16156   int nrange = 0;         /* number of range errors */
16157 #line 3178
16158   int realign = 0;        /* "do we need to fix input data alignment?" */
16159 #line 3178
16160   long cxp = (long) *((char**)xpp);
16161 #line 3178
16162 
16163 #line 3178
16164   realign = (cxp & 7) % SIZEOF_SHORT;
16165 #line 3178
16166   /* sjl: manually stripmine so we can limit amount of
16167 #line 3178
16168    * vector work space reserved to LOOPCNT elements. Also
16169 #line 3178
16170    * makes vectorisation easy */
16171 #line 3178
16172   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
16173 #line 3178
16174     ni=Min(nelems-j,LOOPCNT);
16175 #line 3178
16176     if (realign) {
16177 #line 3178
16178       xp = tmp;
16179 #line 3178
16180     } else {
16181 #line 3178
16182       xp = (short *) *xpp;
16183 #line 3178
16184     }
16185 #line 3178
16186    /* copy the next block */
16187 #line 3178
16188 #pragma cdir loopcnt=LOOPCNT
16189 #line 3178
16190 #pragma cdir shortloop
16191 #line 3178
16192     for (i=0; i<ni; i++) {
16193 #line 3178
16194       /* the normal case: */
16195 #line 3178
16196       xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
16197 #line 3178
16198      /* test for range errors (not always needed but do it anyway) */
16199 #line 3178
16200      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
16201 #line 3178
16202      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
16203 #line 3178
16204       nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
16205 #line 3178
16206     }
16207 #line 3178
16208    /* copy workspace back if necessary */
16209 #line 3178
16210     if (realign) {
16211 #line 3178
16212       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
16213 #line 3178
16214       xp = (short *) *xpp;
16215 #line 3178
16216     }
16217 #line 3178
16218    /* update xpp and tp */
16219 #line 3178
16220     xp += ni;
16221 #line 3178
16222     tp += ni;
16223 #line 3178
16224     *xpp = (void*)xp;
16225 #line 3178
16226   }
16227 #line 3178
16228   return nrange == 0 ? NC_NOERR : NC_ERANGE;
16229 #line 3178
16230 
16231 #line 3178
16232 #else   /* not SX */
16233 #line 3178
16234 
16235 #line 3178
16236 	char *xp = (char *) *xpp;
16237 #line 3178
16238 	int status = NC_NOERR;
16239 #line 3178
16240 
16241 #line 3178
16242 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
16243 #line 3178
16244 	{
16245 #line 3178
16246 		int lstatus = ncx_put_short_double(xp, tp, fillp);
16247 #line 3178
16248 		if (status == NC_NOERR) /* report the first encountered error */
16249 #line 3178
16250 			status = lstatus;
16251 #line 3178
16252 	}
16253 #line 3178
16254 
16255 #line 3178
16256 	*xpp = (void *)xp;
16257 #line 3178
16258 	return status;
16259 #line 3178
16260 #endif
16261 #line 3178
16262 }
16263 #line 3178
16264 
16265 int
16266 #line 3179
ncx_putn_short_longlong(void ** xpp,size_t nelems,const longlong * tp,void * fillp)16267 ncx_putn_short_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
16268 #line 3179
16269 {
16270 #line 3179
16271 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
16272 #line 3179
16273 
16274 #line 3179
16275  /* basic algorithm is:
16276 #line 3179
16277   *   - ensure sane alignment of output data
16278 #line 3179
16279   *   - copy (conversion happens automatically) input data
16280 #line 3179
16281   *     to output
16282 #line 3179
16283   *   - update tp to point at next unconverted input, and xpp to point
16284 #line 3179
16285   *     at next location for converted output
16286 #line 3179
16287   */
16288 #line 3179
16289   long i, j, ni;
16290 #line 3179
16291   short tmp[LOOPCNT];        /* in case input is misaligned */
16292 #line 3179
16293   short *xp;
16294 #line 3179
16295   int nrange = 0;         /* number of range errors */
16296 #line 3179
16297   int realign = 0;        /* "do we need to fix input data alignment?" */
16298 #line 3179
16299   long cxp = (long) *((char**)xpp);
16300 #line 3179
16301 
16302 #line 3179
16303   realign = (cxp & 7) % SIZEOF_SHORT;
16304 #line 3179
16305   /* sjl: manually stripmine so we can limit amount of
16306 #line 3179
16307    * vector work space reserved to LOOPCNT elements. Also
16308 #line 3179
16309    * makes vectorisation easy */
16310 #line 3179
16311   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
16312 #line 3179
16313     ni=Min(nelems-j,LOOPCNT);
16314 #line 3179
16315     if (realign) {
16316 #line 3179
16317       xp = tmp;
16318 #line 3179
16319     } else {
16320 #line 3179
16321       xp = (short *) *xpp;
16322 #line 3179
16323     }
16324 #line 3179
16325    /* copy the next block */
16326 #line 3179
16327 #pragma cdir loopcnt=LOOPCNT
16328 #line 3179
16329 #pragma cdir shortloop
16330 #line 3179
16331     for (i=0; i<ni; i++) {
16332 #line 3179
16333       /* the normal case: */
16334 #line 3179
16335       xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
16336 #line 3179
16337      /* test for range errors (not always needed but do it anyway) */
16338 #line 3179
16339      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
16340 #line 3179
16341      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
16342 #line 3179
16343       nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
16344 #line 3179
16345     }
16346 #line 3179
16347    /* copy workspace back if necessary */
16348 #line 3179
16349     if (realign) {
16350 #line 3179
16351       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
16352 #line 3179
16353       xp = (short *) *xpp;
16354 #line 3179
16355     }
16356 #line 3179
16357    /* update xpp and tp */
16358 #line 3179
16359     xp += ni;
16360 #line 3179
16361     tp += ni;
16362 #line 3179
16363     *xpp = (void*)xp;
16364 #line 3179
16365   }
16366 #line 3179
16367   return nrange == 0 ? NC_NOERR : NC_ERANGE;
16368 #line 3179
16369 
16370 #line 3179
16371 #else   /* not SX */
16372 #line 3179
16373 
16374 #line 3179
16375 	char *xp = (char *) *xpp;
16376 #line 3179
16377 	int status = NC_NOERR;
16378 #line 3179
16379 
16380 #line 3179
16381 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
16382 #line 3179
16383 	{
16384 #line 3179
16385 		int lstatus = ncx_put_short_longlong(xp, tp, fillp);
16386 #line 3179
16387 		if (status == NC_NOERR) /* report the first encountered error */
16388 #line 3179
16389 			status = lstatus;
16390 #line 3179
16391 	}
16392 #line 3179
16393 
16394 #line 3179
16395 	*xpp = (void *)xp;
16396 #line 3179
16397 	return status;
16398 #line 3179
16399 #endif
16400 #line 3179
16401 }
16402 #line 3179
16403 
16404 int
16405 #line 3180
ncx_putn_short_uchar(void ** xpp,size_t nelems,const uchar * tp,void * fillp)16406 ncx_putn_short_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
16407 #line 3180
16408 {
16409 #line 3180
16410 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
16411 #line 3180
16412 
16413 #line 3180
16414  /* basic algorithm is:
16415 #line 3180
16416   *   - ensure sane alignment of output data
16417 #line 3180
16418   *   - copy (conversion happens automatically) input data
16419 #line 3180
16420   *     to output
16421 #line 3180
16422   *   - update tp to point at next unconverted input, and xpp to point
16423 #line 3180
16424   *     at next location for converted output
16425 #line 3180
16426   */
16427 #line 3180
16428   long i, j, ni;
16429 #line 3180
16430   short tmp[LOOPCNT];        /* in case input is misaligned */
16431 #line 3180
16432   short *xp;
16433 #line 3180
16434   int nrange = 0;         /* number of range errors */
16435 #line 3180
16436   int realign = 0;        /* "do we need to fix input data alignment?" */
16437 #line 3180
16438   long cxp = (long) *((char**)xpp);
16439 #line 3180
16440 
16441 #line 3180
16442   realign = (cxp & 7) % SIZEOF_SHORT;
16443 #line 3180
16444   /* sjl: manually stripmine so we can limit amount of
16445 #line 3180
16446    * vector work space reserved to LOOPCNT elements. Also
16447 #line 3180
16448    * makes vectorisation easy */
16449 #line 3180
16450   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
16451 #line 3180
16452     ni=Min(nelems-j,LOOPCNT);
16453 #line 3180
16454     if (realign) {
16455 #line 3180
16456       xp = tmp;
16457 #line 3180
16458     } else {
16459 #line 3180
16460       xp = (short *) *xpp;
16461 #line 3180
16462     }
16463 #line 3180
16464    /* copy the next block */
16465 #line 3180
16466 #pragma cdir loopcnt=LOOPCNT
16467 #line 3180
16468 #pragma cdir shortloop
16469 #line 3180
16470     for (i=0; i<ni; i++) {
16471 #line 3180
16472       /* the normal case: */
16473 #line 3180
16474       xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
16475 #line 3180
16476      /* test for range errors (not always needed but do it anyway) */
16477 #line 3180
16478      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
16479 #line 3180
16480      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
16481 #line 3180
16482       nrange += tp[i] > X_SHORT_MAX ;
16483 #line 3180
16484     }
16485 #line 3180
16486    /* copy workspace back if necessary */
16487 #line 3180
16488     if (realign) {
16489 #line 3180
16490       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
16491 #line 3180
16492       xp = (short *) *xpp;
16493 #line 3180
16494     }
16495 #line 3180
16496    /* update xpp and tp */
16497 #line 3180
16498     xp += ni;
16499 #line 3180
16500     tp += ni;
16501 #line 3180
16502     *xpp = (void*)xp;
16503 #line 3180
16504   }
16505 #line 3180
16506   return nrange == 0 ? NC_NOERR : NC_ERANGE;
16507 #line 3180
16508 
16509 #line 3180
16510 #else   /* not SX */
16511 #line 3180
16512 
16513 #line 3180
16514 	char *xp = (char *) *xpp;
16515 #line 3180
16516 	int status = NC_NOERR;
16517 #line 3180
16518 
16519 #line 3180
16520 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
16521 #line 3180
16522 	{
16523 #line 3180
16524 		int lstatus = ncx_put_short_uchar(xp, tp, fillp);
16525 #line 3180
16526 		if (status == NC_NOERR) /* report the first encountered error */
16527 #line 3180
16528 			status = lstatus;
16529 #line 3180
16530 	}
16531 #line 3180
16532 
16533 #line 3180
16534 	*xpp = (void *)xp;
16535 #line 3180
16536 	return status;
16537 #line 3180
16538 #endif
16539 #line 3180
16540 }
16541 #line 3180
16542 
16543 int
16544 #line 3181
ncx_putn_short_uint(void ** xpp,size_t nelems,const uint * tp,void * fillp)16545 ncx_putn_short_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
16546 #line 3181
16547 {
16548 #line 3181
16549 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
16550 #line 3181
16551 
16552 #line 3181
16553  /* basic algorithm is:
16554 #line 3181
16555   *   - ensure sane alignment of output data
16556 #line 3181
16557   *   - copy (conversion happens automatically) input data
16558 #line 3181
16559   *     to output
16560 #line 3181
16561   *   - update tp to point at next unconverted input, and xpp to point
16562 #line 3181
16563   *     at next location for converted output
16564 #line 3181
16565   */
16566 #line 3181
16567   long i, j, ni;
16568 #line 3181
16569   short tmp[LOOPCNT];        /* in case input is misaligned */
16570 #line 3181
16571   short *xp;
16572 #line 3181
16573   int nrange = 0;         /* number of range errors */
16574 #line 3181
16575   int realign = 0;        /* "do we need to fix input data alignment?" */
16576 #line 3181
16577   long cxp = (long) *((char**)xpp);
16578 #line 3181
16579 
16580 #line 3181
16581   realign = (cxp & 7) % SIZEOF_SHORT;
16582 #line 3181
16583   /* sjl: manually stripmine so we can limit amount of
16584 #line 3181
16585    * vector work space reserved to LOOPCNT elements. Also
16586 #line 3181
16587    * makes vectorisation easy */
16588 #line 3181
16589   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
16590 #line 3181
16591     ni=Min(nelems-j,LOOPCNT);
16592 #line 3181
16593     if (realign) {
16594 #line 3181
16595       xp = tmp;
16596 #line 3181
16597     } else {
16598 #line 3181
16599       xp = (short *) *xpp;
16600 #line 3181
16601     }
16602 #line 3181
16603    /* copy the next block */
16604 #line 3181
16605 #pragma cdir loopcnt=LOOPCNT
16606 #line 3181
16607 #pragma cdir shortloop
16608 #line 3181
16609     for (i=0; i<ni; i++) {
16610 #line 3181
16611       /* the normal case: */
16612 #line 3181
16613       xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
16614 #line 3181
16615      /* test for range errors (not always needed but do it anyway) */
16616 #line 3181
16617      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
16618 #line 3181
16619      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
16620 #line 3181
16621       nrange += tp[i] > X_SHORT_MAX ;
16622 #line 3181
16623     }
16624 #line 3181
16625    /* copy workspace back if necessary */
16626 #line 3181
16627     if (realign) {
16628 #line 3181
16629       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
16630 #line 3181
16631       xp = (short *) *xpp;
16632 #line 3181
16633     }
16634 #line 3181
16635    /* update xpp and tp */
16636 #line 3181
16637     xp += ni;
16638 #line 3181
16639     tp += ni;
16640 #line 3181
16641     *xpp = (void*)xp;
16642 #line 3181
16643   }
16644 #line 3181
16645   return nrange == 0 ? NC_NOERR : NC_ERANGE;
16646 #line 3181
16647 
16648 #line 3181
16649 #else   /* not SX */
16650 #line 3181
16651 
16652 #line 3181
16653 	char *xp = (char *) *xpp;
16654 #line 3181
16655 	int status = NC_NOERR;
16656 #line 3181
16657 
16658 #line 3181
16659 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
16660 #line 3181
16661 	{
16662 #line 3181
16663 		int lstatus = ncx_put_short_uint(xp, tp, fillp);
16664 #line 3181
16665 		if (status == NC_NOERR) /* report the first encountered error */
16666 #line 3181
16667 			status = lstatus;
16668 #line 3181
16669 	}
16670 #line 3181
16671 
16672 #line 3181
16673 	*xpp = (void *)xp;
16674 #line 3181
16675 	return status;
16676 #line 3181
16677 #endif
16678 #line 3181
16679 }
16680 #line 3181
16681 
16682 int
16683 #line 3182
ncx_putn_short_ulonglong(void ** xpp,size_t nelems,const ulonglong * tp,void * fillp)16684 ncx_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
16685 #line 3182
16686 {
16687 #line 3182
16688 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
16689 #line 3182
16690 
16691 #line 3182
16692  /* basic algorithm is:
16693 #line 3182
16694   *   - ensure sane alignment of output data
16695 #line 3182
16696   *   - copy (conversion happens automatically) input data
16697 #line 3182
16698   *     to output
16699 #line 3182
16700   *   - update tp to point at next unconverted input, and xpp to point
16701 #line 3182
16702   *     at next location for converted output
16703 #line 3182
16704   */
16705 #line 3182
16706   long i, j, ni;
16707 #line 3182
16708   short tmp[LOOPCNT];        /* in case input is misaligned */
16709 #line 3182
16710   short *xp;
16711 #line 3182
16712   int nrange = 0;         /* number of range errors */
16713 #line 3182
16714   int realign = 0;        /* "do we need to fix input data alignment?" */
16715 #line 3182
16716   long cxp = (long) *((char**)xpp);
16717 #line 3182
16718 
16719 #line 3182
16720   realign = (cxp & 7) % SIZEOF_SHORT;
16721 #line 3182
16722   /* sjl: manually stripmine so we can limit amount of
16723 #line 3182
16724    * vector work space reserved to LOOPCNT elements. Also
16725 #line 3182
16726    * makes vectorisation easy */
16727 #line 3182
16728   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
16729 #line 3182
16730     ni=Min(nelems-j,LOOPCNT);
16731 #line 3182
16732     if (realign) {
16733 #line 3182
16734       xp = tmp;
16735 #line 3182
16736     } else {
16737 #line 3182
16738       xp = (short *) *xpp;
16739 #line 3182
16740     }
16741 #line 3182
16742    /* copy the next block */
16743 #line 3182
16744 #pragma cdir loopcnt=LOOPCNT
16745 #line 3182
16746 #pragma cdir shortloop
16747 #line 3182
16748     for (i=0; i<ni; i++) {
16749 #line 3182
16750       /* the normal case: */
16751 #line 3182
16752       xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
16753 #line 3182
16754      /* test for range errors (not always needed but do it anyway) */
16755 #line 3182
16756      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
16757 #line 3182
16758      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
16759 #line 3182
16760       nrange += tp[i] > X_SHORT_MAX ;
16761 #line 3182
16762     }
16763 #line 3182
16764    /* copy workspace back if necessary */
16765 #line 3182
16766     if (realign) {
16767 #line 3182
16768       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
16769 #line 3182
16770       xp = (short *) *xpp;
16771 #line 3182
16772     }
16773 #line 3182
16774    /* update xpp and tp */
16775 #line 3182
16776     xp += ni;
16777 #line 3182
16778     tp += ni;
16779 #line 3182
16780     *xpp = (void*)xp;
16781 #line 3182
16782   }
16783 #line 3182
16784   return nrange == 0 ? NC_NOERR : NC_ERANGE;
16785 #line 3182
16786 
16787 #line 3182
16788 #else   /* not SX */
16789 #line 3182
16790 
16791 #line 3182
16792 	char *xp = (char *) *xpp;
16793 #line 3182
16794 	int status = NC_NOERR;
16795 #line 3182
16796 
16797 #line 3182
16798 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
16799 #line 3182
16800 	{
16801 #line 3182
16802 		int lstatus = ncx_put_short_ulonglong(xp, tp, fillp);
16803 #line 3182
16804 		if (status == NC_NOERR) /* report the first encountered error */
16805 #line 3182
16806 			status = lstatus;
16807 #line 3182
16808 	}
16809 #line 3182
16810 
16811 #line 3182
16812 	*xpp = (void *)xp;
16813 #line 3182
16814 	return status;
16815 #line 3182
16816 #endif
16817 #line 3182
16818 }
16819 #line 3182
16820 
16821 int
16822 #line 3183
ncx_putn_short_ushort(void ** xpp,size_t nelems,const ushort * tp,void * fillp)16823 ncx_putn_short_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
16824 #line 3183
16825 {
16826 #line 3183
16827 #if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
16828 #line 3183
16829 
16830 #line 3183
16831  /* basic algorithm is:
16832 #line 3183
16833   *   - ensure sane alignment of output data
16834 #line 3183
16835   *   - copy (conversion happens automatically) input data
16836 #line 3183
16837   *     to output
16838 #line 3183
16839   *   - update tp to point at next unconverted input, and xpp to point
16840 #line 3183
16841   *     at next location for converted output
16842 #line 3183
16843   */
16844 #line 3183
16845   long i, j, ni;
16846 #line 3183
16847   short tmp[LOOPCNT];        /* in case input is misaligned */
16848 #line 3183
16849   short *xp;
16850 #line 3183
16851   int nrange = 0;         /* number of range errors */
16852 #line 3183
16853   int realign = 0;        /* "do we need to fix input data alignment?" */
16854 #line 3183
16855   long cxp = (long) *((char**)xpp);
16856 #line 3183
16857 
16858 #line 3183
16859   realign = (cxp & 7) % SIZEOF_SHORT;
16860 #line 3183
16861   /* sjl: manually stripmine so we can limit amount of
16862 #line 3183
16863    * vector work space reserved to LOOPCNT elements. Also
16864 #line 3183
16865    * makes vectorisation easy */
16866 #line 3183
16867   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
16868 #line 3183
16869     ni=Min(nelems-j,LOOPCNT);
16870 #line 3183
16871     if (realign) {
16872 #line 3183
16873       xp = tmp;
16874 #line 3183
16875     } else {
16876 #line 3183
16877       xp = (short *) *xpp;
16878 #line 3183
16879     }
16880 #line 3183
16881    /* copy the next block */
16882 #line 3183
16883 #pragma cdir loopcnt=LOOPCNT
16884 #line 3183
16885 #pragma cdir shortloop
16886 #line 3183
16887     for (i=0; i<ni; i++) {
16888 #line 3183
16889       /* the normal case: */
16890 #line 3183
16891       xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
16892 #line 3183
16893      /* test for range errors (not always needed but do it anyway) */
16894 #line 3183
16895      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
16896 #line 3183
16897      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
16898 #line 3183
16899       nrange += tp[i] > X_SHORT_MAX ;
16900 #line 3183
16901     }
16902 #line 3183
16903    /* copy workspace back if necessary */
16904 #line 3183
16905     if (realign) {
16906 #line 3183
16907       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
16908 #line 3183
16909       xp = (short *) *xpp;
16910 #line 3183
16911     }
16912 #line 3183
16913    /* update xpp and tp */
16914 #line 3183
16915     xp += ni;
16916 #line 3183
16917     tp += ni;
16918 #line 3183
16919     *xpp = (void*)xp;
16920 #line 3183
16921   }
16922 #line 3183
16923   return nrange == 0 ? NC_NOERR : NC_ERANGE;
16924 #line 3183
16925 
16926 #line 3183
16927 #else   /* not SX */
16928 #line 3183
16929 
16930 #line 3183
16931 	char *xp = (char *) *xpp;
16932 #line 3183
16933 	int status = NC_NOERR;
16934 #line 3183
16935 
16936 #line 3183
16937 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
16938 #line 3183
16939 	{
16940 #line 3183
16941 		int lstatus = ncx_put_short_ushort(xp, tp, fillp);
16942 #line 3183
16943 		if (status == NC_NOERR) /* report the first encountered error */
16944 #line 3183
16945 			status = lstatus;
16946 #line 3183
16947 	}
16948 #line 3183
16949 
16950 #line 3183
16951 	*xpp = (void *)xp;
16952 #line 3183
16953 	return status;
16954 #line 3183
16955 #endif
16956 #line 3183
16957 }
16958 #line 3183
16959 
16960 
16961 int
16962 #line 3185
ncx_pad_putn_short_schar(void ** xpp,size_t nelems,const schar * tp,void * fillp)16963 ncx_pad_putn_short_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
16964 #line 3185
16965 {
16966 #line 3185
16967 	const size_t rndup = nelems % X_SIZEOF_SHORT;
16968 #line 3185
16969 
16970 #line 3185
16971 	char *xp = (char *) *xpp;
16972 #line 3185
16973 	int status = NC_NOERR;
16974 #line 3185
16975 
16976 #line 3185
16977 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
16978 #line 3185
16979 	{
16980 #line 3185
16981 		int lstatus = ncx_put_short_schar(xp, tp, fillp);
16982 #line 3185
16983 		if (status == NC_NOERR) /* report the first encountered error */
16984 #line 3185
16985 			status = lstatus;
16986 #line 3185
16987 	}
16988 #line 3185
16989 
16990 #line 3185
16991 	if (rndup != 0)
16992 #line 3185
16993 	{
16994 #line 3185
16995 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
16996 #line 3185
16997 		xp += X_SIZEOF_SHORT;
16998 #line 3185
16999 	}
17000 #line 3185
17001 
17002 #line 3185
17003 	*xpp = (void *)xp;
17004 #line 3185
17005 	return status;
17006 #line 3185
17007 }
17008 #line 3185
17009 
17010 int
17011 #line 3186
ncx_pad_putn_short_uchar(void ** xpp,size_t nelems,const uchar * tp,void * fillp)17012 ncx_pad_putn_short_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
17013 #line 3186
17014 {
17015 #line 3186
17016 	const size_t rndup = nelems % X_SIZEOF_SHORT;
17017 #line 3186
17018 
17019 #line 3186
17020 	char *xp = (char *) *xpp;
17021 #line 3186
17022 	int status = NC_NOERR;
17023 #line 3186
17024 
17025 #line 3186
17026 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
17027 #line 3186
17028 	{
17029 #line 3186
17030 		int lstatus = ncx_put_short_uchar(xp, tp, fillp);
17031 #line 3186
17032 		if (status == NC_NOERR) /* report the first encountered error */
17033 #line 3186
17034 			status = lstatus;
17035 #line 3186
17036 	}
17037 #line 3186
17038 
17039 #line 3186
17040 	if (rndup != 0)
17041 #line 3186
17042 	{
17043 #line 3186
17044 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
17045 #line 3186
17046 		xp += X_SIZEOF_SHORT;
17047 #line 3186
17048 	}
17049 #line 3186
17050 
17051 #line 3186
17052 	*xpp = (void *)xp;
17053 #line 3186
17054 	return status;
17055 #line 3186
17056 }
17057 #line 3186
17058 
17059 int
17060 #line 3187
ncx_pad_putn_short_short(void ** xpp,size_t nelems,const short * tp,void * fillp)17061 ncx_pad_putn_short_short(void **xpp, size_t nelems, const short *tp, void *fillp)
17062 #line 3187
17063 {
17064 #line 3187
17065 	const size_t rndup = nelems % X_SIZEOF_SHORT;
17066 #line 3187
17067 
17068 #line 3187
17069 	char *xp = (char *) *xpp;
17070 #line 3187
17071 	int status = NC_NOERR;
17072 #line 3187
17073 
17074 #line 3187
17075 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
17076 #line 3187
17077 	{
17078 #line 3187
17079 		int lstatus = ncx_put_short_short(xp, tp, fillp);
17080 #line 3187
17081 		if (status == NC_NOERR) /* report the first encountered error */
17082 #line 3187
17083 			status = lstatus;
17084 #line 3187
17085 	}
17086 #line 3187
17087 
17088 #line 3187
17089 	if (rndup != 0)
17090 #line 3187
17091 	{
17092 #line 3187
17093 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
17094 #line 3187
17095 		xp += X_SIZEOF_SHORT;
17096 #line 3187
17097 	}
17098 #line 3187
17099 
17100 #line 3187
17101 	*xpp = (void *)xp;
17102 #line 3187
17103 	return status;
17104 #line 3187
17105 }
17106 #line 3187
17107 
17108 int
17109 #line 3188
ncx_pad_putn_short_int(void ** xpp,size_t nelems,const int * tp,void * fillp)17110 ncx_pad_putn_short_int(void **xpp, size_t nelems, const int *tp, void *fillp)
17111 #line 3188
17112 {
17113 #line 3188
17114 	const size_t rndup = nelems % X_SIZEOF_SHORT;
17115 #line 3188
17116 
17117 #line 3188
17118 	char *xp = (char *) *xpp;
17119 #line 3188
17120 	int status = NC_NOERR;
17121 #line 3188
17122 
17123 #line 3188
17124 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
17125 #line 3188
17126 	{
17127 #line 3188
17128 		int lstatus = ncx_put_short_int(xp, tp, fillp);
17129 #line 3188
17130 		if (status == NC_NOERR) /* report the first encountered error */
17131 #line 3188
17132 			status = lstatus;
17133 #line 3188
17134 	}
17135 #line 3188
17136 
17137 #line 3188
17138 	if (rndup != 0)
17139 #line 3188
17140 	{
17141 #line 3188
17142 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
17143 #line 3188
17144 		xp += X_SIZEOF_SHORT;
17145 #line 3188
17146 	}
17147 #line 3188
17148 
17149 #line 3188
17150 	*xpp = (void *)xp;
17151 #line 3188
17152 	return status;
17153 #line 3188
17154 }
17155 #line 3188
17156 
17157 int
17158 #line 3189
ncx_pad_putn_short_long(void ** xpp,size_t nelems,const long * tp,void * fillp)17159 ncx_pad_putn_short_long(void **xpp, size_t nelems, const long *tp, void *fillp)
17160 #line 3189
17161 {
17162 #line 3189
17163 	const size_t rndup = nelems % X_SIZEOF_SHORT;
17164 #line 3189
17165 
17166 #line 3189
17167 	char *xp = (char *) *xpp;
17168 #line 3189
17169 	int status = NC_NOERR;
17170 #line 3189
17171 
17172 #line 3189
17173 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
17174 #line 3189
17175 	{
17176 #line 3189
17177 		int lstatus = ncx_put_short_long(xp, tp, fillp);
17178 #line 3189
17179 		if (status == NC_NOERR) /* report the first encountered error */
17180 #line 3189
17181 			status = lstatus;
17182 #line 3189
17183 	}
17184 #line 3189
17185 
17186 #line 3189
17187 	if (rndup != 0)
17188 #line 3189
17189 	{
17190 #line 3189
17191 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
17192 #line 3189
17193 		xp += X_SIZEOF_SHORT;
17194 #line 3189
17195 	}
17196 #line 3189
17197 
17198 #line 3189
17199 	*xpp = (void *)xp;
17200 #line 3189
17201 	return status;
17202 #line 3189
17203 }
17204 #line 3189
17205 
17206 int
17207 #line 3190
ncx_pad_putn_short_float(void ** xpp,size_t nelems,const float * tp,void * fillp)17208 ncx_pad_putn_short_float(void **xpp, size_t nelems, const float *tp, void *fillp)
17209 #line 3190
17210 {
17211 #line 3190
17212 	const size_t rndup = nelems % X_SIZEOF_SHORT;
17213 #line 3190
17214 
17215 #line 3190
17216 	char *xp = (char *) *xpp;
17217 #line 3190
17218 	int status = NC_NOERR;
17219 #line 3190
17220 
17221 #line 3190
17222 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
17223 #line 3190
17224 	{
17225 #line 3190
17226 		int lstatus = ncx_put_short_float(xp, tp, fillp);
17227 #line 3190
17228 		if (status == NC_NOERR) /* report the first encountered error */
17229 #line 3190
17230 			status = lstatus;
17231 #line 3190
17232 	}
17233 #line 3190
17234 
17235 #line 3190
17236 	if (rndup != 0)
17237 #line 3190
17238 	{
17239 #line 3190
17240 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
17241 #line 3190
17242 		xp += X_SIZEOF_SHORT;
17243 #line 3190
17244 	}
17245 #line 3190
17246 
17247 #line 3190
17248 	*xpp = (void *)xp;
17249 #line 3190
17250 	return status;
17251 #line 3190
17252 }
17253 #line 3190
17254 
17255 int
17256 #line 3191
ncx_pad_putn_short_double(void ** xpp,size_t nelems,const double * tp,void * fillp)17257 ncx_pad_putn_short_double(void **xpp, size_t nelems, const double *tp, void *fillp)
17258 #line 3191
17259 {
17260 #line 3191
17261 	const size_t rndup = nelems % X_SIZEOF_SHORT;
17262 #line 3191
17263 
17264 #line 3191
17265 	char *xp = (char *) *xpp;
17266 #line 3191
17267 	int status = NC_NOERR;
17268 #line 3191
17269 
17270 #line 3191
17271 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
17272 #line 3191
17273 	{
17274 #line 3191
17275 		int lstatus = ncx_put_short_double(xp, tp, fillp);
17276 #line 3191
17277 		if (status == NC_NOERR) /* report the first encountered error */
17278 #line 3191
17279 			status = lstatus;
17280 #line 3191
17281 	}
17282 #line 3191
17283 
17284 #line 3191
17285 	if (rndup != 0)
17286 #line 3191
17287 	{
17288 #line 3191
17289 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
17290 #line 3191
17291 		xp += X_SIZEOF_SHORT;
17292 #line 3191
17293 	}
17294 #line 3191
17295 
17296 #line 3191
17297 	*xpp = (void *)xp;
17298 #line 3191
17299 	return status;
17300 #line 3191
17301 }
17302 #line 3191
17303 
17304 int
17305 #line 3192
ncx_pad_putn_short_uint(void ** xpp,size_t nelems,const uint * tp,void * fillp)17306 ncx_pad_putn_short_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
17307 #line 3192
17308 {
17309 #line 3192
17310 	const size_t rndup = nelems % X_SIZEOF_SHORT;
17311 #line 3192
17312 
17313 #line 3192
17314 	char *xp = (char *) *xpp;
17315 #line 3192
17316 	int status = NC_NOERR;
17317 #line 3192
17318 
17319 #line 3192
17320 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
17321 #line 3192
17322 	{
17323 #line 3192
17324 		int lstatus = ncx_put_short_uint(xp, tp, fillp);
17325 #line 3192
17326 		if (status == NC_NOERR) /* report the first encountered error */
17327 #line 3192
17328 			status = lstatus;
17329 #line 3192
17330 	}
17331 #line 3192
17332 
17333 #line 3192
17334 	if (rndup != 0)
17335 #line 3192
17336 	{
17337 #line 3192
17338 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
17339 #line 3192
17340 		xp += X_SIZEOF_SHORT;
17341 #line 3192
17342 	}
17343 #line 3192
17344 
17345 #line 3192
17346 	*xpp = (void *)xp;
17347 #line 3192
17348 	return status;
17349 #line 3192
17350 }
17351 #line 3192
17352 
17353 int
17354 #line 3193
ncx_pad_putn_short_longlong(void ** xpp,size_t nelems,const longlong * tp,void * fillp)17355 ncx_pad_putn_short_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
17356 #line 3193
17357 {
17358 #line 3193
17359 	const size_t rndup = nelems % X_SIZEOF_SHORT;
17360 #line 3193
17361 
17362 #line 3193
17363 	char *xp = (char *) *xpp;
17364 #line 3193
17365 	int status = NC_NOERR;
17366 #line 3193
17367 
17368 #line 3193
17369 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
17370 #line 3193
17371 	{
17372 #line 3193
17373 		int lstatus = ncx_put_short_longlong(xp, tp, fillp);
17374 #line 3193
17375 		if (status == NC_NOERR) /* report the first encountered error */
17376 #line 3193
17377 			status = lstatus;
17378 #line 3193
17379 	}
17380 #line 3193
17381 
17382 #line 3193
17383 	if (rndup != 0)
17384 #line 3193
17385 	{
17386 #line 3193
17387 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
17388 #line 3193
17389 		xp += X_SIZEOF_SHORT;
17390 #line 3193
17391 	}
17392 #line 3193
17393 
17394 #line 3193
17395 	*xpp = (void *)xp;
17396 #line 3193
17397 	return status;
17398 #line 3193
17399 }
17400 #line 3193
17401 
17402 int
17403 #line 3194
ncx_pad_putn_short_ulonglong(void ** xpp,size_t nelems,const ulonglong * tp,void * fillp)17404 ncx_pad_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
17405 #line 3194
17406 {
17407 #line 3194
17408 	const size_t rndup = nelems % X_SIZEOF_SHORT;
17409 #line 3194
17410 
17411 #line 3194
17412 	char *xp = (char *) *xpp;
17413 #line 3194
17414 	int status = NC_NOERR;
17415 #line 3194
17416 
17417 #line 3194
17418 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
17419 #line 3194
17420 	{
17421 #line 3194
17422 		int lstatus = ncx_put_short_ulonglong(xp, tp, fillp);
17423 #line 3194
17424 		if (status == NC_NOERR) /* report the first encountered error */
17425 #line 3194
17426 			status = lstatus;
17427 #line 3194
17428 	}
17429 #line 3194
17430 
17431 #line 3194
17432 	if (rndup != 0)
17433 #line 3194
17434 	{
17435 #line 3194
17436 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
17437 #line 3194
17438 		xp += X_SIZEOF_SHORT;
17439 #line 3194
17440 	}
17441 #line 3194
17442 
17443 #line 3194
17444 	*xpp = (void *)xp;
17445 #line 3194
17446 	return status;
17447 #line 3194
17448 }
17449 #line 3194
17450 
17451 int
17452 #line 3195
ncx_pad_putn_short_ushort(void ** xpp,size_t nelems,const ushort * tp,void * fillp)17453 ncx_pad_putn_short_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
17454 #line 3195
17455 {
17456 #line 3195
17457 	const size_t rndup = nelems % X_SIZEOF_SHORT;
17458 #line 3195
17459 
17460 #line 3195
17461 	char *xp = (char *) *xpp;
17462 #line 3195
17463 	int status = NC_NOERR;
17464 #line 3195
17465 
17466 #line 3195
17467 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
17468 #line 3195
17469 	{
17470 #line 3195
17471 		int lstatus = ncx_put_short_ushort(xp, tp, fillp);
17472 #line 3195
17473 		if (status == NC_NOERR) /* report the first encountered error */
17474 #line 3195
17475 			status = lstatus;
17476 #line 3195
17477 	}
17478 #line 3195
17479 
17480 #line 3195
17481 	if (rndup != 0)
17482 #line 3195
17483 	{
17484 #line 3195
17485 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
17486 #line 3195
17487 		xp += X_SIZEOF_SHORT;
17488 #line 3195
17489 	}
17490 #line 3195
17491 
17492 #line 3195
17493 	*xpp = (void *)xp;
17494 #line 3195
17495 	return status;
17496 #line 3195
17497 }
17498 #line 3195
17499 
17500 
17501 
17502 /* ushort --------------------------------------------------------------------*/
17503 
17504 #if X_SIZEOF_USHORT == SIZEOF_USHORT
17505 /* optimized version */
17506 int
ncx_getn_ushort_ushort(const void ** xpp,size_t nelems,unsigned short * tp)17507 ncx_getn_ushort_ushort(const void **xpp, size_t nelems, unsigned short *tp)
17508 {
17509 #ifdef WORDS_BIGENDIAN
17510 	(void) memcpy(tp, *xpp, (size_t)nelems * SIZEOF_USHORT);
17511 # else
17512 	swapn2b(tp, *xpp, nelems);
17513 # endif
17514 	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_USHORT);
17515 	return NC_NOERR;
17516 }
17517 #else
17518 int
17519 #line 3214
ncx_getn_ushort_ushort(const void ** xpp,size_t nelems,ushort * tp)17520 ncx_getn_ushort_ushort(const void **xpp, size_t nelems, ushort *tp)
17521 #line 3214
17522 {
17523 #line 3214
17524 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
17525 #line 3214
17526 
17527 #line 3214
17528  /* basic algorithm is:
17529 #line 3214
17530   *   - ensure sane alignment of input data
17531 #line 3214
17532   *   - copy (conversion happens automatically) input data
17533 #line 3214
17534   *     to output
17535 #line 3214
17536   *   - update xpp to point at next unconverted input, and tp to point
17537 #line 3214
17538   *     at next location for converted output
17539 #line 3214
17540   */
17541 #line 3214
17542   long i, j, ni;
17543 #line 3214
17544   ushort tmp[LOOPCNT];        /* in case input is misaligned */
17545 #line 3214
17546   ushort *xp;
17547 #line 3214
17548   int nrange = 0;         /* number of range errors */
17549 #line 3214
17550   int realign = 0;        /* "do we need to fix input data alignment?" */
17551 #line 3214
17552   long cxp = (long) *((char**)xpp);
17553 #line 3214
17554 
17555 #line 3214
17556   realign = (cxp & 7) % SIZEOF_USHORT;
17557 #line 3214
17558   /* sjl: manually stripmine so we can limit amount of
17559 #line 3214
17560    * vector work space reserved to LOOPCNT elements. Also
17561 #line 3214
17562    * makes vectorisation easy */
17563 #line 3214
17564   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
17565 #line 3214
17566     ni=Min(nelems-j,LOOPCNT);
17567 #line 3214
17568     if (realign) {
17569 #line 3214
17570       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
17571 #line 3214
17572       xp = tmp;
17573 #line 3214
17574     } else {
17575 #line 3214
17576       xp = (ushort *) *xpp;
17577 #line 3214
17578     }
17579 #line 3214
17580    /* copy the next block */
17581 #line 3214
17582 #pragma cdir loopcnt=LOOPCNT
17583 #line 3214
17584 #pragma cdir shortloop
17585 #line 3214
17586     for (i=0; i<ni; i++) {
17587 #line 3214
17588       tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
17589 #line 3214
17590      /* test for range errors (not always needed but do it anyway) */
17591 #line 3214
17592      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
17593 #line 3214
17594      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
17595 #line 3214
17596       nrange += xp[i] > USHORT_MAX ;
17597 #line 3214
17598     }
17599 #line 3214
17600    /* update xpp and tp */
17601 #line 3214
17602     if (realign) xp = (ushort *) *xpp;
17603 #line 3214
17604     xp += ni;
17605 #line 3214
17606     tp += ni;
17607 #line 3214
17608     *xpp = (void*)xp;
17609 #line 3214
17610   }
17611 #line 3214
17612   return nrange == 0 ? NC_NOERR : NC_ERANGE;
17613 #line 3214
17614 
17615 #line 3214
17616 #else   /* not SX */
17617 #line 3214
17618 	const char *xp = (const char *) *xpp;
17619 #line 3214
17620 	int status = NC_NOERR;
17621 #line 3214
17622 
17623 #line 3214
17624 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
17625 #line 3214
17626 	{
17627 #line 3214
17628 		const int lstatus = ncx_get_ushort_ushort(xp, tp);
17629 #line 3214
17630 		if (status == NC_NOERR) /* report the first encountered error */
17631 #line 3214
17632 			status = lstatus;
17633 #line 3214
17634 	}
17635 #line 3214
17636 
17637 #line 3214
17638 	*xpp = (const void *)xp;
17639 #line 3214
17640 	return status;
17641 #line 3214
17642 #endif
17643 #line 3214
17644 }
17645 #line 3214
17646 
17647 #endif
17648 int
17649 #line 3216
ncx_getn_ushort_schar(const void ** xpp,size_t nelems,schar * tp)17650 ncx_getn_ushort_schar(const void **xpp, size_t nelems, schar *tp)
17651 #line 3216
17652 {
17653 #line 3216
17654 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
17655 #line 3216
17656 
17657 #line 3216
17658  /* basic algorithm is:
17659 #line 3216
17660   *   - ensure sane alignment of input data
17661 #line 3216
17662   *   - copy (conversion happens automatically) input data
17663 #line 3216
17664   *     to output
17665 #line 3216
17666   *   - update xpp to point at next unconverted input, and tp to point
17667 #line 3216
17668   *     at next location for converted output
17669 #line 3216
17670   */
17671 #line 3216
17672   long i, j, ni;
17673 #line 3216
17674   ushort tmp[LOOPCNT];        /* in case input is misaligned */
17675 #line 3216
17676   ushort *xp;
17677 #line 3216
17678   int nrange = 0;         /* number of range errors */
17679 #line 3216
17680   int realign = 0;        /* "do we need to fix input data alignment?" */
17681 #line 3216
17682   long cxp = (long) *((char**)xpp);
17683 #line 3216
17684 
17685 #line 3216
17686   realign = (cxp & 7) % SIZEOF_USHORT;
17687 #line 3216
17688   /* sjl: manually stripmine so we can limit amount of
17689 #line 3216
17690    * vector work space reserved to LOOPCNT elements. Also
17691 #line 3216
17692    * makes vectorisation easy */
17693 #line 3216
17694   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
17695 #line 3216
17696     ni=Min(nelems-j,LOOPCNT);
17697 #line 3216
17698     if (realign) {
17699 #line 3216
17700       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
17701 #line 3216
17702       xp = tmp;
17703 #line 3216
17704     } else {
17705 #line 3216
17706       xp = (ushort *) *xpp;
17707 #line 3216
17708     }
17709 #line 3216
17710    /* copy the next block */
17711 #line 3216
17712 #pragma cdir loopcnt=LOOPCNT
17713 #line 3216
17714 #pragma cdir shortloop
17715 #line 3216
17716     for (i=0; i<ni; i++) {
17717 #line 3216
17718       tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
17719 #line 3216
17720      /* test for range errors (not always needed but do it anyway) */
17721 #line 3216
17722      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
17723 #line 3216
17724      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
17725 #line 3216
17726       nrange += xp[i] > SCHAR_MAX ;
17727 #line 3216
17728     }
17729 #line 3216
17730    /* update xpp and tp */
17731 #line 3216
17732     if (realign) xp = (ushort *) *xpp;
17733 #line 3216
17734     xp += ni;
17735 #line 3216
17736     tp += ni;
17737 #line 3216
17738     *xpp = (void*)xp;
17739 #line 3216
17740   }
17741 #line 3216
17742   return nrange == 0 ? NC_NOERR : NC_ERANGE;
17743 #line 3216
17744 
17745 #line 3216
17746 #else   /* not SX */
17747 #line 3216
17748 	const char *xp = (const char *) *xpp;
17749 #line 3216
17750 	int status = NC_NOERR;
17751 #line 3216
17752 
17753 #line 3216
17754 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
17755 #line 3216
17756 	{
17757 #line 3216
17758 		const int lstatus = ncx_get_ushort_schar(xp, tp);
17759 #line 3216
17760 		if (status == NC_NOERR) /* report the first encountered error */
17761 #line 3216
17762 			status = lstatus;
17763 #line 3216
17764 	}
17765 #line 3216
17766 
17767 #line 3216
17768 	*xpp = (const void *)xp;
17769 #line 3216
17770 	return status;
17771 #line 3216
17772 #endif
17773 #line 3216
17774 }
17775 #line 3216
17776 
17777 int
17778 #line 3217
ncx_getn_ushort_short(const void ** xpp,size_t nelems,short * tp)17779 ncx_getn_ushort_short(const void **xpp, size_t nelems, short *tp)
17780 #line 3217
17781 {
17782 #line 3217
17783 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
17784 #line 3217
17785 
17786 #line 3217
17787  /* basic algorithm is:
17788 #line 3217
17789   *   - ensure sane alignment of input data
17790 #line 3217
17791   *   - copy (conversion happens automatically) input data
17792 #line 3217
17793   *     to output
17794 #line 3217
17795   *   - update xpp to point at next unconverted input, and tp to point
17796 #line 3217
17797   *     at next location for converted output
17798 #line 3217
17799   */
17800 #line 3217
17801   long i, j, ni;
17802 #line 3217
17803   ushort tmp[LOOPCNT];        /* in case input is misaligned */
17804 #line 3217
17805   ushort *xp;
17806 #line 3217
17807   int nrange = 0;         /* number of range errors */
17808 #line 3217
17809   int realign = 0;        /* "do we need to fix input data alignment?" */
17810 #line 3217
17811   long cxp = (long) *((char**)xpp);
17812 #line 3217
17813 
17814 #line 3217
17815   realign = (cxp & 7) % SIZEOF_USHORT;
17816 #line 3217
17817   /* sjl: manually stripmine so we can limit amount of
17818 #line 3217
17819    * vector work space reserved to LOOPCNT elements. Also
17820 #line 3217
17821    * makes vectorisation easy */
17822 #line 3217
17823   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
17824 #line 3217
17825     ni=Min(nelems-j,LOOPCNT);
17826 #line 3217
17827     if (realign) {
17828 #line 3217
17829       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
17830 #line 3217
17831       xp = tmp;
17832 #line 3217
17833     } else {
17834 #line 3217
17835       xp = (ushort *) *xpp;
17836 #line 3217
17837     }
17838 #line 3217
17839    /* copy the next block */
17840 #line 3217
17841 #pragma cdir loopcnt=LOOPCNT
17842 #line 3217
17843 #pragma cdir shortloop
17844 #line 3217
17845     for (i=0; i<ni; i++) {
17846 #line 3217
17847       tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
17848 #line 3217
17849      /* test for range errors (not always needed but do it anyway) */
17850 #line 3217
17851      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
17852 #line 3217
17853      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
17854 #line 3217
17855       nrange += xp[i] > SHORT_MAX ;
17856 #line 3217
17857     }
17858 #line 3217
17859    /* update xpp and tp */
17860 #line 3217
17861     if (realign) xp = (ushort *) *xpp;
17862 #line 3217
17863     xp += ni;
17864 #line 3217
17865     tp += ni;
17866 #line 3217
17867     *xpp = (void*)xp;
17868 #line 3217
17869   }
17870 #line 3217
17871   return nrange == 0 ? NC_NOERR : NC_ERANGE;
17872 #line 3217
17873 
17874 #line 3217
17875 #else   /* not SX */
17876 #line 3217
17877 	const char *xp = (const char *) *xpp;
17878 #line 3217
17879 	int status = NC_NOERR;
17880 #line 3217
17881 
17882 #line 3217
17883 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
17884 #line 3217
17885 	{
17886 #line 3217
17887 		const int lstatus = ncx_get_ushort_short(xp, tp);
17888 #line 3217
17889 		if (status == NC_NOERR) /* report the first encountered error */
17890 #line 3217
17891 			status = lstatus;
17892 #line 3217
17893 	}
17894 #line 3217
17895 
17896 #line 3217
17897 	*xpp = (const void *)xp;
17898 #line 3217
17899 	return status;
17900 #line 3217
17901 #endif
17902 #line 3217
17903 }
17904 #line 3217
17905 
17906 int
17907 #line 3218
ncx_getn_ushort_int(const void ** xpp,size_t nelems,int * tp)17908 ncx_getn_ushort_int(const void **xpp, size_t nelems, int *tp)
17909 #line 3218
17910 {
17911 #line 3218
17912 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
17913 #line 3218
17914 
17915 #line 3218
17916  /* basic algorithm is:
17917 #line 3218
17918   *   - ensure sane alignment of input data
17919 #line 3218
17920   *   - copy (conversion happens automatically) input data
17921 #line 3218
17922   *     to output
17923 #line 3218
17924   *   - update xpp to point at next unconverted input, and tp to point
17925 #line 3218
17926   *     at next location for converted output
17927 #line 3218
17928   */
17929 #line 3218
17930   long i, j, ni;
17931 #line 3218
17932   ushort tmp[LOOPCNT];        /* in case input is misaligned */
17933 #line 3218
17934   ushort *xp;
17935 #line 3218
17936   int nrange = 0;         /* number of range errors */
17937 #line 3218
17938   int realign = 0;        /* "do we need to fix input data alignment?" */
17939 #line 3218
17940   long cxp = (long) *((char**)xpp);
17941 #line 3218
17942 
17943 #line 3218
17944   realign = (cxp & 7) % SIZEOF_USHORT;
17945 #line 3218
17946   /* sjl: manually stripmine so we can limit amount of
17947 #line 3218
17948    * vector work space reserved to LOOPCNT elements. Also
17949 #line 3218
17950    * makes vectorisation easy */
17951 #line 3218
17952   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
17953 #line 3218
17954     ni=Min(nelems-j,LOOPCNT);
17955 #line 3218
17956     if (realign) {
17957 #line 3218
17958       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
17959 #line 3218
17960       xp = tmp;
17961 #line 3218
17962     } else {
17963 #line 3218
17964       xp = (ushort *) *xpp;
17965 #line 3218
17966     }
17967 #line 3218
17968    /* copy the next block */
17969 #line 3218
17970 #pragma cdir loopcnt=LOOPCNT
17971 #line 3218
17972 #pragma cdir shortloop
17973 #line 3218
17974     for (i=0; i<ni; i++) {
17975 #line 3218
17976       tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
17977 #line 3218
17978      /* test for range errors (not always needed but do it anyway) */
17979 #line 3218
17980      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
17981 #line 3218
17982      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
17983 #line 3218
17984       nrange += xp[i] > INT_MAX ;
17985 #line 3218
17986     }
17987 #line 3218
17988    /* update xpp and tp */
17989 #line 3218
17990     if (realign) xp = (ushort *) *xpp;
17991 #line 3218
17992     xp += ni;
17993 #line 3218
17994     tp += ni;
17995 #line 3218
17996     *xpp = (void*)xp;
17997 #line 3218
17998   }
17999 #line 3218
18000   return nrange == 0 ? NC_NOERR : NC_ERANGE;
18001 #line 3218
18002 
18003 #line 3218
18004 #else   /* not SX */
18005 #line 3218
18006 	const char *xp = (const char *) *xpp;
18007 #line 3218
18008 	int status = NC_NOERR;
18009 #line 3218
18010 
18011 #line 3218
18012 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
18013 #line 3218
18014 	{
18015 #line 3218
18016 		const int lstatus = ncx_get_ushort_int(xp, tp);
18017 #line 3218
18018 		if (status == NC_NOERR) /* report the first encountered error */
18019 #line 3218
18020 			status = lstatus;
18021 #line 3218
18022 	}
18023 #line 3218
18024 
18025 #line 3218
18026 	*xpp = (const void *)xp;
18027 #line 3218
18028 	return status;
18029 #line 3218
18030 #endif
18031 #line 3218
18032 }
18033 #line 3218
18034 
18035 int
18036 #line 3219
ncx_getn_ushort_long(const void ** xpp,size_t nelems,long * tp)18037 ncx_getn_ushort_long(const void **xpp, size_t nelems, long *tp)
18038 #line 3219
18039 {
18040 #line 3219
18041 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
18042 #line 3219
18043 
18044 #line 3219
18045  /* basic algorithm is:
18046 #line 3219
18047   *   - ensure sane alignment of input data
18048 #line 3219
18049   *   - copy (conversion happens automatically) input data
18050 #line 3219
18051   *     to output
18052 #line 3219
18053   *   - update xpp to point at next unconverted input, and tp to point
18054 #line 3219
18055   *     at next location for converted output
18056 #line 3219
18057   */
18058 #line 3219
18059   long i, j, ni;
18060 #line 3219
18061   ushort tmp[LOOPCNT];        /* in case input is misaligned */
18062 #line 3219
18063   ushort *xp;
18064 #line 3219
18065   int nrange = 0;         /* number of range errors */
18066 #line 3219
18067   int realign = 0;        /* "do we need to fix input data alignment?" */
18068 #line 3219
18069   long cxp = (long) *((char**)xpp);
18070 #line 3219
18071 
18072 #line 3219
18073   realign = (cxp & 7) % SIZEOF_USHORT;
18074 #line 3219
18075   /* sjl: manually stripmine so we can limit amount of
18076 #line 3219
18077    * vector work space reserved to LOOPCNT elements. Also
18078 #line 3219
18079    * makes vectorisation easy */
18080 #line 3219
18081   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
18082 #line 3219
18083     ni=Min(nelems-j,LOOPCNT);
18084 #line 3219
18085     if (realign) {
18086 #line 3219
18087       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
18088 #line 3219
18089       xp = tmp;
18090 #line 3219
18091     } else {
18092 #line 3219
18093       xp = (ushort *) *xpp;
18094 #line 3219
18095     }
18096 #line 3219
18097    /* copy the next block */
18098 #line 3219
18099 #pragma cdir loopcnt=LOOPCNT
18100 #line 3219
18101 #pragma cdir shortloop
18102 #line 3219
18103     for (i=0; i<ni; i++) {
18104 #line 3219
18105       tp[i] = (long) Max( LONG_MIN, Min(LONG_MAX, (long) xp[i]));
18106 #line 3219
18107      /* test for range errors (not always needed but do it anyway) */
18108 #line 3219
18109      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
18110 #line 3219
18111      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
18112 #line 3219
18113       nrange += xp[i] > LONG_MAX ;
18114 #line 3219
18115     }
18116 #line 3219
18117    /* update xpp and tp */
18118 #line 3219
18119     if (realign) xp = (ushort *) *xpp;
18120 #line 3219
18121     xp += ni;
18122 #line 3219
18123     tp += ni;
18124 #line 3219
18125     *xpp = (void*)xp;
18126 #line 3219
18127   }
18128 #line 3219
18129   return nrange == 0 ? NC_NOERR : NC_ERANGE;
18130 #line 3219
18131 
18132 #line 3219
18133 #else   /* not SX */
18134 #line 3219
18135 	const char *xp = (const char *) *xpp;
18136 #line 3219
18137 	int status = NC_NOERR;
18138 #line 3219
18139 
18140 #line 3219
18141 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
18142 #line 3219
18143 	{
18144 #line 3219
18145 		const int lstatus = ncx_get_ushort_long(xp, tp);
18146 #line 3219
18147 		if (status == NC_NOERR) /* report the first encountered error */
18148 #line 3219
18149 			status = lstatus;
18150 #line 3219
18151 	}
18152 #line 3219
18153 
18154 #line 3219
18155 	*xpp = (const void *)xp;
18156 #line 3219
18157 	return status;
18158 #line 3219
18159 #endif
18160 #line 3219
18161 }
18162 #line 3219
18163 
18164 int
18165 #line 3220
ncx_getn_ushort_float(const void ** xpp,size_t nelems,float * tp)18166 ncx_getn_ushort_float(const void **xpp, size_t nelems, float *tp)
18167 #line 3220
18168 {
18169 #line 3220
18170 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
18171 #line 3220
18172 
18173 #line 3220
18174  /* basic algorithm is:
18175 #line 3220
18176   *   - ensure sane alignment of input data
18177 #line 3220
18178   *   - copy (conversion happens automatically) input data
18179 #line 3220
18180   *     to output
18181 #line 3220
18182   *   - update xpp to point at next unconverted input, and tp to point
18183 #line 3220
18184   *     at next location for converted output
18185 #line 3220
18186   */
18187 #line 3220
18188   long i, j, ni;
18189 #line 3220
18190   ushort tmp[LOOPCNT];        /* in case input is misaligned */
18191 #line 3220
18192   ushort *xp;
18193 #line 3220
18194   int nrange = 0;         /* number of range errors */
18195 #line 3220
18196   int realign = 0;        /* "do we need to fix input data alignment?" */
18197 #line 3220
18198   long cxp = (long) *((char**)xpp);
18199 #line 3220
18200 
18201 #line 3220
18202   realign = (cxp & 7) % SIZEOF_USHORT;
18203 #line 3220
18204   /* sjl: manually stripmine so we can limit amount of
18205 #line 3220
18206    * vector work space reserved to LOOPCNT elements. Also
18207 #line 3220
18208    * makes vectorisation easy */
18209 #line 3220
18210   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
18211 #line 3220
18212     ni=Min(nelems-j,LOOPCNT);
18213 #line 3220
18214     if (realign) {
18215 #line 3220
18216       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
18217 #line 3220
18218       xp = tmp;
18219 #line 3220
18220     } else {
18221 #line 3220
18222       xp = (ushort *) *xpp;
18223 #line 3220
18224     }
18225 #line 3220
18226    /* copy the next block */
18227 #line 3220
18228 #pragma cdir loopcnt=LOOPCNT
18229 #line 3220
18230 #pragma cdir shortloop
18231 #line 3220
18232     for (i=0; i<ni; i++) {
18233 #line 3220
18234       tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
18235 #line 3220
18236      /* test for range errors (not always needed but do it anyway) */
18237 #line 3220
18238      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
18239 #line 3220
18240      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
18241 #line 3220
18242       nrange += xp[i] > FLOAT_MAX ;
18243 #line 3220
18244     }
18245 #line 3220
18246    /* update xpp and tp */
18247 #line 3220
18248     if (realign) xp = (ushort *) *xpp;
18249 #line 3220
18250     xp += ni;
18251 #line 3220
18252     tp += ni;
18253 #line 3220
18254     *xpp = (void*)xp;
18255 #line 3220
18256   }
18257 #line 3220
18258   return nrange == 0 ? NC_NOERR : NC_ERANGE;
18259 #line 3220
18260 
18261 #line 3220
18262 #else   /* not SX */
18263 #line 3220
18264 	const char *xp = (const char *) *xpp;
18265 #line 3220
18266 	int status = NC_NOERR;
18267 #line 3220
18268 
18269 #line 3220
18270 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
18271 #line 3220
18272 	{
18273 #line 3220
18274 		const int lstatus = ncx_get_ushort_float(xp, tp);
18275 #line 3220
18276 		if (status == NC_NOERR) /* report the first encountered error */
18277 #line 3220
18278 			status = lstatus;
18279 #line 3220
18280 	}
18281 #line 3220
18282 
18283 #line 3220
18284 	*xpp = (const void *)xp;
18285 #line 3220
18286 	return status;
18287 #line 3220
18288 #endif
18289 #line 3220
18290 }
18291 #line 3220
18292 
18293 int
18294 #line 3221
ncx_getn_ushort_double(const void ** xpp,size_t nelems,double * tp)18295 ncx_getn_ushort_double(const void **xpp, size_t nelems, double *tp)
18296 #line 3221
18297 {
18298 #line 3221
18299 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
18300 #line 3221
18301 
18302 #line 3221
18303  /* basic algorithm is:
18304 #line 3221
18305   *   - ensure sane alignment of input data
18306 #line 3221
18307   *   - copy (conversion happens automatically) input data
18308 #line 3221
18309   *     to output
18310 #line 3221
18311   *   - update xpp to point at next unconverted input, and tp to point
18312 #line 3221
18313   *     at next location for converted output
18314 #line 3221
18315   */
18316 #line 3221
18317   long i, j, ni;
18318 #line 3221
18319   ushort tmp[LOOPCNT];        /* in case input is misaligned */
18320 #line 3221
18321   ushort *xp;
18322 #line 3221
18323   int nrange = 0;         /* number of range errors */
18324 #line 3221
18325   int realign = 0;        /* "do we need to fix input data alignment?" */
18326 #line 3221
18327   long cxp = (long) *((char**)xpp);
18328 #line 3221
18329 
18330 #line 3221
18331   realign = (cxp & 7) % SIZEOF_USHORT;
18332 #line 3221
18333   /* sjl: manually stripmine so we can limit amount of
18334 #line 3221
18335    * vector work space reserved to LOOPCNT elements. Also
18336 #line 3221
18337    * makes vectorisation easy */
18338 #line 3221
18339   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
18340 #line 3221
18341     ni=Min(nelems-j,LOOPCNT);
18342 #line 3221
18343     if (realign) {
18344 #line 3221
18345       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
18346 #line 3221
18347       xp = tmp;
18348 #line 3221
18349     } else {
18350 #line 3221
18351       xp = (ushort *) *xpp;
18352 #line 3221
18353     }
18354 #line 3221
18355    /* copy the next block */
18356 #line 3221
18357 #pragma cdir loopcnt=LOOPCNT
18358 #line 3221
18359 #pragma cdir shortloop
18360 #line 3221
18361     for (i=0; i<ni; i++) {
18362 #line 3221
18363       tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
18364 #line 3221
18365      /* test for range errors (not always needed but do it anyway) */
18366 #line 3221
18367      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
18368 #line 3221
18369      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
18370 #line 3221
18371       nrange += xp[i] > DOUBLE_MAX ;
18372 #line 3221
18373     }
18374 #line 3221
18375    /* update xpp and tp */
18376 #line 3221
18377     if (realign) xp = (ushort *) *xpp;
18378 #line 3221
18379     xp += ni;
18380 #line 3221
18381     tp += ni;
18382 #line 3221
18383     *xpp = (void*)xp;
18384 #line 3221
18385   }
18386 #line 3221
18387   return nrange == 0 ? NC_NOERR : NC_ERANGE;
18388 #line 3221
18389 
18390 #line 3221
18391 #else   /* not SX */
18392 #line 3221
18393 	const char *xp = (const char *) *xpp;
18394 #line 3221
18395 	int status = NC_NOERR;
18396 #line 3221
18397 
18398 #line 3221
18399 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
18400 #line 3221
18401 	{
18402 #line 3221
18403 		const int lstatus = ncx_get_ushort_double(xp, tp);
18404 #line 3221
18405 		if (status == NC_NOERR) /* report the first encountered error */
18406 #line 3221
18407 			status = lstatus;
18408 #line 3221
18409 	}
18410 #line 3221
18411 
18412 #line 3221
18413 	*xpp = (const void *)xp;
18414 #line 3221
18415 	return status;
18416 #line 3221
18417 #endif
18418 #line 3221
18419 }
18420 #line 3221
18421 
18422 int
18423 #line 3222
ncx_getn_ushort_longlong(const void ** xpp,size_t nelems,longlong * tp)18424 ncx_getn_ushort_longlong(const void **xpp, size_t nelems, longlong *tp)
18425 #line 3222
18426 {
18427 #line 3222
18428 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
18429 #line 3222
18430 
18431 #line 3222
18432  /* basic algorithm is:
18433 #line 3222
18434   *   - ensure sane alignment of input data
18435 #line 3222
18436   *   - copy (conversion happens automatically) input data
18437 #line 3222
18438   *     to output
18439 #line 3222
18440   *   - update xpp to point at next unconverted input, and tp to point
18441 #line 3222
18442   *     at next location for converted output
18443 #line 3222
18444   */
18445 #line 3222
18446   long i, j, ni;
18447 #line 3222
18448   ushort tmp[LOOPCNT];        /* in case input is misaligned */
18449 #line 3222
18450   ushort *xp;
18451 #line 3222
18452   int nrange = 0;         /* number of range errors */
18453 #line 3222
18454   int realign = 0;        /* "do we need to fix input data alignment?" */
18455 #line 3222
18456   long cxp = (long) *((char**)xpp);
18457 #line 3222
18458 
18459 #line 3222
18460   realign = (cxp & 7) % SIZEOF_USHORT;
18461 #line 3222
18462   /* sjl: manually stripmine so we can limit amount of
18463 #line 3222
18464    * vector work space reserved to LOOPCNT elements. Also
18465 #line 3222
18466    * makes vectorisation easy */
18467 #line 3222
18468   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
18469 #line 3222
18470     ni=Min(nelems-j,LOOPCNT);
18471 #line 3222
18472     if (realign) {
18473 #line 3222
18474       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
18475 #line 3222
18476       xp = tmp;
18477 #line 3222
18478     } else {
18479 #line 3222
18480       xp = (ushort *) *xpp;
18481 #line 3222
18482     }
18483 #line 3222
18484    /* copy the next block */
18485 #line 3222
18486 #pragma cdir loopcnt=LOOPCNT
18487 #line 3222
18488 #pragma cdir shortloop
18489 #line 3222
18490     for (i=0; i<ni; i++) {
18491 #line 3222
18492       tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
18493 #line 3222
18494      /* test for range errors (not always needed but do it anyway) */
18495 #line 3222
18496      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
18497 #line 3222
18498      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
18499 #line 3222
18500       nrange += xp[i] > LONGLONG_MAX ;
18501 #line 3222
18502     }
18503 #line 3222
18504    /* update xpp and tp */
18505 #line 3222
18506     if (realign) xp = (ushort *) *xpp;
18507 #line 3222
18508     xp += ni;
18509 #line 3222
18510     tp += ni;
18511 #line 3222
18512     *xpp = (void*)xp;
18513 #line 3222
18514   }
18515 #line 3222
18516   return nrange == 0 ? NC_NOERR : NC_ERANGE;
18517 #line 3222
18518 
18519 #line 3222
18520 #else   /* not SX */
18521 #line 3222
18522 	const char *xp = (const char *) *xpp;
18523 #line 3222
18524 	int status = NC_NOERR;
18525 #line 3222
18526 
18527 #line 3222
18528 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
18529 #line 3222
18530 	{
18531 #line 3222
18532 		const int lstatus = ncx_get_ushort_longlong(xp, tp);
18533 #line 3222
18534 		if (status == NC_NOERR) /* report the first encountered error */
18535 #line 3222
18536 			status = lstatus;
18537 #line 3222
18538 	}
18539 #line 3222
18540 
18541 #line 3222
18542 	*xpp = (const void *)xp;
18543 #line 3222
18544 	return status;
18545 #line 3222
18546 #endif
18547 #line 3222
18548 }
18549 #line 3222
18550 
18551 int
18552 #line 3223
ncx_getn_ushort_uchar(const void ** xpp,size_t nelems,uchar * tp)18553 ncx_getn_ushort_uchar(const void **xpp, size_t nelems, uchar *tp)
18554 #line 3223
18555 {
18556 #line 3223
18557 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
18558 #line 3223
18559 
18560 #line 3223
18561  /* basic algorithm is:
18562 #line 3223
18563   *   - ensure sane alignment of input data
18564 #line 3223
18565   *   - copy (conversion happens automatically) input data
18566 #line 3223
18567   *     to output
18568 #line 3223
18569   *   - update xpp to point at next unconverted input, and tp to point
18570 #line 3223
18571   *     at next location for converted output
18572 #line 3223
18573   */
18574 #line 3223
18575   long i, j, ni;
18576 #line 3223
18577   ushort tmp[LOOPCNT];        /* in case input is misaligned */
18578 #line 3223
18579   ushort *xp;
18580 #line 3223
18581   int nrange = 0;         /* number of range errors */
18582 #line 3223
18583   int realign = 0;        /* "do we need to fix input data alignment?" */
18584 #line 3223
18585   long cxp = (long) *((char**)xpp);
18586 #line 3223
18587 
18588 #line 3223
18589   realign = (cxp & 7) % SIZEOF_USHORT;
18590 #line 3223
18591   /* sjl: manually stripmine so we can limit amount of
18592 #line 3223
18593    * vector work space reserved to LOOPCNT elements. Also
18594 #line 3223
18595    * makes vectorisation easy */
18596 #line 3223
18597   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
18598 #line 3223
18599     ni=Min(nelems-j,LOOPCNT);
18600 #line 3223
18601     if (realign) {
18602 #line 3223
18603       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
18604 #line 3223
18605       xp = tmp;
18606 #line 3223
18607     } else {
18608 #line 3223
18609       xp = (ushort *) *xpp;
18610 #line 3223
18611     }
18612 #line 3223
18613    /* copy the next block */
18614 #line 3223
18615 #pragma cdir loopcnt=LOOPCNT
18616 #line 3223
18617 #pragma cdir shortloop
18618 #line 3223
18619     for (i=0; i<ni; i++) {
18620 #line 3223
18621       tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
18622 #line 3223
18623      /* test for range errors (not always needed but do it anyway) */
18624 #line 3223
18625      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
18626 #line 3223
18627      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
18628 #line 3223
18629       nrange += xp[i] > UCHAR_MAX ;
18630 #line 3223
18631     }
18632 #line 3223
18633    /* update xpp and tp */
18634 #line 3223
18635     if (realign) xp = (ushort *) *xpp;
18636 #line 3223
18637     xp += ni;
18638 #line 3223
18639     tp += ni;
18640 #line 3223
18641     *xpp = (void*)xp;
18642 #line 3223
18643   }
18644 #line 3223
18645   return nrange == 0 ? NC_NOERR : NC_ERANGE;
18646 #line 3223
18647 
18648 #line 3223
18649 #else   /* not SX */
18650 #line 3223
18651 	const char *xp = (const char *) *xpp;
18652 #line 3223
18653 	int status = NC_NOERR;
18654 #line 3223
18655 
18656 #line 3223
18657 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
18658 #line 3223
18659 	{
18660 #line 3223
18661 		const int lstatus = ncx_get_ushort_uchar(xp, tp);
18662 #line 3223
18663 		if (status == NC_NOERR) /* report the first encountered error */
18664 #line 3223
18665 			status = lstatus;
18666 #line 3223
18667 	}
18668 #line 3223
18669 
18670 #line 3223
18671 	*xpp = (const void *)xp;
18672 #line 3223
18673 	return status;
18674 #line 3223
18675 #endif
18676 #line 3223
18677 }
18678 #line 3223
18679 
18680 int
18681 #line 3224
ncx_getn_ushort_uint(const void ** xpp,size_t nelems,uint * tp)18682 ncx_getn_ushort_uint(const void **xpp, size_t nelems, uint *tp)
18683 #line 3224
18684 {
18685 #line 3224
18686 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
18687 #line 3224
18688 
18689 #line 3224
18690  /* basic algorithm is:
18691 #line 3224
18692   *   - ensure sane alignment of input data
18693 #line 3224
18694   *   - copy (conversion happens automatically) input data
18695 #line 3224
18696   *     to output
18697 #line 3224
18698   *   - update xpp to point at next unconverted input, and tp to point
18699 #line 3224
18700   *     at next location for converted output
18701 #line 3224
18702   */
18703 #line 3224
18704   long i, j, ni;
18705 #line 3224
18706   ushort tmp[LOOPCNT];        /* in case input is misaligned */
18707 #line 3224
18708   ushort *xp;
18709 #line 3224
18710   int nrange = 0;         /* number of range errors */
18711 #line 3224
18712   int realign = 0;        /* "do we need to fix input data alignment?" */
18713 #line 3224
18714   long cxp = (long) *((char**)xpp);
18715 #line 3224
18716 
18717 #line 3224
18718   realign = (cxp & 7) % SIZEOF_USHORT;
18719 #line 3224
18720   /* sjl: manually stripmine so we can limit amount of
18721 #line 3224
18722    * vector work space reserved to LOOPCNT elements. Also
18723 #line 3224
18724    * makes vectorisation easy */
18725 #line 3224
18726   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
18727 #line 3224
18728     ni=Min(nelems-j,LOOPCNT);
18729 #line 3224
18730     if (realign) {
18731 #line 3224
18732       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
18733 #line 3224
18734       xp = tmp;
18735 #line 3224
18736     } else {
18737 #line 3224
18738       xp = (ushort *) *xpp;
18739 #line 3224
18740     }
18741 #line 3224
18742    /* copy the next block */
18743 #line 3224
18744 #pragma cdir loopcnt=LOOPCNT
18745 #line 3224
18746 #pragma cdir shortloop
18747 #line 3224
18748     for (i=0; i<ni; i++) {
18749 #line 3224
18750       tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
18751 #line 3224
18752      /* test for range errors (not always needed but do it anyway) */
18753 #line 3224
18754      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
18755 #line 3224
18756      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
18757 #line 3224
18758       nrange += xp[i] > UINT_MAX ;
18759 #line 3224
18760     }
18761 #line 3224
18762    /* update xpp and tp */
18763 #line 3224
18764     if (realign) xp = (ushort *) *xpp;
18765 #line 3224
18766     xp += ni;
18767 #line 3224
18768     tp += ni;
18769 #line 3224
18770     *xpp = (void*)xp;
18771 #line 3224
18772   }
18773 #line 3224
18774   return nrange == 0 ? NC_NOERR : NC_ERANGE;
18775 #line 3224
18776 
18777 #line 3224
18778 #else   /* not SX */
18779 #line 3224
18780 	const char *xp = (const char *) *xpp;
18781 #line 3224
18782 	int status = NC_NOERR;
18783 #line 3224
18784 
18785 #line 3224
18786 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
18787 #line 3224
18788 	{
18789 #line 3224
18790 		const int lstatus = ncx_get_ushort_uint(xp, tp);
18791 #line 3224
18792 		if (status == NC_NOERR) /* report the first encountered error */
18793 #line 3224
18794 			status = lstatus;
18795 #line 3224
18796 	}
18797 #line 3224
18798 
18799 #line 3224
18800 	*xpp = (const void *)xp;
18801 #line 3224
18802 	return status;
18803 #line 3224
18804 #endif
18805 #line 3224
18806 }
18807 #line 3224
18808 
18809 int
18810 #line 3225
ncx_getn_ushort_ulonglong(const void ** xpp,size_t nelems,ulonglong * tp)18811 ncx_getn_ushort_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
18812 #line 3225
18813 {
18814 #line 3225
18815 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
18816 #line 3225
18817 
18818 #line 3225
18819  /* basic algorithm is:
18820 #line 3225
18821   *   - ensure sane alignment of input data
18822 #line 3225
18823   *   - copy (conversion happens automatically) input data
18824 #line 3225
18825   *     to output
18826 #line 3225
18827   *   - update xpp to point at next unconverted input, and tp to point
18828 #line 3225
18829   *     at next location for converted output
18830 #line 3225
18831   */
18832 #line 3225
18833   long i, j, ni;
18834 #line 3225
18835   ushort tmp[LOOPCNT];        /* in case input is misaligned */
18836 #line 3225
18837   ushort *xp;
18838 #line 3225
18839   int nrange = 0;         /* number of range errors */
18840 #line 3225
18841   int realign = 0;        /* "do we need to fix input data alignment?" */
18842 #line 3225
18843   long cxp = (long) *((char**)xpp);
18844 #line 3225
18845 
18846 #line 3225
18847   realign = (cxp & 7) % SIZEOF_USHORT;
18848 #line 3225
18849   /* sjl: manually stripmine so we can limit amount of
18850 #line 3225
18851    * vector work space reserved to LOOPCNT elements. Also
18852 #line 3225
18853    * makes vectorisation easy */
18854 #line 3225
18855   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
18856 #line 3225
18857     ni=Min(nelems-j,LOOPCNT);
18858 #line 3225
18859     if (realign) {
18860 #line 3225
18861       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
18862 #line 3225
18863       xp = tmp;
18864 #line 3225
18865     } else {
18866 #line 3225
18867       xp = (ushort *) *xpp;
18868 #line 3225
18869     }
18870 #line 3225
18871    /* copy the next block */
18872 #line 3225
18873 #pragma cdir loopcnt=LOOPCNT
18874 #line 3225
18875 #pragma cdir shortloop
18876 #line 3225
18877     for (i=0; i<ni; i++) {
18878 #line 3225
18879       tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
18880 #line 3225
18881      /* test for range errors (not always needed but do it anyway) */
18882 #line 3225
18883      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
18884 #line 3225
18885      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
18886 #line 3225
18887       nrange += xp[i] > ULONGLONG_MAX ;
18888 #line 3225
18889     }
18890 #line 3225
18891    /* update xpp and tp */
18892 #line 3225
18893     if (realign) xp = (ushort *) *xpp;
18894 #line 3225
18895     xp += ni;
18896 #line 3225
18897     tp += ni;
18898 #line 3225
18899     *xpp = (void*)xp;
18900 #line 3225
18901   }
18902 #line 3225
18903   return nrange == 0 ? NC_NOERR : NC_ERANGE;
18904 #line 3225
18905 
18906 #line 3225
18907 #else   /* not SX */
18908 #line 3225
18909 	const char *xp = (const char *) *xpp;
18910 #line 3225
18911 	int status = NC_NOERR;
18912 #line 3225
18913 
18914 #line 3225
18915 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
18916 #line 3225
18917 	{
18918 #line 3225
18919 		const int lstatus = ncx_get_ushort_ulonglong(xp, tp);
18920 #line 3225
18921 		if (status == NC_NOERR) /* report the first encountered error */
18922 #line 3225
18923 			status = lstatus;
18924 #line 3225
18925 	}
18926 #line 3225
18927 
18928 #line 3225
18929 	*xpp = (const void *)xp;
18930 #line 3225
18931 	return status;
18932 #line 3225
18933 #endif
18934 #line 3225
18935 }
18936 #line 3225
18937 
18938 
18939 int
18940 #line 3227
ncx_pad_getn_ushort_schar(const void ** xpp,size_t nelems,schar * tp)18941 ncx_pad_getn_ushort_schar(const void **xpp, size_t nelems, schar *tp)
18942 #line 3227
18943 {
18944 #line 3227
18945 	const size_t rndup = nelems % X_SIZEOF_SHORT;
18946 #line 3227
18947 
18948 #line 3227
18949 	const char *xp = (const char *) *xpp;
18950 #line 3227
18951 	int status = NC_NOERR;
18952 #line 3227
18953 
18954 #line 3227
18955 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
18956 #line 3227
18957 	{
18958 #line 3227
18959 		const int lstatus = ncx_get_ushort_schar(xp, tp);
18960 #line 3227
18961 		if (status == NC_NOERR) /* report the first encountered error */
18962 #line 3227
18963 			status = lstatus;
18964 #line 3227
18965 	}
18966 #line 3227
18967 
18968 #line 3227
18969 	if (rndup != 0)
18970 #line 3227
18971 		xp += X_SIZEOF_USHORT;
18972 #line 3227
18973 
18974 #line 3227
18975 	*xpp = (void *)xp;
18976 #line 3227
18977 	return status;
18978 #line 3227
18979 }
18980 #line 3227
18981 
18982 int
18983 #line 3228
ncx_pad_getn_ushort_short(const void ** xpp,size_t nelems,short * tp)18984 ncx_pad_getn_ushort_short(const void **xpp, size_t nelems, short *tp)
18985 #line 3228
18986 {
18987 #line 3228
18988 	const size_t rndup = nelems % X_SIZEOF_SHORT;
18989 #line 3228
18990 
18991 #line 3228
18992 	const char *xp = (const char *) *xpp;
18993 #line 3228
18994 	int status = NC_NOERR;
18995 #line 3228
18996 
18997 #line 3228
18998 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
18999 #line 3228
19000 	{
19001 #line 3228
19002 		const int lstatus = ncx_get_ushort_short(xp, tp);
19003 #line 3228
19004 		if (status == NC_NOERR) /* report the first encountered error */
19005 #line 3228
19006 			status = lstatus;
19007 #line 3228
19008 	}
19009 #line 3228
19010 
19011 #line 3228
19012 	if (rndup != 0)
19013 #line 3228
19014 		xp += X_SIZEOF_USHORT;
19015 #line 3228
19016 
19017 #line 3228
19018 	*xpp = (void *)xp;
19019 #line 3228
19020 	return status;
19021 #line 3228
19022 }
19023 #line 3228
19024 
19025 int
19026 #line 3229
ncx_pad_getn_ushort_int(const void ** xpp,size_t nelems,int * tp)19027 ncx_pad_getn_ushort_int(const void **xpp, size_t nelems, int *tp)
19028 #line 3229
19029 {
19030 #line 3229
19031 	const size_t rndup = nelems % X_SIZEOF_SHORT;
19032 #line 3229
19033 
19034 #line 3229
19035 	const char *xp = (const char *) *xpp;
19036 #line 3229
19037 	int status = NC_NOERR;
19038 #line 3229
19039 
19040 #line 3229
19041 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
19042 #line 3229
19043 	{
19044 #line 3229
19045 		const int lstatus = ncx_get_ushort_int(xp, tp);
19046 #line 3229
19047 		if (status == NC_NOERR) /* report the first encountered error */
19048 #line 3229
19049 			status = lstatus;
19050 #line 3229
19051 	}
19052 #line 3229
19053 
19054 #line 3229
19055 	if (rndup != 0)
19056 #line 3229
19057 		xp += X_SIZEOF_USHORT;
19058 #line 3229
19059 
19060 #line 3229
19061 	*xpp = (void *)xp;
19062 #line 3229
19063 	return status;
19064 #line 3229
19065 }
19066 #line 3229
19067 
19068 int
19069 #line 3230
ncx_pad_getn_ushort_long(const void ** xpp,size_t nelems,long * tp)19070 ncx_pad_getn_ushort_long(const void **xpp, size_t nelems, long *tp)
19071 #line 3230
19072 {
19073 #line 3230
19074 	const size_t rndup = nelems % X_SIZEOF_SHORT;
19075 #line 3230
19076 
19077 #line 3230
19078 	const char *xp = (const char *) *xpp;
19079 #line 3230
19080 	int status = NC_NOERR;
19081 #line 3230
19082 
19083 #line 3230
19084 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
19085 #line 3230
19086 	{
19087 #line 3230
19088 		const int lstatus = ncx_get_ushort_long(xp, tp);
19089 #line 3230
19090 		if (status == NC_NOERR) /* report the first encountered error */
19091 #line 3230
19092 			status = lstatus;
19093 #line 3230
19094 	}
19095 #line 3230
19096 
19097 #line 3230
19098 	if (rndup != 0)
19099 #line 3230
19100 		xp += X_SIZEOF_USHORT;
19101 #line 3230
19102 
19103 #line 3230
19104 	*xpp = (void *)xp;
19105 #line 3230
19106 	return status;
19107 #line 3230
19108 }
19109 #line 3230
19110 
19111 int
19112 #line 3231
ncx_pad_getn_ushort_float(const void ** xpp,size_t nelems,float * tp)19113 ncx_pad_getn_ushort_float(const void **xpp, size_t nelems, float *tp)
19114 #line 3231
19115 {
19116 #line 3231
19117 	const size_t rndup = nelems % X_SIZEOF_SHORT;
19118 #line 3231
19119 
19120 #line 3231
19121 	const char *xp = (const char *) *xpp;
19122 #line 3231
19123 	int status = NC_NOERR;
19124 #line 3231
19125 
19126 #line 3231
19127 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
19128 #line 3231
19129 	{
19130 #line 3231
19131 		const int lstatus = ncx_get_ushort_float(xp, tp);
19132 #line 3231
19133 		if (status == NC_NOERR) /* report the first encountered error */
19134 #line 3231
19135 			status = lstatus;
19136 #line 3231
19137 	}
19138 #line 3231
19139 
19140 #line 3231
19141 	if (rndup != 0)
19142 #line 3231
19143 		xp += X_SIZEOF_USHORT;
19144 #line 3231
19145 
19146 #line 3231
19147 	*xpp = (void *)xp;
19148 #line 3231
19149 	return status;
19150 #line 3231
19151 }
19152 #line 3231
19153 
19154 int
19155 #line 3232
ncx_pad_getn_ushort_double(const void ** xpp,size_t nelems,double * tp)19156 ncx_pad_getn_ushort_double(const void **xpp, size_t nelems, double *tp)
19157 #line 3232
19158 {
19159 #line 3232
19160 	const size_t rndup = nelems % X_SIZEOF_SHORT;
19161 #line 3232
19162 
19163 #line 3232
19164 	const char *xp = (const char *) *xpp;
19165 #line 3232
19166 	int status = NC_NOERR;
19167 #line 3232
19168 
19169 #line 3232
19170 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
19171 #line 3232
19172 	{
19173 #line 3232
19174 		const int lstatus = ncx_get_ushort_double(xp, tp);
19175 #line 3232
19176 		if (status == NC_NOERR) /* report the first encountered error */
19177 #line 3232
19178 			status = lstatus;
19179 #line 3232
19180 	}
19181 #line 3232
19182 
19183 #line 3232
19184 	if (rndup != 0)
19185 #line 3232
19186 		xp += X_SIZEOF_USHORT;
19187 #line 3232
19188 
19189 #line 3232
19190 	*xpp = (void *)xp;
19191 #line 3232
19192 	return status;
19193 #line 3232
19194 }
19195 #line 3232
19196 
19197 int
19198 #line 3233
ncx_pad_getn_ushort_uchar(const void ** xpp,size_t nelems,uchar * tp)19199 ncx_pad_getn_ushort_uchar(const void **xpp, size_t nelems, uchar *tp)
19200 #line 3233
19201 {
19202 #line 3233
19203 	const size_t rndup = nelems % X_SIZEOF_SHORT;
19204 #line 3233
19205 
19206 #line 3233
19207 	const char *xp = (const char *) *xpp;
19208 #line 3233
19209 	int status = NC_NOERR;
19210 #line 3233
19211 
19212 #line 3233
19213 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
19214 #line 3233
19215 	{
19216 #line 3233
19217 		const int lstatus = ncx_get_ushort_uchar(xp, tp);
19218 #line 3233
19219 		if (status == NC_NOERR) /* report the first encountered error */
19220 #line 3233
19221 			status = lstatus;
19222 #line 3233
19223 	}
19224 #line 3233
19225 
19226 #line 3233
19227 	if (rndup != 0)
19228 #line 3233
19229 		xp += X_SIZEOF_USHORT;
19230 #line 3233
19231 
19232 #line 3233
19233 	*xpp = (void *)xp;
19234 #line 3233
19235 	return status;
19236 #line 3233
19237 }
19238 #line 3233
19239 
19240 int
19241 #line 3234
ncx_pad_getn_ushort_ushort(const void ** xpp,size_t nelems,ushort * tp)19242 ncx_pad_getn_ushort_ushort(const void **xpp, size_t nelems, ushort *tp)
19243 #line 3234
19244 {
19245 #line 3234
19246 	const size_t rndup = nelems % X_SIZEOF_SHORT;
19247 #line 3234
19248 
19249 #line 3234
19250 	const char *xp = (const char *) *xpp;
19251 #line 3234
19252 	int status = NC_NOERR;
19253 #line 3234
19254 
19255 #line 3234
19256 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
19257 #line 3234
19258 	{
19259 #line 3234
19260 		const int lstatus = ncx_get_ushort_ushort(xp, tp);
19261 #line 3234
19262 		if (status == NC_NOERR) /* report the first encountered error */
19263 #line 3234
19264 			status = lstatus;
19265 #line 3234
19266 	}
19267 #line 3234
19268 
19269 #line 3234
19270 	if (rndup != 0)
19271 #line 3234
19272 		xp += X_SIZEOF_USHORT;
19273 #line 3234
19274 
19275 #line 3234
19276 	*xpp = (void *)xp;
19277 #line 3234
19278 	return status;
19279 #line 3234
19280 }
19281 #line 3234
19282 
19283 int
19284 #line 3235
ncx_pad_getn_ushort_uint(const void ** xpp,size_t nelems,uint * tp)19285 ncx_pad_getn_ushort_uint(const void **xpp, size_t nelems, uint *tp)
19286 #line 3235
19287 {
19288 #line 3235
19289 	const size_t rndup = nelems % X_SIZEOF_SHORT;
19290 #line 3235
19291 
19292 #line 3235
19293 	const char *xp = (const char *) *xpp;
19294 #line 3235
19295 	int status = NC_NOERR;
19296 #line 3235
19297 
19298 #line 3235
19299 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
19300 #line 3235
19301 	{
19302 #line 3235
19303 		const int lstatus = ncx_get_ushort_uint(xp, tp);
19304 #line 3235
19305 		if (status == NC_NOERR) /* report the first encountered error */
19306 #line 3235
19307 			status = lstatus;
19308 #line 3235
19309 	}
19310 #line 3235
19311 
19312 #line 3235
19313 	if (rndup != 0)
19314 #line 3235
19315 		xp += X_SIZEOF_USHORT;
19316 #line 3235
19317 
19318 #line 3235
19319 	*xpp = (void *)xp;
19320 #line 3235
19321 	return status;
19322 #line 3235
19323 }
19324 #line 3235
19325 
19326 int
19327 #line 3236
ncx_pad_getn_ushort_longlong(const void ** xpp,size_t nelems,longlong * tp)19328 ncx_pad_getn_ushort_longlong(const void **xpp, size_t nelems, longlong *tp)
19329 #line 3236
19330 {
19331 #line 3236
19332 	const size_t rndup = nelems % X_SIZEOF_SHORT;
19333 #line 3236
19334 
19335 #line 3236
19336 	const char *xp = (const char *) *xpp;
19337 #line 3236
19338 	int status = NC_NOERR;
19339 #line 3236
19340 
19341 #line 3236
19342 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
19343 #line 3236
19344 	{
19345 #line 3236
19346 		const int lstatus = ncx_get_ushort_longlong(xp, tp);
19347 #line 3236
19348 		if (status == NC_NOERR) /* report the first encountered error */
19349 #line 3236
19350 			status = lstatus;
19351 #line 3236
19352 	}
19353 #line 3236
19354 
19355 #line 3236
19356 	if (rndup != 0)
19357 #line 3236
19358 		xp += X_SIZEOF_USHORT;
19359 #line 3236
19360 
19361 #line 3236
19362 	*xpp = (void *)xp;
19363 #line 3236
19364 	return status;
19365 #line 3236
19366 }
19367 #line 3236
19368 
19369 int
19370 #line 3237
ncx_pad_getn_ushort_ulonglong(const void ** xpp,size_t nelems,ulonglong * tp)19371 ncx_pad_getn_ushort_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
19372 #line 3237
19373 {
19374 #line 3237
19375 	const size_t rndup = nelems % X_SIZEOF_SHORT;
19376 #line 3237
19377 
19378 #line 3237
19379 	const char *xp = (const char *) *xpp;
19380 #line 3237
19381 	int status = NC_NOERR;
19382 #line 3237
19383 
19384 #line 3237
19385 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
19386 #line 3237
19387 	{
19388 #line 3237
19389 		const int lstatus = ncx_get_ushort_ulonglong(xp, tp);
19390 #line 3237
19391 		if (status == NC_NOERR) /* report the first encountered error */
19392 #line 3237
19393 			status = lstatus;
19394 #line 3237
19395 	}
19396 #line 3237
19397 
19398 #line 3237
19399 	if (rndup != 0)
19400 #line 3237
19401 		xp += X_SIZEOF_USHORT;
19402 #line 3237
19403 
19404 #line 3237
19405 	*xpp = (void *)xp;
19406 #line 3237
19407 	return status;
19408 #line 3237
19409 }
19410 #line 3237
19411 
19412 
19413 #if X_SIZEOF_USHORT == SIZEOF_USHORT
19414 /* optimized version */
19415 int
ncx_putn_ushort_ushort(void ** xpp,size_t nelems,const unsigned short * tp,void * fillp)19416 ncx_putn_ushort_ushort(void **xpp, size_t nelems, const unsigned short *tp, void *fillp)
19417 {
19418 #ifdef WORDS_BIGENDIAN
19419 	(void) memcpy(*xpp, tp, (size_t)nelems * X_SIZEOF_USHORT);
19420 # else
19421 	swapn2b(*xpp, tp, nelems);
19422 # endif
19423 	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_USHORT);
19424 	return NC_NOERR;
19425 }
19426 #else
19427 int
19428 #line 3253
ncx_putn_ushort_ushort(void ** xpp,size_t nelems,const ushort * tp,void * fillp)19429 ncx_putn_ushort_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
19430 #line 3253
19431 {
19432 #line 3253
19433 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
19434 #line 3253
19435 
19436 #line 3253
19437  /* basic algorithm is:
19438 #line 3253
19439   *   - ensure sane alignment of output data
19440 #line 3253
19441   *   - copy (conversion happens automatically) input data
19442 #line 3253
19443   *     to output
19444 #line 3253
19445   *   - update tp to point at next unconverted input, and xpp to point
19446 #line 3253
19447   *     at next location for converted output
19448 #line 3253
19449   */
19450 #line 3253
19451   long i, j, ni;
19452 #line 3253
19453   ushort tmp[LOOPCNT];        /* in case input is misaligned */
19454 #line 3253
19455   ushort *xp;
19456 #line 3253
19457   int nrange = 0;         /* number of range errors */
19458 #line 3253
19459   int realign = 0;        /* "do we need to fix input data alignment?" */
19460 #line 3253
19461   long cxp = (long) *((char**)xpp);
19462 #line 3253
19463 
19464 #line 3253
19465   realign = (cxp & 7) % SIZEOF_USHORT;
19466 #line 3253
19467   /* sjl: manually stripmine so we can limit amount of
19468 #line 3253
19469    * vector work space reserved to LOOPCNT elements. Also
19470 #line 3253
19471    * makes vectorisation easy */
19472 #line 3253
19473   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
19474 #line 3253
19475     ni=Min(nelems-j,LOOPCNT);
19476 #line 3253
19477     if (realign) {
19478 #line 3253
19479       xp = tmp;
19480 #line 3253
19481     } else {
19482 #line 3253
19483       xp = (ushort *) *xpp;
19484 #line 3253
19485     }
19486 #line 3253
19487    /* copy the next block */
19488 #line 3253
19489 #pragma cdir loopcnt=LOOPCNT
19490 #line 3253
19491 #pragma cdir shortloop
19492 #line 3253
19493     for (i=0; i<ni; i++) {
19494 #line 3253
19495       /* the normal case: */
19496 #line 3253
19497       xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
19498 #line 3253
19499      /* test for range errors (not always needed but do it anyway) */
19500 #line 3253
19501      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
19502 #line 3253
19503      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
19504 #line 3253
19505       nrange += tp[i] > X_USHORT_MAX ;
19506 #line 3253
19507     }
19508 #line 3253
19509    /* copy workspace back if necessary */
19510 #line 3253
19511     if (realign) {
19512 #line 3253
19513       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
19514 #line 3253
19515       xp = (ushort *) *xpp;
19516 #line 3253
19517     }
19518 #line 3253
19519    /* update xpp and tp */
19520 #line 3253
19521     xp += ni;
19522 #line 3253
19523     tp += ni;
19524 #line 3253
19525     *xpp = (void*)xp;
19526 #line 3253
19527   }
19528 #line 3253
19529   return nrange == 0 ? NC_NOERR : NC_ERANGE;
19530 #line 3253
19531 
19532 #line 3253
19533 #else   /* not SX */
19534 #line 3253
19535 
19536 #line 3253
19537 	char *xp = (char *) *xpp;
19538 #line 3253
19539 	int status = NC_NOERR;
19540 #line 3253
19541 
19542 #line 3253
19543 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
19544 #line 3253
19545 	{
19546 #line 3253
19547 		int lstatus = ncx_put_ushort_ushort(xp, tp, fillp);
19548 #line 3253
19549 		if (status == NC_NOERR) /* report the first encountered error */
19550 #line 3253
19551 			status = lstatus;
19552 #line 3253
19553 	}
19554 #line 3253
19555 
19556 #line 3253
19557 	*xpp = (void *)xp;
19558 #line 3253
19559 	return status;
19560 #line 3253
19561 #endif
19562 #line 3253
19563 }
19564 #line 3253
19565 
19566 #endif
19567 int
19568 #line 3255
ncx_putn_ushort_schar(void ** xpp,size_t nelems,const schar * tp,void * fillp)19569 ncx_putn_ushort_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
19570 #line 3255
19571 {
19572 #line 3255
19573 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
19574 #line 3255
19575 
19576 #line 3255
19577  /* basic algorithm is:
19578 #line 3255
19579   *   - ensure sane alignment of output data
19580 #line 3255
19581   *   - copy (conversion happens automatically) input data
19582 #line 3255
19583   *     to output
19584 #line 3255
19585   *   - update tp to point at next unconverted input, and xpp to point
19586 #line 3255
19587   *     at next location for converted output
19588 #line 3255
19589   */
19590 #line 3255
19591   long i, j, ni;
19592 #line 3255
19593   ushort tmp[LOOPCNT];        /* in case input is misaligned */
19594 #line 3255
19595   ushort *xp;
19596 #line 3255
19597   int nrange = 0;         /* number of range errors */
19598 #line 3255
19599   int realign = 0;        /* "do we need to fix input data alignment?" */
19600 #line 3255
19601   long cxp = (long) *((char**)xpp);
19602 #line 3255
19603 
19604 #line 3255
19605   realign = (cxp & 7) % SIZEOF_USHORT;
19606 #line 3255
19607   /* sjl: manually stripmine so we can limit amount of
19608 #line 3255
19609    * vector work space reserved to LOOPCNT elements. Also
19610 #line 3255
19611    * makes vectorisation easy */
19612 #line 3255
19613   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
19614 #line 3255
19615     ni=Min(nelems-j,LOOPCNT);
19616 #line 3255
19617     if (realign) {
19618 #line 3255
19619       xp = tmp;
19620 #line 3255
19621     } else {
19622 #line 3255
19623       xp = (ushort *) *xpp;
19624 #line 3255
19625     }
19626 #line 3255
19627    /* copy the next block */
19628 #line 3255
19629 #pragma cdir loopcnt=LOOPCNT
19630 #line 3255
19631 #pragma cdir shortloop
19632 #line 3255
19633     for (i=0; i<ni; i++) {
19634 #line 3255
19635       /* the normal case: */
19636 #line 3255
19637       xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
19638 #line 3255
19639      /* test for range errors (not always needed but do it anyway) */
19640 #line 3255
19641      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
19642 #line 3255
19643      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
19644 #line 3255
19645       nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
19646 #line 3255
19647     }
19648 #line 3255
19649    /* copy workspace back if necessary */
19650 #line 3255
19651     if (realign) {
19652 #line 3255
19653       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
19654 #line 3255
19655       xp = (ushort *) *xpp;
19656 #line 3255
19657     }
19658 #line 3255
19659    /* update xpp and tp */
19660 #line 3255
19661     xp += ni;
19662 #line 3255
19663     tp += ni;
19664 #line 3255
19665     *xpp = (void*)xp;
19666 #line 3255
19667   }
19668 #line 3255
19669   return nrange == 0 ? NC_NOERR : NC_ERANGE;
19670 #line 3255
19671 
19672 #line 3255
19673 #else   /* not SX */
19674 #line 3255
19675 
19676 #line 3255
19677 	char *xp = (char *) *xpp;
19678 #line 3255
19679 	int status = NC_NOERR;
19680 #line 3255
19681 
19682 #line 3255
19683 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
19684 #line 3255
19685 	{
19686 #line 3255
19687 		int lstatus = ncx_put_ushort_schar(xp, tp, fillp);
19688 #line 3255
19689 		if (status == NC_NOERR) /* report the first encountered error */
19690 #line 3255
19691 			status = lstatus;
19692 #line 3255
19693 	}
19694 #line 3255
19695 
19696 #line 3255
19697 	*xpp = (void *)xp;
19698 #line 3255
19699 	return status;
19700 #line 3255
19701 #endif
19702 #line 3255
19703 }
19704 #line 3255
19705 
19706 int
19707 #line 3256
ncx_putn_ushort_short(void ** xpp,size_t nelems,const short * tp,void * fillp)19708 ncx_putn_ushort_short(void **xpp, size_t nelems, const short *tp, void *fillp)
19709 #line 3256
19710 {
19711 #line 3256
19712 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
19713 #line 3256
19714 
19715 #line 3256
19716  /* basic algorithm is:
19717 #line 3256
19718   *   - ensure sane alignment of output data
19719 #line 3256
19720   *   - copy (conversion happens automatically) input data
19721 #line 3256
19722   *     to output
19723 #line 3256
19724   *   - update tp to point at next unconverted input, and xpp to point
19725 #line 3256
19726   *     at next location for converted output
19727 #line 3256
19728   */
19729 #line 3256
19730   long i, j, ni;
19731 #line 3256
19732   ushort tmp[LOOPCNT];        /* in case input is misaligned */
19733 #line 3256
19734   ushort *xp;
19735 #line 3256
19736   int nrange = 0;         /* number of range errors */
19737 #line 3256
19738   int realign = 0;        /* "do we need to fix input data alignment?" */
19739 #line 3256
19740   long cxp = (long) *((char**)xpp);
19741 #line 3256
19742 
19743 #line 3256
19744   realign = (cxp & 7) % SIZEOF_USHORT;
19745 #line 3256
19746   /* sjl: manually stripmine so we can limit amount of
19747 #line 3256
19748    * vector work space reserved to LOOPCNT elements. Also
19749 #line 3256
19750    * makes vectorisation easy */
19751 #line 3256
19752   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
19753 #line 3256
19754     ni=Min(nelems-j,LOOPCNT);
19755 #line 3256
19756     if (realign) {
19757 #line 3256
19758       xp = tmp;
19759 #line 3256
19760     } else {
19761 #line 3256
19762       xp = (ushort *) *xpp;
19763 #line 3256
19764     }
19765 #line 3256
19766    /* copy the next block */
19767 #line 3256
19768 #pragma cdir loopcnt=LOOPCNT
19769 #line 3256
19770 #pragma cdir shortloop
19771 #line 3256
19772     for (i=0; i<ni; i++) {
19773 #line 3256
19774       /* the normal case: */
19775 #line 3256
19776       xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
19777 #line 3256
19778      /* test for range errors (not always needed but do it anyway) */
19779 #line 3256
19780      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
19781 #line 3256
19782      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
19783 #line 3256
19784       nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
19785 #line 3256
19786     }
19787 #line 3256
19788    /* copy workspace back if necessary */
19789 #line 3256
19790     if (realign) {
19791 #line 3256
19792       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
19793 #line 3256
19794       xp = (ushort *) *xpp;
19795 #line 3256
19796     }
19797 #line 3256
19798    /* update xpp and tp */
19799 #line 3256
19800     xp += ni;
19801 #line 3256
19802     tp += ni;
19803 #line 3256
19804     *xpp = (void*)xp;
19805 #line 3256
19806   }
19807 #line 3256
19808   return nrange == 0 ? NC_NOERR : NC_ERANGE;
19809 #line 3256
19810 
19811 #line 3256
19812 #else   /* not SX */
19813 #line 3256
19814 
19815 #line 3256
19816 	char *xp = (char *) *xpp;
19817 #line 3256
19818 	int status = NC_NOERR;
19819 #line 3256
19820 
19821 #line 3256
19822 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
19823 #line 3256
19824 	{
19825 #line 3256
19826 		int lstatus = ncx_put_ushort_short(xp, tp, fillp);
19827 #line 3256
19828 		if (status == NC_NOERR) /* report the first encountered error */
19829 #line 3256
19830 			status = lstatus;
19831 #line 3256
19832 	}
19833 #line 3256
19834 
19835 #line 3256
19836 	*xpp = (void *)xp;
19837 #line 3256
19838 	return status;
19839 #line 3256
19840 #endif
19841 #line 3256
19842 }
19843 #line 3256
19844 
19845 int
19846 #line 3257
ncx_putn_ushort_int(void ** xpp,size_t nelems,const int * tp,void * fillp)19847 ncx_putn_ushort_int(void **xpp, size_t nelems, const int *tp, void *fillp)
19848 #line 3257
19849 {
19850 #line 3257
19851 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
19852 #line 3257
19853 
19854 #line 3257
19855  /* basic algorithm is:
19856 #line 3257
19857   *   - ensure sane alignment of output data
19858 #line 3257
19859   *   - copy (conversion happens automatically) input data
19860 #line 3257
19861   *     to output
19862 #line 3257
19863   *   - update tp to point at next unconverted input, and xpp to point
19864 #line 3257
19865   *     at next location for converted output
19866 #line 3257
19867   */
19868 #line 3257
19869   long i, j, ni;
19870 #line 3257
19871   ushort tmp[LOOPCNT];        /* in case input is misaligned */
19872 #line 3257
19873   ushort *xp;
19874 #line 3257
19875   int nrange = 0;         /* number of range errors */
19876 #line 3257
19877   int realign = 0;        /* "do we need to fix input data alignment?" */
19878 #line 3257
19879   long cxp = (long) *((char**)xpp);
19880 #line 3257
19881 
19882 #line 3257
19883   realign = (cxp & 7) % SIZEOF_USHORT;
19884 #line 3257
19885   /* sjl: manually stripmine so we can limit amount of
19886 #line 3257
19887    * vector work space reserved to LOOPCNT elements. Also
19888 #line 3257
19889    * makes vectorisation easy */
19890 #line 3257
19891   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
19892 #line 3257
19893     ni=Min(nelems-j,LOOPCNT);
19894 #line 3257
19895     if (realign) {
19896 #line 3257
19897       xp = tmp;
19898 #line 3257
19899     } else {
19900 #line 3257
19901       xp = (ushort *) *xpp;
19902 #line 3257
19903     }
19904 #line 3257
19905    /* copy the next block */
19906 #line 3257
19907 #pragma cdir loopcnt=LOOPCNT
19908 #line 3257
19909 #pragma cdir shortloop
19910 #line 3257
19911     for (i=0; i<ni; i++) {
19912 #line 3257
19913       /* the normal case: */
19914 #line 3257
19915       xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
19916 #line 3257
19917      /* test for range errors (not always needed but do it anyway) */
19918 #line 3257
19919      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
19920 #line 3257
19921      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
19922 #line 3257
19923       nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
19924 #line 3257
19925     }
19926 #line 3257
19927    /* copy workspace back if necessary */
19928 #line 3257
19929     if (realign) {
19930 #line 3257
19931       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
19932 #line 3257
19933       xp = (ushort *) *xpp;
19934 #line 3257
19935     }
19936 #line 3257
19937    /* update xpp and tp */
19938 #line 3257
19939     xp += ni;
19940 #line 3257
19941     tp += ni;
19942 #line 3257
19943     *xpp = (void*)xp;
19944 #line 3257
19945   }
19946 #line 3257
19947   return nrange == 0 ? NC_NOERR : NC_ERANGE;
19948 #line 3257
19949 
19950 #line 3257
19951 #else   /* not SX */
19952 #line 3257
19953 
19954 #line 3257
19955 	char *xp = (char *) *xpp;
19956 #line 3257
19957 	int status = NC_NOERR;
19958 #line 3257
19959 
19960 #line 3257
19961 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
19962 #line 3257
19963 	{
19964 #line 3257
19965 		int lstatus = ncx_put_ushort_int(xp, tp, fillp);
19966 #line 3257
19967 		if (status == NC_NOERR) /* report the first encountered error */
19968 #line 3257
19969 			status = lstatus;
19970 #line 3257
19971 	}
19972 #line 3257
19973 
19974 #line 3257
19975 	*xpp = (void *)xp;
19976 #line 3257
19977 	return status;
19978 #line 3257
19979 #endif
19980 #line 3257
19981 }
19982 #line 3257
19983 
19984 int
19985 #line 3258
ncx_putn_ushort_long(void ** xpp,size_t nelems,const long * tp,void * fillp)19986 ncx_putn_ushort_long(void **xpp, size_t nelems, const long *tp, void *fillp)
19987 #line 3258
19988 {
19989 #line 3258
19990 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
19991 #line 3258
19992 
19993 #line 3258
19994  /* basic algorithm is:
19995 #line 3258
19996   *   - ensure sane alignment of output data
19997 #line 3258
19998   *   - copy (conversion happens automatically) input data
19999 #line 3258
20000   *     to output
20001 #line 3258
20002   *   - update tp to point at next unconverted input, and xpp to point
20003 #line 3258
20004   *     at next location for converted output
20005 #line 3258
20006   */
20007 #line 3258
20008   long i, j, ni;
20009 #line 3258
20010   ushort tmp[LOOPCNT];        /* in case input is misaligned */
20011 #line 3258
20012   ushort *xp;
20013 #line 3258
20014   int nrange = 0;         /* number of range errors */
20015 #line 3258
20016   int realign = 0;        /* "do we need to fix input data alignment?" */
20017 #line 3258
20018   long cxp = (long) *((char**)xpp);
20019 #line 3258
20020 
20021 #line 3258
20022   realign = (cxp & 7) % SIZEOF_USHORT;
20023 #line 3258
20024   /* sjl: manually stripmine so we can limit amount of
20025 #line 3258
20026    * vector work space reserved to LOOPCNT elements. Also
20027 #line 3258
20028    * makes vectorisation easy */
20029 #line 3258
20030   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
20031 #line 3258
20032     ni=Min(nelems-j,LOOPCNT);
20033 #line 3258
20034     if (realign) {
20035 #line 3258
20036       xp = tmp;
20037 #line 3258
20038     } else {
20039 #line 3258
20040       xp = (ushort *) *xpp;
20041 #line 3258
20042     }
20043 #line 3258
20044    /* copy the next block */
20045 #line 3258
20046 #pragma cdir loopcnt=LOOPCNT
20047 #line 3258
20048 #pragma cdir shortloop
20049 #line 3258
20050     for (i=0; i<ni; i++) {
20051 #line 3258
20052       /* the normal case: */
20053 #line 3258
20054       xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
20055 #line 3258
20056      /* test for range errors (not always needed but do it anyway) */
20057 #line 3258
20058      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
20059 #line 3258
20060      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
20061 #line 3258
20062       nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
20063 #line 3258
20064     }
20065 #line 3258
20066    /* copy workspace back if necessary */
20067 #line 3258
20068     if (realign) {
20069 #line 3258
20070       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
20071 #line 3258
20072       xp = (ushort *) *xpp;
20073 #line 3258
20074     }
20075 #line 3258
20076    /* update xpp and tp */
20077 #line 3258
20078     xp += ni;
20079 #line 3258
20080     tp += ni;
20081 #line 3258
20082     *xpp = (void*)xp;
20083 #line 3258
20084   }
20085 #line 3258
20086   return nrange == 0 ? NC_NOERR : NC_ERANGE;
20087 #line 3258
20088 
20089 #line 3258
20090 #else   /* not SX */
20091 #line 3258
20092 
20093 #line 3258
20094 	char *xp = (char *) *xpp;
20095 #line 3258
20096 	int status = NC_NOERR;
20097 #line 3258
20098 
20099 #line 3258
20100 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
20101 #line 3258
20102 	{
20103 #line 3258
20104 		int lstatus = ncx_put_ushort_long(xp, tp, fillp);
20105 #line 3258
20106 		if (status == NC_NOERR) /* report the first encountered error */
20107 #line 3258
20108 			status = lstatus;
20109 #line 3258
20110 	}
20111 #line 3258
20112 
20113 #line 3258
20114 	*xpp = (void *)xp;
20115 #line 3258
20116 	return status;
20117 #line 3258
20118 #endif
20119 #line 3258
20120 }
20121 #line 3258
20122 
20123 int
20124 #line 3259
ncx_putn_ushort_float(void ** xpp,size_t nelems,const float * tp,void * fillp)20125 ncx_putn_ushort_float(void **xpp, size_t nelems, const float *tp, void *fillp)
20126 #line 3259
20127 {
20128 #line 3259
20129 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
20130 #line 3259
20131 
20132 #line 3259
20133  /* basic algorithm is:
20134 #line 3259
20135   *   - ensure sane alignment of output data
20136 #line 3259
20137   *   - copy (conversion happens automatically) input data
20138 #line 3259
20139   *     to output
20140 #line 3259
20141   *   - update tp to point at next unconverted input, and xpp to point
20142 #line 3259
20143   *     at next location for converted output
20144 #line 3259
20145   */
20146 #line 3259
20147   long i, j, ni;
20148 #line 3259
20149   ushort tmp[LOOPCNT];        /* in case input is misaligned */
20150 #line 3259
20151   ushort *xp;
20152 #line 3259
20153   int nrange = 0;         /* number of range errors */
20154 #line 3259
20155   int realign = 0;        /* "do we need to fix input data alignment?" */
20156 #line 3259
20157   long cxp = (long) *((char**)xpp);
20158 #line 3259
20159 
20160 #line 3259
20161   realign = (cxp & 7) % SIZEOF_USHORT;
20162 #line 3259
20163   /* sjl: manually stripmine so we can limit amount of
20164 #line 3259
20165    * vector work space reserved to LOOPCNT elements. Also
20166 #line 3259
20167    * makes vectorisation easy */
20168 #line 3259
20169   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
20170 #line 3259
20171     ni=Min(nelems-j,LOOPCNT);
20172 #line 3259
20173     if (realign) {
20174 #line 3259
20175       xp = tmp;
20176 #line 3259
20177     } else {
20178 #line 3259
20179       xp = (ushort *) *xpp;
20180 #line 3259
20181     }
20182 #line 3259
20183    /* copy the next block */
20184 #line 3259
20185 #pragma cdir loopcnt=LOOPCNT
20186 #line 3259
20187 #pragma cdir shortloop
20188 #line 3259
20189     for (i=0; i<ni; i++) {
20190 #line 3259
20191       /* the normal case: */
20192 #line 3259
20193       xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
20194 #line 3259
20195      /* test for range errors (not always needed but do it anyway) */
20196 #line 3259
20197      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
20198 #line 3259
20199      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
20200 #line 3259
20201       nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
20202 #line 3259
20203     }
20204 #line 3259
20205    /* copy workspace back if necessary */
20206 #line 3259
20207     if (realign) {
20208 #line 3259
20209       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
20210 #line 3259
20211       xp = (ushort *) *xpp;
20212 #line 3259
20213     }
20214 #line 3259
20215    /* update xpp and tp */
20216 #line 3259
20217     xp += ni;
20218 #line 3259
20219     tp += ni;
20220 #line 3259
20221     *xpp = (void*)xp;
20222 #line 3259
20223   }
20224 #line 3259
20225   return nrange == 0 ? NC_NOERR : NC_ERANGE;
20226 #line 3259
20227 
20228 #line 3259
20229 #else   /* not SX */
20230 #line 3259
20231 
20232 #line 3259
20233 	char *xp = (char *) *xpp;
20234 #line 3259
20235 	int status = NC_NOERR;
20236 #line 3259
20237 
20238 #line 3259
20239 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
20240 #line 3259
20241 	{
20242 #line 3259
20243 		int lstatus = ncx_put_ushort_float(xp, tp, fillp);
20244 #line 3259
20245 		if (status == NC_NOERR) /* report the first encountered error */
20246 #line 3259
20247 			status = lstatus;
20248 #line 3259
20249 	}
20250 #line 3259
20251 
20252 #line 3259
20253 	*xpp = (void *)xp;
20254 #line 3259
20255 	return status;
20256 #line 3259
20257 #endif
20258 #line 3259
20259 }
20260 #line 3259
20261 
20262 int
20263 #line 3260
ncx_putn_ushort_double(void ** xpp,size_t nelems,const double * tp,void * fillp)20264 ncx_putn_ushort_double(void **xpp, size_t nelems, const double *tp, void *fillp)
20265 #line 3260
20266 {
20267 #line 3260
20268 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
20269 #line 3260
20270 
20271 #line 3260
20272  /* basic algorithm is:
20273 #line 3260
20274   *   - ensure sane alignment of output data
20275 #line 3260
20276   *   - copy (conversion happens automatically) input data
20277 #line 3260
20278   *     to output
20279 #line 3260
20280   *   - update tp to point at next unconverted input, and xpp to point
20281 #line 3260
20282   *     at next location for converted output
20283 #line 3260
20284   */
20285 #line 3260
20286   long i, j, ni;
20287 #line 3260
20288   ushort tmp[LOOPCNT];        /* in case input is misaligned */
20289 #line 3260
20290   ushort *xp;
20291 #line 3260
20292   int nrange = 0;         /* number of range errors */
20293 #line 3260
20294   int realign = 0;        /* "do we need to fix input data alignment?" */
20295 #line 3260
20296   long cxp = (long) *((char**)xpp);
20297 #line 3260
20298 
20299 #line 3260
20300   realign = (cxp & 7) % SIZEOF_USHORT;
20301 #line 3260
20302   /* sjl: manually stripmine so we can limit amount of
20303 #line 3260
20304    * vector work space reserved to LOOPCNT elements. Also
20305 #line 3260
20306    * makes vectorisation easy */
20307 #line 3260
20308   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
20309 #line 3260
20310     ni=Min(nelems-j,LOOPCNT);
20311 #line 3260
20312     if (realign) {
20313 #line 3260
20314       xp = tmp;
20315 #line 3260
20316     } else {
20317 #line 3260
20318       xp = (ushort *) *xpp;
20319 #line 3260
20320     }
20321 #line 3260
20322    /* copy the next block */
20323 #line 3260
20324 #pragma cdir loopcnt=LOOPCNT
20325 #line 3260
20326 #pragma cdir shortloop
20327 #line 3260
20328     for (i=0; i<ni; i++) {
20329 #line 3260
20330       /* the normal case: */
20331 #line 3260
20332       xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
20333 #line 3260
20334      /* test for range errors (not always needed but do it anyway) */
20335 #line 3260
20336      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
20337 #line 3260
20338      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
20339 #line 3260
20340       nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
20341 #line 3260
20342     }
20343 #line 3260
20344    /* copy workspace back if necessary */
20345 #line 3260
20346     if (realign) {
20347 #line 3260
20348       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
20349 #line 3260
20350       xp = (ushort *) *xpp;
20351 #line 3260
20352     }
20353 #line 3260
20354    /* update xpp and tp */
20355 #line 3260
20356     xp += ni;
20357 #line 3260
20358     tp += ni;
20359 #line 3260
20360     *xpp = (void*)xp;
20361 #line 3260
20362   }
20363 #line 3260
20364   return nrange == 0 ? NC_NOERR : NC_ERANGE;
20365 #line 3260
20366 
20367 #line 3260
20368 #else   /* not SX */
20369 #line 3260
20370 
20371 #line 3260
20372 	char *xp = (char *) *xpp;
20373 #line 3260
20374 	int status = NC_NOERR;
20375 #line 3260
20376 
20377 #line 3260
20378 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
20379 #line 3260
20380 	{
20381 #line 3260
20382 		int lstatus = ncx_put_ushort_double(xp, tp, fillp);
20383 #line 3260
20384 		if (status == NC_NOERR) /* report the first encountered error */
20385 #line 3260
20386 			status = lstatus;
20387 #line 3260
20388 	}
20389 #line 3260
20390 
20391 #line 3260
20392 	*xpp = (void *)xp;
20393 #line 3260
20394 	return status;
20395 #line 3260
20396 #endif
20397 #line 3260
20398 }
20399 #line 3260
20400 
20401 int
20402 #line 3261
ncx_putn_ushort_longlong(void ** xpp,size_t nelems,const longlong * tp,void * fillp)20403 ncx_putn_ushort_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
20404 #line 3261
20405 {
20406 #line 3261
20407 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
20408 #line 3261
20409 
20410 #line 3261
20411  /* basic algorithm is:
20412 #line 3261
20413   *   - ensure sane alignment of output data
20414 #line 3261
20415   *   - copy (conversion happens automatically) input data
20416 #line 3261
20417   *     to output
20418 #line 3261
20419   *   - update tp to point at next unconverted input, and xpp to point
20420 #line 3261
20421   *     at next location for converted output
20422 #line 3261
20423   */
20424 #line 3261
20425   long i, j, ni;
20426 #line 3261
20427   ushort tmp[LOOPCNT];        /* in case input is misaligned */
20428 #line 3261
20429   ushort *xp;
20430 #line 3261
20431   int nrange = 0;         /* number of range errors */
20432 #line 3261
20433   int realign = 0;        /* "do we need to fix input data alignment?" */
20434 #line 3261
20435   long cxp = (long) *((char**)xpp);
20436 #line 3261
20437 
20438 #line 3261
20439   realign = (cxp & 7) % SIZEOF_USHORT;
20440 #line 3261
20441   /* sjl: manually stripmine so we can limit amount of
20442 #line 3261
20443    * vector work space reserved to LOOPCNT elements. Also
20444 #line 3261
20445    * makes vectorisation easy */
20446 #line 3261
20447   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
20448 #line 3261
20449     ni=Min(nelems-j,LOOPCNT);
20450 #line 3261
20451     if (realign) {
20452 #line 3261
20453       xp = tmp;
20454 #line 3261
20455     } else {
20456 #line 3261
20457       xp = (ushort *) *xpp;
20458 #line 3261
20459     }
20460 #line 3261
20461    /* copy the next block */
20462 #line 3261
20463 #pragma cdir loopcnt=LOOPCNT
20464 #line 3261
20465 #pragma cdir shortloop
20466 #line 3261
20467     for (i=0; i<ni; i++) {
20468 #line 3261
20469       /* the normal case: */
20470 #line 3261
20471       xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
20472 #line 3261
20473      /* test for range errors (not always needed but do it anyway) */
20474 #line 3261
20475      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
20476 #line 3261
20477      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
20478 #line 3261
20479       nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
20480 #line 3261
20481     }
20482 #line 3261
20483    /* copy workspace back if necessary */
20484 #line 3261
20485     if (realign) {
20486 #line 3261
20487       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
20488 #line 3261
20489       xp = (ushort *) *xpp;
20490 #line 3261
20491     }
20492 #line 3261
20493    /* update xpp and tp */
20494 #line 3261
20495     xp += ni;
20496 #line 3261
20497     tp += ni;
20498 #line 3261
20499     *xpp = (void*)xp;
20500 #line 3261
20501   }
20502 #line 3261
20503   return nrange == 0 ? NC_NOERR : NC_ERANGE;
20504 #line 3261
20505 
20506 #line 3261
20507 #else   /* not SX */
20508 #line 3261
20509 
20510 #line 3261
20511 	char *xp = (char *) *xpp;
20512 #line 3261
20513 	int status = NC_NOERR;
20514 #line 3261
20515 
20516 #line 3261
20517 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
20518 #line 3261
20519 	{
20520 #line 3261
20521 		int lstatus = ncx_put_ushort_longlong(xp, tp, fillp);
20522 #line 3261
20523 		if (status == NC_NOERR) /* report the first encountered error */
20524 #line 3261
20525 			status = lstatus;
20526 #line 3261
20527 	}
20528 #line 3261
20529 
20530 #line 3261
20531 	*xpp = (void *)xp;
20532 #line 3261
20533 	return status;
20534 #line 3261
20535 #endif
20536 #line 3261
20537 }
20538 #line 3261
20539 
20540 int
20541 #line 3262
ncx_putn_ushort_uchar(void ** xpp,size_t nelems,const uchar * tp,void * fillp)20542 ncx_putn_ushort_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
20543 #line 3262
20544 {
20545 #line 3262
20546 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
20547 #line 3262
20548 
20549 #line 3262
20550  /* basic algorithm is:
20551 #line 3262
20552   *   - ensure sane alignment of output data
20553 #line 3262
20554   *   - copy (conversion happens automatically) input data
20555 #line 3262
20556   *     to output
20557 #line 3262
20558   *   - update tp to point at next unconverted input, and xpp to point
20559 #line 3262
20560   *     at next location for converted output
20561 #line 3262
20562   */
20563 #line 3262
20564   long i, j, ni;
20565 #line 3262
20566   ushort tmp[LOOPCNT];        /* in case input is misaligned */
20567 #line 3262
20568   ushort *xp;
20569 #line 3262
20570   int nrange = 0;         /* number of range errors */
20571 #line 3262
20572   int realign = 0;        /* "do we need to fix input data alignment?" */
20573 #line 3262
20574   long cxp = (long) *((char**)xpp);
20575 #line 3262
20576 
20577 #line 3262
20578   realign = (cxp & 7) % SIZEOF_USHORT;
20579 #line 3262
20580   /* sjl: manually stripmine so we can limit amount of
20581 #line 3262
20582    * vector work space reserved to LOOPCNT elements. Also
20583 #line 3262
20584    * makes vectorisation easy */
20585 #line 3262
20586   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
20587 #line 3262
20588     ni=Min(nelems-j,LOOPCNT);
20589 #line 3262
20590     if (realign) {
20591 #line 3262
20592       xp = tmp;
20593 #line 3262
20594     } else {
20595 #line 3262
20596       xp = (ushort *) *xpp;
20597 #line 3262
20598     }
20599 #line 3262
20600    /* copy the next block */
20601 #line 3262
20602 #pragma cdir loopcnt=LOOPCNT
20603 #line 3262
20604 #pragma cdir shortloop
20605 #line 3262
20606     for (i=0; i<ni; i++) {
20607 #line 3262
20608       /* the normal case: */
20609 #line 3262
20610       xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
20611 #line 3262
20612      /* test for range errors (not always needed but do it anyway) */
20613 #line 3262
20614      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
20615 #line 3262
20616      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
20617 #line 3262
20618       nrange += tp[i] > X_USHORT_MAX ;
20619 #line 3262
20620     }
20621 #line 3262
20622    /* copy workspace back if necessary */
20623 #line 3262
20624     if (realign) {
20625 #line 3262
20626       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
20627 #line 3262
20628       xp = (ushort *) *xpp;
20629 #line 3262
20630     }
20631 #line 3262
20632    /* update xpp and tp */
20633 #line 3262
20634     xp += ni;
20635 #line 3262
20636     tp += ni;
20637 #line 3262
20638     *xpp = (void*)xp;
20639 #line 3262
20640   }
20641 #line 3262
20642   return nrange == 0 ? NC_NOERR : NC_ERANGE;
20643 #line 3262
20644 
20645 #line 3262
20646 #else   /* not SX */
20647 #line 3262
20648 
20649 #line 3262
20650 	char *xp = (char *) *xpp;
20651 #line 3262
20652 	int status = NC_NOERR;
20653 #line 3262
20654 
20655 #line 3262
20656 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
20657 #line 3262
20658 	{
20659 #line 3262
20660 		int lstatus = ncx_put_ushort_uchar(xp, tp, fillp);
20661 #line 3262
20662 		if (status == NC_NOERR) /* report the first encountered error */
20663 #line 3262
20664 			status = lstatus;
20665 #line 3262
20666 	}
20667 #line 3262
20668 
20669 #line 3262
20670 	*xpp = (void *)xp;
20671 #line 3262
20672 	return status;
20673 #line 3262
20674 #endif
20675 #line 3262
20676 }
20677 #line 3262
20678 
20679 int
20680 #line 3263
ncx_putn_ushort_uint(void ** xpp,size_t nelems,const uint * tp,void * fillp)20681 ncx_putn_ushort_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
20682 #line 3263
20683 {
20684 #line 3263
20685 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
20686 #line 3263
20687 
20688 #line 3263
20689  /* basic algorithm is:
20690 #line 3263
20691   *   - ensure sane alignment of output data
20692 #line 3263
20693   *   - copy (conversion happens automatically) input data
20694 #line 3263
20695   *     to output
20696 #line 3263
20697   *   - update tp to point at next unconverted input, and xpp to point
20698 #line 3263
20699   *     at next location for converted output
20700 #line 3263
20701   */
20702 #line 3263
20703   long i, j, ni;
20704 #line 3263
20705   ushort tmp[LOOPCNT];        /* in case input is misaligned */
20706 #line 3263
20707   ushort *xp;
20708 #line 3263
20709   int nrange = 0;         /* number of range errors */
20710 #line 3263
20711   int realign = 0;        /* "do we need to fix input data alignment?" */
20712 #line 3263
20713   long cxp = (long) *((char**)xpp);
20714 #line 3263
20715 
20716 #line 3263
20717   realign = (cxp & 7) % SIZEOF_USHORT;
20718 #line 3263
20719   /* sjl: manually stripmine so we can limit amount of
20720 #line 3263
20721    * vector work space reserved to LOOPCNT elements. Also
20722 #line 3263
20723    * makes vectorisation easy */
20724 #line 3263
20725   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
20726 #line 3263
20727     ni=Min(nelems-j,LOOPCNT);
20728 #line 3263
20729     if (realign) {
20730 #line 3263
20731       xp = tmp;
20732 #line 3263
20733     } else {
20734 #line 3263
20735       xp = (ushort *) *xpp;
20736 #line 3263
20737     }
20738 #line 3263
20739    /* copy the next block */
20740 #line 3263
20741 #pragma cdir loopcnt=LOOPCNT
20742 #line 3263
20743 #pragma cdir shortloop
20744 #line 3263
20745     for (i=0; i<ni; i++) {
20746 #line 3263
20747       /* the normal case: */
20748 #line 3263
20749       xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
20750 #line 3263
20751      /* test for range errors (not always needed but do it anyway) */
20752 #line 3263
20753      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
20754 #line 3263
20755      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
20756 #line 3263
20757       nrange += tp[i] > X_USHORT_MAX ;
20758 #line 3263
20759     }
20760 #line 3263
20761    /* copy workspace back if necessary */
20762 #line 3263
20763     if (realign) {
20764 #line 3263
20765       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
20766 #line 3263
20767       xp = (ushort *) *xpp;
20768 #line 3263
20769     }
20770 #line 3263
20771    /* update xpp and tp */
20772 #line 3263
20773     xp += ni;
20774 #line 3263
20775     tp += ni;
20776 #line 3263
20777     *xpp = (void*)xp;
20778 #line 3263
20779   }
20780 #line 3263
20781   return nrange == 0 ? NC_NOERR : NC_ERANGE;
20782 #line 3263
20783 
20784 #line 3263
20785 #else   /* not SX */
20786 #line 3263
20787 
20788 #line 3263
20789 	char *xp = (char *) *xpp;
20790 #line 3263
20791 	int status = NC_NOERR;
20792 #line 3263
20793 
20794 #line 3263
20795 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
20796 #line 3263
20797 	{
20798 #line 3263
20799 		int lstatus = ncx_put_ushort_uint(xp, tp, fillp);
20800 #line 3263
20801 		if (status == NC_NOERR) /* report the first encountered error */
20802 #line 3263
20803 			status = lstatus;
20804 #line 3263
20805 	}
20806 #line 3263
20807 
20808 #line 3263
20809 	*xpp = (void *)xp;
20810 #line 3263
20811 	return status;
20812 #line 3263
20813 #endif
20814 #line 3263
20815 }
20816 #line 3263
20817 
20818 int
20819 #line 3264
ncx_putn_ushort_ulonglong(void ** xpp,size_t nelems,const ulonglong * tp,void * fillp)20820 ncx_putn_ushort_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
20821 #line 3264
20822 {
20823 #line 3264
20824 #if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
20825 #line 3264
20826 
20827 #line 3264
20828  /* basic algorithm is:
20829 #line 3264
20830   *   - ensure sane alignment of output data
20831 #line 3264
20832   *   - copy (conversion happens automatically) input data
20833 #line 3264
20834   *     to output
20835 #line 3264
20836   *   - update tp to point at next unconverted input, and xpp to point
20837 #line 3264
20838   *     at next location for converted output
20839 #line 3264
20840   */
20841 #line 3264
20842   long i, j, ni;
20843 #line 3264
20844   ushort tmp[LOOPCNT];        /* in case input is misaligned */
20845 #line 3264
20846   ushort *xp;
20847 #line 3264
20848   int nrange = 0;         /* number of range errors */
20849 #line 3264
20850   int realign = 0;        /* "do we need to fix input data alignment?" */
20851 #line 3264
20852   long cxp = (long) *((char**)xpp);
20853 #line 3264
20854 
20855 #line 3264
20856   realign = (cxp & 7) % SIZEOF_USHORT;
20857 #line 3264
20858   /* sjl: manually stripmine so we can limit amount of
20859 #line 3264
20860    * vector work space reserved to LOOPCNT elements. Also
20861 #line 3264
20862    * makes vectorisation easy */
20863 #line 3264
20864   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
20865 #line 3264
20866     ni=Min(nelems-j,LOOPCNT);
20867 #line 3264
20868     if (realign) {
20869 #line 3264
20870       xp = tmp;
20871 #line 3264
20872     } else {
20873 #line 3264
20874       xp = (ushort *) *xpp;
20875 #line 3264
20876     }
20877 #line 3264
20878    /* copy the next block */
20879 #line 3264
20880 #pragma cdir loopcnt=LOOPCNT
20881 #line 3264
20882 #pragma cdir shortloop
20883 #line 3264
20884     for (i=0; i<ni; i++) {
20885 #line 3264
20886       /* the normal case: */
20887 #line 3264
20888       xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
20889 #line 3264
20890      /* test for range errors (not always needed but do it anyway) */
20891 #line 3264
20892      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
20893 #line 3264
20894      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
20895 #line 3264
20896       nrange += tp[i] > X_USHORT_MAX ;
20897 #line 3264
20898     }
20899 #line 3264
20900    /* copy workspace back if necessary */
20901 #line 3264
20902     if (realign) {
20903 #line 3264
20904       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
20905 #line 3264
20906       xp = (ushort *) *xpp;
20907 #line 3264
20908     }
20909 #line 3264
20910    /* update xpp and tp */
20911 #line 3264
20912     xp += ni;
20913 #line 3264
20914     tp += ni;
20915 #line 3264
20916     *xpp = (void*)xp;
20917 #line 3264
20918   }
20919 #line 3264
20920   return nrange == 0 ? NC_NOERR : NC_ERANGE;
20921 #line 3264
20922 
20923 #line 3264
20924 #else   /* not SX */
20925 #line 3264
20926 
20927 #line 3264
20928 	char *xp = (char *) *xpp;
20929 #line 3264
20930 	int status = NC_NOERR;
20931 #line 3264
20932 
20933 #line 3264
20934 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
20935 #line 3264
20936 	{
20937 #line 3264
20938 		int lstatus = ncx_put_ushort_ulonglong(xp, tp, fillp);
20939 #line 3264
20940 		if (status == NC_NOERR) /* report the first encountered error */
20941 #line 3264
20942 			status = lstatus;
20943 #line 3264
20944 	}
20945 #line 3264
20946 
20947 #line 3264
20948 	*xpp = (void *)xp;
20949 #line 3264
20950 	return status;
20951 #line 3264
20952 #endif
20953 #line 3264
20954 }
20955 #line 3264
20956 
20957 
20958 int
20959 #line 3266
ncx_pad_putn_ushort_schar(void ** xpp,size_t nelems,const schar * tp,void * fillp)20960 ncx_pad_putn_ushort_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
20961 #line 3266
20962 {
20963 #line 3266
20964 	const size_t rndup = nelems % X_SIZEOF_SHORT;
20965 #line 3266
20966 
20967 #line 3266
20968 	char *xp = (char *) *xpp;
20969 #line 3266
20970 	int status = NC_NOERR;
20971 #line 3266
20972 
20973 #line 3266
20974 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
20975 #line 3266
20976 	{
20977 #line 3266
20978 		int lstatus = ncx_put_ushort_schar(xp, tp, fillp);
20979 #line 3266
20980 		if (status == NC_NOERR) /* report the first encountered error */
20981 #line 3266
20982 			status = lstatus;
20983 #line 3266
20984 	}
20985 #line 3266
20986 
20987 #line 3266
20988 	if (rndup != 0)
20989 #line 3266
20990 	{
20991 #line 3266
20992 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
20993 #line 3266
20994 		xp += X_SIZEOF_USHORT;
20995 #line 3266
20996 	}
20997 #line 3266
20998 
20999 #line 3266
21000 	*xpp = (void *)xp;
21001 #line 3266
21002 	return status;
21003 #line 3266
21004 }
21005 #line 3266
21006 
21007 int
21008 #line 3267
ncx_pad_putn_ushort_uchar(void ** xpp,size_t nelems,const uchar * tp,void * fillp)21009 ncx_pad_putn_ushort_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
21010 #line 3267
21011 {
21012 #line 3267
21013 	const size_t rndup = nelems % X_SIZEOF_SHORT;
21014 #line 3267
21015 
21016 #line 3267
21017 	char *xp = (char *) *xpp;
21018 #line 3267
21019 	int status = NC_NOERR;
21020 #line 3267
21021 
21022 #line 3267
21023 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
21024 #line 3267
21025 	{
21026 #line 3267
21027 		int lstatus = ncx_put_ushort_uchar(xp, tp, fillp);
21028 #line 3267
21029 		if (status == NC_NOERR) /* report the first encountered error */
21030 #line 3267
21031 			status = lstatus;
21032 #line 3267
21033 	}
21034 #line 3267
21035 
21036 #line 3267
21037 	if (rndup != 0)
21038 #line 3267
21039 	{
21040 #line 3267
21041 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
21042 #line 3267
21043 		xp += X_SIZEOF_USHORT;
21044 #line 3267
21045 	}
21046 #line 3267
21047 
21048 #line 3267
21049 	*xpp = (void *)xp;
21050 #line 3267
21051 	return status;
21052 #line 3267
21053 }
21054 #line 3267
21055 
21056 int
21057 #line 3268
ncx_pad_putn_ushort_short(void ** xpp,size_t nelems,const short * tp,void * fillp)21058 ncx_pad_putn_ushort_short(void **xpp, size_t nelems, const short *tp, void *fillp)
21059 #line 3268
21060 {
21061 #line 3268
21062 	const size_t rndup = nelems % X_SIZEOF_SHORT;
21063 #line 3268
21064 
21065 #line 3268
21066 	char *xp = (char *) *xpp;
21067 #line 3268
21068 	int status = NC_NOERR;
21069 #line 3268
21070 
21071 #line 3268
21072 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
21073 #line 3268
21074 	{
21075 #line 3268
21076 		int lstatus = ncx_put_ushort_short(xp, tp, fillp);
21077 #line 3268
21078 		if (status == NC_NOERR) /* report the first encountered error */
21079 #line 3268
21080 			status = lstatus;
21081 #line 3268
21082 	}
21083 #line 3268
21084 
21085 #line 3268
21086 	if (rndup != 0)
21087 #line 3268
21088 	{
21089 #line 3268
21090 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
21091 #line 3268
21092 		xp += X_SIZEOF_USHORT;
21093 #line 3268
21094 	}
21095 #line 3268
21096 
21097 #line 3268
21098 	*xpp = (void *)xp;
21099 #line 3268
21100 	return status;
21101 #line 3268
21102 }
21103 #line 3268
21104 
21105 int
21106 #line 3269
ncx_pad_putn_ushort_int(void ** xpp,size_t nelems,const int * tp,void * fillp)21107 ncx_pad_putn_ushort_int(void **xpp, size_t nelems, const int *tp, void *fillp)
21108 #line 3269
21109 {
21110 #line 3269
21111 	const size_t rndup = nelems % X_SIZEOF_SHORT;
21112 #line 3269
21113 
21114 #line 3269
21115 	char *xp = (char *) *xpp;
21116 #line 3269
21117 	int status = NC_NOERR;
21118 #line 3269
21119 
21120 #line 3269
21121 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
21122 #line 3269
21123 	{
21124 #line 3269
21125 		int lstatus = ncx_put_ushort_int(xp, tp, fillp);
21126 #line 3269
21127 		if (status == NC_NOERR) /* report the first encountered error */
21128 #line 3269
21129 			status = lstatus;
21130 #line 3269
21131 	}
21132 #line 3269
21133 
21134 #line 3269
21135 	if (rndup != 0)
21136 #line 3269
21137 	{
21138 #line 3269
21139 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
21140 #line 3269
21141 		xp += X_SIZEOF_USHORT;
21142 #line 3269
21143 	}
21144 #line 3269
21145 
21146 #line 3269
21147 	*xpp = (void *)xp;
21148 #line 3269
21149 	return status;
21150 #line 3269
21151 }
21152 #line 3269
21153 
21154 int
21155 #line 3270
ncx_pad_putn_ushort_long(void ** xpp,size_t nelems,const long * tp,void * fillp)21156 ncx_pad_putn_ushort_long(void **xpp, size_t nelems, const long *tp, void *fillp)
21157 #line 3270
21158 {
21159 #line 3270
21160 	const size_t rndup = nelems % X_SIZEOF_SHORT;
21161 #line 3270
21162 
21163 #line 3270
21164 	char *xp = (char *) *xpp;
21165 #line 3270
21166 	int status = NC_NOERR;
21167 #line 3270
21168 
21169 #line 3270
21170 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
21171 #line 3270
21172 	{
21173 #line 3270
21174 		int lstatus = ncx_put_ushort_long(xp, tp, fillp);
21175 #line 3270
21176 		if (status == NC_NOERR) /* report the first encountered error */
21177 #line 3270
21178 			status = lstatus;
21179 #line 3270
21180 	}
21181 #line 3270
21182 
21183 #line 3270
21184 	if (rndup != 0)
21185 #line 3270
21186 	{
21187 #line 3270
21188 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
21189 #line 3270
21190 		xp += X_SIZEOF_USHORT;
21191 #line 3270
21192 	}
21193 #line 3270
21194 
21195 #line 3270
21196 	*xpp = (void *)xp;
21197 #line 3270
21198 	return status;
21199 #line 3270
21200 }
21201 #line 3270
21202 
21203 int
21204 #line 3271
ncx_pad_putn_ushort_float(void ** xpp,size_t nelems,const float * tp,void * fillp)21205 ncx_pad_putn_ushort_float(void **xpp, size_t nelems, const float *tp, void *fillp)
21206 #line 3271
21207 {
21208 #line 3271
21209 	const size_t rndup = nelems % X_SIZEOF_SHORT;
21210 #line 3271
21211 
21212 #line 3271
21213 	char *xp = (char *) *xpp;
21214 #line 3271
21215 	int status = NC_NOERR;
21216 #line 3271
21217 
21218 #line 3271
21219 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
21220 #line 3271
21221 	{
21222 #line 3271
21223 		int lstatus = ncx_put_ushort_float(xp, tp, fillp);
21224 #line 3271
21225 		if (status == NC_NOERR) /* report the first encountered error */
21226 #line 3271
21227 			status = lstatus;
21228 #line 3271
21229 	}
21230 #line 3271
21231 
21232 #line 3271
21233 	if (rndup != 0)
21234 #line 3271
21235 	{
21236 #line 3271
21237 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
21238 #line 3271
21239 		xp += X_SIZEOF_USHORT;
21240 #line 3271
21241 	}
21242 #line 3271
21243 
21244 #line 3271
21245 	*xpp = (void *)xp;
21246 #line 3271
21247 	return status;
21248 #line 3271
21249 }
21250 #line 3271
21251 
21252 int
21253 #line 3272
ncx_pad_putn_ushort_double(void ** xpp,size_t nelems,const double * tp,void * fillp)21254 ncx_pad_putn_ushort_double(void **xpp, size_t nelems, const double *tp, void *fillp)
21255 #line 3272
21256 {
21257 #line 3272
21258 	const size_t rndup = nelems % X_SIZEOF_SHORT;
21259 #line 3272
21260 
21261 #line 3272
21262 	char *xp = (char *) *xpp;
21263 #line 3272
21264 	int status = NC_NOERR;
21265 #line 3272
21266 
21267 #line 3272
21268 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
21269 #line 3272
21270 	{
21271 #line 3272
21272 		int lstatus = ncx_put_ushort_double(xp, tp, fillp);
21273 #line 3272
21274 		if (status == NC_NOERR) /* report the first encountered error */
21275 #line 3272
21276 			status = lstatus;
21277 #line 3272
21278 	}
21279 #line 3272
21280 
21281 #line 3272
21282 	if (rndup != 0)
21283 #line 3272
21284 	{
21285 #line 3272
21286 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
21287 #line 3272
21288 		xp += X_SIZEOF_USHORT;
21289 #line 3272
21290 	}
21291 #line 3272
21292 
21293 #line 3272
21294 	*xpp = (void *)xp;
21295 #line 3272
21296 	return status;
21297 #line 3272
21298 }
21299 #line 3272
21300 
21301 int
21302 #line 3273
ncx_pad_putn_ushort_uint(void ** xpp,size_t nelems,const uint * tp,void * fillp)21303 ncx_pad_putn_ushort_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
21304 #line 3273
21305 {
21306 #line 3273
21307 	const size_t rndup = nelems % X_SIZEOF_SHORT;
21308 #line 3273
21309 
21310 #line 3273
21311 	char *xp = (char *) *xpp;
21312 #line 3273
21313 	int status = NC_NOERR;
21314 #line 3273
21315 
21316 #line 3273
21317 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
21318 #line 3273
21319 	{
21320 #line 3273
21321 		int lstatus = ncx_put_ushort_uint(xp, tp, fillp);
21322 #line 3273
21323 		if (status == NC_NOERR) /* report the first encountered error */
21324 #line 3273
21325 			status = lstatus;
21326 #line 3273
21327 	}
21328 #line 3273
21329 
21330 #line 3273
21331 	if (rndup != 0)
21332 #line 3273
21333 	{
21334 #line 3273
21335 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
21336 #line 3273
21337 		xp += X_SIZEOF_USHORT;
21338 #line 3273
21339 	}
21340 #line 3273
21341 
21342 #line 3273
21343 	*xpp = (void *)xp;
21344 #line 3273
21345 	return status;
21346 #line 3273
21347 }
21348 #line 3273
21349 
21350 int
21351 #line 3274
ncx_pad_putn_ushort_longlong(void ** xpp,size_t nelems,const longlong * tp,void * fillp)21352 ncx_pad_putn_ushort_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
21353 #line 3274
21354 {
21355 #line 3274
21356 	const size_t rndup = nelems % X_SIZEOF_SHORT;
21357 #line 3274
21358 
21359 #line 3274
21360 	char *xp = (char *) *xpp;
21361 #line 3274
21362 	int status = NC_NOERR;
21363 #line 3274
21364 
21365 #line 3274
21366 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
21367 #line 3274
21368 	{
21369 #line 3274
21370 		int lstatus = ncx_put_ushort_longlong(xp, tp, fillp);
21371 #line 3274
21372 		if (status == NC_NOERR) /* report the first encountered error */
21373 #line 3274
21374 			status = lstatus;
21375 #line 3274
21376 	}
21377 #line 3274
21378 
21379 #line 3274
21380 	if (rndup != 0)
21381 #line 3274
21382 	{
21383 #line 3274
21384 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
21385 #line 3274
21386 		xp += X_SIZEOF_USHORT;
21387 #line 3274
21388 	}
21389 #line 3274
21390 
21391 #line 3274
21392 	*xpp = (void *)xp;
21393 #line 3274
21394 	return status;
21395 #line 3274
21396 }
21397 #line 3274
21398 
21399 int
21400 #line 3275
ncx_pad_putn_ushort_ulonglong(void ** xpp,size_t nelems,const ulonglong * tp,void * fillp)21401 ncx_pad_putn_ushort_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
21402 #line 3275
21403 {
21404 #line 3275
21405 	const size_t rndup = nelems % X_SIZEOF_SHORT;
21406 #line 3275
21407 
21408 #line 3275
21409 	char *xp = (char *) *xpp;
21410 #line 3275
21411 	int status = NC_NOERR;
21412 #line 3275
21413 
21414 #line 3275
21415 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
21416 #line 3275
21417 	{
21418 #line 3275
21419 		int lstatus = ncx_put_ushort_ulonglong(xp, tp, fillp);
21420 #line 3275
21421 		if (status == NC_NOERR) /* report the first encountered error */
21422 #line 3275
21423 			status = lstatus;
21424 #line 3275
21425 	}
21426 #line 3275
21427 
21428 #line 3275
21429 	if (rndup != 0)
21430 #line 3275
21431 	{
21432 #line 3275
21433 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
21434 #line 3275
21435 		xp += X_SIZEOF_USHORT;
21436 #line 3275
21437 	}
21438 #line 3275
21439 
21440 #line 3275
21441 	*xpp = (void *)xp;
21442 #line 3275
21443 	return status;
21444 #line 3275
21445 }
21446 #line 3275
21447 
21448 int
21449 #line 3276
ncx_pad_putn_ushort_ushort(void ** xpp,size_t nelems,const ushort * tp,void * fillp)21450 ncx_pad_putn_ushort_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
21451 #line 3276
21452 {
21453 #line 3276
21454 	const size_t rndup = nelems % X_SIZEOF_SHORT;
21455 #line 3276
21456 
21457 #line 3276
21458 	char *xp = (char *) *xpp;
21459 #line 3276
21460 	int status = NC_NOERR;
21461 #line 3276
21462 
21463 #line 3276
21464 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
21465 #line 3276
21466 	{
21467 #line 3276
21468 		int lstatus = ncx_put_ushort_ushort(xp, tp, fillp);
21469 #line 3276
21470 		if (status == NC_NOERR) /* report the first encountered error */
21471 #line 3276
21472 			status = lstatus;
21473 #line 3276
21474 	}
21475 #line 3276
21476 
21477 #line 3276
21478 	if (rndup != 0)
21479 #line 3276
21480 	{
21481 #line 3276
21482 		(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
21483 #line 3276
21484 		xp += X_SIZEOF_USHORT;
21485 #line 3276
21486 	}
21487 #line 3276
21488 
21489 #line 3276
21490 	*xpp = (void *)xp;
21491 #line 3276
21492 	return status;
21493 #line 3276
21494 }
21495 #line 3276
21496 
21497 
21498 
21499 /* int -----------------------------------------------------------------------*/
21500 
21501 #if X_SIZEOF_INT == SIZEOF_INT
21502 /* optimized version */
21503 int
ncx_getn_int_int(const void ** xpp,size_t nelems,int * tp)21504 ncx_getn_int_int(const void **xpp, size_t nelems, int *tp)
21505 {
21506 #ifdef WORDS_BIGENDIAN
21507 	(void) memcpy(tp, *xpp, (size_t)nelems * SIZEOF_INT);
21508 # else
21509 	swapn4b(tp, *xpp, nelems);
21510 # endif
21511 	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_INT);
21512 	return NC_NOERR;
21513 }
21514 #else
21515 int
21516 #line 3295
ncx_getn_int_int(const void ** xpp,size_t nelems,int * tp)21517 ncx_getn_int_int(const void **xpp, size_t nelems, int *tp)
21518 #line 3295
21519 {
21520 #line 3295
21521 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
21522 #line 3295
21523 
21524 #line 3295
21525  /* basic algorithm is:
21526 #line 3295
21527   *   - ensure sane alignment of input data
21528 #line 3295
21529   *   - copy (conversion happens automatically) input data
21530 #line 3295
21531   *     to output
21532 #line 3295
21533   *   - update xpp to point at next unconverted input, and tp to point
21534 #line 3295
21535   *     at next location for converted output
21536 #line 3295
21537   */
21538 #line 3295
21539   long i, j, ni;
21540 #line 3295
21541   int tmp[LOOPCNT];        /* in case input is misaligned */
21542 #line 3295
21543   int *xp;
21544 #line 3295
21545   int nrange = 0;         /* number of range errors */
21546 #line 3295
21547   int realign = 0;        /* "do we need to fix input data alignment?" */
21548 #line 3295
21549   long cxp = (long) *((char**)xpp);
21550 #line 3295
21551 
21552 #line 3295
21553   realign = (cxp & 7) % SIZEOF_INT;
21554 #line 3295
21555   /* sjl: manually stripmine so we can limit amount of
21556 #line 3295
21557    * vector work space reserved to LOOPCNT elements. Also
21558 #line 3295
21559    * makes vectorisation easy */
21560 #line 3295
21561   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
21562 #line 3295
21563     ni=Min(nelems-j,LOOPCNT);
21564 #line 3295
21565     if (realign) {
21566 #line 3295
21567       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
21568 #line 3295
21569       xp = tmp;
21570 #line 3295
21571     } else {
21572 #line 3295
21573       xp = (int *) *xpp;
21574 #line 3295
21575     }
21576 #line 3295
21577    /* copy the next block */
21578 #line 3295
21579 #pragma cdir loopcnt=LOOPCNT
21580 #line 3295
21581 #pragma cdir shortloop
21582 #line 3295
21583     for (i=0; i<ni; i++) {
21584 #line 3295
21585       tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
21586 #line 3295
21587      /* test for range errors (not always needed but do it anyway) */
21588 #line 3295
21589      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
21590 #line 3295
21591      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
21592 #line 3295
21593       nrange += xp[i] > INT_MAX || xp[i] < INT_MIN;
21594 #line 3295
21595     }
21596 #line 3295
21597    /* update xpp and tp */
21598 #line 3295
21599     if (realign) xp = (int *) *xpp;
21600 #line 3295
21601     xp += ni;
21602 #line 3295
21603     tp += ni;
21604 #line 3295
21605     *xpp = (void*)xp;
21606 #line 3295
21607   }
21608 #line 3295
21609   return nrange == 0 ? NC_NOERR : NC_ERANGE;
21610 #line 3295
21611 
21612 #line 3295
21613 #else   /* not SX */
21614 #line 3295
21615 	const char *xp = (const char *) *xpp;
21616 #line 3295
21617 	int status = NC_NOERR;
21618 #line 3295
21619 
21620 #line 3295
21621 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
21622 #line 3295
21623 	{
21624 #line 3295
21625 		const int lstatus = ncx_get_int_int(xp, tp);
21626 #line 3295
21627 		if (status == NC_NOERR) /* report the first encountered error */
21628 #line 3295
21629 			status = lstatus;
21630 #line 3295
21631 	}
21632 #line 3295
21633 
21634 #line 3295
21635 	*xpp = (const void *)xp;
21636 #line 3295
21637 	return status;
21638 #line 3295
21639 #endif
21640 #line 3295
21641 }
21642 #line 3295
21643 
21644 #endif
21645 int
21646 #line 3297
ncx_getn_int_schar(const void ** xpp,size_t nelems,schar * tp)21647 ncx_getn_int_schar(const void **xpp, size_t nelems, schar *tp)
21648 #line 3297
21649 {
21650 #line 3297
21651 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
21652 #line 3297
21653 
21654 #line 3297
21655  /* basic algorithm is:
21656 #line 3297
21657   *   - ensure sane alignment of input data
21658 #line 3297
21659   *   - copy (conversion happens automatically) input data
21660 #line 3297
21661   *     to output
21662 #line 3297
21663   *   - update xpp to point at next unconverted input, and tp to point
21664 #line 3297
21665   *     at next location for converted output
21666 #line 3297
21667   */
21668 #line 3297
21669   long i, j, ni;
21670 #line 3297
21671   int tmp[LOOPCNT];        /* in case input is misaligned */
21672 #line 3297
21673   int *xp;
21674 #line 3297
21675   int nrange = 0;         /* number of range errors */
21676 #line 3297
21677   int realign = 0;        /* "do we need to fix input data alignment?" */
21678 #line 3297
21679   long cxp = (long) *((char**)xpp);
21680 #line 3297
21681 
21682 #line 3297
21683   realign = (cxp & 7) % SIZEOF_INT;
21684 #line 3297
21685   /* sjl: manually stripmine so we can limit amount of
21686 #line 3297
21687    * vector work space reserved to LOOPCNT elements. Also
21688 #line 3297
21689    * makes vectorisation easy */
21690 #line 3297
21691   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
21692 #line 3297
21693     ni=Min(nelems-j,LOOPCNT);
21694 #line 3297
21695     if (realign) {
21696 #line 3297
21697       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
21698 #line 3297
21699       xp = tmp;
21700 #line 3297
21701     } else {
21702 #line 3297
21703       xp = (int *) *xpp;
21704 #line 3297
21705     }
21706 #line 3297
21707    /* copy the next block */
21708 #line 3297
21709 #pragma cdir loopcnt=LOOPCNT
21710 #line 3297
21711 #pragma cdir shortloop
21712 #line 3297
21713     for (i=0; i<ni; i++) {
21714 #line 3297
21715       tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
21716 #line 3297
21717      /* test for range errors (not always needed but do it anyway) */
21718 #line 3297
21719      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
21720 #line 3297
21721      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
21722 #line 3297
21723       nrange += xp[i] > SCHAR_MAX || xp[i] < SCHAR_MIN;
21724 #line 3297
21725     }
21726 #line 3297
21727    /* update xpp and tp */
21728 #line 3297
21729     if (realign) xp = (int *) *xpp;
21730 #line 3297
21731     xp += ni;
21732 #line 3297
21733     tp += ni;
21734 #line 3297
21735     *xpp = (void*)xp;
21736 #line 3297
21737   }
21738 #line 3297
21739   return nrange == 0 ? NC_NOERR : NC_ERANGE;
21740 #line 3297
21741 
21742 #line 3297
21743 #else   /* not SX */
21744 #line 3297
21745 	const char *xp = (const char *) *xpp;
21746 #line 3297
21747 	int status = NC_NOERR;
21748 #line 3297
21749 
21750 #line 3297
21751 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
21752 #line 3297
21753 	{
21754 #line 3297
21755 		const int lstatus = ncx_get_int_schar(xp, tp);
21756 #line 3297
21757 		if (status == NC_NOERR) /* report the first encountered error */
21758 #line 3297
21759 			status = lstatus;
21760 #line 3297
21761 	}
21762 #line 3297
21763 
21764 #line 3297
21765 	*xpp = (const void *)xp;
21766 #line 3297
21767 	return status;
21768 #line 3297
21769 #endif
21770 #line 3297
21771 }
21772 #line 3297
21773 
21774 int
21775 #line 3298
ncx_getn_int_short(const void ** xpp,size_t nelems,short * tp)21776 ncx_getn_int_short(const void **xpp, size_t nelems, short *tp)
21777 #line 3298
21778 {
21779 #line 3298
21780 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
21781 #line 3298
21782 
21783 #line 3298
21784  /* basic algorithm is:
21785 #line 3298
21786   *   - ensure sane alignment of input data
21787 #line 3298
21788   *   - copy (conversion happens automatically) input data
21789 #line 3298
21790   *     to output
21791 #line 3298
21792   *   - update xpp to point at next unconverted input, and tp to point
21793 #line 3298
21794   *     at next location for converted output
21795 #line 3298
21796   */
21797 #line 3298
21798   long i, j, ni;
21799 #line 3298
21800   int tmp[LOOPCNT];        /* in case input is misaligned */
21801 #line 3298
21802   int *xp;
21803 #line 3298
21804   int nrange = 0;         /* number of range errors */
21805 #line 3298
21806   int realign = 0;        /* "do we need to fix input data alignment?" */
21807 #line 3298
21808   long cxp = (long) *((char**)xpp);
21809 #line 3298
21810 
21811 #line 3298
21812   realign = (cxp & 7) % SIZEOF_INT;
21813 #line 3298
21814   /* sjl: manually stripmine so we can limit amount of
21815 #line 3298
21816    * vector work space reserved to LOOPCNT elements. Also
21817 #line 3298
21818    * makes vectorisation easy */
21819 #line 3298
21820   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
21821 #line 3298
21822     ni=Min(nelems-j,LOOPCNT);
21823 #line 3298
21824     if (realign) {
21825 #line 3298
21826       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
21827 #line 3298
21828       xp = tmp;
21829 #line 3298
21830     } else {
21831 #line 3298
21832       xp = (int *) *xpp;
21833 #line 3298
21834     }
21835 #line 3298
21836    /* copy the next block */
21837 #line 3298
21838 #pragma cdir loopcnt=LOOPCNT
21839 #line 3298
21840 #pragma cdir shortloop
21841 #line 3298
21842     for (i=0; i<ni; i++) {
21843 #line 3298
21844       tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
21845 #line 3298
21846      /* test for range errors (not always needed but do it anyway) */
21847 #line 3298
21848      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
21849 #line 3298
21850      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
21851 #line 3298
21852       nrange += xp[i] > SHORT_MAX || xp[i] < SHORT_MIN;
21853 #line 3298
21854     }
21855 #line 3298
21856    /* update xpp and tp */
21857 #line 3298
21858     if (realign) xp = (int *) *xpp;
21859 #line 3298
21860     xp += ni;
21861 #line 3298
21862     tp += ni;
21863 #line 3298
21864     *xpp = (void*)xp;
21865 #line 3298
21866   }
21867 #line 3298
21868   return nrange == 0 ? NC_NOERR : NC_ERANGE;
21869 #line 3298
21870 
21871 #line 3298
21872 #else   /* not SX */
21873 #line 3298
21874 	const char *xp = (const char *) *xpp;
21875 #line 3298
21876 	int status = NC_NOERR;
21877 #line 3298
21878 
21879 #line 3298
21880 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
21881 #line 3298
21882 	{
21883 #line 3298
21884 		const int lstatus = ncx_get_int_short(xp, tp);
21885 #line 3298
21886 		if (status == NC_NOERR) /* report the first encountered error */
21887 #line 3298
21888 			status = lstatus;
21889 #line 3298
21890 	}
21891 #line 3298
21892 
21893 #line 3298
21894 	*xpp = (const void *)xp;
21895 #line 3298
21896 	return status;
21897 #line 3298
21898 #endif
21899 #line 3298
21900 }
21901 #line 3298
21902 
21903 int
21904 #line 3299
ncx_getn_int_long(const void ** xpp,size_t nelems,long * tp)21905 ncx_getn_int_long(const void **xpp, size_t nelems, long *tp)
21906 #line 3299
21907 {
21908 #line 3299
21909 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
21910 #line 3299
21911 
21912 #line 3299
21913  /* basic algorithm is:
21914 #line 3299
21915   *   - ensure sane alignment of input data
21916 #line 3299
21917   *   - copy (conversion happens automatically) input data
21918 #line 3299
21919   *     to output
21920 #line 3299
21921   *   - update xpp to point at next unconverted input, and tp to point
21922 #line 3299
21923   *     at next location for converted output
21924 #line 3299
21925   */
21926 #line 3299
21927   long i, j, ni;
21928 #line 3299
21929   int tmp[LOOPCNT];        /* in case input is misaligned */
21930 #line 3299
21931   int *xp;
21932 #line 3299
21933   int nrange = 0;         /* number of range errors */
21934 #line 3299
21935   int realign = 0;        /* "do we need to fix input data alignment?" */
21936 #line 3299
21937   long cxp = (long) *((char**)xpp);
21938 #line 3299
21939 
21940 #line 3299
21941   realign = (cxp & 7) % SIZEOF_INT;
21942 #line 3299
21943   /* sjl: manually stripmine so we can limit amount of
21944 #line 3299
21945    * vector work space reserved to LOOPCNT elements. Also
21946 #line 3299
21947    * makes vectorisation easy */
21948 #line 3299
21949   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
21950 #line 3299
21951     ni=Min(nelems-j,LOOPCNT);
21952 #line 3299
21953     if (realign) {
21954 #line 3299
21955       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
21956 #line 3299
21957       xp = tmp;
21958 #line 3299
21959     } else {
21960 #line 3299
21961       xp = (int *) *xpp;
21962 #line 3299
21963     }
21964 #line 3299
21965    /* copy the next block */
21966 #line 3299
21967 #pragma cdir loopcnt=LOOPCNT
21968 #line 3299
21969 #pragma cdir shortloop
21970 #line 3299
21971     for (i=0; i<ni; i++) {
21972 #line 3299
21973       tp[i] = (long) Max( LONG_MIN, Min(LONG_MAX, (long) xp[i]));
21974 #line 3299
21975      /* test for range errors (not always needed but do it anyway) */
21976 #line 3299
21977      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
21978 #line 3299
21979      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
21980 #line 3299
21981       nrange += xp[i] > LONG_MAX || xp[i] < LONG_MIN;
21982 #line 3299
21983     }
21984 #line 3299
21985    /* update xpp and tp */
21986 #line 3299
21987     if (realign) xp = (int *) *xpp;
21988 #line 3299
21989     xp += ni;
21990 #line 3299
21991     tp += ni;
21992 #line 3299
21993     *xpp = (void*)xp;
21994 #line 3299
21995   }
21996 #line 3299
21997   return nrange == 0 ? NC_NOERR : NC_ERANGE;
21998 #line 3299
21999 
22000 #line 3299
22001 #else   /* not SX */
22002 #line 3299
22003 	const char *xp = (const char *) *xpp;
22004 #line 3299
22005 	int status = NC_NOERR;
22006 #line 3299
22007 
22008 #line 3299
22009 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
22010 #line 3299
22011 	{
22012 #line 3299
22013 		const int lstatus = ncx_get_int_long(xp, tp);
22014 #line 3299
22015 		if (status == NC_NOERR) /* report the first encountered error */
22016 #line 3299
22017 			status = lstatus;
22018 #line 3299
22019 	}
22020 #line 3299
22021 
22022 #line 3299
22023 	*xpp = (const void *)xp;
22024 #line 3299
22025 	return status;
22026 #line 3299
22027 #endif
22028 #line 3299
22029 }
22030 #line 3299
22031 
22032 int
22033 #line 3300
ncx_getn_int_float(const void ** xpp,size_t nelems,float * tp)22034 ncx_getn_int_float(const void **xpp, size_t nelems, float *tp)
22035 #line 3300
22036 {
22037 #line 3300
22038 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
22039 #line 3300
22040 
22041 #line 3300
22042  /* basic algorithm is:
22043 #line 3300
22044   *   - ensure sane alignment of input data
22045 #line 3300
22046   *   - copy (conversion happens automatically) input data
22047 #line 3300
22048   *     to output
22049 #line 3300
22050   *   - update xpp to point at next unconverted input, and tp to point
22051 #line 3300
22052   *     at next location for converted output
22053 #line 3300
22054   */
22055 #line 3300
22056   long i, j, ni;
22057 #line 3300
22058   int tmp[LOOPCNT];        /* in case input is misaligned */
22059 #line 3300
22060   int *xp;
22061 #line 3300
22062   int nrange = 0;         /* number of range errors */
22063 #line 3300
22064   int realign = 0;        /* "do we need to fix input data alignment?" */
22065 #line 3300
22066   long cxp = (long) *((char**)xpp);
22067 #line 3300
22068 
22069 #line 3300
22070   realign = (cxp & 7) % SIZEOF_INT;
22071 #line 3300
22072   /* sjl: manually stripmine so we can limit amount of
22073 #line 3300
22074    * vector work space reserved to LOOPCNT elements. Also
22075 #line 3300
22076    * makes vectorisation easy */
22077 #line 3300
22078   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
22079 #line 3300
22080     ni=Min(nelems-j,LOOPCNT);
22081 #line 3300
22082     if (realign) {
22083 #line 3300
22084       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
22085 #line 3300
22086       xp = tmp;
22087 #line 3300
22088     } else {
22089 #line 3300
22090       xp = (int *) *xpp;
22091 #line 3300
22092     }
22093 #line 3300
22094    /* copy the next block */
22095 #line 3300
22096 #pragma cdir loopcnt=LOOPCNT
22097 #line 3300
22098 #pragma cdir shortloop
22099 #line 3300
22100     for (i=0; i<ni; i++) {
22101 #line 3300
22102       tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
22103 #line 3300
22104      /* test for range errors (not always needed but do it anyway) */
22105 #line 3300
22106      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
22107 #line 3300
22108      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
22109 #line 3300
22110       nrange += xp[i] > FLOAT_MAX || xp[i] < FLOAT_MIN;
22111 #line 3300
22112     }
22113 #line 3300
22114    /* update xpp and tp */
22115 #line 3300
22116     if (realign) xp = (int *) *xpp;
22117 #line 3300
22118     xp += ni;
22119 #line 3300
22120     tp += ni;
22121 #line 3300
22122     *xpp = (void*)xp;
22123 #line 3300
22124   }
22125 #line 3300
22126   return nrange == 0 ? NC_NOERR : NC_ERANGE;
22127 #line 3300
22128 
22129 #line 3300
22130 #else   /* not SX */
22131 #line 3300
22132 	const char *xp = (const char *) *xpp;
22133 #line 3300
22134 	int status = NC_NOERR;
22135 #line 3300
22136 
22137 #line 3300
22138 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
22139 #line 3300
22140 	{
22141 #line 3300
22142 		const int lstatus = ncx_get_int_float(xp, tp);
22143 #line 3300
22144 		if (status == NC_NOERR) /* report the first encountered error */
22145 #line 3300
22146 			status = lstatus;
22147 #line 3300
22148 	}
22149 #line 3300
22150 
22151 #line 3300
22152 	*xpp = (const void *)xp;
22153 #line 3300
22154 	return status;
22155 #line 3300
22156 #endif
22157 #line 3300
22158 }
22159 #line 3300
22160 
22161 int
22162 #line 3301
ncx_getn_int_double(const void ** xpp,size_t nelems,double * tp)22163 ncx_getn_int_double(const void **xpp, size_t nelems, double *tp)
22164 #line 3301
22165 {
22166 #line 3301
22167 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
22168 #line 3301
22169 
22170 #line 3301
22171  /* basic algorithm is:
22172 #line 3301
22173   *   - ensure sane alignment of input data
22174 #line 3301
22175   *   - copy (conversion happens automatically) input data
22176 #line 3301
22177   *     to output
22178 #line 3301
22179   *   - update xpp to point at next unconverted input, and tp to point
22180 #line 3301
22181   *     at next location for converted output
22182 #line 3301
22183   */
22184 #line 3301
22185   long i, j, ni;
22186 #line 3301
22187   int tmp[LOOPCNT];        /* in case input is misaligned */
22188 #line 3301
22189   int *xp;
22190 #line 3301
22191   int nrange = 0;         /* number of range errors */
22192 #line 3301
22193   int realign = 0;        /* "do we need to fix input data alignment?" */
22194 #line 3301
22195   long cxp = (long) *((char**)xpp);
22196 #line 3301
22197 
22198 #line 3301
22199   realign = (cxp & 7) % SIZEOF_INT;
22200 #line 3301
22201   /* sjl: manually stripmine so we can limit amount of
22202 #line 3301
22203    * vector work space reserved to LOOPCNT elements. Also
22204 #line 3301
22205    * makes vectorisation easy */
22206 #line 3301
22207   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
22208 #line 3301
22209     ni=Min(nelems-j,LOOPCNT);
22210 #line 3301
22211     if (realign) {
22212 #line 3301
22213       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
22214 #line 3301
22215       xp = tmp;
22216 #line 3301
22217     } else {
22218 #line 3301
22219       xp = (int *) *xpp;
22220 #line 3301
22221     }
22222 #line 3301
22223    /* copy the next block */
22224 #line 3301
22225 #pragma cdir loopcnt=LOOPCNT
22226 #line 3301
22227 #pragma cdir shortloop
22228 #line 3301
22229     for (i=0; i<ni; i++) {
22230 #line 3301
22231       tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
22232 #line 3301
22233      /* test for range errors (not always needed but do it anyway) */
22234 #line 3301
22235      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
22236 #line 3301
22237      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
22238 #line 3301
22239       nrange += xp[i] > DOUBLE_MAX || xp[i] < DOUBLE_MIN;
22240 #line 3301
22241     }
22242 #line 3301
22243    /* update xpp and tp */
22244 #line 3301
22245     if (realign) xp = (int *) *xpp;
22246 #line 3301
22247     xp += ni;
22248 #line 3301
22249     tp += ni;
22250 #line 3301
22251     *xpp = (void*)xp;
22252 #line 3301
22253   }
22254 #line 3301
22255   return nrange == 0 ? NC_NOERR : NC_ERANGE;
22256 #line 3301
22257 
22258 #line 3301
22259 #else   /* not SX */
22260 #line 3301
22261 	const char *xp = (const char *) *xpp;
22262 #line 3301
22263 	int status = NC_NOERR;
22264 #line 3301
22265 
22266 #line 3301
22267 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
22268 #line 3301
22269 	{
22270 #line 3301
22271 		const int lstatus = ncx_get_int_double(xp, tp);
22272 #line 3301
22273 		if (status == NC_NOERR) /* report the first encountered error */
22274 #line 3301
22275 			status = lstatus;
22276 #line 3301
22277 	}
22278 #line 3301
22279 
22280 #line 3301
22281 	*xpp = (const void *)xp;
22282 #line 3301
22283 	return status;
22284 #line 3301
22285 #endif
22286 #line 3301
22287 }
22288 #line 3301
22289 
22290 int
22291 #line 3302
ncx_getn_int_longlong(const void ** xpp,size_t nelems,longlong * tp)22292 ncx_getn_int_longlong(const void **xpp, size_t nelems, longlong *tp)
22293 #line 3302
22294 {
22295 #line 3302
22296 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
22297 #line 3302
22298 
22299 #line 3302
22300  /* basic algorithm is:
22301 #line 3302
22302   *   - ensure sane alignment of input data
22303 #line 3302
22304   *   - copy (conversion happens automatically) input data
22305 #line 3302
22306   *     to output
22307 #line 3302
22308   *   - update xpp to point at next unconverted input, and tp to point
22309 #line 3302
22310   *     at next location for converted output
22311 #line 3302
22312   */
22313 #line 3302
22314   long i, j, ni;
22315 #line 3302
22316   int tmp[LOOPCNT];        /* in case input is misaligned */
22317 #line 3302
22318   int *xp;
22319 #line 3302
22320   int nrange = 0;         /* number of range errors */
22321 #line 3302
22322   int realign = 0;        /* "do we need to fix input data alignment?" */
22323 #line 3302
22324   long cxp = (long) *((char**)xpp);
22325 #line 3302
22326 
22327 #line 3302
22328   realign = (cxp & 7) % SIZEOF_INT;
22329 #line 3302
22330   /* sjl: manually stripmine so we can limit amount of
22331 #line 3302
22332    * vector work space reserved to LOOPCNT elements. Also
22333 #line 3302
22334    * makes vectorisation easy */
22335 #line 3302
22336   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
22337 #line 3302
22338     ni=Min(nelems-j,LOOPCNT);
22339 #line 3302
22340     if (realign) {
22341 #line 3302
22342       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
22343 #line 3302
22344       xp = tmp;
22345 #line 3302
22346     } else {
22347 #line 3302
22348       xp = (int *) *xpp;
22349 #line 3302
22350     }
22351 #line 3302
22352    /* copy the next block */
22353 #line 3302
22354 #pragma cdir loopcnt=LOOPCNT
22355 #line 3302
22356 #pragma cdir shortloop
22357 #line 3302
22358     for (i=0; i<ni; i++) {
22359 #line 3302
22360       tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
22361 #line 3302
22362      /* test for range errors (not always needed but do it anyway) */
22363 #line 3302
22364      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
22365 #line 3302
22366      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
22367 #line 3302
22368       nrange += xp[i] > LONGLONG_MAX || xp[i] < LONGLONG_MIN;
22369 #line 3302
22370     }
22371 #line 3302
22372    /* update xpp and tp */
22373 #line 3302
22374     if (realign) xp = (int *) *xpp;
22375 #line 3302
22376     xp += ni;
22377 #line 3302
22378     tp += ni;
22379 #line 3302
22380     *xpp = (void*)xp;
22381 #line 3302
22382   }
22383 #line 3302
22384   return nrange == 0 ? NC_NOERR : NC_ERANGE;
22385 #line 3302
22386 
22387 #line 3302
22388 #else   /* not SX */
22389 #line 3302
22390 	const char *xp = (const char *) *xpp;
22391 #line 3302
22392 	int status = NC_NOERR;
22393 #line 3302
22394 
22395 #line 3302
22396 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
22397 #line 3302
22398 	{
22399 #line 3302
22400 		const int lstatus = ncx_get_int_longlong(xp, tp);
22401 #line 3302
22402 		if (status == NC_NOERR) /* report the first encountered error */
22403 #line 3302
22404 			status = lstatus;
22405 #line 3302
22406 	}
22407 #line 3302
22408 
22409 #line 3302
22410 	*xpp = (const void *)xp;
22411 #line 3302
22412 	return status;
22413 #line 3302
22414 #endif
22415 #line 3302
22416 }
22417 #line 3302
22418 
22419 int
22420 #line 3303
ncx_getn_int_uchar(const void ** xpp,size_t nelems,uchar * tp)22421 ncx_getn_int_uchar(const void **xpp, size_t nelems, uchar *tp)
22422 #line 3303
22423 {
22424 #line 3303
22425 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
22426 #line 3303
22427 
22428 #line 3303
22429  /* basic algorithm is:
22430 #line 3303
22431   *   - ensure sane alignment of input data
22432 #line 3303
22433   *   - copy (conversion happens automatically) input data
22434 #line 3303
22435   *     to output
22436 #line 3303
22437   *   - update xpp to point at next unconverted input, and tp to point
22438 #line 3303
22439   *     at next location for converted output
22440 #line 3303
22441   */
22442 #line 3303
22443   long i, j, ni;
22444 #line 3303
22445   int tmp[LOOPCNT];        /* in case input is misaligned */
22446 #line 3303
22447   int *xp;
22448 #line 3303
22449   int nrange = 0;         /* number of range errors */
22450 #line 3303
22451   int realign = 0;        /* "do we need to fix input data alignment?" */
22452 #line 3303
22453   long cxp = (long) *((char**)xpp);
22454 #line 3303
22455 
22456 #line 3303
22457   realign = (cxp & 7) % SIZEOF_INT;
22458 #line 3303
22459   /* sjl: manually stripmine so we can limit amount of
22460 #line 3303
22461    * vector work space reserved to LOOPCNT elements. Also
22462 #line 3303
22463    * makes vectorisation easy */
22464 #line 3303
22465   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
22466 #line 3303
22467     ni=Min(nelems-j,LOOPCNT);
22468 #line 3303
22469     if (realign) {
22470 #line 3303
22471       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
22472 #line 3303
22473       xp = tmp;
22474 #line 3303
22475     } else {
22476 #line 3303
22477       xp = (int *) *xpp;
22478 #line 3303
22479     }
22480 #line 3303
22481    /* copy the next block */
22482 #line 3303
22483 #pragma cdir loopcnt=LOOPCNT
22484 #line 3303
22485 #pragma cdir shortloop
22486 #line 3303
22487     for (i=0; i<ni; i++) {
22488 #line 3303
22489       tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
22490 #line 3303
22491      /* test for range errors (not always needed but do it anyway) */
22492 #line 3303
22493      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
22494 #line 3303
22495      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
22496 #line 3303
22497       nrange += xp[i] > UCHAR_MAX || xp[i] < 0;
22498 #line 3303
22499     }
22500 #line 3303
22501    /* update xpp and tp */
22502 #line 3303
22503     if (realign) xp = (int *) *xpp;
22504 #line 3303
22505     xp += ni;
22506 #line 3303
22507     tp += ni;
22508 #line 3303
22509     *xpp = (void*)xp;
22510 #line 3303
22511   }
22512 #line 3303
22513   return nrange == 0 ? NC_NOERR : NC_ERANGE;
22514 #line 3303
22515 
22516 #line 3303
22517 #else   /* not SX */
22518 #line 3303
22519 	const char *xp = (const char *) *xpp;
22520 #line 3303
22521 	int status = NC_NOERR;
22522 #line 3303
22523 
22524 #line 3303
22525 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
22526 #line 3303
22527 	{
22528 #line 3303
22529 		const int lstatus = ncx_get_int_uchar(xp, tp);
22530 #line 3303
22531 		if (status == NC_NOERR) /* report the first encountered error */
22532 #line 3303
22533 			status = lstatus;
22534 #line 3303
22535 	}
22536 #line 3303
22537 
22538 #line 3303
22539 	*xpp = (const void *)xp;
22540 #line 3303
22541 	return status;
22542 #line 3303
22543 #endif
22544 #line 3303
22545 }
22546 #line 3303
22547 
22548 int
22549 #line 3304
ncx_getn_int_ushort(const void ** xpp,size_t nelems,ushort * tp)22550 ncx_getn_int_ushort(const void **xpp, size_t nelems, ushort *tp)
22551 #line 3304
22552 {
22553 #line 3304
22554 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
22555 #line 3304
22556 
22557 #line 3304
22558  /* basic algorithm is:
22559 #line 3304
22560   *   - ensure sane alignment of input data
22561 #line 3304
22562   *   - copy (conversion happens automatically) input data
22563 #line 3304
22564   *     to output
22565 #line 3304
22566   *   - update xpp to point at next unconverted input, and tp to point
22567 #line 3304
22568   *     at next location for converted output
22569 #line 3304
22570   */
22571 #line 3304
22572   long i, j, ni;
22573 #line 3304
22574   int tmp[LOOPCNT];        /* in case input is misaligned */
22575 #line 3304
22576   int *xp;
22577 #line 3304
22578   int nrange = 0;         /* number of range errors */
22579 #line 3304
22580   int realign = 0;        /* "do we need to fix input data alignment?" */
22581 #line 3304
22582   long cxp = (long) *((char**)xpp);
22583 #line 3304
22584 
22585 #line 3304
22586   realign = (cxp & 7) % SIZEOF_INT;
22587 #line 3304
22588   /* sjl: manually stripmine so we can limit amount of
22589 #line 3304
22590    * vector work space reserved to LOOPCNT elements. Also
22591 #line 3304
22592    * makes vectorisation easy */
22593 #line 3304
22594   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
22595 #line 3304
22596     ni=Min(nelems-j,LOOPCNT);
22597 #line 3304
22598     if (realign) {
22599 #line 3304
22600       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
22601 #line 3304
22602       xp = tmp;
22603 #line 3304
22604     } else {
22605 #line 3304
22606       xp = (int *) *xpp;
22607 #line 3304
22608     }
22609 #line 3304
22610    /* copy the next block */
22611 #line 3304
22612 #pragma cdir loopcnt=LOOPCNT
22613 #line 3304
22614 #pragma cdir shortloop
22615 #line 3304
22616     for (i=0; i<ni; i++) {
22617 #line 3304
22618       tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
22619 #line 3304
22620      /* test for range errors (not always needed but do it anyway) */
22621 #line 3304
22622      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
22623 #line 3304
22624      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
22625 #line 3304
22626       nrange += xp[i] > USHORT_MAX || xp[i] < 0;
22627 #line 3304
22628     }
22629 #line 3304
22630    /* update xpp and tp */
22631 #line 3304
22632     if (realign) xp = (int *) *xpp;
22633 #line 3304
22634     xp += ni;
22635 #line 3304
22636     tp += ni;
22637 #line 3304
22638     *xpp = (void*)xp;
22639 #line 3304
22640   }
22641 #line 3304
22642   return nrange == 0 ? NC_NOERR : NC_ERANGE;
22643 #line 3304
22644 
22645 #line 3304
22646 #else   /* not SX */
22647 #line 3304
22648 	const char *xp = (const char *) *xpp;
22649 #line 3304
22650 	int status = NC_NOERR;
22651 #line 3304
22652 
22653 #line 3304
22654 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
22655 #line 3304
22656 	{
22657 #line 3304
22658 		const int lstatus = ncx_get_int_ushort(xp, tp);
22659 #line 3304
22660 		if (status == NC_NOERR) /* report the first encountered error */
22661 #line 3304
22662 			status = lstatus;
22663 #line 3304
22664 	}
22665 #line 3304
22666 
22667 #line 3304
22668 	*xpp = (const void *)xp;
22669 #line 3304
22670 	return status;
22671 #line 3304
22672 #endif
22673 #line 3304
22674 }
22675 #line 3304
22676 
22677 int
22678 #line 3305
ncx_getn_int_uint(const void ** xpp,size_t nelems,uint * tp)22679 ncx_getn_int_uint(const void **xpp, size_t nelems, uint *tp)
22680 #line 3305
22681 {
22682 #line 3305
22683 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
22684 #line 3305
22685 
22686 #line 3305
22687  /* basic algorithm is:
22688 #line 3305
22689   *   - ensure sane alignment of input data
22690 #line 3305
22691   *   - copy (conversion happens automatically) input data
22692 #line 3305
22693   *     to output
22694 #line 3305
22695   *   - update xpp to point at next unconverted input, and tp to point
22696 #line 3305
22697   *     at next location for converted output
22698 #line 3305
22699   */
22700 #line 3305
22701   long i, j, ni;
22702 #line 3305
22703   int tmp[LOOPCNT];        /* in case input is misaligned */
22704 #line 3305
22705   int *xp;
22706 #line 3305
22707   int nrange = 0;         /* number of range errors */
22708 #line 3305
22709   int realign = 0;        /* "do we need to fix input data alignment?" */
22710 #line 3305
22711   long cxp = (long) *((char**)xpp);
22712 #line 3305
22713 
22714 #line 3305
22715   realign = (cxp & 7) % SIZEOF_INT;
22716 #line 3305
22717   /* sjl: manually stripmine so we can limit amount of
22718 #line 3305
22719    * vector work space reserved to LOOPCNT elements. Also
22720 #line 3305
22721    * makes vectorisation easy */
22722 #line 3305
22723   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
22724 #line 3305
22725     ni=Min(nelems-j,LOOPCNT);
22726 #line 3305
22727     if (realign) {
22728 #line 3305
22729       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
22730 #line 3305
22731       xp = tmp;
22732 #line 3305
22733     } else {
22734 #line 3305
22735       xp = (int *) *xpp;
22736 #line 3305
22737     }
22738 #line 3305
22739    /* copy the next block */
22740 #line 3305
22741 #pragma cdir loopcnt=LOOPCNT
22742 #line 3305
22743 #pragma cdir shortloop
22744 #line 3305
22745     for (i=0; i<ni; i++) {
22746 #line 3305
22747       tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
22748 #line 3305
22749      /* test for range errors (not always needed but do it anyway) */
22750 #line 3305
22751      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
22752 #line 3305
22753      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
22754 #line 3305
22755       nrange += xp[i] > UINT_MAX || xp[i] < 0;
22756 #line 3305
22757     }
22758 #line 3305
22759    /* update xpp and tp */
22760 #line 3305
22761     if (realign) xp = (int *) *xpp;
22762 #line 3305
22763     xp += ni;
22764 #line 3305
22765     tp += ni;
22766 #line 3305
22767     *xpp = (void*)xp;
22768 #line 3305
22769   }
22770 #line 3305
22771   return nrange == 0 ? NC_NOERR : NC_ERANGE;
22772 #line 3305
22773 
22774 #line 3305
22775 #else   /* not SX */
22776 #line 3305
22777 	const char *xp = (const char *) *xpp;
22778 #line 3305
22779 	int status = NC_NOERR;
22780 #line 3305
22781 
22782 #line 3305
22783 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
22784 #line 3305
22785 	{
22786 #line 3305
22787 		const int lstatus = ncx_get_int_uint(xp, tp);
22788 #line 3305
22789 		if (status == NC_NOERR) /* report the first encountered error */
22790 #line 3305
22791 			status = lstatus;
22792 #line 3305
22793 	}
22794 #line 3305
22795 
22796 #line 3305
22797 	*xpp = (const void *)xp;
22798 #line 3305
22799 	return status;
22800 #line 3305
22801 #endif
22802 #line 3305
22803 }
22804 #line 3305
22805 
22806 int
22807 #line 3306
ncx_getn_int_ulonglong(const void ** xpp,size_t nelems,ulonglong * tp)22808 ncx_getn_int_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
22809 #line 3306
22810 {
22811 #line 3306
22812 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
22813 #line 3306
22814 
22815 #line 3306
22816  /* basic algorithm is:
22817 #line 3306
22818   *   - ensure sane alignment of input data
22819 #line 3306
22820   *   - copy (conversion happens automatically) input data
22821 #line 3306
22822   *     to output
22823 #line 3306
22824   *   - update xpp to point at next unconverted input, and tp to point
22825 #line 3306
22826   *     at next location for converted output
22827 #line 3306
22828   */
22829 #line 3306
22830   long i, j, ni;
22831 #line 3306
22832   int tmp[LOOPCNT];        /* in case input is misaligned */
22833 #line 3306
22834   int *xp;
22835 #line 3306
22836   int nrange = 0;         /* number of range errors */
22837 #line 3306
22838   int realign = 0;        /* "do we need to fix input data alignment?" */
22839 #line 3306
22840   long cxp = (long) *((char**)xpp);
22841 #line 3306
22842 
22843 #line 3306
22844   realign = (cxp & 7) % SIZEOF_INT;
22845 #line 3306
22846   /* sjl: manually stripmine so we can limit amount of
22847 #line 3306
22848    * vector work space reserved to LOOPCNT elements. Also
22849 #line 3306
22850    * makes vectorisation easy */
22851 #line 3306
22852   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
22853 #line 3306
22854     ni=Min(nelems-j,LOOPCNT);
22855 #line 3306
22856     if (realign) {
22857 #line 3306
22858       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
22859 #line 3306
22860       xp = tmp;
22861 #line 3306
22862     } else {
22863 #line 3306
22864       xp = (int *) *xpp;
22865 #line 3306
22866     }
22867 #line 3306
22868    /* copy the next block */
22869 #line 3306
22870 #pragma cdir loopcnt=LOOPCNT
22871 #line 3306
22872 #pragma cdir shortloop
22873 #line 3306
22874     for (i=0; i<ni; i++) {
22875 #line 3306
22876       tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
22877 #line 3306
22878      /* test for range errors (not always needed but do it anyway) */
22879 #line 3306
22880      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
22881 #line 3306
22882      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
22883 #line 3306
22884       nrange += xp[i] > ULONGLONG_MAX || xp[i] < 0;
22885 #line 3306
22886     }
22887 #line 3306
22888    /* update xpp and tp */
22889 #line 3306
22890     if (realign) xp = (int *) *xpp;
22891 #line 3306
22892     xp += ni;
22893 #line 3306
22894     tp += ni;
22895 #line 3306
22896     *xpp = (void*)xp;
22897 #line 3306
22898   }
22899 #line 3306
22900   return nrange == 0 ? NC_NOERR : NC_ERANGE;
22901 #line 3306
22902 
22903 #line 3306
22904 #else   /* not SX */
22905 #line 3306
22906 	const char *xp = (const char *) *xpp;
22907 #line 3306
22908 	int status = NC_NOERR;
22909 #line 3306
22910 
22911 #line 3306
22912 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
22913 #line 3306
22914 	{
22915 #line 3306
22916 		const int lstatus = ncx_get_int_ulonglong(xp, tp);
22917 #line 3306
22918 		if (status == NC_NOERR) /* report the first encountered error */
22919 #line 3306
22920 			status = lstatus;
22921 #line 3306
22922 	}
22923 #line 3306
22924 
22925 #line 3306
22926 	*xpp = (const void *)xp;
22927 #line 3306
22928 	return status;
22929 #line 3306
22930 #endif
22931 #line 3306
22932 }
22933 #line 3306
22934 
22935 
22936 #if X_SIZEOF_INT == SIZEOF_INT
22937 /* optimized version */
22938 int
ncx_putn_int_int(void ** xpp,size_t nelems,const int * tp,void * fillp)22939 ncx_putn_int_int(void **xpp, size_t nelems, const int *tp, void *fillp)
22940 {
22941 #ifdef WORDS_BIGENDIAN
22942 	(void) memcpy(*xpp, tp, (size_t)nelems * X_SIZEOF_INT);
22943 # else
22944 	swapn4b(*xpp, tp, nelems);
22945 # endif
22946 	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_INT);
22947 	return NC_NOERR;
22948 }
22949 #else
22950 int
22951 #line 3322
ncx_putn_int_int(void ** xpp,size_t nelems,const int * tp,void * fillp)22952 ncx_putn_int_int(void **xpp, size_t nelems, const int *tp, void *fillp)
22953 #line 3322
22954 {
22955 #line 3322
22956 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
22957 #line 3322
22958 
22959 #line 3322
22960  /* basic algorithm is:
22961 #line 3322
22962   *   - ensure sane alignment of output data
22963 #line 3322
22964   *   - copy (conversion happens automatically) input data
22965 #line 3322
22966   *     to output
22967 #line 3322
22968   *   - update tp to point at next unconverted input, and xpp to point
22969 #line 3322
22970   *     at next location for converted output
22971 #line 3322
22972   */
22973 #line 3322
22974   long i, j, ni;
22975 #line 3322
22976   int tmp[LOOPCNT];        /* in case input is misaligned */
22977 #line 3322
22978   int *xp;
22979 #line 3322
22980   int nrange = 0;         /* number of range errors */
22981 #line 3322
22982   int realign = 0;        /* "do we need to fix input data alignment?" */
22983 #line 3322
22984   long cxp = (long) *((char**)xpp);
22985 #line 3322
22986 
22987 #line 3322
22988   realign = (cxp & 7) % SIZEOF_INT;
22989 #line 3322
22990   /* sjl: manually stripmine so we can limit amount of
22991 #line 3322
22992    * vector work space reserved to LOOPCNT elements. Also
22993 #line 3322
22994    * makes vectorisation easy */
22995 #line 3322
22996   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
22997 #line 3322
22998     ni=Min(nelems-j,LOOPCNT);
22999 #line 3322
23000     if (realign) {
23001 #line 3322
23002       xp = tmp;
23003 #line 3322
23004     } else {
23005 #line 3322
23006       xp = (int *) *xpp;
23007 #line 3322
23008     }
23009 #line 3322
23010    /* copy the next block */
23011 #line 3322
23012 #pragma cdir loopcnt=LOOPCNT
23013 #line 3322
23014 #pragma cdir shortloop
23015 #line 3322
23016     for (i=0; i<ni; i++) {
23017 #line 3322
23018       /* the normal case: */
23019 #line 3322
23020       xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
23021 #line 3322
23022      /* test for range errors (not always needed but do it anyway) */
23023 #line 3322
23024      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
23025 #line 3322
23026      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
23027 #line 3322
23028       nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
23029 #line 3322
23030     }
23031 #line 3322
23032    /* copy workspace back if necessary */
23033 #line 3322
23034     if (realign) {
23035 #line 3322
23036       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
23037 #line 3322
23038       xp = (int *) *xpp;
23039 #line 3322
23040     }
23041 #line 3322
23042    /* update xpp and tp */
23043 #line 3322
23044     xp += ni;
23045 #line 3322
23046     tp += ni;
23047 #line 3322
23048     *xpp = (void*)xp;
23049 #line 3322
23050   }
23051 #line 3322
23052   return nrange == 0 ? NC_NOERR : NC_ERANGE;
23053 #line 3322
23054 
23055 #line 3322
23056 #else   /* not SX */
23057 #line 3322
23058 
23059 #line 3322
23060 	char *xp = (char *) *xpp;
23061 #line 3322
23062 	int status = NC_NOERR;
23063 #line 3322
23064 
23065 #line 3322
23066 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
23067 #line 3322
23068 	{
23069 #line 3322
23070 		int lstatus = ncx_put_int_int(xp, tp, fillp);
23071 #line 3322
23072 		if (status == NC_NOERR) /* report the first encountered error */
23073 #line 3322
23074 			status = lstatus;
23075 #line 3322
23076 	}
23077 #line 3322
23078 
23079 #line 3322
23080 	*xpp = (void *)xp;
23081 #line 3322
23082 	return status;
23083 #line 3322
23084 #endif
23085 #line 3322
23086 }
23087 #line 3322
23088 
23089 #endif
23090 int
23091 #line 3324
ncx_putn_int_schar(void ** xpp,size_t nelems,const schar * tp,void * fillp)23092 ncx_putn_int_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
23093 #line 3324
23094 {
23095 #line 3324
23096 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
23097 #line 3324
23098 
23099 #line 3324
23100  /* basic algorithm is:
23101 #line 3324
23102   *   - ensure sane alignment of output data
23103 #line 3324
23104   *   - copy (conversion happens automatically) input data
23105 #line 3324
23106   *     to output
23107 #line 3324
23108   *   - update tp to point at next unconverted input, and xpp to point
23109 #line 3324
23110   *     at next location for converted output
23111 #line 3324
23112   */
23113 #line 3324
23114   long i, j, ni;
23115 #line 3324
23116   int tmp[LOOPCNT];        /* in case input is misaligned */
23117 #line 3324
23118   int *xp;
23119 #line 3324
23120   int nrange = 0;         /* number of range errors */
23121 #line 3324
23122   int realign = 0;        /* "do we need to fix input data alignment?" */
23123 #line 3324
23124   long cxp = (long) *((char**)xpp);
23125 #line 3324
23126 
23127 #line 3324
23128   realign = (cxp & 7) % SIZEOF_INT;
23129 #line 3324
23130   /* sjl: manually stripmine so we can limit amount of
23131 #line 3324
23132    * vector work space reserved to LOOPCNT elements. Also
23133 #line 3324
23134    * makes vectorisation easy */
23135 #line 3324
23136   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
23137 #line 3324
23138     ni=Min(nelems-j,LOOPCNT);
23139 #line 3324
23140     if (realign) {
23141 #line 3324
23142       xp = tmp;
23143 #line 3324
23144     } else {
23145 #line 3324
23146       xp = (int *) *xpp;
23147 #line 3324
23148     }
23149 #line 3324
23150    /* copy the next block */
23151 #line 3324
23152 #pragma cdir loopcnt=LOOPCNT
23153 #line 3324
23154 #pragma cdir shortloop
23155 #line 3324
23156     for (i=0; i<ni; i++) {
23157 #line 3324
23158       /* the normal case: */
23159 #line 3324
23160       xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
23161 #line 3324
23162      /* test for range errors (not always needed but do it anyway) */
23163 #line 3324
23164      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
23165 #line 3324
23166      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
23167 #line 3324
23168       nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
23169 #line 3324
23170     }
23171 #line 3324
23172    /* copy workspace back if necessary */
23173 #line 3324
23174     if (realign) {
23175 #line 3324
23176       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
23177 #line 3324
23178       xp = (int *) *xpp;
23179 #line 3324
23180     }
23181 #line 3324
23182    /* update xpp and tp */
23183 #line 3324
23184     xp += ni;
23185 #line 3324
23186     tp += ni;
23187 #line 3324
23188     *xpp = (void*)xp;
23189 #line 3324
23190   }
23191 #line 3324
23192   return nrange == 0 ? NC_NOERR : NC_ERANGE;
23193 #line 3324
23194 
23195 #line 3324
23196 #else   /* not SX */
23197 #line 3324
23198 
23199 #line 3324
23200 	char *xp = (char *) *xpp;
23201 #line 3324
23202 	int status = NC_NOERR;
23203 #line 3324
23204 
23205 #line 3324
23206 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
23207 #line 3324
23208 	{
23209 #line 3324
23210 		int lstatus = ncx_put_int_schar(xp, tp, fillp);
23211 #line 3324
23212 		if (status == NC_NOERR) /* report the first encountered error */
23213 #line 3324
23214 			status = lstatus;
23215 #line 3324
23216 	}
23217 #line 3324
23218 
23219 #line 3324
23220 	*xpp = (void *)xp;
23221 #line 3324
23222 	return status;
23223 #line 3324
23224 #endif
23225 #line 3324
23226 }
23227 #line 3324
23228 
23229 int
23230 #line 3325
ncx_putn_int_short(void ** xpp,size_t nelems,const short * tp,void * fillp)23231 ncx_putn_int_short(void **xpp, size_t nelems, const short *tp, void *fillp)
23232 #line 3325
23233 {
23234 #line 3325
23235 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
23236 #line 3325
23237 
23238 #line 3325
23239  /* basic algorithm is:
23240 #line 3325
23241   *   - ensure sane alignment of output data
23242 #line 3325
23243   *   - copy (conversion happens automatically) input data
23244 #line 3325
23245   *     to output
23246 #line 3325
23247   *   - update tp to point at next unconverted input, and xpp to point
23248 #line 3325
23249   *     at next location for converted output
23250 #line 3325
23251   */
23252 #line 3325
23253   long i, j, ni;
23254 #line 3325
23255   int tmp[LOOPCNT];        /* in case input is misaligned */
23256 #line 3325
23257   int *xp;
23258 #line 3325
23259   int nrange = 0;         /* number of range errors */
23260 #line 3325
23261   int realign = 0;        /* "do we need to fix input data alignment?" */
23262 #line 3325
23263   long cxp = (long) *((char**)xpp);
23264 #line 3325
23265 
23266 #line 3325
23267   realign = (cxp & 7) % SIZEOF_INT;
23268 #line 3325
23269   /* sjl: manually stripmine so we can limit amount of
23270 #line 3325
23271    * vector work space reserved to LOOPCNT elements. Also
23272 #line 3325
23273    * makes vectorisation easy */
23274 #line 3325
23275   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
23276 #line 3325
23277     ni=Min(nelems-j,LOOPCNT);
23278 #line 3325
23279     if (realign) {
23280 #line 3325
23281       xp = tmp;
23282 #line 3325
23283     } else {
23284 #line 3325
23285       xp = (int *) *xpp;
23286 #line 3325
23287     }
23288 #line 3325
23289    /* copy the next block */
23290 #line 3325
23291 #pragma cdir loopcnt=LOOPCNT
23292 #line 3325
23293 #pragma cdir shortloop
23294 #line 3325
23295     for (i=0; i<ni; i++) {
23296 #line 3325
23297       /* the normal case: */
23298 #line 3325
23299       xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
23300 #line 3325
23301      /* test for range errors (not always needed but do it anyway) */
23302 #line 3325
23303      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
23304 #line 3325
23305      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
23306 #line 3325
23307       nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
23308 #line 3325
23309     }
23310 #line 3325
23311    /* copy workspace back if necessary */
23312 #line 3325
23313     if (realign) {
23314 #line 3325
23315       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
23316 #line 3325
23317       xp = (int *) *xpp;
23318 #line 3325
23319     }
23320 #line 3325
23321    /* update xpp and tp */
23322 #line 3325
23323     xp += ni;
23324 #line 3325
23325     tp += ni;
23326 #line 3325
23327     *xpp = (void*)xp;
23328 #line 3325
23329   }
23330 #line 3325
23331   return nrange == 0 ? NC_NOERR : NC_ERANGE;
23332 #line 3325
23333 
23334 #line 3325
23335 #else   /* not SX */
23336 #line 3325
23337 
23338 #line 3325
23339 	char *xp = (char *) *xpp;
23340 #line 3325
23341 	int status = NC_NOERR;
23342 #line 3325
23343 
23344 #line 3325
23345 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
23346 #line 3325
23347 	{
23348 #line 3325
23349 		int lstatus = ncx_put_int_short(xp, tp, fillp);
23350 #line 3325
23351 		if (status == NC_NOERR) /* report the first encountered error */
23352 #line 3325
23353 			status = lstatus;
23354 #line 3325
23355 	}
23356 #line 3325
23357 
23358 #line 3325
23359 	*xpp = (void *)xp;
23360 #line 3325
23361 	return status;
23362 #line 3325
23363 #endif
23364 #line 3325
23365 }
23366 #line 3325
23367 
23368 int
23369 #line 3326
ncx_putn_int_long(void ** xpp,size_t nelems,const long * tp,void * fillp)23370 ncx_putn_int_long(void **xpp, size_t nelems, const long *tp, void *fillp)
23371 #line 3326
23372 {
23373 #line 3326
23374 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
23375 #line 3326
23376 
23377 #line 3326
23378  /* basic algorithm is:
23379 #line 3326
23380   *   - ensure sane alignment of output data
23381 #line 3326
23382   *   - copy (conversion happens automatically) input data
23383 #line 3326
23384   *     to output
23385 #line 3326
23386   *   - update tp to point at next unconverted input, and xpp to point
23387 #line 3326
23388   *     at next location for converted output
23389 #line 3326
23390   */
23391 #line 3326
23392   long i, j, ni;
23393 #line 3326
23394   int tmp[LOOPCNT];        /* in case input is misaligned */
23395 #line 3326
23396   int *xp;
23397 #line 3326
23398   int nrange = 0;         /* number of range errors */
23399 #line 3326
23400   int realign = 0;        /* "do we need to fix input data alignment?" */
23401 #line 3326
23402   long cxp = (long) *((char**)xpp);
23403 #line 3326
23404 
23405 #line 3326
23406   realign = (cxp & 7) % SIZEOF_INT;
23407 #line 3326
23408   /* sjl: manually stripmine so we can limit amount of
23409 #line 3326
23410    * vector work space reserved to LOOPCNT elements. Also
23411 #line 3326
23412    * makes vectorisation easy */
23413 #line 3326
23414   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
23415 #line 3326
23416     ni=Min(nelems-j,LOOPCNT);
23417 #line 3326
23418     if (realign) {
23419 #line 3326
23420       xp = tmp;
23421 #line 3326
23422     } else {
23423 #line 3326
23424       xp = (int *) *xpp;
23425 #line 3326
23426     }
23427 #line 3326
23428    /* copy the next block */
23429 #line 3326
23430 #pragma cdir loopcnt=LOOPCNT
23431 #line 3326
23432 #pragma cdir shortloop
23433 #line 3326
23434     for (i=0; i<ni; i++) {
23435 #line 3326
23436       /* the normal case: */
23437 #line 3326
23438       xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
23439 #line 3326
23440      /* test for range errors (not always needed but do it anyway) */
23441 #line 3326
23442      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
23443 #line 3326
23444      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
23445 #line 3326
23446       nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
23447 #line 3326
23448     }
23449 #line 3326
23450    /* copy workspace back if necessary */
23451 #line 3326
23452     if (realign) {
23453 #line 3326
23454       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
23455 #line 3326
23456       xp = (int *) *xpp;
23457 #line 3326
23458     }
23459 #line 3326
23460    /* update xpp and tp */
23461 #line 3326
23462     xp += ni;
23463 #line 3326
23464     tp += ni;
23465 #line 3326
23466     *xpp = (void*)xp;
23467 #line 3326
23468   }
23469 #line 3326
23470   return nrange == 0 ? NC_NOERR : NC_ERANGE;
23471 #line 3326
23472 
23473 #line 3326
23474 #else   /* not SX */
23475 #line 3326
23476 
23477 #line 3326
23478 	char *xp = (char *) *xpp;
23479 #line 3326
23480 	int status = NC_NOERR;
23481 #line 3326
23482 
23483 #line 3326
23484 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
23485 #line 3326
23486 	{
23487 #line 3326
23488 		int lstatus = ncx_put_int_long(xp, tp, fillp);
23489 #line 3326
23490 		if (status == NC_NOERR) /* report the first encountered error */
23491 #line 3326
23492 			status = lstatus;
23493 #line 3326
23494 	}
23495 #line 3326
23496 
23497 #line 3326
23498 	*xpp = (void *)xp;
23499 #line 3326
23500 	return status;
23501 #line 3326
23502 #endif
23503 #line 3326
23504 }
23505 #line 3326
23506 
23507 int
23508 #line 3327
ncx_putn_int_float(void ** xpp,size_t nelems,const float * tp,void * fillp)23509 ncx_putn_int_float(void **xpp, size_t nelems, const float *tp, void *fillp)
23510 #line 3327
23511 {
23512 #line 3327
23513 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
23514 #line 3327
23515 
23516 #line 3327
23517  /* basic algorithm is:
23518 #line 3327
23519   *   - ensure sane alignment of output data
23520 #line 3327
23521   *   - copy (conversion happens automatically) input data
23522 #line 3327
23523   *     to output
23524 #line 3327
23525   *   - update tp to point at next unconverted input, and xpp to point
23526 #line 3327
23527   *     at next location for converted output
23528 #line 3327
23529   */
23530 #line 3327
23531   long i, j, ni;
23532 #line 3327
23533   int tmp[LOOPCNT];        /* in case input is misaligned */
23534 #line 3327
23535   int *xp;
23536 #line 3327
23537   double d;               /* special case for ncx_putn_int_float */
23538 #line 3327
23539   int nrange = 0;         /* number of range errors */
23540 #line 3327
23541   int realign = 0;        /* "do we need to fix input data alignment?" */
23542 #line 3327
23543   long cxp = (long) *((char**)xpp);
23544 #line 3327
23545 
23546 #line 3327
23547   realign = (cxp & 7) % SIZEOF_INT;
23548 #line 3327
23549   /* sjl: manually stripmine so we can limit amount of
23550 #line 3327
23551    * vector work space reserved to LOOPCNT elements. Also
23552 #line 3327
23553    * makes vectorisation easy */
23554 #line 3327
23555   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
23556 #line 3327
23557     ni=Min(nelems-j,LOOPCNT);
23558 #line 3327
23559     if (realign) {
23560 #line 3327
23561       xp = tmp;
23562 #line 3327
23563     } else {
23564 #line 3327
23565       xp = (int *) *xpp;
23566 #line 3327
23567     }
23568 #line 3327
23569    /* copy the next block */
23570 #line 3327
23571 #pragma cdir loopcnt=LOOPCNT
23572 #line 3327
23573 #pragma cdir shortloop
23574 #line 3327
23575     for (i=0; i<ni; i++) {
23576 #line 3327
23577       /* for some reason int to float, for putn, requires a special case */
23578 #line 3327
23579       d = tp[i];
23580 #line 3327
23581       xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) d));
23582 #line 3327
23583       nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
23584 #line 3327
23585     }
23586 #line 3327
23587    /* copy workspace back if necessary */
23588 #line 3327
23589     if (realign) {
23590 #line 3327
23591       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
23592 #line 3327
23593       xp = (int *) *xpp;
23594 #line 3327
23595     }
23596 #line 3327
23597    /* update xpp and tp */
23598 #line 3327
23599     xp += ni;
23600 #line 3327
23601     tp += ni;
23602 #line 3327
23603     *xpp = (void*)xp;
23604 #line 3327
23605   }
23606 #line 3327
23607   return nrange == 0 ? NC_NOERR : NC_ERANGE;
23608 #line 3327
23609 
23610 #line 3327
23611 #else   /* not SX */
23612 #line 3327
23613 
23614 #line 3327
23615 	char *xp = (char *) *xpp;
23616 #line 3327
23617 	int status = NC_NOERR;
23618 #line 3327
23619 
23620 #line 3327
23621 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
23622 #line 3327
23623 	{
23624 #line 3327
23625 		int lstatus = ncx_put_int_float(xp, tp, fillp);
23626 #line 3327
23627 		if (status == NC_NOERR) /* report the first encountered error */
23628 #line 3327
23629 			status = lstatus;
23630 #line 3327
23631 	}
23632 #line 3327
23633 
23634 #line 3327
23635 	*xpp = (void *)xp;
23636 #line 3327
23637 	return status;
23638 #line 3327
23639 #endif
23640 #line 3327
23641 }
23642 #line 3327
23643 
23644 int
23645 #line 3328
ncx_putn_int_double(void ** xpp,size_t nelems,const double * tp,void * fillp)23646 ncx_putn_int_double(void **xpp, size_t nelems, const double *tp, void *fillp)
23647 #line 3328
23648 {
23649 #line 3328
23650 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
23651 #line 3328
23652 
23653 #line 3328
23654  /* basic algorithm is:
23655 #line 3328
23656   *   - ensure sane alignment of output data
23657 #line 3328
23658   *   - copy (conversion happens automatically) input data
23659 #line 3328
23660   *     to output
23661 #line 3328
23662   *   - update tp to point at next unconverted input, and xpp to point
23663 #line 3328
23664   *     at next location for converted output
23665 #line 3328
23666   */
23667 #line 3328
23668   long i, j, ni;
23669 #line 3328
23670   int tmp[LOOPCNT];        /* in case input is misaligned */
23671 #line 3328
23672   int *xp;
23673 #line 3328
23674   int nrange = 0;         /* number of range errors */
23675 #line 3328
23676   int realign = 0;        /* "do we need to fix input data alignment?" */
23677 #line 3328
23678   long cxp = (long) *((char**)xpp);
23679 #line 3328
23680 
23681 #line 3328
23682   realign = (cxp & 7) % SIZEOF_INT;
23683 #line 3328
23684   /* sjl: manually stripmine so we can limit amount of
23685 #line 3328
23686    * vector work space reserved to LOOPCNT elements. Also
23687 #line 3328
23688    * makes vectorisation easy */
23689 #line 3328
23690   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
23691 #line 3328
23692     ni=Min(nelems-j,LOOPCNT);
23693 #line 3328
23694     if (realign) {
23695 #line 3328
23696       xp = tmp;
23697 #line 3328
23698     } else {
23699 #line 3328
23700       xp = (int *) *xpp;
23701 #line 3328
23702     }
23703 #line 3328
23704    /* copy the next block */
23705 #line 3328
23706 #pragma cdir loopcnt=LOOPCNT
23707 #line 3328
23708 #pragma cdir shortloop
23709 #line 3328
23710     for (i=0; i<ni; i++) {
23711 #line 3328
23712       /* the normal case: */
23713 #line 3328
23714       xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
23715 #line 3328
23716      /* test for range errors (not always needed but do it anyway) */
23717 #line 3328
23718      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
23719 #line 3328
23720      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
23721 #line 3328
23722       nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
23723 #line 3328
23724     }
23725 #line 3328
23726    /* copy workspace back if necessary */
23727 #line 3328
23728     if (realign) {
23729 #line 3328
23730       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
23731 #line 3328
23732       xp = (int *) *xpp;
23733 #line 3328
23734     }
23735 #line 3328
23736    /* update xpp and tp */
23737 #line 3328
23738     xp += ni;
23739 #line 3328
23740     tp += ni;
23741 #line 3328
23742     *xpp = (void*)xp;
23743 #line 3328
23744   }
23745 #line 3328
23746   return nrange == 0 ? NC_NOERR : NC_ERANGE;
23747 #line 3328
23748 
23749 #line 3328
23750 #else   /* not SX */
23751 #line 3328
23752 
23753 #line 3328
23754 	char *xp = (char *) *xpp;
23755 #line 3328
23756 	int status = NC_NOERR;
23757 #line 3328
23758 
23759 #line 3328
23760 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
23761 #line 3328
23762 	{
23763 #line 3328
23764 		int lstatus = ncx_put_int_double(xp, tp, fillp);
23765 #line 3328
23766 		if (status == NC_NOERR) /* report the first encountered error */
23767 #line 3328
23768 			status = lstatus;
23769 #line 3328
23770 	}
23771 #line 3328
23772 
23773 #line 3328
23774 	*xpp = (void *)xp;
23775 #line 3328
23776 	return status;
23777 #line 3328
23778 #endif
23779 #line 3328
23780 }
23781 #line 3328
23782 
23783 int
23784 #line 3329
ncx_putn_int_longlong(void ** xpp,size_t nelems,const longlong * tp,void * fillp)23785 ncx_putn_int_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
23786 #line 3329
23787 {
23788 #line 3329
23789 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
23790 #line 3329
23791 
23792 #line 3329
23793  /* basic algorithm is:
23794 #line 3329
23795   *   - ensure sane alignment of output data
23796 #line 3329
23797   *   - copy (conversion happens automatically) input data
23798 #line 3329
23799   *     to output
23800 #line 3329
23801   *   - update tp to point at next unconverted input, and xpp to point
23802 #line 3329
23803   *     at next location for converted output
23804 #line 3329
23805   */
23806 #line 3329
23807   long i, j, ni;
23808 #line 3329
23809   int tmp[LOOPCNT];        /* in case input is misaligned */
23810 #line 3329
23811   int *xp;
23812 #line 3329
23813   int nrange = 0;         /* number of range errors */
23814 #line 3329
23815   int realign = 0;        /* "do we need to fix input data alignment?" */
23816 #line 3329
23817   long cxp = (long) *((char**)xpp);
23818 #line 3329
23819 
23820 #line 3329
23821   realign = (cxp & 7) % SIZEOF_INT;
23822 #line 3329
23823   /* sjl: manually stripmine so we can limit amount of
23824 #line 3329
23825    * vector work space reserved to LOOPCNT elements. Also
23826 #line 3329
23827    * makes vectorisation easy */
23828 #line 3329
23829   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
23830 #line 3329
23831     ni=Min(nelems-j,LOOPCNT);
23832 #line 3329
23833     if (realign) {
23834 #line 3329
23835       xp = tmp;
23836 #line 3329
23837     } else {
23838 #line 3329
23839       xp = (int *) *xpp;
23840 #line 3329
23841     }
23842 #line 3329
23843    /* copy the next block */
23844 #line 3329
23845 #pragma cdir loopcnt=LOOPCNT
23846 #line 3329
23847 #pragma cdir shortloop
23848 #line 3329
23849     for (i=0; i<ni; i++) {
23850 #line 3329
23851       /* the normal case: */
23852 #line 3329
23853       xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
23854 #line 3329
23855      /* test for range errors (not always needed but do it anyway) */
23856 #line 3329
23857      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
23858 #line 3329
23859      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
23860 #line 3329
23861       nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
23862 #line 3329
23863     }
23864 #line 3329
23865    /* copy workspace back if necessary */
23866 #line 3329
23867     if (realign) {
23868 #line 3329
23869       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
23870 #line 3329
23871       xp = (int *) *xpp;
23872 #line 3329
23873     }
23874 #line 3329
23875    /* update xpp and tp */
23876 #line 3329
23877     xp += ni;
23878 #line 3329
23879     tp += ni;
23880 #line 3329
23881     *xpp = (void*)xp;
23882 #line 3329
23883   }
23884 #line 3329
23885   return nrange == 0 ? NC_NOERR : NC_ERANGE;
23886 #line 3329
23887 
23888 #line 3329
23889 #else   /* not SX */
23890 #line 3329
23891 
23892 #line 3329
23893 	char *xp = (char *) *xpp;
23894 #line 3329
23895 	int status = NC_NOERR;
23896 #line 3329
23897 
23898 #line 3329
23899 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
23900 #line 3329
23901 	{
23902 #line 3329
23903 		int lstatus = ncx_put_int_longlong(xp, tp, fillp);
23904 #line 3329
23905 		if (status == NC_NOERR) /* report the first encountered error */
23906 #line 3329
23907 			status = lstatus;
23908 #line 3329
23909 	}
23910 #line 3329
23911 
23912 #line 3329
23913 	*xpp = (void *)xp;
23914 #line 3329
23915 	return status;
23916 #line 3329
23917 #endif
23918 #line 3329
23919 }
23920 #line 3329
23921 
23922 int
23923 #line 3330
ncx_putn_int_uchar(void ** xpp,size_t nelems,const uchar * tp,void * fillp)23924 ncx_putn_int_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
23925 #line 3330
23926 {
23927 #line 3330
23928 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
23929 #line 3330
23930 
23931 #line 3330
23932  /* basic algorithm is:
23933 #line 3330
23934   *   - ensure sane alignment of output data
23935 #line 3330
23936   *   - copy (conversion happens automatically) input data
23937 #line 3330
23938   *     to output
23939 #line 3330
23940   *   - update tp to point at next unconverted input, and xpp to point
23941 #line 3330
23942   *     at next location for converted output
23943 #line 3330
23944   */
23945 #line 3330
23946   long i, j, ni;
23947 #line 3330
23948   int tmp[LOOPCNT];        /* in case input is misaligned */
23949 #line 3330
23950   int *xp;
23951 #line 3330
23952   int nrange = 0;         /* number of range errors */
23953 #line 3330
23954   int realign = 0;        /* "do we need to fix input data alignment?" */
23955 #line 3330
23956   long cxp = (long) *((char**)xpp);
23957 #line 3330
23958 
23959 #line 3330
23960   realign = (cxp & 7) % SIZEOF_INT;
23961 #line 3330
23962   /* sjl: manually stripmine so we can limit amount of
23963 #line 3330
23964    * vector work space reserved to LOOPCNT elements. Also
23965 #line 3330
23966    * makes vectorisation easy */
23967 #line 3330
23968   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
23969 #line 3330
23970     ni=Min(nelems-j,LOOPCNT);
23971 #line 3330
23972     if (realign) {
23973 #line 3330
23974       xp = tmp;
23975 #line 3330
23976     } else {
23977 #line 3330
23978       xp = (int *) *xpp;
23979 #line 3330
23980     }
23981 #line 3330
23982    /* copy the next block */
23983 #line 3330
23984 #pragma cdir loopcnt=LOOPCNT
23985 #line 3330
23986 #pragma cdir shortloop
23987 #line 3330
23988     for (i=0; i<ni; i++) {
23989 #line 3330
23990       /* the normal case: */
23991 #line 3330
23992       xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
23993 #line 3330
23994      /* test for range errors (not always needed but do it anyway) */
23995 #line 3330
23996      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
23997 #line 3330
23998      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
23999 #line 3330
24000       nrange += tp[i] > X_INT_MAX ;
24001 #line 3330
24002     }
24003 #line 3330
24004    /* copy workspace back if necessary */
24005 #line 3330
24006     if (realign) {
24007 #line 3330
24008       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
24009 #line 3330
24010       xp = (int *) *xpp;
24011 #line 3330
24012     }
24013 #line 3330
24014    /* update xpp and tp */
24015 #line 3330
24016     xp += ni;
24017 #line 3330
24018     tp += ni;
24019 #line 3330
24020     *xpp = (void*)xp;
24021 #line 3330
24022   }
24023 #line 3330
24024   return nrange == 0 ? NC_NOERR : NC_ERANGE;
24025 #line 3330
24026 
24027 #line 3330
24028 #else   /* not SX */
24029 #line 3330
24030 
24031 #line 3330
24032 	char *xp = (char *) *xpp;
24033 #line 3330
24034 	int status = NC_NOERR;
24035 #line 3330
24036 
24037 #line 3330
24038 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
24039 #line 3330
24040 	{
24041 #line 3330
24042 		int lstatus = ncx_put_int_uchar(xp, tp, fillp);
24043 #line 3330
24044 		if (status == NC_NOERR) /* report the first encountered error */
24045 #line 3330
24046 			status = lstatus;
24047 #line 3330
24048 	}
24049 #line 3330
24050 
24051 #line 3330
24052 	*xpp = (void *)xp;
24053 #line 3330
24054 	return status;
24055 #line 3330
24056 #endif
24057 #line 3330
24058 }
24059 #line 3330
24060 
24061 int
24062 #line 3331
ncx_putn_int_ushort(void ** xpp,size_t nelems,const ushort * tp,void * fillp)24063 ncx_putn_int_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
24064 #line 3331
24065 {
24066 #line 3331
24067 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
24068 #line 3331
24069 
24070 #line 3331
24071  /* basic algorithm is:
24072 #line 3331
24073   *   - ensure sane alignment of output data
24074 #line 3331
24075   *   - copy (conversion happens automatically) input data
24076 #line 3331
24077   *     to output
24078 #line 3331
24079   *   - update tp to point at next unconverted input, and xpp to point
24080 #line 3331
24081   *     at next location for converted output
24082 #line 3331
24083   */
24084 #line 3331
24085   long i, j, ni;
24086 #line 3331
24087   int tmp[LOOPCNT];        /* in case input is misaligned */
24088 #line 3331
24089   int *xp;
24090 #line 3331
24091   int nrange = 0;         /* number of range errors */
24092 #line 3331
24093   int realign = 0;        /* "do we need to fix input data alignment?" */
24094 #line 3331
24095   long cxp = (long) *((char**)xpp);
24096 #line 3331
24097 
24098 #line 3331
24099   realign = (cxp & 7) % SIZEOF_INT;
24100 #line 3331
24101   /* sjl: manually stripmine so we can limit amount of
24102 #line 3331
24103    * vector work space reserved to LOOPCNT elements. Also
24104 #line 3331
24105    * makes vectorisation easy */
24106 #line 3331
24107   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
24108 #line 3331
24109     ni=Min(nelems-j,LOOPCNT);
24110 #line 3331
24111     if (realign) {
24112 #line 3331
24113       xp = tmp;
24114 #line 3331
24115     } else {
24116 #line 3331
24117       xp = (int *) *xpp;
24118 #line 3331
24119     }
24120 #line 3331
24121    /* copy the next block */
24122 #line 3331
24123 #pragma cdir loopcnt=LOOPCNT
24124 #line 3331
24125 #pragma cdir shortloop
24126 #line 3331
24127     for (i=0; i<ni; i++) {
24128 #line 3331
24129       /* the normal case: */
24130 #line 3331
24131       xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
24132 #line 3331
24133      /* test for range errors (not always needed but do it anyway) */
24134 #line 3331
24135      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
24136 #line 3331
24137      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
24138 #line 3331
24139       nrange += tp[i] > X_INT_MAX ;
24140 #line 3331
24141     }
24142 #line 3331
24143    /* copy workspace back if necessary */
24144 #line 3331
24145     if (realign) {
24146 #line 3331
24147       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
24148 #line 3331
24149       xp = (int *) *xpp;
24150 #line 3331
24151     }
24152 #line 3331
24153    /* update xpp and tp */
24154 #line 3331
24155     xp += ni;
24156 #line 3331
24157     tp += ni;
24158 #line 3331
24159     *xpp = (void*)xp;
24160 #line 3331
24161   }
24162 #line 3331
24163   return nrange == 0 ? NC_NOERR : NC_ERANGE;
24164 #line 3331
24165 
24166 #line 3331
24167 #else   /* not SX */
24168 #line 3331
24169 
24170 #line 3331
24171 	char *xp = (char *) *xpp;
24172 #line 3331
24173 	int status = NC_NOERR;
24174 #line 3331
24175 
24176 #line 3331
24177 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
24178 #line 3331
24179 	{
24180 #line 3331
24181 		int lstatus = ncx_put_int_ushort(xp, tp, fillp);
24182 #line 3331
24183 		if (status == NC_NOERR) /* report the first encountered error */
24184 #line 3331
24185 			status = lstatus;
24186 #line 3331
24187 	}
24188 #line 3331
24189 
24190 #line 3331
24191 	*xpp = (void *)xp;
24192 #line 3331
24193 	return status;
24194 #line 3331
24195 #endif
24196 #line 3331
24197 }
24198 #line 3331
24199 
24200 int
24201 #line 3332
ncx_putn_int_uint(void ** xpp,size_t nelems,const uint * tp,void * fillp)24202 ncx_putn_int_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
24203 #line 3332
24204 {
24205 #line 3332
24206 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
24207 #line 3332
24208 
24209 #line 3332
24210  /* basic algorithm is:
24211 #line 3332
24212   *   - ensure sane alignment of output data
24213 #line 3332
24214   *   - copy (conversion happens automatically) input data
24215 #line 3332
24216   *     to output
24217 #line 3332
24218   *   - update tp to point at next unconverted input, and xpp to point
24219 #line 3332
24220   *     at next location for converted output
24221 #line 3332
24222   */
24223 #line 3332
24224   long i, j, ni;
24225 #line 3332
24226   int tmp[LOOPCNT];        /* in case input is misaligned */
24227 #line 3332
24228   int *xp;
24229 #line 3332
24230   int nrange = 0;         /* number of range errors */
24231 #line 3332
24232   int realign = 0;        /* "do we need to fix input data alignment?" */
24233 #line 3332
24234   long cxp = (long) *((char**)xpp);
24235 #line 3332
24236 
24237 #line 3332
24238   realign = (cxp & 7) % SIZEOF_INT;
24239 #line 3332
24240   /* sjl: manually stripmine so we can limit amount of
24241 #line 3332
24242    * vector work space reserved to LOOPCNT elements. Also
24243 #line 3332
24244    * makes vectorisation easy */
24245 #line 3332
24246   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
24247 #line 3332
24248     ni=Min(nelems-j,LOOPCNT);
24249 #line 3332
24250     if (realign) {
24251 #line 3332
24252       xp = tmp;
24253 #line 3332
24254     } else {
24255 #line 3332
24256       xp = (int *) *xpp;
24257 #line 3332
24258     }
24259 #line 3332
24260    /* copy the next block */
24261 #line 3332
24262 #pragma cdir loopcnt=LOOPCNT
24263 #line 3332
24264 #pragma cdir shortloop
24265 #line 3332
24266     for (i=0; i<ni; i++) {
24267 #line 3332
24268       /* the normal case: */
24269 #line 3332
24270       xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
24271 #line 3332
24272      /* test for range errors (not always needed but do it anyway) */
24273 #line 3332
24274      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
24275 #line 3332
24276      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
24277 #line 3332
24278       nrange += tp[i] > X_INT_MAX ;
24279 #line 3332
24280     }
24281 #line 3332
24282    /* copy workspace back if necessary */
24283 #line 3332
24284     if (realign) {
24285 #line 3332
24286       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
24287 #line 3332
24288       xp = (int *) *xpp;
24289 #line 3332
24290     }
24291 #line 3332
24292    /* update xpp and tp */
24293 #line 3332
24294     xp += ni;
24295 #line 3332
24296     tp += ni;
24297 #line 3332
24298     *xpp = (void*)xp;
24299 #line 3332
24300   }
24301 #line 3332
24302   return nrange == 0 ? NC_NOERR : NC_ERANGE;
24303 #line 3332
24304 
24305 #line 3332
24306 #else   /* not SX */
24307 #line 3332
24308 
24309 #line 3332
24310 	char *xp = (char *) *xpp;
24311 #line 3332
24312 	int status = NC_NOERR;
24313 #line 3332
24314 
24315 #line 3332
24316 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
24317 #line 3332
24318 	{
24319 #line 3332
24320 		int lstatus = ncx_put_int_uint(xp, tp, fillp);
24321 #line 3332
24322 		if (status == NC_NOERR) /* report the first encountered error */
24323 #line 3332
24324 			status = lstatus;
24325 #line 3332
24326 	}
24327 #line 3332
24328 
24329 #line 3332
24330 	*xpp = (void *)xp;
24331 #line 3332
24332 	return status;
24333 #line 3332
24334 #endif
24335 #line 3332
24336 }
24337 #line 3332
24338 
24339 int
24340 #line 3333
ncx_putn_int_ulonglong(void ** xpp,size_t nelems,const ulonglong * tp,void * fillp)24341 ncx_putn_int_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
24342 #line 3333
24343 {
24344 #line 3333
24345 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
24346 #line 3333
24347 
24348 #line 3333
24349  /* basic algorithm is:
24350 #line 3333
24351   *   - ensure sane alignment of output data
24352 #line 3333
24353   *   - copy (conversion happens automatically) input data
24354 #line 3333
24355   *     to output
24356 #line 3333
24357   *   - update tp to point at next unconverted input, and xpp to point
24358 #line 3333
24359   *     at next location for converted output
24360 #line 3333
24361   */
24362 #line 3333
24363   long i, j, ni;
24364 #line 3333
24365   int tmp[LOOPCNT];        /* in case input is misaligned */
24366 #line 3333
24367   int *xp;
24368 #line 3333
24369   int nrange = 0;         /* number of range errors */
24370 #line 3333
24371   int realign = 0;        /* "do we need to fix input data alignment?" */
24372 #line 3333
24373   long cxp = (long) *((char**)xpp);
24374 #line 3333
24375 
24376 #line 3333
24377   realign = (cxp & 7) % SIZEOF_INT;
24378 #line 3333
24379   /* sjl: manually stripmine so we can limit amount of
24380 #line 3333
24381    * vector work space reserved to LOOPCNT elements. Also
24382 #line 3333
24383    * makes vectorisation easy */
24384 #line 3333
24385   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
24386 #line 3333
24387     ni=Min(nelems-j,LOOPCNT);
24388 #line 3333
24389     if (realign) {
24390 #line 3333
24391       xp = tmp;
24392 #line 3333
24393     } else {
24394 #line 3333
24395       xp = (int *) *xpp;
24396 #line 3333
24397     }
24398 #line 3333
24399    /* copy the next block */
24400 #line 3333
24401 #pragma cdir loopcnt=LOOPCNT
24402 #line 3333
24403 #pragma cdir shortloop
24404 #line 3333
24405     for (i=0; i<ni; i++) {
24406 #line 3333
24407       /* the normal case: */
24408 #line 3333
24409       xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
24410 #line 3333
24411      /* test for range errors (not always needed but do it anyway) */
24412 #line 3333
24413      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
24414 #line 3333
24415      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
24416 #line 3333
24417       nrange += tp[i] > X_INT_MAX ;
24418 #line 3333
24419     }
24420 #line 3333
24421    /* copy workspace back if necessary */
24422 #line 3333
24423     if (realign) {
24424 #line 3333
24425       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
24426 #line 3333
24427       xp = (int *) *xpp;
24428 #line 3333
24429     }
24430 #line 3333
24431    /* update xpp and tp */
24432 #line 3333
24433     xp += ni;
24434 #line 3333
24435     tp += ni;
24436 #line 3333
24437     *xpp = (void*)xp;
24438 #line 3333
24439   }
24440 #line 3333
24441   return nrange == 0 ? NC_NOERR : NC_ERANGE;
24442 #line 3333
24443 
24444 #line 3333
24445 #else   /* not SX */
24446 #line 3333
24447 
24448 #line 3333
24449 	char *xp = (char *) *xpp;
24450 #line 3333
24451 	int status = NC_NOERR;
24452 #line 3333
24453 
24454 #line 3333
24455 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
24456 #line 3333
24457 	{
24458 #line 3333
24459 		int lstatus = ncx_put_int_ulonglong(xp, tp, fillp);
24460 #line 3333
24461 		if (status == NC_NOERR) /* report the first encountered error */
24462 #line 3333
24463 			status = lstatus;
24464 #line 3333
24465 	}
24466 #line 3333
24467 
24468 #line 3333
24469 	*xpp = (void *)xp;
24470 #line 3333
24471 	return status;
24472 #line 3333
24473 #endif
24474 #line 3333
24475 }
24476 #line 3333
24477 
24478 
24479 /* uint ----------------------------------------------------------------------*/
24480 
24481 #if X_SIZEOF_UINT == SIZEOF_UINT
24482 /* optimized version */
24483 int
ncx_getn_uint_uint(const void ** xpp,size_t nelems,unsigned int * tp)24484 ncx_getn_uint_uint(const void **xpp, size_t nelems, unsigned int *tp)
24485 {
24486 #ifdef WORDS_BIGENDIAN
24487 	(void) memcpy(tp, *xpp, (size_t)nelems * SIZEOF_UINT);
24488 # else
24489 	swapn4b(tp, *xpp, nelems);
24490 # endif
24491 	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_UINT);
24492 	return NC_NOERR;
24493 }
24494 #else
24495 int
24496 #line 3351
ncx_getn_uint_uint(const void ** xpp,size_t nelems,uint * tp)24497 ncx_getn_uint_uint(const void **xpp, size_t nelems, uint *tp)
24498 #line 3351
24499 {
24500 #line 3351
24501 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
24502 #line 3351
24503 
24504 #line 3351
24505  /* basic algorithm is:
24506 #line 3351
24507   *   - ensure sane alignment of input data
24508 #line 3351
24509   *   - copy (conversion happens automatically) input data
24510 #line 3351
24511   *     to output
24512 #line 3351
24513   *   - update xpp to point at next unconverted input, and tp to point
24514 #line 3351
24515   *     at next location for converted output
24516 #line 3351
24517   */
24518 #line 3351
24519   long i, j, ni;
24520 #line 3351
24521   uint tmp[LOOPCNT];        /* in case input is misaligned */
24522 #line 3351
24523   uint *xp;
24524 #line 3351
24525   int nrange = 0;         /* number of range errors */
24526 #line 3351
24527   int realign = 0;        /* "do we need to fix input data alignment?" */
24528 #line 3351
24529   long cxp = (long) *((char**)xpp);
24530 #line 3351
24531 
24532 #line 3351
24533   realign = (cxp & 7) % SIZEOF_UINT;
24534 #line 3351
24535   /* sjl: manually stripmine so we can limit amount of
24536 #line 3351
24537    * vector work space reserved to LOOPCNT elements. Also
24538 #line 3351
24539    * makes vectorisation easy */
24540 #line 3351
24541   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
24542 #line 3351
24543     ni=Min(nelems-j,LOOPCNT);
24544 #line 3351
24545     if (realign) {
24546 #line 3351
24547       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
24548 #line 3351
24549       xp = tmp;
24550 #line 3351
24551     } else {
24552 #line 3351
24553       xp = (uint *) *xpp;
24554 #line 3351
24555     }
24556 #line 3351
24557    /* copy the next block */
24558 #line 3351
24559 #pragma cdir loopcnt=LOOPCNT
24560 #line 3351
24561 #pragma cdir shortloop
24562 #line 3351
24563     for (i=0; i<ni; i++) {
24564 #line 3351
24565       tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
24566 #line 3351
24567      /* test for range errors (not always needed but do it anyway) */
24568 #line 3351
24569      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
24570 #line 3351
24571      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
24572 #line 3351
24573       nrange += xp[i] > UINT_MAX ;
24574 #line 3351
24575     }
24576 #line 3351
24577    /* update xpp and tp */
24578 #line 3351
24579     if (realign) xp = (uint *) *xpp;
24580 #line 3351
24581     xp += ni;
24582 #line 3351
24583     tp += ni;
24584 #line 3351
24585     *xpp = (void*)xp;
24586 #line 3351
24587   }
24588 #line 3351
24589   return nrange == 0 ? NC_NOERR : NC_ERANGE;
24590 #line 3351
24591 
24592 #line 3351
24593 #else   /* not SX */
24594 #line 3351
24595 	const char *xp = (const char *) *xpp;
24596 #line 3351
24597 	int status = NC_NOERR;
24598 #line 3351
24599 
24600 #line 3351
24601 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
24602 #line 3351
24603 	{
24604 #line 3351
24605 		const int lstatus = ncx_get_uint_uint(xp, tp);
24606 #line 3351
24607 		if (status == NC_NOERR) /* report the first encountered error */
24608 #line 3351
24609 			status = lstatus;
24610 #line 3351
24611 	}
24612 #line 3351
24613 
24614 #line 3351
24615 	*xpp = (const void *)xp;
24616 #line 3351
24617 	return status;
24618 #line 3351
24619 #endif
24620 #line 3351
24621 }
24622 #line 3351
24623 
24624 #endif
24625 int
24626 #line 3353
ncx_getn_uint_schar(const void ** xpp,size_t nelems,schar * tp)24627 ncx_getn_uint_schar(const void **xpp, size_t nelems, schar *tp)
24628 #line 3353
24629 {
24630 #line 3353
24631 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
24632 #line 3353
24633 
24634 #line 3353
24635  /* basic algorithm is:
24636 #line 3353
24637   *   - ensure sane alignment of input data
24638 #line 3353
24639   *   - copy (conversion happens automatically) input data
24640 #line 3353
24641   *     to output
24642 #line 3353
24643   *   - update xpp to point at next unconverted input, and tp to point
24644 #line 3353
24645   *     at next location for converted output
24646 #line 3353
24647   */
24648 #line 3353
24649   long i, j, ni;
24650 #line 3353
24651   uint tmp[LOOPCNT];        /* in case input is misaligned */
24652 #line 3353
24653   uint *xp;
24654 #line 3353
24655   int nrange = 0;         /* number of range errors */
24656 #line 3353
24657   int realign = 0;        /* "do we need to fix input data alignment?" */
24658 #line 3353
24659   long cxp = (long) *((char**)xpp);
24660 #line 3353
24661 
24662 #line 3353
24663   realign = (cxp & 7) % SIZEOF_UINT;
24664 #line 3353
24665   /* sjl: manually stripmine so we can limit amount of
24666 #line 3353
24667    * vector work space reserved to LOOPCNT elements. Also
24668 #line 3353
24669    * makes vectorisation easy */
24670 #line 3353
24671   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
24672 #line 3353
24673     ni=Min(nelems-j,LOOPCNT);
24674 #line 3353
24675     if (realign) {
24676 #line 3353
24677       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
24678 #line 3353
24679       xp = tmp;
24680 #line 3353
24681     } else {
24682 #line 3353
24683       xp = (uint *) *xpp;
24684 #line 3353
24685     }
24686 #line 3353
24687    /* copy the next block */
24688 #line 3353
24689 #pragma cdir loopcnt=LOOPCNT
24690 #line 3353
24691 #pragma cdir shortloop
24692 #line 3353
24693     for (i=0; i<ni; i++) {
24694 #line 3353
24695       tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
24696 #line 3353
24697      /* test for range errors (not always needed but do it anyway) */
24698 #line 3353
24699      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
24700 #line 3353
24701      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
24702 #line 3353
24703       nrange += xp[i] > SCHAR_MAX ;
24704 #line 3353
24705     }
24706 #line 3353
24707    /* update xpp and tp */
24708 #line 3353
24709     if (realign) xp = (uint *) *xpp;
24710 #line 3353
24711     xp += ni;
24712 #line 3353
24713     tp += ni;
24714 #line 3353
24715     *xpp = (void*)xp;
24716 #line 3353
24717   }
24718 #line 3353
24719   return nrange == 0 ? NC_NOERR : NC_ERANGE;
24720 #line 3353
24721 
24722 #line 3353
24723 #else   /* not SX */
24724 #line 3353
24725 	const char *xp = (const char *) *xpp;
24726 #line 3353
24727 	int status = NC_NOERR;
24728 #line 3353
24729 
24730 #line 3353
24731 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
24732 #line 3353
24733 	{
24734 #line 3353
24735 		const int lstatus = ncx_get_uint_schar(xp, tp);
24736 #line 3353
24737 		if (status == NC_NOERR) /* report the first encountered error */
24738 #line 3353
24739 			status = lstatus;
24740 #line 3353
24741 	}
24742 #line 3353
24743 
24744 #line 3353
24745 	*xpp = (const void *)xp;
24746 #line 3353
24747 	return status;
24748 #line 3353
24749 #endif
24750 #line 3353
24751 }
24752 #line 3353
24753 
24754 int
24755 #line 3354
ncx_getn_uint_short(const void ** xpp,size_t nelems,short * tp)24756 ncx_getn_uint_short(const void **xpp, size_t nelems, short *tp)
24757 #line 3354
24758 {
24759 #line 3354
24760 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
24761 #line 3354
24762 
24763 #line 3354
24764  /* basic algorithm is:
24765 #line 3354
24766   *   - ensure sane alignment of input data
24767 #line 3354
24768   *   - copy (conversion happens automatically) input data
24769 #line 3354
24770   *     to output
24771 #line 3354
24772   *   - update xpp to point at next unconverted input, and tp to point
24773 #line 3354
24774   *     at next location for converted output
24775 #line 3354
24776   */
24777 #line 3354
24778   long i, j, ni;
24779 #line 3354
24780   uint tmp[LOOPCNT];        /* in case input is misaligned */
24781 #line 3354
24782   uint *xp;
24783 #line 3354
24784   int nrange = 0;         /* number of range errors */
24785 #line 3354
24786   int realign = 0;        /* "do we need to fix input data alignment?" */
24787 #line 3354
24788   long cxp = (long) *((char**)xpp);
24789 #line 3354
24790 
24791 #line 3354
24792   realign = (cxp & 7) % SIZEOF_UINT;
24793 #line 3354
24794   /* sjl: manually stripmine so we can limit amount of
24795 #line 3354
24796    * vector work space reserved to LOOPCNT elements. Also
24797 #line 3354
24798    * makes vectorisation easy */
24799 #line 3354
24800   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
24801 #line 3354
24802     ni=Min(nelems-j,LOOPCNT);
24803 #line 3354
24804     if (realign) {
24805 #line 3354
24806       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
24807 #line 3354
24808       xp = tmp;
24809 #line 3354
24810     } else {
24811 #line 3354
24812       xp = (uint *) *xpp;
24813 #line 3354
24814     }
24815 #line 3354
24816    /* copy the next block */
24817 #line 3354
24818 #pragma cdir loopcnt=LOOPCNT
24819 #line 3354
24820 #pragma cdir shortloop
24821 #line 3354
24822     for (i=0; i<ni; i++) {
24823 #line 3354
24824       tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
24825 #line 3354
24826      /* test for range errors (not always needed but do it anyway) */
24827 #line 3354
24828      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
24829 #line 3354
24830      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
24831 #line 3354
24832       nrange += xp[i] > SHORT_MAX ;
24833 #line 3354
24834     }
24835 #line 3354
24836    /* update xpp and tp */
24837 #line 3354
24838     if (realign) xp = (uint *) *xpp;
24839 #line 3354
24840     xp += ni;
24841 #line 3354
24842     tp += ni;
24843 #line 3354
24844     *xpp = (void*)xp;
24845 #line 3354
24846   }
24847 #line 3354
24848   return nrange == 0 ? NC_NOERR : NC_ERANGE;
24849 #line 3354
24850 
24851 #line 3354
24852 #else   /* not SX */
24853 #line 3354
24854 	const char *xp = (const char *) *xpp;
24855 #line 3354
24856 	int status = NC_NOERR;
24857 #line 3354
24858 
24859 #line 3354
24860 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
24861 #line 3354
24862 	{
24863 #line 3354
24864 		const int lstatus = ncx_get_uint_short(xp, tp);
24865 #line 3354
24866 		if (status == NC_NOERR) /* report the first encountered error */
24867 #line 3354
24868 			status = lstatus;
24869 #line 3354
24870 	}
24871 #line 3354
24872 
24873 #line 3354
24874 	*xpp = (const void *)xp;
24875 #line 3354
24876 	return status;
24877 #line 3354
24878 #endif
24879 #line 3354
24880 }
24881 #line 3354
24882 
24883 int
24884 #line 3355
ncx_getn_uint_int(const void ** xpp,size_t nelems,int * tp)24885 ncx_getn_uint_int(const void **xpp, size_t nelems, int *tp)
24886 #line 3355
24887 {
24888 #line 3355
24889 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
24890 #line 3355
24891 
24892 #line 3355
24893  /* basic algorithm is:
24894 #line 3355
24895   *   - ensure sane alignment of input data
24896 #line 3355
24897   *   - copy (conversion happens automatically) input data
24898 #line 3355
24899   *     to output
24900 #line 3355
24901   *   - update xpp to point at next unconverted input, and tp to point
24902 #line 3355
24903   *     at next location for converted output
24904 #line 3355
24905   */
24906 #line 3355
24907   long i, j, ni;
24908 #line 3355
24909   uint tmp[LOOPCNT];        /* in case input is misaligned */
24910 #line 3355
24911   uint *xp;
24912 #line 3355
24913   int nrange = 0;         /* number of range errors */
24914 #line 3355
24915   int realign = 0;        /* "do we need to fix input data alignment?" */
24916 #line 3355
24917   long cxp = (long) *((char**)xpp);
24918 #line 3355
24919 
24920 #line 3355
24921   realign = (cxp & 7) % SIZEOF_UINT;
24922 #line 3355
24923   /* sjl: manually stripmine so we can limit amount of
24924 #line 3355
24925    * vector work space reserved to LOOPCNT elements. Also
24926 #line 3355
24927    * makes vectorisation easy */
24928 #line 3355
24929   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
24930 #line 3355
24931     ni=Min(nelems-j,LOOPCNT);
24932 #line 3355
24933     if (realign) {
24934 #line 3355
24935       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
24936 #line 3355
24937       xp = tmp;
24938 #line 3355
24939     } else {
24940 #line 3355
24941       xp = (uint *) *xpp;
24942 #line 3355
24943     }
24944 #line 3355
24945    /* copy the next block */
24946 #line 3355
24947 #pragma cdir loopcnt=LOOPCNT
24948 #line 3355
24949 #pragma cdir shortloop
24950 #line 3355
24951     for (i=0; i<ni; i++) {
24952 #line 3355
24953       tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
24954 #line 3355
24955      /* test for range errors (not always needed but do it anyway) */
24956 #line 3355
24957      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
24958 #line 3355
24959      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
24960 #line 3355
24961       nrange += xp[i] > INT_MAX ;
24962 #line 3355
24963     }
24964 #line 3355
24965    /* update xpp and tp */
24966 #line 3355
24967     if (realign) xp = (uint *) *xpp;
24968 #line 3355
24969     xp += ni;
24970 #line 3355
24971     tp += ni;
24972 #line 3355
24973     *xpp = (void*)xp;
24974 #line 3355
24975   }
24976 #line 3355
24977   return nrange == 0 ? NC_NOERR : NC_ERANGE;
24978 #line 3355
24979 
24980 #line 3355
24981 #else   /* not SX */
24982 #line 3355
24983 	const char *xp = (const char *) *xpp;
24984 #line 3355
24985 	int status = NC_NOERR;
24986 #line 3355
24987 
24988 #line 3355
24989 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
24990 #line 3355
24991 	{
24992 #line 3355
24993 		const int lstatus = ncx_get_uint_int(xp, tp);
24994 #line 3355
24995 		if (status == NC_NOERR) /* report the first encountered error */
24996 #line 3355
24997 			status = lstatus;
24998 #line 3355
24999 	}
25000 #line 3355
25001 
25002 #line 3355
25003 	*xpp = (const void *)xp;
25004 #line 3355
25005 	return status;
25006 #line 3355
25007 #endif
25008 #line 3355
25009 }
25010 #line 3355
25011 
25012 int
25013 #line 3356
ncx_getn_uint_long(const void ** xpp,size_t nelems,long * tp)25014 ncx_getn_uint_long(const void **xpp, size_t nelems, long *tp)
25015 #line 3356
25016 {
25017 #line 3356
25018 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
25019 #line 3356
25020 
25021 #line 3356
25022  /* basic algorithm is:
25023 #line 3356
25024   *   - ensure sane alignment of input data
25025 #line 3356
25026   *   - copy (conversion happens automatically) input data
25027 #line 3356
25028   *     to output
25029 #line 3356
25030   *   - update xpp to point at next unconverted input, and tp to point
25031 #line 3356
25032   *     at next location for converted output
25033 #line 3356
25034   */
25035 #line 3356
25036   long i, j, ni;
25037 #line 3356
25038   uint tmp[LOOPCNT];        /* in case input is misaligned */
25039 #line 3356
25040   uint *xp;
25041 #line 3356
25042   int nrange = 0;         /* number of range errors */
25043 #line 3356
25044   int realign = 0;        /* "do we need to fix input data alignment?" */
25045 #line 3356
25046   long cxp = (long) *((char**)xpp);
25047 #line 3356
25048 
25049 #line 3356
25050   realign = (cxp & 7) % SIZEOF_UINT;
25051 #line 3356
25052   /* sjl: manually stripmine so we can limit amount of
25053 #line 3356
25054    * vector work space reserved to LOOPCNT elements. Also
25055 #line 3356
25056    * makes vectorisation easy */
25057 #line 3356
25058   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
25059 #line 3356
25060     ni=Min(nelems-j,LOOPCNT);
25061 #line 3356
25062     if (realign) {
25063 #line 3356
25064       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
25065 #line 3356
25066       xp = tmp;
25067 #line 3356
25068     } else {
25069 #line 3356
25070       xp = (uint *) *xpp;
25071 #line 3356
25072     }
25073 #line 3356
25074    /* copy the next block */
25075 #line 3356
25076 #pragma cdir loopcnt=LOOPCNT
25077 #line 3356
25078 #pragma cdir shortloop
25079 #line 3356
25080     for (i=0; i<ni; i++) {
25081 #line 3356
25082       tp[i] = (long) Max( LONG_MIN, Min(LONG_MAX, (long) xp[i]));
25083 #line 3356
25084      /* test for range errors (not always needed but do it anyway) */
25085 #line 3356
25086      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
25087 #line 3356
25088      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
25089 #line 3356
25090       nrange += xp[i] > LONG_MAX ;
25091 #line 3356
25092     }
25093 #line 3356
25094    /* update xpp and tp */
25095 #line 3356
25096     if (realign) xp = (uint *) *xpp;
25097 #line 3356
25098     xp += ni;
25099 #line 3356
25100     tp += ni;
25101 #line 3356
25102     *xpp = (void*)xp;
25103 #line 3356
25104   }
25105 #line 3356
25106   return nrange == 0 ? NC_NOERR : NC_ERANGE;
25107 #line 3356
25108 
25109 #line 3356
25110 #else   /* not SX */
25111 #line 3356
25112 	const char *xp = (const char *) *xpp;
25113 #line 3356
25114 	int status = NC_NOERR;
25115 #line 3356
25116 
25117 #line 3356
25118 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
25119 #line 3356
25120 	{
25121 #line 3356
25122 		const int lstatus = ncx_get_uint_long(xp, tp);
25123 #line 3356
25124 		if (status == NC_NOERR) /* report the first encountered error */
25125 #line 3356
25126 			status = lstatus;
25127 #line 3356
25128 	}
25129 #line 3356
25130 
25131 #line 3356
25132 	*xpp = (const void *)xp;
25133 #line 3356
25134 	return status;
25135 #line 3356
25136 #endif
25137 #line 3356
25138 }
25139 #line 3356
25140 
25141 int
25142 #line 3357
ncx_getn_uint_float(const void ** xpp,size_t nelems,float * tp)25143 ncx_getn_uint_float(const void **xpp, size_t nelems, float *tp)
25144 #line 3357
25145 {
25146 #line 3357
25147 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
25148 #line 3357
25149 
25150 #line 3357
25151  /* basic algorithm is:
25152 #line 3357
25153   *   - ensure sane alignment of input data
25154 #line 3357
25155   *   - copy (conversion happens automatically) input data
25156 #line 3357
25157   *     to output
25158 #line 3357
25159   *   - update xpp to point at next unconverted input, and tp to point
25160 #line 3357
25161   *     at next location for converted output
25162 #line 3357
25163   */
25164 #line 3357
25165   long i, j, ni;
25166 #line 3357
25167   uint tmp[LOOPCNT];        /* in case input is misaligned */
25168 #line 3357
25169   uint *xp;
25170 #line 3357
25171   int nrange = 0;         /* number of range errors */
25172 #line 3357
25173   int realign = 0;        /* "do we need to fix input data alignment?" */
25174 #line 3357
25175   long cxp = (long) *((char**)xpp);
25176 #line 3357
25177 
25178 #line 3357
25179   realign = (cxp & 7) % SIZEOF_UINT;
25180 #line 3357
25181   /* sjl: manually stripmine so we can limit amount of
25182 #line 3357
25183    * vector work space reserved to LOOPCNT elements. Also
25184 #line 3357
25185    * makes vectorisation easy */
25186 #line 3357
25187   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
25188 #line 3357
25189     ni=Min(nelems-j,LOOPCNT);
25190 #line 3357
25191     if (realign) {
25192 #line 3357
25193       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
25194 #line 3357
25195       xp = tmp;
25196 #line 3357
25197     } else {
25198 #line 3357
25199       xp = (uint *) *xpp;
25200 #line 3357
25201     }
25202 #line 3357
25203    /* copy the next block */
25204 #line 3357
25205 #pragma cdir loopcnt=LOOPCNT
25206 #line 3357
25207 #pragma cdir shortloop
25208 #line 3357
25209     for (i=0; i<ni; i++) {
25210 #line 3357
25211       tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
25212 #line 3357
25213      /* test for range errors (not always needed but do it anyway) */
25214 #line 3357
25215      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
25216 #line 3357
25217      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
25218 #line 3357
25219       nrange += xp[i] > FLOAT_MAX ;
25220 #line 3357
25221     }
25222 #line 3357
25223    /* update xpp and tp */
25224 #line 3357
25225     if (realign) xp = (uint *) *xpp;
25226 #line 3357
25227     xp += ni;
25228 #line 3357
25229     tp += ni;
25230 #line 3357
25231     *xpp = (void*)xp;
25232 #line 3357
25233   }
25234 #line 3357
25235   return nrange == 0 ? NC_NOERR : NC_ERANGE;
25236 #line 3357
25237 
25238 #line 3357
25239 #else   /* not SX */
25240 #line 3357
25241 	const char *xp = (const char *) *xpp;
25242 #line 3357
25243 	int status = NC_NOERR;
25244 #line 3357
25245 
25246 #line 3357
25247 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
25248 #line 3357
25249 	{
25250 #line 3357
25251 		const int lstatus = ncx_get_uint_float(xp, tp);
25252 #line 3357
25253 		if (status == NC_NOERR) /* report the first encountered error */
25254 #line 3357
25255 			status = lstatus;
25256 #line 3357
25257 	}
25258 #line 3357
25259 
25260 #line 3357
25261 	*xpp = (const void *)xp;
25262 #line 3357
25263 	return status;
25264 #line 3357
25265 #endif
25266 #line 3357
25267 }
25268 #line 3357
25269 
25270 int
25271 #line 3358
ncx_getn_uint_double(const void ** xpp,size_t nelems,double * tp)25272 ncx_getn_uint_double(const void **xpp, size_t nelems, double *tp)
25273 #line 3358
25274 {
25275 #line 3358
25276 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
25277 #line 3358
25278 
25279 #line 3358
25280  /* basic algorithm is:
25281 #line 3358
25282   *   - ensure sane alignment of input data
25283 #line 3358
25284   *   - copy (conversion happens automatically) input data
25285 #line 3358
25286   *     to output
25287 #line 3358
25288   *   - update xpp to point at next unconverted input, and tp to point
25289 #line 3358
25290   *     at next location for converted output
25291 #line 3358
25292   */
25293 #line 3358
25294   long i, j, ni;
25295 #line 3358
25296   uint tmp[LOOPCNT];        /* in case input is misaligned */
25297 #line 3358
25298   uint *xp;
25299 #line 3358
25300   int nrange = 0;         /* number of range errors */
25301 #line 3358
25302   int realign = 0;        /* "do we need to fix input data alignment?" */
25303 #line 3358
25304   long cxp = (long) *((char**)xpp);
25305 #line 3358
25306 
25307 #line 3358
25308   realign = (cxp & 7) % SIZEOF_UINT;
25309 #line 3358
25310   /* sjl: manually stripmine so we can limit amount of
25311 #line 3358
25312    * vector work space reserved to LOOPCNT elements. Also
25313 #line 3358
25314    * makes vectorisation easy */
25315 #line 3358
25316   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
25317 #line 3358
25318     ni=Min(nelems-j,LOOPCNT);
25319 #line 3358
25320     if (realign) {
25321 #line 3358
25322       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
25323 #line 3358
25324       xp = tmp;
25325 #line 3358
25326     } else {
25327 #line 3358
25328       xp = (uint *) *xpp;
25329 #line 3358
25330     }
25331 #line 3358
25332    /* copy the next block */
25333 #line 3358
25334 #pragma cdir loopcnt=LOOPCNT
25335 #line 3358
25336 #pragma cdir shortloop
25337 #line 3358
25338     for (i=0; i<ni; i++) {
25339 #line 3358
25340       tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
25341 #line 3358
25342      /* test for range errors (not always needed but do it anyway) */
25343 #line 3358
25344      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
25345 #line 3358
25346      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
25347 #line 3358
25348       nrange += xp[i] > DOUBLE_MAX ;
25349 #line 3358
25350     }
25351 #line 3358
25352    /* update xpp and tp */
25353 #line 3358
25354     if (realign) xp = (uint *) *xpp;
25355 #line 3358
25356     xp += ni;
25357 #line 3358
25358     tp += ni;
25359 #line 3358
25360     *xpp = (void*)xp;
25361 #line 3358
25362   }
25363 #line 3358
25364   return nrange == 0 ? NC_NOERR : NC_ERANGE;
25365 #line 3358
25366 
25367 #line 3358
25368 #else   /* not SX */
25369 #line 3358
25370 	const char *xp = (const char *) *xpp;
25371 #line 3358
25372 	int status = NC_NOERR;
25373 #line 3358
25374 
25375 #line 3358
25376 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
25377 #line 3358
25378 	{
25379 #line 3358
25380 		const int lstatus = ncx_get_uint_double(xp, tp);
25381 #line 3358
25382 		if (status == NC_NOERR) /* report the first encountered error */
25383 #line 3358
25384 			status = lstatus;
25385 #line 3358
25386 	}
25387 #line 3358
25388 
25389 #line 3358
25390 	*xpp = (const void *)xp;
25391 #line 3358
25392 	return status;
25393 #line 3358
25394 #endif
25395 #line 3358
25396 }
25397 #line 3358
25398 
25399 int
25400 #line 3359
ncx_getn_uint_longlong(const void ** xpp,size_t nelems,longlong * tp)25401 ncx_getn_uint_longlong(const void **xpp, size_t nelems, longlong *tp)
25402 #line 3359
25403 {
25404 #line 3359
25405 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
25406 #line 3359
25407 
25408 #line 3359
25409  /* basic algorithm is:
25410 #line 3359
25411   *   - ensure sane alignment of input data
25412 #line 3359
25413   *   - copy (conversion happens automatically) input data
25414 #line 3359
25415   *     to output
25416 #line 3359
25417   *   - update xpp to point at next unconverted input, and tp to point
25418 #line 3359
25419   *     at next location for converted output
25420 #line 3359
25421   */
25422 #line 3359
25423   long i, j, ni;
25424 #line 3359
25425   uint tmp[LOOPCNT];        /* in case input is misaligned */
25426 #line 3359
25427   uint *xp;
25428 #line 3359
25429   int nrange = 0;         /* number of range errors */
25430 #line 3359
25431   int realign = 0;        /* "do we need to fix input data alignment?" */
25432 #line 3359
25433   long cxp = (long) *((char**)xpp);
25434 #line 3359
25435 
25436 #line 3359
25437   realign = (cxp & 7) % SIZEOF_UINT;
25438 #line 3359
25439   /* sjl: manually stripmine so we can limit amount of
25440 #line 3359
25441    * vector work space reserved to LOOPCNT elements. Also
25442 #line 3359
25443    * makes vectorisation easy */
25444 #line 3359
25445   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
25446 #line 3359
25447     ni=Min(nelems-j,LOOPCNT);
25448 #line 3359
25449     if (realign) {
25450 #line 3359
25451       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
25452 #line 3359
25453       xp = tmp;
25454 #line 3359
25455     } else {
25456 #line 3359
25457       xp = (uint *) *xpp;
25458 #line 3359
25459     }
25460 #line 3359
25461    /* copy the next block */
25462 #line 3359
25463 #pragma cdir loopcnt=LOOPCNT
25464 #line 3359
25465 #pragma cdir shortloop
25466 #line 3359
25467     for (i=0; i<ni; i++) {
25468 #line 3359
25469       tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
25470 #line 3359
25471      /* test for range errors (not always needed but do it anyway) */
25472 #line 3359
25473      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
25474 #line 3359
25475      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
25476 #line 3359
25477       nrange += xp[i] > LONGLONG_MAX ;
25478 #line 3359
25479     }
25480 #line 3359
25481    /* update xpp and tp */
25482 #line 3359
25483     if (realign) xp = (uint *) *xpp;
25484 #line 3359
25485     xp += ni;
25486 #line 3359
25487     tp += ni;
25488 #line 3359
25489     *xpp = (void*)xp;
25490 #line 3359
25491   }
25492 #line 3359
25493   return nrange == 0 ? NC_NOERR : NC_ERANGE;
25494 #line 3359
25495 
25496 #line 3359
25497 #else   /* not SX */
25498 #line 3359
25499 	const char *xp = (const char *) *xpp;
25500 #line 3359
25501 	int status = NC_NOERR;
25502 #line 3359
25503 
25504 #line 3359
25505 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
25506 #line 3359
25507 	{
25508 #line 3359
25509 		const int lstatus = ncx_get_uint_longlong(xp, tp);
25510 #line 3359
25511 		if (status == NC_NOERR) /* report the first encountered error */
25512 #line 3359
25513 			status = lstatus;
25514 #line 3359
25515 	}
25516 #line 3359
25517 
25518 #line 3359
25519 	*xpp = (const void *)xp;
25520 #line 3359
25521 	return status;
25522 #line 3359
25523 #endif
25524 #line 3359
25525 }
25526 #line 3359
25527 
25528 int
25529 #line 3360
ncx_getn_uint_uchar(const void ** xpp,size_t nelems,uchar * tp)25530 ncx_getn_uint_uchar(const void **xpp, size_t nelems, uchar *tp)
25531 #line 3360
25532 {
25533 #line 3360
25534 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
25535 #line 3360
25536 
25537 #line 3360
25538  /* basic algorithm is:
25539 #line 3360
25540   *   - ensure sane alignment of input data
25541 #line 3360
25542   *   - copy (conversion happens automatically) input data
25543 #line 3360
25544   *     to output
25545 #line 3360
25546   *   - update xpp to point at next unconverted input, and tp to point
25547 #line 3360
25548   *     at next location for converted output
25549 #line 3360
25550   */
25551 #line 3360
25552   long i, j, ni;
25553 #line 3360
25554   uint tmp[LOOPCNT];        /* in case input is misaligned */
25555 #line 3360
25556   uint *xp;
25557 #line 3360
25558   int nrange = 0;         /* number of range errors */
25559 #line 3360
25560   int realign = 0;        /* "do we need to fix input data alignment?" */
25561 #line 3360
25562   long cxp = (long) *((char**)xpp);
25563 #line 3360
25564 
25565 #line 3360
25566   realign = (cxp & 7) % SIZEOF_UINT;
25567 #line 3360
25568   /* sjl: manually stripmine so we can limit amount of
25569 #line 3360
25570    * vector work space reserved to LOOPCNT elements. Also
25571 #line 3360
25572    * makes vectorisation easy */
25573 #line 3360
25574   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
25575 #line 3360
25576     ni=Min(nelems-j,LOOPCNT);
25577 #line 3360
25578     if (realign) {
25579 #line 3360
25580       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
25581 #line 3360
25582       xp = tmp;
25583 #line 3360
25584     } else {
25585 #line 3360
25586       xp = (uint *) *xpp;
25587 #line 3360
25588     }
25589 #line 3360
25590    /* copy the next block */
25591 #line 3360
25592 #pragma cdir loopcnt=LOOPCNT
25593 #line 3360
25594 #pragma cdir shortloop
25595 #line 3360
25596     for (i=0; i<ni; i++) {
25597 #line 3360
25598       tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
25599 #line 3360
25600      /* test for range errors (not always needed but do it anyway) */
25601 #line 3360
25602      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
25603 #line 3360
25604      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
25605 #line 3360
25606       nrange += xp[i] > UCHAR_MAX ;
25607 #line 3360
25608     }
25609 #line 3360
25610    /* update xpp and tp */
25611 #line 3360
25612     if (realign) xp = (uint *) *xpp;
25613 #line 3360
25614     xp += ni;
25615 #line 3360
25616     tp += ni;
25617 #line 3360
25618     *xpp = (void*)xp;
25619 #line 3360
25620   }
25621 #line 3360
25622   return nrange == 0 ? NC_NOERR : NC_ERANGE;
25623 #line 3360
25624 
25625 #line 3360
25626 #else   /* not SX */
25627 #line 3360
25628 	const char *xp = (const char *) *xpp;
25629 #line 3360
25630 	int status = NC_NOERR;
25631 #line 3360
25632 
25633 #line 3360
25634 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
25635 #line 3360
25636 	{
25637 #line 3360
25638 		const int lstatus = ncx_get_uint_uchar(xp, tp);
25639 #line 3360
25640 		if (status == NC_NOERR) /* report the first encountered error */
25641 #line 3360
25642 			status = lstatus;
25643 #line 3360
25644 	}
25645 #line 3360
25646 
25647 #line 3360
25648 	*xpp = (const void *)xp;
25649 #line 3360
25650 	return status;
25651 #line 3360
25652 #endif
25653 #line 3360
25654 }
25655 #line 3360
25656 
25657 int
25658 #line 3361
ncx_getn_uint_ushort(const void ** xpp,size_t nelems,ushort * tp)25659 ncx_getn_uint_ushort(const void **xpp, size_t nelems, ushort *tp)
25660 #line 3361
25661 {
25662 #line 3361
25663 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
25664 #line 3361
25665 
25666 #line 3361
25667  /* basic algorithm is:
25668 #line 3361
25669   *   - ensure sane alignment of input data
25670 #line 3361
25671   *   - copy (conversion happens automatically) input data
25672 #line 3361
25673   *     to output
25674 #line 3361
25675   *   - update xpp to point at next unconverted input, and tp to point
25676 #line 3361
25677   *     at next location for converted output
25678 #line 3361
25679   */
25680 #line 3361
25681   long i, j, ni;
25682 #line 3361
25683   uint tmp[LOOPCNT];        /* in case input is misaligned */
25684 #line 3361
25685   uint *xp;
25686 #line 3361
25687   int nrange = 0;         /* number of range errors */
25688 #line 3361
25689   int realign = 0;        /* "do we need to fix input data alignment?" */
25690 #line 3361
25691   long cxp = (long) *((char**)xpp);
25692 #line 3361
25693 
25694 #line 3361
25695   realign = (cxp & 7) % SIZEOF_UINT;
25696 #line 3361
25697   /* sjl: manually stripmine so we can limit amount of
25698 #line 3361
25699    * vector work space reserved to LOOPCNT elements. Also
25700 #line 3361
25701    * makes vectorisation easy */
25702 #line 3361
25703   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
25704 #line 3361
25705     ni=Min(nelems-j,LOOPCNT);
25706 #line 3361
25707     if (realign) {
25708 #line 3361
25709       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
25710 #line 3361
25711       xp = tmp;
25712 #line 3361
25713     } else {
25714 #line 3361
25715       xp = (uint *) *xpp;
25716 #line 3361
25717     }
25718 #line 3361
25719    /* copy the next block */
25720 #line 3361
25721 #pragma cdir loopcnt=LOOPCNT
25722 #line 3361
25723 #pragma cdir shortloop
25724 #line 3361
25725     for (i=0; i<ni; i++) {
25726 #line 3361
25727       tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
25728 #line 3361
25729      /* test for range errors (not always needed but do it anyway) */
25730 #line 3361
25731      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
25732 #line 3361
25733      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
25734 #line 3361
25735       nrange += xp[i] > USHORT_MAX ;
25736 #line 3361
25737     }
25738 #line 3361
25739    /* update xpp and tp */
25740 #line 3361
25741     if (realign) xp = (uint *) *xpp;
25742 #line 3361
25743     xp += ni;
25744 #line 3361
25745     tp += ni;
25746 #line 3361
25747     *xpp = (void*)xp;
25748 #line 3361
25749   }
25750 #line 3361
25751   return nrange == 0 ? NC_NOERR : NC_ERANGE;
25752 #line 3361
25753 
25754 #line 3361
25755 #else   /* not SX */
25756 #line 3361
25757 	const char *xp = (const char *) *xpp;
25758 #line 3361
25759 	int status = NC_NOERR;
25760 #line 3361
25761 
25762 #line 3361
25763 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
25764 #line 3361
25765 	{
25766 #line 3361
25767 		const int lstatus = ncx_get_uint_ushort(xp, tp);
25768 #line 3361
25769 		if (status == NC_NOERR) /* report the first encountered error */
25770 #line 3361
25771 			status = lstatus;
25772 #line 3361
25773 	}
25774 #line 3361
25775 
25776 #line 3361
25777 	*xpp = (const void *)xp;
25778 #line 3361
25779 	return status;
25780 #line 3361
25781 #endif
25782 #line 3361
25783 }
25784 #line 3361
25785 
25786 int
25787 #line 3362
ncx_getn_uint_ulonglong(const void ** xpp,size_t nelems,ulonglong * tp)25788 ncx_getn_uint_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
25789 #line 3362
25790 {
25791 #line 3362
25792 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
25793 #line 3362
25794 
25795 #line 3362
25796  /* basic algorithm is:
25797 #line 3362
25798   *   - ensure sane alignment of input data
25799 #line 3362
25800   *   - copy (conversion happens automatically) input data
25801 #line 3362
25802   *     to output
25803 #line 3362
25804   *   - update xpp to point at next unconverted input, and tp to point
25805 #line 3362
25806   *     at next location for converted output
25807 #line 3362
25808   */
25809 #line 3362
25810   long i, j, ni;
25811 #line 3362
25812   uint tmp[LOOPCNT];        /* in case input is misaligned */
25813 #line 3362
25814   uint *xp;
25815 #line 3362
25816   int nrange = 0;         /* number of range errors */
25817 #line 3362
25818   int realign = 0;        /* "do we need to fix input data alignment?" */
25819 #line 3362
25820   long cxp = (long) *((char**)xpp);
25821 #line 3362
25822 
25823 #line 3362
25824   realign = (cxp & 7) % SIZEOF_UINT;
25825 #line 3362
25826   /* sjl: manually stripmine so we can limit amount of
25827 #line 3362
25828    * vector work space reserved to LOOPCNT elements. Also
25829 #line 3362
25830    * makes vectorisation easy */
25831 #line 3362
25832   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
25833 #line 3362
25834     ni=Min(nelems-j,LOOPCNT);
25835 #line 3362
25836     if (realign) {
25837 #line 3362
25838       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
25839 #line 3362
25840       xp = tmp;
25841 #line 3362
25842     } else {
25843 #line 3362
25844       xp = (uint *) *xpp;
25845 #line 3362
25846     }
25847 #line 3362
25848    /* copy the next block */
25849 #line 3362
25850 #pragma cdir loopcnt=LOOPCNT
25851 #line 3362
25852 #pragma cdir shortloop
25853 #line 3362
25854     for (i=0; i<ni; i++) {
25855 #line 3362
25856       tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
25857 #line 3362
25858      /* test for range errors (not always needed but do it anyway) */
25859 #line 3362
25860      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
25861 #line 3362
25862      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
25863 #line 3362
25864       nrange += xp[i] > ULONGLONG_MAX ;
25865 #line 3362
25866     }
25867 #line 3362
25868    /* update xpp and tp */
25869 #line 3362
25870     if (realign) xp = (uint *) *xpp;
25871 #line 3362
25872     xp += ni;
25873 #line 3362
25874     tp += ni;
25875 #line 3362
25876     *xpp = (void*)xp;
25877 #line 3362
25878   }
25879 #line 3362
25880   return nrange == 0 ? NC_NOERR : NC_ERANGE;
25881 #line 3362
25882 
25883 #line 3362
25884 #else   /* not SX */
25885 #line 3362
25886 	const char *xp = (const char *) *xpp;
25887 #line 3362
25888 	int status = NC_NOERR;
25889 #line 3362
25890 
25891 #line 3362
25892 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
25893 #line 3362
25894 	{
25895 #line 3362
25896 		const int lstatus = ncx_get_uint_ulonglong(xp, tp);
25897 #line 3362
25898 		if (status == NC_NOERR) /* report the first encountered error */
25899 #line 3362
25900 			status = lstatus;
25901 #line 3362
25902 	}
25903 #line 3362
25904 
25905 #line 3362
25906 	*xpp = (const void *)xp;
25907 #line 3362
25908 	return status;
25909 #line 3362
25910 #endif
25911 #line 3362
25912 }
25913 #line 3362
25914 
25915 
25916 #if X_SIZEOF_UINT == SIZEOF_UINT
25917 /* optimized version */
25918 int
ncx_putn_uint_uint(void ** xpp,size_t nelems,const unsigned int * tp,void * fillp)25919 ncx_putn_uint_uint(void **xpp, size_t nelems, const unsigned int *tp, void *fillp)
25920 {
25921 #ifdef WORDS_BIGENDIAN
25922 	(void) memcpy(*xpp, tp, (size_t)nelems * X_SIZEOF_UINT);
25923 # else
25924 	swapn4b(*xpp, tp, nelems);
25925 # endif
25926 	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_UINT);
25927 	return NC_NOERR;
25928 }
25929 #else
25930 int
25931 #line 3378
ncx_putn_uint_uint(void ** xpp,size_t nelems,const uint * tp,void * fillp)25932 ncx_putn_uint_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
25933 #line 3378
25934 {
25935 #line 3378
25936 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
25937 #line 3378
25938 
25939 #line 3378
25940  /* basic algorithm is:
25941 #line 3378
25942   *   - ensure sane alignment of output data
25943 #line 3378
25944   *   - copy (conversion happens automatically) input data
25945 #line 3378
25946   *     to output
25947 #line 3378
25948   *   - update tp to point at next unconverted input, and xpp to point
25949 #line 3378
25950   *     at next location for converted output
25951 #line 3378
25952   */
25953 #line 3378
25954   long i, j, ni;
25955 #line 3378
25956   uint tmp[LOOPCNT];        /* in case input is misaligned */
25957 #line 3378
25958   uint *xp;
25959 #line 3378
25960   int nrange = 0;         /* number of range errors */
25961 #line 3378
25962   int realign = 0;        /* "do we need to fix input data alignment?" */
25963 #line 3378
25964   long cxp = (long) *((char**)xpp);
25965 #line 3378
25966 
25967 #line 3378
25968   realign = (cxp & 7) % SIZEOF_UINT;
25969 #line 3378
25970   /* sjl: manually stripmine so we can limit amount of
25971 #line 3378
25972    * vector work space reserved to LOOPCNT elements. Also
25973 #line 3378
25974    * makes vectorisation easy */
25975 #line 3378
25976   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
25977 #line 3378
25978     ni=Min(nelems-j,LOOPCNT);
25979 #line 3378
25980     if (realign) {
25981 #line 3378
25982       xp = tmp;
25983 #line 3378
25984     } else {
25985 #line 3378
25986       xp = (uint *) *xpp;
25987 #line 3378
25988     }
25989 #line 3378
25990    /* copy the next block */
25991 #line 3378
25992 #pragma cdir loopcnt=LOOPCNT
25993 #line 3378
25994 #pragma cdir shortloop
25995 #line 3378
25996     for (i=0; i<ni; i++) {
25997 #line 3378
25998       /* the normal case: */
25999 #line 3378
26000       xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
26001 #line 3378
26002      /* test for range errors (not always needed but do it anyway) */
26003 #line 3378
26004      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
26005 #line 3378
26006      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
26007 #line 3378
26008       nrange += tp[i] > X_UINT_MAX ;
26009 #line 3378
26010     }
26011 #line 3378
26012    /* copy workspace back if necessary */
26013 #line 3378
26014     if (realign) {
26015 #line 3378
26016       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
26017 #line 3378
26018       xp = (uint *) *xpp;
26019 #line 3378
26020     }
26021 #line 3378
26022    /* update xpp and tp */
26023 #line 3378
26024     xp += ni;
26025 #line 3378
26026     tp += ni;
26027 #line 3378
26028     *xpp = (void*)xp;
26029 #line 3378
26030   }
26031 #line 3378
26032   return nrange == 0 ? NC_NOERR : NC_ERANGE;
26033 #line 3378
26034 
26035 #line 3378
26036 #else   /* not SX */
26037 #line 3378
26038 
26039 #line 3378
26040 	char *xp = (char *) *xpp;
26041 #line 3378
26042 	int status = NC_NOERR;
26043 #line 3378
26044 
26045 #line 3378
26046 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
26047 #line 3378
26048 	{
26049 #line 3378
26050 		int lstatus = ncx_put_uint_uint(xp, tp, fillp);
26051 #line 3378
26052 		if (status == NC_NOERR) /* report the first encountered error */
26053 #line 3378
26054 			status = lstatus;
26055 #line 3378
26056 	}
26057 #line 3378
26058 
26059 #line 3378
26060 	*xpp = (void *)xp;
26061 #line 3378
26062 	return status;
26063 #line 3378
26064 #endif
26065 #line 3378
26066 }
26067 #line 3378
26068 
26069 #endif
26070 int
26071 #line 3380
ncx_putn_uint_schar(void ** xpp,size_t nelems,const schar * tp,void * fillp)26072 ncx_putn_uint_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
26073 #line 3380
26074 {
26075 #line 3380
26076 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
26077 #line 3380
26078 
26079 #line 3380
26080  /* basic algorithm is:
26081 #line 3380
26082   *   - ensure sane alignment of output data
26083 #line 3380
26084   *   - copy (conversion happens automatically) input data
26085 #line 3380
26086   *     to output
26087 #line 3380
26088   *   - update tp to point at next unconverted input, and xpp to point
26089 #line 3380
26090   *     at next location for converted output
26091 #line 3380
26092   */
26093 #line 3380
26094   long i, j, ni;
26095 #line 3380
26096   uint tmp[LOOPCNT];        /* in case input is misaligned */
26097 #line 3380
26098   uint *xp;
26099 #line 3380
26100   int nrange = 0;         /* number of range errors */
26101 #line 3380
26102   int realign = 0;        /* "do we need to fix input data alignment?" */
26103 #line 3380
26104   long cxp = (long) *((char**)xpp);
26105 #line 3380
26106 
26107 #line 3380
26108   realign = (cxp & 7) % SIZEOF_UINT;
26109 #line 3380
26110   /* sjl: manually stripmine so we can limit amount of
26111 #line 3380
26112    * vector work space reserved to LOOPCNT elements. Also
26113 #line 3380
26114    * makes vectorisation easy */
26115 #line 3380
26116   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
26117 #line 3380
26118     ni=Min(nelems-j,LOOPCNT);
26119 #line 3380
26120     if (realign) {
26121 #line 3380
26122       xp = tmp;
26123 #line 3380
26124     } else {
26125 #line 3380
26126       xp = (uint *) *xpp;
26127 #line 3380
26128     }
26129 #line 3380
26130    /* copy the next block */
26131 #line 3380
26132 #pragma cdir loopcnt=LOOPCNT
26133 #line 3380
26134 #pragma cdir shortloop
26135 #line 3380
26136     for (i=0; i<ni; i++) {
26137 #line 3380
26138       /* the normal case: */
26139 #line 3380
26140       xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
26141 #line 3380
26142      /* test for range errors (not always needed but do it anyway) */
26143 #line 3380
26144      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
26145 #line 3380
26146      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
26147 #line 3380
26148       nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
26149 #line 3380
26150     }
26151 #line 3380
26152    /* copy workspace back if necessary */
26153 #line 3380
26154     if (realign) {
26155 #line 3380
26156       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
26157 #line 3380
26158       xp = (uint *) *xpp;
26159 #line 3380
26160     }
26161 #line 3380
26162    /* update xpp and tp */
26163 #line 3380
26164     xp += ni;
26165 #line 3380
26166     tp += ni;
26167 #line 3380
26168     *xpp = (void*)xp;
26169 #line 3380
26170   }
26171 #line 3380
26172   return nrange == 0 ? NC_NOERR : NC_ERANGE;
26173 #line 3380
26174 
26175 #line 3380
26176 #else   /* not SX */
26177 #line 3380
26178 
26179 #line 3380
26180 	char *xp = (char *) *xpp;
26181 #line 3380
26182 	int status = NC_NOERR;
26183 #line 3380
26184 
26185 #line 3380
26186 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
26187 #line 3380
26188 	{
26189 #line 3380
26190 		int lstatus = ncx_put_uint_schar(xp, tp, fillp);
26191 #line 3380
26192 		if (status == NC_NOERR) /* report the first encountered error */
26193 #line 3380
26194 			status = lstatus;
26195 #line 3380
26196 	}
26197 #line 3380
26198 
26199 #line 3380
26200 	*xpp = (void *)xp;
26201 #line 3380
26202 	return status;
26203 #line 3380
26204 #endif
26205 #line 3380
26206 }
26207 #line 3380
26208 
26209 int
26210 #line 3381
ncx_putn_uint_short(void ** xpp,size_t nelems,const short * tp,void * fillp)26211 ncx_putn_uint_short(void **xpp, size_t nelems, const short *tp, void *fillp)
26212 #line 3381
26213 {
26214 #line 3381
26215 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
26216 #line 3381
26217 
26218 #line 3381
26219  /* basic algorithm is:
26220 #line 3381
26221   *   - ensure sane alignment of output data
26222 #line 3381
26223   *   - copy (conversion happens automatically) input data
26224 #line 3381
26225   *     to output
26226 #line 3381
26227   *   - update tp to point at next unconverted input, and xpp to point
26228 #line 3381
26229   *     at next location for converted output
26230 #line 3381
26231   */
26232 #line 3381
26233   long i, j, ni;
26234 #line 3381
26235   uint tmp[LOOPCNT];        /* in case input is misaligned */
26236 #line 3381
26237   uint *xp;
26238 #line 3381
26239   int nrange = 0;         /* number of range errors */
26240 #line 3381
26241   int realign = 0;        /* "do we need to fix input data alignment?" */
26242 #line 3381
26243   long cxp = (long) *((char**)xpp);
26244 #line 3381
26245 
26246 #line 3381
26247   realign = (cxp & 7) % SIZEOF_UINT;
26248 #line 3381
26249   /* sjl: manually stripmine so we can limit amount of
26250 #line 3381
26251    * vector work space reserved to LOOPCNT elements. Also
26252 #line 3381
26253    * makes vectorisation easy */
26254 #line 3381
26255   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
26256 #line 3381
26257     ni=Min(nelems-j,LOOPCNT);
26258 #line 3381
26259     if (realign) {
26260 #line 3381
26261       xp = tmp;
26262 #line 3381
26263     } else {
26264 #line 3381
26265       xp = (uint *) *xpp;
26266 #line 3381
26267     }
26268 #line 3381
26269    /* copy the next block */
26270 #line 3381
26271 #pragma cdir loopcnt=LOOPCNT
26272 #line 3381
26273 #pragma cdir shortloop
26274 #line 3381
26275     for (i=0; i<ni; i++) {
26276 #line 3381
26277       /* the normal case: */
26278 #line 3381
26279       xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
26280 #line 3381
26281      /* test for range errors (not always needed but do it anyway) */
26282 #line 3381
26283      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
26284 #line 3381
26285      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
26286 #line 3381
26287       nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
26288 #line 3381
26289     }
26290 #line 3381
26291    /* copy workspace back if necessary */
26292 #line 3381
26293     if (realign) {
26294 #line 3381
26295       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
26296 #line 3381
26297       xp = (uint *) *xpp;
26298 #line 3381
26299     }
26300 #line 3381
26301    /* update xpp and tp */
26302 #line 3381
26303     xp += ni;
26304 #line 3381
26305     tp += ni;
26306 #line 3381
26307     *xpp = (void*)xp;
26308 #line 3381
26309   }
26310 #line 3381
26311   return nrange == 0 ? NC_NOERR : NC_ERANGE;
26312 #line 3381
26313 
26314 #line 3381
26315 #else   /* not SX */
26316 #line 3381
26317 
26318 #line 3381
26319 	char *xp = (char *) *xpp;
26320 #line 3381
26321 	int status = NC_NOERR;
26322 #line 3381
26323 
26324 #line 3381
26325 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
26326 #line 3381
26327 	{
26328 #line 3381
26329 		int lstatus = ncx_put_uint_short(xp, tp, fillp);
26330 #line 3381
26331 		if (status == NC_NOERR) /* report the first encountered error */
26332 #line 3381
26333 			status = lstatus;
26334 #line 3381
26335 	}
26336 #line 3381
26337 
26338 #line 3381
26339 	*xpp = (void *)xp;
26340 #line 3381
26341 	return status;
26342 #line 3381
26343 #endif
26344 #line 3381
26345 }
26346 #line 3381
26347 
26348 int
26349 #line 3382
ncx_putn_uint_int(void ** xpp,size_t nelems,const int * tp,void * fillp)26350 ncx_putn_uint_int(void **xpp, size_t nelems, const int *tp, void *fillp)
26351 #line 3382
26352 {
26353 #line 3382
26354 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
26355 #line 3382
26356 
26357 #line 3382
26358  /* basic algorithm is:
26359 #line 3382
26360   *   - ensure sane alignment of output data
26361 #line 3382
26362   *   - copy (conversion happens automatically) input data
26363 #line 3382
26364   *     to output
26365 #line 3382
26366   *   - update tp to point at next unconverted input, and xpp to point
26367 #line 3382
26368   *     at next location for converted output
26369 #line 3382
26370   */
26371 #line 3382
26372   long i, j, ni;
26373 #line 3382
26374   uint tmp[LOOPCNT];        /* in case input is misaligned */
26375 #line 3382
26376   uint *xp;
26377 #line 3382
26378   int nrange = 0;         /* number of range errors */
26379 #line 3382
26380   int realign = 0;        /* "do we need to fix input data alignment?" */
26381 #line 3382
26382   long cxp = (long) *((char**)xpp);
26383 #line 3382
26384 
26385 #line 3382
26386   realign = (cxp & 7) % SIZEOF_UINT;
26387 #line 3382
26388   /* sjl: manually stripmine so we can limit amount of
26389 #line 3382
26390    * vector work space reserved to LOOPCNT elements. Also
26391 #line 3382
26392    * makes vectorisation easy */
26393 #line 3382
26394   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
26395 #line 3382
26396     ni=Min(nelems-j,LOOPCNT);
26397 #line 3382
26398     if (realign) {
26399 #line 3382
26400       xp = tmp;
26401 #line 3382
26402     } else {
26403 #line 3382
26404       xp = (uint *) *xpp;
26405 #line 3382
26406     }
26407 #line 3382
26408    /* copy the next block */
26409 #line 3382
26410 #pragma cdir loopcnt=LOOPCNT
26411 #line 3382
26412 #pragma cdir shortloop
26413 #line 3382
26414     for (i=0; i<ni; i++) {
26415 #line 3382
26416       /* the normal case: */
26417 #line 3382
26418       xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
26419 #line 3382
26420      /* test for range errors (not always needed but do it anyway) */
26421 #line 3382
26422      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
26423 #line 3382
26424      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
26425 #line 3382
26426       nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
26427 #line 3382
26428     }
26429 #line 3382
26430    /* copy workspace back if necessary */
26431 #line 3382
26432     if (realign) {
26433 #line 3382
26434       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
26435 #line 3382
26436       xp = (uint *) *xpp;
26437 #line 3382
26438     }
26439 #line 3382
26440    /* update xpp and tp */
26441 #line 3382
26442     xp += ni;
26443 #line 3382
26444     tp += ni;
26445 #line 3382
26446     *xpp = (void*)xp;
26447 #line 3382
26448   }
26449 #line 3382
26450   return nrange == 0 ? NC_NOERR : NC_ERANGE;
26451 #line 3382
26452 
26453 #line 3382
26454 #else   /* not SX */
26455 #line 3382
26456 
26457 #line 3382
26458 	char *xp = (char *) *xpp;
26459 #line 3382
26460 	int status = NC_NOERR;
26461 #line 3382
26462 
26463 #line 3382
26464 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
26465 #line 3382
26466 	{
26467 #line 3382
26468 		int lstatus = ncx_put_uint_int(xp, tp, fillp);
26469 #line 3382
26470 		if (status == NC_NOERR) /* report the first encountered error */
26471 #line 3382
26472 			status = lstatus;
26473 #line 3382
26474 	}
26475 #line 3382
26476 
26477 #line 3382
26478 	*xpp = (void *)xp;
26479 #line 3382
26480 	return status;
26481 #line 3382
26482 #endif
26483 #line 3382
26484 }
26485 #line 3382
26486 
26487 int
26488 #line 3383
ncx_putn_uint_long(void ** xpp,size_t nelems,const long * tp,void * fillp)26489 ncx_putn_uint_long(void **xpp, size_t nelems, const long *tp, void *fillp)
26490 #line 3383
26491 {
26492 #line 3383
26493 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
26494 #line 3383
26495 
26496 #line 3383
26497  /* basic algorithm is:
26498 #line 3383
26499   *   - ensure sane alignment of output data
26500 #line 3383
26501   *   - copy (conversion happens automatically) input data
26502 #line 3383
26503   *     to output
26504 #line 3383
26505   *   - update tp to point at next unconverted input, and xpp to point
26506 #line 3383
26507   *     at next location for converted output
26508 #line 3383
26509   */
26510 #line 3383
26511   long i, j, ni;
26512 #line 3383
26513   uint tmp[LOOPCNT];        /* in case input is misaligned */
26514 #line 3383
26515   uint *xp;
26516 #line 3383
26517   int nrange = 0;         /* number of range errors */
26518 #line 3383
26519   int realign = 0;        /* "do we need to fix input data alignment?" */
26520 #line 3383
26521   long cxp = (long) *((char**)xpp);
26522 #line 3383
26523 
26524 #line 3383
26525   realign = (cxp & 7) % SIZEOF_UINT;
26526 #line 3383
26527   /* sjl: manually stripmine so we can limit amount of
26528 #line 3383
26529    * vector work space reserved to LOOPCNT elements. Also
26530 #line 3383
26531    * makes vectorisation easy */
26532 #line 3383
26533   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
26534 #line 3383
26535     ni=Min(nelems-j,LOOPCNT);
26536 #line 3383
26537     if (realign) {
26538 #line 3383
26539       xp = tmp;
26540 #line 3383
26541     } else {
26542 #line 3383
26543       xp = (uint *) *xpp;
26544 #line 3383
26545     }
26546 #line 3383
26547    /* copy the next block */
26548 #line 3383
26549 #pragma cdir loopcnt=LOOPCNT
26550 #line 3383
26551 #pragma cdir shortloop
26552 #line 3383
26553     for (i=0; i<ni; i++) {
26554 #line 3383
26555       /* the normal case: */
26556 #line 3383
26557       xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
26558 #line 3383
26559      /* test for range errors (not always needed but do it anyway) */
26560 #line 3383
26561      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
26562 #line 3383
26563      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
26564 #line 3383
26565       nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
26566 #line 3383
26567     }
26568 #line 3383
26569    /* copy workspace back if necessary */
26570 #line 3383
26571     if (realign) {
26572 #line 3383
26573       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
26574 #line 3383
26575       xp = (uint *) *xpp;
26576 #line 3383
26577     }
26578 #line 3383
26579    /* update xpp and tp */
26580 #line 3383
26581     xp += ni;
26582 #line 3383
26583     tp += ni;
26584 #line 3383
26585     *xpp = (void*)xp;
26586 #line 3383
26587   }
26588 #line 3383
26589   return nrange == 0 ? NC_NOERR : NC_ERANGE;
26590 #line 3383
26591 
26592 #line 3383
26593 #else   /* not SX */
26594 #line 3383
26595 
26596 #line 3383
26597 	char *xp = (char *) *xpp;
26598 #line 3383
26599 	int status = NC_NOERR;
26600 #line 3383
26601 
26602 #line 3383
26603 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
26604 #line 3383
26605 	{
26606 #line 3383
26607 		int lstatus = ncx_put_uint_long(xp, tp, fillp);
26608 #line 3383
26609 		if (status == NC_NOERR) /* report the first encountered error */
26610 #line 3383
26611 			status = lstatus;
26612 #line 3383
26613 	}
26614 #line 3383
26615 
26616 #line 3383
26617 	*xpp = (void *)xp;
26618 #line 3383
26619 	return status;
26620 #line 3383
26621 #endif
26622 #line 3383
26623 }
26624 #line 3383
26625 
26626 int
26627 #line 3384
ncx_putn_uint_float(void ** xpp,size_t nelems,const float * tp,void * fillp)26628 ncx_putn_uint_float(void **xpp, size_t nelems, const float *tp, void *fillp)
26629 #line 3384
26630 {
26631 #line 3384
26632 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
26633 #line 3384
26634 
26635 #line 3384
26636  /* basic algorithm is:
26637 #line 3384
26638   *   - ensure sane alignment of output data
26639 #line 3384
26640   *   - copy (conversion happens automatically) input data
26641 #line 3384
26642   *     to output
26643 #line 3384
26644   *   - update tp to point at next unconverted input, and xpp to point
26645 #line 3384
26646   *     at next location for converted output
26647 #line 3384
26648   */
26649 #line 3384
26650   long i, j, ni;
26651 #line 3384
26652   uint tmp[LOOPCNT];        /* in case input is misaligned */
26653 #line 3384
26654   uint *xp;
26655 #line 3384
26656   int nrange = 0;         /* number of range errors */
26657 #line 3384
26658   int realign = 0;        /* "do we need to fix input data alignment?" */
26659 #line 3384
26660   long cxp = (long) *((char**)xpp);
26661 #line 3384
26662 
26663 #line 3384
26664   realign = (cxp & 7) % SIZEOF_UINT;
26665 #line 3384
26666   /* sjl: manually stripmine so we can limit amount of
26667 #line 3384
26668    * vector work space reserved to LOOPCNT elements. Also
26669 #line 3384
26670    * makes vectorisation easy */
26671 #line 3384
26672   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
26673 #line 3384
26674     ni=Min(nelems-j,LOOPCNT);
26675 #line 3384
26676     if (realign) {
26677 #line 3384
26678       xp = tmp;
26679 #line 3384
26680     } else {
26681 #line 3384
26682       xp = (uint *) *xpp;
26683 #line 3384
26684     }
26685 #line 3384
26686    /* copy the next block */
26687 #line 3384
26688 #pragma cdir loopcnt=LOOPCNT
26689 #line 3384
26690 #pragma cdir shortloop
26691 #line 3384
26692     for (i=0; i<ni; i++) {
26693 #line 3384
26694       /* the normal case: */
26695 #line 3384
26696       xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
26697 #line 3384
26698      /* test for range errors (not always needed but do it anyway) */
26699 #line 3384
26700      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
26701 #line 3384
26702      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
26703 #line 3384
26704       nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
26705 #line 3384
26706     }
26707 #line 3384
26708    /* copy workspace back if necessary */
26709 #line 3384
26710     if (realign) {
26711 #line 3384
26712       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
26713 #line 3384
26714       xp = (uint *) *xpp;
26715 #line 3384
26716     }
26717 #line 3384
26718    /* update xpp and tp */
26719 #line 3384
26720     xp += ni;
26721 #line 3384
26722     tp += ni;
26723 #line 3384
26724     *xpp = (void*)xp;
26725 #line 3384
26726   }
26727 #line 3384
26728   return nrange == 0 ? NC_NOERR : NC_ERANGE;
26729 #line 3384
26730 
26731 #line 3384
26732 #else   /* not SX */
26733 #line 3384
26734 
26735 #line 3384
26736 	char *xp = (char *) *xpp;
26737 #line 3384
26738 	int status = NC_NOERR;
26739 #line 3384
26740 
26741 #line 3384
26742 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
26743 #line 3384
26744 	{
26745 #line 3384
26746 		int lstatus = ncx_put_uint_float(xp, tp, fillp);
26747 #line 3384
26748 		if (status == NC_NOERR) /* report the first encountered error */
26749 #line 3384
26750 			status = lstatus;
26751 #line 3384
26752 	}
26753 #line 3384
26754 
26755 #line 3384
26756 	*xpp = (void *)xp;
26757 #line 3384
26758 	return status;
26759 #line 3384
26760 #endif
26761 #line 3384
26762 }
26763 #line 3384
26764 
26765 int
26766 #line 3385
ncx_putn_uint_double(void ** xpp,size_t nelems,const double * tp,void * fillp)26767 ncx_putn_uint_double(void **xpp, size_t nelems, const double *tp, void *fillp)
26768 #line 3385
26769 {
26770 #line 3385
26771 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
26772 #line 3385
26773 
26774 #line 3385
26775  /* basic algorithm is:
26776 #line 3385
26777   *   - ensure sane alignment of output data
26778 #line 3385
26779   *   - copy (conversion happens automatically) input data
26780 #line 3385
26781   *     to output
26782 #line 3385
26783   *   - update tp to point at next unconverted input, and xpp to point
26784 #line 3385
26785   *     at next location for converted output
26786 #line 3385
26787   */
26788 #line 3385
26789   long i, j, ni;
26790 #line 3385
26791   uint tmp[LOOPCNT];        /* in case input is misaligned */
26792 #line 3385
26793   uint *xp;
26794 #line 3385
26795   int nrange = 0;         /* number of range errors */
26796 #line 3385
26797   int realign = 0;        /* "do we need to fix input data alignment?" */
26798 #line 3385
26799   long cxp = (long) *((char**)xpp);
26800 #line 3385
26801 
26802 #line 3385
26803   realign = (cxp & 7) % SIZEOF_UINT;
26804 #line 3385
26805   /* sjl: manually stripmine so we can limit amount of
26806 #line 3385
26807    * vector work space reserved to LOOPCNT elements. Also
26808 #line 3385
26809    * makes vectorisation easy */
26810 #line 3385
26811   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
26812 #line 3385
26813     ni=Min(nelems-j,LOOPCNT);
26814 #line 3385
26815     if (realign) {
26816 #line 3385
26817       xp = tmp;
26818 #line 3385
26819     } else {
26820 #line 3385
26821       xp = (uint *) *xpp;
26822 #line 3385
26823     }
26824 #line 3385
26825    /* copy the next block */
26826 #line 3385
26827 #pragma cdir loopcnt=LOOPCNT
26828 #line 3385
26829 #pragma cdir shortloop
26830 #line 3385
26831     for (i=0; i<ni; i++) {
26832 #line 3385
26833       /* the normal case: */
26834 #line 3385
26835       xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
26836 #line 3385
26837      /* test for range errors (not always needed but do it anyway) */
26838 #line 3385
26839      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
26840 #line 3385
26841      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
26842 #line 3385
26843       nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
26844 #line 3385
26845     }
26846 #line 3385
26847    /* copy workspace back if necessary */
26848 #line 3385
26849     if (realign) {
26850 #line 3385
26851       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
26852 #line 3385
26853       xp = (uint *) *xpp;
26854 #line 3385
26855     }
26856 #line 3385
26857    /* update xpp and tp */
26858 #line 3385
26859     xp += ni;
26860 #line 3385
26861     tp += ni;
26862 #line 3385
26863     *xpp = (void*)xp;
26864 #line 3385
26865   }
26866 #line 3385
26867   return nrange == 0 ? NC_NOERR : NC_ERANGE;
26868 #line 3385
26869 
26870 #line 3385
26871 #else   /* not SX */
26872 #line 3385
26873 
26874 #line 3385
26875 	char *xp = (char *) *xpp;
26876 #line 3385
26877 	int status = NC_NOERR;
26878 #line 3385
26879 
26880 #line 3385
26881 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
26882 #line 3385
26883 	{
26884 #line 3385
26885 		int lstatus = ncx_put_uint_double(xp, tp, fillp);
26886 #line 3385
26887 		if (status == NC_NOERR) /* report the first encountered error */
26888 #line 3385
26889 			status = lstatus;
26890 #line 3385
26891 	}
26892 #line 3385
26893 
26894 #line 3385
26895 	*xpp = (void *)xp;
26896 #line 3385
26897 	return status;
26898 #line 3385
26899 #endif
26900 #line 3385
26901 }
26902 #line 3385
26903 
26904 int
26905 #line 3386
ncx_putn_uint_longlong(void ** xpp,size_t nelems,const longlong * tp,void * fillp)26906 ncx_putn_uint_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
26907 #line 3386
26908 {
26909 #line 3386
26910 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
26911 #line 3386
26912 
26913 #line 3386
26914  /* basic algorithm is:
26915 #line 3386
26916   *   - ensure sane alignment of output data
26917 #line 3386
26918   *   - copy (conversion happens automatically) input data
26919 #line 3386
26920   *     to output
26921 #line 3386
26922   *   - update tp to point at next unconverted input, and xpp to point
26923 #line 3386
26924   *     at next location for converted output
26925 #line 3386
26926   */
26927 #line 3386
26928   long i, j, ni;
26929 #line 3386
26930   uint tmp[LOOPCNT];        /* in case input is misaligned */
26931 #line 3386
26932   uint *xp;
26933 #line 3386
26934   int nrange = 0;         /* number of range errors */
26935 #line 3386
26936   int realign = 0;        /* "do we need to fix input data alignment?" */
26937 #line 3386
26938   long cxp = (long) *((char**)xpp);
26939 #line 3386
26940 
26941 #line 3386
26942   realign = (cxp & 7) % SIZEOF_UINT;
26943 #line 3386
26944   /* sjl: manually stripmine so we can limit amount of
26945 #line 3386
26946    * vector work space reserved to LOOPCNT elements. Also
26947 #line 3386
26948    * makes vectorisation easy */
26949 #line 3386
26950   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
26951 #line 3386
26952     ni=Min(nelems-j,LOOPCNT);
26953 #line 3386
26954     if (realign) {
26955 #line 3386
26956       xp = tmp;
26957 #line 3386
26958     } else {
26959 #line 3386
26960       xp = (uint *) *xpp;
26961 #line 3386
26962     }
26963 #line 3386
26964    /* copy the next block */
26965 #line 3386
26966 #pragma cdir loopcnt=LOOPCNT
26967 #line 3386
26968 #pragma cdir shortloop
26969 #line 3386
26970     for (i=0; i<ni; i++) {
26971 #line 3386
26972       /* the normal case: */
26973 #line 3386
26974       xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
26975 #line 3386
26976      /* test for range errors (not always needed but do it anyway) */
26977 #line 3386
26978      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
26979 #line 3386
26980      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
26981 #line 3386
26982       nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
26983 #line 3386
26984     }
26985 #line 3386
26986    /* copy workspace back if necessary */
26987 #line 3386
26988     if (realign) {
26989 #line 3386
26990       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
26991 #line 3386
26992       xp = (uint *) *xpp;
26993 #line 3386
26994     }
26995 #line 3386
26996    /* update xpp and tp */
26997 #line 3386
26998     xp += ni;
26999 #line 3386
27000     tp += ni;
27001 #line 3386
27002     *xpp = (void*)xp;
27003 #line 3386
27004   }
27005 #line 3386
27006   return nrange == 0 ? NC_NOERR : NC_ERANGE;
27007 #line 3386
27008 
27009 #line 3386
27010 #else   /* not SX */
27011 #line 3386
27012 
27013 #line 3386
27014 	char *xp = (char *) *xpp;
27015 #line 3386
27016 	int status = NC_NOERR;
27017 #line 3386
27018 
27019 #line 3386
27020 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
27021 #line 3386
27022 	{
27023 #line 3386
27024 		int lstatus = ncx_put_uint_longlong(xp, tp, fillp);
27025 #line 3386
27026 		if (status == NC_NOERR) /* report the first encountered error */
27027 #line 3386
27028 			status = lstatus;
27029 #line 3386
27030 	}
27031 #line 3386
27032 
27033 #line 3386
27034 	*xpp = (void *)xp;
27035 #line 3386
27036 	return status;
27037 #line 3386
27038 #endif
27039 #line 3386
27040 }
27041 #line 3386
27042 
27043 int
27044 #line 3387
ncx_putn_uint_uchar(void ** xpp,size_t nelems,const uchar * tp,void * fillp)27045 ncx_putn_uint_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
27046 #line 3387
27047 {
27048 #line 3387
27049 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
27050 #line 3387
27051 
27052 #line 3387
27053  /* basic algorithm is:
27054 #line 3387
27055   *   - ensure sane alignment of output data
27056 #line 3387
27057   *   - copy (conversion happens automatically) input data
27058 #line 3387
27059   *     to output
27060 #line 3387
27061   *   - update tp to point at next unconverted input, and xpp to point
27062 #line 3387
27063   *     at next location for converted output
27064 #line 3387
27065   */
27066 #line 3387
27067   long i, j, ni;
27068 #line 3387
27069   uint tmp[LOOPCNT];        /* in case input is misaligned */
27070 #line 3387
27071   uint *xp;
27072 #line 3387
27073   int nrange = 0;         /* number of range errors */
27074 #line 3387
27075   int realign = 0;        /* "do we need to fix input data alignment?" */
27076 #line 3387
27077   long cxp = (long) *((char**)xpp);
27078 #line 3387
27079 
27080 #line 3387
27081   realign = (cxp & 7) % SIZEOF_UINT;
27082 #line 3387
27083   /* sjl: manually stripmine so we can limit amount of
27084 #line 3387
27085    * vector work space reserved to LOOPCNT elements. Also
27086 #line 3387
27087    * makes vectorisation easy */
27088 #line 3387
27089   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
27090 #line 3387
27091     ni=Min(nelems-j,LOOPCNT);
27092 #line 3387
27093     if (realign) {
27094 #line 3387
27095       xp = tmp;
27096 #line 3387
27097     } else {
27098 #line 3387
27099       xp = (uint *) *xpp;
27100 #line 3387
27101     }
27102 #line 3387
27103    /* copy the next block */
27104 #line 3387
27105 #pragma cdir loopcnt=LOOPCNT
27106 #line 3387
27107 #pragma cdir shortloop
27108 #line 3387
27109     for (i=0; i<ni; i++) {
27110 #line 3387
27111       /* the normal case: */
27112 #line 3387
27113       xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
27114 #line 3387
27115      /* test for range errors (not always needed but do it anyway) */
27116 #line 3387
27117      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
27118 #line 3387
27119      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
27120 #line 3387
27121       nrange += tp[i] > X_UINT_MAX ;
27122 #line 3387
27123     }
27124 #line 3387
27125    /* copy workspace back if necessary */
27126 #line 3387
27127     if (realign) {
27128 #line 3387
27129       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
27130 #line 3387
27131       xp = (uint *) *xpp;
27132 #line 3387
27133     }
27134 #line 3387
27135    /* update xpp and tp */
27136 #line 3387
27137     xp += ni;
27138 #line 3387
27139     tp += ni;
27140 #line 3387
27141     *xpp = (void*)xp;
27142 #line 3387
27143   }
27144 #line 3387
27145   return nrange == 0 ? NC_NOERR : NC_ERANGE;
27146 #line 3387
27147 
27148 #line 3387
27149 #else   /* not SX */
27150 #line 3387
27151 
27152 #line 3387
27153 	char *xp = (char *) *xpp;
27154 #line 3387
27155 	int status = NC_NOERR;
27156 #line 3387
27157 
27158 #line 3387
27159 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
27160 #line 3387
27161 	{
27162 #line 3387
27163 		int lstatus = ncx_put_uint_uchar(xp, tp, fillp);
27164 #line 3387
27165 		if (status == NC_NOERR) /* report the first encountered error */
27166 #line 3387
27167 			status = lstatus;
27168 #line 3387
27169 	}
27170 #line 3387
27171 
27172 #line 3387
27173 	*xpp = (void *)xp;
27174 #line 3387
27175 	return status;
27176 #line 3387
27177 #endif
27178 #line 3387
27179 }
27180 #line 3387
27181 
27182 int
27183 #line 3388
ncx_putn_uint_ushort(void ** xpp,size_t nelems,const ushort * tp,void * fillp)27184 ncx_putn_uint_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
27185 #line 3388
27186 {
27187 #line 3388
27188 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
27189 #line 3388
27190 
27191 #line 3388
27192  /* basic algorithm is:
27193 #line 3388
27194   *   - ensure sane alignment of output data
27195 #line 3388
27196   *   - copy (conversion happens automatically) input data
27197 #line 3388
27198   *     to output
27199 #line 3388
27200   *   - update tp to point at next unconverted input, and xpp to point
27201 #line 3388
27202   *     at next location for converted output
27203 #line 3388
27204   */
27205 #line 3388
27206   long i, j, ni;
27207 #line 3388
27208   uint tmp[LOOPCNT];        /* in case input is misaligned */
27209 #line 3388
27210   uint *xp;
27211 #line 3388
27212   int nrange = 0;         /* number of range errors */
27213 #line 3388
27214   int realign = 0;        /* "do we need to fix input data alignment?" */
27215 #line 3388
27216   long cxp = (long) *((char**)xpp);
27217 #line 3388
27218 
27219 #line 3388
27220   realign = (cxp & 7) % SIZEOF_UINT;
27221 #line 3388
27222   /* sjl: manually stripmine so we can limit amount of
27223 #line 3388
27224    * vector work space reserved to LOOPCNT elements. Also
27225 #line 3388
27226    * makes vectorisation easy */
27227 #line 3388
27228   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
27229 #line 3388
27230     ni=Min(nelems-j,LOOPCNT);
27231 #line 3388
27232     if (realign) {
27233 #line 3388
27234       xp = tmp;
27235 #line 3388
27236     } else {
27237 #line 3388
27238       xp = (uint *) *xpp;
27239 #line 3388
27240     }
27241 #line 3388
27242    /* copy the next block */
27243 #line 3388
27244 #pragma cdir loopcnt=LOOPCNT
27245 #line 3388
27246 #pragma cdir shortloop
27247 #line 3388
27248     for (i=0; i<ni; i++) {
27249 #line 3388
27250       /* the normal case: */
27251 #line 3388
27252       xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
27253 #line 3388
27254      /* test for range errors (not always needed but do it anyway) */
27255 #line 3388
27256      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
27257 #line 3388
27258      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
27259 #line 3388
27260       nrange += tp[i] > X_UINT_MAX ;
27261 #line 3388
27262     }
27263 #line 3388
27264    /* copy workspace back if necessary */
27265 #line 3388
27266     if (realign) {
27267 #line 3388
27268       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
27269 #line 3388
27270       xp = (uint *) *xpp;
27271 #line 3388
27272     }
27273 #line 3388
27274    /* update xpp and tp */
27275 #line 3388
27276     xp += ni;
27277 #line 3388
27278     tp += ni;
27279 #line 3388
27280     *xpp = (void*)xp;
27281 #line 3388
27282   }
27283 #line 3388
27284   return nrange == 0 ? NC_NOERR : NC_ERANGE;
27285 #line 3388
27286 
27287 #line 3388
27288 #else   /* not SX */
27289 #line 3388
27290 
27291 #line 3388
27292 	char *xp = (char *) *xpp;
27293 #line 3388
27294 	int status = NC_NOERR;
27295 #line 3388
27296 
27297 #line 3388
27298 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
27299 #line 3388
27300 	{
27301 #line 3388
27302 		int lstatus = ncx_put_uint_ushort(xp, tp, fillp);
27303 #line 3388
27304 		if (status == NC_NOERR) /* report the first encountered error */
27305 #line 3388
27306 			status = lstatus;
27307 #line 3388
27308 	}
27309 #line 3388
27310 
27311 #line 3388
27312 	*xpp = (void *)xp;
27313 #line 3388
27314 	return status;
27315 #line 3388
27316 #endif
27317 #line 3388
27318 }
27319 #line 3388
27320 
27321 int
27322 #line 3389
ncx_putn_uint_ulonglong(void ** xpp,size_t nelems,const ulonglong * tp,void * fillp)27323 ncx_putn_uint_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
27324 #line 3389
27325 {
27326 #line 3389
27327 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
27328 #line 3389
27329 
27330 #line 3389
27331  /* basic algorithm is:
27332 #line 3389
27333   *   - ensure sane alignment of output data
27334 #line 3389
27335   *   - copy (conversion happens automatically) input data
27336 #line 3389
27337   *     to output
27338 #line 3389
27339   *   - update tp to point at next unconverted input, and xpp to point
27340 #line 3389
27341   *     at next location for converted output
27342 #line 3389
27343   */
27344 #line 3389
27345   long i, j, ni;
27346 #line 3389
27347   uint tmp[LOOPCNT];        /* in case input is misaligned */
27348 #line 3389
27349   uint *xp;
27350 #line 3389
27351   int nrange = 0;         /* number of range errors */
27352 #line 3389
27353   int realign = 0;        /* "do we need to fix input data alignment?" */
27354 #line 3389
27355   long cxp = (long) *((char**)xpp);
27356 #line 3389
27357 
27358 #line 3389
27359   realign = (cxp & 7) % SIZEOF_UINT;
27360 #line 3389
27361   /* sjl: manually stripmine so we can limit amount of
27362 #line 3389
27363    * vector work space reserved to LOOPCNT elements. Also
27364 #line 3389
27365    * makes vectorisation easy */
27366 #line 3389
27367   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
27368 #line 3389
27369     ni=Min(nelems-j,LOOPCNT);
27370 #line 3389
27371     if (realign) {
27372 #line 3389
27373       xp = tmp;
27374 #line 3389
27375     } else {
27376 #line 3389
27377       xp = (uint *) *xpp;
27378 #line 3389
27379     }
27380 #line 3389
27381    /* copy the next block */
27382 #line 3389
27383 #pragma cdir loopcnt=LOOPCNT
27384 #line 3389
27385 #pragma cdir shortloop
27386 #line 3389
27387     for (i=0; i<ni; i++) {
27388 #line 3389
27389       /* the normal case: */
27390 #line 3389
27391       xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
27392 #line 3389
27393      /* test for range errors (not always needed but do it anyway) */
27394 #line 3389
27395      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
27396 #line 3389
27397      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
27398 #line 3389
27399       nrange += tp[i] > X_UINT_MAX ;
27400 #line 3389
27401     }
27402 #line 3389
27403    /* copy workspace back if necessary */
27404 #line 3389
27405     if (realign) {
27406 #line 3389
27407       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
27408 #line 3389
27409       xp = (uint *) *xpp;
27410 #line 3389
27411     }
27412 #line 3389
27413    /* update xpp and tp */
27414 #line 3389
27415     xp += ni;
27416 #line 3389
27417     tp += ni;
27418 #line 3389
27419     *xpp = (void*)xp;
27420 #line 3389
27421   }
27422 #line 3389
27423   return nrange == 0 ? NC_NOERR : NC_ERANGE;
27424 #line 3389
27425 
27426 #line 3389
27427 #else   /* not SX */
27428 #line 3389
27429 
27430 #line 3389
27431 	char *xp = (char *) *xpp;
27432 #line 3389
27433 	int status = NC_NOERR;
27434 #line 3389
27435 
27436 #line 3389
27437 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
27438 #line 3389
27439 	{
27440 #line 3389
27441 		int lstatus = ncx_put_uint_ulonglong(xp, tp, fillp);
27442 #line 3389
27443 		if (status == NC_NOERR) /* report the first encountered error */
27444 #line 3389
27445 			status = lstatus;
27446 #line 3389
27447 	}
27448 #line 3389
27449 
27450 #line 3389
27451 	*xpp = (void *)xp;
27452 #line 3389
27453 	return status;
27454 #line 3389
27455 #endif
27456 #line 3389
27457 }
27458 #line 3389
27459 
27460 
27461 
27462 /* float ---------------------------------------------------------------------*/
27463 
27464 #if X_SIZEOF_FLOAT == SIZEOF_FLOAT && !defined(NO_IEEE_FLOAT)
27465 /* optimized version */
27466 int
ncx_getn_float_float(const void ** xpp,size_t nelems,float * tp)27467 ncx_getn_float_float(const void **xpp, size_t nelems, float *tp)
27468 {
27469 #ifdef WORDS_BIGENDIAN
27470 	(void) memcpy(tp, *xpp, (size_t)nelems * SIZEOF_FLOAT);
27471 # else
27472 	swapn4b(tp, *xpp, nelems);
27473 # endif
27474 	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_FLOAT);
27475 	return NC_NOERR;
27476 }
27477 #elif defined(vax) && vax != 0
27478 int
ncx_getn_float_float(const void ** xpp,size_t nfloats,float * ip)27479 ncx_getn_float_float(const void **xpp, size_t nfloats, float *ip)
27480 {
27481 	float *const end = ip + nfloats;
27482 
27483 	while (ip < end)
27484 	{
27485 		struct vax_single *const vsp = (struct vax_single *) ip;
27486 #line 3415
27487 		const struct ieee_single *const isp =
27488 #line 3415
27489 			 (const struct ieee_single *) (*xpp);
27490 #line 3415
27491 		unsigned exp = isp->exp_hi << 1 | isp->exp_lo;
27492 #line 3415
27493 
27494 #line 3415
27495 		switch(exp) {
27496 #line 3415
27497 		case 0 :
27498 #line 3415
27499 			/* ieee subnormal */
27500 #line 3415
27501 			if (isp->mant_hi == min.ieee.mant_hi
27502 #line 3415
27503 				&& isp->mant_lo_hi == min.ieee.mant_lo_hi
27504 #line 3415
27505 				&& isp->mant_lo_lo == min.ieee.mant_lo_lo)
27506 #line 3415
27507 			{
27508 #line 3415
27509 				*vsp = min.s;
27510 #line 3415
27511 			}
27512 #line 3415
27513 			else
27514 #line 3415
27515 			{
27516 #line 3415
27517 				unsigned mantissa = (isp->mant_hi << 16)
27518 #line 3415
27519 					 | isp->mant_lo_hi << 8
27520 #line 3415
27521 					 | isp->mant_lo_lo;
27522 #line 3415
27523 				unsigned tmp = mantissa >> 20;
27524 #line 3415
27525 				if (tmp >= 4) {
27526 #line 3415
27527 					vsp->exp = 2;
27528 #line 3415
27529 				} else if (tmp >= 2) {
27530 #line 3415
27531 					vsp->exp = 1;
27532 #line 3415
27533 				} else {
27534 #line 3415
27535 					*vsp = min.s;
27536 #line 3415
27537 					break;
27538 #line 3415
27539 				} /* else */
27540 #line 3415
27541 				tmp = mantissa - (1 << (20 + vsp->exp ));
27542 #line 3415
27543 				tmp <<= 3 - vsp->exp;
27544 #line 3415
27545 				vsp->mantissa2 = tmp;
27546 #line 3415
27547 				vsp->mantissa1 = (tmp >> 16);
27548 #line 3415
27549 			}
27550 #line 3415
27551 			break;
27552 #line 3415
27553 		case 0xfe :
27554 #line 3415
27555 		case 0xff :
27556 #line 3415
27557 			*vsp = max.s;
27558 #line 3415
27559 			break;
27560 #line 3415
27561 		default :
27562 #line 3415
27563 			vsp->exp = exp - IEEE_SNG_BIAS + VAX_SNG_BIAS;
27564 #line 3415
27565 			vsp->mantissa2 = isp->mant_lo_hi << 8 | isp->mant_lo_lo;
27566 #line 3415
27567 			vsp->mantissa1 = isp->mant_hi;
27568 #line 3415
27569 		}
27570 #line 3415
27571 
27572 #line 3415
27573 		vsp->sign = isp->sign;
27574 #line 3415
27575 
27576 
27577 		ip++;
27578 		*xpp = (char *)(*xpp) + X_SIZEOF_FLOAT;
27579 	}
27580 	return NC_NOERR;
27581 }
27582 #else
27583 int
ncx_getn_float_float(const void ** xpp,size_t nelems,float * tp)27584 ncx_getn_float_float(const void **xpp, size_t nelems, float *tp)
27585 {
27586 	const char *xp = *xpp;
27587 	int status = NC_NOERR;
27588 
27589 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
27590 	{
27591 		const int lstatus = ncx_get_float_float(xp, tp, fillp);
27592 		if (status == NC_NOERR) /* report the first encountered error */
27593 			status = lstatus;
27594 	}
27595 
27596 	*xpp = (const void *)xp;
27597 	return status;
27598 }
27599 
27600 #endif
27601 int
27602 #line 3441
ncx_getn_float_schar(const void ** xpp,size_t nelems,schar * tp)27603 ncx_getn_float_schar(const void **xpp, size_t nelems, schar *tp)
27604 #line 3441
27605 {
27606 #line 3441
27607 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
27608 #line 3441
27609 
27610 #line 3441
27611  /* basic algorithm is:
27612 #line 3441
27613   *   - ensure sane alignment of input data
27614 #line 3441
27615   *   - copy (conversion happens automatically) input data
27616 #line 3441
27617   *     to output
27618 #line 3441
27619   *   - update xpp to point at next unconverted input, and tp to point
27620 #line 3441
27621   *     at next location for converted output
27622 #line 3441
27623   */
27624 #line 3441
27625   long i, j, ni;
27626 #line 3441
27627   float tmp[LOOPCNT];        /* in case input is misaligned */
27628 #line 3441
27629   float *xp;
27630 #line 3441
27631   int nrange = 0;         /* number of range errors */
27632 #line 3441
27633   int realign = 0;        /* "do we need to fix input data alignment?" */
27634 #line 3441
27635   long cxp = (long) *((char**)xpp);
27636 #line 3441
27637 
27638 #line 3441
27639   realign = (cxp & 7) % SIZEOF_FLOAT;
27640 #line 3441
27641   /* sjl: manually stripmine so we can limit amount of
27642 #line 3441
27643    * vector work space reserved to LOOPCNT elements. Also
27644 #line 3441
27645    * makes vectorisation easy */
27646 #line 3441
27647   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
27648 #line 3441
27649     ni=Min(nelems-j,LOOPCNT);
27650 #line 3441
27651     if (realign) {
27652 #line 3441
27653       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
27654 #line 3441
27655       xp = tmp;
27656 #line 3441
27657     } else {
27658 #line 3441
27659       xp = (float *) *xpp;
27660 #line 3441
27661     }
27662 #line 3441
27663    /* copy the next block */
27664 #line 3441
27665 #pragma cdir loopcnt=LOOPCNT
27666 #line 3441
27667 #pragma cdir shortloop
27668 #line 3441
27669     for (i=0; i<ni; i++) {
27670 #line 3441
27671       tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
27672 #line 3441
27673      /* test for range errors (not always needed but do it anyway) */
27674 #line 3441
27675      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
27676 #line 3441
27677      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
27678 #line 3441
27679       nrange += xp[i] > SCHAR_MAX || xp[i] < SCHAR_MIN;
27680 #line 3441
27681     }
27682 #line 3441
27683    /* update xpp and tp */
27684 #line 3441
27685     if (realign) xp = (float *) *xpp;
27686 #line 3441
27687     xp += ni;
27688 #line 3441
27689     tp += ni;
27690 #line 3441
27691     *xpp = (void*)xp;
27692 #line 3441
27693   }
27694 #line 3441
27695   return nrange == 0 ? NC_NOERR : NC_ERANGE;
27696 #line 3441
27697 
27698 #line 3441
27699 #else   /* not SX */
27700 #line 3441
27701 	const char *xp = (const char *) *xpp;
27702 #line 3441
27703 	int status = NC_NOERR;
27704 #line 3441
27705 
27706 #line 3441
27707 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
27708 #line 3441
27709 	{
27710 #line 3441
27711 		const int lstatus = ncx_get_float_schar(xp, tp);
27712 #line 3441
27713 		if (status == NC_NOERR) /* report the first encountered error */
27714 #line 3441
27715 			status = lstatus;
27716 #line 3441
27717 	}
27718 #line 3441
27719 
27720 #line 3441
27721 	*xpp = (const void *)xp;
27722 #line 3441
27723 	return status;
27724 #line 3441
27725 #endif
27726 #line 3441
27727 }
27728 #line 3441
27729 
27730 int
27731 #line 3442
ncx_getn_float_short(const void ** xpp,size_t nelems,short * tp)27732 ncx_getn_float_short(const void **xpp, size_t nelems, short *tp)
27733 #line 3442
27734 {
27735 #line 3442
27736 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
27737 #line 3442
27738 
27739 #line 3442
27740  /* basic algorithm is:
27741 #line 3442
27742   *   - ensure sane alignment of input data
27743 #line 3442
27744   *   - copy (conversion happens automatically) input data
27745 #line 3442
27746   *     to output
27747 #line 3442
27748   *   - update xpp to point at next unconverted input, and tp to point
27749 #line 3442
27750   *     at next location for converted output
27751 #line 3442
27752   */
27753 #line 3442
27754   long i, j, ni;
27755 #line 3442
27756   float tmp[LOOPCNT];        /* in case input is misaligned */
27757 #line 3442
27758   float *xp;
27759 #line 3442
27760   int nrange = 0;         /* number of range errors */
27761 #line 3442
27762   int realign = 0;        /* "do we need to fix input data alignment?" */
27763 #line 3442
27764   long cxp = (long) *((char**)xpp);
27765 #line 3442
27766 
27767 #line 3442
27768   realign = (cxp & 7) % SIZEOF_FLOAT;
27769 #line 3442
27770   /* sjl: manually stripmine so we can limit amount of
27771 #line 3442
27772    * vector work space reserved to LOOPCNT elements. Also
27773 #line 3442
27774    * makes vectorisation easy */
27775 #line 3442
27776   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
27777 #line 3442
27778     ni=Min(nelems-j,LOOPCNT);
27779 #line 3442
27780     if (realign) {
27781 #line 3442
27782       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
27783 #line 3442
27784       xp = tmp;
27785 #line 3442
27786     } else {
27787 #line 3442
27788       xp = (float *) *xpp;
27789 #line 3442
27790     }
27791 #line 3442
27792    /* copy the next block */
27793 #line 3442
27794 #pragma cdir loopcnt=LOOPCNT
27795 #line 3442
27796 #pragma cdir shortloop
27797 #line 3442
27798     for (i=0; i<ni; i++) {
27799 #line 3442
27800       tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
27801 #line 3442
27802      /* test for range errors (not always needed but do it anyway) */
27803 #line 3442
27804      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
27805 #line 3442
27806      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
27807 #line 3442
27808       nrange += xp[i] > SHORT_MAX || xp[i] < SHORT_MIN;
27809 #line 3442
27810     }
27811 #line 3442
27812    /* update xpp and tp */
27813 #line 3442
27814     if (realign) xp = (float *) *xpp;
27815 #line 3442
27816     xp += ni;
27817 #line 3442
27818     tp += ni;
27819 #line 3442
27820     *xpp = (void*)xp;
27821 #line 3442
27822   }
27823 #line 3442
27824   return nrange == 0 ? NC_NOERR : NC_ERANGE;
27825 #line 3442
27826 
27827 #line 3442
27828 #else   /* not SX */
27829 #line 3442
27830 	const char *xp = (const char *) *xpp;
27831 #line 3442
27832 	int status = NC_NOERR;
27833 #line 3442
27834 
27835 #line 3442
27836 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
27837 #line 3442
27838 	{
27839 #line 3442
27840 		const int lstatus = ncx_get_float_short(xp, tp);
27841 #line 3442
27842 		if (status == NC_NOERR) /* report the first encountered error */
27843 #line 3442
27844 			status = lstatus;
27845 #line 3442
27846 	}
27847 #line 3442
27848 
27849 #line 3442
27850 	*xpp = (const void *)xp;
27851 #line 3442
27852 	return status;
27853 #line 3442
27854 #endif
27855 #line 3442
27856 }
27857 #line 3442
27858 
27859 int
27860 #line 3443
ncx_getn_float_int(const void ** xpp,size_t nelems,int * tp)27861 ncx_getn_float_int(const void **xpp, size_t nelems, int *tp)
27862 #line 3443
27863 {
27864 #line 3443
27865 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
27866 #line 3443
27867 
27868 #line 3443
27869  /* basic algorithm is:
27870 #line 3443
27871   *   - ensure sane alignment of input data
27872 #line 3443
27873   *   - copy (conversion happens automatically) input data
27874 #line 3443
27875   *     to output
27876 #line 3443
27877   *   - update xpp to point at next unconverted input, and tp to point
27878 #line 3443
27879   *     at next location for converted output
27880 #line 3443
27881   */
27882 #line 3443
27883   long i, j, ni;
27884 #line 3443
27885   float tmp[LOOPCNT];        /* in case input is misaligned */
27886 #line 3443
27887   float *xp;
27888 #line 3443
27889   int nrange = 0;         /* number of range errors */
27890 #line 3443
27891   int realign = 0;        /* "do we need to fix input data alignment?" */
27892 #line 3443
27893   long cxp = (long) *((char**)xpp);
27894 #line 3443
27895 
27896 #line 3443
27897   realign = (cxp & 7) % SIZEOF_FLOAT;
27898 #line 3443
27899   /* sjl: manually stripmine so we can limit amount of
27900 #line 3443
27901    * vector work space reserved to LOOPCNT elements. Also
27902 #line 3443
27903    * makes vectorisation easy */
27904 #line 3443
27905   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
27906 #line 3443
27907     ni=Min(nelems-j,LOOPCNT);
27908 #line 3443
27909     if (realign) {
27910 #line 3443
27911       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
27912 #line 3443
27913       xp = tmp;
27914 #line 3443
27915     } else {
27916 #line 3443
27917       xp = (float *) *xpp;
27918 #line 3443
27919     }
27920 #line 3443
27921    /* copy the next block */
27922 #line 3443
27923 #pragma cdir loopcnt=LOOPCNT
27924 #line 3443
27925 #pragma cdir shortloop
27926 #line 3443
27927     for (i=0; i<ni; i++) {
27928 #line 3443
27929       tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
27930 #line 3443
27931      /* test for range errors (not always needed but do it anyway) */
27932 #line 3443
27933      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
27934 #line 3443
27935      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
27936 #line 3443
27937       nrange += xp[i] > INT_MAX || xp[i] < INT_MIN;
27938 #line 3443
27939     }
27940 #line 3443
27941    /* update xpp and tp */
27942 #line 3443
27943     if (realign) xp = (float *) *xpp;
27944 #line 3443
27945     xp += ni;
27946 #line 3443
27947     tp += ni;
27948 #line 3443
27949     *xpp = (void*)xp;
27950 #line 3443
27951   }
27952 #line 3443
27953   return nrange == 0 ? NC_NOERR : NC_ERANGE;
27954 #line 3443
27955 
27956 #line 3443
27957 #else   /* not SX */
27958 #line 3443
27959 	const char *xp = (const char *) *xpp;
27960 #line 3443
27961 	int status = NC_NOERR;
27962 #line 3443
27963 
27964 #line 3443
27965 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
27966 #line 3443
27967 	{
27968 #line 3443
27969 		const int lstatus = ncx_get_float_int(xp, tp);
27970 #line 3443
27971 		if (status == NC_NOERR) /* report the first encountered error */
27972 #line 3443
27973 			status = lstatus;
27974 #line 3443
27975 	}
27976 #line 3443
27977 
27978 #line 3443
27979 	*xpp = (const void *)xp;
27980 #line 3443
27981 	return status;
27982 #line 3443
27983 #endif
27984 #line 3443
27985 }
27986 #line 3443
27987 
27988 int
27989 #line 3444
ncx_getn_float_long(const void ** xpp,size_t nelems,long * tp)27990 ncx_getn_float_long(const void **xpp, size_t nelems, long *tp)
27991 #line 3444
27992 {
27993 #line 3444
27994 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
27995 #line 3444
27996 
27997 #line 3444
27998  /* basic algorithm is:
27999 #line 3444
28000   *   - ensure sane alignment of input data
28001 #line 3444
28002   *   - copy (conversion happens automatically) input data
28003 #line 3444
28004   *     to output
28005 #line 3444
28006   *   - update xpp to point at next unconverted input, and tp to point
28007 #line 3444
28008   *     at next location for converted output
28009 #line 3444
28010   */
28011 #line 3444
28012   long i, j, ni;
28013 #line 3444
28014   float tmp[LOOPCNT];        /* in case input is misaligned */
28015 #line 3444
28016   float *xp;
28017 #line 3444
28018   int nrange = 0;         /* number of range errors */
28019 #line 3444
28020   int realign = 0;        /* "do we need to fix input data alignment?" */
28021 #line 3444
28022   long cxp = (long) *((char**)xpp);
28023 #line 3444
28024 
28025 #line 3444
28026   realign = (cxp & 7) % SIZEOF_FLOAT;
28027 #line 3444
28028   /* sjl: manually stripmine so we can limit amount of
28029 #line 3444
28030    * vector work space reserved to LOOPCNT elements. Also
28031 #line 3444
28032    * makes vectorisation easy */
28033 #line 3444
28034   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
28035 #line 3444
28036     ni=Min(nelems-j,LOOPCNT);
28037 #line 3444
28038     if (realign) {
28039 #line 3444
28040       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
28041 #line 3444
28042       xp = tmp;
28043 #line 3444
28044     } else {
28045 #line 3444
28046       xp = (float *) *xpp;
28047 #line 3444
28048     }
28049 #line 3444
28050    /* copy the next block */
28051 #line 3444
28052 #pragma cdir loopcnt=LOOPCNT
28053 #line 3444
28054 #pragma cdir shortloop
28055 #line 3444
28056     for (i=0; i<ni; i++) {
28057 #line 3444
28058       tp[i] = (long) Max( LONG_MIN, Min(LONG_MAX, (long) xp[i]));
28059 #line 3444
28060      /* test for range errors (not always needed but do it anyway) */
28061 #line 3444
28062      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
28063 #line 3444
28064      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
28065 #line 3444
28066       nrange += xp[i] > LONG_MAX || xp[i] < LONG_MIN;
28067 #line 3444
28068     }
28069 #line 3444
28070    /* update xpp and tp */
28071 #line 3444
28072     if (realign) xp = (float *) *xpp;
28073 #line 3444
28074     xp += ni;
28075 #line 3444
28076     tp += ni;
28077 #line 3444
28078     *xpp = (void*)xp;
28079 #line 3444
28080   }
28081 #line 3444
28082   return nrange == 0 ? NC_NOERR : NC_ERANGE;
28083 #line 3444
28084 
28085 #line 3444
28086 #else   /* not SX */
28087 #line 3444
28088 	const char *xp = (const char *) *xpp;
28089 #line 3444
28090 	int status = NC_NOERR;
28091 #line 3444
28092 
28093 #line 3444
28094 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
28095 #line 3444
28096 	{
28097 #line 3444
28098 		const int lstatus = ncx_get_float_long(xp, tp);
28099 #line 3444
28100 		if (status == NC_NOERR) /* report the first encountered error */
28101 #line 3444
28102 			status = lstatus;
28103 #line 3444
28104 	}
28105 #line 3444
28106 
28107 #line 3444
28108 	*xpp = (const void *)xp;
28109 #line 3444
28110 	return status;
28111 #line 3444
28112 #endif
28113 #line 3444
28114 }
28115 #line 3444
28116 
28117 int
28118 #line 3445
ncx_getn_float_double(const void ** xpp,size_t nelems,double * tp)28119 ncx_getn_float_double(const void **xpp, size_t nelems, double *tp)
28120 #line 3445
28121 {
28122 #line 3445
28123 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
28124 #line 3445
28125 
28126 #line 3445
28127  /* basic algorithm is:
28128 #line 3445
28129   *   - ensure sane alignment of input data
28130 #line 3445
28131   *   - copy (conversion happens automatically) input data
28132 #line 3445
28133   *     to output
28134 #line 3445
28135   *   - update xpp to point at next unconverted input, and tp to point
28136 #line 3445
28137   *     at next location for converted output
28138 #line 3445
28139   */
28140 #line 3445
28141   long i, j, ni;
28142 #line 3445
28143   float tmp[LOOPCNT];        /* in case input is misaligned */
28144 #line 3445
28145   float *xp;
28146 #line 3445
28147   int nrange = 0;         /* number of range errors */
28148 #line 3445
28149   int realign = 0;        /* "do we need to fix input data alignment?" */
28150 #line 3445
28151   long cxp = (long) *((char**)xpp);
28152 #line 3445
28153 
28154 #line 3445
28155   realign = (cxp & 7) % SIZEOF_FLOAT;
28156 #line 3445
28157   /* sjl: manually stripmine so we can limit amount of
28158 #line 3445
28159    * vector work space reserved to LOOPCNT elements. Also
28160 #line 3445
28161    * makes vectorisation easy */
28162 #line 3445
28163   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
28164 #line 3445
28165     ni=Min(nelems-j,LOOPCNT);
28166 #line 3445
28167     if (realign) {
28168 #line 3445
28169       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
28170 #line 3445
28171       xp = tmp;
28172 #line 3445
28173     } else {
28174 #line 3445
28175       xp = (float *) *xpp;
28176 #line 3445
28177     }
28178 #line 3445
28179    /* copy the next block */
28180 #line 3445
28181 #pragma cdir loopcnt=LOOPCNT
28182 #line 3445
28183 #pragma cdir shortloop
28184 #line 3445
28185     for (i=0; i<ni; i++) {
28186 #line 3445
28187       tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
28188 #line 3445
28189      /* test for range errors (not always needed but do it anyway) */
28190 #line 3445
28191      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
28192 #line 3445
28193      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
28194 #line 3445
28195       nrange += xp[i] > DOUBLE_MAX || xp[i] < DOUBLE_MIN;
28196 #line 3445
28197     }
28198 #line 3445
28199    /* update xpp and tp */
28200 #line 3445
28201     if (realign) xp = (float *) *xpp;
28202 #line 3445
28203     xp += ni;
28204 #line 3445
28205     tp += ni;
28206 #line 3445
28207     *xpp = (void*)xp;
28208 #line 3445
28209   }
28210 #line 3445
28211   return nrange == 0 ? NC_NOERR : NC_ERANGE;
28212 #line 3445
28213 
28214 #line 3445
28215 #else   /* not SX */
28216 #line 3445
28217 	const char *xp = (const char *) *xpp;
28218 #line 3445
28219 	int status = NC_NOERR;
28220 #line 3445
28221 
28222 #line 3445
28223 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
28224 #line 3445
28225 	{
28226 #line 3445
28227 		const int lstatus = ncx_get_float_double(xp, tp);
28228 #line 3445
28229 		if (status == NC_NOERR) /* report the first encountered error */
28230 #line 3445
28231 			status = lstatus;
28232 #line 3445
28233 	}
28234 #line 3445
28235 
28236 #line 3445
28237 	*xpp = (const void *)xp;
28238 #line 3445
28239 	return status;
28240 #line 3445
28241 #endif
28242 #line 3445
28243 }
28244 #line 3445
28245 
28246 int
28247 #line 3446
ncx_getn_float_longlong(const void ** xpp,size_t nelems,longlong * tp)28248 ncx_getn_float_longlong(const void **xpp, size_t nelems, longlong *tp)
28249 #line 3446
28250 {
28251 #line 3446
28252 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
28253 #line 3446
28254 
28255 #line 3446
28256  /* basic algorithm is:
28257 #line 3446
28258   *   - ensure sane alignment of input data
28259 #line 3446
28260   *   - copy (conversion happens automatically) input data
28261 #line 3446
28262   *     to output
28263 #line 3446
28264   *   - update xpp to point at next unconverted input, and tp to point
28265 #line 3446
28266   *     at next location for converted output
28267 #line 3446
28268   */
28269 #line 3446
28270   long i, j, ni;
28271 #line 3446
28272   float tmp[LOOPCNT];        /* in case input is misaligned */
28273 #line 3446
28274   float *xp;
28275 #line 3446
28276   int nrange = 0;         /* number of range errors */
28277 #line 3446
28278   int realign = 0;        /* "do we need to fix input data alignment?" */
28279 #line 3446
28280   long cxp = (long) *((char**)xpp);
28281 #line 3446
28282 
28283 #line 3446
28284   realign = (cxp & 7) % SIZEOF_FLOAT;
28285 #line 3446
28286   /* sjl: manually stripmine so we can limit amount of
28287 #line 3446
28288    * vector work space reserved to LOOPCNT elements. Also
28289 #line 3446
28290    * makes vectorisation easy */
28291 #line 3446
28292   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
28293 #line 3446
28294     ni=Min(nelems-j,LOOPCNT);
28295 #line 3446
28296     if (realign) {
28297 #line 3446
28298       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
28299 #line 3446
28300       xp = tmp;
28301 #line 3446
28302     } else {
28303 #line 3446
28304       xp = (float *) *xpp;
28305 #line 3446
28306     }
28307 #line 3446
28308    /* copy the next block */
28309 #line 3446
28310 #pragma cdir loopcnt=LOOPCNT
28311 #line 3446
28312 #pragma cdir shortloop
28313 #line 3446
28314     for (i=0; i<ni; i++) {
28315 #line 3446
28316       tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
28317 #line 3446
28318      /* test for range errors (not always needed but do it anyway) */
28319 #line 3446
28320      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
28321 #line 3446
28322      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
28323 #line 3446
28324       nrange += xp[i] > LONGLONG_MAX || xp[i] < LONGLONG_MIN;
28325 #line 3446
28326     }
28327 #line 3446
28328    /* update xpp and tp */
28329 #line 3446
28330     if (realign) xp = (float *) *xpp;
28331 #line 3446
28332     xp += ni;
28333 #line 3446
28334     tp += ni;
28335 #line 3446
28336     *xpp = (void*)xp;
28337 #line 3446
28338   }
28339 #line 3446
28340   return nrange == 0 ? NC_NOERR : NC_ERANGE;
28341 #line 3446
28342 
28343 #line 3446
28344 #else   /* not SX */
28345 #line 3446
28346 	const char *xp = (const char *) *xpp;
28347 #line 3446
28348 	int status = NC_NOERR;
28349 #line 3446
28350 
28351 #line 3446
28352 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
28353 #line 3446
28354 	{
28355 #line 3446
28356 		const int lstatus = ncx_get_float_longlong(xp, tp);
28357 #line 3446
28358 		if (status == NC_NOERR) /* report the first encountered error */
28359 #line 3446
28360 			status = lstatus;
28361 #line 3446
28362 	}
28363 #line 3446
28364 
28365 #line 3446
28366 	*xpp = (const void *)xp;
28367 #line 3446
28368 	return status;
28369 #line 3446
28370 #endif
28371 #line 3446
28372 }
28373 #line 3446
28374 
28375 int
28376 #line 3447
ncx_getn_float_ushort(const void ** xpp,size_t nelems,ushort * tp)28377 ncx_getn_float_ushort(const void **xpp, size_t nelems, ushort *tp)
28378 #line 3447
28379 {
28380 #line 3447
28381 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
28382 #line 3447
28383 
28384 #line 3447
28385  /* basic algorithm is:
28386 #line 3447
28387   *   - ensure sane alignment of input data
28388 #line 3447
28389   *   - copy (conversion happens automatically) input data
28390 #line 3447
28391   *     to output
28392 #line 3447
28393   *   - update xpp to point at next unconverted input, and tp to point
28394 #line 3447
28395   *     at next location for converted output
28396 #line 3447
28397   */
28398 #line 3447
28399   long i, j, ni;
28400 #line 3447
28401   float tmp[LOOPCNT];        /* in case input is misaligned */
28402 #line 3447
28403   float *xp;
28404 #line 3447
28405   int nrange = 0;         /* number of range errors */
28406 #line 3447
28407   int realign = 0;        /* "do we need to fix input data alignment?" */
28408 #line 3447
28409   long cxp = (long) *((char**)xpp);
28410 #line 3447
28411 
28412 #line 3447
28413   realign = (cxp & 7) % SIZEOF_FLOAT;
28414 #line 3447
28415   /* sjl: manually stripmine so we can limit amount of
28416 #line 3447
28417    * vector work space reserved to LOOPCNT elements. Also
28418 #line 3447
28419    * makes vectorisation easy */
28420 #line 3447
28421   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
28422 #line 3447
28423     ni=Min(nelems-j,LOOPCNT);
28424 #line 3447
28425     if (realign) {
28426 #line 3447
28427       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
28428 #line 3447
28429       xp = tmp;
28430 #line 3447
28431     } else {
28432 #line 3447
28433       xp = (float *) *xpp;
28434 #line 3447
28435     }
28436 #line 3447
28437    /* copy the next block */
28438 #line 3447
28439 #pragma cdir loopcnt=LOOPCNT
28440 #line 3447
28441 #pragma cdir shortloop
28442 #line 3447
28443     for (i=0; i<ni; i++) {
28444 #line 3447
28445       tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
28446 #line 3447
28447      /* test for range errors (not always needed but do it anyway) */
28448 #line 3447
28449      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
28450 #line 3447
28451      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
28452 #line 3447
28453       nrange += xp[i] > USHORT_MAX || xp[i] < 0;
28454 #line 3447
28455     }
28456 #line 3447
28457    /* update xpp and tp */
28458 #line 3447
28459     if (realign) xp = (float *) *xpp;
28460 #line 3447
28461     xp += ni;
28462 #line 3447
28463     tp += ni;
28464 #line 3447
28465     *xpp = (void*)xp;
28466 #line 3447
28467   }
28468 #line 3447
28469   return nrange == 0 ? NC_NOERR : NC_ERANGE;
28470 #line 3447
28471 
28472 #line 3447
28473 #else   /* not SX */
28474 #line 3447
28475 	const char *xp = (const char *) *xpp;
28476 #line 3447
28477 	int status = NC_NOERR;
28478 #line 3447
28479 
28480 #line 3447
28481 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
28482 #line 3447
28483 	{
28484 #line 3447
28485 		const int lstatus = ncx_get_float_ushort(xp, tp);
28486 #line 3447
28487 		if (status == NC_NOERR) /* report the first encountered error */
28488 #line 3447
28489 			status = lstatus;
28490 #line 3447
28491 	}
28492 #line 3447
28493 
28494 #line 3447
28495 	*xpp = (const void *)xp;
28496 #line 3447
28497 	return status;
28498 #line 3447
28499 #endif
28500 #line 3447
28501 }
28502 #line 3447
28503 
28504 int
28505 #line 3448
ncx_getn_float_uchar(const void ** xpp,size_t nelems,uchar * tp)28506 ncx_getn_float_uchar(const void **xpp, size_t nelems, uchar *tp)
28507 #line 3448
28508 {
28509 #line 3448
28510 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
28511 #line 3448
28512 
28513 #line 3448
28514  /* basic algorithm is:
28515 #line 3448
28516   *   - ensure sane alignment of input data
28517 #line 3448
28518   *   - copy (conversion happens automatically) input data
28519 #line 3448
28520   *     to output
28521 #line 3448
28522   *   - update xpp to point at next unconverted input, and tp to point
28523 #line 3448
28524   *     at next location for converted output
28525 #line 3448
28526   */
28527 #line 3448
28528   long i, j, ni;
28529 #line 3448
28530   float tmp[LOOPCNT];        /* in case input is misaligned */
28531 #line 3448
28532   float *xp;
28533 #line 3448
28534   int nrange = 0;         /* number of range errors */
28535 #line 3448
28536   int realign = 0;        /* "do we need to fix input data alignment?" */
28537 #line 3448
28538   long cxp = (long) *((char**)xpp);
28539 #line 3448
28540 
28541 #line 3448
28542   realign = (cxp & 7) % SIZEOF_FLOAT;
28543 #line 3448
28544   /* sjl: manually stripmine so we can limit amount of
28545 #line 3448
28546    * vector work space reserved to LOOPCNT elements. Also
28547 #line 3448
28548    * makes vectorisation easy */
28549 #line 3448
28550   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
28551 #line 3448
28552     ni=Min(nelems-j,LOOPCNT);
28553 #line 3448
28554     if (realign) {
28555 #line 3448
28556       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
28557 #line 3448
28558       xp = tmp;
28559 #line 3448
28560     } else {
28561 #line 3448
28562       xp = (float *) *xpp;
28563 #line 3448
28564     }
28565 #line 3448
28566    /* copy the next block */
28567 #line 3448
28568 #pragma cdir loopcnt=LOOPCNT
28569 #line 3448
28570 #pragma cdir shortloop
28571 #line 3448
28572     for (i=0; i<ni; i++) {
28573 #line 3448
28574       tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
28575 #line 3448
28576      /* test for range errors (not always needed but do it anyway) */
28577 #line 3448
28578      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
28579 #line 3448
28580      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
28581 #line 3448
28582       nrange += xp[i] > UCHAR_MAX || xp[i] < 0;
28583 #line 3448
28584     }
28585 #line 3448
28586    /* update xpp and tp */
28587 #line 3448
28588     if (realign) xp = (float *) *xpp;
28589 #line 3448
28590     xp += ni;
28591 #line 3448
28592     tp += ni;
28593 #line 3448
28594     *xpp = (void*)xp;
28595 #line 3448
28596   }
28597 #line 3448
28598   return nrange == 0 ? NC_NOERR : NC_ERANGE;
28599 #line 3448
28600 
28601 #line 3448
28602 #else   /* not SX */
28603 #line 3448
28604 	const char *xp = (const char *) *xpp;
28605 #line 3448
28606 	int status = NC_NOERR;
28607 #line 3448
28608 
28609 #line 3448
28610 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
28611 #line 3448
28612 	{
28613 #line 3448
28614 		const int lstatus = ncx_get_float_uchar(xp, tp);
28615 #line 3448
28616 		if (status == NC_NOERR) /* report the first encountered error */
28617 #line 3448
28618 			status = lstatus;
28619 #line 3448
28620 	}
28621 #line 3448
28622 
28623 #line 3448
28624 	*xpp = (const void *)xp;
28625 #line 3448
28626 	return status;
28627 #line 3448
28628 #endif
28629 #line 3448
28630 }
28631 #line 3448
28632 
28633 int
28634 #line 3449
ncx_getn_float_uint(const void ** xpp,size_t nelems,uint * tp)28635 ncx_getn_float_uint(const void **xpp, size_t nelems, uint *tp)
28636 #line 3449
28637 {
28638 #line 3449
28639 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
28640 #line 3449
28641 
28642 #line 3449
28643  /* basic algorithm is:
28644 #line 3449
28645   *   - ensure sane alignment of input data
28646 #line 3449
28647   *   - copy (conversion happens automatically) input data
28648 #line 3449
28649   *     to output
28650 #line 3449
28651   *   - update xpp to point at next unconverted input, and tp to point
28652 #line 3449
28653   *     at next location for converted output
28654 #line 3449
28655   */
28656 #line 3449
28657   long i, j, ni;
28658 #line 3449
28659   float tmp[LOOPCNT];        /* in case input is misaligned */
28660 #line 3449
28661   float *xp;
28662 #line 3449
28663   int nrange = 0;         /* number of range errors */
28664 #line 3449
28665   int realign = 0;        /* "do we need to fix input data alignment?" */
28666 #line 3449
28667   long cxp = (long) *((char**)xpp);
28668 #line 3449
28669 
28670 #line 3449
28671   realign = (cxp & 7) % SIZEOF_FLOAT;
28672 #line 3449
28673   /* sjl: manually stripmine so we can limit amount of
28674 #line 3449
28675    * vector work space reserved to LOOPCNT elements. Also
28676 #line 3449
28677    * makes vectorisation easy */
28678 #line 3449
28679   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
28680 #line 3449
28681     ni=Min(nelems-j,LOOPCNT);
28682 #line 3449
28683     if (realign) {
28684 #line 3449
28685       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
28686 #line 3449
28687       xp = tmp;
28688 #line 3449
28689     } else {
28690 #line 3449
28691       xp = (float *) *xpp;
28692 #line 3449
28693     }
28694 #line 3449
28695    /* copy the next block */
28696 #line 3449
28697 #pragma cdir loopcnt=LOOPCNT
28698 #line 3449
28699 #pragma cdir shortloop
28700 #line 3449
28701     for (i=0; i<ni; i++) {
28702 #line 3449
28703       tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
28704 #line 3449
28705      /* test for range errors (not always needed but do it anyway) */
28706 #line 3449
28707      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
28708 #line 3449
28709      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
28710 #line 3449
28711       nrange += xp[i] > UINT_MAX || xp[i] < 0;
28712 #line 3449
28713     }
28714 #line 3449
28715    /* update xpp and tp */
28716 #line 3449
28717     if (realign) xp = (float *) *xpp;
28718 #line 3449
28719     xp += ni;
28720 #line 3449
28721     tp += ni;
28722 #line 3449
28723     *xpp = (void*)xp;
28724 #line 3449
28725   }
28726 #line 3449
28727   return nrange == 0 ? NC_NOERR : NC_ERANGE;
28728 #line 3449
28729 
28730 #line 3449
28731 #else   /* not SX */
28732 #line 3449
28733 	const char *xp = (const char *) *xpp;
28734 #line 3449
28735 	int status = NC_NOERR;
28736 #line 3449
28737 
28738 #line 3449
28739 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
28740 #line 3449
28741 	{
28742 #line 3449
28743 		const int lstatus = ncx_get_float_uint(xp, tp);
28744 #line 3449
28745 		if (status == NC_NOERR) /* report the first encountered error */
28746 #line 3449
28747 			status = lstatus;
28748 #line 3449
28749 	}
28750 #line 3449
28751 
28752 #line 3449
28753 	*xpp = (const void *)xp;
28754 #line 3449
28755 	return status;
28756 #line 3449
28757 #endif
28758 #line 3449
28759 }
28760 #line 3449
28761 
28762 int
28763 #line 3450
ncx_getn_float_ulonglong(const void ** xpp,size_t nelems,ulonglong * tp)28764 ncx_getn_float_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
28765 #line 3450
28766 {
28767 #line 3450
28768 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
28769 #line 3450
28770 
28771 #line 3450
28772  /* basic algorithm is:
28773 #line 3450
28774   *   - ensure sane alignment of input data
28775 #line 3450
28776   *   - copy (conversion happens automatically) input data
28777 #line 3450
28778   *     to output
28779 #line 3450
28780   *   - update xpp to point at next unconverted input, and tp to point
28781 #line 3450
28782   *     at next location for converted output
28783 #line 3450
28784   */
28785 #line 3450
28786   long i, j, ni;
28787 #line 3450
28788   float tmp[LOOPCNT];        /* in case input is misaligned */
28789 #line 3450
28790   float *xp;
28791 #line 3450
28792   int nrange = 0;         /* number of range errors */
28793 #line 3450
28794   int realign = 0;        /* "do we need to fix input data alignment?" */
28795 #line 3450
28796   long cxp = (long) *((char**)xpp);
28797 #line 3450
28798 
28799 #line 3450
28800   realign = (cxp & 7) % SIZEOF_FLOAT;
28801 #line 3450
28802   /* sjl: manually stripmine so we can limit amount of
28803 #line 3450
28804    * vector work space reserved to LOOPCNT elements. Also
28805 #line 3450
28806    * makes vectorisation easy */
28807 #line 3450
28808   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
28809 #line 3450
28810     ni=Min(nelems-j,LOOPCNT);
28811 #line 3450
28812     if (realign) {
28813 #line 3450
28814       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
28815 #line 3450
28816       xp = tmp;
28817 #line 3450
28818     } else {
28819 #line 3450
28820       xp = (float *) *xpp;
28821 #line 3450
28822     }
28823 #line 3450
28824    /* copy the next block */
28825 #line 3450
28826 #pragma cdir loopcnt=LOOPCNT
28827 #line 3450
28828 #pragma cdir shortloop
28829 #line 3450
28830     for (i=0; i<ni; i++) {
28831 #line 3450
28832       tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
28833 #line 3450
28834      /* test for range errors (not always needed but do it anyway) */
28835 #line 3450
28836      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
28837 #line 3450
28838      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
28839 #line 3450
28840       nrange += xp[i] > ULONGLONG_MAX || xp[i] < 0;
28841 #line 3450
28842     }
28843 #line 3450
28844    /* update xpp and tp */
28845 #line 3450
28846     if (realign) xp = (float *) *xpp;
28847 #line 3450
28848     xp += ni;
28849 #line 3450
28850     tp += ni;
28851 #line 3450
28852     *xpp = (void*)xp;
28853 #line 3450
28854   }
28855 #line 3450
28856   return nrange == 0 ? NC_NOERR : NC_ERANGE;
28857 #line 3450
28858 
28859 #line 3450
28860 #else   /* not SX */
28861 #line 3450
28862 	const char *xp = (const char *) *xpp;
28863 #line 3450
28864 	int status = NC_NOERR;
28865 #line 3450
28866 
28867 #line 3450
28868 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
28869 #line 3450
28870 	{
28871 #line 3450
28872 		const int lstatus = ncx_get_float_ulonglong(xp, tp);
28873 #line 3450
28874 		if (status == NC_NOERR) /* report the first encountered error */
28875 #line 3450
28876 			status = lstatus;
28877 #line 3450
28878 	}
28879 #line 3450
28880 
28881 #line 3450
28882 	*xpp = (const void *)xp;
28883 #line 3450
28884 	return status;
28885 #line 3450
28886 #endif
28887 #line 3450
28888 }
28889 #line 3450
28890 
28891 
28892 int
ncx_putn_float_float(void ** xpp,size_t nelems,const float * tp,void * fillp)28893 ncx_putn_float_float(void **xpp, size_t nelems, const float *tp, void *fillp)
28894 #if X_SIZEOF_FLOAT == SIZEOF_FLOAT && !defined(NO_IEEE_FLOAT)
28895 /* optimized version */
28896 {
28897 #ifdef WORDS_BIGENDIAN
28898 	(void) memcpy(*xpp, tp, (size_t)nelems * X_SIZEOF_FLOAT);
28899 # else
28900 	swapn4b(*xpp, tp, nelems);
28901 # endif
28902 	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_FLOAT);
28903 	return NC_NOERR;
28904 }
28905 #elif defined(vax) && vax != 0
28906 {
28907 	const float *const end = tp + nelems;
28908 
28909 	while (tp < end) {
28910 				const struct vax_single *const vsp =
28911 #line 3470
28912 			 (const struct vax_single *)ip;
28913 #line 3470
28914 		struct ieee_single *const isp = (struct ieee_single *) (*xpp);
28915 #line 3470
28916 
28917 #line 3470
28918 		switch(vsp->exp){
28919 #line 3470
28920 		case 0 :
28921 #line 3470
28922 			/* all vax float with zero exponent map to zero */
28923 #line 3470
28924 			*isp = min.ieee;
28925 #line 3470
28926 			break;
28927 #line 3470
28928 		case 2 :
28929 #line 3470
28930 		case 1 :
28931 #line 3470
28932 		{
28933 #line 3470
28934 			/* These will map to subnormals */
28935 #line 3470
28936 			unsigned mantissa = (vsp->mantissa1 << 16)
28937 #line 3470
28938 					 | vsp->mantissa2;
28939 #line 3470
28940 			mantissa >>= 3 - vsp->exp;
28941 #line 3470
28942 			mantissa += (1 << (20 + vsp->exp));
28943 #line 3470
28944 			isp->mant_lo_lo = mantissa;
28945 #line 3470
28946 			isp->mant_lo_hi = mantissa >> 8;
28947 #line 3470
28948 			isp->mant_hi = mantissa >> 16;
28949 #line 3470
28950 			isp->exp_lo = 0;
28951 #line 3470
28952 			isp->exp_hi = 0;
28953 #line 3470
28954 		}
28955 #line 3470
28956 			break;
28957 #line 3470
28958 		case 0xff : /* max.s.exp */
28959 #line 3470
28960 			if (vsp->mantissa2 == max.s.mantissa2 &&
28961 #line 3470
28962 			    vsp->mantissa1 == max.s.mantissa1)
28963 #line 3470
28964 			{
28965 #line 3470
28966 				/* map largest vax float to ieee infinity */
28967 #line 3470
28968 				*isp = max.ieee;
28969 #line 3470
28970 				break;
28971 #line 3470
28972 			} /* else, fall thru */
28973 #line 3470
28974 		default :
28975 #line 3470
28976 		{
28977 #line 3470
28978 			unsigned exp = vsp->exp - VAX_SNG_BIAS + IEEE_SNG_BIAS;
28979 #line 3470
28980 			isp->exp_hi = exp >> 1;
28981 #line 3470
28982 			isp->exp_lo = exp;
28983 #line 3470
28984 			isp->mant_lo_lo = vsp->mantissa2;
28985 #line 3470
28986 			isp->mant_lo_hi = vsp->mantissa2 >> 8;
28987 #line 3470
28988 			isp->mant_hi = vsp->mantissa1;
28989 #line 3470
28990 		}
28991 #line 3470
28992 		}
28993 #line 3470
28994 
28995 #line 3470
28996 		isp->sign = vsp->sign;
28997 #line 3470
28998 
28999 		tp++;
29000 		*xpp = (char *)(*xpp) + X_SIZEOF_FLOAT;
29001 	}
29002 	return NC_NOERR;
29003 }
29004 #else
29005 {
29006 	char *xp = *xpp;
29007 	int status = NC_NOERR;
29008 
29009 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) {
29010 		int lstatus = ncx_put_float_float(xp, tp, fillp);
29011 		if (status == NC_NOERR) /* report the first encountered error */
29012 			status = lstatus;
29013 	}
29014 
29015 	*xpp = (void *)xp;
29016 	return status;
29017 }
29018 #endif
29019 int
29020 #line 3491
ncx_putn_float_schar(void ** xpp,size_t nelems,const schar * tp,void * fillp)29021 ncx_putn_float_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
29022 #line 3491
29023 {
29024 #line 3491
29025 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
29026 #line 3491
29027 
29028 #line 3491
29029  /* basic algorithm is:
29030 #line 3491
29031   *   - ensure sane alignment of output data
29032 #line 3491
29033   *   - copy (conversion happens automatically) input data
29034 #line 3491
29035   *     to output
29036 #line 3491
29037   *   - update tp to point at next unconverted input, and xpp to point
29038 #line 3491
29039   *     at next location for converted output
29040 #line 3491
29041   */
29042 #line 3491
29043   long i, j, ni;
29044 #line 3491
29045   float tmp[LOOPCNT];        /* in case input is misaligned */
29046 #line 3491
29047   float *xp;
29048 #line 3491
29049   int nrange = 0;         /* number of range errors */
29050 #line 3491
29051   int realign = 0;        /* "do we need to fix input data alignment?" */
29052 #line 3491
29053   long cxp = (long) *((char**)xpp);
29054 #line 3491
29055 
29056 #line 3491
29057   realign = (cxp & 7) % SIZEOF_FLOAT;
29058 #line 3491
29059   /* sjl: manually stripmine so we can limit amount of
29060 #line 3491
29061    * vector work space reserved to LOOPCNT elements. Also
29062 #line 3491
29063    * makes vectorisation easy */
29064 #line 3491
29065   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
29066 #line 3491
29067     ni=Min(nelems-j,LOOPCNT);
29068 #line 3491
29069     if (realign) {
29070 #line 3491
29071       xp = tmp;
29072 #line 3491
29073     } else {
29074 #line 3491
29075       xp = (float *) *xpp;
29076 #line 3491
29077     }
29078 #line 3491
29079    /* copy the next block */
29080 #line 3491
29081 #pragma cdir loopcnt=LOOPCNT
29082 #line 3491
29083 #pragma cdir shortloop
29084 #line 3491
29085     for (i=0; i<ni; i++) {
29086 #line 3491
29087       /* the normal case: */
29088 #line 3491
29089       xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
29090 #line 3491
29091      /* test for range errors (not always needed but do it anyway) */
29092 #line 3491
29093      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
29094 #line 3491
29095      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
29096 #line 3491
29097       nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
29098 #line 3491
29099     }
29100 #line 3491
29101    /* copy workspace back if necessary */
29102 #line 3491
29103     if (realign) {
29104 #line 3491
29105       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
29106 #line 3491
29107       xp = (float *) *xpp;
29108 #line 3491
29109     }
29110 #line 3491
29111    /* update xpp and tp */
29112 #line 3491
29113     xp += ni;
29114 #line 3491
29115     tp += ni;
29116 #line 3491
29117     *xpp = (void*)xp;
29118 #line 3491
29119   }
29120 #line 3491
29121   return nrange == 0 ? NC_NOERR : NC_ERANGE;
29122 #line 3491
29123 
29124 #line 3491
29125 #else   /* not SX */
29126 #line 3491
29127 
29128 #line 3491
29129 	char *xp = (char *) *xpp;
29130 #line 3491
29131 	int status = NC_NOERR;
29132 #line 3491
29133 
29134 #line 3491
29135 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
29136 #line 3491
29137 	{
29138 #line 3491
29139 		int lstatus = ncx_put_float_schar(xp, tp, fillp);
29140 #line 3491
29141 		if (status == NC_NOERR) /* report the first encountered error */
29142 #line 3491
29143 			status = lstatus;
29144 #line 3491
29145 	}
29146 #line 3491
29147 
29148 #line 3491
29149 	*xpp = (void *)xp;
29150 #line 3491
29151 	return status;
29152 #line 3491
29153 #endif
29154 #line 3491
29155 }
29156 #line 3491
29157 
29158 int
29159 #line 3492
ncx_putn_float_short(void ** xpp,size_t nelems,const short * tp,void * fillp)29160 ncx_putn_float_short(void **xpp, size_t nelems, const short *tp, void *fillp)
29161 #line 3492
29162 {
29163 #line 3492
29164 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
29165 #line 3492
29166 
29167 #line 3492
29168  /* basic algorithm is:
29169 #line 3492
29170   *   - ensure sane alignment of output data
29171 #line 3492
29172   *   - copy (conversion happens automatically) input data
29173 #line 3492
29174   *     to output
29175 #line 3492
29176   *   - update tp to point at next unconverted input, and xpp to point
29177 #line 3492
29178   *     at next location for converted output
29179 #line 3492
29180   */
29181 #line 3492
29182   long i, j, ni;
29183 #line 3492
29184   float tmp[LOOPCNT];        /* in case input is misaligned */
29185 #line 3492
29186   float *xp;
29187 #line 3492
29188   int nrange = 0;         /* number of range errors */
29189 #line 3492
29190   int realign = 0;        /* "do we need to fix input data alignment?" */
29191 #line 3492
29192   long cxp = (long) *((char**)xpp);
29193 #line 3492
29194 
29195 #line 3492
29196   realign = (cxp & 7) % SIZEOF_FLOAT;
29197 #line 3492
29198   /* sjl: manually stripmine so we can limit amount of
29199 #line 3492
29200    * vector work space reserved to LOOPCNT elements. Also
29201 #line 3492
29202    * makes vectorisation easy */
29203 #line 3492
29204   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
29205 #line 3492
29206     ni=Min(nelems-j,LOOPCNT);
29207 #line 3492
29208     if (realign) {
29209 #line 3492
29210       xp = tmp;
29211 #line 3492
29212     } else {
29213 #line 3492
29214       xp = (float *) *xpp;
29215 #line 3492
29216     }
29217 #line 3492
29218    /* copy the next block */
29219 #line 3492
29220 #pragma cdir loopcnt=LOOPCNT
29221 #line 3492
29222 #pragma cdir shortloop
29223 #line 3492
29224     for (i=0; i<ni; i++) {
29225 #line 3492
29226       /* the normal case: */
29227 #line 3492
29228       xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
29229 #line 3492
29230      /* test for range errors (not always needed but do it anyway) */
29231 #line 3492
29232      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
29233 #line 3492
29234      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
29235 #line 3492
29236       nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
29237 #line 3492
29238     }
29239 #line 3492
29240    /* copy workspace back if necessary */
29241 #line 3492
29242     if (realign) {
29243 #line 3492
29244       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
29245 #line 3492
29246       xp = (float *) *xpp;
29247 #line 3492
29248     }
29249 #line 3492
29250    /* update xpp and tp */
29251 #line 3492
29252     xp += ni;
29253 #line 3492
29254     tp += ni;
29255 #line 3492
29256     *xpp = (void*)xp;
29257 #line 3492
29258   }
29259 #line 3492
29260   return nrange == 0 ? NC_NOERR : NC_ERANGE;
29261 #line 3492
29262 
29263 #line 3492
29264 #else   /* not SX */
29265 #line 3492
29266 
29267 #line 3492
29268 	char *xp = (char *) *xpp;
29269 #line 3492
29270 	int status = NC_NOERR;
29271 #line 3492
29272 
29273 #line 3492
29274 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
29275 #line 3492
29276 	{
29277 #line 3492
29278 		int lstatus = ncx_put_float_short(xp, tp, fillp);
29279 #line 3492
29280 		if (status == NC_NOERR) /* report the first encountered error */
29281 #line 3492
29282 			status = lstatus;
29283 #line 3492
29284 	}
29285 #line 3492
29286 
29287 #line 3492
29288 	*xpp = (void *)xp;
29289 #line 3492
29290 	return status;
29291 #line 3492
29292 #endif
29293 #line 3492
29294 }
29295 #line 3492
29296 
29297 int
29298 #line 3493
ncx_putn_float_int(void ** xpp,size_t nelems,const int * tp,void * fillp)29299 ncx_putn_float_int(void **xpp, size_t nelems, const int *tp, void *fillp)
29300 #line 3493
29301 {
29302 #line 3493
29303 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
29304 #line 3493
29305 
29306 #line 3493
29307  /* basic algorithm is:
29308 #line 3493
29309   *   - ensure sane alignment of output data
29310 #line 3493
29311   *   - copy (conversion happens automatically) input data
29312 #line 3493
29313   *     to output
29314 #line 3493
29315   *   - update tp to point at next unconverted input, and xpp to point
29316 #line 3493
29317   *     at next location for converted output
29318 #line 3493
29319   */
29320 #line 3493
29321   long i, j, ni;
29322 #line 3493
29323   float tmp[LOOPCNT];        /* in case input is misaligned */
29324 #line 3493
29325   float *xp;
29326 #line 3493
29327   int nrange = 0;         /* number of range errors */
29328 #line 3493
29329   int realign = 0;        /* "do we need to fix input data alignment?" */
29330 #line 3493
29331   long cxp = (long) *((char**)xpp);
29332 #line 3493
29333 
29334 #line 3493
29335   realign = (cxp & 7) % SIZEOF_FLOAT;
29336 #line 3493
29337   /* sjl: manually stripmine so we can limit amount of
29338 #line 3493
29339    * vector work space reserved to LOOPCNT elements. Also
29340 #line 3493
29341    * makes vectorisation easy */
29342 #line 3493
29343   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
29344 #line 3493
29345     ni=Min(nelems-j,LOOPCNT);
29346 #line 3493
29347     if (realign) {
29348 #line 3493
29349       xp = tmp;
29350 #line 3493
29351     } else {
29352 #line 3493
29353       xp = (float *) *xpp;
29354 #line 3493
29355     }
29356 #line 3493
29357    /* copy the next block */
29358 #line 3493
29359 #pragma cdir loopcnt=LOOPCNT
29360 #line 3493
29361 #pragma cdir shortloop
29362 #line 3493
29363     for (i=0; i<ni; i++) {
29364 #line 3493
29365       /* the normal case: */
29366 #line 3493
29367       xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
29368 #line 3493
29369      /* test for range errors (not always needed but do it anyway) */
29370 #line 3493
29371      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
29372 #line 3493
29373      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
29374 #line 3493
29375       nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
29376 #line 3493
29377     }
29378 #line 3493
29379    /* copy workspace back if necessary */
29380 #line 3493
29381     if (realign) {
29382 #line 3493
29383       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
29384 #line 3493
29385       xp = (float *) *xpp;
29386 #line 3493
29387     }
29388 #line 3493
29389    /* update xpp and tp */
29390 #line 3493
29391     xp += ni;
29392 #line 3493
29393     tp += ni;
29394 #line 3493
29395     *xpp = (void*)xp;
29396 #line 3493
29397   }
29398 #line 3493
29399   return nrange == 0 ? NC_NOERR : NC_ERANGE;
29400 #line 3493
29401 
29402 #line 3493
29403 #else   /* not SX */
29404 #line 3493
29405 
29406 #line 3493
29407 	char *xp = (char *) *xpp;
29408 #line 3493
29409 	int status = NC_NOERR;
29410 #line 3493
29411 
29412 #line 3493
29413 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
29414 #line 3493
29415 	{
29416 #line 3493
29417 		int lstatus = ncx_put_float_int(xp, tp, fillp);
29418 #line 3493
29419 		if (status == NC_NOERR) /* report the first encountered error */
29420 #line 3493
29421 			status = lstatus;
29422 #line 3493
29423 	}
29424 #line 3493
29425 
29426 #line 3493
29427 	*xpp = (void *)xp;
29428 #line 3493
29429 	return status;
29430 #line 3493
29431 #endif
29432 #line 3493
29433 }
29434 #line 3493
29435 
29436 int
29437 #line 3494
ncx_putn_float_long(void ** xpp,size_t nelems,const long * tp,void * fillp)29438 ncx_putn_float_long(void **xpp, size_t nelems, const long *tp, void *fillp)
29439 #line 3494
29440 {
29441 #line 3494
29442 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
29443 #line 3494
29444 
29445 #line 3494
29446  /* basic algorithm is:
29447 #line 3494
29448   *   - ensure sane alignment of output data
29449 #line 3494
29450   *   - copy (conversion happens automatically) input data
29451 #line 3494
29452   *     to output
29453 #line 3494
29454   *   - update tp to point at next unconverted input, and xpp to point
29455 #line 3494
29456   *     at next location for converted output
29457 #line 3494
29458   */
29459 #line 3494
29460   long i, j, ni;
29461 #line 3494
29462   float tmp[LOOPCNT];        /* in case input is misaligned */
29463 #line 3494
29464   float *xp;
29465 #line 3494
29466   int nrange = 0;         /* number of range errors */
29467 #line 3494
29468   int realign = 0;        /* "do we need to fix input data alignment?" */
29469 #line 3494
29470   long cxp = (long) *((char**)xpp);
29471 #line 3494
29472 
29473 #line 3494
29474   realign = (cxp & 7) % SIZEOF_FLOAT;
29475 #line 3494
29476   /* sjl: manually stripmine so we can limit amount of
29477 #line 3494
29478    * vector work space reserved to LOOPCNT elements. Also
29479 #line 3494
29480    * makes vectorisation easy */
29481 #line 3494
29482   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
29483 #line 3494
29484     ni=Min(nelems-j,LOOPCNT);
29485 #line 3494
29486     if (realign) {
29487 #line 3494
29488       xp = tmp;
29489 #line 3494
29490     } else {
29491 #line 3494
29492       xp = (float *) *xpp;
29493 #line 3494
29494     }
29495 #line 3494
29496    /* copy the next block */
29497 #line 3494
29498 #pragma cdir loopcnt=LOOPCNT
29499 #line 3494
29500 #pragma cdir shortloop
29501 #line 3494
29502     for (i=0; i<ni; i++) {
29503 #line 3494
29504       /* the normal case: */
29505 #line 3494
29506       xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
29507 #line 3494
29508      /* test for range errors (not always needed but do it anyway) */
29509 #line 3494
29510      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
29511 #line 3494
29512      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
29513 #line 3494
29514       nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
29515 #line 3494
29516     }
29517 #line 3494
29518    /* copy workspace back if necessary */
29519 #line 3494
29520     if (realign) {
29521 #line 3494
29522       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
29523 #line 3494
29524       xp = (float *) *xpp;
29525 #line 3494
29526     }
29527 #line 3494
29528    /* update xpp and tp */
29529 #line 3494
29530     xp += ni;
29531 #line 3494
29532     tp += ni;
29533 #line 3494
29534     *xpp = (void*)xp;
29535 #line 3494
29536   }
29537 #line 3494
29538   return nrange == 0 ? NC_NOERR : NC_ERANGE;
29539 #line 3494
29540 
29541 #line 3494
29542 #else   /* not SX */
29543 #line 3494
29544 
29545 #line 3494
29546 	char *xp = (char *) *xpp;
29547 #line 3494
29548 	int status = NC_NOERR;
29549 #line 3494
29550 
29551 #line 3494
29552 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
29553 #line 3494
29554 	{
29555 #line 3494
29556 		int lstatus = ncx_put_float_long(xp, tp, fillp);
29557 #line 3494
29558 		if (status == NC_NOERR) /* report the first encountered error */
29559 #line 3494
29560 			status = lstatus;
29561 #line 3494
29562 	}
29563 #line 3494
29564 
29565 #line 3494
29566 	*xpp = (void *)xp;
29567 #line 3494
29568 	return status;
29569 #line 3494
29570 #endif
29571 #line 3494
29572 }
29573 #line 3494
29574 
29575 int
29576 #line 3495
ncx_putn_float_double(void ** xpp,size_t nelems,const double * tp,void * fillp)29577 ncx_putn_float_double(void **xpp, size_t nelems, const double *tp, void *fillp)
29578 #line 3495
29579 {
29580 #line 3495
29581 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
29582 #line 3495
29583 
29584 #line 3495
29585  /* basic algorithm is:
29586 #line 3495
29587   *   - ensure sane alignment of output data
29588 #line 3495
29589   *   - copy (conversion happens automatically) input data
29590 #line 3495
29591   *     to output
29592 #line 3495
29593   *   - update tp to point at next unconverted input, and xpp to point
29594 #line 3495
29595   *     at next location for converted output
29596 #line 3495
29597   */
29598 #line 3495
29599   long i, j, ni;
29600 #line 3495
29601   float tmp[LOOPCNT];        /* in case input is misaligned */
29602 #line 3495
29603   float *xp;
29604 #line 3495
29605   int nrange = 0;         /* number of range errors */
29606 #line 3495
29607   int realign = 0;        /* "do we need to fix input data alignment?" */
29608 #line 3495
29609   long cxp = (long) *((char**)xpp);
29610 #line 3495
29611 
29612 #line 3495
29613   realign = (cxp & 7) % SIZEOF_FLOAT;
29614 #line 3495
29615   /* sjl: manually stripmine so we can limit amount of
29616 #line 3495
29617    * vector work space reserved to LOOPCNT elements. Also
29618 #line 3495
29619    * makes vectorisation easy */
29620 #line 3495
29621   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
29622 #line 3495
29623     ni=Min(nelems-j,LOOPCNT);
29624 #line 3495
29625     if (realign) {
29626 #line 3495
29627       xp = tmp;
29628 #line 3495
29629     } else {
29630 #line 3495
29631       xp = (float *) *xpp;
29632 #line 3495
29633     }
29634 #line 3495
29635    /* copy the next block */
29636 #line 3495
29637 #pragma cdir loopcnt=LOOPCNT
29638 #line 3495
29639 #pragma cdir shortloop
29640 #line 3495
29641     for (i=0; i<ni; i++) {
29642 #line 3495
29643       /* the normal case: */
29644 #line 3495
29645       xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
29646 #line 3495
29647      /* test for range errors (not always needed but do it anyway) */
29648 #line 3495
29649      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
29650 #line 3495
29651      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
29652 #line 3495
29653       nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
29654 #line 3495
29655     }
29656 #line 3495
29657    /* copy workspace back if necessary */
29658 #line 3495
29659     if (realign) {
29660 #line 3495
29661       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
29662 #line 3495
29663       xp = (float *) *xpp;
29664 #line 3495
29665     }
29666 #line 3495
29667    /* update xpp and tp */
29668 #line 3495
29669     xp += ni;
29670 #line 3495
29671     tp += ni;
29672 #line 3495
29673     *xpp = (void*)xp;
29674 #line 3495
29675   }
29676 #line 3495
29677   return nrange == 0 ? NC_NOERR : NC_ERANGE;
29678 #line 3495
29679 
29680 #line 3495
29681 #else   /* not SX */
29682 #line 3495
29683 
29684 #line 3495
29685 	char *xp = (char *) *xpp;
29686 #line 3495
29687 	int status = NC_NOERR;
29688 #line 3495
29689 
29690 #line 3495
29691 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
29692 #line 3495
29693 	{
29694 #line 3495
29695 		int lstatus = ncx_put_float_double(xp, tp, fillp);
29696 #line 3495
29697 		if (status == NC_NOERR) /* report the first encountered error */
29698 #line 3495
29699 			status = lstatus;
29700 #line 3495
29701 	}
29702 #line 3495
29703 
29704 #line 3495
29705 	*xpp = (void *)xp;
29706 #line 3495
29707 	return status;
29708 #line 3495
29709 #endif
29710 #line 3495
29711 }
29712 #line 3495
29713 
29714 int
29715 #line 3496
ncx_putn_float_longlong(void ** xpp,size_t nelems,const longlong * tp,void * fillp)29716 ncx_putn_float_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
29717 #line 3496
29718 {
29719 #line 3496
29720 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
29721 #line 3496
29722 
29723 #line 3496
29724  /* basic algorithm is:
29725 #line 3496
29726   *   - ensure sane alignment of output data
29727 #line 3496
29728   *   - copy (conversion happens automatically) input data
29729 #line 3496
29730   *     to output
29731 #line 3496
29732   *   - update tp to point at next unconverted input, and xpp to point
29733 #line 3496
29734   *     at next location for converted output
29735 #line 3496
29736   */
29737 #line 3496
29738   long i, j, ni;
29739 #line 3496
29740   float tmp[LOOPCNT];        /* in case input is misaligned */
29741 #line 3496
29742   float *xp;
29743 #line 3496
29744   int nrange = 0;         /* number of range errors */
29745 #line 3496
29746   int realign = 0;        /* "do we need to fix input data alignment?" */
29747 #line 3496
29748   long cxp = (long) *((char**)xpp);
29749 #line 3496
29750 
29751 #line 3496
29752   realign = (cxp & 7) % SIZEOF_FLOAT;
29753 #line 3496
29754   /* sjl: manually stripmine so we can limit amount of
29755 #line 3496
29756    * vector work space reserved to LOOPCNT elements. Also
29757 #line 3496
29758    * makes vectorisation easy */
29759 #line 3496
29760   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
29761 #line 3496
29762     ni=Min(nelems-j,LOOPCNT);
29763 #line 3496
29764     if (realign) {
29765 #line 3496
29766       xp = tmp;
29767 #line 3496
29768     } else {
29769 #line 3496
29770       xp = (float *) *xpp;
29771 #line 3496
29772     }
29773 #line 3496
29774    /* copy the next block */
29775 #line 3496
29776 #pragma cdir loopcnt=LOOPCNT
29777 #line 3496
29778 #pragma cdir shortloop
29779 #line 3496
29780     for (i=0; i<ni; i++) {
29781 #line 3496
29782       /* the normal case: */
29783 #line 3496
29784       xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
29785 #line 3496
29786      /* test for range errors (not always needed but do it anyway) */
29787 #line 3496
29788      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
29789 #line 3496
29790      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
29791 #line 3496
29792       nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
29793 #line 3496
29794     }
29795 #line 3496
29796    /* copy workspace back if necessary */
29797 #line 3496
29798     if (realign) {
29799 #line 3496
29800       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
29801 #line 3496
29802       xp = (float *) *xpp;
29803 #line 3496
29804     }
29805 #line 3496
29806    /* update xpp and tp */
29807 #line 3496
29808     xp += ni;
29809 #line 3496
29810     tp += ni;
29811 #line 3496
29812     *xpp = (void*)xp;
29813 #line 3496
29814   }
29815 #line 3496
29816   return nrange == 0 ? NC_NOERR : NC_ERANGE;
29817 #line 3496
29818 
29819 #line 3496
29820 #else   /* not SX */
29821 #line 3496
29822 
29823 #line 3496
29824 	char *xp = (char *) *xpp;
29825 #line 3496
29826 	int status = NC_NOERR;
29827 #line 3496
29828 
29829 #line 3496
29830 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
29831 #line 3496
29832 	{
29833 #line 3496
29834 		int lstatus = ncx_put_float_longlong(xp, tp, fillp);
29835 #line 3496
29836 		if (status == NC_NOERR) /* report the first encountered error */
29837 #line 3496
29838 			status = lstatus;
29839 #line 3496
29840 	}
29841 #line 3496
29842 
29843 #line 3496
29844 	*xpp = (void *)xp;
29845 #line 3496
29846 	return status;
29847 #line 3496
29848 #endif
29849 #line 3496
29850 }
29851 #line 3496
29852 
29853 int
29854 #line 3497
ncx_putn_float_uchar(void ** xpp,size_t nelems,const uchar * tp,void * fillp)29855 ncx_putn_float_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
29856 #line 3497
29857 {
29858 #line 3497
29859 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
29860 #line 3497
29861 
29862 #line 3497
29863  /* basic algorithm is:
29864 #line 3497
29865   *   - ensure sane alignment of output data
29866 #line 3497
29867   *   - copy (conversion happens automatically) input data
29868 #line 3497
29869   *     to output
29870 #line 3497
29871   *   - update tp to point at next unconverted input, and xpp to point
29872 #line 3497
29873   *     at next location for converted output
29874 #line 3497
29875   */
29876 #line 3497
29877   long i, j, ni;
29878 #line 3497
29879   float tmp[LOOPCNT];        /* in case input is misaligned */
29880 #line 3497
29881   float *xp;
29882 #line 3497
29883   int nrange = 0;         /* number of range errors */
29884 #line 3497
29885   int realign = 0;        /* "do we need to fix input data alignment?" */
29886 #line 3497
29887   long cxp = (long) *((char**)xpp);
29888 #line 3497
29889 
29890 #line 3497
29891   realign = (cxp & 7) % SIZEOF_FLOAT;
29892 #line 3497
29893   /* sjl: manually stripmine so we can limit amount of
29894 #line 3497
29895    * vector work space reserved to LOOPCNT elements. Also
29896 #line 3497
29897    * makes vectorisation easy */
29898 #line 3497
29899   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
29900 #line 3497
29901     ni=Min(nelems-j,LOOPCNT);
29902 #line 3497
29903     if (realign) {
29904 #line 3497
29905       xp = tmp;
29906 #line 3497
29907     } else {
29908 #line 3497
29909       xp = (float *) *xpp;
29910 #line 3497
29911     }
29912 #line 3497
29913    /* copy the next block */
29914 #line 3497
29915 #pragma cdir loopcnt=LOOPCNT
29916 #line 3497
29917 #pragma cdir shortloop
29918 #line 3497
29919     for (i=0; i<ni; i++) {
29920 #line 3497
29921       /* the normal case: */
29922 #line 3497
29923       xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
29924 #line 3497
29925      /* test for range errors (not always needed but do it anyway) */
29926 #line 3497
29927      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
29928 #line 3497
29929      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
29930 #line 3497
29931       nrange += tp[i] > X_FLOAT_MAX ;
29932 #line 3497
29933     }
29934 #line 3497
29935    /* copy workspace back if necessary */
29936 #line 3497
29937     if (realign) {
29938 #line 3497
29939       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
29940 #line 3497
29941       xp = (float *) *xpp;
29942 #line 3497
29943     }
29944 #line 3497
29945    /* update xpp and tp */
29946 #line 3497
29947     xp += ni;
29948 #line 3497
29949     tp += ni;
29950 #line 3497
29951     *xpp = (void*)xp;
29952 #line 3497
29953   }
29954 #line 3497
29955   return nrange == 0 ? NC_NOERR : NC_ERANGE;
29956 #line 3497
29957 
29958 #line 3497
29959 #else   /* not SX */
29960 #line 3497
29961 
29962 #line 3497
29963 	char *xp = (char *) *xpp;
29964 #line 3497
29965 	int status = NC_NOERR;
29966 #line 3497
29967 
29968 #line 3497
29969 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
29970 #line 3497
29971 	{
29972 #line 3497
29973 		int lstatus = ncx_put_float_uchar(xp, tp, fillp);
29974 #line 3497
29975 		if (status == NC_NOERR) /* report the first encountered error */
29976 #line 3497
29977 			status = lstatus;
29978 #line 3497
29979 	}
29980 #line 3497
29981 
29982 #line 3497
29983 	*xpp = (void *)xp;
29984 #line 3497
29985 	return status;
29986 #line 3497
29987 #endif
29988 #line 3497
29989 }
29990 #line 3497
29991 
29992 int
29993 #line 3498
ncx_putn_float_ushort(void ** xpp,size_t nelems,const ushort * tp,void * fillp)29994 ncx_putn_float_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
29995 #line 3498
29996 {
29997 #line 3498
29998 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
29999 #line 3498
30000 
30001 #line 3498
30002  /* basic algorithm is:
30003 #line 3498
30004   *   - ensure sane alignment of output data
30005 #line 3498
30006   *   - copy (conversion happens automatically) input data
30007 #line 3498
30008   *     to output
30009 #line 3498
30010   *   - update tp to point at next unconverted input, and xpp to point
30011 #line 3498
30012   *     at next location for converted output
30013 #line 3498
30014   */
30015 #line 3498
30016   long i, j, ni;
30017 #line 3498
30018   float tmp[LOOPCNT];        /* in case input is misaligned */
30019 #line 3498
30020   float *xp;
30021 #line 3498
30022   int nrange = 0;         /* number of range errors */
30023 #line 3498
30024   int realign = 0;        /* "do we need to fix input data alignment?" */
30025 #line 3498
30026   long cxp = (long) *((char**)xpp);
30027 #line 3498
30028 
30029 #line 3498
30030   realign = (cxp & 7) % SIZEOF_FLOAT;
30031 #line 3498
30032   /* sjl: manually stripmine so we can limit amount of
30033 #line 3498
30034    * vector work space reserved to LOOPCNT elements. Also
30035 #line 3498
30036    * makes vectorisation easy */
30037 #line 3498
30038   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
30039 #line 3498
30040     ni=Min(nelems-j,LOOPCNT);
30041 #line 3498
30042     if (realign) {
30043 #line 3498
30044       xp = tmp;
30045 #line 3498
30046     } else {
30047 #line 3498
30048       xp = (float *) *xpp;
30049 #line 3498
30050     }
30051 #line 3498
30052    /* copy the next block */
30053 #line 3498
30054 #pragma cdir loopcnt=LOOPCNT
30055 #line 3498
30056 #pragma cdir shortloop
30057 #line 3498
30058     for (i=0; i<ni; i++) {
30059 #line 3498
30060       /* the normal case: */
30061 #line 3498
30062       xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
30063 #line 3498
30064      /* test for range errors (not always needed but do it anyway) */
30065 #line 3498
30066      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
30067 #line 3498
30068      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
30069 #line 3498
30070       nrange += tp[i] > X_FLOAT_MAX ;
30071 #line 3498
30072     }
30073 #line 3498
30074    /* copy workspace back if necessary */
30075 #line 3498
30076     if (realign) {
30077 #line 3498
30078       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
30079 #line 3498
30080       xp = (float *) *xpp;
30081 #line 3498
30082     }
30083 #line 3498
30084    /* update xpp and tp */
30085 #line 3498
30086     xp += ni;
30087 #line 3498
30088     tp += ni;
30089 #line 3498
30090     *xpp = (void*)xp;
30091 #line 3498
30092   }
30093 #line 3498
30094   return nrange == 0 ? NC_NOERR : NC_ERANGE;
30095 #line 3498
30096 
30097 #line 3498
30098 #else   /* not SX */
30099 #line 3498
30100 
30101 #line 3498
30102 	char *xp = (char *) *xpp;
30103 #line 3498
30104 	int status = NC_NOERR;
30105 #line 3498
30106 
30107 #line 3498
30108 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
30109 #line 3498
30110 	{
30111 #line 3498
30112 		int lstatus = ncx_put_float_ushort(xp, tp, fillp);
30113 #line 3498
30114 		if (status == NC_NOERR) /* report the first encountered error */
30115 #line 3498
30116 			status = lstatus;
30117 #line 3498
30118 	}
30119 #line 3498
30120 
30121 #line 3498
30122 	*xpp = (void *)xp;
30123 #line 3498
30124 	return status;
30125 #line 3498
30126 #endif
30127 #line 3498
30128 }
30129 #line 3498
30130 
30131 int
30132 #line 3499
ncx_putn_float_uint(void ** xpp,size_t nelems,const uint * tp,void * fillp)30133 ncx_putn_float_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
30134 #line 3499
30135 {
30136 #line 3499
30137 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
30138 #line 3499
30139 
30140 #line 3499
30141  /* basic algorithm is:
30142 #line 3499
30143   *   - ensure sane alignment of output data
30144 #line 3499
30145   *   - copy (conversion happens automatically) input data
30146 #line 3499
30147   *     to output
30148 #line 3499
30149   *   - update tp to point at next unconverted input, and xpp to point
30150 #line 3499
30151   *     at next location for converted output
30152 #line 3499
30153   */
30154 #line 3499
30155   long i, j, ni;
30156 #line 3499
30157   float tmp[LOOPCNT];        /* in case input is misaligned */
30158 #line 3499
30159   float *xp;
30160 #line 3499
30161   int nrange = 0;         /* number of range errors */
30162 #line 3499
30163   int realign = 0;        /* "do we need to fix input data alignment?" */
30164 #line 3499
30165   long cxp = (long) *((char**)xpp);
30166 #line 3499
30167 
30168 #line 3499
30169   realign = (cxp & 7) % SIZEOF_FLOAT;
30170 #line 3499
30171   /* sjl: manually stripmine so we can limit amount of
30172 #line 3499
30173    * vector work space reserved to LOOPCNT elements. Also
30174 #line 3499
30175    * makes vectorisation easy */
30176 #line 3499
30177   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
30178 #line 3499
30179     ni=Min(nelems-j,LOOPCNT);
30180 #line 3499
30181     if (realign) {
30182 #line 3499
30183       xp = tmp;
30184 #line 3499
30185     } else {
30186 #line 3499
30187       xp = (float *) *xpp;
30188 #line 3499
30189     }
30190 #line 3499
30191    /* copy the next block */
30192 #line 3499
30193 #pragma cdir loopcnt=LOOPCNT
30194 #line 3499
30195 #pragma cdir shortloop
30196 #line 3499
30197     for (i=0; i<ni; i++) {
30198 #line 3499
30199       /* the normal case: */
30200 #line 3499
30201       xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
30202 #line 3499
30203      /* test for range errors (not always needed but do it anyway) */
30204 #line 3499
30205      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
30206 #line 3499
30207      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
30208 #line 3499
30209       nrange += tp[i] > X_FLOAT_MAX ;
30210 #line 3499
30211     }
30212 #line 3499
30213    /* copy workspace back if necessary */
30214 #line 3499
30215     if (realign) {
30216 #line 3499
30217       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
30218 #line 3499
30219       xp = (float *) *xpp;
30220 #line 3499
30221     }
30222 #line 3499
30223    /* update xpp and tp */
30224 #line 3499
30225     xp += ni;
30226 #line 3499
30227     tp += ni;
30228 #line 3499
30229     *xpp = (void*)xp;
30230 #line 3499
30231   }
30232 #line 3499
30233   return nrange == 0 ? NC_NOERR : NC_ERANGE;
30234 #line 3499
30235 
30236 #line 3499
30237 #else   /* not SX */
30238 #line 3499
30239 
30240 #line 3499
30241 	char *xp = (char *) *xpp;
30242 #line 3499
30243 	int status = NC_NOERR;
30244 #line 3499
30245 
30246 #line 3499
30247 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
30248 #line 3499
30249 	{
30250 #line 3499
30251 		int lstatus = ncx_put_float_uint(xp, tp, fillp);
30252 #line 3499
30253 		if (status == NC_NOERR) /* report the first encountered error */
30254 #line 3499
30255 			status = lstatus;
30256 #line 3499
30257 	}
30258 #line 3499
30259 
30260 #line 3499
30261 	*xpp = (void *)xp;
30262 #line 3499
30263 	return status;
30264 #line 3499
30265 #endif
30266 #line 3499
30267 }
30268 #line 3499
30269 
30270 int
30271 #line 3500
ncx_putn_float_ulonglong(void ** xpp,size_t nelems,const ulonglong * tp,void * fillp)30272 ncx_putn_float_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
30273 #line 3500
30274 {
30275 #line 3500
30276 #if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
30277 #line 3500
30278 
30279 #line 3500
30280  /* basic algorithm is:
30281 #line 3500
30282   *   - ensure sane alignment of output data
30283 #line 3500
30284   *   - copy (conversion happens automatically) input data
30285 #line 3500
30286   *     to output
30287 #line 3500
30288   *   - update tp to point at next unconverted input, and xpp to point
30289 #line 3500
30290   *     at next location for converted output
30291 #line 3500
30292   */
30293 #line 3500
30294   long i, j, ni;
30295 #line 3500
30296   float tmp[LOOPCNT];        /* in case input is misaligned */
30297 #line 3500
30298   float *xp;
30299 #line 3500
30300   int nrange = 0;         /* number of range errors */
30301 #line 3500
30302   int realign = 0;        /* "do we need to fix input data alignment?" */
30303 #line 3500
30304   long cxp = (long) *((char**)xpp);
30305 #line 3500
30306 
30307 #line 3500
30308   realign = (cxp & 7) % SIZEOF_FLOAT;
30309 #line 3500
30310   /* sjl: manually stripmine so we can limit amount of
30311 #line 3500
30312    * vector work space reserved to LOOPCNT elements. Also
30313 #line 3500
30314    * makes vectorisation easy */
30315 #line 3500
30316   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
30317 #line 3500
30318     ni=Min(nelems-j,LOOPCNT);
30319 #line 3500
30320     if (realign) {
30321 #line 3500
30322       xp = tmp;
30323 #line 3500
30324     } else {
30325 #line 3500
30326       xp = (float *) *xpp;
30327 #line 3500
30328     }
30329 #line 3500
30330    /* copy the next block */
30331 #line 3500
30332 #pragma cdir loopcnt=LOOPCNT
30333 #line 3500
30334 #pragma cdir shortloop
30335 #line 3500
30336     for (i=0; i<ni; i++) {
30337 #line 3500
30338       /* the normal case: */
30339 #line 3500
30340       xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
30341 #line 3500
30342      /* test for range errors (not always needed but do it anyway) */
30343 #line 3500
30344      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
30345 #line 3500
30346      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
30347 #line 3500
30348       nrange += tp[i] > X_FLOAT_MAX ;
30349 #line 3500
30350     }
30351 #line 3500
30352    /* copy workspace back if necessary */
30353 #line 3500
30354     if (realign) {
30355 #line 3500
30356       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
30357 #line 3500
30358       xp = (float *) *xpp;
30359 #line 3500
30360     }
30361 #line 3500
30362    /* update xpp and tp */
30363 #line 3500
30364     xp += ni;
30365 #line 3500
30366     tp += ni;
30367 #line 3500
30368     *xpp = (void*)xp;
30369 #line 3500
30370   }
30371 #line 3500
30372   return nrange == 0 ? NC_NOERR : NC_ERANGE;
30373 #line 3500
30374 
30375 #line 3500
30376 #else   /* not SX */
30377 #line 3500
30378 
30379 #line 3500
30380 	char *xp = (char *) *xpp;
30381 #line 3500
30382 	int status = NC_NOERR;
30383 #line 3500
30384 
30385 #line 3500
30386 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
30387 #line 3500
30388 	{
30389 #line 3500
30390 		int lstatus = ncx_put_float_ulonglong(xp, tp, fillp);
30391 #line 3500
30392 		if (status == NC_NOERR) /* report the first encountered error */
30393 #line 3500
30394 			status = lstatus;
30395 #line 3500
30396 	}
30397 #line 3500
30398 
30399 #line 3500
30400 	*xpp = (void *)xp;
30401 #line 3500
30402 	return status;
30403 #line 3500
30404 #endif
30405 #line 3500
30406 }
30407 #line 3500
30408 
30409 
30410 /* double --------------------------------------------------------------------*/
30411 
30412 #if X_SIZEOF_DOUBLE == SIZEOF_DOUBLE && !defined(NO_IEEE_FLOAT)
30413 /* optimized version */
30414 int
ncx_getn_double_double(const void ** xpp,size_t nelems,double * tp)30415 ncx_getn_double_double(const void **xpp, size_t nelems, double *tp)
30416 {
30417 #ifdef WORDS_BIGENDIAN
30418 	(void) memcpy(tp, *xpp, (size_t)nelems * SIZEOF_DOUBLE);
30419 # else
30420 	swapn8b(tp, *xpp, nelems);
30421 # endif
30422 	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_DOUBLE);
30423 	return NC_NOERR;
30424 }
30425 #elif defined(vax) && vax != 0
30426 int
ncx_getn_double_double(const void ** xpp,size_t ndoubles,double * ip)30427 ncx_getn_double_double(const void **xpp, size_t ndoubles, double *ip)
30428 {
30429 	double *const end = ip + ndoubles;
30430 
30431 	while (ip < end)
30432 	{
30433 	struct vax_double *const vdp =
30434 #line 3525
30435 			 (struct vax_double *)ip;
30436 #line 3525
30437 	const struct ieee_double *const idp =
30438 #line 3525
30439 			 (const struct ieee_double *) (*xpp);
30440 #line 3525
30441 	{
30442 #line 3525
30443 		const struct dbl_limits *lim;
30444 #line 3525
30445 		int ii;
30446 #line 3525
30447 		for (ii = 0, lim = dbl_limits;
30448 #line 3525
30449 			ii < sizeof(dbl_limits)/sizeof(struct dbl_limits);
30450 #line 3525
30451 			ii++, lim++)
30452 #line 3525
30453 		{
30454 #line 3525
30455 			if ((idp->mant_lo == lim->ieee.mant_lo)
30456 #line 3525
30457 				&& (idp->mant_4 == lim->ieee.mant_4)
30458 #line 3525
30459 				&& (idp->mant_5 == lim->ieee.mant_5)
30460 #line 3525
30461 				&& (idp->mant_6 == lim->ieee.mant_6)
30462 #line 3525
30463 				&& (idp->exp_lo == lim->ieee.exp_lo)
30464 #line 3525
30465 				&& (idp->exp_hi == lim->ieee.exp_hi)
30466 #line 3525
30467 				)
30468 #line 3525
30469 			{
30470 #line 3525
30471 				*vdp = lim->d;
30472 #line 3525
30473 				goto doneit;
30474 #line 3525
30475 			}
30476 #line 3525
30477 		}
30478 #line 3525
30479 	}
30480 #line 3525
30481 	{
30482 #line 3525
30483 		unsigned exp = idp->exp_hi << 4 | idp->exp_lo;
30484 #line 3525
30485 		vdp->exp = exp - IEEE_DBL_BIAS + VAX_DBL_BIAS;
30486 #line 3525
30487 	}
30488 #line 3525
30489 	{
30490 #line 3525
30491 		unsigned mant_hi = ((idp->mant_6 << 16)
30492 #line 3525
30493 				 | (idp->mant_5 << 8)
30494 #line 3525
30495 				 | idp->mant_4);
30496 #line 3525
30497 		unsigned mant_lo = SWAP4(idp->mant_lo);
30498 #line 3525
30499 		vdp->mantissa1 = (mant_hi >> 13);
30500 #line 3525
30501 		vdp->mantissa2 = ((mant_hi & MASK(13)) << 3)
30502 #line 3525
30503 				| (mant_lo >> 29);
30504 #line 3525
30505 		vdp->mantissa3 = (mant_lo >> 13);
30506 #line 3525
30507 		vdp->mantissa4 = (mant_lo << 3);
30508 #line 3525
30509 	}
30510 #line 3525
30511 	doneit:
30512 #line 3525
30513 		vdp->sign = idp->sign;
30514 #line 3525
30515 
30516 		ip++;
30517 		*xpp = (char *)(*xpp) + X_SIZEOF_DOUBLE;
30518 	}
30519 	return NC_NOERR;
30520 }
30521 	/* vax */
30522 #else
30523 int
ncx_getn_double_double(const void ** xpp,size_t nelems,double * tp)30524 ncx_getn_double_double(const void **xpp, size_t nelems, double *tp)
30525 {
30526 	const char *xp = *xpp;
30527 	int status = NC_NOERR;
30528 
30529 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
30530 	{
30531 		const int lstatus = ncx_get_double_double(xp, tp, fillp);
30532 		if (status == NC_NOERR) /* report the first encountered error */
30533 			status = lstatus;
30534 	}
30535 
30536 	*xpp = (const void *)xp;
30537 	return status;
30538 }
30539 #endif
30540 int
30541 #line 3550
ncx_getn_double_schar(const void ** xpp,size_t nelems,schar * tp)30542 ncx_getn_double_schar(const void **xpp, size_t nelems, schar *tp)
30543 #line 3550
30544 {
30545 #line 3550
30546 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
30547 #line 3550
30548 
30549 #line 3550
30550  /* basic algorithm is:
30551 #line 3550
30552   *   - ensure sane alignment of input data
30553 #line 3550
30554   *   - copy (conversion happens automatically) input data
30555 #line 3550
30556   *     to output
30557 #line 3550
30558   *   - update xpp to point at next unconverted input, and tp to point
30559 #line 3550
30560   *     at next location for converted output
30561 #line 3550
30562   */
30563 #line 3550
30564   long i, j, ni;
30565 #line 3550
30566   double tmp[LOOPCNT];        /* in case input is misaligned */
30567 #line 3550
30568   double *xp;
30569 #line 3550
30570   int nrange = 0;         /* number of range errors */
30571 #line 3550
30572   int realign = 0;        /* "do we need to fix input data alignment?" */
30573 #line 3550
30574   long cxp = (long) *((char**)xpp);
30575 #line 3550
30576 
30577 #line 3550
30578   realign = (cxp & 7) % SIZEOF_DOUBLE;
30579 #line 3550
30580   /* sjl: manually stripmine so we can limit amount of
30581 #line 3550
30582    * vector work space reserved to LOOPCNT elements. Also
30583 #line 3550
30584    * makes vectorisation easy */
30585 #line 3550
30586   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
30587 #line 3550
30588     ni=Min(nelems-j,LOOPCNT);
30589 #line 3550
30590     if (realign) {
30591 #line 3550
30592       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
30593 #line 3550
30594       xp = tmp;
30595 #line 3550
30596     } else {
30597 #line 3550
30598       xp = (double *) *xpp;
30599 #line 3550
30600     }
30601 #line 3550
30602    /* copy the next block */
30603 #line 3550
30604 #pragma cdir loopcnt=LOOPCNT
30605 #line 3550
30606 #pragma cdir shortloop
30607 #line 3550
30608     for (i=0; i<ni; i++) {
30609 #line 3550
30610       tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
30611 #line 3550
30612      /* test for range errors (not always needed but do it anyway) */
30613 #line 3550
30614      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
30615 #line 3550
30616      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
30617 #line 3550
30618       nrange += xp[i] > SCHAR_MAX || xp[i] < SCHAR_MIN;
30619 #line 3550
30620     }
30621 #line 3550
30622    /* update xpp and tp */
30623 #line 3550
30624     if (realign) xp = (double *) *xpp;
30625 #line 3550
30626     xp += ni;
30627 #line 3550
30628     tp += ni;
30629 #line 3550
30630     *xpp = (void*)xp;
30631 #line 3550
30632   }
30633 #line 3550
30634   return nrange == 0 ? NC_NOERR : NC_ERANGE;
30635 #line 3550
30636 
30637 #line 3550
30638 #else   /* not SX */
30639 #line 3550
30640 	const char *xp = (const char *) *xpp;
30641 #line 3550
30642 	int status = NC_NOERR;
30643 #line 3550
30644 
30645 #line 3550
30646 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
30647 #line 3550
30648 	{
30649 #line 3550
30650 		const int lstatus = ncx_get_double_schar(xp, tp);
30651 #line 3550
30652 		if (status == NC_NOERR) /* report the first encountered error */
30653 #line 3550
30654 			status = lstatus;
30655 #line 3550
30656 	}
30657 #line 3550
30658 
30659 #line 3550
30660 	*xpp = (const void *)xp;
30661 #line 3550
30662 	return status;
30663 #line 3550
30664 #endif
30665 #line 3550
30666 }
30667 #line 3550
30668 
30669 int
30670 #line 3551
ncx_getn_double_short(const void ** xpp,size_t nelems,short * tp)30671 ncx_getn_double_short(const void **xpp, size_t nelems, short *tp)
30672 #line 3551
30673 {
30674 #line 3551
30675 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
30676 #line 3551
30677 
30678 #line 3551
30679  /* basic algorithm is:
30680 #line 3551
30681   *   - ensure sane alignment of input data
30682 #line 3551
30683   *   - copy (conversion happens automatically) input data
30684 #line 3551
30685   *     to output
30686 #line 3551
30687   *   - update xpp to point at next unconverted input, and tp to point
30688 #line 3551
30689   *     at next location for converted output
30690 #line 3551
30691   */
30692 #line 3551
30693   long i, j, ni;
30694 #line 3551
30695   double tmp[LOOPCNT];        /* in case input is misaligned */
30696 #line 3551
30697   double *xp;
30698 #line 3551
30699   int nrange = 0;         /* number of range errors */
30700 #line 3551
30701   int realign = 0;        /* "do we need to fix input data alignment?" */
30702 #line 3551
30703   long cxp = (long) *((char**)xpp);
30704 #line 3551
30705 
30706 #line 3551
30707   realign = (cxp & 7) % SIZEOF_DOUBLE;
30708 #line 3551
30709   /* sjl: manually stripmine so we can limit amount of
30710 #line 3551
30711    * vector work space reserved to LOOPCNT elements. Also
30712 #line 3551
30713    * makes vectorisation easy */
30714 #line 3551
30715   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
30716 #line 3551
30717     ni=Min(nelems-j,LOOPCNT);
30718 #line 3551
30719     if (realign) {
30720 #line 3551
30721       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
30722 #line 3551
30723       xp = tmp;
30724 #line 3551
30725     } else {
30726 #line 3551
30727       xp = (double *) *xpp;
30728 #line 3551
30729     }
30730 #line 3551
30731    /* copy the next block */
30732 #line 3551
30733 #pragma cdir loopcnt=LOOPCNT
30734 #line 3551
30735 #pragma cdir shortloop
30736 #line 3551
30737     for (i=0; i<ni; i++) {
30738 #line 3551
30739       tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
30740 #line 3551
30741      /* test for range errors (not always needed but do it anyway) */
30742 #line 3551
30743      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
30744 #line 3551
30745      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
30746 #line 3551
30747       nrange += xp[i] > SHORT_MAX || xp[i] < SHORT_MIN;
30748 #line 3551
30749     }
30750 #line 3551
30751    /* update xpp and tp */
30752 #line 3551
30753     if (realign) xp = (double *) *xpp;
30754 #line 3551
30755     xp += ni;
30756 #line 3551
30757     tp += ni;
30758 #line 3551
30759     *xpp = (void*)xp;
30760 #line 3551
30761   }
30762 #line 3551
30763   return nrange == 0 ? NC_NOERR : NC_ERANGE;
30764 #line 3551
30765 
30766 #line 3551
30767 #else   /* not SX */
30768 #line 3551
30769 	const char *xp = (const char *) *xpp;
30770 #line 3551
30771 	int status = NC_NOERR;
30772 #line 3551
30773 
30774 #line 3551
30775 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
30776 #line 3551
30777 	{
30778 #line 3551
30779 		const int lstatus = ncx_get_double_short(xp, tp);
30780 #line 3551
30781 		if (status == NC_NOERR) /* report the first encountered error */
30782 #line 3551
30783 			status = lstatus;
30784 #line 3551
30785 	}
30786 #line 3551
30787 
30788 #line 3551
30789 	*xpp = (const void *)xp;
30790 #line 3551
30791 	return status;
30792 #line 3551
30793 #endif
30794 #line 3551
30795 }
30796 #line 3551
30797 
30798 int
30799 #line 3552
ncx_getn_double_int(const void ** xpp,size_t nelems,int * tp)30800 ncx_getn_double_int(const void **xpp, size_t nelems, int *tp)
30801 #line 3552
30802 {
30803 #line 3552
30804 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
30805 #line 3552
30806 
30807 #line 3552
30808  /* basic algorithm is:
30809 #line 3552
30810   *   - ensure sane alignment of input data
30811 #line 3552
30812   *   - copy (conversion happens automatically) input data
30813 #line 3552
30814   *     to output
30815 #line 3552
30816   *   - update xpp to point at next unconverted input, and tp to point
30817 #line 3552
30818   *     at next location for converted output
30819 #line 3552
30820   */
30821 #line 3552
30822   long i, j, ni;
30823 #line 3552
30824   double tmp[LOOPCNT];        /* in case input is misaligned */
30825 #line 3552
30826   double *xp;
30827 #line 3552
30828   int nrange = 0;         /* number of range errors */
30829 #line 3552
30830   int realign = 0;        /* "do we need to fix input data alignment?" */
30831 #line 3552
30832   long cxp = (long) *((char**)xpp);
30833 #line 3552
30834 
30835 #line 3552
30836   realign = (cxp & 7) % SIZEOF_DOUBLE;
30837 #line 3552
30838   /* sjl: manually stripmine so we can limit amount of
30839 #line 3552
30840    * vector work space reserved to LOOPCNT elements. Also
30841 #line 3552
30842    * makes vectorisation easy */
30843 #line 3552
30844   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
30845 #line 3552
30846     ni=Min(nelems-j,LOOPCNT);
30847 #line 3552
30848     if (realign) {
30849 #line 3552
30850       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
30851 #line 3552
30852       xp = tmp;
30853 #line 3552
30854     } else {
30855 #line 3552
30856       xp = (double *) *xpp;
30857 #line 3552
30858     }
30859 #line 3552
30860    /* copy the next block */
30861 #line 3552
30862 #pragma cdir loopcnt=LOOPCNT
30863 #line 3552
30864 #pragma cdir shortloop
30865 #line 3552
30866     for (i=0; i<ni; i++) {
30867 #line 3552
30868       tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
30869 #line 3552
30870      /* test for range errors (not always needed but do it anyway) */
30871 #line 3552
30872      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
30873 #line 3552
30874      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
30875 #line 3552
30876       nrange += xp[i] > INT_MAX || xp[i] < INT_MIN;
30877 #line 3552
30878     }
30879 #line 3552
30880    /* update xpp and tp */
30881 #line 3552
30882     if (realign) xp = (double *) *xpp;
30883 #line 3552
30884     xp += ni;
30885 #line 3552
30886     tp += ni;
30887 #line 3552
30888     *xpp = (void*)xp;
30889 #line 3552
30890   }
30891 #line 3552
30892   return nrange == 0 ? NC_NOERR : NC_ERANGE;
30893 #line 3552
30894 
30895 #line 3552
30896 #else   /* not SX */
30897 #line 3552
30898 	const char *xp = (const char *) *xpp;
30899 #line 3552
30900 	int status = NC_NOERR;
30901 #line 3552
30902 
30903 #line 3552
30904 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
30905 #line 3552
30906 	{
30907 #line 3552
30908 		const int lstatus = ncx_get_double_int(xp, tp);
30909 #line 3552
30910 		if (status == NC_NOERR) /* report the first encountered error */
30911 #line 3552
30912 			status = lstatus;
30913 #line 3552
30914 	}
30915 #line 3552
30916 
30917 #line 3552
30918 	*xpp = (const void *)xp;
30919 #line 3552
30920 	return status;
30921 #line 3552
30922 #endif
30923 #line 3552
30924 }
30925 #line 3552
30926 
30927 int
30928 #line 3553
ncx_getn_double_long(const void ** xpp,size_t nelems,long * tp)30929 ncx_getn_double_long(const void **xpp, size_t nelems, long *tp)
30930 #line 3553
30931 {
30932 #line 3553
30933 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
30934 #line 3553
30935 
30936 #line 3553
30937  /* basic algorithm is:
30938 #line 3553
30939   *   - ensure sane alignment of input data
30940 #line 3553
30941   *   - copy (conversion happens automatically) input data
30942 #line 3553
30943   *     to output
30944 #line 3553
30945   *   - update xpp to point at next unconverted input, and tp to point
30946 #line 3553
30947   *     at next location for converted output
30948 #line 3553
30949   */
30950 #line 3553
30951   long i, j, ni;
30952 #line 3553
30953   double tmp[LOOPCNT];        /* in case input is misaligned */
30954 #line 3553
30955   double *xp;
30956 #line 3553
30957   int nrange = 0;         /* number of range errors */
30958 #line 3553
30959   int realign = 0;        /* "do we need to fix input data alignment?" */
30960 #line 3553
30961   long cxp = (long) *((char**)xpp);
30962 #line 3553
30963 
30964 #line 3553
30965   realign = (cxp & 7) % SIZEOF_DOUBLE;
30966 #line 3553
30967   /* sjl: manually stripmine so we can limit amount of
30968 #line 3553
30969    * vector work space reserved to LOOPCNT elements. Also
30970 #line 3553
30971    * makes vectorisation easy */
30972 #line 3553
30973   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
30974 #line 3553
30975     ni=Min(nelems-j,LOOPCNT);
30976 #line 3553
30977     if (realign) {
30978 #line 3553
30979       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
30980 #line 3553
30981       xp = tmp;
30982 #line 3553
30983     } else {
30984 #line 3553
30985       xp = (double *) *xpp;
30986 #line 3553
30987     }
30988 #line 3553
30989    /* copy the next block */
30990 #line 3553
30991 #pragma cdir loopcnt=LOOPCNT
30992 #line 3553
30993 #pragma cdir shortloop
30994 #line 3553
30995     for (i=0; i<ni; i++) {
30996 #line 3553
30997       tp[i] = (long) Max( LONG_MIN, Min(LONG_MAX, (long) xp[i]));
30998 #line 3553
30999      /* test for range errors (not always needed but do it anyway) */
31000 #line 3553
31001      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
31002 #line 3553
31003      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
31004 #line 3553
31005       nrange += xp[i] > LONG_MAX || xp[i] < LONG_MIN;
31006 #line 3553
31007     }
31008 #line 3553
31009    /* update xpp and tp */
31010 #line 3553
31011     if (realign) xp = (double *) *xpp;
31012 #line 3553
31013     xp += ni;
31014 #line 3553
31015     tp += ni;
31016 #line 3553
31017     *xpp = (void*)xp;
31018 #line 3553
31019   }
31020 #line 3553
31021   return nrange == 0 ? NC_NOERR : NC_ERANGE;
31022 #line 3553
31023 
31024 #line 3553
31025 #else   /* not SX */
31026 #line 3553
31027 	const char *xp = (const char *) *xpp;
31028 #line 3553
31029 	int status = NC_NOERR;
31030 #line 3553
31031 
31032 #line 3553
31033 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
31034 #line 3553
31035 	{
31036 #line 3553
31037 		const int lstatus = ncx_get_double_long(xp, tp);
31038 #line 3553
31039 		if (status == NC_NOERR) /* report the first encountered error */
31040 #line 3553
31041 			status = lstatus;
31042 #line 3553
31043 	}
31044 #line 3553
31045 
31046 #line 3553
31047 	*xpp = (const void *)xp;
31048 #line 3553
31049 	return status;
31050 #line 3553
31051 #endif
31052 #line 3553
31053 }
31054 #line 3553
31055 
31056 int
31057 #line 3554
ncx_getn_double_float(const void ** xpp,size_t nelems,float * tp)31058 ncx_getn_double_float(const void **xpp, size_t nelems, float *tp)
31059 #line 3554
31060 {
31061 #line 3554
31062 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
31063 #line 3554
31064 
31065 #line 3554
31066  /* basic algorithm is:
31067 #line 3554
31068   *   - ensure sane alignment of input data
31069 #line 3554
31070   *   - copy (conversion happens automatically) input data
31071 #line 3554
31072   *     to output
31073 #line 3554
31074   *   - update xpp to point at next unconverted input, and tp to point
31075 #line 3554
31076   *     at next location for converted output
31077 #line 3554
31078   */
31079 #line 3554
31080   long i, j, ni;
31081 #line 3554
31082   double tmp[LOOPCNT];        /* in case input is misaligned */
31083 #line 3554
31084   double *xp;
31085 #line 3554
31086   int nrange = 0;         /* number of range errors */
31087 #line 3554
31088   int realign = 0;        /* "do we need to fix input data alignment?" */
31089 #line 3554
31090   long cxp = (long) *((char**)xpp);
31091 #line 3554
31092 
31093 #line 3554
31094   realign = (cxp & 7) % SIZEOF_DOUBLE;
31095 #line 3554
31096   /* sjl: manually stripmine so we can limit amount of
31097 #line 3554
31098    * vector work space reserved to LOOPCNT elements. Also
31099 #line 3554
31100    * makes vectorisation easy */
31101 #line 3554
31102   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
31103 #line 3554
31104     ni=Min(nelems-j,LOOPCNT);
31105 #line 3554
31106     if (realign) {
31107 #line 3554
31108       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
31109 #line 3554
31110       xp = tmp;
31111 #line 3554
31112     } else {
31113 #line 3554
31114       xp = (double *) *xpp;
31115 #line 3554
31116     }
31117 #line 3554
31118    /* copy the next block */
31119 #line 3554
31120 #pragma cdir loopcnt=LOOPCNT
31121 #line 3554
31122 #pragma cdir shortloop
31123 #line 3554
31124     for (i=0; i<ni; i++) {
31125 #line 3554
31126       tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
31127 #line 3554
31128      /* test for range errors (not always needed but do it anyway) */
31129 #line 3554
31130      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
31131 #line 3554
31132      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
31133 #line 3554
31134       nrange += xp[i] > FLOAT_MAX || xp[i] < FLOAT_MIN;
31135 #line 3554
31136     }
31137 #line 3554
31138    /* update xpp and tp */
31139 #line 3554
31140     if (realign) xp = (double *) *xpp;
31141 #line 3554
31142     xp += ni;
31143 #line 3554
31144     tp += ni;
31145 #line 3554
31146     *xpp = (void*)xp;
31147 #line 3554
31148   }
31149 #line 3554
31150   return nrange == 0 ? NC_NOERR : NC_ERANGE;
31151 #line 3554
31152 
31153 #line 3554
31154 #else   /* not SX */
31155 #line 3554
31156 	const char *xp = (const char *) *xpp;
31157 #line 3554
31158 	int status = NC_NOERR;
31159 #line 3554
31160 
31161 #line 3554
31162 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
31163 #line 3554
31164 	{
31165 #line 3554
31166 		const int lstatus = ncx_get_double_float(xp, tp);
31167 #line 3554
31168 		if (status == NC_NOERR) /* report the first encountered error */
31169 #line 3554
31170 			status = lstatus;
31171 #line 3554
31172 	}
31173 #line 3554
31174 
31175 #line 3554
31176 	*xpp = (const void *)xp;
31177 #line 3554
31178 	return status;
31179 #line 3554
31180 #endif
31181 #line 3554
31182 }
31183 #line 3554
31184 
31185 int
31186 #line 3555
ncx_getn_double_longlong(const void ** xpp,size_t nelems,longlong * tp)31187 ncx_getn_double_longlong(const void **xpp, size_t nelems, longlong *tp)
31188 #line 3555
31189 {
31190 #line 3555
31191 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
31192 #line 3555
31193 
31194 #line 3555
31195  /* basic algorithm is:
31196 #line 3555
31197   *   - ensure sane alignment of input data
31198 #line 3555
31199   *   - copy (conversion happens automatically) input data
31200 #line 3555
31201   *     to output
31202 #line 3555
31203   *   - update xpp to point at next unconverted input, and tp to point
31204 #line 3555
31205   *     at next location for converted output
31206 #line 3555
31207   */
31208 #line 3555
31209   long i, j, ni;
31210 #line 3555
31211   double tmp[LOOPCNT];        /* in case input is misaligned */
31212 #line 3555
31213   double *xp;
31214 #line 3555
31215   int nrange = 0;         /* number of range errors */
31216 #line 3555
31217   int realign = 0;        /* "do we need to fix input data alignment?" */
31218 #line 3555
31219   long cxp = (long) *((char**)xpp);
31220 #line 3555
31221 
31222 #line 3555
31223   realign = (cxp & 7) % SIZEOF_DOUBLE;
31224 #line 3555
31225   /* sjl: manually stripmine so we can limit amount of
31226 #line 3555
31227    * vector work space reserved to LOOPCNT elements. Also
31228 #line 3555
31229    * makes vectorisation easy */
31230 #line 3555
31231   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
31232 #line 3555
31233     ni=Min(nelems-j,LOOPCNT);
31234 #line 3555
31235     if (realign) {
31236 #line 3555
31237       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
31238 #line 3555
31239       xp = tmp;
31240 #line 3555
31241     } else {
31242 #line 3555
31243       xp = (double *) *xpp;
31244 #line 3555
31245     }
31246 #line 3555
31247    /* copy the next block */
31248 #line 3555
31249 #pragma cdir loopcnt=LOOPCNT
31250 #line 3555
31251 #pragma cdir shortloop
31252 #line 3555
31253     for (i=0; i<ni; i++) {
31254 #line 3555
31255       tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
31256 #line 3555
31257      /* test for range errors (not always needed but do it anyway) */
31258 #line 3555
31259      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
31260 #line 3555
31261      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
31262 #line 3555
31263       nrange += xp[i] > LONGLONG_MAX || xp[i] < LONGLONG_MIN;
31264 #line 3555
31265     }
31266 #line 3555
31267    /* update xpp and tp */
31268 #line 3555
31269     if (realign) xp = (double *) *xpp;
31270 #line 3555
31271     xp += ni;
31272 #line 3555
31273     tp += ni;
31274 #line 3555
31275     *xpp = (void*)xp;
31276 #line 3555
31277   }
31278 #line 3555
31279   return nrange == 0 ? NC_NOERR : NC_ERANGE;
31280 #line 3555
31281 
31282 #line 3555
31283 #else   /* not SX */
31284 #line 3555
31285 	const char *xp = (const char *) *xpp;
31286 #line 3555
31287 	int status = NC_NOERR;
31288 #line 3555
31289 
31290 #line 3555
31291 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
31292 #line 3555
31293 	{
31294 #line 3555
31295 		const int lstatus = ncx_get_double_longlong(xp, tp);
31296 #line 3555
31297 		if (status == NC_NOERR) /* report the first encountered error */
31298 #line 3555
31299 			status = lstatus;
31300 #line 3555
31301 	}
31302 #line 3555
31303 
31304 #line 3555
31305 	*xpp = (const void *)xp;
31306 #line 3555
31307 	return status;
31308 #line 3555
31309 #endif
31310 #line 3555
31311 }
31312 #line 3555
31313 
31314 int
31315 #line 3556
ncx_getn_double_uchar(const void ** xpp,size_t nelems,uchar * tp)31316 ncx_getn_double_uchar(const void **xpp, size_t nelems, uchar *tp)
31317 #line 3556
31318 {
31319 #line 3556
31320 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
31321 #line 3556
31322 
31323 #line 3556
31324  /* basic algorithm is:
31325 #line 3556
31326   *   - ensure sane alignment of input data
31327 #line 3556
31328   *   - copy (conversion happens automatically) input data
31329 #line 3556
31330   *     to output
31331 #line 3556
31332   *   - update xpp to point at next unconverted input, and tp to point
31333 #line 3556
31334   *     at next location for converted output
31335 #line 3556
31336   */
31337 #line 3556
31338   long i, j, ni;
31339 #line 3556
31340   double tmp[LOOPCNT];        /* in case input is misaligned */
31341 #line 3556
31342   double *xp;
31343 #line 3556
31344   int nrange = 0;         /* number of range errors */
31345 #line 3556
31346   int realign = 0;        /* "do we need to fix input data alignment?" */
31347 #line 3556
31348   long cxp = (long) *((char**)xpp);
31349 #line 3556
31350 
31351 #line 3556
31352   realign = (cxp & 7) % SIZEOF_DOUBLE;
31353 #line 3556
31354   /* sjl: manually stripmine so we can limit amount of
31355 #line 3556
31356    * vector work space reserved to LOOPCNT elements. Also
31357 #line 3556
31358    * makes vectorisation easy */
31359 #line 3556
31360   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
31361 #line 3556
31362     ni=Min(nelems-j,LOOPCNT);
31363 #line 3556
31364     if (realign) {
31365 #line 3556
31366       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
31367 #line 3556
31368       xp = tmp;
31369 #line 3556
31370     } else {
31371 #line 3556
31372       xp = (double *) *xpp;
31373 #line 3556
31374     }
31375 #line 3556
31376    /* copy the next block */
31377 #line 3556
31378 #pragma cdir loopcnt=LOOPCNT
31379 #line 3556
31380 #pragma cdir shortloop
31381 #line 3556
31382     for (i=0; i<ni; i++) {
31383 #line 3556
31384       tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
31385 #line 3556
31386      /* test for range errors (not always needed but do it anyway) */
31387 #line 3556
31388      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
31389 #line 3556
31390      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
31391 #line 3556
31392       nrange += xp[i] > UCHAR_MAX || xp[i] < 0;
31393 #line 3556
31394     }
31395 #line 3556
31396    /* update xpp and tp */
31397 #line 3556
31398     if (realign) xp = (double *) *xpp;
31399 #line 3556
31400     xp += ni;
31401 #line 3556
31402     tp += ni;
31403 #line 3556
31404     *xpp = (void*)xp;
31405 #line 3556
31406   }
31407 #line 3556
31408   return nrange == 0 ? NC_NOERR : NC_ERANGE;
31409 #line 3556
31410 
31411 #line 3556
31412 #else   /* not SX */
31413 #line 3556
31414 	const char *xp = (const char *) *xpp;
31415 #line 3556
31416 	int status = NC_NOERR;
31417 #line 3556
31418 
31419 #line 3556
31420 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
31421 #line 3556
31422 	{
31423 #line 3556
31424 		const int lstatus = ncx_get_double_uchar(xp, tp);
31425 #line 3556
31426 		if (status == NC_NOERR) /* report the first encountered error */
31427 #line 3556
31428 			status = lstatus;
31429 #line 3556
31430 	}
31431 #line 3556
31432 
31433 #line 3556
31434 	*xpp = (const void *)xp;
31435 #line 3556
31436 	return status;
31437 #line 3556
31438 #endif
31439 #line 3556
31440 }
31441 #line 3556
31442 
31443 int
31444 #line 3557
ncx_getn_double_ushort(const void ** xpp,size_t nelems,ushort * tp)31445 ncx_getn_double_ushort(const void **xpp, size_t nelems, ushort *tp)
31446 #line 3557
31447 {
31448 #line 3557
31449 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
31450 #line 3557
31451 
31452 #line 3557
31453  /* basic algorithm is:
31454 #line 3557
31455   *   - ensure sane alignment of input data
31456 #line 3557
31457   *   - copy (conversion happens automatically) input data
31458 #line 3557
31459   *     to output
31460 #line 3557
31461   *   - update xpp to point at next unconverted input, and tp to point
31462 #line 3557
31463   *     at next location for converted output
31464 #line 3557
31465   */
31466 #line 3557
31467   long i, j, ni;
31468 #line 3557
31469   double tmp[LOOPCNT];        /* in case input is misaligned */
31470 #line 3557
31471   double *xp;
31472 #line 3557
31473   int nrange = 0;         /* number of range errors */
31474 #line 3557
31475   int realign = 0;        /* "do we need to fix input data alignment?" */
31476 #line 3557
31477   long cxp = (long) *((char**)xpp);
31478 #line 3557
31479 
31480 #line 3557
31481   realign = (cxp & 7) % SIZEOF_DOUBLE;
31482 #line 3557
31483   /* sjl: manually stripmine so we can limit amount of
31484 #line 3557
31485    * vector work space reserved to LOOPCNT elements. Also
31486 #line 3557
31487    * makes vectorisation easy */
31488 #line 3557
31489   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
31490 #line 3557
31491     ni=Min(nelems-j,LOOPCNT);
31492 #line 3557
31493     if (realign) {
31494 #line 3557
31495       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
31496 #line 3557
31497       xp = tmp;
31498 #line 3557
31499     } else {
31500 #line 3557
31501       xp = (double *) *xpp;
31502 #line 3557
31503     }
31504 #line 3557
31505    /* copy the next block */
31506 #line 3557
31507 #pragma cdir loopcnt=LOOPCNT
31508 #line 3557
31509 #pragma cdir shortloop
31510 #line 3557
31511     for (i=0; i<ni; i++) {
31512 #line 3557
31513       tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
31514 #line 3557
31515      /* test for range errors (not always needed but do it anyway) */
31516 #line 3557
31517      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
31518 #line 3557
31519      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
31520 #line 3557
31521       nrange += xp[i] > USHORT_MAX || xp[i] < 0;
31522 #line 3557
31523     }
31524 #line 3557
31525    /* update xpp and tp */
31526 #line 3557
31527     if (realign) xp = (double *) *xpp;
31528 #line 3557
31529     xp += ni;
31530 #line 3557
31531     tp += ni;
31532 #line 3557
31533     *xpp = (void*)xp;
31534 #line 3557
31535   }
31536 #line 3557
31537   return nrange == 0 ? NC_NOERR : NC_ERANGE;
31538 #line 3557
31539 
31540 #line 3557
31541 #else   /* not SX */
31542 #line 3557
31543 	const char *xp = (const char *) *xpp;
31544 #line 3557
31545 	int status = NC_NOERR;
31546 #line 3557
31547 
31548 #line 3557
31549 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
31550 #line 3557
31551 	{
31552 #line 3557
31553 		const int lstatus = ncx_get_double_ushort(xp, tp);
31554 #line 3557
31555 		if (status == NC_NOERR) /* report the first encountered error */
31556 #line 3557
31557 			status = lstatus;
31558 #line 3557
31559 	}
31560 #line 3557
31561 
31562 #line 3557
31563 	*xpp = (const void *)xp;
31564 #line 3557
31565 	return status;
31566 #line 3557
31567 #endif
31568 #line 3557
31569 }
31570 #line 3557
31571 
31572 int
31573 #line 3558
ncx_getn_double_uint(const void ** xpp,size_t nelems,uint * tp)31574 ncx_getn_double_uint(const void **xpp, size_t nelems, uint *tp)
31575 #line 3558
31576 {
31577 #line 3558
31578 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
31579 #line 3558
31580 
31581 #line 3558
31582  /* basic algorithm is:
31583 #line 3558
31584   *   - ensure sane alignment of input data
31585 #line 3558
31586   *   - copy (conversion happens automatically) input data
31587 #line 3558
31588   *     to output
31589 #line 3558
31590   *   - update xpp to point at next unconverted input, and tp to point
31591 #line 3558
31592   *     at next location for converted output
31593 #line 3558
31594   */
31595 #line 3558
31596   long i, j, ni;
31597 #line 3558
31598   double tmp[LOOPCNT];        /* in case input is misaligned */
31599 #line 3558
31600   double *xp;
31601 #line 3558
31602   int nrange = 0;         /* number of range errors */
31603 #line 3558
31604   int realign = 0;        /* "do we need to fix input data alignment?" */
31605 #line 3558
31606   long cxp = (long) *((char**)xpp);
31607 #line 3558
31608 
31609 #line 3558
31610   realign = (cxp & 7) % SIZEOF_DOUBLE;
31611 #line 3558
31612   /* sjl: manually stripmine so we can limit amount of
31613 #line 3558
31614    * vector work space reserved to LOOPCNT elements. Also
31615 #line 3558
31616    * makes vectorisation easy */
31617 #line 3558
31618   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
31619 #line 3558
31620     ni=Min(nelems-j,LOOPCNT);
31621 #line 3558
31622     if (realign) {
31623 #line 3558
31624       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
31625 #line 3558
31626       xp = tmp;
31627 #line 3558
31628     } else {
31629 #line 3558
31630       xp = (double *) *xpp;
31631 #line 3558
31632     }
31633 #line 3558
31634    /* copy the next block */
31635 #line 3558
31636 #pragma cdir loopcnt=LOOPCNT
31637 #line 3558
31638 #pragma cdir shortloop
31639 #line 3558
31640     for (i=0; i<ni; i++) {
31641 #line 3558
31642       tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
31643 #line 3558
31644      /* test for range errors (not always needed but do it anyway) */
31645 #line 3558
31646      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
31647 #line 3558
31648      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
31649 #line 3558
31650       nrange += xp[i] > UINT_MAX || xp[i] < 0;
31651 #line 3558
31652     }
31653 #line 3558
31654    /* update xpp and tp */
31655 #line 3558
31656     if (realign) xp = (double *) *xpp;
31657 #line 3558
31658     xp += ni;
31659 #line 3558
31660     tp += ni;
31661 #line 3558
31662     *xpp = (void*)xp;
31663 #line 3558
31664   }
31665 #line 3558
31666   return nrange == 0 ? NC_NOERR : NC_ERANGE;
31667 #line 3558
31668 
31669 #line 3558
31670 #else   /* not SX */
31671 #line 3558
31672 	const char *xp = (const char *) *xpp;
31673 #line 3558
31674 	int status = NC_NOERR;
31675 #line 3558
31676 
31677 #line 3558
31678 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
31679 #line 3558
31680 	{
31681 #line 3558
31682 		const int lstatus = ncx_get_double_uint(xp, tp);
31683 #line 3558
31684 		if (status == NC_NOERR) /* report the first encountered error */
31685 #line 3558
31686 			status = lstatus;
31687 #line 3558
31688 	}
31689 #line 3558
31690 
31691 #line 3558
31692 	*xpp = (const void *)xp;
31693 #line 3558
31694 	return status;
31695 #line 3558
31696 #endif
31697 #line 3558
31698 }
31699 #line 3558
31700 
31701 int
31702 #line 3559
ncx_getn_double_ulonglong(const void ** xpp,size_t nelems,ulonglong * tp)31703 ncx_getn_double_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
31704 #line 3559
31705 {
31706 #line 3559
31707 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
31708 #line 3559
31709 
31710 #line 3559
31711  /* basic algorithm is:
31712 #line 3559
31713   *   - ensure sane alignment of input data
31714 #line 3559
31715   *   - copy (conversion happens automatically) input data
31716 #line 3559
31717   *     to output
31718 #line 3559
31719   *   - update xpp to point at next unconverted input, and tp to point
31720 #line 3559
31721   *     at next location for converted output
31722 #line 3559
31723   */
31724 #line 3559
31725   long i, j, ni;
31726 #line 3559
31727   double tmp[LOOPCNT];        /* in case input is misaligned */
31728 #line 3559
31729   double *xp;
31730 #line 3559
31731   int nrange = 0;         /* number of range errors */
31732 #line 3559
31733   int realign = 0;        /* "do we need to fix input data alignment?" */
31734 #line 3559
31735   long cxp = (long) *((char**)xpp);
31736 #line 3559
31737 
31738 #line 3559
31739   realign = (cxp & 7) % SIZEOF_DOUBLE;
31740 #line 3559
31741   /* sjl: manually stripmine so we can limit amount of
31742 #line 3559
31743    * vector work space reserved to LOOPCNT elements. Also
31744 #line 3559
31745    * makes vectorisation easy */
31746 #line 3559
31747   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
31748 #line 3559
31749     ni=Min(nelems-j,LOOPCNT);
31750 #line 3559
31751     if (realign) {
31752 #line 3559
31753       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
31754 #line 3559
31755       xp = tmp;
31756 #line 3559
31757     } else {
31758 #line 3559
31759       xp = (double *) *xpp;
31760 #line 3559
31761     }
31762 #line 3559
31763    /* copy the next block */
31764 #line 3559
31765 #pragma cdir loopcnt=LOOPCNT
31766 #line 3559
31767 #pragma cdir shortloop
31768 #line 3559
31769     for (i=0; i<ni; i++) {
31770 #line 3559
31771       tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
31772 #line 3559
31773      /* test for range errors (not always needed but do it anyway) */
31774 #line 3559
31775      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
31776 #line 3559
31777      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
31778 #line 3559
31779       nrange += xp[i] > ULONGLONG_MAX || xp[i] < 0;
31780 #line 3559
31781     }
31782 #line 3559
31783    /* update xpp and tp */
31784 #line 3559
31785     if (realign) xp = (double *) *xpp;
31786 #line 3559
31787     xp += ni;
31788 #line 3559
31789     tp += ni;
31790 #line 3559
31791     *xpp = (void*)xp;
31792 #line 3559
31793   }
31794 #line 3559
31795   return nrange == 0 ? NC_NOERR : NC_ERANGE;
31796 #line 3559
31797 
31798 #line 3559
31799 #else   /* not SX */
31800 #line 3559
31801 	const char *xp = (const char *) *xpp;
31802 #line 3559
31803 	int status = NC_NOERR;
31804 #line 3559
31805 
31806 #line 3559
31807 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
31808 #line 3559
31809 	{
31810 #line 3559
31811 		const int lstatus = ncx_get_double_ulonglong(xp, tp);
31812 #line 3559
31813 		if (status == NC_NOERR) /* report the first encountered error */
31814 #line 3559
31815 			status = lstatus;
31816 #line 3559
31817 	}
31818 #line 3559
31819 
31820 #line 3559
31821 	*xpp = (const void *)xp;
31822 #line 3559
31823 	return status;
31824 #line 3559
31825 #endif
31826 #line 3559
31827 }
31828 #line 3559
31829 
31830 
31831 #if X_SIZEOF_DOUBLE == SIZEOF_DOUBLE && !defined(NO_IEEE_FLOAT)
31832 /* optimized version */
31833 int
ncx_putn_double_double(void ** xpp,size_t nelems,const double * tp,void * fillp)31834 ncx_putn_double_double(void **xpp, size_t nelems, const double *tp, void *fillp)
31835 {
31836 #ifdef WORDS_BIGENDIAN
31837 	(void) memcpy(*xpp, tp, (size_t)nelems * X_SIZEOF_DOUBLE);
31838 # else
31839 	swapn8b(*xpp, tp, nelems);
31840 # endif
31841 	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_DOUBLE);
31842 	return NC_NOERR;
31843 }
31844 #elif defined(vax) && vax != 0
31845 int
ncx_putn_double_double(void ** xpp,size_t ndoubles,const double * ip,void * fillp)31846 ncx_putn_double_double(void **xpp, size_t ndoubles, const double *ip, void *fillp)
31847 {
31848 	const double *const end = ip + ndoubles;
31849 
31850 	while (ip < end)
31851 	{
31852 	const struct vax_double *const vdp =
31853 #line 3582
31854 			(const struct vax_double *)ip;
31855 #line 3582
31856 	struct ieee_double *const idp =
31857 #line 3582
31858 			 (struct ieee_double *) (*xpp);
31859 #line 3582
31860 
31861 #line 3582
31862 	if ((vdp->mantissa4 > (dbl_limits[0].d.mantissa4 - 3)) &&
31863 #line 3582
31864 		(vdp->mantissa3 == dbl_limits[0].d.mantissa3) &&
31865 #line 3582
31866 		(vdp->mantissa2 == dbl_limits[0].d.mantissa2) &&
31867 #line 3582
31868 		(vdp->mantissa1 == dbl_limits[0].d.mantissa1) &&
31869 #line 3582
31870 		(vdp->exp == dbl_limits[0].d.exp))
31871 #line 3582
31872 	{
31873 #line 3582
31874 		*idp = dbl_limits[0].ieee;
31875 #line 3582
31876 		goto shipit;
31877 #line 3582
31878 	}
31879 #line 3582
31880 	if ((vdp->mantissa4 == dbl_limits[1].d.mantissa4) &&
31881 #line 3582
31882 		(vdp->mantissa3 == dbl_limits[1].d.mantissa3) &&
31883 #line 3582
31884 		(vdp->mantissa2 == dbl_limits[1].d.mantissa2) &&
31885 #line 3582
31886 		(vdp->mantissa1 == dbl_limits[1].d.mantissa1) &&
31887 #line 3582
31888 		(vdp->exp == dbl_limits[1].d.exp))
31889 #line 3582
31890 	{
31891 #line 3582
31892 		*idp = dbl_limits[1].ieee;
31893 #line 3582
31894 		goto shipit;
31895 #line 3582
31896 	}
31897 #line 3582
31898 
31899 #line 3582
31900 	{
31901 #line 3582
31902 		unsigned exp = vdp->exp - VAX_DBL_BIAS + IEEE_DBL_BIAS;
31903 #line 3582
31904 
31905 #line 3582
31906 		unsigned mant_lo = ((vdp->mantissa2 & MASK(3)) << 29) |
31907 #line 3582
31908 			(vdp->mantissa3 << 13) |
31909 #line 3582
31910 			((vdp->mantissa4 >> 3) & MASK(13));
31911 #line 3582
31912 
31913 #line 3582
31914 		unsigned mant_hi = (vdp->mantissa1 << 13)
31915 #line 3582
31916 				 | (vdp->mantissa2 >> 3);
31917 #line 3582
31918 
31919 #line 3582
31920 		if ((vdp->mantissa4 & 7) > 4)
31921 #line 3582
31922 		{
31923 #line 3582
31924 			/* round up */
31925 #line 3582
31926 			mant_lo++;
31927 #line 3582
31928 			if (mant_lo == 0)
31929 #line 3582
31930 			{
31931 #line 3582
31932 				mant_hi++;
31933 #line 3582
31934 				if (mant_hi > 0xffffff)
31935 #line 3582
31936 				{
31937 #line 3582
31938 					mant_hi = 0;
31939 #line 3582
31940 					exp++;
31941 #line 3582
31942 				}
31943 #line 3582
31944 			}
31945 #line 3582
31946 		}
31947 #line 3582
31948 
31949 #line 3582
31950 		idp->mant_lo = SWAP4(mant_lo);
31951 #line 3582
31952 		idp->mant_6 = mant_hi >> 16;
31953 #line 3582
31954 		idp->mant_5 = (mant_hi & 0xff00) >> 8;
31955 #line 3582
31956 		idp->mant_4 = mant_hi;
31957 #line 3582
31958 		idp->exp_hi = exp >> 4;
31959 #line 3582
31960 		idp->exp_lo = exp;
31961 #line 3582
31962 	}
31963 #line 3582
31964 
31965 #line 3582
31966 	shipit:
31967 #line 3582
31968 		idp->sign = vdp->sign;
31969 #line 3582
31970 
31971 		ip++;
31972 		*xpp = (char *)(*xpp) + X_SIZEOF_DOUBLE;
31973 	}
31974 	return NC_NOERR;
31975 }
31976 	/* vax */
31977 #else
31978 int
ncx_putn_double_double(void ** xpp,size_t nelems,const double * tp,void * fillp)31979 ncx_putn_double_double(void **xpp, size_t nelems, const double *tp, void *fillp)
31980 {
31981 	char *xp = *xpp;
31982 	int status = NC_NOERR;
31983 
31984 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
31985 	{
31986 		int lstatus = ncx_put_double_double(xp, tp, fillp);
31987 		if (status == NC_NOERR) /* report the first encountered error */
31988 			status = lstatus;
31989 	}
31990 
31991 	*xpp = (void *)xp;
31992 	return status;
31993 }
31994 #endif
31995 int
31996 #line 3607
ncx_putn_double_schar(void ** xpp,size_t nelems,const schar * tp,void * fillp)31997 ncx_putn_double_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
31998 #line 3607
31999 {
32000 #line 3607
32001 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
32002 #line 3607
32003 
32004 #line 3607
32005  /* basic algorithm is:
32006 #line 3607
32007   *   - ensure sane alignment of output data
32008 #line 3607
32009   *   - copy (conversion happens automatically) input data
32010 #line 3607
32011   *     to output
32012 #line 3607
32013   *   - update tp to point at next unconverted input, and xpp to point
32014 #line 3607
32015   *     at next location for converted output
32016 #line 3607
32017   */
32018 #line 3607
32019   long i, j, ni;
32020 #line 3607
32021   double tmp[LOOPCNT];        /* in case input is misaligned */
32022 #line 3607
32023   double *xp;
32024 #line 3607
32025   int nrange = 0;         /* number of range errors */
32026 #line 3607
32027   int realign = 0;        /* "do we need to fix input data alignment?" */
32028 #line 3607
32029   long cxp = (long) *((char**)xpp);
32030 #line 3607
32031 
32032 #line 3607
32033   realign = (cxp & 7) % SIZEOF_DOUBLE;
32034 #line 3607
32035   /* sjl: manually stripmine so we can limit amount of
32036 #line 3607
32037    * vector work space reserved to LOOPCNT elements. Also
32038 #line 3607
32039    * makes vectorisation easy */
32040 #line 3607
32041   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
32042 #line 3607
32043     ni=Min(nelems-j,LOOPCNT);
32044 #line 3607
32045     if (realign) {
32046 #line 3607
32047       xp = tmp;
32048 #line 3607
32049     } else {
32050 #line 3607
32051       xp = (double *) *xpp;
32052 #line 3607
32053     }
32054 #line 3607
32055    /* copy the next block */
32056 #line 3607
32057 #pragma cdir loopcnt=LOOPCNT
32058 #line 3607
32059 #pragma cdir shortloop
32060 #line 3607
32061     for (i=0; i<ni; i++) {
32062 #line 3607
32063       /* the normal case: */
32064 #line 3607
32065       xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
32066 #line 3607
32067      /* test for range errors (not always needed but do it anyway) */
32068 #line 3607
32069      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
32070 #line 3607
32071      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
32072 #line 3607
32073       nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
32074 #line 3607
32075     }
32076 #line 3607
32077    /* copy workspace back if necessary */
32078 #line 3607
32079     if (realign) {
32080 #line 3607
32081       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
32082 #line 3607
32083       xp = (double *) *xpp;
32084 #line 3607
32085     }
32086 #line 3607
32087    /* update xpp and tp */
32088 #line 3607
32089     xp += ni;
32090 #line 3607
32091     tp += ni;
32092 #line 3607
32093     *xpp = (void*)xp;
32094 #line 3607
32095   }
32096 #line 3607
32097   return nrange == 0 ? NC_NOERR : NC_ERANGE;
32098 #line 3607
32099 
32100 #line 3607
32101 #else   /* not SX */
32102 #line 3607
32103 
32104 #line 3607
32105 	char *xp = (char *) *xpp;
32106 #line 3607
32107 	int status = NC_NOERR;
32108 #line 3607
32109 
32110 #line 3607
32111 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
32112 #line 3607
32113 	{
32114 #line 3607
32115 		int lstatus = ncx_put_double_schar(xp, tp, fillp);
32116 #line 3607
32117 		if (status == NC_NOERR) /* report the first encountered error */
32118 #line 3607
32119 			status = lstatus;
32120 #line 3607
32121 	}
32122 #line 3607
32123 
32124 #line 3607
32125 	*xpp = (void *)xp;
32126 #line 3607
32127 	return status;
32128 #line 3607
32129 #endif
32130 #line 3607
32131 }
32132 #line 3607
32133 
32134 int
32135 #line 3608
ncx_putn_double_short(void ** xpp,size_t nelems,const short * tp,void * fillp)32136 ncx_putn_double_short(void **xpp, size_t nelems, const short *tp, void *fillp)
32137 #line 3608
32138 {
32139 #line 3608
32140 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
32141 #line 3608
32142 
32143 #line 3608
32144  /* basic algorithm is:
32145 #line 3608
32146   *   - ensure sane alignment of output data
32147 #line 3608
32148   *   - copy (conversion happens automatically) input data
32149 #line 3608
32150   *     to output
32151 #line 3608
32152   *   - update tp to point at next unconverted input, and xpp to point
32153 #line 3608
32154   *     at next location for converted output
32155 #line 3608
32156   */
32157 #line 3608
32158   long i, j, ni;
32159 #line 3608
32160   double tmp[LOOPCNT];        /* in case input is misaligned */
32161 #line 3608
32162   double *xp;
32163 #line 3608
32164   int nrange = 0;         /* number of range errors */
32165 #line 3608
32166   int realign = 0;        /* "do we need to fix input data alignment?" */
32167 #line 3608
32168   long cxp = (long) *((char**)xpp);
32169 #line 3608
32170 
32171 #line 3608
32172   realign = (cxp & 7) % SIZEOF_DOUBLE;
32173 #line 3608
32174   /* sjl: manually stripmine so we can limit amount of
32175 #line 3608
32176    * vector work space reserved to LOOPCNT elements. Also
32177 #line 3608
32178    * makes vectorisation easy */
32179 #line 3608
32180   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
32181 #line 3608
32182     ni=Min(nelems-j,LOOPCNT);
32183 #line 3608
32184     if (realign) {
32185 #line 3608
32186       xp = tmp;
32187 #line 3608
32188     } else {
32189 #line 3608
32190       xp = (double *) *xpp;
32191 #line 3608
32192     }
32193 #line 3608
32194    /* copy the next block */
32195 #line 3608
32196 #pragma cdir loopcnt=LOOPCNT
32197 #line 3608
32198 #pragma cdir shortloop
32199 #line 3608
32200     for (i=0; i<ni; i++) {
32201 #line 3608
32202       /* the normal case: */
32203 #line 3608
32204       xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
32205 #line 3608
32206      /* test for range errors (not always needed but do it anyway) */
32207 #line 3608
32208      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
32209 #line 3608
32210      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
32211 #line 3608
32212       nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
32213 #line 3608
32214     }
32215 #line 3608
32216    /* copy workspace back if necessary */
32217 #line 3608
32218     if (realign) {
32219 #line 3608
32220       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
32221 #line 3608
32222       xp = (double *) *xpp;
32223 #line 3608
32224     }
32225 #line 3608
32226    /* update xpp and tp */
32227 #line 3608
32228     xp += ni;
32229 #line 3608
32230     tp += ni;
32231 #line 3608
32232     *xpp = (void*)xp;
32233 #line 3608
32234   }
32235 #line 3608
32236   return nrange == 0 ? NC_NOERR : NC_ERANGE;
32237 #line 3608
32238 
32239 #line 3608
32240 #else   /* not SX */
32241 #line 3608
32242 
32243 #line 3608
32244 	char *xp = (char *) *xpp;
32245 #line 3608
32246 	int status = NC_NOERR;
32247 #line 3608
32248 
32249 #line 3608
32250 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
32251 #line 3608
32252 	{
32253 #line 3608
32254 		int lstatus = ncx_put_double_short(xp, tp, fillp);
32255 #line 3608
32256 		if (status == NC_NOERR) /* report the first encountered error */
32257 #line 3608
32258 			status = lstatus;
32259 #line 3608
32260 	}
32261 #line 3608
32262 
32263 #line 3608
32264 	*xpp = (void *)xp;
32265 #line 3608
32266 	return status;
32267 #line 3608
32268 #endif
32269 #line 3608
32270 }
32271 #line 3608
32272 
32273 int
32274 #line 3609
ncx_putn_double_int(void ** xpp,size_t nelems,const int * tp,void * fillp)32275 ncx_putn_double_int(void **xpp, size_t nelems, const int *tp, void *fillp)
32276 #line 3609
32277 {
32278 #line 3609
32279 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
32280 #line 3609
32281 
32282 #line 3609
32283  /* basic algorithm is:
32284 #line 3609
32285   *   - ensure sane alignment of output data
32286 #line 3609
32287   *   - copy (conversion happens automatically) input data
32288 #line 3609
32289   *     to output
32290 #line 3609
32291   *   - update tp to point at next unconverted input, and xpp to point
32292 #line 3609
32293   *     at next location for converted output
32294 #line 3609
32295   */
32296 #line 3609
32297   long i, j, ni;
32298 #line 3609
32299   double tmp[LOOPCNT];        /* in case input is misaligned */
32300 #line 3609
32301   double *xp;
32302 #line 3609
32303   int nrange = 0;         /* number of range errors */
32304 #line 3609
32305   int realign = 0;        /* "do we need to fix input data alignment?" */
32306 #line 3609
32307   long cxp = (long) *((char**)xpp);
32308 #line 3609
32309 
32310 #line 3609
32311   realign = (cxp & 7) % SIZEOF_DOUBLE;
32312 #line 3609
32313   /* sjl: manually stripmine so we can limit amount of
32314 #line 3609
32315    * vector work space reserved to LOOPCNT elements. Also
32316 #line 3609
32317    * makes vectorisation easy */
32318 #line 3609
32319   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
32320 #line 3609
32321     ni=Min(nelems-j,LOOPCNT);
32322 #line 3609
32323     if (realign) {
32324 #line 3609
32325       xp = tmp;
32326 #line 3609
32327     } else {
32328 #line 3609
32329       xp = (double *) *xpp;
32330 #line 3609
32331     }
32332 #line 3609
32333    /* copy the next block */
32334 #line 3609
32335 #pragma cdir loopcnt=LOOPCNT
32336 #line 3609
32337 #pragma cdir shortloop
32338 #line 3609
32339     for (i=0; i<ni; i++) {
32340 #line 3609
32341       /* the normal case: */
32342 #line 3609
32343       xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
32344 #line 3609
32345      /* test for range errors (not always needed but do it anyway) */
32346 #line 3609
32347      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
32348 #line 3609
32349      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
32350 #line 3609
32351       nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
32352 #line 3609
32353     }
32354 #line 3609
32355    /* copy workspace back if necessary */
32356 #line 3609
32357     if (realign) {
32358 #line 3609
32359       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
32360 #line 3609
32361       xp = (double *) *xpp;
32362 #line 3609
32363     }
32364 #line 3609
32365    /* update xpp and tp */
32366 #line 3609
32367     xp += ni;
32368 #line 3609
32369     tp += ni;
32370 #line 3609
32371     *xpp = (void*)xp;
32372 #line 3609
32373   }
32374 #line 3609
32375   return nrange == 0 ? NC_NOERR : NC_ERANGE;
32376 #line 3609
32377 
32378 #line 3609
32379 #else   /* not SX */
32380 #line 3609
32381 
32382 #line 3609
32383 	char *xp = (char *) *xpp;
32384 #line 3609
32385 	int status = NC_NOERR;
32386 #line 3609
32387 
32388 #line 3609
32389 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
32390 #line 3609
32391 	{
32392 #line 3609
32393 		int lstatus = ncx_put_double_int(xp, tp, fillp);
32394 #line 3609
32395 		if (status == NC_NOERR) /* report the first encountered error */
32396 #line 3609
32397 			status = lstatus;
32398 #line 3609
32399 	}
32400 #line 3609
32401 
32402 #line 3609
32403 	*xpp = (void *)xp;
32404 #line 3609
32405 	return status;
32406 #line 3609
32407 #endif
32408 #line 3609
32409 }
32410 #line 3609
32411 
32412 int
32413 #line 3610
ncx_putn_double_long(void ** xpp,size_t nelems,const long * tp,void * fillp)32414 ncx_putn_double_long(void **xpp, size_t nelems, const long *tp, void *fillp)
32415 #line 3610
32416 {
32417 #line 3610
32418 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
32419 #line 3610
32420 
32421 #line 3610
32422  /* basic algorithm is:
32423 #line 3610
32424   *   - ensure sane alignment of output data
32425 #line 3610
32426   *   - copy (conversion happens automatically) input data
32427 #line 3610
32428   *     to output
32429 #line 3610
32430   *   - update tp to point at next unconverted input, and xpp to point
32431 #line 3610
32432   *     at next location for converted output
32433 #line 3610
32434   */
32435 #line 3610
32436   long i, j, ni;
32437 #line 3610
32438   double tmp[LOOPCNT];        /* in case input is misaligned */
32439 #line 3610
32440   double *xp;
32441 #line 3610
32442   int nrange = 0;         /* number of range errors */
32443 #line 3610
32444   int realign = 0;        /* "do we need to fix input data alignment?" */
32445 #line 3610
32446   long cxp = (long) *((char**)xpp);
32447 #line 3610
32448 
32449 #line 3610
32450   realign = (cxp & 7) % SIZEOF_DOUBLE;
32451 #line 3610
32452   /* sjl: manually stripmine so we can limit amount of
32453 #line 3610
32454    * vector work space reserved to LOOPCNT elements. Also
32455 #line 3610
32456    * makes vectorisation easy */
32457 #line 3610
32458   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
32459 #line 3610
32460     ni=Min(nelems-j,LOOPCNT);
32461 #line 3610
32462     if (realign) {
32463 #line 3610
32464       xp = tmp;
32465 #line 3610
32466     } else {
32467 #line 3610
32468       xp = (double *) *xpp;
32469 #line 3610
32470     }
32471 #line 3610
32472    /* copy the next block */
32473 #line 3610
32474 #pragma cdir loopcnt=LOOPCNT
32475 #line 3610
32476 #pragma cdir shortloop
32477 #line 3610
32478     for (i=0; i<ni; i++) {
32479 #line 3610
32480       /* the normal case: */
32481 #line 3610
32482       xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
32483 #line 3610
32484      /* test for range errors (not always needed but do it anyway) */
32485 #line 3610
32486      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
32487 #line 3610
32488      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
32489 #line 3610
32490       nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
32491 #line 3610
32492     }
32493 #line 3610
32494    /* copy workspace back if necessary */
32495 #line 3610
32496     if (realign) {
32497 #line 3610
32498       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
32499 #line 3610
32500       xp = (double *) *xpp;
32501 #line 3610
32502     }
32503 #line 3610
32504    /* update xpp and tp */
32505 #line 3610
32506     xp += ni;
32507 #line 3610
32508     tp += ni;
32509 #line 3610
32510     *xpp = (void*)xp;
32511 #line 3610
32512   }
32513 #line 3610
32514   return nrange == 0 ? NC_NOERR : NC_ERANGE;
32515 #line 3610
32516 
32517 #line 3610
32518 #else   /* not SX */
32519 #line 3610
32520 
32521 #line 3610
32522 	char *xp = (char *) *xpp;
32523 #line 3610
32524 	int status = NC_NOERR;
32525 #line 3610
32526 
32527 #line 3610
32528 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
32529 #line 3610
32530 	{
32531 #line 3610
32532 		int lstatus = ncx_put_double_long(xp, tp, fillp);
32533 #line 3610
32534 		if (status == NC_NOERR) /* report the first encountered error */
32535 #line 3610
32536 			status = lstatus;
32537 #line 3610
32538 	}
32539 #line 3610
32540 
32541 #line 3610
32542 	*xpp = (void *)xp;
32543 #line 3610
32544 	return status;
32545 #line 3610
32546 #endif
32547 #line 3610
32548 }
32549 #line 3610
32550 
32551 int
32552 #line 3611
ncx_putn_double_float(void ** xpp,size_t nelems,const float * tp,void * fillp)32553 ncx_putn_double_float(void **xpp, size_t nelems, const float *tp, void *fillp)
32554 #line 3611
32555 {
32556 #line 3611
32557 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
32558 #line 3611
32559 
32560 #line 3611
32561  /* basic algorithm is:
32562 #line 3611
32563   *   - ensure sane alignment of output data
32564 #line 3611
32565   *   - copy (conversion happens automatically) input data
32566 #line 3611
32567   *     to output
32568 #line 3611
32569   *   - update tp to point at next unconverted input, and xpp to point
32570 #line 3611
32571   *     at next location for converted output
32572 #line 3611
32573   */
32574 #line 3611
32575   long i, j, ni;
32576 #line 3611
32577   double tmp[LOOPCNT];        /* in case input is misaligned */
32578 #line 3611
32579   double *xp;
32580 #line 3611
32581   int nrange = 0;         /* number of range errors */
32582 #line 3611
32583   int realign = 0;        /* "do we need to fix input data alignment?" */
32584 #line 3611
32585   long cxp = (long) *((char**)xpp);
32586 #line 3611
32587 
32588 #line 3611
32589   realign = (cxp & 7) % SIZEOF_DOUBLE;
32590 #line 3611
32591   /* sjl: manually stripmine so we can limit amount of
32592 #line 3611
32593    * vector work space reserved to LOOPCNT elements. Also
32594 #line 3611
32595    * makes vectorisation easy */
32596 #line 3611
32597   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
32598 #line 3611
32599     ni=Min(nelems-j,LOOPCNT);
32600 #line 3611
32601     if (realign) {
32602 #line 3611
32603       xp = tmp;
32604 #line 3611
32605     } else {
32606 #line 3611
32607       xp = (double *) *xpp;
32608 #line 3611
32609     }
32610 #line 3611
32611    /* copy the next block */
32612 #line 3611
32613 #pragma cdir loopcnt=LOOPCNT
32614 #line 3611
32615 #pragma cdir shortloop
32616 #line 3611
32617     for (i=0; i<ni; i++) {
32618 #line 3611
32619       /* the normal case: */
32620 #line 3611
32621       xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
32622 #line 3611
32623      /* test for range errors (not always needed but do it anyway) */
32624 #line 3611
32625      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
32626 #line 3611
32627      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
32628 #line 3611
32629       nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
32630 #line 3611
32631     }
32632 #line 3611
32633    /* copy workspace back if necessary */
32634 #line 3611
32635     if (realign) {
32636 #line 3611
32637       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
32638 #line 3611
32639       xp = (double *) *xpp;
32640 #line 3611
32641     }
32642 #line 3611
32643    /* update xpp and tp */
32644 #line 3611
32645     xp += ni;
32646 #line 3611
32647     tp += ni;
32648 #line 3611
32649     *xpp = (void*)xp;
32650 #line 3611
32651   }
32652 #line 3611
32653   return nrange == 0 ? NC_NOERR : NC_ERANGE;
32654 #line 3611
32655 
32656 #line 3611
32657 #else   /* not SX */
32658 #line 3611
32659 
32660 #line 3611
32661 	char *xp = (char *) *xpp;
32662 #line 3611
32663 	int status = NC_NOERR;
32664 #line 3611
32665 
32666 #line 3611
32667 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
32668 #line 3611
32669 	{
32670 #line 3611
32671 		int lstatus = ncx_put_double_float(xp, tp, fillp);
32672 #line 3611
32673 		if (status == NC_NOERR) /* report the first encountered error */
32674 #line 3611
32675 			status = lstatus;
32676 #line 3611
32677 	}
32678 #line 3611
32679 
32680 #line 3611
32681 	*xpp = (void *)xp;
32682 #line 3611
32683 	return status;
32684 #line 3611
32685 #endif
32686 #line 3611
32687 }
32688 #line 3611
32689 
32690 int
32691 #line 3612
ncx_putn_double_longlong(void ** xpp,size_t nelems,const longlong * tp,void * fillp)32692 ncx_putn_double_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
32693 #line 3612
32694 {
32695 #line 3612
32696 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
32697 #line 3612
32698 
32699 #line 3612
32700  /* basic algorithm is:
32701 #line 3612
32702   *   - ensure sane alignment of output data
32703 #line 3612
32704   *   - copy (conversion happens automatically) input data
32705 #line 3612
32706   *     to output
32707 #line 3612
32708   *   - update tp to point at next unconverted input, and xpp to point
32709 #line 3612
32710   *     at next location for converted output
32711 #line 3612
32712   */
32713 #line 3612
32714   long i, j, ni;
32715 #line 3612
32716   double tmp[LOOPCNT];        /* in case input is misaligned */
32717 #line 3612
32718   double *xp;
32719 #line 3612
32720   int nrange = 0;         /* number of range errors */
32721 #line 3612
32722   int realign = 0;        /* "do we need to fix input data alignment?" */
32723 #line 3612
32724   long cxp = (long) *((char**)xpp);
32725 #line 3612
32726 
32727 #line 3612
32728   realign = (cxp & 7) % SIZEOF_DOUBLE;
32729 #line 3612
32730   /* sjl: manually stripmine so we can limit amount of
32731 #line 3612
32732    * vector work space reserved to LOOPCNT elements. Also
32733 #line 3612
32734    * makes vectorisation easy */
32735 #line 3612
32736   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
32737 #line 3612
32738     ni=Min(nelems-j,LOOPCNT);
32739 #line 3612
32740     if (realign) {
32741 #line 3612
32742       xp = tmp;
32743 #line 3612
32744     } else {
32745 #line 3612
32746       xp = (double *) *xpp;
32747 #line 3612
32748     }
32749 #line 3612
32750    /* copy the next block */
32751 #line 3612
32752 #pragma cdir loopcnt=LOOPCNT
32753 #line 3612
32754 #pragma cdir shortloop
32755 #line 3612
32756     for (i=0; i<ni; i++) {
32757 #line 3612
32758       /* the normal case: */
32759 #line 3612
32760       xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
32761 #line 3612
32762      /* test for range errors (not always needed but do it anyway) */
32763 #line 3612
32764      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
32765 #line 3612
32766      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
32767 #line 3612
32768       nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
32769 #line 3612
32770     }
32771 #line 3612
32772    /* copy workspace back if necessary */
32773 #line 3612
32774     if (realign) {
32775 #line 3612
32776       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
32777 #line 3612
32778       xp = (double *) *xpp;
32779 #line 3612
32780     }
32781 #line 3612
32782    /* update xpp and tp */
32783 #line 3612
32784     xp += ni;
32785 #line 3612
32786     tp += ni;
32787 #line 3612
32788     *xpp = (void*)xp;
32789 #line 3612
32790   }
32791 #line 3612
32792   return nrange == 0 ? NC_NOERR : NC_ERANGE;
32793 #line 3612
32794 
32795 #line 3612
32796 #else   /* not SX */
32797 #line 3612
32798 
32799 #line 3612
32800 	char *xp = (char *) *xpp;
32801 #line 3612
32802 	int status = NC_NOERR;
32803 #line 3612
32804 
32805 #line 3612
32806 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
32807 #line 3612
32808 	{
32809 #line 3612
32810 		int lstatus = ncx_put_double_longlong(xp, tp, fillp);
32811 #line 3612
32812 		if (status == NC_NOERR) /* report the first encountered error */
32813 #line 3612
32814 			status = lstatus;
32815 #line 3612
32816 	}
32817 #line 3612
32818 
32819 #line 3612
32820 	*xpp = (void *)xp;
32821 #line 3612
32822 	return status;
32823 #line 3612
32824 #endif
32825 #line 3612
32826 }
32827 #line 3612
32828 
32829 int
32830 #line 3613
ncx_putn_double_uchar(void ** xpp,size_t nelems,const uchar * tp,void * fillp)32831 ncx_putn_double_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
32832 #line 3613
32833 {
32834 #line 3613
32835 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
32836 #line 3613
32837 
32838 #line 3613
32839  /* basic algorithm is:
32840 #line 3613
32841   *   - ensure sane alignment of output data
32842 #line 3613
32843   *   - copy (conversion happens automatically) input data
32844 #line 3613
32845   *     to output
32846 #line 3613
32847   *   - update tp to point at next unconverted input, and xpp to point
32848 #line 3613
32849   *     at next location for converted output
32850 #line 3613
32851   */
32852 #line 3613
32853   long i, j, ni;
32854 #line 3613
32855   double tmp[LOOPCNT];        /* in case input is misaligned */
32856 #line 3613
32857   double *xp;
32858 #line 3613
32859   int nrange = 0;         /* number of range errors */
32860 #line 3613
32861   int realign = 0;        /* "do we need to fix input data alignment?" */
32862 #line 3613
32863   long cxp = (long) *((char**)xpp);
32864 #line 3613
32865 
32866 #line 3613
32867   realign = (cxp & 7) % SIZEOF_DOUBLE;
32868 #line 3613
32869   /* sjl: manually stripmine so we can limit amount of
32870 #line 3613
32871    * vector work space reserved to LOOPCNT elements. Also
32872 #line 3613
32873    * makes vectorisation easy */
32874 #line 3613
32875   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
32876 #line 3613
32877     ni=Min(nelems-j,LOOPCNT);
32878 #line 3613
32879     if (realign) {
32880 #line 3613
32881       xp = tmp;
32882 #line 3613
32883     } else {
32884 #line 3613
32885       xp = (double *) *xpp;
32886 #line 3613
32887     }
32888 #line 3613
32889    /* copy the next block */
32890 #line 3613
32891 #pragma cdir loopcnt=LOOPCNT
32892 #line 3613
32893 #pragma cdir shortloop
32894 #line 3613
32895     for (i=0; i<ni; i++) {
32896 #line 3613
32897       /* the normal case: */
32898 #line 3613
32899       xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
32900 #line 3613
32901      /* test for range errors (not always needed but do it anyway) */
32902 #line 3613
32903      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
32904 #line 3613
32905      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
32906 #line 3613
32907       nrange += tp[i] > X_DOUBLE_MAX ;
32908 #line 3613
32909     }
32910 #line 3613
32911    /* copy workspace back if necessary */
32912 #line 3613
32913     if (realign) {
32914 #line 3613
32915       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
32916 #line 3613
32917       xp = (double *) *xpp;
32918 #line 3613
32919     }
32920 #line 3613
32921    /* update xpp and tp */
32922 #line 3613
32923     xp += ni;
32924 #line 3613
32925     tp += ni;
32926 #line 3613
32927     *xpp = (void*)xp;
32928 #line 3613
32929   }
32930 #line 3613
32931   return nrange == 0 ? NC_NOERR : NC_ERANGE;
32932 #line 3613
32933 
32934 #line 3613
32935 #else   /* not SX */
32936 #line 3613
32937 
32938 #line 3613
32939 	char *xp = (char *) *xpp;
32940 #line 3613
32941 	int status = NC_NOERR;
32942 #line 3613
32943 
32944 #line 3613
32945 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
32946 #line 3613
32947 	{
32948 #line 3613
32949 		int lstatus = ncx_put_double_uchar(xp, tp, fillp);
32950 #line 3613
32951 		if (status == NC_NOERR) /* report the first encountered error */
32952 #line 3613
32953 			status = lstatus;
32954 #line 3613
32955 	}
32956 #line 3613
32957 
32958 #line 3613
32959 	*xpp = (void *)xp;
32960 #line 3613
32961 	return status;
32962 #line 3613
32963 #endif
32964 #line 3613
32965 }
32966 #line 3613
32967 
32968 int
32969 #line 3614
ncx_putn_double_ushort(void ** xpp,size_t nelems,const ushort * tp,void * fillp)32970 ncx_putn_double_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
32971 #line 3614
32972 {
32973 #line 3614
32974 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
32975 #line 3614
32976 
32977 #line 3614
32978  /* basic algorithm is:
32979 #line 3614
32980   *   - ensure sane alignment of output data
32981 #line 3614
32982   *   - copy (conversion happens automatically) input data
32983 #line 3614
32984   *     to output
32985 #line 3614
32986   *   - update tp to point at next unconverted input, and xpp to point
32987 #line 3614
32988   *     at next location for converted output
32989 #line 3614
32990   */
32991 #line 3614
32992   long i, j, ni;
32993 #line 3614
32994   double tmp[LOOPCNT];        /* in case input is misaligned */
32995 #line 3614
32996   double *xp;
32997 #line 3614
32998   int nrange = 0;         /* number of range errors */
32999 #line 3614
33000   int realign = 0;        /* "do we need to fix input data alignment?" */
33001 #line 3614
33002   long cxp = (long) *((char**)xpp);
33003 #line 3614
33004 
33005 #line 3614
33006   realign = (cxp & 7) % SIZEOF_DOUBLE;
33007 #line 3614
33008   /* sjl: manually stripmine so we can limit amount of
33009 #line 3614
33010    * vector work space reserved to LOOPCNT elements. Also
33011 #line 3614
33012    * makes vectorisation easy */
33013 #line 3614
33014   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
33015 #line 3614
33016     ni=Min(nelems-j,LOOPCNT);
33017 #line 3614
33018     if (realign) {
33019 #line 3614
33020       xp = tmp;
33021 #line 3614
33022     } else {
33023 #line 3614
33024       xp = (double *) *xpp;
33025 #line 3614
33026     }
33027 #line 3614
33028    /* copy the next block */
33029 #line 3614
33030 #pragma cdir loopcnt=LOOPCNT
33031 #line 3614
33032 #pragma cdir shortloop
33033 #line 3614
33034     for (i=0; i<ni; i++) {
33035 #line 3614
33036       /* the normal case: */
33037 #line 3614
33038       xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
33039 #line 3614
33040      /* test for range errors (not always needed but do it anyway) */
33041 #line 3614
33042      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
33043 #line 3614
33044      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
33045 #line 3614
33046       nrange += tp[i] > X_DOUBLE_MAX ;
33047 #line 3614
33048     }
33049 #line 3614
33050    /* copy workspace back if necessary */
33051 #line 3614
33052     if (realign) {
33053 #line 3614
33054       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
33055 #line 3614
33056       xp = (double *) *xpp;
33057 #line 3614
33058     }
33059 #line 3614
33060    /* update xpp and tp */
33061 #line 3614
33062     xp += ni;
33063 #line 3614
33064     tp += ni;
33065 #line 3614
33066     *xpp = (void*)xp;
33067 #line 3614
33068   }
33069 #line 3614
33070   return nrange == 0 ? NC_NOERR : NC_ERANGE;
33071 #line 3614
33072 
33073 #line 3614
33074 #else   /* not SX */
33075 #line 3614
33076 
33077 #line 3614
33078 	char *xp = (char *) *xpp;
33079 #line 3614
33080 	int status = NC_NOERR;
33081 #line 3614
33082 
33083 #line 3614
33084 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
33085 #line 3614
33086 	{
33087 #line 3614
33088 		int lstatus = ncx_put_double_ushort(xp, tp, fillp);
33089 #line 3614
33090 		if (status == NC_NOERR) /* report the first encountered error */
33091 #line 3614
33092 			status = lstatus;
33093 #line 3614
33094 	}
33095 #line 3614
33096 
33097 #line 3614
33098 	*xpp = (void *)xp;
33099 #line 3614
33100 	return status;
33101 #line 3614
33102 #endif
33103 #line 3614
33104 }
33105 #line 3614
33106 
33107 int
33108 #line 3615
ncx_putn_double_uint(void ** xpp,size_t nelems,const uint * tp,void * fillp)33109 ncx_putn_double_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
33110 #line 3615
33111 {
33112 #line 3615
33113 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
33114 #line 3615
33115 
33116 #line 3615
33117  /* basic algorithm is:
33118 #line 3615
33119   *   - ensure sane alignment of output data
33120 #line 3615
33121   *   - copy (conversion happens automatically) input data
33122 #line 3615
33123   *     to output
33124 #line 3615
33125   *   - update tp to point at next unconverted input, and xpp to point
33126 #line 3615
33127   *     at next location for converted output
33128 #line 3615
33129   */
33130 #line 3615
33131   long i, j, ni;
33132 #line 3615
33133   double tmp[LOOPCNT];        /* in case input is misaligned */
33134 #line 3615
33135   double *xp;
33136 #line 3615
33137   int nrange = 0;         /* number of range errors */
33138 #line 3615
33139   int realign = 0;        /* "do we need to fix input data alignment?" */
33140 #line 3615
33141   long cxp = (long) *((char**)xpp);
33142 #line 3615
33143 
33144 #line 3615
33145   realign = (cxp & 7) % SIZEOF_DOUBLE;
33146 #line 3615
33147   /* sjl: manually stripmine so we can limit amount of
33148 #line 3615
33149    * vector work space reserved to LOOPCNT elements. Also
33150 #line 3615
33151    * makes vectorisation easy */
33152 #line 3615
33153   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
33154 #line 3615
33155     ni=Min(nelems-j,LOOPCNT);
33156 #line 3615
33157     if (realign) {
33158 #line 3615
33159       xp = tmp;
33160 #line 3615
33161     } else {
33162 #line 3615
33163       xp = (double *) *xpp;
33164 #line 3615
33165     }
33166 #line 3615
33167    /* copy the next block */
33168 #line 3615
33169 #pragma cdir loopcnt=LOOPCNT
33170 #line 3615
33171 #pragma cdir shortloop
33172 #line 3615
33173     for (i=0; i<ni; i++) {
33174 #line 3615
33175       /* the normal case: */
33176 #line 3615
33177       xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
33178 #line 3615
33179      /* test for range errors (not always needed but do it anyway) */
33180 #line 3615
33181      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
33182 #line 3615
33183      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
33184 #line 3615
33185       nrange += tp[i] > X_DOUBLE_MAX ;
33186 #line 3615
33187     }
33188 #line 3615
33189    /* copy workspace back if necessary */
33190 #line 3615
33191     if (realign) {
33192 #line 3615
33193       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
33194 #line 3615
33195       xp = (double *) *xpp;
33196 #line 3615
33197     }
33198 #line 3615
33199    /* update xpp and tp */
33200 #line 3615
33201     xp += ni;
33202 #line 3615
33203     tp += ni;
33204 #line 3615
33205     *xpp = (void*)xp;
33206 #line 3615
33207   }
33208 #line 3615
33209   return nrange == 0 ? NC_NOERR : NC_ERANGE;
33210 #line 3615
33211 
33212 #line 3615
33213 #else   /* not SX */
33214 #line 3615
33215 
33216 #line 3615
33217 	char *xp = (char *) *xpp;
33218 #line 3615
33219 	int status = NC_NOERR;
33220 #line 3615
33221 
33222 #line 3615
33223 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
33224 #line 3615
33225 	{
33226 #line 3615
33227 		int lstatus = ncx_put_double_uint(xp, tp, fillp);
33228 #line 3615
33229 		if (status == NC_NOERR) /* report the first encountered error */
33230 #line 3615
33231 			status = lstatus;
33232 #line 3615
33233 	}
33234 #line 3615
33235 
33236 #line 3615
33237 	*xpp = (void *)xp;
33238 #line 3615
33239 	return status;
33240 #line 3615
33241 #endif
33242 #line 3615
33243 }
33244 #line 3615
33245 
33246 int
33247 #line 3616
ncx_putn_double_ulonglong(void ** xpp,size_t nelems,const ulonglong * tp,void * fillp)33248 ncx_putn_double_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
33249 #line 3616
33250 {
33251 #line 3616
33252 #if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
33253 #line 3616
33254 
33255 #line 3616
33256  /* basic algorithm is:
33257 #line 3616
33258   *   - ensure sane alignment of output data
33259 #line 3616
33260   *   - copy (conversion happens automatically) input data
33261 #line 3616
33262   *     to output
33263 #line 3616
33264   *   - update tp to point at next unconverted input, and xpp to point
33265 #line 3616
33266   *     at next location for converted output
33267 #line 3616
33268   */
33269 #line 3616
33270   long i, j, ni;
33271 #line 3616
33272   double tmp[LOOPCNT];        /* in case input is misaligned */
33273 #line 3616
33274   double *xp;
33275 #line 3616
33276   int nrange = 0;         /* number of range errors */
33277 #line 3616
33278   int realign = 0;        /* "do we need to fix input data alignment?" */
33279 #line 3616
33280   long cxp = (long) *((char**)xpp);
33281 #line 3616
33282 
33283 #line 3616
33284   realign = (cxp & 7) % SIZEOF_DOUBLE;
33285 #line 3616
33286   /* sjl: manually stripmine so we can limit amount of
33287 #line 3616
33288    * vector work space reserved to LOOPCNT elements. Also
33289 #line 3616
33290    * makes vectorisation easy */
33291 #line 3616
33292   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
33293 #line 3616
33294     ni=Min(nelems-j,LOOPCNT);
33295 #line 3616
33296     if (realign) {
33297 #line 3616
33298       xp = tmp;
33299 #line 3616
33300     } else {
33301 #line 3616
33302       xp = (double *) *xpp;
33303 #line 3616
33304     }
33305 #line 3616
33306    /* copy the next block */
33307 #line 3616
33308 #pragma cdir loopcnt=LOOPCNT
33309 #line 3616
33310 #pragma cdir shortloop
33311 #line 3616
33312     for (i=0; i<ni; i++) {
33313 #line 3616
33314       /* the normal case: */
33315 #line 3616
33316       xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
33317 #line 3616
33318      /* test for range errors (not always needed but do it anyway) */
33319 #line 3616
33320      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
33321 #line 3616
33322      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
33323 #line 3616
33324       nrange += tp[i] > X_DOUBLE_MAX ;
33325 #line 3616
33326     }
33327 #line 3616
33328    /* copy workspace back if necessary */
33329 #line 3616
33330     if (realign) {
33331 #line 3616
33332       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
33333 #line 3616
33334       xp = (double *) *xpp;
33335 #line 3616
33336     }
33337 #line 3616
33338    /* update xpp and tp */
33339 #line 3616
33340     xp += ni;
33341 #line 3616
33342     tp += ni;
33343 #line 3616
33344     *xpp = (void*)xp;
33345 #line 3616
33346   }
33347 #line 3616
33348   return nrange == 0 ? NC_NOERR : NC_ERANGE;
33349 #line 3616
33350 
33351 #line 3616
33352 #else   /* not SX */
33353 #line 3616
33354 
33355 #line 3616
33356 	char *xp = (char *) *xpp;
33357 #line 3616
33358 	int status = NC_NOERR;
33359 #line 3616
33360 
33361 #line 3616
33362 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
33363 #line 3616
33364 	{
33365 #line 3616
33366 		int lstatus = ncx_put_double_ulonglong(xp, tp, fillp);
33367 #line 3616
33368 		if (status == NC_NOERR) /* report the first encountered error */
33369 #line 3616
33370 			status = lstatus;
33371 #line 3616
33372 	}
33373 #line 3616
33374 
33375 #line 3616
33376 	*xpp = (void *)xp;
33377 #line 3616
33378 	return status;
33379 #line 3616
33380 #endif
33381 #line 3616
33382 }
33383 #line 3616
33384 
33385 
33386 
33387 /* longlong ------------------------------------------------------------------*/
33388 
33389 #if X_SIZEOF_INT64 == SIZEOF_LONGLONG
33390 /* optimized version */
33391 int
ncx_getn_longlong_longlong(const void ** xpp,size_t nelems,long long * tp)33392 ncx_getn_longlong_longlong(const void **xpp, size_t nelems, long long *tp)
33393 {
33394 #ifdef WORDS_BIGENDIAN
33395 	(void) memcpy(tp, *xpp, (size_t)nelems * SIZEOF_LONG_LONG);
33396 # else
33397 	swapn8b(tp, *xpp, nelems);
33398 # endif
33399 	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_INT64);
33400 	return NC_NOERR;
33401 }
33402 #else
33403 int
33404 #line 3635
ncx_getn_longlong_longlong(const void ** xpp,size_t nelems,longlong * tp)33405 ncx_getn_longlong_longlong(const void **xpp, size_t nelems, longlong *tp)
33406 #line 3635
33407 {
33408 #line 3635
33409 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
33410 #line 3635
33411 
33412 #line 3635
33413  /* basic algorithm is:
33414 #line 3635
33415   *   - ensure sane alignment of input data
33416 #line 3635
33417   *   - copy (conversion happens automatically) input data
33418 #line 3635
33419   *     to output
33420 #line 3635
33421   *   - update xpp to point at next unconverted input, and tp to point
33422 #line 3635
33423   *     at next location for converted output
33424 #line 3635
33425   */
33426 #line 3635
33427   long i, j, ni;
33428 #line 3635
33429   int64 tmp[LOOPCNT];        /* in case input is misaligned */
33430 #line 3635
33431   int64 *xp;
33432 #line 3635
33433   int nrange = 0;         /* number of range errors */
33434 #line 3635
33435   int realign = 0;        /* "do we need to fix input data alignment?" */
33436 #line 3635
33437   long cxp = (long) *((char**)xpp);
33438 #line 3635
33439 
33440 #line 3635
33441   realign = (cxp & 7) % SIZEOF_INT64;
33442 #line 3635
33443   /* sjl: manually stripmine so we can limit amount of
33444 #line 3635
33445    * vector work space reserved to LOOPCNT elements. Also
33446 #line 3635
33447    * makes vectorisation easy */
33448 #line 3635
33449   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
33450 #line 3635
33451     ni=Min(nelems-j,LOOPCNT);
33452 #line 3635
33453     if (realign) {
33454 #line 3635
33455       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
33456 #line 3635
33457       xp = tmp;
33458 #line 3635
33459     } else {
33460 #line 3635
33461       xp = (int64 *) *xpp;
33462 #line 3635
33463     }
33464 #line 3635
33465    /* copy the next block */
33466 #line 3635
33467 #pragma cdir loopcnt=LOOPCNT
33468 #line 3635
33469 #pragma cdir shortloop
33470 #line 3635
33471     for (i=0; i<ni; i++) {
33472 #line 3635
33473       tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
33474 #line 3635
33475      /* test for range errors (not always needed but do it anyway) */
33476 #line 3635
33477      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
33478 #line 3635
33479      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
33480 #line 3635
33481       nrange += xp[i] > LONGLONG_MAX || xp[i] < LONGLONG_MIN;
33482 #line 3635
33483     }
33484 #line 3635
33485    /* update xpp and tp */
33486 #line 3635
33487     if (realign) xp = (int64 *) *xpp;
33488 #line 3635
33489     xp += ni;
33490 #line 3635
33491     tp += ni;
33492 #line 3635
33493     *xpp = (void*)xp;
33494 #line 3635
33495   }
33496 #line 3635
33497   return nrange == 0 ? NC_NOERR : NC_ERANGE;
33498 #line 3635
33499 
33500 #line 3635
33501 #else   /* not SX */
33502 #line 3635
33503 	const char *xp = (const char *) *xpp;
33504 #line 3635
33505 	int status = NC_NOERR;
33506 #line 3635
33507 
33508 #line 3635
33509 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
33510 #line 3635
33511 	{
33512 #line 3635
33513 		const int lstatus = ncx_get_longlong_longlong(xp, tp);
33514 #line 3635
33515 		if (status == NC_NOERR) /* report the first encountered error */
33516 #line 3635
33517 			status = lstatus;
33518 #line 3635
33519 	}
33520 #line 3635
33521 
33522 #line 3635
33523 	*xpp = (const void *)xp;
33524 #line 3635
33525 	return status;
33526 #line 3635
33527 #endif
33528 #line 3635
33529 }
33530 #line 3635
33531 
33532 #endif
33533 int
33534 #line 3637
ncx_getn_longlong_schar(const void ** xpp,size_t nelems,schar * tp)33535 ncx_getn_longlong_schar(const void **xpp, size_t nelems, schar *tp)
33536 #line 3637
33537 {
33538 #line 3637
33539 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
33540 #line 3637
33541 
33542 #line 3637
33543  /* basic algorithm is:
33544 #line 3637
33545   *   - ensure sane alignment of input data
33546 #line 3637
33547   *   - copy (conversion happens automatically) input data
33548 #line 3637
33549   *     to output
33550 #line 3637
33551   *   - update xpp to point at next unconverted input, and tp to point
33552 #line 3637
33553   *     at next location for converted output
33554 #line 3637
33555   */
33556 #line 3637
33557   long i, j, ni;
33558 #line 3637
33559   int64 tmp[LOOPCNT];        /* in case input is misaligned */
33560 #line 3637
33561   int64 *xp;
33562 #line 3637
33563   int nrange = 0;         /* number of range errors */
33564 #line 3637
33565   int realign = 0;        /* "do we need to fix input data alignment?" */
33566 #line 3637
33567   long cxp = (long) *((char**)xpp);
33568 #line 3637
33569 
33570 #line 3637
33571   realign = (cxp & 7) % SIZEOF_INT64;
33572 #line 3637
33573   /* sjl: manually stripmine so we can limit amount of
33574 #line 3637
33575    * vector work space reserved to LOOPCNT elements. Also
33576 #line 3637
33577    * makes vectorisation easy */
33578 #line 3637
33579   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
33580 #line 3637
33581     ni=Min(nelems-j,LOOPCNT);
33582 #line 3637
33583     if (realign) {
33584 #line 3637
33585       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
33586 #line 3637
33587       xp = tmp;
33588 #line 3637
33589     } else {
33590 #line 3637
33591       xp = (int64 *) *xpp;
33592 #line 3637
33593     }
33594 #line 3637
33595    /* copy the next block */
33596 #line 3637
33597 #pragma cdir loopcnt=LOOPCNT
33598 #line 3637
33599 #pragma cdir shortloop
33600 #line 3637
33601     for (i=0; i<ni; i++) {
33602 #line 3637
33603       tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
33604 #line 3637
33605      /* test for range errors (not always needed but do it anyway) */
33606 #line 3637
33607      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
33608 #line 3637
33609      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
33610 #line 3637
33611       nrange += xp[i] > SCHAR_MAX || xp[i] < SCHAR_MIN;
33612 #line 3637
33613     }
33614 #line 3637
33615    /* update xpp and tp */
33616 #line 3637
33617     if (realign) xp = (int64 *) *xpp;
33618 #line 3637
33619     xp += ni;
33620 #line 3637
33621     tp += ni;
33622 #line 3637
33623     *xpp = (void*)xp;
33624 #line 3637
33625   }
33626 #line 3637
33627   return nrange == 0 ? NC_NOERR : NC_ERANGE;
33628 #line 3637
33629 
33630 #line 3637
33631 #else   /* not SX */
33632 #line 3637
33633 	const char *xp = (const char *) *xpp;
33634 #line 3637
33635 	int status = NC_NOERR;
33636 #line 3637
33637 
33638 #line 3637
33639 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
33640 #line 3637
33641 	{
33642 #line 3637
33643 		const int lstatus = ncx_get_longlong_schar(xp, tp);
33644 #line 3637
33645 		if (status == NC_NOERR) /* report the first encountered error */
33646 #line 3637
33647 			status = lstatus;
33648 #line 3637
33649 	}
33650 #line 3637
33651 
33652 #line 3637
33653 	*xpp = (const void *)xp;
33654 #line 3637
33655 	return status;
33656 #line 3637
33657 #endif
33658 #line 3637
33659 }
33660 #line 3637
33661 
33662 int
33663 #line 3638
ncx_getn_longlong_short(const void ** xpp,size_t nelems,short * tp)33664 ncx_getn_longlong_short(const void **xpp, size_t nelems, short *tp)
33665 #line 3638
33666 {
33667 #line 3638
33668 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
33669 #line 3638
33670 
33671 #line 3638
33672  /* basic algorithm is:
33673 #line 3638
33674   *   - ensure sane alignment of input data
33675 #line 3638
33676   *   - copy (conversion happens automatically) input data
33677 #line 3638
33678   *     to output
33679 #line 3638
33680   *   - update xpp to point at next unconverted input, and tp to point
33681 #line 3638
33682   *     at next location for converted output
33683 #line 3638
33684   */
33685 #line 3638
33686   long i, j, ni;
33687 #line 3638
33688   int64 tmp[LOOPCNT];        /* in case input is misaligned */
33689 #line 3638
33690   int64 *xp;
33691 #line 3638
33692   int nrange = 0;         /* number of range errors */
33693 #line 3638
33694   int realign = 0;        /* "do we need to fix input data alignment?" */
33695 #line 3638
33696   long cxp = (long) *((char**)xpp);
33697 #line 3638
33698 
33699 #line 3638
33700   realign = (cxp & 7) % SIZEOF_INT64;
33701 #line 3638
33702   /* sjl: manually stripmine so we can limit amount of
33703 #line 3638
33704    * vector work space reserved to LOOPCNT elements. Also
33705 #line 3638
33706    * makes vectorisation easy */
33707 #line 3638
33708   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
33709 #line 3638
33710     ni=Min(nelems-j,LOOPCNT);
33711 #line 3638
33712     if (realign) {
33713 #line 3638
33714       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
33715 #line 3638
33716       xp = tmp;
33717 #line 3638
33718     } else {
33719 #line 3638
33720       xp = (int64 *) *xpp;
33721 #line 3638
33722     }
33723 #line 3638
33724    /* copy the next block */
33725 #line 3638
33726 #pragma cdir loopcnt=LOOPCNT
33727 #line 3638
33728 #pragma cdir shortloop
33729 #line 3638
33730     for (i=0; i<ni; i++) {
33731 #line 3638
33732       tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
33733 #line 3638
33734      /* test for range errors (not always needed but do it anyway) */
33735 #line 3638
33736      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
33737 #line 3638
33738      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
33739 #line 3638
33740       nrange += xp[i] > SHORT_MAX || xp[i] < SHORT_MIN;
33741 #line 3638
33742     }
33743 #line 3638
33744    /* update xpp and tp */
33745 #line 3638
33746     if (realign) xp = (int64 *) *xpp;
33747 #line 3638
33748     xp += ni;
33749 #line 3638
33750     tp += ni;
33751 #line 3638
33752     *xpp = (void*)xp;
33753 #line 3638
33754   }
33755 #line 3638
33756   return nrange == 0 ? NC_NOERR : NC_ERANGE;
33757 #line 3638
33758 
33759 #line 3638
33760 #else   /* not SX */
33761 #line 3638
33762 	const char *xp = (const char *) *xpp;
33763 #line 3638
33764 	int status = NC_NOERR;
33765 #line 3638
33766 
33767 #line 3638
33768 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
33769 #line 3638
33770 	{
33771 #line 3638
33772 		const int lstatus = ncx_get_longlong_short(xp, tp);
33773 #line 3638
33774 		if (status == NC_NOERR) /* report the first encountered error */
33775 #line 3638
33776 			status = lstatus;
33777 #line 3638
33778 	}
33779 #line 3638
33780 
33781 #line 3638
33782 	*xpp = (const void *)xp;
33783 #line 3638
33784 	return status;
33785 #line 3638
33786 #endif
33787 #line 3638
33788 }
33789 #line 3638
33790 
33791 int
33792 #line 3639
ncx_getn_longlong_int(const void ** xpp,size_t nelems,int * tp)33793 ncx_getn_longlong_int(const void **xpp, size_t nelems, int *tp)
33794 #line 3639
33795 {
33796 #line 3639
33797 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
33798 #line 3639
33799 
33800 #line 3639
33801  /* basic algorithm is:
33802 #line 3639
33803   *   - ensure sane alignment of input data
33804 #line 3639
33805   *   - copy (conversion happens automatically) input data
33806 #line 3639
33807   *     to output
33808 #line 3639
33809   *   - update xpp to point at next unconverted input, and tp to point
33810 #line 3639
33811   *     at next location for converted output
33812 #line 3639
33813   */
33814 #line 3639
33815   long i, j, ni;
33816 #line 3639
33817   int64 tmp[LOOPCNT];        /* in case input is misaligned */
33818 #line 3639
33819   int64 *xp;
33820 #line 3639
33821   int nrange = 0;         /* number of range errors */
33822 #line 3639
33823   int realign = 0;        /* "do we need to fix input data alignment?" */
33824 #line 3639
33825   long cxp = (long) *((char**)xpp);
33826 #line 3639
33827 
33828 #line 3639
33829   realign = (cxp & 7) % SIZEOF_INT64;
33830 #line 3639
33831   /* sjl: manually stripmine so we can limit amount of
33832 #line 3639
33833    * vector work space reserved to LOOPCNT elements. Also
33834 #line 3639
33835    * makes vectorisation easy */
33836 #line 3639
33837   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
33838 #line 3639
33839     ni=Min(nelems-j,LOOPCNT);
33840 #line 3639
33841     if (realign) {
33842 #line 3639
33843       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
33844 #line 3639
33845       xp = tmp;
33846 #line 3639
33847     } else {
33848 #line 3639
33849       xp = (int64 *) *xpp;
33850 #line 3639
33851     }
33852 #line 3639
33853    /* copy the next block */
33854 #line 3639
33855 #pragma cdir loopcnt=LOOPCNT
33856 #line 3639
33857 #pragma cdir shortloop
33858 #line 3639
33859     for (i=0; i<ni; i++) {
33860 #line 3639
33861       tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
33862 #line 3639
33863      /* test for range errors (not always needed but do it anyway) */
33864 #line 3639
33865      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
33866 #line 3639
33867      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
33868 #line 3639
33869       nrange += xp[i] > INT_MAX || xp[i] < INT_MIN;
33870 #line 3639
33871     }
33872 #line 3639
33873    /* update xpp and tp */
33874 #line 3639
33875     if (realign) xp = (int64 *) *xpp;
33876 #line 3639
33877     xp += ni;
33878 #line 3639
33879     tp += ni;
33880 #line 3639
33881     *xpp = (void*)xp;
33882 #line 3639
33883   }
33884 #line 3639
33885   return nrange == 0 ? NC_NOERR : NC_ERANGE;
33886 #line 3639
33887 
33888 #line 3639
33889 #else   /* not SX */
33890 #line 3639
33891 	const char *xp = (const char *) *xpp;
33892 #line 3639
33893 	int status = NC_NOERR;
33894 #line 3639
33895 
33896 #line 3639
33897 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
33898 #line 3639
33899 	{
33900 #line 3639
33901 		const int lstatus = ncx_get_longlong_int(xp, tp);
33902 #line 3639
33903 		if (status == NC_NOERR) /* report the first encountered error */
33904 #line 3639
33905 			status = lstatus;
33906 #line 3639
33907 	}
33908 #line 3639
33909 
33910 #line 3639
33911 	*xpp = (const void *)xp;
33912 #line 3639
33913 	return status;
33914 #line 3639
33915 #endif
33916 #line 3639
33917 }
33918 #line 3639
33919 
33920 int
33921 #line 3640
ncx_getn_longlong_long(const void ** xpp,size_t nelems,long * tp)33922 ncx_getn_longlong_long(const void **xpp, size_t nelems, long *tp)
33923 #line 3640
33924 {
33925 #line 3640
33926 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
33927 #line 3640
33928 
33929 #line 3640
33930  /* basic algorithm is:
33931 #line 3640
33932   *   - ensure sane alignment of input data
33933 #line 3640
33934   *   - copy (conversion happens automatically) input data
33935 #line 3640
33936   *     to output
33937 #line 3640
33938   *   - update xpp to point at next unconverted input, and tp to point
33939 #line 3640
33940   *     at next location for converted output
33941 #line 3640
33942   */
33943 #line 3640
33944   long i, j, ni;
33945 #line 3640
33946   int64 tmp[LOOPCNT];        /* in case input is misaligned */
33947 #line 3640
33948   int64 *xp;
33949 #line 3640
33950   int nrange = 0;         /* number of range errors */
33951 #line 3640
33952   int realign = 0;        /* "do we need to fix input data alignment?" */
33953 #line 3640
33954   long cxp = (long) *((char**)xpp);
33955 #line 3640
33956 
33957 #line 3640
33958   realign = (cxp & 7) % SIZEOF_INT64;
33959 #line 3640
33960   /* sjl: manually stripmine so we can limit amount of
33961 #line 3640
33962    * vector work space reserved to LOOPCNT elements. Also
33963 #line 3640
33964    * makes vectorisation easy */
33965 #line 3640
33966   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
33967 #line 3640
33968     ni=Min(nelems-j,LOOPCNT);
33969 #line 3640
33970     if (realign) {
33971 #line 3640
33972       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
33973 #line 3640
33974       xp = tmp;
33975 #line 3640
33976     } else {
33977 #line 3640
33978       xp = (int64 *) *xpp;
33979 #line 3640
33980     }
33981 #line 3640
33982    /* copy the next block */
33983 #line 3640
33984 #pragma cdir loopcnt=LOOPCNT
33985 #line 3640
33986 #pragma cdir shortloop
33987 #line 3640
33988     for (i=0; i<ni; i++) {
33989 #line 3640
33990       tp[i] = (long) Max( LONG_MIN, Min(LONG_MAX, (long) xp[i]));
33991 #line 3640
33992      /* test for range errors (not always needed but do it anyway) */
33993 #line 3640
33994      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
33995 #line 3640
33996      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
33997 #line 3640
33998       nrange += xp[i] > LONG_MAX || xp[i] < LONG_MIN;
33999 #line 3640
34000     }
34001 #line 3640
34002    /* update xpp and tp */
34003 #line 3640
34004     if (realign) xp = (int64 *) *xpp;
34005 #line 3640
34006     xp += ni;
34007 #line 3640
34008     tp += ni;
34009 #line 3640
34010     *xpp = (void*)xp;
34011 #line 3640
34012   }
34013 #line 3640
34014   return nrange == 0 ? NC_NOERR : NC_ERANGE;
34015 #line 3640
34016 
34017 #line 3640
34018 #else   /* not SX */
34019 #line 3640
34020 	const char *xp = (const char *) *xpp;
34021 #line 3640
34022 	int status = NC_NOERR;
34023 #line 3640
34024 
34025 #line 3640
34026 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
34027 #line 3640
34028 	{
34029 #line 3640
34030 		const int lstatus = ncx_get_longlong_long(xp, tp);
34031 #line 3640
34032 		if (status == NC_NOERR) /* report the first encountered error */
34033 #line 3640
34034 			status = lstatus;
34035 #line 3640
34036 	}
34037 #line 3640
34038 
34039 #line 3640
34040 	*xpp = (const void *)xp;
34041 #line 3640
34042 	return status;
34043 #line 3640
34044 #endif
34045 #line 3640
34046 }
34047 #line 3640
34048 
34049 int
34050 #line 3641
ncx_getn_longlong_float(const void ** xpp,size_t nelems,float * tp)34051 ncx_getn_longlong_float(const void **xpp, size_t nelems, float *tp)
34052 #line 3641
34053 {
34054 #line 3641
34055 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
34056 #line 3641
34057 
34058 #line 3641
34059  /* basic algorithm is:
34060 #line 3641
34061   *   - ensure sane alignment of input data
34062 #line 3641
34063   *   - copy (conversion happens automatically) input data
34064 #line 3641
34065   *     to output
34066 #line 3641
34067   *   - update xpp to point at next unconverted input, and tp to point
34068 #line 3641
34069   *     at next location for converted output
34070 #line 3641
34071   */
34072 #line 3641
34073   long i, j, ni;
34074 #line 3641
34075   int64 tmp[LOOPCNT];        /* in case input is misaligned */
34076 #line 3641
34077   int64 *xp;
34078 #line 3641
34079   int nrange = 0;         /* number of range errors */
34080 #line 3641
34081   int realign = 0;        /* "do we need to fix input data alignment?" */
34082 #line 3641
34083   long cxp = (long) *((char**)xpp);
34084 #line 3641
34085 
34086 #line 3641
34087   realign = (cxp & 7) % SIZEOF_INT64;
34088 #line 3641
34089   /* sjl: manually stripmine so we can limit amount of
34090 #line 3641
34091    * vector work space reserved to LOOPCNT elements. Also
34092 #line 3641
34093    * makes vectorisation easy */
34094 #line 3641
34095   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
34096 #line 3641
34097     ni=Min(nelems-j,LOOPCNT);
34098 #line 3641
34099     if (realign) {
34100 #line 3641
34101       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
34102 #line 3641
34103       xp = tmp;
34104 #line 3641
34105     } else {
34106 #line 3641
34107       xp = (int64 *) *xpp;
34108 #line 3641
34109     }
34110 #line 3641
34111    /* copy the next block */
34112 #line 3641
34113 #pragma cdir loopcnt=LOOPCNT
34114 #line 3641
34115 #pragma cdir shortloop
34116 #line 3641
34117     for (i=0; i<ni; i++) {
34118 #line 3641
34119       tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
34120 #line 3641
34121      /* test for range errors (not always needed but do it anyway) */
34122 #line 3641
34123      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
34124 #line 3641
34125      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
34126 #line 3641
34127       nrange += xp[i] > FLOAT_MAX || xp[i] < FLOAT_MIN;
34128 #line 3641
34129     }
34130 #line 3641
34131    /* update xpp and tp */
34132 #line 3641
34133     if (realign) xp = (int64 *) *xpp;
34134 #line 3641
34135     xp += ni;
34136 #line 3641
34137     tp += ni;
34138 #line 3641
34139     *xpp = (void*)xp;
34140 #line 3641
34141   }
34142 #line 3641
34143   return nrange == 0 ? NC_NOERR : NC_ERANGE;
34144 #line 3641
34145 
34146 #line 3641
34147 #else   /* not SX */
34148 #line 3641
34149 	const char *xp = (const char *) *xpp;
34150 #line 3641
34151 	int status = NC_NOERR;
34152 #line 3641
34153 
34154 #line 3641
34155 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
34156 #line 3641
34157 	{
34158 #line 3641
34159 		const int lstatus = ncx_get_longlong_float(xp, tp);
34160 #line 3641
34161 		if (status == NC_NOERR) /* report the first encountered error */
34162 #line 3641
34163 			status = lstatus;
34164 #line 3641
34165 	}
34166 #line 3641
34167 
34168 #line 3641
34169 	*xpp = (const void *)xp;
34170 #line 3641
34171 	return status;
34172 #line 3641
34173 #endif
34174 #line 3641
34175 }
34176 #line 3641
34177 
34178 int
34179 #line 3642
ncx_getn_longlong_double(const void ** xpp,size_t nelems,double * tp)34180 ncx_getn_longlong_double(const void **xpp, size_t nelems, double *tp)
34181 #line 3642
34182 {
34183 #line 3642
34184 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
34185 #line 3642
34186 
34187 #line 3642
34188  /* basic algorithm is:
34189 #line 3642
34190   *   - ensure sane alignment of input data
34191 #line 3642
34192   *   - copy (conversion happens automatically) input data
34193 #line 3642
34194   *     to output
34195 #line 3642
34196   *   - update xpp to point at next unconverted input, and tp to point
34197 #line 3642
34198   *     at next location for converted output
34199 #line 3642
34200   */
34201 #line 3642
34202   long i, j, ni;
34203 #line 3642
34204   int64 tmp[LOOPCNT];        /* in case input is misaligned */
34205 #line 3642
34206   int64 *xp;
34207 #line 3642
34208   int nrange = 0;         /* number of range errors */
34209 #line 3642
34210   int realign = 0;        /* "do we need to fix input data alignment?" */
34211 #line 3642
34212   long cxp = (long) *((char**)xpp);
34213 #line 3642
34214 
34215 #line 3642
34216   realign = (cxp & 7) % SIZEOF_INT64;
34217 #line 3642
34218   /* sjl: manually stripmine so we can limit amount of
34219 #line 3642
34220    * vector work space reserved to LOOPCNT elements. Also
34221 #line 3642
34222    * makes vectorisation easy */
34223 #line 3642
34224   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
34225 #line 3642
34226     ni=Min(nelems-j,LOOPCNT);
34227 #line 3642
34228     if (realign) {
34229 #line 3642
34230       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
34231 #line 3642
34232       xp = tmp;
34233 #line 3642
34234     } else {
34235 #line 3642
34236       xp = (int64 *) *xpp;
34237 #line 3642
34238     }
34239 #line 3642
34240    /* copy the next block */
34241 #line 3642
34242 #pragma cdir loopcnt=LOOPCNT
34243 #line 3642
34244 #pragma cdir shortloop
34245 #line 3642
34246     for (i=0; i<ni; i++) {
34247 #line 3642
34248       tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
34249 #line 3642
34250      /* test for range errors (not always needed but do it anyway) */
34251 #line 3642
34252      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
34253 #line 3642
34254      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
34255 #line 3642
34256       nrange += xp[i] > DOUBLE_MAX || xp[i] < DOUBLE_MIN;
34257 #line 3642
34258     }
34259 #line 3642
34260    /* update xpp and tp */
34261 #line 3642
34262     if (realign) xp = (int64 *) *xpp;
34263 #line 3642
34264     xp += ni;
34265 #line 3642
34266     tp += ni;
34267 #line 3642
34268     *xpp = (void*)xp;
34269 #line 3642
34270   }
34271 #line 3642
34272   return nrange == 0 ? NC_NOERR : NC_ERANGE;
34273 #line 3642
34274 
34275 #line 3642
34276 #else   /* not SX */
34277 #line 3642
34278 	const char *xp = (const char *) *xpp;
34279 #line 3642
34280 	int status = NC_NOERR;
34281 #line 3642
34282 
34283 #line 3642
34284 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
34285 #line 3642
34286 	{
34287 #line 3642
34288 		const int lstatus = ncx_get_longlong_double(xp, tp);
34289 #line 3642
34290 		if (status == NC_NOERR) /* report the first encountered error */
34291 #line 3642
34292 			status = lstatus;
34293 #line 3642
34294 	}
34295 #line 3642
34296 
34297 #line 3642
34298 	*xpp = (const void *)xp;
34299 #line 3642
34300 	return status;
34301 #line 3642
34302 #endif
34303 #line 3642
34304 }
34305 #line 3642
34306 
34307 int
34308 #line 3643
ncx_getn_longlong_uchar(const void ** xpp,size_t nelems,uchar * tp)34309 ncx_getn_longlong_uchar(const void **xpp, size_t nelems, uchar *tp)
34310 #line 3643
34311 {
34312 #line 3643
34313 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
34314 #line 3643
34315 
34316 #line 3643
34317  /* basic algorithm is:
34318 #line 3643
34319   *   - ensure sane alignment of input data
34320 #line 3643
34321   *   - copy (conversion happens automatically) input data
34322 #line 3643
34323   *     to output
34324 #line 3643
34325   *   - update xpp to point at next unconverted input, and tp to point
34326 #line 3643
34327   *     at next location for converted output
34328 #line 3643
34329   */
34330 #line 3643
34331   long i, j, ni;
34332 #line 3643
34333   int64 tmp[LOOPCNT];        /* in case input is misaligned */
34334 #line 3643
34335   int64 *xp;
34336 #line 3643
34337   int nrange = 0;         /* number of range errors */
34338 #line 3643
34339   int realign = 0;        /* "do we need to fix input data alignment?" */
34340 #line 3643
34341   long cxp = (long) *((char**)xpp);
34342 #line 3643
34343 
34344 #line 3643
34345   realign = (cxp & 7) % SIZEOF_INT64;
34346 #line 3643
34347   /* sjl: manually stripmine so we can limit amount of
34348 #line 3643
34349    * vector work space reserved to LOOPCNT elements. Also
34350 #line 3643
34351    * makes vectorisation easy */
34352 #line 3643
34353   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
34354 #line 3643
34355     ni=Min(nelems-j,LOOPCNT);
34356 #line 3643
34357     if (realign) {
34358 #line 3643
34359       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
34360 #line 3643
34361       xp = tmp;
34362 #line 3643
34363     } else {
34364 #line 3643
34365       xp = (int64 *) *xpp;
34366 #line 3643
34367     }
34368 #line 3643
34369    /* copy the next block */
34370 #line 3643
34371 #pragma cdir loopcnt=LOOPCNT
34372 #line 3643
34373 #pragma cdir shortloop
34374 #line 3643
34375     for (i=0; i<ni; i++) {
34376 #line 3643
34377       tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
34378 #line 3643
34379      /* test for range errors (not always needed but do it anyway) */
34380 #line 3643
34381      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
34382 #line 3643
34383      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
34384 #line 3643
34385       nrange += xp[i] > UCHAR_MAX || xp[i] < 0;
34386 #line 3643
34387     }
34388 #line 3643
34389    /* update xpp and tp */
34390 #line 3643
34391     if (realign) xp = (int64 *) *xpp;
34392 #line 3643
34393     xp += ni;
34394 #line 3643
34395     tp += ni;
34396 #line 3643
34397     *xpp = (void*)xp;
34398 #line 3643
34399   }
34400 #line 3643
34401   return nrange == 0 ? NC_NOERR : NC_ERANGE;
34402 #line 3643
34403 
34404 #line 3643
34405 #else   /* not SX */
34406 #line 3643
34407 	const char *xp = (const char *) *xpp;
34408 #line 3643
34409 	int status = NC_NOERR;
34410 #line 3643
34411 
34412 #line 3643
34413 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
34414 #line 3643
34415 	{
34416 #line 3643
34417 		const int lstatus = ncx_get_longlong_uchar(xp, tp);
34418 #line 3643
34419 		if (status == NC_NOERR) /* report the first encountered error */
34420 #line 3643
34421 			status = lstatus;
34422 #line 3643
34423 	}
34424 #line 3643
34425 
34426 #line 3643
34427 	*xpp = (const void *)xp;
34428 #line 3643
34429 	return status;
34430 #line 3643
34431 #endif
34432 #line 3643
34433 }
34434 #line 3643
34435 
34436 int
34437 #line 3644
ncx_getn_longlong_ushort(const void ** xpp,size_t nelems,ushort * tp)34438 ncx_getn_longlong_ushort(const void **xpp, size_t nelems, ushort *tp)
34439 #line 3644
34440 {
34441 #line 3644
34442 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
34443 #line 3644
34444 
34445 #line 3644
34446  /* basic algorithm is:
34447 #line 3644
34448   *   - ensure sane alignment of input data
34449 #line 3644
34450   *   - copy (conversion happens automatically) input data
34451 #line 3644
34452   *     to output
34453 #line 3644
34454   *   - update xpp to point at next unconverted input, and tp to point
34455 #line 3644
34456   *     at next location for converted output
34457 #line 3644
34458   */
34459 #line 3644
34460   long i, j, ni;
34461 #line 3644
34462   int64 tmp[LOOPCNT];        /* in case input is misaligned */
34463 #line 3644
34464   int64 *xp;
34465 #line 3644
34466   int nrange = 0;         /* number of range errors */
34467 #line 3644
34468   int realign = 0;        /* "do we need to fix input data alignment?" */
34469 #line 3644
34470   long cxp = (long) *((char**)xpp);
34471 #line 3644
34472 
34473 #line 3644
34474   realign = (cxp & 7) % SIZEOF_INT64;
34475 #line 3644
34476   /* sjl: manually stripmine so we can limit amount of
34477 #line 3644
34478    * vector work space reserved to LOOPCNT elements. Also
34479 #line 3644
34480    * makes vectorisation easy */
34481 #line 3644
34482   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
34483 #line 3644
34484     ni=Min(nelems-j,LOOPCNT);
34485 #line 3644
34486     if (realign) {
34487 #line 3644
34488       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
34489 #line 3644
34490       xp = tmp;
34491 #line 3644
34492     } else {
34493 #line 3644
34494       xp = (int64 *) *xpp;
34495 #line 3644
34496     }
34497 #line 3644
34498    /* copy the next block */
34499 #line 3644
34500 #pragma cdir loopcnt=LOOPCNT
34501 #line 3644
34502 #pragma cdir shortloop
34503 #line 3644
34504     for (i=0; i<ni; i++) {
34505 #line 3644
34506       tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
34507 #line 3644
34508      /* test for range errors (not always needed but do it anyway) */
34509 #line 3644
34510      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
34511 #line 3644
34512      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
34513 #line 3644
34514       nrange += xp[i] > USHORT_MAX || xp[i] < 0;
34515 #line 3644
34516     }
34517 #line 3644
34518    /* update xpp and tp */
34519 #line 3644
34520     if (realign) xp = (int64 *) *xpp;
34521 #line 3644
34522     xp += ni;
34523 #line 3644
34524     tp += ni;
34525 #line 3644
34526     *xpp = (void*)xp;
34527 #line 3644
34528   }
34529 #line 3644
34530   return nrange == 0 ? NC_NOERR : NC_ERANGE;
34531 #line 3644
34532 
34533 #line 3644
34534 #else   /* not SX */
34535 #line 3644
34536 	const char *xp = (const char *) *xpp;
34537 #line 3644
34538 	int status = NC_NOERR;
34539 #line 3644
34540 
34541 #line 3644
34542 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
34543 #line 3644
34544 	{
34545 #line 3644
34546 		const int lstatus = ncx_get_longlong_ushort(xp, tp);
34547 #line 3644
34548 		if (status == NC_NOERR) /* report the first encountered error */
34549 #line 3644
34550 			status = lstatus;
34551 #line 3644
34552 	}
34553 #line 3644
34554 
34555 #line 3644
34556 	*xpp = (const void *)xp;
34557 #line 3644
34558 	return status;
34559 #line 3644
34560 #endif
34561 #line 3644
34562 }
34563 #line 3644
34564 
34565 int
34566 #line 3645
ncx_getn_longlong_uint(const void ** xpp,size_t nelems,uint * tp)34567 ncx_getn_longlong_uint(const void **xpp, size_t nelems, uint *tp)
34568 #line 3645
34569 {
34570 #line 3645
34571 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
34572 #line 3645
34573 
34574 #line 3645
34575  /* basic algorithm is:
34576 #line 3645
34577   *   - ensure sane alignment of input data
34578 #line 3645
34579   *   - copy (conversion happens automatically) input data
34580 #line 3645
34581   *     to output
34582 #line 3645
34583   *   - update xpp to point at next unconverted input, and tp to point
34584 #line 3645
34585   *     at next location for converted output
34586 #line 3645
34587   */
34588 #line 3645
34589   long i, j, ni;
34590 #line 3645
34591   int64 tmp[LOOPCNT];        /* in case input is misaligned */
34592 #line 3645
34593   int64 *xp;
34594 #line 3645
34595   int nrange = 0;         /* number of range errors */
34596 #line 3645
34597   int realign = 0;        /* "do we need to fix input data alignment?" */
34598 #line 3645
34599   long cxp = (long) *((char**)xpp);
34600 #line 3645
34601 
34602 #line 3645
34603   realign = (cxp & 7) % SIZEOF_INT64;
34604 #line 3645
34605   /* sjl: manually stripmine so we can limit amount of
34606 #line 3645
34607    * vector work space reserved to LOOPCNT elements. Also
34608 #line 3645
34609    * makes vectorisation easy */
34610 #line 3645
34611   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
34612 #line 3645
34613     ni=Min(nelems-j,LOOPCNT);
34614 #line 3645
34615     if (realign) {
34616 #line 3645
34617       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
34618 #line 3645
34619       xp = tmp;
34620 #line 3645
34621     } else {
34622 #line 3645
34623       xp = (int64 *) *xpp;
34624 #line 3645
34625     }
34626 #line 3645
34627    /* copy the next block */
34628 #line 3645
34629 #pragma cdir loopcnt=LOOPCNT
34630 #line 3645
34631 #pragma cdir shortloop
34632 #line 3645
34633     for (i=0; i<ni; i++) {
34634 #line 3645
34635       tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
34636 #line 3645
34637      /* test for range errors (not always needed but do it anyway) */
34638 #line 3645
34639      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
34640 #line 3645
34641      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
34642 #line 3645
34643       nrange += xp[i] > UINT_MAX || xp[i] < 0;
34644 #line 3645
34645     }
34646 #line 3645
34647    /* update xpp and tp */
34648 #line 3645
34649     if (realign) xp = (int64 *) *xpp;
34650 #line 3645
34651     xp += ni;
34652 #line 3645
34653     tp += ni;
34654 #line 3645
34655     *xpp = (void*)xp;
34656 #line 3645
34657   }
34658 #line 3645
34659   return nrange == 0 ? NC_NOERR : NC_ERANGE;
34660 #line 3645
34661 
34662 #line 3645
34663 #else   /* not SX */
34664 #line 3645
34665 	const char *xp = (const char *) *xpp;
34666 #line 3645
34667 	int status = NC_NOERR;
34668 #line 3645
34669 
34670 #line 3645
34671 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
34672 #line 3645
34673 	{
34674 #line 3645
34675 		const int lstatus = ncx_get_longlong_uint(xp, tp);
34676 #line 3645
34677 		if (status == NC_NOERR) /* report the first encountered error */
34678 #line 3645
34679 			status = lstatus;
34680 #line 3645
34681 	}
34682 #line 3645
34683 
34684 #line 3645
34685 	*xpp = (const void *)xp;
34686 #line 3645
34687 	return status;
34688 #line 3645
34689 #endif
34690 #line 3645
34691 }
34692 #line 3645
34693 
34694 int
34695 #line 3646
ncx_getn_longlong_ulonglong(const void ** xpp,size_t nelems,ulonglong * tp)34696 ncx_getn_longlong_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
34697 #line 3646
34698 {
34699 #line 3646
34700 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
34701 #line 3646
34702 
34703 #line 3646
34704  /* basic algorithm is:
34705 #line 3646
34706   *   - ensure sane alignment of input data
34707 #line 3646
34708   *   - copy (conversion happens automatically) input data
34709 #line 3646
34710   *     to output
34711 #line 3646
34712   *   - update xpp to point at next unconverted input, and tp to point
34713 #line 3646
34714   *     at next location for converted output
34715 #line 3646
34716   */
34717 #line 3646
34718   long i, j, ni;
34719 #line 3646
34720   int64 tmp[LOOPCNT];        /* in case input is misaligned */
34721 #line 3646
34722   int64 *xp;
34723 #line 3646
34724   int nrange = 0;         /* number of range errors */
34725 #line 3646
34726   int realign = 0;        /* "do we need to fix input data alignment?" */
34727 #line 3646
34728   long cxp = (long) *((char**)xpp);
34729 #line 3646
34730 
34731 #line 3646
34732   realign = (cxp & 7) % SIZEOF_INT64;
34733 #line 3646
34734   /* sjl: manually stripmine so we can limit amount of
34735 #line 3646
34736    * vector work space reserved to LOOPCNT elements. Also
34737 #line 3646
34738    * makes vectorisation easy */
34739 #line 3646
34740   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
34741 #line 3646
34742     ni=Min(nelems-j,LOOPCNT);
34743 #line 3646
34744     if (realign) {
34745 #line 3646
34746       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
34747 #line 3646
34748       xp = tmp;
34749 #line 3646
34750     } else {
34751 #line 3646
34752       xp = (int64 *) *xpp;
34753 #line 3646
34754     }
34755 #line 3646
34756    /* copy the next block */
34757 #line 3646
34758 #pragma cdir loopcnt=LOOPCNT
34759 #line 3646
34760 #pragma cdir shortloop
34761 #line 3646
34762     for (i=0; i<ni; i++) {
34763 #line 3646
34764       tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
34765 #line 3646
34766      /* test for range errors (not always needed but do it anyway) */
34767 #line 3646
34768      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
34769 #line 3646
34770      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
34771 #line 3646
34772       nrange += xp[i] > ULONGLONG_MAX || xp[i] < 0;
34773 #line 3646
34774     }
34775 #line 3646
34776    /* update xpp and tp */
34777 #line 3646
34778     if (realign) xp = (int64 *) *xpp;
34779 #line 3646
34780     xp += ni;
34781 #line 3646
34782     tp += ni;
34783 #line 3646
34784     *xpp = (void*)xp;
34785 #line 3646
34786   }
34787 #line 3646
34788   return nrange == 0 ? NC_NOERR : NC_ERANGE;
34789 #line 3646
34790 
34791 #line 3646
34792 #else   /* not SX */
34793 #line 3646
34794 	const char *xp = (const char *) *xpp;
34795 #line 3646
34796 	int status = NC_NOERR;
34797 #line 3646
34798 
34799 #line 3646
34800 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
34801 #line 3646
34802 	{
34803 #line 3646
34804 		const int lstatus = ncx_get_longlong_ulonglong(xp, tp);
34805 #line 3646
34806 		if (status == NC_NOERR) /* report the first encountered error */
34807 #line 3646
34808 			status = lstatus;
34809 #line 3646
34810 	}
34811 #line 3646
34812 
34813 #line 3646
34814 	*xpp = (const void *)xp;
34815 #line 3646
34816 	return status;
34817 #line 3646
34818 #endif
34819 #line 3646
34820 }
34821 #line 3646
34822 
34823 
34824 #if X_SIZEOF_INT64 == SIZEOF_LONGLONG
34825 /* optimized version */
34826 int
ncx_putn_longlong_longlong(void ** xpp,size_t nelems,const long long * tp,void * fillp)34827 ncx_putn_longlong_longlong(void **xpp, size_t nelems, const long long *tp, void *fillp)
34828 {
34829 #ifdef WORDS_BIGENDIAN
34830 	(void) memcpy(*xpp, tp, (size_t)nelems * X_SIZEOF_INT64);
34831 # else
34832 	swapn8b(*xpp, tp, nelems);
34833 # endif
34834 	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_INT64);
34835 	return NC_NOERR;
34836 }
34837 #else
34838 int
34839 #line 3662
ncx_putn_longlong_longlong(void ** xpp,size_t nelems,const longlong * tp,void * fillp)34840 ncx_putn_longlong_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
34841 #line 3662
34842 {
34843 #line 3662
34844 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
34845 #line 3662
34846 
34847 #line 3662
34848  /* basic algorithm is:
34849 #line 3662
34850   *   - ensure sane alignment of output data
34851 #line 3662
34852   *   - copy (conversion happens automatically) input data
34853 #line 3662
34854   *     to output
34855 #line 3662
34856   *   - update tp to point at next unconverted input, and xpp to point
34857 #line 3662
34858   *     at next location for converted output
34859 #line 3662
34860   */
34861 #line 3662
34862   long i, j, ni;
34863 #line 3662
34864   int64 tmp[LOOPCNT];        /* in case input is misaligned */
34865 #line 3662
34866   int64 *xp;
34867 #line 3662
34868   int nrange = 0;         /* number of range errors */
34869 #line 3662
34870   int realign = 0;        /* "do we need to fix input data alignment?" */
34871 #line 3662
34872   long cxp = (long) *((char**)xpp);
34873 #line 3662
34874 
34875 #line 3662
34876   realign = (cxp & 7) % SIZEOF_INT64;
34877 #line 3662
34878   /* sjl: manually stripmine so we can limit amount of
34879 #line 3662
34880    * vector work space reserved to LOOPCNT elements. Also
34881 #line 3662
34882    * makes vectorisation easy */
34883 #line 3662
34884   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
34885 #line 3662
34886     ni=Min(nelems-j,LOOPCNT);
34887 #line 3662
34888     if (realign) {
34889 #line 3662
34890       xp = tmp;
34891 #line 3662
34892     } else {
34893 #line 3662
34894       xp = (int64 *) *xpp;
34895 #line 3662
34896     }
34897 #line 3662
34898    /* copy the next block */
34899 #line 3662
34900 #pragma cdir loopcnt=LOOPCNT
34901 #line 3662
34902 #pragma cdir shortloop
34903 #line 3662
34904     for (i=0; i<ni; i++) {
34905 #line 3662
34906       /* the normal case: */
34907 #line 3662
34908       xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
34909 #line 3662
34910      /* test for range errors (not always needed but do it anyway) */
34911 #line 3662
34912      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
34913 #line 3662
34914      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
34915 #line 3662
34916       nrange += tp[i] > X_INT64_MAX || tp[i] < X_INT64_MIN;
34917 #line 3662
34918     }
34919 #line 3662
34920    /* copy workspace back if necessary */
34921 #line 3662
34922     if (realign) {
34923 #line 3662
34924       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
34925 #line 3662
34926       xp = (int64 *) *xpp;
34927 #line 3662
34928     }
34929 #line 3662
34930    /* update xpp and tp */
34931 #line 3662
34932     xp += ni;
34933 #line 3662
34934     tp += ni;
34935 #line 3662
34936     *xpp = (void*)xp;
34937 #line 3662
34938   }
34939 #line 3662
34940   return nrange == 0 ? NC_NOERR : NC_ERANGE;
34941 #line 3662
34942 
34943 #line 3662
34944 #else   /* not SX */
34945 #line 3662
34946 
34947 #line 3662
34948 	char *xp = (char *) *xpp;
34949 #line 3662
34950 	int status = NC_NOERR;
34951 #line 3662
34952 
34953 #line 3662
34954 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
34955 #line 3662
34956 	{
34957 #line 3662
34958 		int lstatus = ncx_put_longlong_longlong(xp, tp, fillp);
34959 #line 3662
34960 		if (status == NC_NOERR) /* report the first encountered error */
34961 #line 3662
34962 			status = lstatus;
34963 #line 3662
34964 	}
34965 #line 3662
34966 
34967 #line 3662
34968 	*xpp = (void *)xp;
34969 #line 3662
34970 	return status;
34971 #line 3662
34972 #endif
34973 #line 3662
34974 }
34975 #line 3662
34976 
34977 #endif
34978 int
34979 #line 3664
ncx_putn_longlong_schar(void ** xpp,size_t nelems,const schar * tp,void * fillp)34980 ncx_putn_longlong_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
34981 #line 3664
34982 {
34983 #line 3664
34984 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
34985 #line 3664
34986 
34987 #line 3664
34988  /* basic algorithm is:
34989 #line 3664
34990   *   - ensure sane alignment of output data
34991 #line 3664
34992   *   - copy (conversion happens automatically) input data
34993 #line 3664
34994   *     to output
34995 #line 3664
34996   *   - update tp to point at next unconverted input, and xpp to point
34997 #line 3664
34998   *     at next location for converted output
34999 #line 3664
35000   */
35001 #line 3664
35002   long i, j, ni;
35003 #line 3664
35004   int64 tmp[LOOPCNT];        /* in case input is misaligned */
35005 #line 3664
35006   int64 *xp;
35007 #line 3664
35008   int nrange = 0;         /* number of range errors */
35009 #line 3664
35010   int realign = 0;        /* "do we need to fix input data alignment?" */
35011 #line 3664
35012   long cxp = (long) *((char**)xpp);
35013 #line 3664
35014 
35015 #line 3664
35016   realign = (cxp & 7) % SIZEOF_INT64;
35017 #line 3664
35018   /* sjl: manually stripmine so we can limit amount of
35019 #line 3664
35020    * vector work space reserved to LOOPCNT elements. Also
35021 #line 3664
35022    * makes vectorisation easy */
35023 #line 3664
35024   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
35025 #line 3664
35026     ni=Min(nelems-j,LOOPCNT);
35027 #line 3664
35028     if (realign) {
35029 #line 3664
35030       xp = tmp;
35031 #line 3664
35032     } else {
35033 #line 3664
35034       xp = (int64 *) *xpp;
35035 #line 3664
35036     }
35037 #line 3664
35038    /* copy the next block */
35039 #line 3664
35040 #pragma cdir loopcnt=LOOPCNT
35041 #line 3664
35042 #pragma cdir shortloop
35043 #line 3664
35044     for (i=0; i<ni; i++) {
35045 #line 3664
35046       /* the normal case: */
35047 #line 3664
35048       xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
35049 #line 3664
35050      /* test for range errors (not always needed but do it anyway) */
35051 #line 3664
35052      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
35053 #line 3664
35054      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
35055 #line 3664
35056       nrange += tp[i] > X_INT64_MAX || tp[i] < X_INT64_MIN;
35057 #line 3664
35058     }
35059 #line 3664
35060    /* copy workspace back if necessary */
35061 #line 3664
35062     if (realign) {
35063 #line 3664
35064       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
35065 #line 3664
35066       xp = (int64 *) *xpp;
35067 #line 3664
35068     }
35069 #line 3664
35070    /* update xpp and tp */
35071 #line 3664
35072     xp += ni;
35073 #line 3664
35074     tp += ni;
35075 #line 3664
35076     *xpp = (void*)xp;
35077 #line 3664
35078   }
35079 #line 3664
35080   return nrange == 0 ? NC_NOERR : NC_ERANGE;
35081 #line 3664
35082 
35083 #line 3664
35084 #else   /* not SX */
35085 #line 3664
35086 
35087 #line 3664
35088 	char *xp = (char *) *xpp;
35089 #line 3664
35090 	int status = NC_NOERR;
35091 #line 3664
35092 
35093 #line 3664
35094 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
35095 #line 3664
35096 	{
35097 #line 3664
35098 		int lstatus = ncx_put_longlong_schar(xp, tp, fillp);
35099 #line 3664
35100 		if (status == NC_NOERR) /* report the first encountered error */
35101 #line 3664
35102 			status = lstatus;
35103 #line 3664
35104 	}
35105 #line 3664
35106 
35107 #line 3664
35108 	*xpp = (void *)xp;
35109 #line 3664
35110 	return status;
35111 #line 3664
35112 #endif
35113 #line 3664
35114 }
35115 #line 3664
35116 
35117 int
35118 #line 3665
ncx_putn_longlong_short(void ** xpp,size_t nelems,const short * tp,void * fillp)35119 ncx_putn_longlong_short(void **xpp, size_t nelems, const short *tp, void *fillp)
35120 #line 3665
35121 {
35122 #line 3665
35123 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
35124 #line 3665
35125 
35126 #line 3665
35127  /* basic algorithm is:
35128 #line 3665
35129   *   - ensure sane alignment of output data
35130 #line 3665
35131   *   - copy (conversion happens automatically) input data
35132 #line 3665
35133   *     to output
35134 #line 3665
35135   *   - update tp to point at next unconverted input, and xpp to point
35136 #line 3665
35137   *     at next location for converted output
35138 #line 3665
35139   */
35140 #line 3665
35141   long i, j, ni;
35142 #line 3665
35143   int64 tmp[LOOPCNT];        /* in case input is misaligned */
35144 #line 3665
35145   int64 *xp;
35146 #line 3665
35147   int nrange = 0;         /* number of range errors */
35148 #line 3665
35149   int realign = 0;        /* "do we need to fix input data alignment?" */
35150 #line 3665
35151   long cxp = (long) *((char**)xpp);
35152 #line 3665
35153 
35154 #line 3665
35155   realign = (cxp & 7) % SIZEOF_INT64;
35156 #line 3665
35157   /* sjl: manually stripmine so we can limit amount of
35158 #line 3665
35159    * vector work space reserved to LOOPCNT elements. Also
35160 #line 3665
35161    * makes vectorisation easy */
35162 #line 3665
35163   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
35164 #line 3665
35165     ni=Min(nelems-j,LOOPCNT);
35166 #line 3665
35167     if (realign) {
35168 #line 3665
35169       xp = tmp;
35170 #line 3665
35171     } else {
35172 #line 3665
35173       xp = (int64 *) *xpp;
35174 #line 3665
35175     }
35176 #line 3665
35177    /* copy the next block */
35178 #line 3665
35179 #pragma cdir loopcnt=LOOPCNT
35180 #line 3665
35181 #pragma cdir shortloop
35182 #line 3665
35183     for (i=0; i<ni; i++) {
35184 #line 3665
35185       /* the normal case: */
35186 #line 3665
35187       xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
35188 #line 3665
35189      /* test for range errors (not always needed but do it anyway) */
35190 #line 3665
35191      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
35192 #line 3665
35193      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
35194 #line 3665
35195       nrange += tp[i] > X_INT64_MAX || tp[i] < X_INT64_MIN;
35196 #line 3665
35197     }
35198 #line 3665
35199    /* copy workspace back if necessary */
35200 #line 3665
35201     if (realign) {
35202 #line 3665
35203       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
35204 #line 3665
35205       xp = (int64 *) *xpp;
35206 #line 3665
35207     }
35208 #line 3665
35209    /* update xpp and tp */
35210 #line 3665
35211     xp += ni;
35212 #line 3665
35213     tp += ni;
35214 #line 3665
35215     *xpp = (void*)xp;
35216 #line 3665
35217   }
35218 #line 3665
35219   return nrange == 0 ? NC_NOERR : NC_ERANGE;
35220 #line 3665
35221 
35222 #line 3665
35223 #else   /* not SX */
35224 #line 3665
35225 
35226 #line 3665
35227 	char *xp = (char *) *xpp;
35228 #line 3665
35229 	int status = NC_NOERR;
35230 #line 3665
35231 
35232 #line 3665
35233 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
35234 #line 3665
35235 	{
35236 #line 3665
35237 		int lstatus = ncx_put_longlong_short(xp, tp, fillp);
35238 #line 3665
35239 		if (status == NC_NOERR) /* report the first encountered error */
35240 #line 3665
35241 			status = lstatus;
35242 #line 3665
35243 	}
35244 #line 3665
35245 
35246 #line 3665
35247 	*xpp = (void *)xp;
35248 #line 3665
35249 	return status;
35250 #line 3665
35251 #endif
35252 #line 3665
35253 }
35254 #line 3665
35255 
35256 int
35257 #line 3666
ncx_putn_longlong_int(void ** xpp,size_t nelems,const int * tp,void * fillp)35258 ncx_putn_longlong_int(void **xpp, size_t nelems, const int *tp, void *fillp)
35259 #line 3666
35260 {
35261 #line 3666
35262 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
35263 #line 3666
35264 
35265 #line 3666
35266  /* basic algorithm is:
35267 #line 3666
35268   *   - ensure sane alignment of output data
35269 #line 3666
35270   *   - copy (conversion happens automatically) input data
35271 #line 3666
35272   *     to output
35273 #line 3666
35274   *   - update tp to point at next unconverted input, and xpp to point
35275 #line 3666
35276   *     at next location for converted output
35277 #line 3666
35278   */
35279 #line 3666
35280   long i, j, ni;
35281 #line 3666
35282   int64 tmp[LOOPCNT];        /* in case input is misaligned */
35283 #line 3666
35284   int64 *xp;
35285 #line 3666
35286   int nrange = 0;         /* number of range errors */
35287 #line 3666
35288   int realign = 0;        /* "do we need to fix input data alignment?" */
35289 #line 3666
35290   long cxp = (long) *((char**)xpp);
35291 #line 3666
35292 
35293 #line 3666
35294   realign = (cxp & 7) % SIZEOF_INT64;
35295 #line 3666
35296   /* sjl: manually stripmine so we can limit amount of
35297 #line 3666
35298    * vector work space reserved to LOOPCNT elements. Also
35299 #line 3666
35300    * makes vectorisation easy */
35301 #line 3666
35302   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
35303 #line 3666
35304     ni=Min(nelems-j,LOOPCNT);
35305 #line 3666
35306     if (realign) {
35307 #line 3666
35308       xp = tmp;
35309 #line 3666
35310     } else {
35311 #line 3666
35312       xp = (int64 *) *xpp;
35313 #line 3666
35314     }
35315 #line 3666
35316    /* copy the next block */
35317 #line 3666
35318 #pragma cdir loopcnt=LOOPCNT
35319 #line 3666
35320 #pragma cdir shortloop
35321 #line 3666
35322     for (i=0; i<ni; i++) {
35323 #line 3666
35324       /* the normal case: */
35325 #line 3666
35326       xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
35327 #line 3666
35328      /* test for range errors (not always needed but do it anyway) */
35329 #line 3666
35330      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
35331 #line 3666
35332      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
35333 #line 3666
35334       nrange += tp[i] > X_INT64_MAX || tp[i] < X_INT64_MIN;
35335 #line 3666
35336     }
35337 #line 3666
35338    /* copy workspace back if necessary */
35339 #line 3666
35340     if (realign) {
35341 #line 3666
35342       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
35343 #line 3666
35344       xp = (int64 *) *xpp;
35345 #line 3666
35346     }
35347 #line 3666
35348    /* update xpp and tp */
35349 #line 3666
35350     xp += ni;
35351 #line 3666
35352     tp += ni;
35353 #line 3666
35354     *xpp = (void*)xp;
35355 #line 3666
35356   }
35357 #line 3666
35358   return nrange == 0 ? NC_NOERR : NC_ERANGE;
35359 #line 3666
35360 
35361 #line 3666
35362 #else   /* not SX */
35363 #line 3666
35364 
35365 #line 3666
35366 	char *xp = (char *) *xpp;
35367 #line 3666
35368 	int status = NC_NOERR;
35369 #line 3666
35370 
35371 #line 3666
35372 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
35373 #line 3666
35374 	{
35375 #line 3666
35376 		int lstatus = ncx_put_longlong_int(xp, tp, fillp);
35377 #line 3666
35378 		if (status == NC_NOERR) /* report the first encountered error */
35379 #line 3666
35380 			status = lstatus;
35381 #line 3666
35382 	}
35383 #line 3666
35384 
35385 #line 3666
35386 	*xpp = (void *)xp;
35387 #line 3666
35388 	return status;
35389 #line 3666
35390 #endif
35391 #line 3666
35392 }
35393 #line 3666
35394 
35395 int
35396 #line 3667
ncx_putn_longlong_long(void ** xpp,size_t nelems,const long * tp,void * fillp)35397 ncx_putn_longlong_long(void **xpp, size_t nelems, const long *tp, void *fillp)
35398 #line 3667
35399 {
35400 #line 3667
35401 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
35402 #line 3667
35403 
35404 #line 3667
35405  /* basic algorithm is:
35406 #line 3667
35407   *   - ensure sane alignment of output data
35408 #line 3667
35409   *   - copy (conversion happens automatically) input data
35410 #line 3667
35411   *     to output
35412 #line 3667
35413   *   - update tp to point at next unconverted input, and xpp to point
35414 #line 3667
35415   *     at next location for converted output
35416 #line 3667
35417   */
35418 #line 3667
35419   long i, j, ni;
35420 #line 3667
35421   int64 tmp[LOOPCNT];        /* in case input is misaligned */
35422 #line 3667
35423   int64 *xp;
35424 #line 3667
35425   int nrange = 0;         /* number of range errors */
35426 #line 3667
35427   int realign = 0;        /* "do we need to fix input data alignment?" */
35428 #line 3667
35429   long cxp = (long) *((char**)xpp);
35430 #line 3667
35431 
35432 #line 3667
35433   realign = (cxp & 7) % SIZEOF_INT64;
35434 #line 3667
35435   /* sjl: manually stripmine so we can limit amount of
35436 #line 3667
35437    * vector work space reserved to LOOPCNT elements. Also
35438 #line 3667
35439    * makes vectorisation easy */
35440 #line 3667
35441   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
35442 #line 3667
35443     ni=Min(nelems-j,LOOPCNT);
35444 #line 3667
35445     if (realign) {
35446 #line 3667
35447       xp = tmp;
35448 #line 3667
35449     } else {
35450 #line 3667
35451       xp = (int64 *) *xpp;
35452 #line 3667
35453     }
35454 #line 3667
35455    /* copy the next block */
35456 #line 3667
35457 #pragma cdir loopcnt=LOOPCNT
35458 #line 3667
35459 #pragma cdir shortloop
35460 #line 3667
35461     for (i=0; i<ni; i++) {
35462 #line 3667
35463       /* the normal case: */
35464 #line 3667
35465       xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
35466 #line 3667
35467      /* test for range errors (not always needed but do it anyway) */
35468 #line 3667
35469      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
35470 #line 3667
35471      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
35472 #line 3667
35473       nrange += tp[i] > X_INT64_MAX || tp[i] < X_INT64_MIN;
35474 #line 3667
35475     }
35476 #line 3667
35477    /* copy workspace back if necessary */
35478 #line 3667
35479     if (realign) {
35480 #line 3667
35481       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
35482 #line 3667
35483       xp = (int64 *) *xpp;
35484 #line 3667
35485     }
35486 #line 3667
35487    /* update xpp and tp */
35488 #line 3667
35489     xp += ni;
35490 #line 3667
35491     tp += ni;
35492 #line 3667
35493     *xpp = (void*)xp;
35494 #line 3667
35495   }
35496 #line 3667
35497   return nrange == 0 ? NC_NOERR : NC_ERANGE;
35498 #line 3667
35499 
35500 #line 3667
35501 #else   /* not SX */
35502 #line 3667
35503 
35504 #line 3667
35505 	char *xp = (char *) *xpp;
35506 #line 3667
35507 	int status = NC_NOERR;
35508 #line 3667
35509 
35510 #line 3667
35511 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
35512 #line 3667
35513 	{
35514 #line 3667
35515 		int lstatus = ncx_put_longlong_long(xp, tp, fillp);
35516 #line 3667
35517 		if (status == NC_NOERR) /* report the first encountered error */
35518 #line 3667
35519 			status = lstatus;
35520 #line 3667
35521 	}
35522 #line 3667
35523 
35524 #line 3667
35525 	*xpp = (void *)xp;
35526 #line 3667
35527 	return status;
35528 #line 3667
35529 #endif
35530 #line 3667
35531 }
35532 #line 3667
35533 
35534 int
35535 #line 3668
ncx_putn_longlong_float(void ** xpp,size_t nelems,const float * tp,void * fillp)35536 ncx_putn_longlong_float(void **xpp, size_t nelems, const float *tp, void *fillp)
35537 #line 3668
35538 {
35539 #line 3668
35540 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
35541 #line 3668
35542 
35543 #line 3668
35544  /* basic algorithm is:
35545 #line 3668
35546   *   - ensure sane alignment of output data
35547 #line 3668
35548   *   - copy (conversion happens automatically) input data
35549 #line 3668
35550   *     to output
35551 #line 3668
35552   *   - update tp to point at next unconverted input, and xpp to point
35553 #line 3668
35554   *     at next location for converted output
35555 #line 3668
35556   */
35557 #line 3668
35558   long i, j, ni;
35559 #line 3668
35560   int64 tmp[LOOPCNT];        /* in case input is misaligned */
35561 #line 3668
35562   int64 *xp;
35563 #line 3668
35564   int nrange = 0;         /* number of range errors */
35565 #line 3668
35566   int realign = 0;        /* "do we need to fix input data alignment?" */
35567 #line 3668
35568   long cxp = (long) *((char**)xpp);
35569 #line 3668
35570 
35571 #line 3668
35572   realign = (cxp & 7) % SIZEOF_INT64;
35573 #line 3668
35574   /* sjl: manually stripmine so we can limit amount of
35575 #line 3668
35576    * vector work space reserved to LOOPCNT elements. Also
35577 #line 3668
35578    * makes vectorisation easy */
35579 #line 3668
35580   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
35581 #line 3668
35582     ni=Min(nelems-j,LOOPCNT);
35583 #line 3668
35584     if (realign) {
35585 #line 3668
35586       xp = tmp;
35587 #line 3668
35588     } else {
35589 #line 3668
35590       xp = (int64 *) *xpp;
35591 #line 3668
35592     }
35593 #line 3668
35594    /* copy the next block */
35595 #line 3668
35596 #pragma cdir loopcnt=LOOPCNT
35597 #line 3668
35598 #pragma cdir shortloop
35599 #line 3668
35600     for (i=0; i<ni; i++) {
35601 #line 3668
35602       /* the normal case: */
35603 #line 3668
35604       xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
35605 #line 3668
35606      /* test for range errors (not always needed but do it anyway) */
35607 #line 3668
35608      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
35609 #line 3668
35610      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
35611 #line 3668
35612       nrange += tp[i] > X_INT64_MAX || tp[i] < X_INT64_MIN;
35613 #line 3668
35614     }
35615 #line 3668
35616    /* copy workspace back if necessary */
35617 #line 3668
35618     if (realign) {
35619 #line 3668
35620       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
35621 #line 3668
35622       xp = (int64 *) *xpp;
35623 #line 3668
35624     }
35625 #line 3668
35626    /* update xpp and tp */
35627 #line 3668
35628     xp += ni;
35629 #line 3668
35630     tp += ni;
35631 #line 3668
35632     *xpp = (void*)xp;
35633 #line 3668
35634   }
35635 #line 3668
35636   return nrange == 0 ? NC_NOERR : NC_ERANGE;
35637 #line 3668
35638 
35639 #line 3668
35640 #else   /* not SX */
35641 #line 3668
35642 
35643 #line 3668
35644 	char *xp = (char *) *xpp;
35645 #line 3668
35646 	int status = NC_NOERR;
35647 #line 3668
35648 
35649 #line 3668
35650 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
35651 #line 3668
35652 	{
35653 #line 3668
35654 		int lstatus = ncx_put_longlong_float(xp, tp, fillp);
35655 #line 3668
35656 		if (status == NC_NOERR) /* report the first encountered error */
35657 #line 3668
35658 			status = lstatus;
35659 #line 3668
35660 	}
35661 #line 3668
35662 
35663 #line 3668
35664 	*xpp = (void *)xp;
35665 #line 3668
35666 	return status;
35667 #line 3668
35668 #endif
35669 #line 3668
35670 }
35671 #line 3668
35672 
35673 int
35674 #line 3669
ncx_putn_longlong_double(void ** xpp,size_t nelems,const double * tp,void * fillp)35675 ncx_putn_longlong_double(void **xpp, size_t nelems, const double *tp, void *fillp)
35676 #line 3669
35677 {
35678 #line 3669
35679 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
35680 #line 3669
35681 
35682 #line 3669
35683  /* basic algorithm is:
35684 #line 3669
35685   *   - ensure sane alignment of output data
35686 #line 3669
35687   *   - copy (conversion happens automatically) input data
35688 #line 3669
35689   *     to output
35690 #line 3669
35691   *   - update tp to point at next unconverted input, and xpp to point
35692 #line 3669
35693   *     at next location for converted output
35694 #line 3669
35695   */
35696 #line 3669
35697   long i, j, ni;
35698 #line 3669
35699   int64 tmp[LOOPCNT];        /* in case input is misaligned */
35700 #line 3669
35701   int64 *xp;
35702 #line 3669
35703   int nrange = 0;         /* number of range errors */
35704 #line 3669
35705   int realign = 0;        /* "do we need to fix input data alignment?" */
35706 #line 3669
35707   long cxp = (long) *((char**)xpp);
35708 #line 3669
35709 
35710 #line 3669
35711   realign = (cxp & 7) % SIZEOF_INT64;
35712 #line 3669
35713   /* sjl: manually stripmine so we can limit amount of
35714 #line 3669
35715    * vector work space reserved to LOOPCNT elements. Also
35716 #line 3669
35717    * makes vectorisation easy */
35718 #line 3669
35719   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
35720 #line 3669
35721     ni=Min(nelems-j,LOOPCNT);
35722 #line 3669
35723     if (realign) {
35724 #line 3669
35725       xp = tmp;
35726 #line 3669
35727     } else {
35728 #line 3669
35729       xp = (int64 *) *xpp;
35730 #line 3669
35731     }
35732 #line 3669
35733    /* copy the next block */
35734 #line 3669
35735 #pragma cdir loopcnt=LOOPCNT
35736 #line 3669
35737 #pragma cdir shortloop
35738 #line 3669
35739     for (i=0; i<ni; i++) {
35740 #line 3669
35741       /* the normal case: */
35742 #line 3669
35743       xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
35744 #line 3669
35745      /* test for range errors (not always needed but do it anyway) */
35746 #line 3669
35747      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
35748 #line 3669
35749      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
35750 #line 3669
35751       nrange += tp[i] > X_INT64_MAX || tp[i] < X_INT64_MIN;
35752 #line 3669
35753     }
35754 #line 3669
35755    /* copy workspace back if necessary */
35756 #line 3669
35757     if (realign) {
35758 #line 3669
35759       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
35760 #line 3669
35761       xp = (int64 *) *xpp;
35762 #line 3669
35763     }
35764 #line 3669
35765    /* update xpp and tp */
35766 #line 3669
35767     xp += ni;
35768 #line 3669
35769     tp += ni;
35770 #line 3669
35771     *xpp = (void*)xp;
35772 #line 3669
35773   }
35774 #line 3669
35775   return nrange == 0 ? NC_NOERR : NC_ERANGE;
35776 #line 3669
35777 
35778 #line 3669
35779 #else   /* not SX */
35780 #line 3669
35781 
35782 #line 3669
35783 	char *xp = (char *) *xpp;
35784 #line 3669
35785 	int status = NC_NOERR;
35786 #line 3669
35787 
35788 #line 3669
35789 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
35790 #line 3669
35791 	{
35792 #line 3669
35793 		int lstatus = ncx_put_longlong_double(xp, tp, fillp);
35794 #line 3669
35795 		if (status == NC_NOERR) /* report the first encountered error */
35796 #line 3669
35797 			status = lstatus;
35798 #line 3669
35799 	}
35800 #line 3669
35801 
35802 #line 3669
35803 	*xpp = (void *)xp;
35804 #line 3669
35805 	return status;
35806 #line 3669
35807 #endif
35808 #line 3669
35809 }
35810 #line 3669
35811 
35812 int
35813 #line 3670
ncx_putn_longlong_uchar(void ** xpp,size_t nelems,const uchar * tp,void * fillp)35814 ncx_putn_longlong_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
35815 #line 3670
35816 {
35817 #line 3670
35818 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
35819 #line 3670
35820 
35821 #line 3670
35822  /* basic algorithm is:
35823 #line 3670
35824   *   - ensure sane alignment of output data
35825 #line 3670
35826   *   - copy (conversion happens automatically) input data
35827 #line 3670
35828   *     to output
35829 #line 3670
35830   *   - update tp to point at next unconverted input, and xpp to point
35831 #line 3670
35832   *     at next location for converted output
35833 #line 3670
35834   */
35835 #line 3670
35836   long i, j, ni;
35837 #line 3670
35838   int64 tmp[LOOPCNT];        /* in case input is misaligned */
35839 #line 3670
35840   int64 *xp;
35841 #line 3670
35842   int nrange = 0;         /* number of range errors */
35843 #line 3670
35844   int realign = 0;        /* "do we need to fix input data alignment?" */
35845 #line 3670
35846   long cxp = (long) *((char**)xpp);
35847 #line 3670
35848 
35849 #line 3670
35850   realign = (cxp & 7) % SIZEOF_INT64;
35851 #line 3670
35852   /* sjl: manually stripmine so we can limit amount of
35853 #line 3670
35854    * vector work space reserved to LOOPCNT elements. Also
35855 #line 3670
35856    * makes vectorisation easy */
35857 #line 3670
35858   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
35859 #line 3670
35860     ni=Min(nelems-j,LOOPCNT);
35861 #line 3670
35862     if (realign) {
35863 #line 3670
35864       xp = tmp;
35865 #line 3670
35866     } else {
35867 #line 3670
35868       xp = (int64 *) *xpp;
35869 #line 3670
35870     }
35871 #line 3670
35872    /* copy the next block */
35873 #line 3670
35874 #pragma cdir loopcnt=LOOPCNT
35875 #line 3670
35876 #pragma cdir shortloop
35877 #line 3670
35878     for (i=0; i<ni; i++) {
35879 #line 3670
35880       /* the normal case: */
35881 #line 3670
35882       xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
35883 #line 3670
35884      /* test for range errors (not always needed but do it anyway) */
35885 #line 3670
35886      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
35887 #line 3670
35888      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
35889 #line 3670
35890       nrange += tp[i] > X_INT64_MAX ;
35891 #line 3670
35892     }
35893 #line 3670
35894    /* copy workspace back if necessary */
35895 #line 3670
35896     if (realign) {
35897 #line 3670
35898       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
35899 #line 3670
35900       xp = (int64 *) *xpp;
35901 #line 3670
35902     }
35903 #line 3670
35904    /* update xpp and tp */
35905 #line 3670
35906     xp += ni;
35907 #line 3670
35908     tp += ni;
35909 #line 3670
35910     *xpp = (void*)xp;
35911 #line 3670
35912   }
35913 #line 3670
35914   return nrange == 0 ? NC_NOERR : NC_ERANGE;
35915 #line 3670
35916 
35917 #line 3670
35918 #else   /* not SX */
35919 #line 3670
35920 
35921 #line 3670
35922 	char *xp = (char *) *xpp;
35923 #line 3670
35924 	int status = NC_NOERR;
35925 #line 3670
35926 
35927 #line 3670
35928 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
35929 #line 3670
35930 	{
35931 #line 3670
35932 		int lstatus = ncx_put_longlong_uchar(xp, tp, fillp);
35933 #line 3670
35934 		if (status == NC_NOERR) /* report the first encountered error */
35935 #line 3670
35936 			status = lstatus;
35937 #line 3670
35938 	}
35939 #line 3670
35940 
35941 #line 3670
35942 	*xpp = (void *)xp;
35943 #line 3670
35944 	return status;
35945 #line 3670
35946 #endif
35947 #line 3670
35948 }
35949 #line 3670
35950 
35951 int
35952 #line 3671
ncx_putn_longlong_ushort(void ** xpp,size_t nelems,const ushort * tp,void * fillp)35953 ncx_putn_longlong_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
35954 #line 3671
35955 {
35956 #line 3671
35957 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
35958 #line 3671
35959 
35960 #line 3671
35961  /* basic algorithm is:
35962 #line 3671
35963   *   - ensure sane alignment of output data
35964 #line 3671
35965   *   - copy (conversion happens automatically) input data
35966 #line 3671
35967   *     to output
35968 #line 3671
35969   *   - update tp to point at next unconverted input, and xpp to point
35970 #line 3671
35971   *     at next location for converted output
35972 #line 3671
35973   */
35974 #line 3671
35975   long i, j, ni;
35976 #line 3671
35977   int64 tmp[LOOPCNT];        /* in case input is misaligned */
35978 #line 3671
35979   int64 *xp;
35980 #line 3671
35981   int nrange = 0;         /* number of range errors */
35982 #line 3671
35983   int realign = 0;        /* "do we need to fix input data alignment?" */
35984 #line 3671
35985   long cxp = (long) *((char**)xpp);
35986 #line 3671
35987 
35988 #line 3671
35989   realign = (cxp & 7) % SIZEOF_INT64;
35990 #line 3671
35991   /* sjl: manually stripmine so we can limit amount of
35992 #line 3671
35993    * vector work space reserved to LOOPCNT elements. Also
35994 #line 3671
35995    * makes vectorisation easy */
35996 #line 3671
35997   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
35998 #line 3671
35999     ni=Min(nelems-j,LOOPCNT);
36000 #line 3671
36001     if (realign) {
36002 #line 3671
36003       xp = tmp;
36004 #line 3671
36005     } else {
36006 #line 3671
36007       xp = (int64 *) *xpp;
36008 #line 3671
36009     }
36010 #line 3671
36011    /* copy the next block */
36012 #line 3671
36013 #pragma cdir loopcnt=LOOPCNT
36014 #line 3671
36015 #pragma cdir shortloop
36016 #line 3671
36017     for (i=0; i<ni; i++) {
36018 #line 3671
36019       /* the normal case: */
36020 #line 3671
36021       xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
36022 #line 3671
36023      /* test for range errors (not always needed but do it anyway) */
36024 #line 3671
36025      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
36026 #line 3671
36027      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
36028 #line 3671
36029       nrange += tp[i] > X_INT64_MAX ;
36030 #line 3671
36031     }
36032 #line 3671
36033    /* copy workspace back if necessary */
36034 #line 3671
36035     if (realign) {
36036 #line 3671
36037       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
36038 #line 3671
36039       xp = (int64 *) *xpp;
36040 #line 3671
36041     }
36042 #line 3671
36043    /* update xpp and tp */
36044 #line 3671
36045     xp += ni;
36046 #line 3671
36047     tp += ni;
36048 #line 3671
36049     *xpp = (void*)xp;
36050 #line 3671
36051   }
36052 #line 3671
36053   return nrange == 0 ? NC_NOERR : NC_ERANGE;
36054 #line 3671
36055 
36056 #line 3671
36057 #else   /* not SX */
36058 #line 3671
36059 
36060 #line 3671
36061 	char *xp = (char *) *xpp;
36062 #line 3671
36063 	int status = NC_NOERR;
36064 #line 3671
36065 
36066 #line 3671
36067 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
36068 #line 3671
36069 	{
36070 #line 3671
36071 		int lstatus = ncx_put_longlong_ushort(xp, tp, fillp);
36072 #line 3671
36073 		if (status == NC_NOERR) /* report the first encountered error */
36074 #line 3671
36075 			status = lstatus;
36076 #line 3671
36077 	}
36078 #line 3671
36079 
36080 #line 3671
36081 	*xpp = (void *)xp;
36082 #line 3671
36083 	return status;
36084 #line 3671
36085 #endif
36086 #line 3671
36087 }
36088 #line 3671
36089 
36090 int
36091 #line 3672
ncx_putn_longlong_uint(void ** xpp,size_t nelems,const uint * tp,void * fillp)36092 ncx_putn_longlong_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
36093 #line 3672
36094 {
36095 #line 3672
36096 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
36097 #line 3672
36098 
36099 #line 3672
36100  /* basic algorithm is:
36101 #line 3672
36102   *   - ensure sane alignment of output data
36103 #line 3672
36104   *   - copy (conversion happens automatically) input data
36105 #line 3672
36106   *     to output
36107 #line 3672
36108   *   - update tp to point at next unconverted input, and xpp to point
36109 #line 3672
36110   *     at next location for converted output
36111 #line 3672
36112   */
36113 #line 3672
36114   long i, j, ni;
36115 #line 3672
36116   int64 tmp[LOOPCNT];        /* in case input is misaligned */
36117 #line 3672
36118   int64 *xp;
36119 #line 3672
36120   int nrange = 0;         /* number of range errors */
36121 #line 3672
36122   int realign = 0;        /* "do we need to fix input data alignment?" */
36123 #line 3672
36124   long cxp = (long) *((char**)xpp);
36125 #line 3672
36126 
36127 #line 3672
36128   realign = (cxp & 7) % SIZEOF_INT64;
36129 #line 3672
36130   /* sjl: manually stripmine so we can limit amount of
36131 #line 3672
36132    * vector work space reserved to LOOPCNT elements. Also
36133 #line 3672
36134    * makes vectorisation easy */
36135 #line 3672
36136   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
36137 #line 3672
36138     ni=Min(nelems-j,LOOPCNT);
36139 #line 3672
36140     if (realign) {
36141 #line 3672
36142       xp = tmp;
36143 #line 3672
36144     } else {
36145 #line 3672
36146       xp = (int64 *) *xpp;
36147 #line 3672
36148     }
36149 #line 3672
36150    /* copy the next block */
36151 #line 3672
36152 #pragma cdir loopcnt=LOOPCNT
36153 #line 3672
36154 #pragma cdir shortloop
36155 #line 3672
36156     for (i=0; i<ni; i++) {
36157 #line 3672
36158       /* the normal case: */
36159 #line 3672
36160       xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
36161 #line 3672
36162      /* test for range errors (not always needed but do it anyway) */
36163 #line 3672
36164      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
36165 #line 3672
36166      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
36167 #line 3672
36168       nrange += tp[i] > X_INT64_MAX ;
36169 #line 3672
36170     }
36171 #line 3672
36172    /* copy workspace back if necessary */
36173 #line 3672
36174     if (realign) {
36175 #line 3672
36176       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
36177 #line 3672
36178       xp = (int64 *) *xpp;
36179 #line 3672
36180     }
36181 #line 3672
36182    /* update xpp and tp */
36183 #line 3672
36184     xp += ni;
36185 #line 3672
36186     tp += ni;
36187 #line 3672
36188     *xpp = (void*)xp;
36189 #line 3672
36190   }
36191 #line 3672
36192   return nrange == 0 ? NC_NOERR : NC_ERANGE;
36193 #line 3672
36194 
36195 #line 3672
36196 #else   /* not SX */
36197 #line 3672
36198 
36199 #line 3672
36200 	char *xp = (char *) *xpp;
36201 #line 3672
36202 	int status = NC_NOERR;
36203 #line 3672
36204 
36205 #line 3672
36206 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
36207 #line 3672
36208 	{
36209 #line 3672
36210 		int lstatus = ncx_put_longlong_uint(xp, tp, fillp);
36211 #line 3672
36212 		if (status == NC_NOERR) /* report the first encountered error */
36213 #line 3672
36214 			status = lstatus;
36215 #line 3672
36216 	}
36217 #line 3672
36218 
36219 #line 3672
36220 	*xpp = (void *)xp;
36221 #line 3672
36222 	return status;
36223 #line 3672
36224 #endif
36225 #line 3672
36226 }
36227 #line 3672
36228 
36229 int
36230 #line 3673
ncx_putn_longlong_ulonglong(void ** xpp,size_t nelems,const ulonglong * tp,void * fillp)36231 ncx_putn_longlong_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
36232 #line 3673
36233 {
36234 #line 3673
36235 #if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
36236 #line 3673
36237 
36238 #line 3673
36239  /* basic algorithm is:
36240 #line 3673
36241   *   - ensure sane alignment of output data
36242 #line 3673
36243   *   - copy (conversion happens automatically) input data
36244 #line 3673
36245   *     to output
36246 #line 3673
36247   *   - update tp to point at next unconverted input, and xpp to point
36248 #line 3673
36249   *     at next location for converted output
36250 #line 3673
36251   */
36252 #line 3673
36253   long i, j, ni;
36254 #line 3673
36255   int64 tmp[LOOPCNT];        /* in case input is misaligned */
36256 #line 3673
36257   int64 *xp;
36258 #line 3673
36259   int nrange = 0;         /* number of range errors */
36260 #line 3673
36261   int realign = 0;        /* "do we need to fix input data alignment?" */
36262 #line 3673
36263   long cxp = (long) *((char**)xpp);
36264 #line 3673
36265 
36266 #line 3673
36267   realign = (cxp & 7) % SIZEOF_INT64;
36268 #line 3673
36269   /* sjl: manually stripmine so we can limit amount of
36270 #line 3673
36271    * vector work space reserved to LOOPCNT elements. Also
36272 #line 3673
36273    * makes vectorisation easy */
36274 #line 3673
36275   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
36276 #line 3673
36277     ni=Min(nelems-j,LOOPCNT);
36278 #line 3673
36279     if (realign) {
36280 #line 3673
36281       xp = tmp;
36282 #line 3673
36283     } else {
36284 #line 3673
36285       xp = (int64 *) *xpp;
36286 #line 3673
36287     }
36288 #line 3673
36289    /* copy the next block */
36290 #line 3673
36291 #pragma cdir loopcnt=LOOPCNT
36292 #line 3673
36293 #pragma cdir shortloop
36294 #line 3673
36295     for (i=0; i<ni; i++) {
36296 #line 3673
36297       /* the normal case: */
36298 #line 3673
36299       xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
36300 #line 3673
36301      /* test for range errors (not always needed but do it anyway) */
36302 #line 3673
36303      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
36304 #line 3673
36305      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
36306 #line 3673
36307       nrange += tp[i] > X_INT64_MAX ;
36308 #line 3673
36309     }
36310 #line 3673
36311    /* copy workspace back if necessary */
36312 #line 3673
36313     if (realign) {
36314 #line 3673
36315       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
36316 #line 3673
36317       xp = (int64 *) *xpp;
36318 #line 3673
36319     }
36320 #line 3673
36321    /* update xpp and tp */
36322 #line 3673
36323     xp += ni;
36324 #line 3673
36325     tp += ni;
36326 #line 3673
36327     *xpp = (void*)xp;
36328 #line 3673
36329   }
36330 #line 3673
36331   return nrange == 0 ? NC_NOERR : NC_ERANGE;
36332 #line 3673
36333 
36334 #line 3673
36335 #else   /* not SX */
36336 #line 3673
36337 
36338 #line 3673
36339 	char *xp = (char *) *xpp;
36340 #line 3673
36341 	int status = NC_NOERR;
36342 #line 3673
36343 
36344 #line 3673
36345 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
36346 #line 3673
36347 	{
36348 #line 3673
36349 		int lstatus = ncx_put_longlong_ulonglong(xp, tp, fillp);
36350 #line 3673
36351 		if (status == NC_NOERR) /* report the first encountered error */
36352 #line 3673
36353 			status = lstatus;
36354 #line 3673
36355 	}
36356 #line 3673
36357 
36358 #line 3673
36359 	*xpp = (void *)xp;
36360 #line 3673
36361 	return status;
36362 #line 3673
36363 #endif
36364 #line 3673
36365 }
36366 #line 3673
36367 
36368 
36369 /* uint64 --------------------------------------------------------------------*/
36370 
36371 #if X_SIZEOF_UINT64 == SIZEOF_ULONGLONG
36372 /* optimized version */
36373 int
ncx_getn_ulonglong_ulonglong(const void ** xpp,size_t nelems,unsigned long long * tp)36374 ncx_getn_ulonglong_ulonglong(const void **xpp, size_t nelems, unsigned long long *tp)
36375 {
36376 #ifdef WORDS_BIGENDIAN
36377 	(void) memcpy(tp, *xpp, (size_t)nelems * SIZEOF_UNSIGNED_LONG_LONG);
36378 # else
36379 	swapn8b(tp, *xpp, nelems);
36380 # endif
36381 	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_UINT64);
36382 	return NC_NOERR;
36383 }
36384 #else
36385 int
36386 #line 3691
ncx_getn_ulonglong_ulonglong(const void ** xpp,size_t nelems,ulonglong * tp)36387 ncx_getn_ulonglong_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
36388 #line 3691
36389 {
36390 #line 3691
36391 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
36392 #line 3691
36393 
36394 #line 3691
36395  /* basic algorithm is:
36396 #line 3691
36397   *   - ensure sane alignment of input data
36398 #line 3691
36399   *   - copy (conversion happens automatically) input data
36400 #line 3691
36401   *     to output
36402 #line 3691
36403   *   - update xpp to point at next unconverted input, and tp to point
36404 #line 3691
36405   *     at next location for converted output
36406 #line 3691
36407   */
36408 #line 3691
36409   long i, j, ni;
36410 #line 3691
36411   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
36412 #line 3691
36413   uint64 *xp;
36414 #line 3691
36415   int nrange = 0;         /* number of range errors */
36416 #line 3691
36417   int realign = 0;        /* "do we need to fix input data alignment?" */
36418 #line 3691
36419   long cxp = (long) *((char**)xpp);
36420 #line 3691
36421 
36422 #line 3691
36423   realign = (cxp & 7) % SIZEOF_UINT64;
36424 #line 3691
36425   /* sjl: manually stripmine so we can limit amount of
36426 #line 3691
36427    * vector work space reserved to LOOPCNT elements. Also
36428 #line 3691
36429    * makes vectorisation easy */
36430 #line 3691
36431   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
36432 #line 3691
36433     ni=Min(nelems-j,LOOPCNT);
36434 #line 3691
36435     if (realign) {
36436 #line 3691
36437       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
36438 #line 3691
36439       xp = tmp;
36440 #line 3691
36441     } else {
36442 #line 3691
36443       xp = (uint64 *) *xpp;
36444 #line 3691
36445     }
36446 #line 3691
36447    /* copy the next block */
36448 #line 3691
36449 #pragma cdir loopcnt=LOOPCNT
36450 #line 3691
36451 #pragma cdir shortloop
36452 #line 3691
36453     for (i=0; i<ni; i++) {
36454 #line 3691
36455       tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
36456 #line 3691
36457      /* test for range errors (not always needed but do it anyway) */
36458 #line 3691
36459      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
36460 #line 3691
36461      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
36462 #line 3691
36463       nrange += xp[i] > ULONGLONG_MAX ;
36464 #line 3691
36465     }
36466 #line 3691
36467    /* update xpp and tp */
36468 #line 3691
36469     if (realign) xp = (uint64 *) *xpp;
36470 #line 3691
36471     xp += ni;
36472 #line 3691
36473     tp += ni;
36474 #line 3691
36475     *xpp = (void*)xp;
36476 #line 3691
36477   }
36478 #line 3691
36479   return nrange == 0 ? NC_NOERR : NC_ERANGE;
36480 #line 3691
36481 
36482 #line 3691
36483 #else   /* not SX */
36484 #line 3691
36485 	const char *xp = (const char *) *xpp;
36486 #line 3691
36487 	int status = NC_NOERR;
36488 #line 3691
36489 
36490 #line 3691
36491 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
36492 #line 3691
36493 	{
36494 #line 3691
36495 		const int lstatus = ncx_get_ulonglong_ulonglong(xp, tp);
36496 #line 3691
36497 		if (status == NC_NOERR) /* report the first encountered error */
36498 #line 3691
36499 			status = lstatus;
36500 #line 3691
36501 	}
36502 #line 3691
36503 
36504 #line 3691
36505 	*xpp = (const void *)xp;
36506 #line 3691
36507 	return status;
36508 #line 3691
36509 #endif
36510 #line 3691
36511 }
36512 #line 3691
36513 
36514 #endif
36515 int
36516 #line 3693
ncx_getn_ulonglong_schar(const void ** xpp,size_t nelems,schar * tp)36517 ncx_getn_ulonglong_schar(const void **xpp, size_t nelems, schar *tp)
36518 #line 3693
36519 {
36520 #line 3693
36521 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
36522 #line 3693
36523 
36524 #line 3693
36525  /* basic algorithm is:
36526 #line 3693
36527   *   - ensure sane alignment of input data
36528 #line 3693
36529   *   - copy (conversion happens automatically) input data
36530 #line 3693
36531   *     to output
36532 #line 3693
36533   *   - update xpp to point at next unconverted input, and tp to point
36534 #line 3693
36535   *     at next location for converted output
36536 #line 3693
36537   */
36538 #line 3693
36539   long i, j, ni;
36540 #line 3693
36541   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
36542 #line 3693
36543   uint64 *xp;
36544 #line 3693
36545   int nrange = 0;         /* number of range errors */
36546 #line 3693
36547   int realign = 0;        /* "do we need to fix input data alignment?" */
36548 #line 3693
36549   long cxp = (long) *((char**)xpp);
36550 #line 3693
36551 
36552 #line 3693
36553   realign = (cxp & 7) % SIZEOF_UINT64;
36554 #line 3693
36555   /* sjl: manually stripmine so we can limit amount of
36556 #line 3693
36557    * vector work space reserved to LOOPCNT elements. Also
36558 #line 3693
36559    * makes vectorisation easy */
36560 #line 3693
36561   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
36562 #line 3693
36563     ni=Min(nelems-j,LOOPCNT);
36564 #line 3693
36565     if (realign) {
36566 #line 3693
36567       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
36568 #line 3693
36569       xp = tmp;
36570 #line 3693
36571     } else {
36572 #line 3693
36573       xp = (uint64 *) *xpp;
36574 #line 3693
36575     }
36576 #line 3693
36577    /* copy the next block */
36578 #line 3693
36579 #pragma cdir loopcnt=LOOPCNT
36580 #line 3693
36581 #pragma cdir shortloop
36582 #line 3693
36583     for (i=0; i<ni; i++) {
36584 #line 3693
36585       tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
36586 #line 3693
36587      /* test for range errors (not always needed but do it anyway) */
36588 #line 3693
36589      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
36590 #line 3693
36591      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
36592 #line 3693
36593       nrange += xp[i] > SCHAR_MAX ;
36594 #line 3693
36595     }
36596 #line 3693
36597    /* update xpp and tp */
36598 #line 3693
36599     if (realign) xp = (uint64 *) *xpp;
36600 #line 3693
36601     xp += ni;
36602 #line 3693
36603     tp += ni;
36604 #line 3693
36605     *xpp = (void*)xp;
36606 #line 3693
36607   }
36608 #line 3693
36609   return nrange == 0 ? NC_NOERR : NC_ERANGE;
36610 #line 3693
36611 
36612 #line 3693
36613 #else   /* not SX */
36614 #line 3693
36615 	const char *xp = (const char *) *xpp;
36616 #line 3693
36617 	int status = NC_NOERR;
36618 #line 3693
36619 
36620 #line 3693
36621 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
36622 #line 3693
36623 	{
36624 #line 3693
36625 		const int lstatus = ncx_get_ulonglong_schar(xp, tp);
36626 #line 3693
36627 		if (status == NC_NOERR) /* report the first encountered error */
36628 #line 3693
36629 			status = lstatus;
36630 #line 3693
36631 	}
36632 #line 3693
36633 
36634 #line 3693
36635 	*xpp = (const void *)xp;
36636 #line 3693
36637 	return status;
36638 #line 3693
36639 #endif
36640 #line 3693
36641 }
36642 #line 3693
36643 
36644 int
36645 #line 3694
ncx_getn_ulonglong_short(const void ** xpp,size_t nelems,short * tp)36646 ncx_getn_ulonglong_short(const void **xpp, size_t nelems, short *tp)
36647 #line 3694
36648 {
36649 #line 3694
36650 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
36651 #line 3694
36652 
36653 #line 3694
36654  /* basic algorithm is:
36655 #line 3694
36656   *   - ensure sane alignment of input data
36657 #line 3694
36658   *   - copy (conversion happens automatically) input data
36659 #line 3694
36660   *     to output
36661 #line 3694
36662   *   - update xpp to point at next unconverted input, and tp to point
36663 #line 3694
36664   *     at next location for converted output
36665 #line 3694
36666   */
36667 #line 3694
36668   long i, j, ni;
36669 #line 3694
36670   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
36671 #line 3694
36672   uint64 *xp;
36673 #line 3694
36674   int nrange = 0;         /* number of range errors */
36675 #line 3694
36676   int realign = 0;        /* "do we need to fix input data alignment?" */
36677 #line 3694
36678   long cxp = (long) *((char**)xpp);
36679 #line 3694
36680 
36681 #line 3694
36682   realign = (cxp & 7) % SIZEOF_UINT64;
36683 #line 3694
36684   /* sjl: manually stripmine so we can limit amount of
36685 #line 3694
36686    * vector work space reserved to LOOPCNT elements. Also
36687 #line 3694
36688    * makes vectorisation easy */
36689 #line 3694
36690   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
36691 #line 3694
36692     ni=Min(nelems-j,LOOPCNT);
36693 #line 3694
36694     if (realign) {
36695 #line 3694
36696       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
36697 #line 3694
36698       xp = tmp;
36699 #line 3694
36700     } else {
36701 #line 3694
36702       xp = (uint64 *) *xpp;
36703 #line 3694
36704     }
36705 #line 3694
36706    /* copy the next block */
36707 #line 3694
36708 #pragma cdir loopcnt=LOOPCNT
36709 #line 3694
36710 #pragma cdir shortloop
36711 #line 3694
36712     for (i=0; i<ni; i++) {
36713 #line 3694
36714       tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
36715 #line 3694
36716      /* test for range errors (not always needed but do it anyway) */
36717 #line 3694
36718      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
36719 #line 3694
36720      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
36721 #line 3694
36722       nrange += xp[i] > SHORT_MAX ;
36723 #line 3694
36724     }
36725 #line 3694
36726    /* update xpp and tp */
36727 #line 3694
36728     if (realign) xp = (uint64 *) *xpp;
36729 #line 3694
36730     xp += ni;
36731 #line 3694
36732     tp += ni;
36733 #line 3694
36734     *xpp = (void*)xp;
36735 #line 3694
36736   }
36737 #line 3694
36738   return nrange == 0 ? NC_NOERR : NC_ERANGE;
36739 #line 3694
36740 
36741 #line 3694
36742 #else   /* not SX */
36743 #line 3694
36744 	const char *xp = (const char *) *xpp;
36745 #line 3694
36746 	int status = NC_NOERR;
36747 #line 3694
36748 
36749 #line 3694
36750 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
36751 #line 3694
36752 	{
36753 #line 3694
36754 		const int lstatus = ncx_get_ulonglong_short(xp, tp);
36755 #line 3694
36756 		if (status == NC_NOERR) /* report the first encountered error */
36757 #line 3694
36758 			status = lstatus;
36759 #line 3694
36760 	}
36761 #line 3694
36762 
36763 #line 3694
36764 	*xpp = (const void *)xp;
36765 #line 3694
36766 	return status;
36767 #line 3694
36768 #endif
36769 #line 3694
36770 }
36771 #line 3694
36772 
36773 int
36774 #line 3695
ncx_getn_ulonglong_int(const void ** xpp,size_t nelems,int * tp)36775 ncx_getn_ulonglong_int(const void **xpp, size_t nelems, int *tp)
36776 #line 3695
36777 {
36778 #line 3695
36779 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
36780 #line 3695
36781 
36782 #line 3695
36783  /* basic algorithm is:
36784 #line 3695
36785   *   - ensure sane alignment of input data
36786 #line 3695
36787   *   - copy (conversion happens automatically) input data
36788 #line 3695
36789   *     to output
36790 #line 3695
36791   *   - update xpp to point at next unconverted input, and tp to point
36792 #line 3695
36793   *     at next location for converted output
36794 #line 3695
36795   */
36796 #line 3695
36797   long i, j, ni;
36798 #line 3695
36799   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
36800 #line 3695
36801   uint64 *xp;
36802 #line 3695
36803   int nrange = 0;         /* number of range errors */
36804 #line 3695
36805   int realign = 0;        /* "do we need to fix input data alignment?" */
36806 #line 3695
36807   long cxp = (long) *((char**)xpp);
36808 #line 3695
36809 
36810 #line 3695
36811   realign = (cxp & 7) % SIZEOF_UINT64;
36812 #line 3695
36813   /* sjl: manually stripmine so we can limit amount of
36814 #line 3695
36815    * vector work space reserved to LOOPCNT elements. Also
36816 #line 3695
36817    * makes vectorisation easy */
36818 #line 3695
36819   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
36820 #line 3695
36821     ni=Min(nelems-j,LOOPCNT);
36822 #line 3695
36823     if (realign) {
36824 #line 3695
36825       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
36826 #line 3695
36827       xp = tmp;
36828 #line 3695
36829     } else {
36830 #line 3695
36831       xp = (uint64 *) *xpp;
36832 #line 3695
36833     }
36834 #line 3695
36835    /* copy the next block */
36836 #line 3695
36837 #pragma cdir loopcnt=LOOPCNT
36838 #line 3695
36839 #pragma cdir shortloop
36840 #line 3695
36841     for (i=0; i<ni; i++) {
36842 #line 3695
36843       tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
36844 #line 3695
36845      /* test for range errors (not always needed but do it anyway) */
36846 #line 3695
36847      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
36848 #line 3695
36849      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
36850 #line 3695
36851       nrange += xp[i] > INT_MAX ;
36852 #line 3695
36853     }
36854 #line 3695
36855    /* update xpp and tp */
36856 #line 3695
36857     if (realign) xp = (uint64 *) *xpp;
36858 #line 3695
36859     xp += ni;
36860 #line 3695
36861     tp += ni;
36862 #line 3695
36863     *xpp = (void*)xp;
36864 #line 3695
36865   }
36866 #line 3695
36867   return nrange == 0 ? NC_NOERR : NC_ERANGE;
36868 #line 3695
36869 
36870 #line 3695
36871 #else   /* not SX */
36872 #line 3695
36873 	const char *xp = (const char *) *xpp;
36874 #line 3695
36875 	int status = NC_NOERR;
36876 #line 3695
36877 
36878 #line 3695
36879 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
36880 #line 3695
36881 	{
36882 #line 3695
36883 		const int lstatus = ncx_get_ulonglong_int(xp, tp);
36884 #line 3695
36885 		if (status == NC_NOERR) /* report the first encountered error */
36886 #line 3695
36887 			status = lstatus;
36888 #line 3695
36889 	}
36890 #line 3695
36891 
36892 #line 3695
36893 	*xpp = (const void *)xp;
36894 #line 3695
36895 	return status;
36896 #line 3695
36897 #endif
36898 #line 3695
36899 }
36900 #line 3695
36901 
36902 int
36903 #line 3696
ncx_getn_ulonglong_long(const void ** xpp,size_t nelems,long * tp)36904 ncx_getn_ulonglong_long(const void **xpp, size_t nelems, long *tp)
36905 #line 3696
36906 {
36907 #line 3696
36908 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
36909 #line 3696
36910 
36911 #line 3696
36912  /* basic algorithm is:
36913 #line 3696
36914   *   - ensure sane alignment of input data
36915 #line 3696
36916   *   - copy (conversion happens automatically) input data
36917 #line 3696
36918   *     to output
36919 #line 3696
36920   *   - update xpp to point at next unconverted input, and tp to point
36921 #line 3696
36922   *     at next location for converted output
36923 #line 3696
36924   */
36925 #line 3696
36926   long i, j, ni;
36927 #line 3696
36928   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
36929 #line 3696
36930   uint64 *xp;
36931 #line 3696
36932   int nrange = 0;         /* number of range errors */
36933 #line 3696
36934   int realign = 0;        /* "do we need to fix input data alignment?" */
36935 #line 3696
36936   long cxp = (long) *((char**)xpp);
36937 #line 3696
36938 
36939 #line 3696
36940   realign = (cxp & 7) % SIZEOF_UINT64;
36941 #line 3696
36942   /* sjl: manually stripmine so we can limit amount of
36943 #line 3696
36944    * vector work space reserved to LOOPCNT elements. Also
36945 #line 3696
36946    * makes vectorisation easy */
36947 #line 3696
36948   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
36949 #line 3696
36950     ni=Min(nelems-j,LOOPCNT);
36951 #line 3696
36952     if (realign) {
36953 #line 3696
36954       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
36955 #line 3696
36956       xp = tmp;
36957 #line 3696
36958     } else {
36959 #line 3696
36960       xp = (uint64 *) *xpp;
36961 #line 3696
36962     }
36963 #line 3696
36964    /* copy the next block */
36965 #line 3696
36966 #pragma cdir loopcnt=LOOPCNT
36967 #line 3696
36968 #pragma cdir shortloop
36969 #line 3696
36970     for (i=0; i<ni; i++) {
36971 #line 3696
36972       tp[i] = (long) Max( LONG_MIN, Min(LONG_MAX, (long) xp[i]));
36973 #line 3696
36974      /* test for range errors (not always needed but do it anyway) */
36975 #line 3696
36976      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
36977 #line 3696
36978      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
36979 #line 3696
36980       nrange += xp[i] > LONG_MAX ;
36981 #line 3696
36982     }
36983 #line 3696
36984    /* update xpp and tp */
36985 #line 3696
36986     if (realign) xp = (uint64 *) *xpp;
36987 #line 3696
36988     xp += ni;
36989 #line 3696
36990     tp += ni;
36991 #line 3696
36992     *xpp = (void*)xp;
36993 #line 3696
36994   }
36995 #line 3696
36996   return nrange == 0 ? NC_NOERR : NC_ERANGE;
36997 #line 3696
36998 
36999 #line 3696
37000 #else   /* not SX */
37001 #line 3696
37002 	const char *xp = (const char *) *xpp;
37003 #line 3696
37004 	int status = NC_NOERR;
37005 #line 3696
37006 
37007 #line 3696
37008 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
37009 #line 3696
37010 	{
37011 #line 3696
37012 		const int lstatus = ncx_get_ulonglong_long(xp, tp);
37013 #line 3696
37014 		if (status == NC_NOERR) /* report the first encountered error */
37015 #line 3696
37016 			status = lstatus;
37017 #line 3696
37018 	}
37019 #line 3696
37020 
37021 #line 3696
37022 	*xpp = (const void *)xp;
37023 #line 3696
37024 	return status;
37025 #line 3696
37026 #endif
37027 #line 3696
37028 }
37029 #line 3696
37030 
37031 int
37032 #line 3697
ncx_getn_ulonglong_float(const void ** xpp,size_t nelems,float * tp)37033 ncx_getn_ulonglong_float(const void **xpp, size_t nelems, float *tp)
37034 #line 3697
37035 {
37036 #line 3697
37037 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
37038 #line 3697
37039 
37040 #line 3697
37041  /* basic algorithm is:
37042 #line 3697
37043   *   - ensure sane alignment of input data
37044 #line 3697
37045   *   - copy (conversion happens automatically) input data
37046 #line 3697
37047   *     to output
37048 #line 3697
37049   *   - update xpp to point at next unconverted input, and tp to point
37050 #line 3697
37051   *     at next location for converted output
37052 #line 3697
37053   */
37054 #line 3697
37055   long i, j, ni;
37056 #line 3697
37057   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
37058 #line 3697
37059   uint64 *xp;
37060 #line 3697
37061   int nrange = 0;         /* number of range errors */
37062 #line 3697
37063   int realign = 0;        /* "do we need to fix input data alignment?" */
37064 #line 3697
37065   long cxp = (long) *((char**)xpp);
37066 #line 3697
37067 
37068 #line 3697
37069   realign = (cxp & 7) % SIZEOF_UINT64;
37070 #line 3697
37071   /* sjl: manually stripmine so we can limit amount of
37072 #line 3697
37073    * vector work space reserved to LOOPCNT elements. Also
37074 #line 3697
37075    * makes vectorisation easy */
37076 #line 3697
37077   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
37078 #line 3697
37079     ni=Min(nelems-j,LOOPCNT);
37080 #line 3697
37081     if (realign) {
37082 #line 3697
37083       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
37084 #line 3697
37085       xp = tmp;
37086 #line 3697
37087     } else {
37088 #line 3697
37089       xp = (uint64 *) *xpp;
37090 #line 3697
37091     }
37092 #line 3697
37093    /* copy the next block */
37094 #line 3697
37095 #pragma cdir loopcnt=LOOPCNT
37096 #line 3697
37097 #pragma cdir shortloop
37098 #line 3697
37099     for (i=0; i<ni; i++) {
37100 #line 3697
37101       tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
37102 #line 3697
37103      /* test for range errors (not always needed but do it anyway) */
37104 #line 3697
37105      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
37106 #line 3697
37107      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
37108 #line 3697
37109       nrange += xp[i] > FLOAT_MAX ;
37110 #line 3697
37111     }
37112 #line 3697
37113    /* update xpp and tp */
37114 #line 3697
37115     if (realign) xp = (uint64 *) *xpp;
37116 #line 3697
37117     xp += ni;
37118 #line 3697
37119     tp += ni;
37120 #line 3697
37121     *xpp = (void*)xp;
37122 #line 3697
37123   }
37124 #line 3697
37125   return nrange == 0 ? NC_NOERR : NC_ERANGE;
37126 #line 3697
37127 
37128 #line 3697
37129 #else   /* not SX */
37130 #line 3697
37131 	const char *xp = (const char *) *xpp;
37132 #line 3697
37133 	int status = NC_NOERR;
37134 #line 3697
37135 
37136 #line 3697
37137 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
37138 #line 3697
37139 	{
37140 #line 3697
37141 		const int lstatus = ncx_get_ulonglong_float(xp, tp);
37142 #line 3697
37143 		if (status == NC_NOERR) /* report the first encountered error */
37144 #line 3697
37145 			status = lstatus;
37146 #line 3697
37147 	}
37148 #line 3697
37149 
37150 #line 3697
37151 	*xpp = (const void *)xp;
37152 #line 3697
37153 	return status;
37154 #line 3697
37155 #endif
37156 #line 3697
37157 }
37158 #line 3697
37159 
37160 int
37161 #line 3698
ncx_getn_ulonglong_double(const void ** xpp,size_t nelems,double * tp)37162 ncx_getn_ulonglong_double(const void **xpp, size_t nelems, double *tp)
37163 #line 3698
37164 {
37165 #line 3698
37166 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
37167 #line 3698
37168 
37169 #line 3698
37170  /* basic algorithm is:
37171 #line 3698
37172   *   - ensure sane alignment of input data
37173 #line 3698
37174   *   - copy (conversion happens automatically) input data
37175 #line 3698
37176   *     to output
37177 #line 3698
37178   *   - update xpp to point at next unconverted input, and tp to point
37179 #line 3698
37180   *     at next location for converted output
37181 #line 3698
37182   */
37183 #line 3698
37184   long i, j, ni;
37185 #line 3698
37186   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
37187 #line 3698
37188   uint64 *xp;
37189 #line 3698
37190   int nrange = 0;         /* number of range errors */
37191 #line 3698
37192   int realign = 0;        /* "do we need to fix input data alignment?" */
37193 #line 3698
37194   long cxp = (long) *((char**)xpp);
37195 #line 3698
37196 
37197 #line 3698
37198   realign = (cxp & 7) % SIZEOF_UINT64;
37199 #line 3698
37200   /* sjl: manually stripmine so we can limit amount of
37201 #line 3698
37202    * vector work space reserved to LOOPCNT elements. Also
37203 #line 3698
37204    * makes vectorisation easy */
37205 #line 3698
37206   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
37207 #line 3698
37208     ni=Min(nelems-j,LOOPCNT);
37209 #line 3698
37210     if (realign) {
37211 #line 3698
37212       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
37213 #line 3698
37214       xp = tmp;
37215 #line 3698
37216     } else {
37217 #line 3698
37218       xp = (uint64 *) *xpp;
37219 #line 3698
37220     }
37221 #line 3698
37222    /* copy the next block */
37223 #line 3698
37224 #pragma cdir loopcnt=LOOPCNT
37225 #line 3698
37226 #pragma cdir shortloop
37227 #line 3698
37228     for (i=0; i<ni; i++) {
37229 #line 3698
37230       tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
37231 #line 3698
37232      /* test for range errors (not always needed but do it anyway) */
37233 #line 3698
37234      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
37235 #line 3698
37236      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
37237 #line 3698
37238       nrange += xp[i] > DOUBLE_MAX ;
37239 #line 3698
37240     }
37241 #line 3698
37242    /* update xpp and tp */
37243 #line 3698
37244     if (realign) xp = (uint64 *) *xpp;
37245 #line 3698
37246     xp += ni;
37247 #line 3698
37248     tp += ni;
37249 #line 3698
37250     *xpp = (void*)xp;
37251 #line 3698
37252   }
37253 #line 3698
37254   return nrange == 0 ? NC_NOERR : NC_ERANGE;
37255 #line 3698
37256 
37257 #line 3698
37258 #else   /* not SX */
37259 #line 3698
37260 	const char *xp = (const char *) *xpp;
37261 #line 3698
37262 	int status = NC_NOERR;
37263 #line 3698
37264 
37265 #line 3698
37266 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
37267 #line 3698
37268 	{
37269 #line 3698
37270 		const int lstatus = ncx_get_ulonglong_double(xp, tp);
37271 #line 3698
37272 		if (status == NC_NOERR) /* report the first encountered error */
37273 #line 3698
37274 			status = lstatus;
37275 #line 3698
37276 	}
37277 #line 3698
37278 
37279 #line 3698
37280 	*xpp = (const void *)xp;
37281 #line 3698
37282 	return status;
37283 #line 3698
37284 #endif
37285 #line 3698
37286 }
37287 #line 3698
37288 
37289 int
37290 #line 3699
ncx_getn_ulonglong_longlong(const void ** xpp,size_t nelems,longlong * tp)37291 ncx_getn_ulonglong_longlong(const void **xpp, size_t nelems, longlong *tp)
37292 #line 3699
37293 {
37294 #line 3699
37295 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
37296 #line 3699
37297 
37298 #line 3699
37299  /* basic algorithm is:
37300 #line 3699
37301   *   - ensure sane alignment of input data
37302 #line 3699
37303   *   - copy (conversion happens automatically) input data
37304 #line 3699
37305   *     to output
37306 #line 3699
37307   *   - update xpp to point at next unconverted input, and tp to point
37308 #line 3699
37309   *     at next location for converted output
37310 #line 3699
37311   */
37312 #line 3699
37313   long i, j, ni;
37314 #line 3699
37315   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
37316 #line 3699
37317   uint64 *xp;
37318 #line 3699
37319   int nrange = 0;         /* number of range errors */
37320 #line 3699
37321   int realign = 0;        /* "do we need to fix input data alignment?" */
37322 #line 3699
37323   long cxp = (long) *((char**)xpp);
37324 #line 3699
37325 
37326 #line 3699
37327   realign = (cxp & 7) % SIZEOF_UINT64;
37328 #line 3699
37329   /* sjl: manually stripmine so we can limit amount of
37330 #line 3699
37331    * vector work space reserved to LOOPCNT elements. Also
37332 #line 3699
37333    * makes vectorisation easy */
37334 #line 3699
37335   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
37336 #line 3699
37337     ni=Min(nelems-j,LOOPCNT);
37338 #line 3699
37339     if (realign) {
37340 #line 3699
37341       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
37342 #line 3699
37343       xp = tmp;
37344 #line 3699
37345     } else {
37346 #line 3699
37347       xp = (uint64 *) *xpp;
37348 #line 3699
37349     }
37350 #line 3699
37351    /* copy the next block */
37352 #line 3699
37353 #pragma cdir loopcnt=LOOPCNT
37354 #line 3699
37355 #pragma cdir shortloop
37356 #line 3699
37357     for (i=0; i<ni; i++) {
37358 #line 3699
37359       tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
37360 #line 3699
37361      /* test for range errors (not always needed but do it anyway) */
37362 #line 3699
37363      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
37364 #line 3699
37365      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
37366 #line 3699
37367       nrange += xp[i] > LONGLONG_MAX ;
37368 #line 3699
37369     }
37370 #line 3699
37371    /* update xpp and tp */
37372 #line 3699
37373     if (realign) xp = (uint64 *) *xpp;
37374 #line 3699
37375     xp += ni;
37376 #line 3699
37377     tp += ni;
37378 #line 3699
37379     *xpp = (void*)xp;
37380 #line 3699
37381   }
37382 #line 3699
37383   return nrange == 0 ? NC_NOERR : NC_ERANGE;
37384 #line 3699
37385 
37386 #line 3699
37387 #else   /* not SX */
37388 #line 3699
37389 	const char *xp = (const char *) *xpp;
37390 #line 3699
37391 	int status = NC_NOERR;
37392 #line 3699
37393 
37394 #line 3699
37395 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
37396 #line 3699
37397 	{
37398 #line 3699
37399 		const int lstatus = ncx_get_ulonglong_longlong(xp, tp);
37400 #line 3699
37401 		if (status == NC_NOERR) /* report the first encountered error */
37402 #line 3699
37403 			status = lstatus;
37404 #line 3699
37405 	}
37406 #line 3699
37407 
37408 #line 3699
37409 	*xpp = (const void *)xp;
37410 #line 3699
37411 	return status;
37412 #line 3699
37413 #endif
37414 #line 3699
37415 }
37416 #line 3699
37417 
37418 int
37419 #line 3700
ncx_getn_ulonglong_uchar(const void ** xpp,size_t nelems,uchar * tp)37420 ncx_getn_ulonglong_uchar(const void **xpp, size_t nelems, uchar *tp)
37421 #line 3700
37422 {
37423 #line 3700
37424 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
37425 #line 3700
37426 
37427 #line 3700
37428  /* basic algorithm is:
37429 #line 3700
37430   *   - ensure sane alignment of input data
37431 #line 3700
37432   *   - copy (conversion happens automatically) input data
37433 #line 3700
37434   *     to output
37435 #line 3700
37436   *   - update xpp to point at next unconverted input, and tp to point
37437 #line 3700
37438   *     at next location for converted output
37439 #line 3700
37440   */
37441 #line 3700
37442   long i, j, ni;
37443 #line 3700
37444   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
37445 #line 3700
37446   uint64 *xp;
37447 #line 3700
37448   int nrange = 0;         /* number of range errors */
37449 #line 3700
37450   int realign = 0;        /* "do we need to fix input data alignment?" */
37451 #line 3700
37452   long cxp = (long) *((char**)xpp);
37453 #line 3700
37454 
37455 #line 3700
37456   realign = (cxp & 7) % SIZEOF_UINT64;
37457 #line 3700
37458   /* sjl: manually stripmine so we can limit amount of
37459 #line 3700
37460    * vector work space reserved to LOOPCNT elements. Also
37461 #line 3700
37462    * makes vectorisation easy */
37463 #line 3700
37464   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
37465 #line 3700
37466     ni=Min(nelems-j,LOOPCNT);
37467 #line 3700
37468     if (realign) {
37469 #line 3700
37470       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
37471 #line 3700
37472       xp = tmp;
37473 #line 3700
37474     } else {
37475 #line 3700
37476       xp = (uint64 *) *xpp;
37477 #line 3700
37478     }
37479 #line 3700
37480    /* copy the next block */
37481 #line 3700
37482 #pragma cdir loopcnt=LOOPCNT
37483 #line 3700
37484 #pragma cdir shortloop
37485 #line 3700
37486     for (i=0; i<ni; i++) {
37487 #line 3700
37488       tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
37489 #line 3700
37490      /* test for range errors (not always needed but do it anyway) */
37491 #line 3700
37492      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
37493 #line 3700
37494      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
37495 #line 3700
37496       nrange += xp[i] > UCHAR_MAX ;
37497 #line 3700
37498     }
37499 #line 3700
37500    /* update xpp and tp */
37501 #line 3700
37502     if (realign) xp = (uint64 *) *xpp;
37503 #line 3700
37504     xp += ni;
37505 #line 3700
37506     tp += ni;
37507 #line 3700
37508     *xpp = (void*)xp;
37509 #line 3700
37510   }
37511 #line 3700
37512   return nrange == 0 ? NC_NOERR : NC_ERANGE;
37513 #line 3700
37514 
37515 #line 3700
37516 #else   /* not SX */
37517 #line 3700
37518 	const char *xp = (const char *) *xpp;
37519 #line 3700
37520 	int status = NC_NOERR;
37521 #line 3700
37522 
37523 #line 3700
37524 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
37525 #line 3700
37526 	{
37527 #line 3700
37528 		const int lstatus = ncx_get_ulonglong_uchar(xp, tp);
37529 #line 3700
37530 		if (status == NC_NOERR) /* report the first encountered error */
37531 #line 3700
37532 			status = lstatus;
37533 #line 3700
37534 	}
37535 #line 3700
37536 
37537 #line 3700
37538 	*xpp = (const void *)xp;
37539 #line 3700
37540 	return status;
37541 #line 3700
37542 #endif
37543 #line 3700
37544 }
37545 #line 3700
37546 
37547 int
37548 #line 3701
ncx_getn_ulonglong_ushort(const void ** xpp,size_t nelems,ushort * tp)37549 ncx_getn_ulonglong_ushort(const void **xpp, size_t nelems, ushort *tp)
37550 #line 3701
37551 {
37552 #line 3701
37553 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
37554 #line 3701
37555 
37556 #line 3701
37557  /* basic algorithm is:
37558 #line 3701
37559   *   - ensure sane alignment of input data
37560 #line 3701
37561   *   - copy (conversion happens automatically) input data
37562 #line 3701
37563   *     to output
37564 #line 3701
37565   *   - update xpp to point at next unconverted input, and tp to point
37566 #line 3701
37567   *     at next location for converted output
37568 #line 3701
37569   */
37570 #line 3701
37571   long i, j, ni;
37572 #line 3701
37573   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
37574 #line 3701
37575   uint64 *xp;
37576 #line 3701
37577   int nrange = 0;         /* number of range errors */
37578 #line 3701
37579   int realign = 0;        /* "do we need to fix input data alignment?" */
37580 #line 3701
37581   long cxp = (long) *((char**)xpp);
37582 #line 3701
37583 
37584 #line 3701
37585   realign = (cxp & 7) % SIZEOF_UINT64;
37586 #line 3701
37587   /* sjl: manually stripmine so we can limit amount of
37588 #line 3701
37589    * vector work space reserved to LOOPCNT elements. Also
37590 #line 3701
37591    * makes vectorisation easy */
37592 #line 3701
37593   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
37594 #line 3701
37595     ni=Min(nelems-j,LOOPCNT);
37596 #line 3701
37597     if (realign) {
37598 #line 3701
37599       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
37600 #line 3701
37601       xp = tmp;
37602 #line 3701
37603     } else {
37604 #line 3701
37605       xp = (uint64 *) *xpp;
37606 #line 3701
37607     }
37608 #line 3701
37609    /* copy the next block */
37610 #line 3701
37611 #pragma cdir loopcnt=LOOPCNT
37612 #line 3701
37613 #pragma cdir shortloop
37614 #line 3701
37615     for (i=0; i<ni; i++) {
37616 #line 3701
37617       tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
37618 #line 3701
37619      /* test for range errors (not always needed but do it anyway) */
37620 #line 3701
37621      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
37622 #line 3701
37623      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
37624 #line 3701
37625       nrange += xp[i] > USHORT_MAX ;
37626 #line 3701
37627     }
37628 #line 3701
37629    /* update xpp and tp */
37630 #line 3701
37631     if (realign) xp = (uint64 *) *xpp;
37632 #line 3701
37633     xp += ni;
37634 #line 3701
37635     tp += ni;
37636 #line 3701
37637     *xpp = (void*)xp;
37638 #line 3701
37639   }
37640 #line 3701
37641   return nrange == 0 ? NC_NOERR : NC_ERANGE;
37642 #line 3701
37643 
37644 #line 3701
37645 #else   /* not SX */
37646 #line 3701
37647 	const char *xp = (const char *) *xpp;
37648 #line 3701
37649 	int status = NC_NOERR;
37650 #line 3701
37651 
37652 #line 3701
37653 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
37654 #line 3701
37655 	{
37656 #line 3701
37657 		const int lstatus = ncx_get_ulonglong_ushort(xp, tp);
37658 #line 3701
37659 		if (status == NC_NOERR) /* report the first encountered error */
37660 #line 3701
37661 			status = lstatus;
37662 #line 3701
37663 	}
37664 #line 3701
37665 
37666 #line 3701
37667 	*xpp = (const void *)xp;
37668 #line 3701
37669 	return status;
37670 #line 3701
37671 #endif
37672 #line 3701
37673 }
37674 #line 3701
37675 
37676 int
37677 #line 3702
ncx_getn_ulonglong_uint(const void ** xpp,size_t nelems,uint * tp)37678 ncx_getn_ulonglong_uint(const void **xpp, size_t nelems, uint *tp)
37679 #line 3702
37680 {
37681 #line 3702
37682 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
37683 #line 3702
37684 
37685 #line 3702
37686  /* basic algorithm is:
37687 #line 3702
37688   *   - ensure sane alignment of input data
37689 #line 3702
37690   *   - copy (conversion happens automatically) input data
37691 #line 3702
37692   *     to output
37693 #line 3702
37694   *   - update xpp to point at next unconverted input, and tp to point
37695 #line 3702
37696   *     at next location for converted output
37697 #line 3702
37698   */
37699 #line 3702
37700   long i, j, ni;
37701 #line 3702
37702   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
37703 #line 3702
37704   uint64 *xp;
37705 #line 3702
37706   int nrange = 0;         /* number of range errors */
37707 #line 3702
37708   int realign = 0;        /* "do we need to fix input data alignment?" */
37709 #line 3702
37710   long cxp = (long) *((char**)xpp);
37711 #line 3702
37712 
37713 #line 3702
37714   realign = (cxp & 7) % SIZEOF_UINT64;
37715 #line 3702
37716   /* sjl: manually stripmine so we can limit amount of
37717 #line 3702
37718    * vector work space reserved to LOOPCNT elements. Also
37719 #line 3702
37720    * makes vectorisation easy */
37721 #line 3702
37722   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
37723 #line 3702
37724     ni=Min(nelems-j,LOOPCNT);
37725 #line 3702
37726     if (realign) {
37727 #line 3702
37728       memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
37729 #line 3702
37730       xp = tmp;
37731 #line 3702
37732     } else {
37733 #line 3702
37734       xp = (uint64 *) *xpp;
37735 #line 3702
37736     }
37737 #line 3702
37738    /* copy the next block */
37739 #line 3702
37740 #pragma cdir loopcnt=LOOPCNT
37741 #line 3702
37742 #pragma cdir shortloop
37743 #line 3702
37744     for (i=0; i<ni; i++) {
37745 #line 3702
37746       tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
37747 #line 3702
37748      /* test for range errors (not always needed but do it anyway) */
37749 #line 3702
37750      /* if xpp is unsigned, we need not check if xp[i] < _MIN */
37751 #line 3702
37752      /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
37753 #line 3702
37754       nrange += xp[i] > UINT_MAX ;
37755 #line 3702
37756     }
37757 #line 3702
37758    /* update xpp and tp */
37759 #line 3702
37760     if (realign) xp = (uint64 *) *xpp;
37761 #line 3702
37762     xp += ni;
37763 #line 3702
37764     tp += ni;
37765 #line 3702
37766     *xpp = (void*)xp;
37767 #line 3702
37768   }
37769 #line 3702
37770   return nrange == 0 ? NC_NOERR : NC_ERANGE;
37771 #line 3702
37772 
37773 #line 3702
37774 #else   /* not SX */
37775 #line 3702
37776 	const char *xp = (const char *) *xpp;
37777 #line 3702
37778 	int status = NC_NOERR;
37779 #line 3702
37780 
37781 #line 3702
37782 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
37783 #line 3702
37784 	{
37785 #line 3702
37786 		const int lstatus = ncx_get_ulonglong_uint(xp, tp);
37787 #line 3702
37788 		if (status == NC_NOERR) /* report the first encountered error */
37789 #line 3702
37790 			status = lstatus;
37791 #line 3702
37792 	}
37793 #line 3702
37794 
37795 #line 3702
37796 	*xpp = (const void *)xp;
37797 #line 3702
37798 	return status;
37799 #line 3702
37800 #endif
37801 #line 3702
37802 }
37803 #line 3702
37804 
37805 
37806 #if X_SIZEOF_UINT64 == SIZEOF_ULONGLONG
37807 /* optimized version */
37808 int
ncx_putn_ulonglong_ulonglong(void ** xpp,size_t nelems,const unsigned long long * tp,void * fillp)37809 ncx_putn_ulonglong_ulonglong(void **xpp, size_t nelems, const unsigned long long *tp, void *fillp)
37810 {
37811 #ifdef WORDS_BIGENDIAN
37812 	(void) memcpy(*xpp, tp, (size_t)nelems * X_SIZEOF_UINT64);
37813 # else
37814 	swapn8b(*xpp, tp, nelems);
37815 # endif
37816 	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_UINT64);
37817 	return NC_NOERR;
37818 }
37819 #else
37820 int
37821 #line 3718
ncx_putn_ulonglong_ulonglong(void ** xpp,size_t nelems,const ulonglong * tp,void * fillp)37822 ncx_putn_ulonglong_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
37823 #line 3718
37824 {
37825 #line 3718
37826 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
37827 #line 3718
37828 
37829 #line 3718
37830  /* basic algorithm is:
37831 #line 3718
37832   *   - ensure sane alignment of output data
37833 #line 3718
37834   *   - copy (conversion happens automatically) input data
37835 #line 3718
37836   *     to output
37837 #line 3718
37838   *   - update tp to point at next unconverted input, and xpp to point
37839 #line 3718
37840   *     at next location for converted output
37841 #line 3718
37842   */
37843 #line 3718
37844   long i, j, ni;
37845 #line 3718
37846   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
37847 #line 3718
37848   uint64 *xp;
37849 #line 3718
37850   int nrange = 0;         /* number of range errors */
37851 #line 3718
37852   int realign = 0;        /* "do we need to fix input data alignment?" */
37853 #line 3718
37854   long cxp = (long) *((char**)xpp);
37855 #line 3718
37856 
37857 #line 3718
37858   realign = (cxp & 7) % SIZEOF_UINT64;
37859 #line 3718
37860   /* sjl: manually stripmine so we can limit amount of
37861 #line 3718
37862    * vector work space reserved to LOOPCNT elements. Also
37863 #line 3718
37864    * makes vectorisation easy */
37865 #line 3718
37866   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
37867 #line 3718
37868     ni=Min(nelems-j,LOOPCNT);
37869 #line 3718
37870     if (realign) {
37871 #line 3718
37872       xp = tmp;
37873 #line 3718
37874     } else {
37875 #line 3718
37876       xp = (uint64 *) *xpp;
37877 #line 3718
37878     }
37879 #line 3718
37880    /* copy the next block */
37881 #line 3718
37882 #pragma cdir loopcnt=LOOPCNT
37883 #line 3718
37884 #pragma cdir shortloop
37885 #line 3718
37886     for (i=0; i<ni; i++) {
37887 #line 3718
37888       /* the normal case: */
37889 #line 3718
37890       xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
37891 #line 3718
37892      /* test for range errors (not always needed but do it anyway) */
37893 #line 3718
37894      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
37895 #line 3718
37896      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
37897 #line 3718
37898       nrange += tp[i] > X_UINT64_MAX ;
37899 #line 3718
37900     }
37901 #line 3718
37902    /* copy workspace back if necessary */
37903 #line 3718
37904     if (realign) {
37905 #line 3718
37906       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
37907 #line 3718
37908       xp = (uint64 *) *xpp;
37909 #line 3718
37910     }
37911 #line 3718
37912    /* update xpp and tp */
37913 #line 3718
37914     xp += ni;
37915 #line 3718
37916     tp += ni;
37917 #line 3718
37918     *xpp = (void*)xp;
37919 #line 3718
37920   }
37921 #line 3718
37922   return nrange == 0 ? NC_NOERR : NC_ERANGE;
37923 #line 3718
37924 
37925 #line 3718
37926 #else   /* not SX */
37927 #line 3718
37928 
37929 #line 3718
37930 	char *xp = (char *) *xpp;
37931 #line 3718
37932 	int status = NC_NOERR;
37933 #line 3718
37934 
37935 #line 3718
37936 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
37937 #line 3718
37938 	{
37939 #line 3718
37940 		int lstatus = ncx_put_ulonglong_ulonglong(xp, tp, fillp);
37941 #line 3718
37942 		if (status == NC_NOERR) /* report the first encountered error */
37943 #line 3718
37944 			status = lstatus;
37945 #line 3718
37946 	}
37947 #line 3718
37948 
37949 #line 3718
37950 	*xpp = (void *)xp;
37951 #line 3718
37952 	return status;
37953 #line 3718
37954 #endif
37955 #line 3718
37956 }
37957 #line 3718
37958 
37959 #endif
37960 int
37961 #line 3720
ncx_putn_ulonglong_schar(void ** xpp,size_t nelems,const schar * tp,void * fillp)37962 ncx_putn_ulonglong_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
37963 #line 3720
37964 {
37965 #line 3720
37966 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
37967 #line 3720
37968 
37969 #line 3720
37970  /* basic algorithm is:
37971 #line 3720
37972   *   - ensure sane alignment of output data
37973 #line 3720
37974   *   - copy (conversion happens automatically) input data
37975 #line 3720
37976   *     to output
37977 #line 3720
37978   *   - update tp to point at next unconverted input, and xpp to point
37979 #line 3720
37980   *     at next location for converted output
37981 #line 3720
37982   */
37983 #line 3720
37984   long i, j, ni;
37985 #line 3720
37986   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
37987 #line 3720
37988   uint64 *xp;
37989 #line 3720
37990   int nrange = 0;         /* number of range errors */
37991 #line 3720
37992   int realign = 0;        /* "do we need to fix input data alignment?" */
37993 #line 3720
37994   long cxp = (long) *((char**)xpp);
37995 #line 3720
37996 
37997 #line 3720
37998   realign = (cxp & 7) % SIZEOF_UINT64;
37999 #line 3720
38000   /* sjl: manually stripmine so we can limit amount of
38001 #line 3720
38002    * vector work space reserved to LOOPCNT elements. Also
38003 #line 3720
38004    * makes vectorisation easy */
38005 #line 3720
38006   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
38007 #line 3720
38008     ni=Min(nelems-j,LOOPCNT);
38009 #line 3720
38010     if (realign) {
38011 #line 3720
38012       xp = tmp;
38013 #line 3720
38014     } else {
38015 #line 3720
38016       xp = (uint64 *) *xpp;
38017 #line 3720
38018     }
38019 #line 3720
38020    /* copy the next block */
38021 #line 3720
38022 #pragma cdir loopcnt=LOOPCNT
38023 #line 3720
38024 #pragma cdir shortloop
38025 #line 3720
38026     for (i=0; i<ni; i++) {
38027 #line 3720
38028       /* the normal case: */
38029 #line 3720
38030       xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
38031 #line 3720
38032      /* test for range errors (not always needed but do it anyway) */
38033 #line 3720
38034      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
38035 #line 3720
38036      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
38037 #line 3720
38038       nrange += tp[i] > X_UINT64_MAX || tp[i] < 0;
38039 #line 3720
38040     }
38041 #line 3720
38042    /* copy workspace back if necessary */
38043 #line 3720
38044     if (realign) {
38045 #line 3720
38046       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
38047 #line 3720
38048       xp = (uint64 *) *xpp;
38049 #line 3720
38050     }
38051 #line 3720
38052    /* update xpp and tp */
38053 #line 3720
38054     xp += ni;
38055 #line 3720
38056     tp += ni;
38057 #line 3720
38058     *xpp = (void*)xp;
38059 #line 3720
38060   }
38061 #line 3720
38062   return nrange == 0 ? NC_NOERR : NC_ERANGE;
38063 #line 3720
38064 
38065 #line 3720
38066 #else   /* not SX */
38067 #line 3720
38068 
38069 #line 3720
38070 	char *xp = (char *) *xpp;
38071 #line 3720
38072 	int status = NC_NOERR;
38073 #line 3720
38074 
38075 #line 3720
38076 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
38077 #line 3720
38078 	{
38079 #line 3720
38080 		int lstatus = ncx_put_ulonglong_schar(xp, tp, fillp);
38081 #line 3720
38082 		if (status == NC_NOERR) /* report the first encountered error */
38083 #line 3720
38084 			status = lstatus;
38085 #line 3720
38086 	}
38087 #line 3720
38088 
38089 #line 3720
38090 	*xpp = (void *)xp;
38091 #line 3720
38092 	return status;
38093 #line 3720
38094 #endif
38095 #line 3720
38096 }
38097 #line 3720
38098 
38099 int
38100 #line 3721
ncx_putn_ulonglong_short(void ** xpp,size_t nelems,const short * tp,void * fillp)38101 ncx_putn_ulonglong_short(void **xpp, size_t nelems, const short *tp, void *fillp)
38102 #line 3721
38103 {
38104 #line 3721
38105 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
38106 #line 3721
38107 
38108 #line 3721
38109  /* basic algorithm is:
38110 #line 3721
38111   *   - ensure sane alignment of output data
38112 #line 3721
38113   *   - copy (conversion happens automatically) input data
38114 #line 3721
38115   *     to output
38116 #line 3721
38117   *   - update tp to point at next unconverted input, and xpp to point
38118 #line 3721
38119   *     at next location for converted output
38120 #line 3721
38121   */
38122 #line 3721
38123   long i, j, ni;
38124 #line 3721
38125   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
38126 #line 3721
38127   uint64 *xp;
38128 #line 3721
38129   int nrange = 0;         /* number of range errors */
38130 #line 3721
38131   int realign = 0;        /* "do we need to fix input data alignment?" */
38132 #line 3721
38133   long cxp = (long) *((char**)xpp);
38134 #line 3721
38135 
38136 #line 3721
38137   realign = (cxp & 7) % SIZEOF_UINT64;
38138 #line 3721
38139   /* sjl: manually stripmine so we can limit amount of
38140 #line 3721
38141    * vector work space reserved to LOOPCNT elements. Also
38142 #line 3721
38143    * makes vectorisation easy */
38144 #line 3721
38145   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
38146 #line 3721
38147     ni=Min(nelems-j,LOOPCNT);
38148 #line 3721
38149     if (realign) {
38150 #line 3721
38151       xp = tmp;
38152 #line 3721
38153     } else {
38154 #line 3721
38155       xp = (uint64 *) *xpp;
38156 #line 3721
38157     }
38158 #line 3721
38159    /* copy the next block */
38160 #line 3721
38161 #pragma cdir loopcnt=LOOPCNT
38162 #line 3721
38163 #pragma cdir shortloop
38164 #line 3721
38165     for (i=0; i<ni; i++) {
38166 #line 3721
38167       /* the normal case: */
38168 #line 3721
38169       xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
38170 #line 3721
38171      /* test for range errors (not always needed but do it anyway) */
38172 #line 3721
38173      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
38174 #line 3721
38175      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
38176 #line 3721
38177       nrange += tp[i] > X_UINT64_MAX || tp[i] < 0;
38178 #line 3721
38179     }
38180 #line 3721
38181    /* copy workspace back if necessary */
38182 #line 3721
38183     if (realign) {
38184 #line 3721
38185       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
38186 #line 3721
38187       xp = (uint64 *) *xpp;
38188 #line 3721
38189     }
38190 #line 3721
38191    /* update xpp and tp */
38192 #line 3721
38193     xp += ni;
38194 #line 3721
38195     tp += ni;
38196 #line 3721
38197     *xpp = (void*)xp;
38198 #line 3721
38199   }
38200 #line 3721
38201   return nrange == 0 ? NC_NOERR : NC_ERANGE;
38202 #line 3721
38203 
38204 #line 3721
38205 #else   /* not SX */
38206 #line 3721
38207 
38208 #line 3721
38209 	char *xp = (char *) *xpp;
38210 #line 3721
38211 	int status = NC_NOERR;
38212 #line 3721
38213 
38214 #line 3721
38215 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
38216 #line 3721
38217 	{
38218 #line 3721
38219 		int lstatus = ncx_put_ulonglong_short(xp, tp, fillp);
38220 #line 3721
38221 		if (status == NC_NOERR) /* report the first encountered error */
38222 #line 3721
38223 			status = lstatus;
38224 #line 3721
38225 	}
38226 #line 3721
38227 
38228 #line 3721
38229 	*xpp = (void *)xp;
38230 #line 3721
38231 	return status;
38232 #line 3721
38233 #endif
38234 #line 3721
38235 }
38236 #line 3721
38237 
38238 int
38239 #line 3722
ncx_putn_ulonglong_int(void ** xpp,size_t nelems,const int * tp,void * fillp)38240 ncx_putn_ulonglong_int(void **xpp, size_t nelems, const int *tp, void *fillp)
38241 #line 3722
38242 {
38243 #line 3722
38244 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
38245 #line 3722
38246 
38247 #line 3722
38248  /* basic algorithm is:
38249 #line 3722
38250   *   - ensure sane alignment of output data
38251 #line 3722
38252   *   - copy (conversion happens automatically) input data
38253 #line 3722
38254   *     to output
38255 #line 3722
38256   *   - update tp to point at next unconverted input, and xpp to point
38257 #line 3722
38258   *     at next location for converted output
38259 #line 3722
38260   */
38261 #line 3722
38262   long i, j, ni;
38263 #line 3722
38264   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
38265 #line 3722
38266   uint64 *xp;
38267 #line 3722
38268   int nrange = 0;         /* number of range errors */
38269 #line 3722
38270   int realign = 0;        /* "do we need to fix input data alignment?" */
38271 #line 3722
38272   long cxp = (long) *((char**)xpp);
38273 #line 3722
38274 
38275 #line 3722
38276   realign = (cxp & 7) % SIZEOF_UINT64;
38277 #line 3722
38278   /* sjl: manually stripmine so we can limit amount of
38279 #line 3722
38280    * vector work space reserved to LOOPCNT elements. Also
38281 #line 3722
38282    * makes vectorisation easy */
38283 #line 3722
38284   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
38285 #line 3722
38286     ni=Min(nelems-j,LOOPCNT);
38287 #line 3722
38288     if (realign) {
38289 #line 3722
38290       xp = tmp;
38291 #line 3722
38292     } else {
38293 #line 3722
38294       xp = (uint64 *) *xpp;
38295 #line 3722
38296     }
38297 #line 3722
38298    /* copy the next block */
38299 #line 3722
38300 #pragma cdir loopcnt=LOOPCNT
38301 #line 3722
38302 #pragma cdir shortloop
38303 #line 3722
38304     for (i=0; i<ni; i++) {
38305 #line 3722
38306       /* the normal case: */
38307 #line 3722
38308       xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
38309 #line 3722
38310      /* test for range errors (not always needed but do it anyway) */
38311 #line 3722
38312      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
38313 #line 3722
38314      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
38315 #line 3722
38316       nrange += tp[i] > X_UINT64_MAX || tp[i] < 0;
38317 #line 3722
38318     }
38319 #line 3722
38320    /* copy workspace back if necessary */
38321 #line 3722
38322     if (realign) {
38323 #line 3722
38324       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
38325 #line 3722
38326       xp = (uint64 *) *xpp;
38327 #line 3722
38328     }
38329 #line 3722
38330    /* update xpp and tp */
38331 #line 3722
38332     xp += ni;
38333 #line 3722
38334     tp += ni;
38335 #line 3722
38336     *xpp = (void*)xp;
38337 #line 3722
38338   }
38339 #line 3722
38340   return nrange == 0 ? NC_NOERR : NC_ERANGE;
38341 #line 3722
38342 
38343 #line 3722
38344 #else   /* not SX */
38345 #line 3722
38346 
38347 #line 3722
38348 	char *xp = (char *) *xpp;
38349 #line 3722
38350 	int status = NC_NOERR;
38351 #line 3722
38352 
38353 #line 3722
38354 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
38355 #line 3722
38356 	{
38357 #line 3722
38358 		int lstatus = ncx_put_ulonglong_int(xp, tp, fillp);
38359 #line 3722
38360 		if (status == NC_NOERR) /* report the first encountered error */
38361 #line 3722
38362 			status = lstatus;
38363 #line 3722
38364 	}
38365 #line 3722
38366 
38367 #line 3722
38368 	*xpp = (void *)xp;
38369 #line 3722
38370 	return status;
38371 #line 3722
38372 #endif
38373 #line 3722
38374 }
38375 #line 3722
38376 
38377 int
38378 #line 3723
ncx_putn_ulonglong_long(void ** xpp,size_t nelems,const long * tp,void * fillp)38379 ncx_putn_ulonglong_long(void **xpp, size_t nelems, const long *tp, void *fillp)
38380 #line 3723
38381 {
38382 #line 3723
38383 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
38384 #line 3723
38385 
38386 #line 3723
38387  /* basic algorithm is:
38388 #line 3723
38389   *   - ensure sane alignment of output data
38390 #line 3723
38391   *   - copy (conversion happens automatically) input data
38392 #line 3723
38393   *     to output
38394 #line 3723
38395   *   - update tp to point at next unconverted input, and xpp to point
38396 #line 3723
38397   *     at next location for converted output
38398 #line 3723
38399   */
38400 #line 3723
38401   long i, j, ni;
38402 #line 3723
38403   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
38404 #line 3723
38405   uint64 *xp;
38406 #line 3723
38407   int nrange = 0;         /* number of range errors */
38408 #line 3723
38409   int realign = 0;        /* "do we need to fix input data alignment?" */
38410 #line 3723
38411   long cxp = (long) *((char**)xpp);
38412 #line 3723
38413 
38414 #line 3723
38415   realign = (cxp & 7) % SIZEOF_UINT64;
38416 #line 3723
38417   /* sjl: manually stripmine so we can limit amount of
38418 #line 3723
38419    * vector work space reserved to LOOPCNT elements. Also
38420 #line 3723
38421    * makes vectorisation easy */
38422 #line 3723
38423   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
38424 #line 3723
38425     ni=Min(nelems-j,LOOPCNT);
38426 #line 3723
38427     if (realign) {
38428 #line 3723
38429       xp = tmp;
38430 #line 3723
38431     } else {
38432 #line 3723
38433       xp = (uint64 *) *xpp;
38434 #line 3723
38435     }
38436 #line 3723
38437    /* copy the next block */
38438 #line 3723
38439 #pragma cdir loopcnt=LOOPCNT
38440 #line 3723
38441 #pragma cdir shortloop
38442 #line 3723
38443     for (i=0; i<ni; i++) {
38444 #line 3723
38445       /* the normal case: */
38446 #line 3723
38447       xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
38448 #line 3723
38449      /* test for range errors (not always needed but do it anyway) */
38450 #line 3723
38451      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
38452 #line 3723
38453      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
38454 #line 3723
38455       nrange += tp[i] > X_UINT64_MAX || tp[i] < 0;
38456 #line 3723
38457     }
38458 #line 3723
38459    /* copy workspace back if necessary */
38460 #line 3723
38461     if (realign) {
38462 #line 3723
38463       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
38464 #line 3723
38465       xp = (uint64 *) *xpp;
38466 #line 3723
38467     }
38468 #line 3723
38469    /* update xpp and tp */
38470 #line 3723
38471     xp += ni;
38472 #line 3723
38473     tp += ni;
38474 #line 3723
38475     *xpp = (void*)xp;
38476 #line 3723
38477   }
38478 #line 3723
38479   return nrange == 0 ? NC_NOERR : NC_ERANGE;
38480 #line 3723
38481 
38482 #line 3723
38483 #else   /* not SX */
38484 #line 3723
38485 
38486 #line 3723
38487 	char *xp = (char *) *xpp;
38488 #line 3723
38489 	int status = NC_NOERR;
38490 #line 3723
38491 
38492 #line 3723
38493 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
38494 #line 3723
38495 	{
38496 #line 3723
38497 		int lstatus = ncx_put_ulonglong_long(xp, tp, fillp);
38498 #line 3723
38499 		if (status == NC_NOERR) /* report the first encountered error */
38500 #line 3723
38501 			status = lstatus;
38502 #line 3723
38503 	}
38504 #line 3723
38505 
38506 #line 3723
38507 	*xpp = (void *)xp;
38508 #line 3723
38509 	return status;
38510 #line 3723
38511 #endif
38512 #line 3723
38513 }
38514 #line 3723
38515 
38516 int
38517 #line 3724
ncx_putn_ulonglong_float(void ** xpp,size_t nelems,const float * tp,void * fillp)38518 ncx_putn_ulonglong_float(void **xpp, size_t nelems, const float *tp, void *fillp)
38519 #line 3724
38520 {
38521 #line 3724
38522 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
38523 #line 3724
38524 
38525 #line 3724
38526  /* basic algorithm is:
38527 #line 3724
38528   *   - ensure sane alignment of output data
38529 #line 3724
38530   *   - copy (conversion happens automatically) input data
38531 #line 3724
38532   *     to output
38533 #line 3724
38534   *   - update tp to point at next unconverted input, and xpp to point
38535 #line 3724
38536   *     at next location for converted output
38537 #line 3724
38538   */
38539 #line 3724
38540   long i, j, ni;
38541 #line 3724
38542   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
38543 #line 3724
38544   uint64 *xp;
38545 #line 3724
38546   int nrange = 0;         /* number of range errors */
38547 #line 3724
38548   int realign = 0;        /* "do we need to fix input data alignment?" */
38549 #line 3724
38550   long cxp = (long) *((char**)xpp);
38551 #line 3724
38552 
38553 #line 3724
38554   realign = (cxp & 7) % SIZEOF_UINT64;
38555 #line 3724
38556   /* sjl: manually stripmine so we can limit amount of
38557 #line 3724
38558    * vector work space reserved to LOOPCNT elements. Also
38559 #line 3724
38560    * makes vectorisation easy */
38561 #line 3724
38562   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
38563 #line 3724
38564     ni=Min(nelems-j,LOOPCNT);
38565 #line 3724
38566     if (realign) {
38567 #line 3724
38568       xp = tmp;
38569 #line 3724
38570     } else {
38571 #line 3724
38572       xp = (uint64 *) *xpp;
38573 #line 3724
38574     }
38575 #line 3724
38576    /* copy the next block */
38577 #line 3724
38578 #pragma cdir loopcnt=LOOPCNT
38579 #line 3724
38580 #pragma cdir shortloop
38581 #line 3724
38582     for (i=0; i<ni; i++) {
38583 #line 3724
38584       /* the normal case: */
38585 #line 3724
38586       xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
38587 #line 3724
38588      /* test for range errors (not always needed but do it anyway) */
38589 #line 3724
38590      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
38591 #line 3724
38592      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
38593 #line 3724
38594       nrange += tp[i] > X_UINT64_MAX || tp[i] < 0;
38595 #line 3724
38596     }
38597 #line 3724
38598    /* copy workspace back if necessary */
38599 #line 3724
38600     if (realign) {
38601 #line 3724
38602       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
38603 #line 3724
38604       xp = (uint64 *) *xpp;
38605 #line 3724
38606     }
38607 #line 3724
38608    /* update xpp and tp */
38609 #line 3724
38610     xp += ni;
38611 #line 3724
38612     tp += ni;
38613 #line 3724
38614     *xpp = (void*)xp;
38615 #line 3724
38616   }
38617 #line 3724
38618   return nrange == 0 ? NC_NOERR : NC_ERANGE;
38619 #line 3724
38620 
38621 #line 3724
38622 #else   /* not SX */
38623 #line 3724
38624 
38625 #line 3724
38626 	char *xp = (char *) *xpp;
38627 #line 3724
38628 	int status = NC_NOERR;
38629 #line 3724
38630 
38631 #line 3724
38632 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
38633 #line 3724
38634 	{
38635 #line 3724
38636 		int lstatus = ncx_put_ulonglong_float(xp, tp, fillp);
38637 #line 3724
38638 		if (status == NC_NOERR) /* report the first encountered error */
38639 #line 3724
38640 			status = lstatus;
38641 #line 3724
38642 	}
38643 #line 3724
38644 
38645 #line 3724
38646 	*xpp = (void *)xp;
38647 #line 3724
38648 	return status;
38649 #line 3724
38650 #endif
38651 #line 3724
38652 }
38653 #line 3724
38654 
38655 int
38656 #line 3725
ncx_putn_ulonglong_double(void ** xpp,size_t nelems,const double * tp,void * fillp)38657 ncx_putn_ulonglong_double(void **xpp, size_t nelems, const double *tp, void *fillp)
38658 #line 3725
38659 {
38660 #line 3725
38661 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
38662 #line 3725
38663 
38664 #line 3725
38665  /* basic algorithm is:
38666 #line 3725
38667   *   - ensure sane alignment of output data
38668 #line 3725
38669   *   - copy (conversion happens automatically) input data
38670 #line 3725
38671   *     to output
38672 #line 3725
38673   *   - update tp to point at next unconverted input, and xpp to point
38674 #line 3725
38675   *     at next location for converted output
38676 #line 3725
38677   */
38678 #line 3725
38679   long i, j, ni;
38680 #line 3725
38681   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
38682 #line 3725
38683   uint64 *xp;
38684 #line 3725
38685   int nrange = 0;         /* number of range errors */
38686 #line 3725
38687   int realign = 0;        /* "do we need to fix input data alignment?" */
38688 #line 3725
38689   long cxp = (long) *((char**)xpp);
38690 #line 3725
38691 
38692 #line 3725
38693   realign = (cxp & 7) % SIZEOF_UINT64;
38694 #line 3725
38695   /* sjl: manually stripmine so we can limit amount of
38696 #line 3725
38697    * vector work space reserved to LOOPCNT elements. Also
38698 #line 3725
38699    * makes vectorisation easy */
38700 #line 3725
38701   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
38702 #line 3725
38703     ni=Min(nelems-j,LOOPCNT);
38704 #line 3725
38705     if (realign) {
38706 #line 3725
38707       xp = tmp;
38708 #line 3725
38709     } else {
38710 #line 3725
38711       xp = (uint64 *) *xpp;
38712 #line 3725
38713     }
38714 #line 3725
38715    /* copy the next block */
38716 #line 3725
38717 #pragma cdir loopcnt=LOOPCNT
38718 #line 3725
38719 #pragma cdir shortloop
38720 #line 3725
38721     for (i=0; i<ni; i++) {
38722 #line 3725
38723       /* the normal case: */
38724 #line 3725
38725       xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
38726 #line 3725
38727      /* test for range errors (not always needed but do it anyway) */
38728 #line 3725
38729      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
38730 #line 3725
38731      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
38732 #line 3725
38733       nrange += tp[i] > X_UINT64_MAX || tp[i] < 0;
38734 #line 3725
38735     }
38736 #line 3725
38737    /* copy workspace back if necessary */
38738 #line 3725
38739     if (realign) {
38740 #line 3725
38741       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
38742 #line 3725
38743       xp = (uint64 *) *xpp;
38744 #line 3725
38745     }
38746 #line 3725
38747    /* update xpp and tp */
38748 #line 3725
38749     xp += ni;
38750 #line 3725
38751     tp += ni;
38752 #line 3725
38753     *xpp = (void*)xp;
38754 #line 3725
38755   }
38756 #line 3725
38757   return nrange == 0 ? NC_NOERR : NC_ERANGE;
38758 #line 3725
38759 
38760 #line 3725
38761 #else   /* not SX */
38762 #line 3725
38763 
38764 #line 3725
38765 	char *xp = (char *) *xpp;
38766 #line 3725
38767 	int status = NC_NOERR;
38768 #line 3725
38769 
38770 #line 3725
38771 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
38772 #line 3725
38773 	{
38774 #line 3725
38775 		int lstatus = ncx_put_ulonglong_double(xp, tp, fillp);
38776 #line 3725
38777 		if (status == NC_NOERR) /* report the first encountered error */
38778 #line 3725
38779 			status = lstatus;
38780 #line 3725
38781 	}
38782 #line 3725
38783 
38784 #line 3725
38785 	*xpp = (void *)xp;
38786 #line 3725
38787 	return status;
38788 #line 3725
38789 #endif
38790 #line 3725
38791 }
38792 #line 3725
38793 
38794 int
38795 #line 3726
ncx_putn_ulonglong_longlong(void ** xpp,size_t nelems,const longlong * tp,void * fillp)38796 ncx_putn_ulonglong_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
38797 #line 3726
38798 {
38799 #line 3726
38800 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
38801 #line 3726
38802 
38803 #line 3726
38804  /* basic algorithm is:
38805 #line 3726
38806   *   - ensure sane alignment of output data
38807 #line 3726
38808   *   - copy (conversion happens automatically) input data
38809 #line 3726
38810   *     to output
38811 #line 3726
38812   *   - update tp to point at next unconverted input, and xpp to point
38813 #line 3726
38814   *     at next location for converted output
38815 #line 3726
38816   */
38817 #line 3726
38818   long i, j, ni;
38819 #line 3726
38820   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
38821 #line 3726
38822   uint64 *xp;
38823 #line 3726
38824   int nrange = 0;         /* number of range errors */
38825 #line 3726
38826   int realign = 0;        /* "do we need to fix input data alignment?" */
38827 #line 3726
38828   long cxp = (long) *((char**)xpp);
38829 #line 3726
38830 
38831 #line 3726
38832   realign = (cxp & 7) % SIZEOF_UINT64;
38833 #line 3726
38834   /* sjl: manually stripmine so we can limit amount of
38835 #line 3726
38836    * vector work space reserved to LOOPCNT elements. Also
38837 #line 3726
38838    * makes vectorisation easy */
38839 #line 3726
38840   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
38841 #line 3726
38842     ni=Min(nelems-j,LOOPCNT);
38843 #line 3726
38844     if (realign) {
38845 #line 3726
38846       xp = tmp;
38847 #line 3726
38848     } else {
38849 #line 3726
38850       xp = (uint64 *) *xpp;
38851 #line 3726
38852     }
38853 #line 3726
38854    /* copy the next block */
38855 #line 3726
38856 #pragma cdir loopcnt=LOOPCNT
38857 #line 3726
38858 #pragma cdir shortloop
38859 #line 3726
38860     for (i=0; i<ni; i++) {
38861 #line 3726
38862       /* the normal case: */
38863 #line 3726
38864       xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
38865 #line 3726
38866      /* test for range errors (not always needed but do it anyway) */
38867 #line 3726
38868      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
38869 #line 3726
38870      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
38871 #line 3726
38872       nrange += tp[i] > X_UINT64_MAX || tp[i] < 0;
38873 #line 3726
38874     }
38875 #line 3726
38876    /* copy workspace back if necessary */
38877 #line 3726
38878     if (realign) {
38879 #line 3726
38880       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
38881 #line 3726
38882       xp = (uint64 *) *xpp;
38883 #line 3726
38884     }
38885 #line 3726
38886    /* update xpp and tp */
38887 #line 3726
38888     xp += ni;
38889 #line 3726
38890     tp += ni;
38891 #line 3726
38892     *xpp = (void*)xp;
38893 #line 3726
38894   }
38895 #line 3726
38896   return nrange == 0 ? NC_NOERR : NC_ERANGE;
38897 #line 3726
38898 
38899 #line 3726
38900 #else   /* not SX */
38901 #line 3726
38902 
38903 #line 3726
38904 	char *xp = (char *) *xpp;
38905 #line 3726
38906 	int status = NC_NOERR;
38907 #line 3726
38908 
38909 #line 3726
38910 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
38911 #line 3726
38912 	{
38913 #line 3726
38914 		int lstatus = ncx_put_ulonglong_longlong(xp, tp, fillp);
38915 #line 3726
38916 		if (status == NC_NOERR) /* report the first encountered error */
38917 #line 3726
38918 			status = lstatus;
38919 #line 3726
38920 	}
38921 #line 3726
38922 
38923 #line 3726
38924 	*xpp = (void *)xp;
38925 #line 3726
38926 	return status;
38927 #line 3726
38928 #endif
38929 #line 3726
38930 }
38931 #line 3726
38932 
38933 int
38934 #line 3727
ncx_putn_ulonglong_uchar(void ** xpp,size_t nelems,const uchar * tp,void * fillp)38935 ncx_putn_ulonglong_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
38936 #line 3727
38937 {
38938 #line 3727
38939 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
38940 #line 3727
38941 
38942 #line 3727
38943  /* basic algorithm is:
38944 #line 3727
38945   *   - ensure sane alignment of output data
38946 #line 3727
38947   *   - copy (conversion happens automatically) input data
38948 #line 3727
38949   *     to output
38950 #line 3727
38951   *   - update tp to point at next unconverted input, and xpp to point
38952 #line 3727
38953   *     at next location for converted output
38954 #line 3727
38955   */
38956 #line 3727
38957   long i, j, ni;
38958 #line 3727
38959   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
38960 #line 3727
38961   uint64 *xp;
38962 #line 3727
38963   int nrange = 0;         /* number of range errors */
38964 #line 3727
38965   int realign = 0;        /* "do we need to fix input data alignment?" */
38966 #line 3727
38967   long cxp = (long) *((char**)xpp);
38968 #line 3727
38969 
38970 #line 3727
38971   realign = (cxp & 7) % SIZEOF_UINT64;
38972 #line 3727
38973   /* sjl: manually stripmine so we can limit amount of
38974 #line 3727
38975    * vector work space reserved to LOOPCNT elements. Also
38976 #line 3727
38977    * makes vectorisation easy */
38978 #line 3727
38979   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
38980 #line 3727
38981     ni=Min(nelems-j,LOOPCNT);
38982 #line 3727
38983     if (realign) {
38984 #line 3727
38985       xp = tmp;
38986 #line 3727
38987     } else {
38988 #line 3727
38989       xp = (uint64 *) *xpp;
38990 #line 3727
38991     }
38992 #line 3727
38993    /* copy the next block */
38994 #line 3727
38995 #pragma cdir loopcnt=LOOPCNT
38996 #line 3727
38997 #pragma cdir shortloop
38998 #line 3727
38999     for (i=0; i<ni; i++) {
39000 #line 3727
39001       /* the normal case: */
39002 #line 3727
39003       xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
39004 #line 3727
39005      /* test for range errors (not always needed but do it anyway) */
39006 #line 3727
39007      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
39008 #line 3727
39009      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
39010 #line 3727
39011       nrange += tp[i] > X_UINT64_MAX ;
39012 #line 3727
39013     }
39014 #line 3727
39015    /* copy workspace back if necessary */
39016 #line 3727
39017     if (realign) {
39018 #line 3727
39019       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
39020 #line 3727
39021       xp = (uint64 *) *xpp;
39022 #line 3727
39023     }
39024 #line 3727
39025    /* update xpp and tp */
39026 #line 3727
39027     xp += ni;
39028 #line 3727
39029     tp += ni;
39030 #line 3727
39031     *xpp = (void*)xp;
39032 #line 3727
39033   }
39034 #line 3727
39035   return nrange == 0 ? NC_NOERR : NC_ERANGE;
39036 #line 3727
39037 
39038 #line 3727
39039 #else   /* not SX */
39040 #line 3727
39041 
39042 #line 3727
39043 	char *xp = (char *) *xpp;
39044 #line 3727
39045 	int status = NC_NOERR;
39046 #line 3727
39047 
39048 #line 3727
39049 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
39050 #line 3727
39051 	{
39052 #line 3727
39053 		int lstatus = ncx_put_ulonglong_uchar(xp, tp, fillp);
39054 #line 3727
39055 		if (status == NC_NOERR) /* report the first encountered error */
39056 #line 3727
39057 			status = lstatus;
39058 #line 3727
39059 	}
39060 #line 3727
39061 
39062 #line 3727
39063 	*xpp = (void *)xp;
39064 #line 3727
39065 	return status;
39066 #line 3727
39067 #endif
39068 #line 3727
39069 }
39070 #line 3727
39071 
39072 int
39073 #line 3728
ncx_putn_ulonglong_ushort(void ** xpp,size_t nelems,const ushort * tp,void * fillp)39074 ncx_putn_ulonglong_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
39075 #line 3728
39076 {
39077 #line 3728
39078 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
39079 #line 3728
39080 
39081 #line 3728
39082  /* basic algorithm is:
39083 #line 3728
39084   *   - ensure sane alignment of output data
39085 #line 3728
39086   *   - copy (conversion happens automatically) input data
39087 #line 3728
39088   *     to output
39089 #line 3728
39090   *   - update tp to point at next unconverted input, and xpp to point
39091 #line 3728
39092   *     at next location for converted output
39093 #line 3728
39094   */
39095 #line 3728
39096   long i, j, ni;
39097 #line 3728
39098   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
39099 #line 3728
39100   uint64 *xp;
39101 #line 3728
39102   int nrange = 0;         /* number of range errors */
39103 #line 3728
39104   int realign = 0;        /* "do we need to fix input data alignment?" */
39105 #line 3728
39106   long cxp = (long) *((char**)xpp);
39107 #line 3728
39108 
39109 #line 3728
39110   realign = (cxp & 7) % SIZEOF_UINT64;
39111 #line 3728
39112   /* sjl: manually stripmine so we can limit amount of
39113 #line 3728
39114    * vector work space reserved to LOOPCNT elements. Also
39115 #line 3728
39116    * makes vectorisation easy */
39117 #line 3728
39118   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
39119 #line 3728
39120     ni=Min(nelems-j,LOOPCNT);
39121 #line 3728
39122     if (realign) {
39123 #line 3728
39124       xp = tmp;
39125 #line 3728
39126     } else {
39127 #line 3728
39128       xp = (uint64 *) *xpp;
39129 #line 3728
39130     }
39131 #line 3728
39132    /* copy the next block */
39133 #line 3728
39134 #pragma cdir loopcnt=LOOPCNT
39135 #line 3728
39136 #pragma cdir shortloop
39137 #line 3728
39138     for (i=0; i<ni; i++) {
39139 #line 3728
39140       /* the normal case: */
39141 #line 3728
39142       xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
39143 #line 3728
39144      /* test for range errors (not always needed but do it anyway) */
39145 #line 3728
39146      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
39147 #line 3728
39148      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
39149 #line 3728
39150       nrange += tp[i] > X_UINT64_MAX ;
39151 #line 3728
39152     }
39153 #line 3728
39154    /* copy workspace back if necessary */
39155 #line 3728
39156     if (realign) {
39157 #line 3728
39158       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
39159 #line 3728
39160       xp = (uint64 *) *xpp;
39161 #line 3728
39162     }
39163 #line 3728
39164    /* update xpp and tp */
39165 #line 3728
39166     xp += ni;
39167 #line 3728
39168     tp += ni;
39169 #line 3728
39170     *xpp = (void*)xp;
39171 #line 3728
39172   }
39173 #line 3728
39174   return nrange == 0 ? NC_NOERR : NC_ERANGE;
39175 #line 3728
39176 
39177 #line 3728
39178 #else   /* not SX */
39179 #line 3728
39180 
39181 #line 3728
39182 	char *xp = (char *) *xpp;
39183 #line 3728
39184 	int status = NC_NOERR;
39185 #line 3728
39186 
39187 #line 3728
39188 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
39189 #line 3728
39190 	{
39191 #line 3728
39192 		int lstatus = ncx_put_ulonglong_ushort(xp, tp, fillp);
39193 #line 3728
39194 		if (status == NC_NOERR) /* report the first encountered error */
39195 #line 3728
39196 			status = lstatus;
39197 #line 3728
39198 	}
39199 #line 3728
39200 
39201 #line 3728
39202 	*xpp = (void *)xp;
39203 #line 3728
39204 	return status;
39205 #line 3728
39206 #endif
39207 #line 3728
39208 }
39209 #line 3728
39210 
39211 int
39212 #line 3729
ncx_putn_ulonglong_uint(void ** xpp,size_t nelems,const uint * tp,void * fillp)39213 ncx_putn_ulonglong_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
39214 #line 3729
39215 {
39216 #line 3729
39217 #if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
39218 #line 3729
39219 
39220 #line 3729
39221  /* basic algorithm is:
39222 #line 3729
39223   *   - ensure sane alignment of output data
39224 #line 3729
39225   *   - copy (conversion happens automatically) input data
39226 #line 3729
39227   *     to output
39228 #line 3729
39229   *   - update tp to point at next unconverted input, and xpp to point
39230 #line 3729
39231   *     at next location for converted output
39232 #line 3729
39233   */
39234 #line 3729
39235   long i, j, ni;
39236 #line 3729
39237   uint64 tmp[LOOPCNT];        /* in case input is misaligned */
39238 #line 3729
39239   uint64 *xp;
39240 #line 3729
39241   int nrange = 0;         /* number of range errors */
39242 #line 3729
39243   int realign = 0;        /* "do we need to fix input data alignment?" */
39244 #line 3729
39245   long cxp = (long) *((char**)xpp);
39246 #line 3729
39247 
39248 #line 3729
39249   realign = (cxp & 7) % SIZEOF_UINT64;
39250 #line 3729
39251   /* sjl: manually stripmine so we can limit amount of
39252 #line 3729
39253    * vector work space reserved to LOOPCNT elements. Also
39254 #line 3729
39255    * makes vectorisation easy */
39256 #line 3729
39257   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
39258 #line 3729
39259     ni=Min(nelems-j,LOOPCNT);
39260 #line 3729
39261     if (realign) {
39262 #line 3729
39263       xp = tmp;
39264 #line 3729
39265     } else {
39266 #line 3729
39267       xp = (uint64 *) *xpp;
39268 #line 3729
39269     }
39270 #line 3729
39271    /* copy the next block */
39272 #line 3729
39273 #pragma cdir loopcnt=LOOPCNT
39274 #line 3729
39275 #pragma cdir shortloop
39276 #line 3729
39277     for (i=0; i<ni; i++) {
39278 #line 3729
39279       /* the normal case: */
39280 #line 3729
39281       xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
39282 #line 3729
39283      /* test for range errors (not always needed but do it anyway) */
39284 #line 3729
39285      /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
39286 #line 3729
39287      /* if tp is unsigned, we need not check if tp[i] < X__MIN */
39288 #line 3729
39289       nrange += tp[i] > X_UINT64_MAX ;
39290 #line 3729
39291     }
39292 #line 3729
39293    /* copy workspace back if necessary */
39294 #line 3729
39295     if (realign) {
39296 #line 3729
39297       memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
39298 #line 3729
39299       xp = (uint64 *) *xpp;
39300 #line 3729
39301     }
39302 #line 3729
39303    /* update xpp and tp */
39304 #line 3729
39305     xp += ni;
39306 #line 3729
39307     tp += ni;
39308 #line 3729
39309     *xpp = (void*)xp;
39310 #line 3729
39311   }
39312 #line 3729
39313   return nrange == 0 ? NC_NOERR : NC_ERANGE;
39314 #line 3729
39315 
39316 #line 3729
39317 #else   /* not SX */
39318 #line 3729
39319 
39320 #line 3729
39321 	char *xp = (char *) *xpp;
39322 #line 3729
39323 	int status = NC_NOERR;
39324 #line 3729
39325 
39326 #line 3729
39327 	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
39328 #line 3729
39329 	{
39330 #line 3729
39331 		int lstatus = ncx_put_ulonglong_uint(xp, tp, fillp);
39332 #line 3729
39333 		if (status == NC_NOERR) /* report the first encountered error */
39334 #line 3729
39335 			status = lstatus;
39336 #line 3729
39337 	}
39338 #line 3729
39339 
39340 #line 3729
39341 	*xpp = (void *)xp;
39342 #line 3729
39343 	return status;
39344 #line 3729
39345 #endif
39346 #line 3729
39347 }
39348 #line 3729
39349 
39350 
39351 
39352 /*
39353  * Other aggregate conversion functions.
39354  */
39355 
39356 /* text */
39357 
39358 int
ncx_getn_text(const void ** xpp,size_t nelems,char * tp)39359 ncx_getn_text(const void **xpp, size_t nelems, char *tp)
39360 {
39361 	(void) memcpy(tp, *xpp, (size_t)nelems);
39362 #line 3741
39363 	*xpp = (void *)((char *)(*xpp) + nelems);
39364 #line 3741
39365 	return NC_NOERR;
39366 #line 3741
39367 
39368 }
39369 
39370 int
ncx_pad_getn_text(const void ** xpp,size_t nelems,char * tp)39371 ncx_pad_getn_text(const void **xpp, size_t nelems, char *tp)
39372 {
39373 	size_t rndup = nelems % X_ALIGN;
39374 #line 3747
39375 
39376 #line 3747
39377 	if (rndup)
39378 #line 3747
39379 		rndup = X_ALIGN - rndup;
39380 #line 3747
39381 
39382 #line 3747
39383 	(void) memcpy(tp, *xpp, (size_t)nelems);
39384 #line 3747
39385 	*xpp = (void *)((char *)(*xpp) + nelems + rndup);
39386 #line 3747
39387 
39388 #line 3747
39389 	return NC_NOERR;
39390 #line 3747
39391 
39392 }
39393 
39394 int
ncx_putn_text(void ** xpp,size_t nelems,const char * tp)39395 ncx_putn_text(void **xpp, size_t nelems, const char *tp)
39396 {
39397 	(void) memcpy(*xpp, tp, (size_t)nelems);
39398 #line 3753
39399 	*xpp = (void *)((char *)(*xpp) + nelems);
39400 #line 3753
39401 
39402 #line 3753
39403 	return NC_NOERR;
39404 #line 3753
39405 
39406 }
39407 
39408 int
ncx_pad_putn_text(void ** xpp,size_t nelems,const char * tp)39409 ncx_pad_putn_text(void **xpp, size_t nelems, const char *tp)
39410 {
39411 	size_t rndup = nelems % X_ALIGN;
39412 #line 3759
39413 
39414 #line 3759
39415 	if (rndup)
39416 #line 3759
39417 		rndup = X_ALIGN - rndup;
39418 #line 3759
39419 
39420 #line 3759
39421 	(void) memcpy(*xpp, tp, (size_t)nelems);
39422 #line 3759
39423 	*xpp = (void *)((char *)(*xpp) + nelems);
39424 #line 3759
39425 
39426 #line 3759
39427 	if (rndup)
39428 #line 3759
39429 	{
39430 #line 3759
39431 		(void) memcpy(*xpp, nada, (size_t)rndup);
39432 #line 3759
39433 		*xpp = (void *)((char *)(*xpp) + rndup);
39434 #line 3759
39435 	}
39436 #line 3759
39437 
39438 #line 3759
39439 	return NC_NOERR;
39440 #line 3759
39441 
39442 }
39443 
39444 
39445 /* opaque */
39446 
39447 int
ncx_getn_void(const void ** xpp,size_t nelems,void * tp)39448 ncx_getn_void(const void **xpp, size_t nelems, void *tp)
39449 {
39450 	(void) memcpy(tp, *xpp, (size_t)nelems);
39451 #line 3768
39452 	*xpp = (void *)((char *)(*xpp) + nelems);
39453 #line 3768
39454 	return NC_NOERR;
39455 #line 3768
39456 
39457 }
39458 
39459 int
ncx_pad_getn_void(const void ** xpp,size_t nelems,void * tp)39460 ncx_pad_getn_void(const void **xpp, size_t nelems, void *tp)
39461 {
39462 	size_t rndup = nelems % X_ALIGN;
39463 #line 3774
39464 
39465 #line 3774
39466 	if (rndup)
39467 #line 3774
39468 		rndup = X_ALIGN - rndup;
39469 #line 3774
39470 
39471 #line 3774
39472 	(void) memcpy(tp, *xpp, (size_t)nelems);
39473 #line 3774
39474 	*xpp = (void *)((char *)(*xpp) + nelems + rndup);
39475 #line 3774
39476 
39477 #line 3774
39478 	return NC_NOERR;
39479 #line 3774
39480 
39481 }
39482 
39483 int
ncx_putn_void(void ** xpp,size_t nelems,const void * tp)39484 ncx_putn_void(void **xpp, size_t nelems, const void *tp)
39485 {
39486 	(void) memcpy(*xpp, tp, (size_t)nelems);
39487 #line 3780
39488 	*xpp = (void *)((char *)(*xpp) + nelems);
39489 #line 3780
39490 
39491 #line 3780
39492 	return NC_NOERR;
39493 #line 3780
39494 
39495 }
39496 
39497 int
ncx_pad_putn_void(void ** xpp,size_t nelems,const void * tp)39498 ncx_pad_putn_void(void **xpp, size_t nelems, const void *tp)
39499 {
39500 	size_t rndup = nelems % X_ALIGN;
39501 #line 3786
39502 
39503 #line 3786
39504 	if (rndup)
39505 #line 3786
39506 		rndup = X_ALIGN - rndup;
39507 #line 3786
39508 
39509 #line 3786
39510 	(void) memcpy(*xpp, tp, (size_t)nelems);
39511 #line 3786
39512 	*xpp = (void *)((char *)(*xpp) + nelems);
39513 #line 3786
39514 
39515 #line 3786
39516 	if (rndup)
39517 #line 3786
39518 	{
39519 #line 3786
39520 		(void) memcpy(*xpp, nada, (size_t)rndup);
39521 #line 3786
39522 		*xpp = (void *)((char *)(*xpp) + rndup);
39523 #line 3786
39524 	}
39525 #line 3786
39526 
39527 #line 3786
39528 	return NC_NOERR;
39529 #line 3786
39530 
39531 }
39532