spinn_common 7.2.2
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#define _Fract int
224#define _Accum int
225#define _Sat
226
227#endif /* __arm__ */
228
232
236
237static inline int_hr_t bitshr(
238 const s07 f)
239{
240 union { int_hr_t r; s07 fx; } x;
241
242 x.fx = f;
243 return x.r;
244}
245
249
250static inline int_r_t bitsr(
251 const s015 f)
252{
253 union { int_r_t r; s015 fx; } x;
254
255 x.fx = f;
256 return x.r;
257}
258
262
263static inline int_lr_t bitslr(
264 const s031 f)
265{
266 union { int_lr_t r; s031 fx; } x;
267
268 x.fx = f;
269 return x.r;
270}
271
275
276static inline int_hk_t bitshk(
277 const s87 f)
278{
279 union { int_hk_t r; s87 fx; } x;
280
281 x.fx = f;
282 return x.r;
283}
284
288
289static inline int_k_t bitsk(
290 const s1615 f)
291{
292 union { int_k_t r; s1615 fx; } x;
293
294 x.fx = f;
295 return x.r;
296}
297
301
302static inline int_lk_t bitslk(
303 const s3231 f)
304{
305 union { int_lk_t r; s3231 fx; } x;
306
307 x.fx = f;
308 return x.r;
309}
310
314
315static inline uint_uhr_t bitsuhr(
316 const u08 f)
317{
318 union { uint_uhr_t r; u08 fx; } x;
319
320 x.fx = f;
321 return x.r;
322}
323
327
328static inline uint_ur_t bitsur(
329 const u016 f)
330{
331 union { uint_ur_t r; u016 fx; } x;
332
333 x.fx = f;
334 return x.r;
335}
336
340
341static inline uint_ulr_t bitsulr(
342 const u032 f)
343{
344 union { uint_ulr_t r; u032 fx; } x;
345
346 x.fx = f;
347 return x.r;
348}
349
353
354static inline uint_uhk_t bitsuhk(
355 const u88 f)
356{
357 union { uint_uhk_t r; u88 fx; } x;
358
359 x.fx = f;
360 return x.r;
361}
362
366
367static inline uint_uk_t bitsuk(
368 const u1616 f)
369{
370 union { uint_uk_t r; u1616 fx; } x;
371
372 x.fx = f;
373 return x.r;
374}
375
379
380static inline uint_ulk_t bitsulk(
381 const u3232 f)
382{
383 union { uint_ulk_t r; u3232 fx; } x;
384
385 x.fx = f;
386 return x.r;
387}
389
393
397
398static inline s07 hrbits(
399 const int_hr_t n)
400{
401 union { int_hr_t r; s07 fx; } x;
402
403 x.r = n;
404 return x.fx;
405}
406
410
411static inline s015 rbits(
412 const int_r_t n)
413{
414 union { int_r_t r; s015 fx; } x;
415
416 x.r = n;
417 return x.fx;
418}
419
423
424static inline s031 lrbits(
425 const int_lr_t n)
426{
427 union { int_lr_t r; s031 fx; } x;
428
429 x.r = n;
430 return x.fx;
431}
432
436
437static inline s87 hkbits(
438 const int_hk_t n)
439{
440 union { int_hk_t r; s87 fx; } x;
441
442 x.r = n;
443 return x.fx;
444}
445
449
450static inline s1615 kbits(
451 const int_k_t n)
452{
453 union { int_k_t r; s1615 fx; } x;
454
455 x.r = n;
456 return x.fx;
457}
458
462
463static inline s3231 lkbits(
464 const int_lk_t n)
465{
466 union { int_lk_t r; s3231 fx; } x;
467
468 x.r = n;
469 return x.fx;
470}
471
475
476static inline u08 uhrbits(
477 const uint_uhr_t n)
478{
479 union { uint_uhr_t r; u08 fx; } x;
480
481 x.r = n;
482 return x.fx;
483}
484
488
489static inline u016 urbits(
490 const uint_ur_t n)
491{
492 union { uint_ur_t r; u016 fx; } x;
493
494 x.r = n;
495 return x.fx;
496}
497
501
502static inline u032 ulrbits(
503 const uint_ulr_t n)
504{
505 union { uint_ulr_t r; u032 fx; } x;
506
507 x.r = n;
508 return x.fx;
509}
510
514
515static inline u88 uhkbits(
516 const uint_uhk_t n)
517{
518 union { uint_uhk_t r; u88 fx; } x;
519
520 x.r = n;
521 return x.fx;
522}
523
527
528static inline u1616 ukbits(
529 const uint_uk_t n)
530{
531 union { uint_uk_t r; u1616 fx; } x;
532
533 x.r = n;
534 return x.fx;
535}
536
540
541static inline u3232 ulkbits(
542 const uint_ulk_t n)
543{
544 union { uint_ulk_t r; u3232 fx; } x;
545
546 x.r = n;
547 return x.fx;
548}
550
551// Wrapped casts
553#define __I(x) ((int) (x))
555#define __I32(x) ((int32_t) (x))
557#define __I64(x) ((int64_t) (x))
559#define __LI(x) ((long int) (x))
561#define __U32(x) ((uint32_t) (x))
563#define __U64(x) ((uint64_t) (x))
565#define __UI(x) ((unsigned int) (x))
567#define __ULI(x) ((unsigned long int) (x))
568
569// Saturation operations
570
574
575static inline int32_t __stdfix_sat_hr(
576 const int32_t x)
577{
578 if (x > INT8_MAX) {
579 return INT8_MAX;
580 }
581 if (x < INT8_MIN) {
582 return INT8_MIN;
583 }
584
585 return x;
586}
587
591
592static inline int32_t __stdfix_sat_r(
593 const int32_t x)
594{
595 if (x > INT16_MAX) {
596 return INT16_MAX;
597 }
598 if (x < INT16_MIN) {
599 return INT16_MIN;
600 }
601
602 return x;
603}
604
608
609static inline int32_t __stdfix_sat_lr(
610 const int64_t x)
611{
612 if (x > INT32_MAX) {
613 return INT32_MAX;
614 }
615 if (x < INT32_MIN) {
616 return INT32_MIN;
617 }
618
619 return __I32(x);
620}
621
625
626static inline int32_t __stdfix_sat_hk(
627 const int32_t x)
628{
629 if (x > INT16_MAX) {
630 return INT16_MAX;
631 }
632 if (x < INT16_MIN) {
633 return INT16_MIN;
634 }
635
636 return x;
637}
638
642
643static inline int32_t __stdfix_sat_k(
644 const int64_t x)
645{
646 if (x > INT32_MAX) {
647 return INT32_MAX;
648 }
649 if (x < INT32_MIN) {
650 return INT32_MIN;
651 }
652
653 return __I32(x);
654}
655
659
660static inline uint32_t __stdfix_sat_uhr(
661 const uint32_t x)
662{
663 if (x > UINT8_MAX) {
664 return UINT8_MAX;
665 }
666
667 return x;
668}
669
673
674static inline uint32_t __stdfix_sat_ur(
675 const uint32_t x)
676{
677 if (x > UINT16_MAX) {
678 return UINT16_MAX;
679 }
680
681 return x;
682}
683
687
688static inline uint32_t __stdfix_sat_ulr(
689 const uint64_t x)
690{
691 if (x > UINT32_MAX) {
692 return UINT32_MAX;
693 }
694
695 return __U32(x);
696}
697
701
702static inline uint32_t __stdfix_sat_uhk(
703 const uint32_t x)
704{
705 if (x > UINT16_MAX) {
706 return UINT16_MAX;
707 }
708
709 return x;
710}
711
715
716static inline uint32_t __stdfix_sat_uk(
717 const uint64_t x)
718{
719 if (x > UINT32_MAX) {
720 return UINT32_MAX;
721 }
722
723 return __U32(x);
724}
725
726// software simulation of basic saturating arithmetic
727
732
733static inline int32_t __stdfix_sadd_hr(
734 int_hr_t x,
735 int_hr_t y)
736{
737 return __stdfix_sat_hr(__I32(x) + __I32(y));
738}
739
744
745static inline int32_t __stdfix_ssub_hr(
746 int_hr_t x,
747 int_hr_t y)
748{
749 return __stdfix_sat_hr(__I32(x) - __I32(y));
750}
751
755
756static inline int32_t __stdfix_sneg_hr(
757 int_hr_t x)
758{
759 return __stdfix_sat_hr(__I32(-x));
760}
761
766
767static inline int32_t __stdfix_sadd_r(
768 int32_t x,
769 int32_t y)
770{
771 return __stdfix_sat_r(__I32(x) + __I32(y));
772}
773
778
779static inline int32_t __stdfix_ssub_r(
780 int32_t x,
781 int32_t y)
782{
783 return __stdfix_sat_r(__I32(x) - __I32(y));
784}
785
789
790static inline int32_t __stdfix_sneg_r(
791 int32_t x)
792{
793 return __stdfix_sat_r(__I32(-x));
794}
795
800
801static inline int32_t __stdfix_sadd_lr(
802 int32_t x,
803 int32_t y)
804{
805 return __stdfix_sat_lr(__I64(x) + __I64(y));
806}
807
812
813static inline int32_t __stdfix_ssub_lr(
814 int32_t x,
815 int32_t y)
816{
817 return __stdfix_sat_lr(__I64(x) - __I64(y));
818}
819
823
824static inline int32_t __stdfix_sneg_lr(
825 int32_t x)
826{
827 return __stdfix_sat_lr(__I64(-x));
828}
829
834
835static inline int32_t __stdfix_sadd_hk(
836 int32_t x,
837 int32_t y)
838{
839 return __stdfix_sat_hk(__I32(x) + __I32(y));
840}
841
846
847static inline int32_t __stdfix_ssub_hk(
848 int32_t x,
849 int32_t y)
850{
851 return __stdfix_sat_hk(__I32(x) - __I32(y));
852}
853
857
858static inline int32_t __stdfix_sneg_hk(
859 int32_t x)
860{
861 return __stdfix_sat_hk(__I32(-x));
862}
863
868
869static inline int32_t __stdfix_sadd_k(
870 int32_t x,
871 int32_t y)
872{
873#ifdef __ARM_FEATURE_DSP
874 return __qadd(x, y);
875#else /*__ARM_FEATURE_DSP*/
876 return __stdfix_sat_k(__I64(x) + __I64(y));
877#endif /*__ARM_FEATURE_DSP*/
878}
879
884
885static inline int32_t __stdfix_ssub_k(
886 int32_t x,
887 int32_t y)
888{
889#ifdef __ARM_FEATURE_DSP
890 return __qsub(x, y);
891#else /*__ARM_FEATURE_DSP*/
892 return __stdfix_sat_k(__I64(x) - __I64(y));
893#endif /*__ARM_FEATURE_DSP*/
894}
895
899
900static inline int32_t __stdfix_sneg_k(
901 int32_t x)
902{
903#ifdef __ARM_FEATURE_DSP
904 return __qsub(0, x);
905#else /*__ARM_FEATURE_DSP*/
906 return __stdfix_sat_k(__I64(-x));
907#endif /*__ARM_FEATURE_DSP*/
908}
909
914
915int64_t __stdfix_sadd_lk(int64_t x, int64_t y);
916
921
922int64_t __stdfix_ssub_lk(int64_t x, int64_t y);
923
927
928int64_t __stdfix_sneg_lk(int64_t x);
929
934
935static inline int32_t __stdfix_smul_hr(
936 int32_t x,
937 int32_t y)
938{
939 if (x == INT8_MIN && y == INT8_MIN) { // special case for -1.0*-1.0
940 return INT8_MAX;
941 }
942
943 return __I32(__stdfix_sat_hr((__I32(x) * __I32(y)) >> 7));
944}
945
950
951static inline int32_t __stdfix_smul_r(
952 int32_t x,
953 int32_t y)
954{
955 if (x == INT16_MIN && y == INT16_MIN) { // special case for -1.0*-1.0
956 return INT16_MAX;
957 }
958
959 return __I32(__stdfix_sat_r((__I32(x) * __I32(y)) >> 15));
960}
961
966
967static inline int32_t __stdfix_smul_lr(
968 int32_t x,
969 int32_t y)
970{
971 if (x == INT32_MIN && y == INT32_MIN) { // special case for -1.0*-1.0
972 return INT32_MAX;
973 }
974
975 return __stdfix_sat_lr((__I64(x) * __I64(y)) >> 31);
976}
977
982
983static inline int32_t __stdfix_smul_hk(
984 int32_t x,
985 int32_t y)
986{
987 if (x == INT16_MIN && y == INT16_MIN) { // special case for -1.0*-1.0
988 return INT16_MAX;
989 }
990
991 return __stdfix_sat_hk((__I32(x) * __I32(y)) >> 7);
992}
993
998
999static inline int32_t __stdfix_smul_k(
1000 int32_t x,
1001 int32_t y)
1002{
1003 if (x == INT32_MIN && y == INT32_MIN) { // special case for -1.0*-1.0
1004 return INT32_MAX;
1005 }
1006
1007 return __stdfix_sat_k((__I64(x) * __I64(y)) >> 15);
1008}
1009
1014
1015int64_t __stdfix_smul_lk(int64_t x, int64_t y);
1016
1022
1023static inline uint32_t __stdfix_sadd_uhr(
1024 uint32_t x,
1025 uint32_t y)
1026{
1027 return __stdfix_sat_uhr(__U32(x) + __U32(y));
1028}
1029
1035
1036static inline uint32_t __stdfix_ssub_uhr(
1037 uint32_t x,
1038 uint32_t y)
1039{
1040 return __stdfix_sat_uhr(__U32(x) - __U32(y));
1041}
1042
1048
1049static inline uint32_t __stdfix_sadd_ur(
1050 uint32_t x,
1051 uint32_t y)
1052{
1053 return __stdfix_sat_ur(__U32(x) + __U32(y));
1054}
1055
1061
1062static inline uint32_t __stdfix_ssub_ur(
1063 uint32_t x,
1064 uint32_t y)
1065{
1066 return __stdfix_sat_ur(__U32(x) - __U32(y));
1067}
1068
1074
1075static inline uint32_t __stdfix_sadd_ulr(
1076 uint32_t x,
1077 uint32_t y)
1078{
1079 return __stdfix_sat_ulr(__U64(x) + __U64(y));
1080}
1081
1087
1088static inline uint32_t __stdfix_ssub_ulr(
1089 uint32_t x,
1090 uint32_t y)
1091{
1092 return __stdfix_sat_ulr(__U64(x) - __U64(y));
1093}
1094
1100
1101static inline uint32_t __stdfix_sadd_uhk(
1102 uint32_t x,
1103 uint32_t y)
1104{
1105 return __stdfix_sat_uhk(__U32(x) + __U32(y));
1106}
1107
1113
1114static inline uint32_t __stdfix_ssub_uhk(
1115 uint32_t x,
1116 uint32_t y)
1117{
1118 return __stdfix_sat_uhk(__U32(x) - __U32(y));
1119}
1120
1126
1127static inline uint32_t __stdfix_sadd_uk(
1128 uint32_t x,
1129 uint32_t y)
1130{
1131 return __stdfix_sat_uk(__U64(x) + __U64(y));
1132}
1133
1139
1140static inline uint32_t __stdfix_ssub_uk(
1141 uint32_t x,
1142 uint32_t y)
1143{
1144 return __stdfix_sat_uk(__U64(x) - __U64(y));
1145}
1146
1152
1153uint64_t __stdfix_sadd_ulk(uint64_t x, uint64_t y);
1154
1160
1161uint64_t __stdfix_ssub_ulk(uint64_t x, uint64_t y);
1162
1171
1172static inline uint32_t __stdfix_smul_uhr(
1173 uint32_t x,
1174 uint32_t y)
1175{
1176 return __stdfix_sat_uhr((__U32(x) * __U32(y)) >> 8);
1177}
1178
1185
1186static inline uint32_t __stdfix_smul_ur(
1187 uint32_t x,
1188 uint32_t y)
1189{
1190 return __stdfix_sat_ur((__U32(x) * __U32(y)) >> 16);
1191}
1192
1201
1202static inline uint32_t __stdfix_smul_ulr(
1203 uint32_t x,
1204 uint32_t y)
1205{
1206 return __stdfix_sat_ulr((__U64(x) * __U64(y)) >> 32);
1207}
1208
1217
1218static inline uint32_t __stdfix_smul_uhk(
1219 uint32_t x,
1220 uint32_t y)
1221{
1222 return __stdfix_sat_uhk((__U32(x) * __U32(y)) >> 8);
1223}
1224
1231
1232static inline uint32_t __stdfix_smul_uk(
1233 uint32_t x,
1234 uint32_t y)
1235{
1236 return __stdfix_sat_uk((__U64(x) * __U64(y)) >> 16);
1237}
1238
1247
1248uint64_t __stdfix_smul_ulk(uint64_t x, uint64_t y);
1249
1262
1267
1268static inline int mulir(
1269 int n,
1270 s015 x)
1271{
1272 return __I((__I64(n) * __I64(bitsr(x))) >> 15);
1273}
1274
1279
1280static inline long int mulilr(
1281 long int n,
1282 s031 x)
1283{
1284 return __LI((__I64(n) * __I64(bitslr(x))) >> 31);
1285}
1286
1291
1292static inline int mulik(
1293 int n,
1294 s1615 x)
1295{
1296 return __I((__I64(n) * __I64(bitsk(x))) >> 15);
1297}
1298
1304
1305static inline long int mulilk(
1306 long int n,
1307 s3231 x)
1308{
1309 int64_t r = bitslk(x);
1310 int64_t k = __I64(n) * (r >> 31);
1311 int64_t c = (__I64(n) * (r & INT64_C(0x7FFFFFF))) >> 31;
1312
1313 return __LI(k + c);
1314}
1315
1320
1321static inline int divir(
1322 int n,
1323 s015 x)
1324{
1325 return __I((__I64(n) << 15) / bitsr(x));
1326}
1327
1332
1333static inline long int divilr(
1334 long int n,
1335 s031 x)
1336{
1337 return __LI((__I64(n) << 31) / bitslr(x));
1338}
1339
1344
1345static inline int divik(
1346 int n,
1347 s1615 x)
1348{
1349 return __LI((__I64(n) << 15) / bitsk(x));
1350}
1351
1356
1357static inline long int divilk(
1358 long int n,
1359 s3231 x)
1360{
1361 return __LI((__I64(n) << 31) / bitslk(x));
1362}
1363
1368
1369static inline s015 rdivi(
1370 int i,
1371 int j)
1372{
1373 return rbits((int_r_t) ((__I64(i) << 15) / __I64(j)));
1374}
1375
1380
1381static inline s031 lrdivi(
1382 long int i,
1383 long int j)
1384{
1385 return lrbits((int_lr_t) ((__I64(i) << 31) / __I64(j)));
1386}
1387
1392
1393static inline s1615 kdivi(
1394 int i,
1395 int j)
1396{
1397 return kbits((int_k_t) ((__I64(i) << 15) / __I64(j)));
1398}
1399
1404
1405static inline s3231 lkdivi(
1406 long int i,
1407 long int j)
1408{
1409 return lkbits((int_lk_t) ((__I64(i) << 31) / __I64(j)));
1410}
1411
1416
1417static inline int idivr(
1418 s015 x,
1419 s015 y)
1420{
1421 return __I(rbits(x) / rbits(y));
1422}
1423
1428
1429static inline long int idivlr(
1430 s031 x,
1431 s031 y)
1432{
1433 return __LI(lrbits(x) / lrbits(y));
1434}
1435
1440
1441static inline int idivk(
1442 s1615 x,
1443 s1615 y)
1444{
1445 return __I(kbits(x) / kbits(y));
1446}
1447
1452
1453static inline long int idivlk(
1454 s3231 x,
1455 s3231 y)
1456{
1457 return __LI(lkbits(x) / lkbits(y));
1458}
1459
1465
1466static inline unsigned int muliur(
1467 unsigned int n,
1468 u016 x)
1469{
1470 return __UI((__U64(n) * __U64(bitsur(x))) >> 16);
1471}
1472
1478
1479static inline unsigned long int muliulr(
1480 unsigned long int n,
1481 u032 x)
1482{
1483 return __ULI((__U64(n) * __U64(bitsulr(x))) >> 32);
1484}
1485
1491
1492static inline unsigned int muliuk(
1493 unsigned int n,
1494 u1616 x)
1495{
1496 return __UI(__U64(n) * __U64(bitsuk(x)) >> 16);
1497}
1498
1504
1505static inline unsigned long int muliulk(
1506 unsigned long int n,
1507 u3232 x)
1508{
1509 uint64_t r = bitsulk(x);
1510 uint64_t k = __U64(n) * (r >> 32);
1511 uint64_t c = (__U64(n) * (r & INT64_C(0xFFFFFFF))) >> 32;
1512
1513 return __ULI(k + c);
1514}
1515
1521
1522static inline unsigned int diviur(
1523 unsigned int n,
1524 u016 x)
1525{
1526 return __UI((__U64(n) << 16) / bitsur(x));
1527}
1528
1534
1535static inline unsigned long int diviulr(
1536 unsigned long int n,
1537 u032 x)
1538{
1539 return __ULI((__U64(n) << 32) / bitsulr(x));
1540}
1541
1547
1548static inline unsigned int diviuk(
1549 unsigned int n,
1550 u1616 x)
1551{
1552 return __ULI((__U64(n) << 16) / bitsuk(x));
1553}
1554
1560
1561static inline unsigned long int diviulk(
1562 unsigned long int n,
1563 u3232 x)
1564{
1565 return __ULI((__U64(n) << 32) / bitsulk(x));
1566}
1567
1572
1573static inline u016 urdivi(
1574 unsigned int i,
1575 unsigned int j)
1576{
1577 return ulrbits((uint_ulr_t) ((__U64(i) << 16) / __U64(j)));
1578}
1579
1585
1586static inline u032 ulrdivi(
1587 unsigned long int i,
1588 unsigned long int j)
1589{
1590 return ulrbits((uint_ulr_t) ((__U64(i) << 32) / __U64(j)));
1591}
1592
1597
1598static inline u1616 ukdivi(
1599 unsigned int i,
1600 unsigned int j)
1601{
1602 return ukbits((uint_uk_t) ((__U64(i) << 16) / __U64(j)));
1603}
1604
1610
1611static inline u3232 ulkdivi(
1612 unsigned long int i,
1613 unsigned long int j)
1614{
1615 return ulkbits((uint_ulk_t) ((__U64(i) << 32) / __U64(j)));
1616}
1617
1622
1623static inline unsigned int idivur(
1624 u016 x,
1625 u016 y)
1626{
1627 return __UI(urbits(x) / urbits(y));
1628}
1629
1635
1636static inline unsigned long int idivulr(
1637 u032 x,
1638 u032 y)
1639{
1640 return __ULI(ulrbits(x) / ulrbits(y));
1641}
1642
1647
1648static inline unsigned int idivuk(
1649 u1616 x,
1650 u1616 y)
1651{
1652 return __UI(ukbits(x) / ukbits(y));
1653}
1654
1659
1660static inline unsigned long int idivulk(
1661 u3232 x,
1662 u3232 y)
1663{
1664 return __ULI(ulkbits(x) / ulkbits(y));
1665}
1667
1676
1680
1681static inline s07 abshr(
1682 s07 f)
1683{
1684 int_hr_t r = bitshr(f);
1685
1686 if (r < 0) {
1687 r = (r == INT8_MIN) ? INT8_MAX : -r;
1688 }
1689
1690 return hrbits(r);
1691}
1692
1696
1697static inline s015 absr(
1698 s015 f)
1699{
1700 int_r_t r = bitsr(f);
1701
1702 if (r < 0) {
1703 r = (r == INT16_MIN) ? INT16_MAX : -r;
1704 }
1705
1706 return rbits(r);
1707}
1708
1712
1713static inline s031 abslr(
1714 s031 f)
1715{
1716 int_lr_t r = bitslr(f);
1717
1718 if (r < 0) {
1719 r = (r == INT32_MIN) ? INT32_MAX : -r;
1720 }
1721
1722 return lrbits(r);
1723}
1724
1728
1729static inline s87 abshk(
1730 s87 f)
1731{
1732 int_hk_t r = bitshk(f);
1733
1734 if (r < 0) {
1735 r = (r == INT16_MIN) ? INT16_MAX : -r;
1736 }
1737
1738 return hkbits(r);
1739}
1740
1744
1745static inline s1615 absk(
1746 s1615 f)
1747{
1748 int_k_t r = bitsk(f);
1749
1750 if (r < 0) {
1751 r = (r == INT32_MIN) ? INT32_MAX : -r;
1752 }
1753
1754 return kbits(r);
1755}
1756
1760
1761static inline s3231 abslk(
1762 s3231 f)
1763{
1764 int_lk_t r = bitslk(f);
1765
1766 if (r < 0) {
1767 r = (r == INT64_MIN) ? INT64_MAX : -r;
1768 }
1769
1770 return lkbits(r);
1771}
1773
1789
1795
1796static inline uint8_t __stdfix_round_u8(
1797 uint8_t x,
1798 int n)
1799{
1800 register uint8_t r, c;
1801
1802 c = (x >> (n-1)) & 0x1;
1803 r = x >> n;
1804 r = (r + c) << n;
1805
1806 return r;
1807}
1808
1814
1815static inline uint16_t __stdfix_round_u16(
1816 uint16_t x,
1817 int n)
1818{
1819 register uint16_t r, c;
1820
1821 c = (x >> (n-1)) & 0x1;
1822 r = x >> n;
1823 r = (r + c) << n;
1824
1825 return r;
1826}
1827
1833
1834static inline uint32_t __stdfix_round_u32(
1835 uint32_t x,
1836 int n)
1837{
1838 register uint32_t r, c;
1839
1840 c = (x >> (n-1)) & 0x1;
1841 r = x >> n;
1842 r = (r + c) << n;
1843
1844 return r;
1845}
1846
1852
1853static inline uint64_t __stdfix_round_u64(
1854 uint64_t x,
1855 int n)
1856{
1857 register uint64_t r, c;
1858
1859 c = (x >> (n-1)) & 0x1;
1860 r = x >> n;
1861 r = (r + c) << n;
1862
1863 return r;
1864}
1865
1871
1872static inline int8_t __stdfix_round_s8(
1873 int8_t x,
1874 int n)
1875{
1876 register int8_t r, c;
1877
1878 c = (x >> (n-1)) & 0x1;
1879 r = x >> n;
1880 r = (r + c) << n;
1881
1882 return r;
1883}
1884
1890
1891static inline int16_t __stdfix_round_s16(
1892 int16_t x,
1893 int n)
1894{
1895 register int16_t r, c;
1896
1897 c = (x >> (n-1)) & 0x1;
1898 r = x >> n;
1899 r = (r + c) << n;
1900
1901 return r;
1902}
1903
1909
1910static inline int32_t __stdfix_round_s32(
1911 int32_t x,
1912 int n)
1913{
1914 register int32_t r, c;
1915
1916 c = (x >> (n-1)) & 0x1;
1917 r = x >> n;
1918 r = (r + c) << n;
1919
1920 return r;
1921}
1922
1928
1929static inline int64_t __stdfix_round_s64(
1930 int64_t x,
1931 int n)
1932{
1933 register int64_t r, c;
1934
1935 c = (x >> (n-1)) & 0x1;
1936 r = x >> n;
1937 r = (r + c) << n;
1938
1939 return r;
1940}
1941
1947
1948static inline s07 roundhr(
1949 s07 f,
1950 int n)
1951{
1952 return hrbits(__stdfix_round_s8(bitshr(f), n));
1953}
1954
1960
1961static inline s015 roundr(
1962 s015 f,
1963 int n)
1964{
1965 return rbits(__stdfix_round_s16(bitsr(f), n));
1966}
1967
1973
1974static inline s031 roundlr(
1975 s031 f,
1976 int n)
1977{
1978 return lrbits(__stdfix_round_s32(bitslr(f), n));
1979}
1980
1986
1987static inline s87 roundhk(
1988 s87 f,
1989 int n)
1990{
1991 return hkbits(__stdfix_round_s16(bitshk(f), n));
1992}
1993
1999
2000static inline s1615 roundk(
2001 s1615 f,
2002 int n)
2003{
2004 return kbits(__stdfix_round_s32(bitsk(f), n));
2005}
2006
2012
2013static inline s3231 roundlk(
2014 s3231 f,
2015 int n)
2016{
2017 return lkbits(__stdfix_round_s64(bitslk(f), n));
2018}
2019
2025
2026static inline u08 rounduhr(
2027 u08 f,
2028 int n)
2029{
2030 return uhrbits(__stdfix_round_u8(bitsuhr(f), n));
2031}
2032
2038
2039static inline u016 roundur(
2040 u016 f,
2041 int n)
2042{
2043 return urbits(__stdfix_round_u16(bitsur(f), n));
2044}
2045
2051
2052static inline u032 roundulr(
2053 u032 f,
2054 int n)
2055{
2056 return ulrbits(__stdfix_round_u32(bitsulr(f), n));
2057}
2058
2064
2065static inline u88 rounduhk(
2066 u88 f,
2067 int n)
2068{
2069 return uhkbits(__stdfix_round_u16(bitsuhk(f), n));
2070}
2071
2077
2078static inline u1616 rounduk(
2079 u1616 f,
2080 int n)
2081{
2082 return ukbits(__stdfix_round_u32(bitsuk(f), n));
2083}
2084
2090
2091static inline u3232 roundulk(
2092 u3232 f,
2093 int n)
2094{
2095 return ulkbits(__stdfix_round_u64(bitsulk(f), n));
2096}
2098
2114
2119
2120static inline int countlshr(
2121 s07 f)
2122{
2123 int32_t n = __I32(bitshr(f));
2124
2125 if (n == 0) {
2126 return 7;
2127 }
2128
2129 return __builtin_clrsb(n) - 24;
2130}
2131
2135
2136static inline int countlsr(
2137 s015 f)
2138{
2139 int32_t n = __I32(bitsr(f));
2140
2141 if (n == 0) {
2142 return 15;
2143 }
2144
2145 return __builtin_clrsb(n) - 16;
2146}
2147
2152
2153static inline int countlslr(
2154 s031 f)
2155{
2156 int_lr_t n = bitslr(f);
2157
2158 if (n == 0) {
2159 return 31;
2160 }
2161
2162 return __builtin_clrsb(n);
2163}
2164
2169
2170static inline int countlshk(
2171 s87 f)
2172{
2173 int32_t n = __I32(bitshk(f));
2174
2175 if (n == 0) {
2176 return 15;
2177 }
2178
2179 return __builtin_clrsb(n) - 16;
2180}
2181
2185
2186static inline int countlsk(
2187 s1615 f)
2188{
2189 int_k_t n = bitsk(f);
2190
2191 if (n == 0) {
2192 return 31;
2193 }
2194
2195 return __builtin_clrsb(n);
2196}
2197
2202
2203static inline int countlslk(
2204 s3231 f)
2205{
2206 int64_t n = __I64(bitslk(f));
2207
2208 if (n == 0) {
2209 return 63;
2210 }
2211
2212 return __builtin_clrsbll(n);
2213}
2214
2219
2220static inline int countlsuhr(
2221 u08 f)
2222{
2223 uint32_t n = __U32(bitsuhr(f));
2224
2225 if (n == 0) {
2226 return 8;
2227 }
2228
2229 return __builtin_clz(n) - 24;
2230}
2231
2236
2237static inline int countlsur(
2238 u016 f)
2239{
2240 uint32_t n = __U32(bitsur(f));
2241
2242 if (n == 0) {
2243 return 16;
2244 }
2245
2246 return __builtin_clz(n) - 16;
2247}
2248
2253
2254static inline int countlsulr(
2255 u032 f)
2256{
2257 uint_ulr_t n = bitsulr(f);
2258
2259 if (n == 0) {
2260 return 32;
2261 }
2262
2263 return __builtin_clz(n);
2264}
2265
2270
2271static inline int countlsuhk(
2272 u88 f)
2273{
2274 uint32_t n = __U32(bitsuhk(f));
2275
2276 if (n == 0) {
2277 return 16;
2278 }
2279
2280 return __builtin_clz(n) - 16;
2281}
2282
2287
2288static inline int countlsuk(
2289 u1616 f)
2290{
2291 uint_uk_t n = (uint_uk_t) bitsuk(f);
2292
2293 if (n == 0) {
2294 return 32;
2295 }
2296
2297 return __builtin_clz(n);
2298}
2299
2304
2305static inline int countlsulk(
2306 u3232 f)
2307{
2308 uint_ulk_t n = (uint_ulk_t) bitsulk(f);
2309
2310 if (n == 0) {
2311 return 64;
2312 }
2313
2314 return __builtin_clzll(n);
2315}
2317
2335
2340
2341#define absfx(f) \
2342 _Generic((f), \
2343 s07: abshr(f), \
2344 s015: absr(f), \
2345 s031: abslr(f), \
2346 s87: abshk(f), \
2347 s1615: absk(f), \
2348 s3231: abslk(f), \
2349 default: abort() \
2350 )
2351
2357
2358#define roundfx(f, n) \
2359 _Generic((f), \
2360 s07: roundhr(f, n), \
2361 s015: roundr(f, n), \
2362 s031: roundlr(f, n), \
2363 s87: roundhk(f, n), \
2364 s1615: roundk(f, n), \
2365 s3231: roundlk(f, n), \
2366 u08: rounduhr(f, n), \
2367 u016: roundur(f, n), \
2368 u032: roundulr(f, n), \
2369 u88: rounduhk(f, n), \
2370 u1616: rounduk(f, n), \
2371 u3232: roundulk(f, n), \
2372 default: abort() \
2373 )
2374
2379
2380#define countlsfx(f) \
2381 _Generic((f), \
2382 s07: countlshr(f), \
2383 s015: countlsr(f), \
2384 s031: countlslr(f), \
2385 s87: countlshk(f), \
2386 s1615: countlsk(f), \
2387 s3231: countlslk(f), \
2388 u08: countlsuhr(f), \
2389 u016: countlsur(f), \
2390 u032: countlsulr(f), \
2391 u88: countlsuhk(f), \
2392 u1616: countlsuk(f), \
2393 u3232: countlsulk(f), \
2394 default: abort() \
2395 )
2397
2460
2461#ifndef __arm__
2462s07 strtofxhr (const char *restrict nptr, char **restrict endptr);
2463s015 strtofxr (const char *restrict nptr, char **restrict endptr);
2464s031 strtofxlr (const char *restrict nptr, char **restrict endptr);
2465s87 strtofxhk (const char *restrict nptr, char **restrict endptr);
2466s1615 strtofxk (const char *restrict nptr, char **restrict endptr);
2467s3231 strtofxlk (const char *restrict nptr, char **restrict endptr);
2468
2469u08 strtofxuhr(const char *restrict nptr, char **restrict endptr);
2470u016 strtofxur (const char *restrict nptr, char **restrict endptr);
2471u032 strtofxulr(const char *restrict nptr, char **restrict endptr);
2472u88 strtofxuhk(const char *restrict nptr, char **restrict endptr);
2473u1616 strtofxuk (const char *restrict nptr, char **restrict endptr);
2474u3232 strtofxulk(const char *restrict nptr, char **restrict endptr);
2475#endif /*__arm__*/
2476
2478
2479#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:1479
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:1049
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:463
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:1357
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:2091
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:354
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:1548
static int countlsuhr(u08 f)
This function counts the number of leading zeros of an unsigned short fract.
Definition stdfix-full-iso.h:2220
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:2254
static u032 ulrbits(const uint_ulr_t n)
Converts an unsigned integer into an unsigned long fract.
Definition stdfix-full-iso.h:502
static int countlsuk(u1616 f)
This function counts the number of leading zeros of an unsigned accum.
Definition stdfix-full-iso.h:2288
#define __UI(x)
Cast to unsigned int.
Definition stdfix-full-iso.h:565
static int divik(int n, s1615 x)
Divides an integer by an accum giving an integer answer.
Definition stdfix-full-iso.h:1345
static int countlsk(s1615 f)
This function counts the number of leading sign-bits of an accum.
Definition stdfix-full-iso.h:2186
static s031 lrbits(const int_lr_t n)
Converts a signed integer into a signed long fract.
Definition stdfix-full-iso.h:424
static int_hr_t bitshr(const s07 f)
Converts a short fract into an integer.
Definition stdfix-full-iso.h:237
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:1202
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:1948
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:1292
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:745
static int countlsur(u016 f)
This function counts the number of leading zeros of an unsigned fract.
Definition stdfix-full-iso.h:2237
static int countlsr(s015 f)
This function counts the number of leading sign-bits of a fract.
Definition stdfix-full-iso.h:2136
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:2120
static int countlslr(s031 f)
This function counts the number of leading sign-bits of a long fract.
Definition stdfix-full-iso.h:2153
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:1127
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:1172
static int_lr_t bitslr(const s031 f)
Converts a long fract into an integer.
Definition stdfix-full-iso.h:263
static int mulir(int n, s015 x)
Multiplies an integer by a fract giving an integer answer.
Definition stdfix-full-iso.h:1268
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:1453
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:2039
static uint_uk_t bitsuk(const u1616 f)
Converts an unsigned accum into an integer.
Definition stdfix-full-iso.h:367
static int divir(int n, s015 x)
Divides an integer by a fract giving an integer answer.
Definition stdfix-full-iso.h:1321
static int32_t __stdfix_ssub_r(int32_t x, int32_t y)
Saturated subtraction of the underlying integer representations.
Definition stdfix-full-iso.h:779
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:1466
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:1961
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:1586
static u1616 ukdivi(unsigned int i, unsigned int j)
Divides two unsigned integers giving an unsigned accum answer.
Definition stdfix-full-iso.h:1598
#define __U32(x)
Cast to uint32_t.
Definition stdfix-full-iso.h:561
static int32_t __stdfix_sat_hr(const int32_t x)
Saturates an integer to 8 bits.
Definition stdfix-full-iso.h:575
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:1114
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:1636
static u08 uhrbits(const uint_uhr_t n)
Converts an unsigned integer into an unsigned short fract.
Definition stdfix-full-iso.h:476
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:674
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:1101
#define __U64(x)
Cast to uint64_t.
Definition stdfix-full-iso.h:563
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:2026
static uint_uhr_t bitsuhr(const u08 f)
Converts an unsigned short fract into an integer.
Definition stdfix-full-iso.h:315
static int_k_t bitsk(const s1615 f)
Converts an accum into an integer.
Definition stdfix-full-iso.h:289
static int32_t __stdfix_sneg_k(int32_t x)
Saturated negation of the underlying integer representations.
Definition stdfix-full-iso.h:900
static unsigned int idivuk(u1616 x, u1616 y)
Divides two unsigned accums giving an unsigned integer answer.
Definition stdfix-full-iso.h:1648
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:1815
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:1561
static int32_t __stdfix_smul_hk(int32_t x, int32_t y)
Saturated multiplication of the underlying integer representations.
Definition stdfix-full-iso.h:983
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:1305
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:2013
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:1891
static int32_t __stdfix_smul_hr(int32_t x, int32_t y)
Saturated multiplication of the underlying integer representations.
Definition stdfix-full-iso.h:935
static int32_t __stdfix_sadd_r(int32_t x, int32_t y)
Saturated addition of the underlying integer representations.
Definition stdfix-full-iso.h:767
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:801
static u88 uhkbits(const uint_uhk_t n)
Converts an unsigned integer into an unsigned short accum.
Definition stdfix-full-iso.h:515
static uint_ulk_t bitsulk(const u3232 f)
Converts an unsigned long accum into an integer.
Definition stdfix-full-iso.h:380
static int32_t __stdfix_sat_k(const int64_t x)
Saturates a 64-bit integer to 32-bits.
Definition stdfix-full-iso.h:643
static s1615 absk(s1615 f)
This function returns the absolute value of an accum.
Definition stdfix-full-iso.h:1745
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:1505
static int32_t __stdfix_smul_k(int32_t x, int32_t y)
Saturated multiplication of the underlying integer representations.
Definition stdfix-full-iso.h:999
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:1218
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:1974
static s3231 abslk(s3231 f)
This function returns the absolute value of a long accum.
Definition stdfix-full-iso.h:1761
static uint32_t __stdfix_sat_ulr(const uint64_t x)
Saturates an unsigned 64-bit integer to 32 bits.
Definition stdfix-full-iso.h:688
static s87 abshk(s87 f)
This function returns the absolute value of a short accum.
Definition stdfix-full-iso.h:1729
static int32_t __stdfix_sat_hk(const int32_t x)
Saturates an integer to 16 bits.
Definition stdfix-full-iso.h:626
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:1834
static int idivk(s1615 x, s1615 y)
Divides two accums giving an integer answer.
Definition stdfix-full-iso.h:1441
#define __I(x)
Cast to int.
Definition stdfix-full-iso.h:553
static int32_t __stdfix_ssub_hk(int32_t x, int32_t y)
Saturated subtraction of the underlying integer representations.
Definition stdfix-full-iso.h:847
static int_r_t bitsr(const s015 f)
Converts a fract into an integer.
Definition stdfix-full-iso.h:250
static int32_t __stdfix_sneg_hk(int32_t x)
Saturated negation of the underlying integer representations.
Definition stdfix-full-iso.h:858
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:1492
static int countlshk(s87 f)
This function counts the number of leading sign-bits of a short accum.
Definition stdfix-full-iso.h:2170
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:1075
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:1062
static uint_ur_t bitsur(const u016 f)
Converts an unsigned fract into an integer.
Definition stdfix-full-iso.h:328
static int32_t __stdfix_sadd_hk(int32_t x, int32_t y)
Saturated addition of the underlying integer representations.
Definition stdfix-full-iso.h:835
static int countlsulk(u3232 f)
This function counts the number of leading zeros of an unsigned long accum.
Definition stdfix-full-iso.h:2305
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:1522
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:733
static u016 urdivi(unsigned int i, unsigned int j)
Divides two unsigned integers giving an unsigned fract answer.
Definition stdfix-full-iso.h:1573
static u016 urbits(const uint_ur_t n)
Converts an unsigned integer into an unsigned fract.
Definition stdfix-full-iso.h:489
static int32_t __stdfix_sneg_r(int32_t x)
Saturated negation of the underlying integer representations.
Definition stdfix-full-iso.h:790
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:341
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:1713
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:1853
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:1796
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:2065
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:592
#define __ULI(x)
Cast to unsigned long int.
Definition stdfix-full-iso.h:567
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:2052
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:1987
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:813
static s3231 lkdivi(long int i, long int j)
Divides two integers giving a long accum answer.
Definition stdfix-full-iso.h:1405
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:1088
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:1660
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:1140
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:2078
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:559
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:1929
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:541
static int32_t __stdfix_sneg_lr(int32_t x)
Saturated negation of the underlying integer representations.
Definition stdfix-full-iso.h:824
static int32_t __stdfix_smul_r(int32_t x, int32_t y)
Saturated multiplication of the underlying integer representations.
Definition stdfix-full-iso.h:951
static unsigned int idivur(u016 x, u016 y)
Divides two unsigned fracts giving an unsigned integer answer.
Definition stdfix-full-iso.h:1623
static s015 rbits(const int_r_t n)
Converts a signed integer into a signed fract.
Definition stdfix-full-iso.h:411
static int_hk_t bitshk(const s87 f)
Converts a short accum into an integer.
Definition stdfix-full-iso.h:276
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:1280
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:1535
static long int idivlr(s031 x, s031 y)
Divides two long fracts giving a long integer answer.
Definition stdfix-full-iso.h:1429
static u1616 ukbits(const uint_uk_t n)
Converts an unsigned integer into an unsigned accum.
Definition stdfix-full-iso.h:528
static uint32_t __stdfix_sat_uhk(const uint32_t x)
Saturates an unsigned integer to 16 bits.
Definition stdfix-full-iso.h:702
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:1872
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:1186
static int32_t __stdfix_ssub_k(int32_t x, int32_t y)
Saturated subtraction of the underlying integer representations.
Definition stdfix-full-iso.h:885
static int countlsuhk(u88 f)
This function counts the number of leading zeros of an unsigned short accum.
Definition stdfix-full-iso.h:2271
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:1023
static s07 hrbits(const int_hr_t n)
Converts a signed integer into a signed short fract.
Definition stdfix-full-iso.h:398
static s015 absr(s015 f)
This function returns the absolute value of a fract.
Definition stdfix-full-iso.h:1697
static s87 hkbits(const int_hk_t n)
Converts a signed integer into a signed short accum.
Definition stdfix-full-iso.h:437
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:1611
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:1333
static s031 lrdivi(long int i, long int j)
Divides two integers giving a long fract answer.
Definition stdfix-full-iso.h:1381
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:1910
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:302
#define __I32(x)
Cast to int32_t.
Definition stdfix-full-iso.h:555
static int32_t __stdfix_sadd_k(int32_t x, int32_t y)
Saturated addition of the underlying integer representations.
Definition stdfix-full-iso.h:869
static s1615 kdivi(int i, int j)
Divides two integers giving an accum answer.
Definition stdfix-full-iso.h:1393
static int countlslk(s3231 f)
This function counts the number of leading sign-bits of a long accum.
Definition stdfix-full-iso.h:2203
static s1615 kbits(const int_k_t n)
Converts a signed integer into a signed accum.
Definition stdfix-full-iso.h:450
static int32_t __stdfix_sat_lr(const int64_t x)
Saturates a 64-bit integer to 32-bits.
Definition stdfix-full-iso.h:609
#define __I64(x)
Cast to int64_t.
Definition stdfix-full-iso.h:557
static uint32_t __stdfix_sat_uk(const uint64_t x)
Saturates an unsigned 64-bit integer to 32 bits.
Definition stdfix-full-iso.h:716
static int idivr(s015 x, s015 y)
Divides two fracts giving an integer answer.
Definition stdfix-full-iso.h:1417
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:1036
static s07 abshr(s07 f)
This function returns the absolute value of a short fract.
Definition stdfix-full-iso.h:1681
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:1232
static int32_t __stdfix_sneg_hr(int_hr_t x)
Saturated negation of the underlying integer representations.
Definition stdfix-full-iso.h:756
static s015 rdivi(int i, int j)
Divides two integers giving a fract answer.
Definition stdfix-full-iso.h:1369
static uint32_t __stdfix_sat_uhr(const uint32_t x)
Saturates an unsigned integer to 8 bits.
Definition stdfix-full-iso.h:660
static int32_t __stdfix_smul_lr(int32_t x, int32_t y)
Saturated multiplication of the underlying integer representations.
Definition stdfix-full-iso.h:967
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:2000