1 
2 /*============================================================================
3 
4 This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5 Package, Release 3d, by John R. Hauser.
6 
7 Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8 University of California.  All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 
13  1. Redistributions of source code must retain the above copyright notice,
14     this list of conditions, and the following disclaimer.
15 
16  2. Redistributions in binary form must reproduce the above copyright notice,
17     this list of conditions, and the following disclaimer in the documentation
18     and/or other materials provided with the distribution.
19 
20  3. Neither the name of the University nor the names of its contributors may
21     be used to endorse or promote products derived from this software without
22     specific prior written permission.
23 
24 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27 DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 
35 =============================================================================*/
36 
37 #ifndef primitives_h
38 #define primitives_h 1
39 
40 #include <stdbool.h>
41 #include <stdint.h>
42 #include "primitiveTypes.h"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 #ifndef softfloat_shortShiftRightJam64
49 /*----------------------------------------------------------------------------
50 | Shifts 'a' right by the number of bits given in 'dist', which must be in
51 | the range 1 to 63.  If any nonzero bits are shifted off, they are "jammed"
52 | into the least-significant bit of the shifted value by setting the least-
53 | significant bit to 1.  This shifted-and-jammed value is returned.
54 *----------------------------------------------------------------------------*/
55 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
56 INLINE
softfloat_shortShiftRightJam64(uint64_t a,uint_fast8_t dist)57 uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist )
58     { return a>>dist | ((a & (((uint_fast64_t) 1<<dist) - 1)) != 0); }
59 #else
60 uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist );
61 #endif
62 #endif
63 
64 #ifndef softfloat_shiftRightJam32
65 /*----------------------------------------------------------------------------
66 | Shifts 'a' right by the number of bits given in 'dist', which must not
67 | be zero.  If any nonzero bits are shifted off, they are "jammed" into the
68 | least-significant bit of the shifted value by setting the least-significant
69 | bit to 1.  This shifted-and-jammed value is returned.
70 |   The value of 'dist' can be arbitrarily large.  In particular, if 'dist' is
71 | greater than 32, the result will be either 0 or 1, depending on whether 'a'
72 | is zero or nonzero.
73 *----------------------------------------------------------------------------*/
74 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
softfloat_shiftRightJam32(uint32_t a,uint_fast16_t dist)75 INLINE uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist )
76 {
77     return
78         (dist < 31) ? a>>dist | ((uint32_t) (a<<(-dist & 31)) != 0) : (a != 0);
79 }
80 #else
81 uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist );
82 #endif
83 #endif
84 
85 #ifndef softfloat_shiftRightJam64
86 /*----------------------------------------------------------------------------
87 | Shifts 'a' right by the number of bits given in 'dist', which must not
88 | be zero.  If any nonzero bits are shifted off, they are "jammed" into the
89 | least-significant bit of the shifted value by setting the least-significant
90 | bit to 1.  This shifted-and-jammed value is returned.
91 |   The value of 'dist' can be arbitrarily large.  In particular, if 'dist' is
92 | greater than 64, the result will be either 0 or 1, depending on whether 'a'
93 | is zero or nonzero.
94 *----------------------------------------------------------------------------*/
95 #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
softfloat_shiftRightJam64(uint64_t a,uint_fast32_t dist)96 INLINE uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist )
97 {
98     return
99         (dist < 63) ? a>>dist | ((uint64_t) (a<<(-dist & 63)) != 0) : (a != 0);
100 }
101 #else
102 uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist );
103 #endif
104 #endif
105 
106 /*----------------------------------------------------------------------------
107 | A constant table that translates an 8-bit unsigned integer (the array index)
108 | into the number of leading 0 bits before the most-significant 1 of that
109 | integer.  For integer zero (index 0), the corresponding table element is 8.
110 *----------------------------------------------------------------------------*/
111 extern const uint_least8_t softfloat_countLeadingZeros8[256];
112 
113 #ifndef softfloat_countLeadingZeros16
114 /*----------------------------------------------------------------------------
115 | Returns the number of leading 0 bits before the most-significant 1 bit of
116 | 'a'.  If 'a' is zero, 16 is returned.
117 *----------------------------------------------------------------------------*/
118 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
softfloat_countLeadingZeros16(uint16_t a)119 INLINE uint_fast8_t softfloat_countLeadingZeros16( uint16_t a )
120 {
121     uint_fast8_t count = 8;
122     if ( 0x100 <= a ) {
123         count = 0;
124         a >>= 8;
125     }
126     count += softfloat_countLeadingZeros8[a];
127     return count;
128 }
129 #else
130 uint_fast8_t softfloat_countLeadingZeros16( uint16_t a );
131 #endif
132 #endif
133 
134 #ifndef softfloat_countLeadingZeros32
135 /*----------------------------------------------------------------------------
136 | Returns the number of leading 0 bits before the most-significant 1 bit of
137 | 'a'.  If 'a' is zero, 32 is returned.
138 *----------------------------------------------------------------------------*/
139 #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
softfloat_countLeadingZeros32(uint32_t a)140 INLINE uint_fast8_t softfloat_countLeadingZeros32( uint32_t a )
141 {
142     uint_fast8_t count = 0;
143     if ( a < 0x10000 ) {
144         count = 16;
145         a <<= 16;
146     }
147     if ( a < 0x1000000 ) {
148         count += 8;
149         a <<= 8;
150     }
151     count += softfloat_countLeadingZeros8[a>>24];
152     return count;
153 }
154 #else
155 uint_fast8_t softfloat_countLeadingZeros32( uint32_t a );
156 #endif
157 #endif
158 
159 #ifndef softfloat_countLeadingZeros64
160 /*----------------------------------------------------------------------------
161 | Returns the number of leading 0 bits before the most-significant 1 bit of
162 | 'a'.  If 'a' is zero, 64 is returned.
163 *----------------------------------------------------------------------------*/
164 uint_fast8_t softfloat_countLeadingZeros64( uint64_t a );
165 #endif
166 
167 extern const uint16_t softfloat_approxRecip_1k0s[16];
168 extern const uint16_t softfloat_approxRecip_1k1s[16];
169 
170 #ifndef softfloat_approxRecip32_1
171 /*----------------------------------------------------------------------------
172 | Returns an approximation to the reciprocal of the number represented by 'a',
173 | where 'a' is interpreted as an unsigned fixed-point number with one integer
174 | bit and 31 fraction bits.  The 'a' input must be "normalized", meaning that
175 | its most-significant bit (bit 31) must be 1.  Thus, if A is the value of
176 | the fixed-point interpretation of 'a', then 1 <= A < 2.  The returned value
177 | is interpreted as a pure unsigned fraction, having no integer bits and 32
178 | fraction bits.  The approximation returned is never greater than the true
179 | reciprocal 1/A, and it differs from the true reciprocal by at most 2.006 ulp
180 | (units in the last place).
181 *----------------------------------------------------------------------------*/
182 #ifdef SOFTFLOAT_FAST_DIV64TO32
183 #define softfloat_approxRecip32_1( a ) ((uint32_t) (UINT64_C( 0x7FFFFFFFFFFFFFFF ) / (uint32_t) (a)))
184 #else
185 uint32_t softfloat_approxRecip32_1( uint32_t a );
186 #endif
187 #endif
188 
189 extern const uint16_t softfloat_approxRecipSqrt_1k0s[16];
190 extern const uint16_t softfloat_approxRecipSqrt_1k1s[16];
191 
192 #ifndef softfloat_approxRecipSqrt32_1
193 /*----------------------------------------------------------------------------
194 | Returns an approximation to the reciprocal of the square root of the number
195 | represented by 'a', where 'a' is interpreted as an unsigned fixed-point
196 | number either with one integer bit and 31 fraction bits or with two integer
197 | bits and 30 fraction bits.  The format of 'a' is determined by 'oddExpA',
198 | which must be either 0 or 1.  If 'oddExpA' is 1, 'a' is interpreted as
199 | having one integer bit, and if 'oddExpA' is 0, 'a' is interpreted as having
200 | two integer bits.  The 'a' input must be "normalized", meaning that its
201 | most-significant bit (bit 31) must be 1.  Thus, if A is the value of the
202 | fixed-point interpretation of 'a', it follows that 1 <= A < 2 when 'oddExpA'
203 | is 1, and 2 <= A < 4 when 'oddExpA' is 0.
204 |   The returned value is interpreted as a pure unsigned fraction, having
205 | no integer bits and 32 fraction bits.  The approximation returned is never
206 | greater than the true reciprocal 1/sqrt(A), and it differs from the true
207 | reciprocal by at most 2.06 ulp (units in the last place).  The approximation
208 | returned is also always within the range 0.5 to 1; thus, the most-
209 | significant bit of the result is always set.
210 *----------------------------------------------------------------------------*/
211 uint32_t softfloat_approxRecipSqrt32_1( unsigned int oddExpA, uint32_t a );
212 #endif
213 
214 #ifdef SOFTFLOAT_FAST_INT64
215 
216 /*----------------------------------------------------------------------------
217 | The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is
218 | defined.
219 *----------------------------------------------------------------------------*/
220 
221 #ifndef softfloat_eq128
222 /*----------------------------------------------------------------------------
223 | Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
224 | and 'a0' is equal to the 128-bit unsigned integer formed by concatenating
225 | 'b64' and 'b0'.
226 *----------------------------------------------------------------------------*/
227 #if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
228 INLINE
softfloat_eq128(uint64_t a64,uint64_t a0,uint64_t b64,uint64_t b0)229 bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
230     { return (a64 == b64) && (a0 == b0); }
231 #else
232 bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
233 #endif
234 #endif
235 
236 #ifndef softfloat_le128
237 /*----------------------------------------------------------------------------
238 | Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
239 | and 'a0' is less than or equal to the 128-bit unsigned integer formed by
240 | concatenating 'b64' and 'b0'.
241 *----------------------------------------------------------------------------*/
242 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
243 INLINE
softfloat_le128(uint64_t a64,uint64_t a0,uint64_t b64,uint64_t b0)244 bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
245     { return (a64 < b64) || ((a64 == b64) && (a0 <= b0)); }
246 #else
247 bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
248 #endif
249 #endif
250 
251 #ifndef softfloat_lt128
252 /*----------------------------------------------------------------------------
253 | Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
254 | and 'a0' is less than the 128-bit unsigned integer formed by concatenating
255 | 'b64' and 'b0'.
256 *----------------------------------------------------------------------------*/
257 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
258 INLINE
softfloat_lt128(uint64_t a64,uint64_t a0,uint64_t b64,uint64_t b0)259 bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
260     { return (a64 < b64) || ((a64 == b64) && (a0 < b0)); }
261 #else
262 bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
263 #endif
264 #endif
265 
266 #ifndef softfloat_shortShiftLeft128
267 /*----------------------------------------------------------------------------
268 | Shifts the 128 bits formed by concatenating 'a64' and 'a0' left by the
269 | number of bits given in 'dist', which must be in the range 1 to 63.
270 *----------------------------------------------------------------------------*/
271 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
272 INLINE
273 struct uint128
softfloat_shortShiftLeft128(uint64_t a64,uint64_t a0,uint_fast8_t dist)274  softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
275 {
276     struct uint128 z;
277     z.v64 = a64<<dist | a0>>(-dist & 63);
278     z.v0 = a0<<dist;
279     return z;
280 }
281 #else
282 struct uint128
283  softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist );
284 #endif
285 #endif
286 
287 #ifndef softfloat_shortShiftRight128
288 /*----------------------------------------------------------------------------
289 | Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
290 | number of bits given in 'dist', which must be in the range 1 to 63.
291 *----------------------------------------------------------------------------*/
292 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
293 INLINE
294 struct uint128
softfloat_shortShiftRight128(uint64_t a64,uint64_t a0,uint_fast8_t dist)295  softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
296 {
297     struct uint128 z;
298     z.v64 = a64>>dist;
299     z.v0 = a64<<(-dist & 63) | a0>>dist;
300     return z;
301 }
302 #else
303 struct uint128
304  softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist );
305 #endif
306 #endif
307 
308 #ifndef softfloat_shortShiftRightJam64Extra
309 /*----------------------------------------------------------------------------
310 | This function is the same as 'softfloat_shiftRightJam64Extra' (below),
311 | except that 'dist' must be in the range 1 to 63.
312 *----------------------------------------------------------------------------*/
313 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
314 INLINE
315 struct uint64_extra
softfloat_shortShiftRightJam64Extra(uint64_t a,uint64_t extra,uint_fast8_t dist)316  softfloat_shortShiftRightJam64Extra(
317      uint64_t a, uint64_t extra, uint_fast8_t dist )
318 {
319     struct uint64_extra z;
320     z.v = a>>dist;
321     z.extra = a<<(-dist & 63) | (extra != 0);
322     return z;
323 }
324 #else
325 struct uint64_extra
326  softfloat_shortShiftRightJam64Extra(
327      uint64_t a, uint64_t extra, uint_fast8_t dist );
328 #endif
329 #endif
330 
331 #ifndef softfloat_shortShiftRightJam128
332 /*----------------------------------------------------------------------------
333 | Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
334 | number of bits given in 'dist', which must be in the range 1 to 63.  If any
335 | nonzero bits are shifted off, they are "jammed" into the least-significant
336 | bit of the shifted value by setting the least-significant bit to 1.  This
337 | shifted-and-jammed value is returned.
338 *----------------------------------------------------------------------------*/
339 #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
340 INLINE
341 struct uint128
softfloat_shortShiftRightJam128(uint64_t a64,uint64_t a0,uint_fast8_t dist)342  softfloat_shortShiftRightJam128(
343      uint64_t a64, uint64_t a0, uint_fast8_t dist )
344 {
345     uint_fast8_t negDist = -dist;
346     struct uint128 z;
347     z.v64 = a64>>dist;
348     z.v0 =
349         a64<<(negDist & 63) | a0>>dist
350             | ((uint64_t) (a0<<(negDist & 63)) != 0);
351     return z;
352 }
353 #else
354 struct uint128
355  softfloat_shortShiftRightJam128(
356      uint64_t a64, uint64_t a0, uint_fast8_t dist );
357 #endif
358 #endif
359 
360 #ifndef softfloat_shortShiftRightJam128Extra
361 /*----------------------------------------------------------------------------
362 | This function is the same as 'softfloat_shiftRightJam128Extra' (below),
363 | except that 'dist' must be in the range 1 to 63.
364 *----------------------------------------------------------------------------*/
365 #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
366 INLINE
367 struct uint128_extra
softfloat_shortShiftRightJam128Extra(uint64_t a64,uint64_t a0,uint64_t extra,uint_fast8_t dist)368  softfloat_shortShiftRightJam128Extra(
369      uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist )
370 {
371     uint_fast8_t negDist = -dist;
372     struct uint128_extra z;
373     z.v.v64 = a64>>dist;
374     z.v.v0 = a64<<(negDist & 63) | a0>>dist;
375     z.extra = a0<<(negDist & 63) | (extra != 0);
376     return z;
377 }
378 #else
379 struct uint128_extra
380  softfloat_shortShiftRightJam128Extra(
381      uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist );
382 #endif
383 #endif
384 
385 #ifndef softfloat_shiftRightJam64Extra
386 /*----------------------------------------------------------------------------
387 | Shifts the 128 bits formed by concatenating 'a' and 'extra' right by 64
388 | _plus_ the number of bits given in 'dist', which must not be zero.  This
389 | shifted value is at most 64 nonzero bits and is returned in the 'v' field
390 | of the 'struct uint64_extra' result.  The 64-bit 'extra' field of the result
391 | contains a value formed as follows from the bits that were shifted off:  The
392 | _last_ bit shifted off is the most-significant bit of the 'extra' field, and
393 | the other 63 bits of the 'extra' field are all zero if and only if _all_but_
394 | _the_last_ bits shifted off were all zero.
395 |   (This function makes more sense if 'a' and 'extra' are considered to form
396 | an unsigned fixed-point number with binary point between 'a' and 'extra'.
397 | This fixed-point value is shifted right by the number of bits given in
398 | 'dist', and the integer part of this shifted value is returned in the 'v'
399 | field of the result.  The fractional part of the shifted value is modified
400 | as described above and returned in the 'extra' field of the result.)
401 *----------------------------------------------------------------------------*/
402 #if defined INLINE_LEVEL && (4 <= INLINE_LEVEL)
403 INLINE
404 struct uint64_extra
softfloat_shiftRightJam64Extra(uint64_t a,uint64_t extra,uint_fast32_t dist)405  softfloat_shiftRightJam64Extra(
406      uint64_t a, uint64_t extra, uint_fast32_t dist )
407 {
408     struct uint64_extra z;
409     if ( dist < 64 ) {
410         z.v = a>>dist;
411         z.extra = a<<(-dist & 63);
412     } else {
413         z.v = 0;
414         z.extra = (dist == 64) ? a : (a != 0);
415     }
416     z.extra |= (extra != 0);
417     return z;
418 }
419 #else
420 struct uint64_extra
421  softfloat_shiftRightJam64Extra(
422      uint64_t a, uint64_t extra, uint_fast32_t dist );
423 #endif
424 #endif
425 
426 #ifndef softfloat_shiftRightJam128
427 /*----------------------------------------------------------------------------
428 | Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
429 | number of bits given in 'dist', which must not be zero.  If any nonzero bits
430 | are shifted off, they are "jammed" into the least-significant bit of the
431 | shifted value by setting the least-significant bit to 1.  This shifted-and-
432 | jammed value is returned.
433 |   The value of 'dist' can be arbitrarily large.  In particular, if 'dist' is
434 | greater than 128, the result will be either 0 or 1, depending on whether the
435 | original 128 bits are all zeros.
436 *----------------------------------------------------------------------------*/
437 struct uint128
438  softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t dist );
439 #endif
440 
441 #ifndef softfloat_shiftRightJam128Extra
442 /*----------------------------------------------------------------------------
443 | Shifts the 192 bits formed by concatenating 'a64', 'a0', and 'extra' right
444 | by 64 _plus_ the number of bits given in 'dist', which must not be zero.
445 | This shifted value is at most 128 nonzero bits and is returned in the 'v'
446 | field of the 'struct uint128_extra' result.  The 64-bit 'extra' field of the
447 | result contains a value formed as follows from the bits that were shifted
448 | off:  The _last_ bit shifted off is the most-significant bit of the 'extra'
449 | field, and the other 63 bits of the 'extra' field are all zero if and only
450 | if _all_but_the_last_ bits shifted off were all zero.
451 |   (This function makes more sense if 'a64', 'a0', and 'extra' are considered
452 | to form an unsigned fixed-point number with binary point between 'a0' and
453 | 'extra'.  This fixed-point value is shifted right by the number of bits
454 | given in 'dist', and the integer part of this shifted value is returned
455 | in the 'v' field of the result.  The fractional part of the shifted value
456 | is modified as described above and returned in the 'extra' field of the
457 | result.)
458 *----------------------------------------------------------------------------*/
459 struct uint128_extra
460  softfloat_shiftRightJam128Extra(
461      uint64_t a64, uint64_t a0, uint64_t extra, uint_fast32_t dist );
462 #endif
463 
464 #ifndef softfloat_shiftRightJam256M
465 /*----------------------------------------------------------------------------
466 | Shifts the 256-bit unsigned integer pointed to by 'aPtr' right by the number
467 | of bits given in 'dist', which must not be zero.  If any nonzero bits are
468 | shifted off, they are "jammed" into the least-significant bit of the shifted
469 | value by setting the least-significant bit to 1.  This shifted-and-jammed
470 | value is stored at the location pointed to by 'zPtr'.  Each of 'aPtr' and
471 | 'zPtr' points to an array of four 64-bit elements that concatenate in the
472 | platform's normal endian order to form a 256-bit integer.
473 |   The value of 'dist' can be arbitrarily large.  In particular, if 'dist'
474 | is greater than 256, the stored result will be either 0 or 1, depending on
475 | whether the original 256 bits are all zeros.
476 *----------------------------------------------------------------------------*/
477 void
478  softfloat_shiftRightJam256M(
479      const uint64_t *aPtr, uint_fast32_t dist, uint64_t *zPtr );
480 #endif
481 
482 #ifndef softfloat_add128
483 /*----------------------------------------------------------------------------
484 | Returns the sum of the 128-bit integer formed by concatenating 'a64' and
485 | 'a0' and the 128-bit integer formed by concatenating 'b64' and 'b0'.  The
486 | addition is modulo 2^128, so any carry out is lost.
487 *----------------------------------------------------------------------------*/
488 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
489 INLINE
490 struct uint128
softfloat_add128(uint64_t a64,uint64_t a0,uint64_t b64,uint64_t b0)491  softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
492 {
493     struct uint128 z;
494     z.v0 = a0 + b0;
495     z.v64 = a64 + b64 + (z.v0 < a0);
496     return z;
497 }
498 #else
499 struct uint128
500  softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
501 #endif
502 #endif
503 
504 #ifndef softfloat_add256M
505 /*----------------------------------------------------------------------------
506 | Adds the two 256-bit integers pointed to by 'aPtr' and 'bPtr'.  The addition
507 | is modulo 2^256, so any carry out is lost.  The sum is stored at the
508 | location pointed to by 'zPtr'.  Each of 'aPtr', 'bPtr', and 'zPtr' points to
509 | an array of four 64-bit elements that concatenate in the platform's normal
510 | endian order to form a 256-bit integer.
511 *----------------------------------------------------------------------------*/
512 void
513  softfloat_add256M(
514      const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr );
515 #endif
516 
517 #ifndef softfloat_sub128
518 /*----------------------------------------------------------------------------
519 | Returns the difference of the 128-bit integer formed by concatenating 'a64'
520 | and 'a0' and the 128-bit integer formed by concatenating 'b64' and 'b0'.
521 | The subtraction is modulo 2^128, so any borrow out (carry out) is lost.
522 *----------------------------------------------------------------------------*/
523 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
524 INLINE
525 struct uint128
softfloat_sub128(uint64_t a64,uint64_t a0,uint64_t b64,uint64_t b0)526  softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
527 {
528     struct uint128 z;
529     z.v0 = a0 - b0;
530     z.v64 = a64 - b64;
531     z.v64 -= (a0 < b0);
532     return z;
533 }
534 #else
535 struct uint128
536  softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
537 #endif
538 #endif
539 
540 #ifndef softfloat_sub256M
541 /*----------------------------------------------------------------------------
542 | Subtracts the 256-bit integer pointed to by 'bPtr' from the 256-bit integer
543 | pointed to by 'aPtr'.  The addition is modulo 2^256, so any borrow out
544 | (carry out) is lost.  The difference is stored at the location pointed to
545 | by 'zPtr'.  Each of 'aPtr', 'bPtr', and 'zPtr' points to an array of four
546 | 64-bit elements that concatenate in the platform's normal endian order to
547 | form a 256-bit integer.
548 *----------------------------------------------------------------------------*/
549 void
550  softfloat_sub256M(
551      const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr );
552 #endif
553 
554 #ifndef softfloat_mul64ByShifted32To128
555 /*----------------------------------------------------------------------------
556 | Returns the 128-bit product of 'a', 'b', and 2^32.
557 *----------------------------------------------------------------------------*/
558 #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
softfloat_mul64ByShifted32To128(uint64_t a,uint32_t b)559 INLINE struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b )
560 {
561     uint_fast64_t mid;
562     struct uint128 z;
563     mid = (uint_fast64_t) (uint32_t) a * b;
564     z.v0 = mid<<32;
565     z.v64 = (uint_fast64_t) (uint32_t) (a>>32) * b + (mid>>32);
566     return z;
567 }
568 #else
569 struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b );
570 #endif
571 #endif
572 
573 #ifndef softfloat_mul64To128
574 /*----------------------------------------------------------------------------
575 | Returns the 128-bit product of 'a' and 'b'.
576 *----------------------------------------------------------------------------*/
577 struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b );
578 #endif
579 
580 #ifndef softfloat_mul128By32
581 /*----------------------------------------------------------------------------
582 | Returns the product of the 128-bit integer formed by concatenating 'a64' and
583 | 'a0', multiplied by 'b'.  The multiplication is modulo 2^128; any overflow
584 | bits are discarded.
585 *----------------------------------------------------------------------------*/
586 #if defined INLINE_LEVEL && (4 <= INLINE_LEVEL)
587 INLINE
softfloat_mul128By32(uint64_t a64,uint64_t a0,uint32_t b)588 struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b )
589 {
590     struct uint128 z;
591     uint_fast64_t mid;
592     uint_fast32_t carry;
593     z.v0 = a0 * b;
594     mid = (uint_fast64_t) (uint32_t) (a0>>32) * b;
595     carry = (uint32_t) ((uint_fast32_t) (z.v0>>32) - (uint_fast32_t) mid);
596     z.v64 = a64 * b + (uint_fast32_t) ((mid + carry)>>32);
597     return z;
598 }
599 #else
600 struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b );
601 #endif
602 #endif
603 
604 #ifndef softfloat_mul128To256M
605 /*----------------------------------------------------------------------------
606 | Multiplies the 128-bit unsigned integer formed by concatenating 'a64' and
607 | 'a0' by the 128-bit unsigned integer formed by concatenating 'b64' and
608 | 'b0'.  The 256-bit product is stored at the location pointed to by 'zPtr'.
609 | Argument 'zPtr' points to an array of four 64-bit elements that concatenate
610 | in the platform's normal endian order to form a 256-bit integer.
611 *----------------------------------------------------------------------------*/
612 void
613  softfloat_mul128To256M(
614      uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0, uint64_t *zPtr );
615 #endif
616 
617 #else
618 
619 /*----------------------------------------------------------------------------
620 | The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is not
621 | defined.
622 *----------------------------------------------------------------------------*/
623 
624 #ifndef softfloat_compare96M
625 /*----------------------------------------------------------------------------
626 | Compares the two 96-bit unsigned integers pointed to by 'aPtr' and 'bPtr'.
627 | Returns -1 if the first integer (A) is less than the second (B); returns 0
628 | if the two integers are equal; and returns +1 if the first integer (A)
629 | is greater than the second (B).  (The result is thus the signum of A - B.)
630 | Each of 'aPtr' and 'bPtr' points to an array of three 32-bit elements that
631 | concatenate in the platform's normal endian order to form a 96-bit integer.
632 *----------------------------------------------------------------------------*/
633 int_fast8_t softfloat_compare96M( const uint32_t *aPtr, const uint32_t *bPtr );
634 #endif
635 
636 #ifndef softfloat_compare128M
637 /*----------------------------------------------------------------------------
638 | Compares the two 128-bit unsigned integers pointed to by 'aPtr' and 'bPtr'.
639 | Returns -1 if the first integer (A) is less than the second (B); returns 0
640 | if the two integers are equal; and returns +1 if the first integer (A)
641 | is greater than the second (B).  (The result is thus the signum of A - B.)
642 | Each of 'aPtr' and 'bPtr' points to an array of four 32-bit elements that
643 | concatenate in the platform's normal endian order to form a 128-bit integer.
644 *----------------------------------------------------------------------------*/
645 int_fast8_t
646  softfloat_compare128M( const uint32_t *aPtr, const uint32_t *bPtr );
647 #endif
648 
649 #ifndef softfloat_shortShiftLeft64To96M
650 /*----------------------------------------------------------------------------
651 | Extends 'a' to 96 bits and shifts the value left by the number of bits given
652 | in 'dist', which must be in the range 1 to 31.  The result is stored at the
653 | location pointed to by 'zPtr'.  Argument 'zPtr' points to an array of three
654 | 32-bit elements that concatenate in the platform's normal endian order to
655 | form a 96-bit integer.
656 *----------------------------------------------------------------------------*/
657 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
658 INLINE
659 void
softfloat_shortShiftLeft64To96M(uint64_t a,uint_fast8_t dist,uint32_t * zPtr)660  softfloat_shortShiftLeft64To96M(
661      uint64_t a, uint_fast8_t dist, uint32_t *zPtr )
662 {
663     zPtr[indexWord( 3, 0 )] = (uint32_t) a<<dist;
664     a >>= 32 - dist;
665     zPtr[indexWord( 3, 2 )] = a>>32;
666     zPtr[indexWord( 3, 1 )] = a;
667 }
668 #else
669 void
670  softfloat_shortShiftLeft64To96M(
671      uint64_t a, uint_fast8_t dist, uint32_t *zPtr );
672 #endif
673 #endif
674 
675 #ifndef softfloat_shortShiftLeftM
676 /*----------------------------------------------------------------------------
677 | Shifts the N-bit unsigned integer pointed to by 'aPtr' left by the number
678 | of bits given in 'dist', where N = 'size_words' * 32.  The value of 'dist'
679 | must be in the range 1 to 31.  Any nonzero bits shifted off are lost.  The
680 | shifted N-bit result is stored at the location pointed to by 'zPtr'.  Each
681 | of 'aPtr' and 'zPtr' points to a 'size_words'-long array of 32-bit elements
682 | that concatenate in the platform's normal endian order to form an N-bit
683 | integer.
684 *----------------------------------------------------------------------------*/
685 void
686  softfloat_shortShiftLeftM(
687      uint_fast8_t size_words,
688      const uint32_t *aPtr,
689      uint_fast8_t dist,
690      uint32_t *zPtr
691  );
692 #endif
693 
694 #ifndef softfloat_shortShiftLeft96M
695 /*----------------------------------------------------------------------------
696 | This function or macro is the same as 'softfloat_shortShiftLeftM' with
697 | 'size_words' = 3 (N = 96).
698 *----------------------------------------------------------------------------*/
699 #define softfloat_shortShiftLeft96M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 3, aPtr, dist, zPtr )
700 #endif
701 
702 #ifndef softfloat_shortShiftLeft128M
703 /*----------------------------------------------------------------------------
704 | This function or macro is the same as 'softfloat_shortShiftLeftM' with
705 | 'size_words' = 4 (N = 128).
706 *----------------------------------------------------------------------------*/
707 #define softfloat_shortShiftLeft128M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 4, aPtr, dist, zPtr )
708 #endif
709 
710 #ifndef softfloat_shortShiftLeft160M
711 /*----------------------------------------------------------------------------
712 | This function or macro is the same as 'softfloat_shortShiftLeftM' with
713 | 'size_words' = 5 (N = 160).
714 *----------------------------------------------------------------------------*/
715 #define softfloat_shortShiftLeft160M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 5, aPtr, dist, zPtr )
716 #endif
717 
718 #ifndef softfloat_shiftLeftM
719 /*----------------------------------------------------------------------------
720 | Shifts the N-bit unsigned integer pointed to by 'aPtr' left by the number
721 | of bits given in 'dist', where N = 'size_words' * 32.  The value of 'dist'
722 | must not be zero.  Any nonzero bits shifted off are lost.  The shifted
723 | N-bit result is stored at the location pointed to by 'zPtr'.  Each of 'aPtr'
724 | and 'zPtr' points to a 'size_words'-long array of 32-bit elements that
725 | concatenate in the platform's normal endian order to form an N-bit integer.
726 |   The value of 'dist' can be arbitrarily large.  In particular, if 'dist' is
727 | greater than N, the stored result will be 0.
728 *----------------------------------------------------------------------------*/
729 void
730  softfloat_shiftLeftM(
731      uint_fast8_t size_words,
732      const uint32_t *aPtr,
733      uint32_t dist,
734      uint32_t *zPtr
735  );
736 #endif
737 
738 #ifndef softfloat_shiftLeft96M
739 /*----------------------------------------------------------------------------
740 | This function or macro is the same as 'softfloat_shiftLeftM' with
741 | 'size_words' = 3 (N = 96).
742 *----------------------------------------------------------------------------*/
743 #define softfloat_shiftLeft96M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 3, aPtr, dist, zPtr )
744 #endif
745 
746 #ifndef softfloat_shiftLeft128M
747 /*----------------------------------------------------------------------------
748 | This function or macro is the same as 'softfloat_shiftLeftM' with
749 | 'size_words' = 4 (N = 128).
750 *----------------------------------------------------------------------------*/
751 #define softfloat_shiftLeft128M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 4, aPtr, dist, zPtr )
752 #endif
753 
754 #ifndef softfloat_shiftLeft160M
755 /*----------------------------------------------------------------------------
756 | This function or macro is the same as 'softfloat_shiftLeftM' with
757 | 'size_words' = 5 (N = 160).
758 *----------------------------------------------------------------------------*/
759 #define softfloat_shiftLeft160M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 5, aPtr, dist, zPtr )
760 #endif
761 
762 #ifndef softfloat_shortShiftRightM
763 /*----------------------------------------------------------------------------
764 | Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
765 | of bits given in 'dist', where N = 'size_words' * 32.  The value of 'dist'
766 | must be in the range 1 to 31.  Any nonzero bits shifted off are lost.  The
767 | shifted N-bit result is stored at the location pointed to by 'zPtr'.  Each
768 | of 'aPtr' and 'zPtr' points to a 'size_words'-long array of 32-bit elements
769 | that concatenate in the platform's normal endian order to form an N-bit
770 | integer.
771 *----------------------------------------------------------------------------*/
772 void
773  softfloat_shortShiftRightM(
774      uint_fast8_t size_words,
775      const uint32_t *aPtr,
776      uint_fast8_t dist,
777      uint32_t *zPtr
778  );
779 #endif
780 
781 #ifndef softfloat_shortShiftRight128M
782 /*----------------------------------------------------------------------------
783 | This function or macro is the same as 'softfloat_shortShiftRightM' with
784 | 'size_words' = 4 (N = 128).
785 *----------------------------------------------------------------------------*/
786 #define softfloat_shortShiftRight128M( aPtr, dist, zPtr ) softfloat_shortShiftRightM( 4, aPtr, dist, zPtr )
787 #endif
788 
789 #ifndef softfloat_shortShiftRight160M
790 /*----------------------------------------------------------------------------
791 | This function or macro is the same as 'softfloat_shortShiftRightM' with
792 | 'size_words' = 5 (N = 160).
793 *----------------------------------------------------------------------------*/
794 #define softfloat_shortShiftRight160M( aPtr, dist, zPtr ) softfloat_shortShiftRightM( 5, aPtr, dist, zPtr )
795 #endif
796 
797 #ifndef softfloat_shortShiftRightJamM
798 /*----------------------------------------------------------------------------
799 | Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
800 | of bits given in 'dist', where N = 'size_words' * 32.  The value of 'dist'
801 | must be in the range 1 to 31.  If any nonzero bits are shifted off, they are
802 | "jammed" into the least-significant bit of the shifted value by setting the
803 | least-significant bit to 1.  This shifted-and-jammed N-bit result is stored
804 | at the location pointed to by 'zPtr'.  Each of 'aPtr' and 'zPtr' points
805 | to a 'size_words'-long array of 32-bit elements that concatenate in the
806 | platform's normal endian order to form an N-bit integer.
807 *----------------------------------------------------------------------------*/
808 void
809  softfloat_shortShiftRightJamM(
810      uint_fast8_t, const uint32_t *, uint_fast8_t, uint32_t * );
811 #endif
812 
813 #ifndef softfloat_shortShiftRightJam160M
814 /*----------------------------------------------------------------------------
815 | This function or macro is the same as 'softfloat_shortShiftRightJamM' with
816 | 'size_words' = 5 (N = 160).
817 *----------------------------------------------------------------------------*/
818 #define softfloat_shortShiftRightJam160M( aPtr, dist, zPtr ) softfloat_shortShiftRightJamM( 5, aPtr, dist, zPtr )
819 #endif
820 
821 #ifndef softfloat_shiftRightM
822 /*----------------------------------------------------------------------------
823 | Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
824 | of bits given in 'dist', where N = 'size_words' * 32.  The value of 'dist'
825 | must not be zero.  Any nonzero bits shifted off are lost.  The shifted
826 | N-bit result is stored at the location pointed to by 'zPtr'.  Each of 'aPtr'
827 | and 'zPtr' points to a 'size_words'-long array of 32-bit elements that
828 | concatenate in the platform's normal endian order to form an N-bit integer.
829 |   The value of 'dist' can be arbitrarily large.  In particular, if 'dist' is
830 | greater than N, the stored result will be 0.
831 *----------------------------------------------------------------------------*/
832 void
833  softfloat_shiftRightM(
834      uint_fast8_t size_words,
835      const uint32_t *aPtr,
836      uint32_t dist,
837      uint32_t *zPtr
838  );
839 #endif
840 
841 #ifndef softfloat_shiftRight96M
842 /*----------------------------------------------------------------------------
843 | This function or macro is the same as 'softfloat_shiftRightM' with
844 | 'size_words' = 3 (N = 96).
845 *----------------------------------------------------------------------------*/
846 #define softfloat_shiftRight96M( aPtr, dist, zPtr ) softfloat_shiftRightM( 3, aPtr, dist, zPtr )
847 #endif
848 
849 #ifndef softfloat_shiftRightJamM
850 /*----------------------------------------------------------------------------
851 | Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
852 | of bits given in 'dist', where N = 'size_words' * 32.  The value of 'dist'
853 | must not be zero.  If any nonzero bits are shifted off, they are "jammed"
854 | into the least-significant bit of the shifted value by setting the least-
855 | significant bit to 1.  This shifted-and-jammed N-bit result is stored
856 | at the location pointed to by 'zPtr'.  Each of 'aPtr' and 'zPtr' points
857 | to a 'size_words'-long array of 32-bit elements that concatenate in the
858 | platform's normal endian order to form an N-bit integer.
859 |   The value of 'dist' can be arbitrarily large.  In particular, if 'dist'
860 | is greater than N, the stored result will be either 0 or 1, depending on
861 | whether the original N bits are all zeros.
862 *----------------------------------------------------------------------------*/
863 void
864  softfloat_shiftRightJamM(
865      uint_fast8_t size_words,
866      const uint32_t *aPtr,
867      uint32_t dist,
868      uint32_t *zPtr
869  );
870 #endif
871 
872 #ifndef softfloat_shiftRightJam96M
873 /*----------------------------------------------------------------------------
874 | This function or macro is the same as 'softfloat_shiftRightJamM' with
875 | 'size_words' = 3 (N = 96).
876 *----------------------------------------------------------------------------*/
877 #define softfloat_shiftRightJam96M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 3, aPtr, dist, zPtr )
878 #endif
879 
880 #ifndef softfloat_shiftRightJam128M
881 /*----------------------------------------------------------------------------
882 | This function or macro is the same as 'softfloat_shiftRightJamM' with
883 | 'size_words' = 4 (N = 128).
884 *----------------------------------------------------------------------------*/
885 #define softfloat_shiftRightJam128M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 4, aPtr, dist, zPtr )
886 #endif
887 
888 #ifndef softfloat_shiftRightJam160M
889 /*----------------------------------------------------------------------------
890 | This function or macro is the same as 'softfloat_shiftRightJamM' with
891 | 'size_words' = 5 (N = 160).
892 *----------------------------------------------------------------------------*/
893 #define softfloat_shiftRightJam160M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 5, aPtr, dist, zPtr )
894 #endif
895 
896 #ifndef softfloat_addM
897 /*----------------------------------------------------------------------------
898 | Adds the two N-bit integers pointed to by 'aPtr' and 'bPtr', where N =
899 | 'size_words' * 32.  The addition is modulo 2^N, so any carry out is lost.
900 | The N-bit sum is stored at the location pointed to by 'zPtr'.  Each of
901 | 'aPtr', 'bPtr', and 'zPtr' points to a 'size_words'-long array of 32-bit
902 | elements that concatenate in the platform's normal endian order to form an
903 | N-bit integer.
904 *----------------------------------------------------------------------------*/
905 void
906  softfloat_addM(
907      uint_fast8_t size_words,
908      const uint32_t *aPtr,
909      const uint32_t *bPtr,
910      uint32_t *zPtr
911  );
912 #endif
913 
914 #ifndef softfloat_add96M
915 /*----------------------------------------------------------------------------
916 | This function or macro is the same as 'softfloat_addM' with 'size_words'
917 | = 3 (N = 96).
918 *----------------------------------------------------------------------------*/
919 #define softfloat_add96M( aPtr, bPtr, zPtr ) softfloat_addM( 3, aPtr, bPtr, zPtr )
920 #endif
921 
922 #ifndef softfloat_add128M
923 /*----------------------------------------------------------------------------
924 | This function or macro is the same as 'softfloat_addM' with 'size_words'
925 | = 4 (N = 128).
926 *----------------------------------------------------------------------------*/
927 #define softfloat_add128M( aPtr, bPtr, zPtr ) softfloat_addM( 4, aPtr, bPtr, zPtr )
928 #endif
929 
930 #ifndef softfloat_add160M
931 /*----------------------------------------------------------------------------
932 | This function or macro is the same as 'softfloat_addM' with 'size_words'
933 | = 5 (N = 160).
934 *----------------------------------------------------------------------------*/
935 #define softfloat_add160M( aPtr, bPtr, zPtr ) softfloat_addM( 5, aPtr, bPtr, zPtr )
936 #endif
937 
938 #ifndef softfloat_addCarryM
939 /*----------------------------------------------------------------------------
940 | Adds the two N-bit unsigned integers pointed to by 'aPtr' and 'bPtr', where
941 | N = 'size_words' * 32, plus 'carry', which must be either 0 or 1.  The N-bit
942 | sum (modulo 2^N) is stored at the location pointed to by 'zPtr', and any
943 | carry out is returned as the result.  Each of 'aPtr', 'bPtr', and 'zPtr'
944 | points to a 'size_words'-long array of 32-bit elements that concatenate in
945 | the platform's normal endian order to form an N-bit integer.
946 *----------------------------------------------------------------------------*/
947 uint_fast8_t
948  softfloat_addCarryM(
949      uint_fast8_t size_words,
950      const uint32_t *aPtr,
951      const uint32_t *bPtr,
952      uint_fast8_t carry,
953      uint32_t *zPtr
954  );
955 #endif
956 
957 #ifndef softfloat_addComplCarryM
958 /*----------------------------------------------------------------------------
959 | This function or macro is the same as 'softfloat_addCarryM', except that
960 | the value of the unsigned integer pointed to by 'bPtr' is bit-wise completed
961 | before the addition.
962 *----------------------------------------------------------------------------*/
963 uint_fast8_t
964  softfloat_addComplCarryM(
965      uint_fast8_t size_words,
966      const uint32_t *aPtr,
967      const uint32_t *bPtr,
968      uint_fast8_t carry,
969      uint32_t *zPtr
970  );
971 #endif
972 
973 #ifndef softfloat_addComplCarry96M
974 /*----------------------------------------------------------------------------
975 | This function or macro is the same as 'softfloat_addComplCarryM' with
976 | 'size_words' = 3 (N = 96).
977 *----------------------------------------------------------------------------*/
978 #define softfloat_addComplCarry96M( aPtr, bPtr, carry, zPtr ) softfloat_addComplCarryM( 3, aPtr, bPtr, carry, zPtr )
979 #endif
980 
981 #ifndef softfloat_negXM
982 /*----------------------------------------------------------------------------
983 | Replaces the N-bit unsigned integer pointed to by 'zPtr' by the
984 | 2s-complement of itself, where N = 'size_words' * 32.  Argument 'zPtr'
985 | points to a 'size_words'-long array of 32-bit elements that concatenate in
986 | the platform's normal endian order to form an N-bit integer.
987 *----------------------------------------------------------------------------*/
988 void softfloat_negXM( uint_fast8_t size_words, uint32_t *zPtr );
989 #endif
990 
991 #ifndef softfloat_negX96M
992 /*----------------------------------------------------------------------------
993 | This function or macro is the same as 'softfloat_negXM' with 'size_words'
994 | = 3 (N = 96).
995 *----------------------------------------------------------------------------*/
996 #define softfloat_negX96M( zPtr ) softfloat_negXM( 3, zPtr )
997 #endif
998 
999 #ifndef softfloat_negX128M
1000 /*----------------------------------------------------------------------------
1001 | This function or macro is the same as 'softfloat_negXM' with 'size_words'
1002 | = 4 (N = 128).
1003 *----------------------------------------------------------------------------*/
1004 #define softfloat_negX128M( zPtr ) softfloat_negXM( 4, zPtr )
1005 #endif
1006 
1007 #ifndef softfloat_negX160M
1008 /*----------------------------------------------------------------------------
1009 | This function or macro is the same as 'softfloat_negXM' with 'size_words'
1010 | = 5 (N = 160).
1011 *----------------------------------------------------------------------------*/
1012 #define softfloat_negX160M( zPtr ) softfloat_negXM( 5, zPtr )
1013 #endif
1014 
1015 #ifndef softfloat_negX256M
1016 /*----------------------------------------------------------------------------
1017 | This function or macro is the same as 'softfloat_negXM' with 'size_words'
1018 | = 8 (N = 256).
1019 *----------------------------------------------------------------------------*/
1020 #define softfloat_negX256M( zPtr ) softfloat_negXM( 8, zPtr )
1021 #endif
1022 
1023 #ifndef softfloat_sub1XM
1024 /*----------------------------------------------------------------------------
1025 | Subtracts 1 from the N-bit integer pointed to by 'zPtr', where N =
1026 | 'size_words' * 32.  The subtraction is modulo 2^N, so any borrow out (carry
1027 | out) is lost.  Argument 'zPtr' points to a 'size_words'-long array of 32-bit
1028 | elements that concatenate in the platform's normal endian order to form an
1029 | N-bit integer.
1030 *----------------------------------------------------------------------------*/
1031 void softfloat_sub1XM( uint_fast8_t size_words, uint32_t *zPtr );
1032 #endif
1033 
1034 #ifndef softfloat_sub1X96M
1035 /*----------------------------------------------------------------------------
1036 | This function or macro is the same as 'softfloat_sub1XM' with 'size_words'
1037 | = 3 (N = 96).
1038 *----------------------------------------------------------------------------*/
1039 #define softfloat_sub1X96M( zPtr ) softfloat_sub1XM( 3, zPtr )
1040 #endif
1041 
1042 #ifndef softfloat_sub1X160M
1043 /*----------------------------------------------------------------------------
1044 | This function or macro is the same as 'softfloat_sub1XM' with 'size_words'
1045 | = 5 (N = 160).
1046 *----------------------------------------------------------------------------*/
1047 #define softfloat_sub1X160M( zPtr ) softfloat_sub1XM( 5, zPtr )
1048 #endif
1049 
1050 #ifndef softfloat_subM
1051 /*----------------------------------------------------------------------------
1052 | Subtracts the two N-bit integers pointed to by 'aPtr' and 'bPtr', where N =
1053 | 'size_words' * 32.  The subtraction is modulo 2^N, so any borrow out (carry
1054 | out) is lost.  The N-bit difference is stored at the location pointed to by
1055 | 'zPtr'.  Each of 'aPtr', 'bPtr', and 'zPtr' points to a 'size_words'-long
1056 | array of 32-bit elements that concatenate in the platform's normal endian
1057 | order to form an N-bit integer.
1058 *----------------------------------------------------------------------------*/
1059 void
1060  softfloat_subM(
1061      uint_fast8_t size_words,
1062      const uint32_t *aPtr,
1063      const uint32_t *bPtr,
1064      uint32_t *zPtr
1065  );
1066 #endif
1067 
1068 #ifndef softfloat_sub96M
1069 /*----------------------------------------------------------------------------
1070 | This function or macro is the same as 'softfloat_subM' with 'size_words'
1071 | = 3 (N = 96).
1072 *----------------------------------------------------------------------------*/
1073 #define softfloat_sub96M( aPtr, bPtr, zPtr ) softfloat_subM( 3, aPtr, bPtr, zPtr )
1074 #endif
1075 
1076 #ifndef softfloat_sub128M
1077 /*----------------------------------------------------------------------------
1078 | This function or macro is the same as 'softfloat_subM' with 'size_words'
1079 | = 4 (N = 128).
1080 *----------------------------------------------------------------------------*/
1081 #define softfloat_sub128M( aPtr, bPtr, zPtr ) softfloat_subM( 4, aPtr, bPtr, zPtr )
1082 #endif
1083 
1084 #ifndef softfloat_sub160M
1085 /*----------------------------------------------------------------------------
1086 | This function or macro is the same as 'softfloat_subM' with 'size_words'
1087 | = 5 (N = 160).
1088 *----------------------------------------------------------------------------*/
1089 #define softfloat_sub160M( aPtr, bPtr, zPtr ) softfloat_subM( 5, aPtr, bPtr, zPtr )
1090 #endif
1091 
1092 #ifndef softfloat_mul64To128M
1093 /*----------------------------------------------------------------------------
1094 | Multiplies 'a' and 'b' and stores the 128-bit product at the location
1095 | pointed to by 'zPtr'.  Argument 'zPtr' points to an array of four 32-bit
1096 | elements that concatenate in the platform's normal endian order to form a
1097 | 128-bit integer.
1098 *----------------------------------------------------------------------------*/
1099 void softfloat_mul64To128M( uint64_t a, uint64_t b, uint32_t *zPtr );
1100 #endif
1101 
1102 #ifndef softfloat_mul128MTo256M
1103 /*----------------------------------------------------------------------------
1104 | Multiplies the two 128-bit unsigned integers pointed to by 'aPtr' and
1105 | 'bPtr', and stores the 256-bit product at the location pointed to by 'zPtr'.
1106 | Each of 'aPtr' and 'bPtr' points to an array of four 32-bit elements that
1107 | concatenate in the platform's normal endian order to form a 128-bit integer.
1108 | Argument 'zPtr' points to an array of eight 32-bit elements that concatenate
1109 | to form a 256-bit integer.
1110 *----------------------------------------------------------------------------*/
1111 void
1112  softfloat_mul128MTo256M(
1113      const uint32_t *aPtr, const uint32_t *bPtr, uint32_t *zPtr );
1114 #endif
1115 
1116 #ifndef softfloat_remStepMBy32
1117 /*----------------------------------------------------------------------------
1118 | Performs a "remainder reduction step" as follows:  Arguments 'remPtr' and
1119 | 'bPtr' both point to N-bit unsigned integers, where N = 'size_words' * 32.
1120 | Defining R and B as the values of those integers, the expression (R<<'dist')
1121 | - B * q is computed modulo 2^N, and the N-bit result is stored at the
1122 | location pointed to by 'zPtr'.  Each of 'remPtr', 'bPtr', and 'zPtr' points
1123 | to a 'size_words'-long array of 32-bit elements that concatenate in the
1124 | platform's normal endian order to form an N-bit integer.
1125 *----------------------------------------------------------------------------*/
1126 void
1127  softfloat_remStepMBy32(
1128      uint_fast8_t size_words,
1129      const uint32_t *remPtr,
1130      uint_fast8_t dist,
1131      const uint32_t *bPtr,
1132      uint32_t q,
1133      uint32_t *zPtr
1134  );
1135 #endif
1136 
1137 #ifndef softfloat_remStep96MBy32
1138 /*----------------------------------------------------------------------------
1139 | This function or macro is the same as 'softfloat_remStepMBy32' with
1140 | 'size_words' = 3 (N = 96).
1141 *----------------------------------------------------------------------------*/
1142 #define softfloat_remStep96MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 3, remPtr, dist, bPtr, q, zPtr )
1143 #endif
1144 
1145 #ifndef softfloat_remStep128MBy32
1146 /*----------------------------------------------------------------------------
1147 | This function or macro is the same as 'softfloat_remStepMBy32' with
1148 | 'size_words' = 4 (N = 128).
1149 *----------------------------------------------------------------------------*/
1150 #define softfloat_remStep128MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 4, remPtr, dist, bPtr, q, zPtr )
1151 #endif
1152 
1153 #ifndef softfloat_remStep160MBy32
1154 /*----------------------------------------------------------------------------
1155 | This function or macro is the same as 'softfloat_remStepMBy32' with
1156 | 'size_words' = 5 (N = 160).
1157 *----------------------------------------------------------------------------*/
1158 #define softfloat_remStep160MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 5, remPtr, dist, bPtr, q, zPtr )
1159 #endif
1160 
1161 #endif
1162 
1163 #ifdef __cplusplus
1164 }
1165 #endif
1166 
1167 #endif
1168 
1169