Lines Matching refs:a
41 static inline void zero128(int128 a)
43 a[LSW128] = a[NLSW128] = a[NMSW128] = a[MSW128] = 0;
48 unsigned int i0, int128 a)
50 a[LSW128] = i0;
51 a[NLSW128] = i1;
52 a[NMSW128] = i2;
53 a[MSW128] = i3;
69 static inline void put_i128(const int128 a)
71 printk("%08x %08x %08x %08x\n", a[MSW128], a[NMSW128],
72 a[NLSW128], a[LSW128]);
80 static inline void _lsl128(unsigned int count, int128 a)
82 a[MSW128] = (a[MSW128] << count) | (a[NMSW128] >> (32 - count));
83 a[NMSW128] = (a[NMSW128] << count) | (a[NLSW128] >> (32 - count));
84 a[NLSW128] = (a[NLSW128] << count) | (a[LSW128] >> (32 - count));
85 a[LSW128] <<= count;
88 static inline void _lsr128(unsigned int count, int128 a)
90 a[LSW128] = (a[LSW128] >> count) | (a[NLSW128] << (32 - count));
91 a[NLSW128] = (a[NLSW128] >> count) | (a[NMSW128] << (32 - count));
92 a[NMSW128] = (a[NMSW128] >> count) | (a[MSW128] << (32 - count));
93 a[MSW128] >>= count;
98 static inline void lslone128(int128 a)
105 "=d" (a[LSW128]),
106 "=d"(a[NLSW128]),
107 "=d"(a[NMSW128]),
108 "=d"(a[MSW128])
110 "0"(a[LSW128]),
111 "1"(a[NLSW128]),
112 "2"(a[NMSW128]),
113 "3"(a[MSW128]));
116 static inline void lsrone128(int128 a)
123 "=d" (a[MSW128]),
124 "=d"(a[NMSW128]),
125 "=d"(a[NLSW128]),
126 "=d"(a[LSW128])
128 "0"(a[MSW128]),
129 "1"(a[NMSW128]),
130 "2"(a[NLSW128]),
131 "3"(a[LSW128]));
138 static inline void lsl128(unsigned int count, int128 a)
143 _lsl128(count % 32, a);
150 a[i] = a[i + wordcount];
153 a[i] = 0;
157 static inline void lsr128(unsigned int count, int128 a)
162 _lsr128(count % 32, a);
168 a[i] = a[i - wordcount];
171 a[i] = 0;
175 static inline int orl128(int a, int128 b)
177 b[LSW128] |= a;
180 static inline int btsthi128(const int128 a)
182 return a[MSW128] & 0x80000000;
186 static inline int bftestlo128(int top, const int128 a)
191 r |= a[LSW128];
193 r |= a[NLSW128];
195 r |= a[NMSW128];
197 r |= a[3 - (top / 32)] & ((1 << (top % 32 + 1)) - 1);
641 static inline int fls(unsigned int a)
646 : "=d" (r) : "md" (a));
651 static inline int fls128(const int128 a)
653 if (a[MSW128])
654 return fls(a[MSW128]);
655 if (a[NMSW128])
656 return fls(a[NMSW128]) + 32;
662 if (a[NLSW128])
663 return fls(a[NLSW128]) + 64;
664 if (a[LSW128])
665 return fls(a[LSW128]) + 96;
670 static inline int zerop128(const int128 a)
672 return !(a[LSW128] | a[NLSW128] | a[NMSW128] | a[MSW128]);
675 static inline int nonzerop128(const int128 a)
677 return (a[LSW128] | a[NLSW128] | a[NMSW128] | a[MSW128]);
683 static inline void add128(const int128 a, int128 b)
688 carry[0] = a[LSW128] > (0xffffffff - b[LSW128]);
689 b[LSW128] += a[LSW128];
691 carry[1] = a[NLSW128] > (0xffffffff - b[NLSW128] - carry[0]);
692 b[NLSW128] = a[NLSW128] + b[NLSW128] + carry[0];
694 carry[0] = a[NMSW128] > (0xffffffff - b[NMSW128] - carry[1]);
695 b[NMSW128] = a[NMSW128] + b[NMSW128] + carry[1];
697 b[MSW128] = a[MSW128] + b[MSW128] + carry[0];
701 static inline void sub128(const int128 a, int128 b)
706 borrow[0] = b[LSW128] < a[LSW128];
707 b[LSW128] -= a[LSW128];
709 borrow[1] = b[NLSW128] < a[NLSW128] + borrow[0];
710 b[NLSW128] = b[NLSW128] - a[NLSW128] - borrow[0];
712 borrow[0] = b[NMSW128] < a[NMSW128] + borrow[1];
713 b[NMSW128] = b[NMSW128] - a[NMSW128] - borrow[1];
715 b[MSW128] = b[MSW128] - a[MSW128] - borrow[0];
719 static inline void mul64(unsigned long long a, unsigned long long b, int128 c)
728 if (LO_WORD(a) && LO_WORD(b)) {
729 acc = (long long) LO_WORD(a) * LO_WORD(b);
734 if (HI_WORD(a) && HI_WORD(b)) {
735 acc = (long long) HI_WORD(a) * HI_WORD(b);
740 if (LO_WORD(a) && HI_WORD(b)) {
741 acc = (long long) LO_WORD(a) * HI_WORD(b);
747 if (HI_WORD(a) && LO_WORD(b)) {
748 acc = (long long) HI_WORD(a) * LO_WORD(b);
756 static inline int cmp128(int128 a, int128 b)
758 if (a[MSW128] < b[MSW128])
760 if (a[MSW128] > b[MSW128])
762 if (a[NMSW128] < b[NMSW128])
764 if (a[NMSW128] > b[NMSW128])
766 if (a[NLSW128] < b[NLSW128])
768 if (a[NLSW128] > b[NLSW128])
771 return (signed) a[LSW128] - b[LSW128];
774 inline void div128(int128 a, int128 b, int128 c)
799 while (cmp128(b, a) < 0 && !btsthi128(b)) {
807 if (cmp128(a, b) >= 0) {
808 sub128(b, a);