spinn_common 7.1.1
Support code for SpiNNaker applications.
Loading...
Searching...
No Matches
stdfix-full-iso.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013 The University of Manchester
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
47#ifndef __STDFIX_FULL_ISO_H__
48#define __STDFIX_FULL_ISO_H__
49
50#include <stdint.h>
51#include <stdbool.h>
52#include "arm_acle.h"
53
58#ifndef min
59#define min(a, b) (((a)<(b)) ? (a) : (b))
60#endif
61
66
67#define __stdfix_max(a, b) \
68 (((a)<(b)) ? (b) : (a))
69
72
73// note that this is a use of the semicolon swallowing as defined in:
74// https://gcc.gnu.org/onlinedocs/cpp/Swallowing-the-Semicolon.html
75#define __stdfix_use(a) \
76 do {} while ((a)!=(a))
77
81
82#define __stdfix_abs(a) \
83 (((a)<0) ? -(a) : (a))
84
88
89#define __stdfix_ms_u32(x) \
90 ((x) >> 32)
91
95
96#define __stdfix_ls_u32(x) \
97 ((x) & UINT32_MAX)
98
105
106void __stdfix_64x64_128(uint64_t *hi, uint64_t *lo, uint64_t x, uint64_t y);
107
111
114typedef int8_t int_hr_t;
115
117typedef int16_t int_r_t;
118
121typedef int32_t int_lr_t;
122
125typedef int16_t int_hk_t;
126
128typedef int32_t int_k_t;
129
132typedef int64_t int_lk_t;
133
136typedef uint8_t uint_uhr_t;
137
140typedef uint16_t uint_ur_t;
141
144typedef uint32_t uint_ulr_t;
145
148typedef uint16_t uint_uhk_t;
149
152typedef uint32_t uint_uk_t;
153
156typedef uint64_t uint_ulk_t;
158
159#ifdef __arm__
160#include <stdfix.h>
161
162// TRULY AWFUL HACK to make the Eclipse CDT not complain like crazy
163// https://fasaxc.blogspot.co.uk/2015/02/working-with-cs-new-fixed-point.html
164// I am so, so sorry...
165#ifdef ECLIPSE_CDT_INDEXER_HACK
166#define _Fract int
167#define _Accum int
168#define _Sat
169#endif // ECLIPSE_CDT_INDEXER_HACK
170
172typedef short fract s07;
173
175typedef fract s015;
176
178typedef long fract s031;
179
181typedef short accum s87;
182
184typedef accum s1615;
185
187typedef long accum s3231;
188
190typedef unsigned short fract u08;
191
193typedef unsigned fract u016;
194
196typedef unsigned long fract u032;
197
199typedef unsigned short accum u88;
200
202typedef unsigned accum u1616;
203
205typedef unsigned long accum u3232;
206
207#else /* ! __arm__ */
208
209typedef int8_t s07;
210typedef int16_t s015;
211typedef int32_t s031;
212typedef int16_t s87;
213typedef int32_t s1615;
214typedef int64_t s3231;
215
216typedef uint8_t u08;
217typedef uint16_t u016;
218typedef uint32_t u032;
219typedef uint16_t u88;
220typedef uint32_t u1616;
221typedef uint64_t u3232;
222
223#endif /* __arm__ */
224
228
232
233static inline int_hr_t bitshr(
234 const s07 f)
235{
236 union { int_hr_t r; s07 fx; } x;
237
238 x.fx = f;
239 return x.r;
240}
241
245
246static inline int_r_t bitsr(
247 const s015 f)
248{
249 union { int_r_t r; s015 fx; } x;
250
251 x.fx = f;
252 return x.r;
253}
254
258
259static inline int_lr_t bitslr(
260 const s031 f)
261{
262 union { int_lr_t r; s031 fx; } x;
263
264 x.fx = f;
265 return x.r;
266}
267
271
272static inline int_hk_t bitshk(
273 const s87 f)
274{
275 union { int_hk_t r; s87 fx; } x;
276
277 x.fx = f;
278 return x.r;
279}
280
284
285static inline int_k_t bitsk(
286 const s1615 f)
287{
288 union { int_k_t r; s1615 fx; } x;
289
290 x.fx = f;
291 return x.r;
292}
293
297
298static inline int_lk_t bitslk(
299 const s3231 f)
300{
301 union { int_lk_t r; s3231 fx; } x;
302
303 x.fx = f;
304 return x.r;
305}
306
310
311static inline uint_uhr_t bitsuhr(
312 const u08 f)
313{
314 union { uint_uhr_t r; u08 fx; } x;
315
316 x.fx = f;
317 return x.r;
318}
319
323
324static inline uint_ur_t bitsur(
325 const u016 f)
326{
327 union { uint_ur_t r; u016 fx; } x;
328
329 x.fx = f;
330 return x.r;
331}
332
336
337static inline uint_ulr_t bitsulr(
338 const u032 f)
339{
340 union { uint_ulr_t r; u032 fx; } x;
341
342 x.fx = f;
343 return x.r;
344}
345
349
350static inline uint_uhk_t bitsuhk(
351 const u88 f)
352{
353 union { uint_uhk_t r; u88 fx; } x;
354
355 x.fx = f;
356 return x.r;
357}
358
362
363static inline uint_uk_t bitsuk(
364 const u1616 f)
365{
366 union { uint_uk_t r; u1616 fx; } x;
367
368 x.fx = f;
369 return x.r;
370}
371
375
376static inline uint_ulk_t bitsulk(
377 const u3232 f)
378{
379 union { uint_ulk_t r; u3232 fx; } x;
380
381 x.fx = f;
382 return x.r;
383}
385
389
393
394static inline s07 hrbits(
395 const int_hr_t n)
396{
397 union { int_hr_t r; s07 fx; } x;
398
399 x.r = n;
400 return x.fx;
401}
402
406
407static inline s015 rbits(
408 const int_r_t n)
409{
410 union { int_r_t r; s015 fx; } x;
411
412 x.r = n;
413 return x.fx;
414}
415
419
420static inline s031 lrbits(
421 const int_lr_t n)
422{
423 union { int_lr_t r; s031 fx; } x;
424
425 x.r = n;
426 return x.fx;
427}
428
432
433static inline s87 hkbits(
434 const int_hk_t n)
435{
436 union { int_hk_t r; s87 fx; } x;
437
438 x.r = n;
439 return x.fx;
440}
441
445
446static inline s1615 kbits(
447 const int_k_t n)
448{
449 union { int_k_t r; s1615 fx; } x;
450
451 x.r = n;
452 return x.fx;
453}
454
458
459static inline s3231 lkbits(
460 const int_lk_t n)
461{
462 union { int_lk_t r; s3231 fx; } x;
463
464 x.r = n;
465 return x.fx;
466}
467
471
472static inline u08 uhrbits(
473 const uint_uhr_t n)
474{
475 union { uint_uhr_t r; u08 fx; } x;
476
477 x.r = n;
478 return x.fx;
479}
480
484
485static inline u016 urbits(
486 const uint_ur_t n)
487{
488 union { uint_ur_t r; u016 fx; } x;
489
490 x.r = n;
491 return x.fx;
492}
493
497
498static inline u032 ulrbits(
499 const uint_ulr_t n)
500{
501 union { uint_ulr_t r; u032 fx; } x;
502
503 x.r = n;
504 return x.fx;
505}
506
510
511static inline u88 uhkbits(
512 const uint_uhk_t n)
513{
514 union { uint_uhk_t r; u88 fx; } x;
515
516 x.r = n;
517 return x.fx;
518}
519
523
524static inline u1616 ukbits(
525 const uint_uk_t n)
526{
527 union { uint_uk_t r; u1616 fx; } x;
528
529 x.r = n;
530 return x.fx;
531}
532
536
537static inline u3232 ulkbits(
538 const uint_ulk_t n)
539{
540 union { uint_ulk_t r; u3232 fx; } x;
541
542 x.r = n;
543 return x.fx;
544}
546
547// Wrapped casts
549#define __I(x) ((int) (x))
551#define __I32(x) ((int32_t) (x))
553#define __I64(x) ((int64_t) (x))
555#define __LI(x) ((long int) (x))
557#define __U32(x) ((uint32_t) (x))
559#define __U64(x) ((uint64_t) (x))
561#define __UI(x) ((unsigned int) (x))
563#define __ULI(x) ((unsigned long int) (x))
564
565// Saturation operations
566
570
571static inline int32_t __stdfix_sat_hr(
572 const int32_t x)
573{
574 if (x > INT8_MAX) {
575 return INT8_MAX;
576 }
577 if (x < INT8_MIN) {
578 return INT8_MIN;
579 }
580
581 return x;
582}
583
587
588static inline int32_t __stdfix_sat_r(
589 const int32_t x)
590{
591 if (x > INT16_MAX) {
592 return INT16_MAX;
593 }
594 if (x < INT16_MIN) {
595 return INT16_MIN;
596 }
597
598 return x;
599}
600
604
605static inline int32_t __stdfix_sat_lr(
606 const int64_t x)
607{
608 if (x > INT32_MAX) {
609 return INT32_MAX;
610 }
611 if (x < INT32_MIN) {
612 return INT32_MIN;
613 }
614
615 return __I32(x);
616}
617
621
622static inline int32_t __stdfix_sat_hk(
623 const int32_t x)
624{
625 if (x > INT16_MAX) {
626 return INT16_MAX;
627 }
628 if (x < INT16_MIN) {
629 return INT16_MIN;
630 }
631
632 return x;
633}
634
638
639static inline int32_t __stdfix_sat_k(
640 const int64_t x)
641{
642 if (x > INT32_MAX) {
643 return INT32_MAX;
644 }
645 if (x < INT32_MIN) {
646 return INT32_MIN;
647 }
648
649 return __I32(x);
650}
651
655
656static inline uint32_t __stdfix_sat_uhr(
657 const uint32_t x)
658{
659 if (x > UINT8_MAX) {
660 return UINT8_MAX;
661 }
662
663 return x;
664}
665
669
670static inline uint32_t __stdfix_sat_ur(
671 const uint32_t x)
672{
673 if (x > UINT16_MAX) {
674 return UINT16_MAX;
675 }
676
677 return x;
678}
679
683
684static inline uint32_t __stdfix_sat_ulr(
685 const uint64_t x)
686{
687 if (x > UINT32_MAX) {
688 return UINT32_MAX;
689 }
690
691 return __U32(x);
692}
693
697
698static inline uint32_t __stdfix_sat_uhk(
699 const uint32_t x)
700{
701 if (x > UINT16_MAX) {
702 return UINT16_MAX;
703 }
704
705 return x;
706}
707
711
712static inline uint32_t __stdfix_sat_uk(
713 const uint64_t x)
714{
715 if (x > UINT32_MAX) {
716 return UINT32_MAX;
717 }
718
719 return __U32(x);
720}
721
722// software simulation of basic saturating arithmetic
723
728
729static inline int32_t __stdfix_sadd_hr(
730 int_hr_t x,
731 int_hr_t y)
732{
733 return __stdfix_sat_hr(__I32(x) + __I32(y));
734}
735
740
741static inline int32_t __stdfix_ssub_hr(
742 int_hr_t x,
743 int_hr_t y)
744{
745 return __stdfix_sat_hr(__I32(x) - __I32(y));
746}
747
751
752static inline int32_t __stdfix_sneg_hr(
753 int_hr_t x)
754{
755 return __stdfix_sat_hr(__I32(-x));
756}
757
762
763static inline int32_t __stdfix_sadd_r(
764 int32_t x,
765 int32_t y)
766{
767 return __stdfix_sat_r(__I32(x) + __I32(y));
768}
769
774
775static inline int32_t __stdfix_ssub_r(
776 int32_t x,
777 int32_t y)
778{
779 return __stdfix_sat_r(__I32(x) - __I32(y));
780}
781
785
786static inline int32_t __stdfix_sneg_r(
787 int32_t x)
788{
789 return __stdfix_sat_r(__I32(-x));
790}
791
796
797static inline int32_t __stdfix_sadd_lr(
798 int32_t x,
799 int32_t y)
800{
801 return __stdfix_sat_lr(__I64(x) + __I64(y));
802}
803
808
809static inline int32_t __stdfix_ssub_lr(
810 int32_t x,
811 int32_t y)
812{
813 return __stdfix_sat_lr(__I64(x) - __I64(y));
814}
815
819
820static inline int32_t __stdfix_sneg_lr(
821 int32_t x)
822{
823 return __stdfix_sat_lr(__I64(-x));
824}
825
830
831static inline int32_t __stdfix_sadd_hk(
832 int32_t x,
833 int32_t y)
834{
835 return __stdfix_sat_hk(__I32(x) + __I32(y));
836}
837
842
843static inline int32_t __stdfix_ssub_hk(
844 int32_t x,
845 int32_t y)
846{
847 return __stdfix_sat_hk(__I32(x) - __I32(y));
848}
849
853
854static inline int32_t __stdfix_sneg_hk(
855 int32_t x)
856{
857 return __stdfix_sat_hk(__I32(-x));
858}
859
864
865static inline int32_t __stdfix_sadd_k(
866 int32_t x,
867 int32_t y)
868{
869#ifdef __ARM_FEATURE_DSP
870 return __qadd(x, y);
871#else /*__ARM_FEATURE_DSP*/
872 return __stdfix_sat_k(__I64(x) + __I64(y));
873#endif /*__ARM_FEATURE_DSP*/
874}
875
880
881static inline int32_t __stdfix_ssub_k(
882 int32_t x,
883 int32_t y)
884{
885#ifdef __ARM_FEATURE_DSP
886 return __qsub(x, y);
887#else /*__ARM_FEATURE_DSP*/
888 return __stdfix_sat_k(__I64(x) - __I64(y));
889#endif /*__ARM_FEATURE_DSP*/
890}
891
895
896static inline int32_t __stdfix_sneg_k(
897 int32_t x)
898{
899#ifdef __ARM_FEATURE_DSP
900 return __qsub(0, x);
901#else /*__ARM_FEATURE_DSP*/
902 return __stdfix_sat_k(__I64(-x));
903#endif /*__ARM_FEATURE_DSP*/
904}
905
910
911int64_t __stdfix_sadd_lk(int64_t x, int64_t y);
912
917
918int64_t __stdfix_ssub_lk(int64_t x, int64_t y);
919
923
924int64_t __stdfix_sneg_lk(int64_t x);
925
930
931static inline int32_t __stdfix_smul_hr(
932 int32_t x,
933 int32_t y)
934{
935 if (x == INT8_MIN && y == INT8_MIN) { // special case for -1.0*-1.0
936 return INT8_MAX;
937 }
938
939 return __I32(__stdfix_sat_hr((__I32(x) * __I32(y)) >> 7));
940}
941
946
947static inline int32_t __stdfix_smul_r(
948 int32_t x,
949 int32_t y)
950{
951 if (x == INT16_MIN && y == INT16_MIN) { // special case for -1.0*-1.0
952 return INT16_MAX;
953 }
954
955 return __I32(__stdfix_sat_r((__I32(x) * __I32(y)) >> 15));
956}
957
962
963static inline int32_t __stdfix_smul_lr(
964 int32_t x,
965 int32_t y)
966{
967 if (x == INT32_MIN && y == INT32_MIN) { // special case for -1.0*-1.0
968 return INT32_MAX;
969 }
970
971 return __stdfix_sat_lr((__I64(x) * __I64(y)) >> 31);
972}
973
978
979static inline int32_t __stdfix_smul_hk(
980 int32_t x,
981 int32_t y)
982{
983 if (x == INT16_MIN && y == INT16_MIN) { // special case for -1.0*-1.0
984 return INT16_MAX;
985 }
986
987 return __stdfix_sat_hk((__I32(x) * __I32(y)) >> 7);
988}
989
994
995static inline int32_t __stdfix_smul_k(
996 int32_t x,
997 int32_t y)
998{
999 if (x == INT32_MIN && y == INT32_MIN) { // special case for -1.0*-1.0
1000 return INT32_MAX;
1001 }
1002
1003 return __stdfix_sat_k((__I64(x) * __I64(y)) >> 15);
1004}
1005
1010
1011int64_t __stdfix_smul_lk(int64_t x, int64_t y);
1012
1018
1019static inline uint32_t __stdfix_sadd_uhr(
1020 uint32_t x,
1021 uint32_t y)
1022{
1023 return __stdfix_sat_uhr(__U32(x) + __U32(y));
1024}
1025
1031
1032static inline uint32_t __stdfix_ssub_uhr(
1033 uint32_t x,
1034 uint32_t y)
1035{
1036 return __stdfix_sat_uhr(__U32(x) - __U32(y));
1037}
1038
1044
1045static inline uint32_t __stdfix_sadd_ur(
1046 uint32_t x,
1047 uint32_t y)
1048{
1049 return __stdfix_sat_ur(__U32(x) + __U32(y));
1050}
1051
1057
1058static inline uint32_t __stdfix_ssub_ur(
1059 uint32_t x,
1060 uint32_t y)
1061{
1062 return __stdfix_sat_ur(__U32(x) - __U32(y));
1063}
1064
1070
1071static inline uint32_t __stdfix_sadd_ulr(
1072 uint32_t x,
1073 uint32_t y)
1074{
1075 return __stdfix_sat_ulr(__U64(x) + __U64(y));
1076}
1077
1083
1084static inline uint32_t __stdfix_ssub_ulr(
1085 uint32_t x,
1086 uint32_t y)
1087{
1088 return __stdfix_sat_ulr(__U64(x) - __U64(y));
1089}
1090
1096
1097static inline uint32_t __stdfix_sadd_uhk(
1098 uint32_t x,
1099 uint32_t y)
1100{
1101 return __stdfix_sat_uhk(__U32(x) + __U32(y));
1102}
1103
1109
1110static inline uint32_t __stdfix_ssub_uhk(
1111 uint32_t x,
1112 uint32_t y)
1113{
1114 return __stdfix_sat_uhk(__U32(x) - __U32(y));
1115}
1116
1122
1123static inline uint32_t __stdfix_sadd_uk(
1124 uint32_t x,
1125 uint32_t y)
1126{
1127 return __stdfix_sat_uk(__U64(x) + __U64(y));
1128}
1129
1135
1136static inline uint32_t __stdfix_ssub_uk(
1137 uint32_t x,
1138 uint32_t y)
1139{
1140 return __stdfix_sat_uk(__U64(x) - __U64(y));
1141}
1142
1148
1149uint64_t __stdfix_sadd_ulk(uint64_t x, uint64_t y);
1150
1156
1157uint64_t __stdfix_ssub_ulk(uint64_t x, uint64_t y);
1158
1167
1168static inline uint32_t __stdfix_smul_uhr(
1169 uint32_t x,
1170 uint32_t y)
1171{
1172 return __stdfix_sat_uhr((__U32(x) * __U32(y)) >> 8);
1173}
1174
1181
1182static inline uint32_t __stdfix_smul_ur(
1183 uint32_t x,
1184 uint32_t y)
1185{
1186 return __stdfix_sat_ur((__U32(x) * __U32(y)) >> 16);
1187}
1188
1197
1198static inline uint32_t __stdfix_smul_ulr(
1199 uint32_t x,
1200 uint32_t y)
1201{
1202 return __stdfix_sat_ulr((__U64(x) * __U64(y)) >> 32);
1203}
1204
1213
1214static inline uint32_t __stdfix_smul_uhk(
1215 uint32_t x,
1216 uint32_t y)
1217{
1218 return __stdfix_sat_uhk((__U32(x) * __U32(y)) >> 8);
1219}
1220
1227
1228static inline uint32_t __stdfix_smul_uk(
1229 uint32_t x,
1230 uint32_t y)
1231{
1232 return __stdfix_sat_uk((__U64(x) * __U64(y)) >> 16);
1233}
1234
1243
1244uint64_t __stdfix_smul_ulk(uint64_t x, uint64_t y);
1245
1258
1263
1264static inline int mulir(
1265 int n,
1266 s015 x)
1267{
1268 return __I((__I64(n) * __I64(bitsr(x))) >> 15);
1269}
1270
1275
1276static inline long int mulilr(
1277 long int n,
1278 s031 x)
1279{
1280 return __LI((__I64(n) * __I64(bitslr(x))) >> 31);
1281}
1282
1287
1288static inline int mulik(
1289 int n,
1290 s1615 x)
1291{
1292 return __I((__I64(n) * __I64(bitsk(x))) >> 15);
1293}
1294
1300
1301static inline long int mulilk(
1302 long int n,
1303 s3231 x)
1304{
1305 int64_t r = bitslk(x);
1306 int64_t k = __I64(n) * (r >> 31);
1307 int64_t c = (__I64(n) * (r & INT64_C(0x7FFFFFF))) >> 31;
1308
1309 return __LI(k + c);
1310}
1311
1316
1317static inline int divir(
1318 int n,
1319 s015 x)
1320{
1321 return __I((__I64(n) << 15) / bitsr(x));
1322}
1323
1328
1329static inline long int divilr(
1330 long int n,
1331 s031 x)
1332{
1333 return __LI((__I64(n) << 31) / bitslr(x));
1334}
1335
1340
1341static inline int divik(
1342 int n,
1343 s1615 x)
1344{
1345 return __LI((__I64(n) << 15) / bitsk(x));
1346}
1347
1352
1353static inline long int divilk(
1354 long int n,
1355 s3231 x)
1356{
1357 return __LI((__I64(n) << 31) / bitslk(x));
1358}
1359
1364
1365static inline s015 rdivi(
1366 int i,
1367 int j)
1368{
1369 return rbits((int_r_t) ((__I64(i) << 15) / __I64(j)));
1370}
1371
1376
1377static inline s031 lrdivi(
1378 long int i,
1379 long int j)
1380{
1381 return lrbits((int_lr_t) ((__I64(i) << 31) / __I64(j)));
1382}
1383
1388
1389static inline s1615 kdivi(
1390 int i,
1391 int j)
1392{
1393 return kbits((int_k_t) ((__I64(i) << 15) / __I64(j)));
1394}
1395
1400
1401static inline s3231 lkdivi(
1402 long int i,
1403 long int j)
1404{
1405 return lkbits((int_lk_t) ((__I64(i) << 31) / __I64(j)));
1406}
1407
1412
1413static inline int idivr(
1414 s015 x,
1415 s015 y)
1416{
1417 return __I(rbits(x) / rbits(y));
1418}
1419
1424
1425static inline long int idivlr(
1426 s031 x,
1427 s031 y)
1428{
1429 return __LI(lrbits(x) / lrbits(y));
1430}
1431
1436
1437static inline int idivk(
1438 s1615 x,
1439 s1615 y)
1440{
1441 return __I(kbits(x) / kbits(y));
1442}
1443
1448
1449static inline long int idivlk(
1450 s3231 x,
1451 s3231 y)
1452{
1453 return __LI(lkbits(x) / lkbits(y));
1454}
1455
1461
1462static inline unsigned int muliur(
1463 unsigned int n,
1464 u016 x)
1465{
1466 return __UI((__U64(n) * __U64(bitsur(x))) >> 16);
1467}
1468
1474
1475static inline unsigned long int muliulr(
1476 unsigned long int n,
1477 u032 x)
1478{
1479 return __ULI((__U64(n) * __U64(bitsulr(x))) >> 32);
1480}
1481
1487
1488static inline unsigned int muliuk(
1489 unsigned int n,
1490 u1616 x)
1491{
1492 return __UI(__U64(n) * __U64(bitsuk(x)) >> 16);
1493}
1494
1500
1501static inline unsigned long int muliulk(
1502 unsigned long int n,
1503 u3232 x)
1504{
1505 uint64_t r = bitsulk(x);
1506 uint64_t k = __U64(n) * (r >> 32);
1507 uint64_t c = (__U64(n) * (r & INT64_C(0xFFFFFFF))) >> 32;
1508
1509 return __ULI(k + c);
1510}
1511
1517
1518static inline unsigned int diviur(
1519 unsigned int n,
1520 u016 x)
1521{
1522 return __UI((__U64(n) << 16) / bitsur(x));
1523}
1524
1530
1531static inline unsigned long int diviulr(
1532 unsigned long int n,
1533 u032 x)
1534{
1535 return __ULI((__U64(n) << 32) / bitsulr(x));
1536}
1537
1543
1544static inline unsigned int diviuk(
1545 unsigned int n,
1546 u1616 x)
1547{
1548 return __ULI((__U64(n) << 16) / bitsuk(x));
1549}
1550
1556
1557static inline unsigned long int diviulk(
1558 unsigned long int n,
1559 u3232 x)
1560{
1561 return __ULI((__U64(n) << 32) / bitsulk(x));
1562}
1563
1568
1569static inline u016 urdivi(
1570 unsigned int i,
1571 unsigned int j)
1572{
1573 return ulrbits((uint_ulr_t) ((__U64(i) << 16) / __U64(j)));
1574}
1575
1581
1582static inline u032 ulrdivi(
1583 unsigned long int i,
1584 unsigned long int j)
1585{
1586 return ulrbits((uint_ulr_t) ((__U64(i) << 32) / __U64(j)));
1587}
1588
1593
1594static inline u1616 ukdivi(
1595 unsigned int i,
1596 unsigned int j)
1597{
1598 return ukbits((uint_uk_t) ((__U64(i) << 16) / __U64(j)));
1599}
1600
1606
1607static inline u3232 ulkdivi(
1608 unsigned long int i,
1609 unsigned long int j)
1610{
1611 return ulkbits((uint_ulk_t) ((__U64(i) << 32) / __U64(j)));
1612}
1613
1618
1619static inline unsigned int idivur(
1620 u016 x,
1621 u016 y)
1622{
1623 return __UI(urbits(x) / urbits(y));
1624}
1625
1631
1632static inline unsigned long int idivulr(
1633 u032 x,
1634 u032 y)
1635{
1636 return __ULI(ulrbits(x) / ulrbits(y));
1637}
1638
1643
1644static inline unsigned int idivuk(
1645 u1616 x,
1646 u1616 y)
1647{
1648 return __UI(ukbits(x) / ukbits(y));
1649}
1650
1655
1656static inline unsigned long int idivulk(
1657 u3232 x,
1658 u3232 y)
1659{
1660 return __ULI(ulkbits(x) / ulkbits(y));
1661}
1663
1672
1676
1677static inline s07 abshr(
1678 s07 f)
1679{
1680 int_hr_t r = bitshr(f);
1681
1682 if (r < 0) {
1683 r = (r == INT8_MIN) ? INT8_MAX : -r;
1684 }
1685
1686 return hrbits(r);
1687}
1688
1692
1693static inline s015 absr(
1694 s015 f)
1695{
1696 int_r_t r = bitsr(f);
1697
1698 if (r < 0) {
1699 r = (r == INT16_MIN) ? INT16_MAX : -r;
1700 }
1701
1702 return rbits(r);
1703}
1704
1708
1709static inline s031 abslr(
1710 s031 f)
1711{
1712 int_lr_t r = bitslr(f);
1713
1714 if (r < 0) {
1715 r = (r == INT32_MIN) ? INT32_MAX : -r;
1716 }
1717
1718 return lrbits(r);
1719}
1720
1724
1725static inline s87 abshk(
1726 s87 f)
1727{
1728 int_hk_t r = bitshk(f);
1729
1730 if (r < 0) {
1731 r = (r == INT16_MIN) ? INT16_MAX : -r;
1732 }
1733
1734 return hkbits(r);
1735}
1736
1740
1741static inline s1615 absk(
1742 s1615 f)
1743{
1744 int_k_t r = bitsk(f);
1745
1746 if (r < 0) {
1747 r = (r == INT32_MIN) ? INT32_MAX : -r;
1748 }
1749
1750 return kbits(r);
1751}
1752
1756
1757static inline s3231 abslk(
1758 s3231 f)
1759{
1760 int_lk_t r = bitslk(f);
1761
1762 if (r < 0) {
1763 r = (r == INT64_MIN) ? INT64_MAX : -r;
1764 }
1765
1766 return lkbits(r);
1767}
1769
1785
1791
1792static inline uint8_t __stdfix_round_u8(
1793 uint8_t x,
1794 int n)
1795{
1796 register uint8_t r, c;
1797
1798 c = (x >> (n-1)) & 0x1;
1799 r = x >> n;
1800 r = (r + c) << n;
1801
1802 return r;
1803}
1804
1810
1811static inline uint16_t __stdfix_round_u16(
1812 uint16_t x,
1813 int n)
1814{
1815 register uint16_t r, c;
1816
1817 c = (x >> (n-1)) & 0x1;
1818 r = x >> n;
1819 r = (r + c) << n;
1820
1821 return r;
1822}
1823
1829
1830static inline uint32_t __stdfix_round_u32(
1831 uint32_t x,
1832 int n)
1833{
1834 register uint32_t r, c;
1835
1836 c = (x >> (n-1)) & 0x1;
1837 r = x >> n;
1838 r = (r + c) << n;
1839
1840 return r;
1841}
1842
1848
1849static inline uint64_t __stdfix_round_u64(
1850 uint64_t x,
1851 int n)
1852{
1853 register uint64_t r, c;
1854
1855 c = (x >> (n-1)) & 0x1;
1856 r = x >> n;
1857 r = (r + c) << n;
1858
1859 return r;
1860}
1861
1867
1868static inline int8_t __stdfix_round_s8(
1869 int8_t x,
1870 int n)
1871{
1872 register int8_t r, c;
1873
1874 c = (x >> (n-1)) & 0x1;
1875 r = x >> n;
1876 r = (r + c) << n;
1877
1878 return r;
1879}
1880
1886
1887static inline int16_t __stdfix_round_s16(
1888 int16_t x,
1889 int n)
1890{
1891 register int16_t r, c;
1892
1893 c = (x >> (n-1)) & 0x1;
1894 r = x >> n;
1895 r = (r + c) << n;
1896
1897 return r;
1898}
1899
1905
1906static inline int32_t __stdfix_round_s32(
1907 int32_t x,
1908 int n)
1909{
1910 register int32_t r, c;
1911
1912 c = (x >> (n-1)) & 0x1;
1913 r = x >> n;
1914 r = (r + c) << n;
1915
1916 return r;
1917}
1918
1924
1925static inline int64_t __stdfix_round_s64(
1926 int64_t x,
1927 int n)
1928{
1929 register int64_t r, c;
1930
1931 c = (x >> (n-1)) & 0x1;
1932 r = x >> n;
1933 r = (r + c) << n;
1934
1935 return r;
1936}
1937
1943
1944static inline s07 roundhr(
1945 s07 f,
1946 int n)
1947{
1948 return hrbits(__stdfix_round_s8(bitshr(f), n));
1949}
1950
1956
1957static inline s015 roundr(
1958 s015 f,
1959 int n)
1960{
1961 return rbits(__stdfix_round_s16(bitsr(f), n));
1962}
1963
1969
1970static inline s031 roundlr(
1971 s031 f,
1972 int n)
1973{
1974 return lrbits(__stdfix_round_s32(bitslr(f), n));
1975}
1976
1982
1983static inline s87 roundhk(
1984 s87 f,
1985 int n)
1986{
1987 return hkbits(__stdfix_round_s16(bitshk(f), n));
1988}
1989
1995
1996static inline s1615 roundk(
1997 s1615 f,
1998 int n)
1999{
2000 return kbits(__stdfix_round_s32(bitsk(f), n));
2001}
2002
2008
2009static inline s3231 roundlk(
2010 s3231 f,
2011 int n)
2012{
2013 return lkbits(__stdfix_round_s64(bitslk(f), n));
2014}
2015
2021
2022static inline u08 rounduhr(
2023 u08 f,
2024 int n)
2025{
2026 return uhrbits(__stdfix_round_u8(bitsuhr(f), n));
2027}
2028
2034
2035static inline u016 roundur(
2036 u016 f,
2037 int n)
2038{
2039 return urbits(__stdfix_round_u16(bitsur(f), n));
2040}
2041
2047
2048static inline u032 roundulr(
2049 u032 f,
2050 int n)
2051{
2052 return ulrbits(__stdfix_round_u32(bitsulr(f), n));
2053}
2054
2060
2061static inline u88 rounduhk(
2062 u88 f,
2063 int n)
2064{
2065 return uhkbits(__stdfix_round_u16(bitsuhk(f), n));
2066}
2067
2073
2074static inline u1616 rounduk(
2075 u1616 f,
2076 int n)
2077{
2078 return ukbits(__stdfix_round_u32(bitsuk(f), n));
2079}
2080
2086
2087static inline u3232 roundulk(
2088 u3232 f,
2089 int n)
2090{
2091 return ulkbits(__stdfix_round_u64(bitsulk(f), n));
2092}
2094
2110
2115
2116static inline int countlshr(
2117 s07 f)
2118{
2119 int32_t n = __I32(bitshr(f));
2120
2121 if (n == 0) {
2122 return 7;
2123 }
2124
2125 return __builtin_clrsb(n) - 24;
2126}
2127
2131
2132static inline int countlsr(
2133 s015 f)
2134{
2135 int32_t n = __I32(bitsr(f));
2136
2137 if (n == 0) {
2138 return 15;
2139 }
2140
2141 return __builtin_clrsb(n) - 16;
2142}
2143
2148
2149static inline int countlslr(
2150 s031 f)
2151{
2152 int_lr_t n = bitslr(f);
2153
2154 if (n == 0) {
2155 return 31;
2156 }
2157
2158 return __builtin_clrsb(n);
2159}
2160
2165
2166static inline int countlshk(
2167 s87 f)
2168{
2169 int32_t n = __I32(bitshk(f));
2170
2171 if (n == 0) {
2172 return 15;
2173 }
2174
2175 return __builtin_clrsb(n) - 16;
2176}
2177
2181
2182static inline int countlsk(
2183 s1615 f)
2184{
2185 int_k_t n = bitsk(f);
2186
2187 if (n == 0) {
2188 return 31;
2189 }
2190
2191 return __builtin_clrsb(n);
2192}
2193
2198
2199static inline int countlslk(
2200 s3231 f)
2201{
2202 int64_t n = __I64(bitslk(f));
2203
2204 if (n == 0) {
2205 return 63;
2206 }
2207
2208 return __builtin_clrsbll(n);
2209}
2210
2215
2216static inline int countlsuhr(
2217 u08 f)
2218{
2219 uint32_t n = __U32(bitsuhr(f));
2220
2221 if (n == 0) {
2222 return 8;
2223 }
2224
2225 return __builtin_clz(n) - 24;
2226}
2227
2232
2233static inline int countlsur(
2234 u016 f)
2235{
2236 uint32_t n = __U32(bitsur(f));
2237
2238 if (n == 0) {
2239 return 16;
2240 }
2241
2242 return __builtin_clz(n) - 16;
2243}
2244
2249
2250static inline int countlsulr(
2251 u032 f)
2252{
2253 uint_ulr_t n = bitsulr(f);
2254
2255 if (n == 0) {
2256 return 32;
2257 }
2258
2259 return __builtin_clz(n);
2260}
2261
2266
2267static inline int countlsuhk(
2268 u88 f)
2269{
2270 uint32_t n = __U32(bitsuhk(f));
2271
2272 if (n == 0) {
2273 return 16;
2274 }
2275
2276 return __builtin_clz(n) - 16;
2277}
2278
2283
2284static inline int countlsuk(
2285 u1616 f)
2286{
2287 uint_uk_t n = (uint_uk_t) bitsuk(f);
2288
2289 if (n == 0) {
2290 return 32;
2291 }
2292
2293 return __builtin_clz(n);
2294}
2295
2300
2301static inline int countlsulk(
2302 u3232 f)
2303{
2304 uint_ulk_t n = (uint_ulk_t) bitsulk(f);
2305
2306 if (n == 0) {
2307 return 64;
2308 }
2309
2310 return __builtin_clzll(n);
2311}
2313
2331
2336
2337#define absfx(f) \
2338 _Generic((f), \
2339 s07: abshr(f), \
2340 s015: absr(f), \
2341 s031: abslr(f), \
2342 s87: abshk(f), \
2343 s1615: absk(f), \
2344 s3231: abslk(f), \
2345 default: abort() \
2346 )
2347
2353
2354#define roundfx(f, n) \
2355 _Generic((f), \
2356 s07: roundhr(f, n), \
2357 s015: roundr(f, n), \
2358 s031: roundlr(f, n), \
2359 s87: roundhk(f, n), \
2360 s1615: roundk(f, n), \
2361 s3231: roundlk(f, n), \
2362 u08: rounduhr(f, n), \
2363 u016: roundur(f, n), \
2364 u032: roundulr(f, n), \
2365 u88: rounduhk(f, n), \
2366 u1616: rounduk(f, n), \
2367 u3232: roundulk(f, n), \
2368 default: abort() \
2369 )
2370
2375
2376#define countlsfx(f) \
2377 _Generic((f), \
2378 s07: countlshr(f), \
2379 s015: countlsr(f), \
2380 s031: countlslr(f), \
2381 s87: countlshk(f), \
2382 s1615: countlsk(f), \
2383 s3231: countlslk(f), \
2384 u08: countlsuhr(f), \
2385 u016: countlsur(f), \
2386 u032: countlsulr(f), \
2387 u88: countlsuhk(f), \
2388 u1616: countlsuk(f), \
2389 u3232: countlsulk(f), \
2390 default: abort() \
2391 )
2393
2456
2457#ifndef __arm__
2458s07 strtofxhr (const char *restrict nptr, char **restrict endptr);
2459s015 strtofxr (const char *restrict nptr, char **restrict endptr);
2460s031 strtofxlr (const char *restrict nptr, char **restrict endptr);
2461s87 strtofxhk (const char *restrict nptr, char **restrict endptr);
2462s1615 strtofxk (const char *restrict nptr, char **restrict endptr);
2463s3231 strtofxlk (const char *restrict nptr, char **restrict endptr);
2464
2465u08 strtofxuhr(const char *restrict nptr, char **restrict endptr);
2466u016 strtofxur (const char *restrict nptr, char **restrict endptr);
2467u032 strtofxulr(const char *restrict nptr, char **restrict endptr);
2468u88 strtofxuhk(const char *restrict nptr, char **restrict endptr);
2469u1616 strtofxuk (const char *restrict nptr, char **restrict endptr);
2470u3232 strtofxulk(const char *restrict nptr, char **restrict endptr);
2471#endif /*__arm__*/
2472
2474
2475#endif /* __STDFIX_FULL_ISO_H__ */
static unsigned long int muliulr(unsigned long int n, u032 x)
Multiplies an unsigned long integer by an unsigned long fract giving an unsigned integer answer.
Definition stdfix-full-iso.h:1475
short fract s07
An alternative name for the signed short fract type.
Definition stdfix-full-iso.h:172
static uint32_t __stdfix_sadd_ur(uint32_t x, uint32_t y)
Saturated addition of the underlying unsigned integer representations.
Definition stdfix-full-iso.h:1045
int16_t int_r_t
This is the integer type into which signed fract can be converted.
Definition stdfix-full-iso.h:117
static s3231 lkbits(const int_lk_t n)
Converts a signed integer into a signed long accum.
Definition stdfix-full-iso.h:459
void __stdfix_64x64_128(uint64_t *hi, uint64_t *lo, uint64_t x, uint64_t y)
Multiplies two 64-bit unsigned integers returning a 128-bit result in hi and lo.
static long int divilk(long int n, s3231 x)
Divides an integer by a long accum giving a long integer answer.
Definition stdfix-full-iso.h:1353
static u3232 roundulk(u3232 f, int n)
This function rounds the input unsigned long accum to a number of bits, returning an unsigned long ac...
Definition stdfix-full-iso.h:2087
uint64_t __stdfix_sadd_ulk(uint64_t x, uint64_t y)
Saturated addition of the underlying unsigned integer representations.
static uint_uhk_t bitsuhk(const u88 f)
Converts an unsigned short accum into an integer.
Definition stdfix-full-iso.h:350
static unsigned int diviuk(unsigned int n, u1616 x)
Divides an unsigned integer by an unsigned accum giving an unsigned integer answer.
Definition stdfix-full-iso.h:1544
static int countlsuhr(u08 f)
This function counts the number of leading zeros of an unsigned short fract.
Definition stdfix-full-iso.h:2216
uint32_t uint_ulr_t
This is the unsigned integer type into which unsigned long fract can be converted.
Definition stdfix-full-iso.h:144
static int countlsulr(u032 f)
This function counts the number of leading zeros of an unsigned long fract.
Definition stdfix-full-iso.h:2250
static u032 ulrbits(const uint_ulr_t n)
Converts an unsigned integer into an unsigned long fract.
Definition stdfix-full-iso.h:498
static int countlsuk(u1616 f)
This function counts the number of leading zeros of an unsigned accum.
Definition stdfix-full-iso.h:2284
#define __UI(x)
Cast to unsigned int.
Definition stdfix-full-iso.h:561
static int divik(int n, s1615 x)
Divides an integer by an accum giving an integer answer.
Definition stdfix-full-iso.h:1341
static int countlsk(s1615 f)
This function counts the number of leading sign-bits of an accum.
Definition stdfix-full-iso.h:2182
static s031 lrbits(const int_lr_t n)
Converts a signed integer into a signed long fract.
Definition stdfix-full-iso.h:420
static int_hr_t bitshr(const s07 f)
Converts a short fract into an integer.
Definition stdfix-full-iso.h:233
static uint32_t __stdfix_smul_ulr(uint32_t x, uint32_t y)
Saturated multiplication of the underlying unsigned integer representations.
Definition stdfix-full-iso.h:1198
static s07 roundhr(s07 f, int n)
This function rounds the input short fract to a number of bits, returning a short fract.
Definition stdfix-full-iso.h:1944
unsigned fract u016
An alternative name for the unsigned fract type.
Definition stdfix-full-iso.h:193
int64_t __stdfix_ssub_lk(int64_t x, int64_t y)
Saturated subtraction of the underlying integer representations.
unsigned accum u1616
An alternative name for the unsigned accum type.
Definition stdfix-full-iso.h:202
static int mulik(int n, s1615 x)
Multiplies an integer by an accum giving an integer answer.
Definition stdfix-full-iso.h:1288
static int32_t __stdfix_ssub_hr(int_hr_t x, int_hr_t y)
Saturated subtraction of the underlying integer representations.
Definition stdfix-full-iso.h:741
static int countlsur(u016 f)
This function counts the number of leading zeros of an unsigned fract.
Definition stdfix-full-iso.h:2233
static int countlsr(s015 f)
This function counts the number of leading sign-bits of a fract.
Definition stdfix-full-iso.h:2132
uint8_t uint_uhr_t
This is the unsigned integer type into which unsigned short accum can be converted.
Definition stdfix-full-iso.h:136
static int countlshr(s07 f)
This function counts the number of leading sign-bits of a short fract.
Definition stdfix-full-iso.h:2116
static int countlslr(s031 f)
This function counts the number of leading sign-bits of a long fract.
Definition stdfix-full-iso.h:2149
static uint32_t __stdfix_sadd_uk(uint32_t x, uint32_t y)
Saturated addition of the underlying unsigned integer representations.
Definition stdfix-full-iso.h:1123
static uint32_t __stdfix_smul_uhr(uint32_t x, uint32_t y)
Saturated multiplication of the underlying unsigned integer representations.
Definition stdfix-full-iso.h:1168
static int_lr_t bitslr(const s031 f)
Converts a long fract into an integer.
Definition stdfix-full-iso.h:259
static int mulir(int n, s015 x)
Multiplies an integer by a fract giving an integer answer.
Definition stdfix-full-iso.h:1264
uint16_t uint_ur_t
This is the unsigned integer type into which unsigned fract can be converted.
Definition stdfix-full-iso.h:140
long accum s3231
An alternative name for the signed long accum type.
Definition stdfix-full-iso.h:187
static long int idivlk(s3231 x, s3231 y)
Divides two long accums giving a long integer answer.
Definition stdfix-full-iso.h:1449
int16_t int_hk_t
This is the integer type into which signed short accum can be converted.
Definition stdfix-full-iso.h:125
static u016 roundur(u016 f, int n)
This function rounds the input unsigned fract to a number of bits, returning an unsigned fract.
Definition stdfix-full-iso.h:2035
static uint_uk_t bitsuk(const u1616 f)
Converts an unsigned accum into an integer.
Definition stdfix-full-iso.h:363
static int divir(int n, s015 x)
Divides an integer by a fract giving an integer answer.
Definition stdfix-full-iso.h:1317
static int32_t __stdfix_ssub_r(int32_t x, int32_t y)
Saturated subtraction of the underlying integer representations.
Definition stdfix-full-iso.h:775
static unsigned int muliur(unsigned int n, u016 x)
Multiplies an unsigned integer by an unsigned fract giving an unsigned integer answer.
Definition stdfix-full-iso.h:1462
static s015 roundr(s015 f, int n)
This function rounds the input fract to a number of bits, returning a fract.
Definition stdfix-full-iso.h:1957
int8_t int_hr_t
This is the integer type into which signed short fract can be converted.
Definition stdfix-full-iso.h:114
static u032 ulrdivi(unsigned long int i, unsigned long int j)
Divides two unsigned long integers giving an unsigned long fract answer.
Definition stdfix-full-iso.h:1582
static u1616 ukdivi(unsigned int i, unsigned int j)
Divides two unsigned integers giving an unsigned accum answer.
Definition stdfix-full-iso.h:1594
#define __U32(x)
Cast to uint32_t.
Definition stdfix-full-iso.h:557
static int32_t __stdfix_sat_hr(const int32_t x)
Saturates an integer to 8 bits.
Definition stdfix-full-iso.h:571
static uint32_t __stdfix_ssub_uhk(uint32_t x, uint32_t y)
Saturated subtraction of the underlying unsigned integer representations.
Definition stdfix-full-iso.h:1110
static unsigned long int idivulr(u032 x, u032 y)
Divides two unsigned long fracts giving an unsigned long integer answer.
Definition stdfix-full-iso.h:1632
static u08 uhrbits(const uint_uhr_t n)
Converts an unsigned integer into an unsigned short fract.
Definition stdfix-full-iso.h:472
fract s015
An alternative name for the signed fract type.
Definition stdfix-full-iso.h:175
static uint32_t __stdfix_sat_ur(const uint32_t x)
Saturates an unsigned integer to 16 bits.
Definition stdfix-full-iso.h:670
int64_t __stdfix_sneg_lk(int64_t x)
Saturated negation of the underlying integer representations.
static uint32_t __stdfix_sadd_uhk(uint32_t x, uint32_t y)
Saturated addition of the underlying unsigned integer representations.
Definition stdfix-full-iso.h:1097
#define __U64(x)
Cast to uint64_t.
Definition stdfix-full-iso.h:559
uint32_t uint_uk_t
This is the unsigned integer type into which unsigned accum can be converted.
Definition stdfix-full-iso.h:152
uint64_t __stdfix_ssub_ulk(uint64_t x, uint64_t y)
Saturated subtraction of the underlying unsigned integer representations.
uint64_t __stdfix_smul_ulk(uint64_t x, uint64_t y)
Saturated multiplication of the underlying unsigned integer representations.
static u08 rounduhr(u08 f, int n)
This function rounds the input unsigned short fract to a number of bits, returning an unsigned short ...
Definition stdfix-full-iso.h:2022
static uint_uhr_t bitsuhr(const u08 f)
Converts an unsigned short fract into an integer.
Definition stdfix-full-iso.h:311
static int_k_t bitsk(const s1615 f)
Converts an accum into an integer.
Definition stdfix-full-iso.h:285
static int32_t __stdfix_sneg_k(int32_t x)
Saturated negation of the underlying integer representations.
Definition stdfix-full-iso.h:896
static unsigned int idivuk(u1616 x, u1616 y)
Divides two unsigned accums giving an unsigned integer answer.
Definition stdfix-full-iso.h:1644
static uint16_t __stdfix_round_u16(uint16_t x, int n)
This function rounds the input unsigned 16-bit integer to a number of bits, returning a 16-bit intege...
Definition stdfix-full-iso.h:1811
static unsigned long int diviulk(unsigned long int n, u3232 x)
Divides a long unsigned integer by a long unsigned accum giving an unsigned integer answer.
Definition stdfix-full-iso.h:1557
static int32_t __stdfix_smul_hk(int32_t x, int32_t y)
Saturated multiplication of the underlying integer representations.
Definition stdfix-full-iso.h:979
static long int mulilk(long int n, s3231 x)
Multiplies a long integer by a long accum giving a long integer answer.
Definition stdfix-full-iso.h:1301
int32_t int_lr_t
This is the integer type into which signed long fract can be converted.
Definition stdfix-full-iso.h:121
static s3231 roundlk(s3231 f, int n)
This function rounds the input long accum to a number of bits, returning a long accum.
Definition stdfix-full-iso.h:2009
static int16_t __stdfix_round_s16(int16_t x, int n)
This function rounds the input signed 16-bit integer to a number of bits, returning a 16-bit integer.
Definition stdfix-full-iso.h:1887
static int32_t __stdfix_smul_hr(int32_t x, int32_t y)
Saturated multiplication of the underlying integer representations.
Definition stdfix-full-iso.h:931
static int32_t __stdfix_sadd_r(int32_t x, int32_t y)
Saturated addition of the underlying integer representations.
Definition stdfix-full-iso.h:763
unsigned short fract u08
An alternative name for the unsigned short fract type.
Definition stdfix-full-iso.h:190
static int32_t __stdfix_sadd_lr(int32_t x, int32_t y)
Saturated addition of the underlying integer representations.
Definition stdfix-full-iso.h:797
static u88 uhkbits(const uint_uhk_t n)
Converts an unsigned integer into an unsigned short accum.
Definition stdfix-full-iso.h:511
static uint_ulk_t bitsulk(const u3232 f)
Converts an unsigned long accum into an integer.
Definition stdfix-full-iso.h:376
static int32_t __stdfix_sat_k(const int64_t x)
Saturates a 64-bit integer to 32-bits.
Definition stdfix-full-iso.h:639
static s1615 absk(s1615 f)
This function returns the absolute value of an accum.
Definition stdfix-full-iso.h:1741
static unsigned long int muliulk(unsigned long int n, u3232 x)
Multiplies an unsigned long integer by an unsigned long accum giving an unsigned long integer answer.
Definition stdfix-full-iso.h:1501
static int32_t __stdfix_smul_k(int32_t x, int32_t y)
Saturated multiplication of the underlying integer representations.
Definition stdfix-full-iso.h:995
static uint32_t __stdfix_smul_uhk(uint32_t x, uint32_t y)
Saturated multiplication of the underlying unsigned integer representations.
Definition stdfix-full-iso.h:1214
static s031 roundlr(s031 f, int n)
This function rounds the input long fract to a number of bits, returning a long fract.
Definition stdfix-full-iso.h:1970
static s3231 abslk(s3231 f)
This function returns the absolute value of a long accum.
Definition stdfix-full-iso.h:1757
static uint32_t __stdfix_sat_ulr(const uint64_t x)
Saturates an unsigned 64-bit integer to 32 bits.
Definition stdfix-full-iso.h:684
static s87 abshk(s87 f)
This function returns the absolute value of a short accum.
Definition stdfix-full-iso.h:1725
static int32_t __stdfix_sat_hk(const int32_t x)
Saturates an integer to 16 bits.
Definition stdfix-full-iso.h:622
static uint32_t __stdfix_round_u32(uint32_t x, int n)
This function rounds the input unsigned 32-bit integer to a number of bits, returning a 32-bit intege...
Definition stdfix-full-iso.h:1830
static int idivk(s1615 x, s1615 y)
Divides two accums giving an integer answer.
Definition stdfix-full-iso.h:1437
#define __I(x)
Cast to int.
Definition stdfix-full-iso.h:549
static int32_t __stdfix_ssub_hk(int32_t x, int32_t y)
Saturated subtraction of the underlying integer representations.
Definition stdfix-full-iso.h:843
static int_r_t bitsr(const s015 f)
Converts a fract into an integer.
Definition stdfix-full-iso.h:246
static int32_t __stdfix_sneg_hk(int32_t x)
Saturated negation of the underlying integer representations.
Definition stdfix-full-iso.h:854
int64_t int_lk_t
This is the integer type into which signed long accum can be converted.
Definition stdfix-full-iso.h:132
static unsigned int muliuk(unsigned int n, u1616 x)
Multiplies an unsigned integer by an unsigned accum giving an unsigned integer answer.
Definition stdfix-full-iso.h:1488
static int countlshk(s87 f)
This function counts the number of leading sign-bits of a short accum.
Definition stdfix-full-iso.h:2166
static uint32_t __stdfix_sadd_ulr(uint32_t x, uint32_t y)
Saturated addition of the underlying unsigned integer representations.
Definition stdfix-full-iso.h:1071
uint16_t uint_uhk_t
This is the unsigned integer type into which unsigned short accum can be converted.
Definition stdfix-full-iso.h:148
static uint32_t __stdfix_ssub_ur(uint32_t x, uint32_t y)
Saturated subtraction of the underlying unsigned integer representations.
Definition stdfix-full-iso.h:1058
static uint_ur_t bitsur(const u016 f)
Converts an unsigned fract into an integer.
Definition stdfix-full-iso.h:324
static int32_t __stdfix_sadd_hk(int32_t x, int32_t y)
Saturated addition of the underlying integer representations.
Definition stdfix-full-iso.h:831
static int countlsulk(u3232 f)
This function counts the number of leading zeros of an unsigned long accum.
Definition stdfix-full-iso.h:2301
static unsigned int diviur(unsigned int n, u016 x)
Divides an unsigned integer by an unsigned fract giving an unsigned integer answer.
Definition stdfix-full-iso.h:1518
static int32_t __stdfix_sadd_hr(int_hr_t x, int_hr_t y)
Saturated addition of the underlying integer representations.
Definition stdfix-full-iso.h:729
static u016 urdivi(unsigned int i, unsigned int j)
Divides two unsigned integers giving an unsigned fract answer.
Definition stdfix-full-iso.h:1569
static u016 urbits(const uint_ur_t n)
Converts an unsigned integer into an unsigned fract.
Definition stdfix-full-iso.h:485
static int32_t __stdfix_sneg_r(int32_t x)
Saturated negation of the underlying integer representations.
Definition stdfix-full-iso.h:786
int64_t __stdfix_sadd_lk(int64_t x, int64_t y)
Saturated addition of the underlying integer representations.
static uint_ulr_t bitsulr(const u032 f)
Converts an unsigned long fract into an integer.
Definition stdfix-full-iso.h:337
int64_t __stdfix_smul_lk(int64_t x, int64_t y)
Saturated multiplication of the underlying integer representations.
static s031 abslr(s031 f)
This function returns the absolute value of a long fract.
Definition stdfix-full-iso.h:1709
static uint64_t __stdfix_round_u64(uint64_t x, int n)
This function rounds the input unsigned 64-bit integer to a number of bits, returning a 64-bit intege...
Definition stdfix-full-iso.h:1849
static uint8_t __stdfix_round_u8(uint8_t x, int n)
This function rounds the input unsigned 8-bit integer to a number of bits, returning an 8-bit integer...
Definition stdfix-full-iso.h:1792
static u88 rounduhk(u88 f, int n)
This function rounds the input unsigned short accum to a number of bits, returning an unsigned short ...
Definition stdfix-full-iso.h:2061
int32_t int_k_t
This is the integer type into which signed accum can be converted.
Definition stdfix-full-iso.h:128
static int32_t __stdfix_sat_r(const int32_t x)
Saturates an integer to 16 bits.
Definition stdfix-full-iso.h:588
#define __ULI(x)
Cast to unsigned long int.
Definition stdfix-full-iso.h:563
static u032 roundulr(u032 f, int n)
This function rounds the input unsigned long fract to a number of bits, returning an unsigned long fr...
Definition stdfix-full-iso.h:2048
static s87 roundhk(s87 f, int n)
This function rounds the input short accum to a number of bits, returning a short accum.
Definition stdfix-full-iso.h:1983
long fract s031
An alternative name for the signed long fract type.
Definition stdfix-full-iso.h:178
static int32_t __stdfix_ssub_lr(int32_t x, int32_t y)
Saturated subtraction of the underlying integer representations.
Definition stdfix-full-iso.h:809
static s3231 lkdivi(long int i, long int j)
Divides two integers giving a long accum answer.
Definition stdfix-full-iso.h:1401
static uint32_t __stdfix_ssub_ulr(uint32_t x, uint32_t y)
Saturated subtraction of the underlying unsigned integer representations.
Definition stdfix-full-iso.h:1084
static unsigned long int idivulk(u3232 x, u3232 y)
Divides two unsigned long accums giving an unsigned long integer answer.
Definition stdfix-full-iso.h:1656
static uint32_t __stdfix_ssub_uk(uint32_t x, uint32_t y)
Saturated subtraction of the underlying unsigned integer representations.
Definition stdfix-full-iso.h:1136
static u1616 rounduk(u1616 f, int n)
This function rounds the input unsigned accum to a number of bits, returning an unsigned accum.
Definition stdfix-full-iso.h:2074
short accum s87
An alternative name for the signed short accum type.
Definition stdfix-full-iso.h:181
unsigned short accum u88
An alternative name for the unsigned short accum type.
Definition stdfix-full-iso.h:199
#define __LI(x)
Cast to long int.
Definition stdfix-full-iso.h:555
static int64_t __stdfix_round_s64(int64_t x, int n)
This function rounds the input signed 64-bit integer to a number of bits, returning a 64-bit integer.
Definition stdfix-full-iso.h:1925
accum s1615
An alternative name for the signed accum type.
Definition stdfix-full-iso.h:184
static u3232 ulkbits(const uint_ulk_t n)
Converts an unsigned integer into an unsigned long accum.
Definition stdfix-full-iso.h:537
static int32_t __stdfix_sneg_lr(int32_t x)
Saturated negation of the underlying integer representations.
Definition stdfix-full-iso.h:820
static int32_t __stdfix_smul_r(int32_t x, int32_t y)
Saturated multiplication of the underlying integer representations.
Definition stdfix-full-iso.h:947
static unsigned int idivur(u016 x, u016 y)
Divides two unsigned fracts giving an unsigned integer answer.
Definition stdfix-full-iso.h:1619
static s015 rbits(const int_r_t n)
Converts a signed integer into a signed fract.
Definition stdfix-full-iso.h:407
static int_hk_t bitshk(const s87 f)
Converts a short accum into an integer.
Definition stdfix-full-iso.h:272
static long int mulilr(long int n, s031 x)
Multiplies a long integer by a long fract giving an integer answer.
Definition stdfix-full-iso.h:1276
static unsigned long int diviulr(unsigned long int n, u032 x)
Divides a long unsigned integer by a long unsigned fract giving an unsigned integer answer.
Definition stdfix-full-iso.h:1531
static long int idivlr(s031 x, s031 y)
Divides two long fracts giving a long integer answer.
Definition stdfix-full-iso.h:1425
static u1616 ukbits(const uint_uk_t n)
Converts an unsigned integer into an unsigned accum.
Definition stdfix-full-iso.h:524
static uint32_t __stdfix_sat_uhk(const uint32_t x)
Saturates an unsigned integer to 16 bits.
Definition stdfix-full-iso.h:698
static int8_t __stdfix_round_s8(int8_t x, int n)
This function rounds the input signed 8-bit integer to a number of bits, returning an 8-bit integer.
Definition stdfix-full-iso.h:1868
static uint32_t __stdfix_smul_ur(uint32_t x, uint32_t y)
Saturated multiplication of the underlying unsigned integer representations.
Definition stdfix-full-iso.h:1182
static int32_t __stdfix_ssub_k(int32_t x, int32_t y)
Saturated subtraction of the underlying integer representations.
Definition stdfix-full-iso.h:881
static int countlsuhk(u88 f)
This function counts the number of leading zeros of an unsigned short accum.
Definition stdfix-full-iso.h:2267
static uint32_t __stdfix_sadd_uhr(uint32_t x, uint32_t y)
Saturated addition of the underlying unsigned integer representations.
Definition stdfix-full-iso.h:1019
static s07 hrbits(const int_hr_t n)
Converts a signed integer into a signed short fract.
Definition stdfix-full-iso.h:394
static s015 absr(s015 f)
This function returns the absolute value of a fract.
Definition stdfix-full-iso.h:1693
static s87 hkbits(const int_hk_t n)
Converts a signed integer into a signed short accum.
Definition stdfix-full-iso.h:433
static u3232 ulkdivi(unsigned long int i, unsigned long int j)
Divides two unsigned long integers giving an unsigned long accum answer.
Definition stdfix-full-iso.h:1607
unsigned long fract u032
An alternative name for the unsigned long fract type.
Definition stdfix-full-iso.h:196
uint64_t uint_ulk_t
This is the unsigned integer type into which unsigned long accum can be converted.
Definition stdfix-full-iso.h:156
static long int divilr(long int n, s031 x)
Divides a long integer by a long fract giving a long integer answer.
Definition stdfix-full-iso.h:1329
static s031 lrdivi(long int i, long int j)
Divides two integers giving a long fract answer.
Definition stdfix-full-iso.h:1377
static int32_t __stdfix_round_s32(int32_t x, int n)
This function rounds the input signed 32-bit integer to a number of bits, returning a 32-bit integer.
Definition stdfix-full-iso.h:1906
unsigned long accum u3232
An alternative name for the unsigned long accum type.
Definition stdfix-full-iso.h:205
static int_lk_t bitslk(const s3231 f)
Converts a long accum into an integer.
Definition stdfix-full-iso.h:298
#define __I32(x)
Cast to int32_t.
Definition stdfix-full-iso.h:551
static int32_t __stdfix_sadd_k(int32_t x, int32_t y)
Saturated addition of the underlying integer representations.
Definition stdfix-full-iso.h:865
static s1615 kdivi(int i, int j)
Divides two integers giving an accum answer.
Definition stdfix-full-iso.h:1389
static int countlslk(s3231 f)
This function counts the number of leading sign-bits of a long accum.
Definition stdfix-full-iso.h:2199
static s1615 kbits(const int_k_t n)
Converts a signed integer into a signed accum.
Definition stdfix-full-iso.h:446
static int32_t __stdfix_sat_lr(const int64_t x)
Saturates a 64-bit integer to 32-bits.
Definition stdfix-full-iso.h:605
#define __I64(x)
Cast to int64_t.
Definition stdfix-full-iso.h:553
static uint32_t __stdfix_sat_uk(const uint64_t x)
Saturates an unsigned 64-bit integer to 32 bits.
Definition stdfix-full-iso.h:712
static int idivr(s015 x, s015 y)
Divides two fracts giving an integer answer.
Definition stdfix-full-iso.h:1413
static uint32_t __stdfix_ssub_uhr(uint32_t x, uint32_t y)
Saturated subtraction of the underlying unsigned integer representations.
Definition stdfix-full-iso.h:1032
static s07 abshr(s07 f)
This function returns the absolute value of a short fract.
Definition stdfix-full-iso.h:1677
static uint32_t __stdfix_smul_uk(uint32_t x, uint32_t y)
Saturated multiplication of the underlying unsigned integer representations.
Definition stdfix-full-iso.h:1228
static int32_t __stdfix_sneg_hr(int_hr_t x)
Saturated negation of the underlying integer representations.
Definition stdfix-full-iso.h:752
static s015 rdivi(int i, int j)
Divides two integers giving a fract answer.
Definition stdfix-full-iso.h:1365
static uint32_t __stdfix_sat_uhr(const uint32_t x)
Saturates an unsigned integer to 8 bits.
Definition stdfix-full-iso.h:656
static int32_t __stdfix_smul_lr(int32_t x, int32_t y)
Saturated multiplication of the underlying integer representations.
Definition stdfix-full-iso.h:963
static s1615 roundk(s1615 f, int n)
This function rounds the input accum to a number of bits, returning an accum.
Definition stdfix-full-iso.h:1996