xref: /openbmc/linux/arch/alpha/math-emu/sfp-util.h (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds #include <linux/kernel.h>
31da177e4SLinus Torvalds #include <linux/sched.h>
41da177e4SLinus Torvalds #include <linux/types.h>
51da177e4SLinus Torvalds #include <asm/byteorder.h>
61da177e4SLinus Torvalds #include <asm/fpu.h>
71da177e4SLinus Torvalds 
81da177e4SLinus Torvalds #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
91da177e4SLinus Torvalds   ((sl) = (al) + (bl), (sh) = (ah) + (bh) + ((sl) < (al)))
101da177e4SLinus Torvalds 
111da177e4SLinus Torvalds #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
121da177e4SLinus Torvalds   ((sl) = (al) - (bl), (sh) = (ah) - (bh) - ((al) < (bl)))
131da177e4SLinus Torvalds 
141da177e4SLinus Torvalds #define umul_ppmm(wh, wl, u, v)			\
151da177e4SLinus Torvalds   __asm__ ("mulq %2,%3,%1; umulh %2,%3,%0"	\
161da177e4SLinus Torvalds 	   : "=r" ((UDItype)(wh)),		\
171da177e4SLinus Torvalds 	     "=&r" ((UDItype)(wl))		\
181da177e4SLinus Torvalds 	   : "r" ((UDItype)(u)),		\
191da177e4SLinus Torvalds 	     "r" ((UDItype)(v)))
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds #define udiv_qrnnd(q, r, n1, n0, d)				\
221da177e4SLinus Torvalds   do { unsigned long __r;					\
231da177e4SLinus Torvalds     (q) = __udiv_qrnnd (&__r, (n1), (n0), (d));			\
241da177e4SLinus Torvalds     (r) = __r;							\
251da177e4SLinus Torvalds   } while (0)
261da177e4SLinus Torvalds extern unsigned long __udiv_qrnnd (unsigned long *, unsigned long,
271da177e4SLinus Torvalds 				   unsigned long , unsigned long);
281da177e4SLinus Torvalds 
291da177e4SLinus Torvalds #define UDIV_NEEDS_NORMALIZATION 1
301da177e4SLinus Torvalds 
311da177e4SLinus Torvalds #define abort()			goto bad_insn
3213da9e20SLinus Torvalds 
3313da9e20SLinus Torvalds #ifndef __LITTLE_ENDIAN
3413da9e20SLinus Torvalds #define __LITTLE_ENDIAN -1
3513da9e20SLinus Torvalds #endif
3613da9e20SLinus Torvalds #define __BYTE_ORDER __LITTLE_ENDIAN
37