#include <fpu_control.h>
#define _FP_W_TYPE_SIZE 64
-#define _FP_W_TYPE unsigned long long
+#define _FP_W_TYPE unsigned long
#define _FP_WS_TYPE signed long long
-#define _FP_I_TYPE long long
+#define _FP_I_TYPE long
#define _FP_MUL_MEAT_S(R,X,Y) \
_FP_MUL_MEAT_1_imm(_FP_WFRACBITS_S,R,X,Y)
udiv_qrnnd_generic (&__q, &__r, __n1, __n0, __d)
-#endif /* __GMP_ARHC_H */
+/* add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1,
+ high_addend_2, low_addend_2) adds two UWtype integers, composed by
+ HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and LOW_ADDEND_2
+ respectively. The result is placed in HIGH_SUM and LOW_SUM. Overflow
+ (i.e. carry out) is not stored anywhere, and is lost. */
+static __always_inline void
+add_ssaaaa_generic (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah,
+ mp_limb_t al, mp_limb_t bh, mp_limb_t bl)
+{
+ *sl = al + bl;
+ *sh = (ah + bh) + (*sl < al);
+}
+#undef add_ssaaaa
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ add_ssaaaa_generic (&sh, &sl, ah, al, bh, bl)
+
+/* sub_ddmmss(high_difference, low_difference, high_minuend, low_minuend,
+ high_subtrahend, low_subtrahend) subtracts two two-word UWtype integers,
+ composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and
+ LOW_SUBTRAHEND_2 respectively. The result is placed in HIGH_DIFFERENCE
+ and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere,
+ and is lost. */
+static __always_inline void
+sub_ddmmss_generic (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah,
+ mp_limb_t al, mp_limb_t bh, mp_limb_t bl)
+{
+ *sl = al - bl;
+ *sh = (ah - bh) - (*sl > al);
+}
+#undef sub_ddmmss
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ sub_ddmmss_generic (&sh, &sl, ah, al, bh, bl)
+
+#endif
#include <fpu_control.h>
#define _FP_W_TYPE_SIZE 64
-#define _FP_W_TYPE unsigned long long
-#define _FP_WS_TYPE signed long long
-#define _FP_I_TYPE long long
+#define _FP_W_TYPE unsigned long
+#define _FP_WS_TYPE signed long
+#define _FP_I_TYPE long
#define _FP_MUL_MEAT_S(R, X, Y) _FP_MUL_MEAT_1_imm (_FP_WFRACBITS_S, R, X, Y)
#define _FP_MUL_MEAT_D(R, X, Y) \
#define _FP_W_TYPE_SIZE 64
-#define _FP_W_TYPE unsigned long long
-#define _FP_WS_TYPE signed long long
-#define _FP_I_TYPE long long
+#define _FP_W_TYPE unsigned long
+#define _FP_WS_TYPE signed long
+#define _FP_I_TYPE long
typedef int TItype __attribute__ ((mode (TI)));
typedef unsigned int UTItype __attribute__ ((mode (TI)));
#else
# define _FP_W_TYPE_SIZE 64
-# define _FP_W_TYPE unsigned long long
-# define _FP_WS_TYPE signed long long
-# define _FP_I_TYPE long long
+# define _FP_W_TYPE unsigned long
+# define _FP_WS_TYPE signed long
+# define _FP_I_TYPE long
# define _FP_MUL_MEAT_S(R, X, Y) \
_FP_MUL_MEAT_1_imm (_FP_WFRACBITS_S, R, X, Y)
#ifdef __x86_64__
# define _FP_W_TYPE_SIZE 64
-# define _FP_W_TYPE unsigned long long
-# define _FP_WS_TYPE signed long long
-# define _FP_I_TYPE long long
+# ifndef __ILP32__
+# define _FP_W_TYPE unsigned long
+# define _FP_WS_TYPE signed long
+# define _FP_I_TYPE long
+# else
+# define _FP_W_TYPE unsigned long long
+# define _FP_WS_TYPE signed long long
+# define _FP_I_TYPE long long
+# endif
typedef int TItype __attribute__ ((mode (TI)));
typedef unsigned int UTItype __attribute__ ((mode (TI)));
} while (0)
#else
# define _FP_W_TYPE_SIZE 32
-# define _FP_W_TYPE unsigned int
-# define _FP_WS_TYPE signed int
-# define _FP_I_TYPE int
+# define _FP_W_TYPE unsigned long int
+# define _FP_WS_TYPE signed long int
+# define _FP_I_TYPE long int
# define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0) \
__asm__ ("add{l} {%11,%3|%3,%11}\n\t" \
#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \
udiv_qrnnd_x86 (&__q, &__r, __n1, __n0, __d)
+static __always_inline void
+add_ssaaaa_x86 (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah,
+ mp_limb_t al, mp_limb_t bh, mp_limb_t bl)
+{
+#ifdef __x86_64__
+ asm ("add{q} {%5,%1|%1,%5}\n\tadc{q} {%3,%0|%0,%3}"
+ : "=r" (*sh),
+ "=&r" (*sl)
+ : "%0" (ah),
+ "rme" (bh),
+ "%1" (al),
+ "rme" (bl));
+#else
+ asm ("add{l} {%5,%1|%1,%5}\n\tadc{l} {%3,%0|%0,%3}"
+ : "=r" (*sh),
+ "=&r" (*sl)
+ : "%0" (ah),
+ "g" (bh),
+ "%1" (al),
+ "g" (bl));
+#endif
+}
+#undef add_ssaaaa
+#define add_ssaaaa(__sh, __sl, __ah, __al, __bh, __bl) \
+ add_ssaaaa_x86 (&__sh, &__sl, __ah, __al, __bh, __bl)
+
+static __always_inline void
+sub_ddmmss_x86 (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah,
+ mp_limb_t al, mp_limb_t bh, mp_limb_t bl)
+{
+#ifdef __x86_64__
+ asm ("sub{q} {%5,%1|%1,%5}\n\tsbb{q} {%3,%0|%0,%3}"
+ : "=r" (*sh),
+ "=&r" (*sl)
+ : "0" (ah),
+ "rme" (bh),
+ "1" (al),
+ "rme" (bl));
+#else
+ asm ("sub{l} {%5,%1|%1,%5}\n\tsbb{l} {%3,%0|%0,%3}"
+ : "=r" (*sh),
+ "=&r" (*sl)
+ : "0" (ah),
+ "g" (bh),
+ "1" (al),
+ "g" (bl));
+#endif
+}
+#undef sub_ddmmss
+#define sub_ddmmss(__sh, __sl, __ah, __al, __bh, __bl) \
+ sub_ddmmss_x86 (&__sh, &__sl, __ah, __al, __bh, __bl)
+
#endif