Home | History | Annotate | Line # | Download | only in spmath
      1 /*	$NetBSD: quad_float.h,v 1.3 2022/05/28 22:08:47 andvar Exp $	*/
      2 
      3 /*	$OpenBSD: quad_float.h,v 1.5 2001/03/29 03:58:19 mickey Exp $	*/
      4 
      5 /*
      6  * Copyright 1996 1995 by Open Software Foundation, Inc.
      7  *              All Rights Reserved
      8  *
      9  * Permission to use, copy, modify, and distribute this software and
     10  * its documentation for any purpose and without fee is hereby granted,
     11  * provided that the above copyright notice appears in all copies and
     12  * that both the copyright notice and this permission notice appear in
     13  * supporting documentation.
     14  *
     15  * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
     16  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     17  * FOR A PARTICULAR PURPOSE.
     18  *
     19  * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
     20  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
     21  * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
     22  * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
     23  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     24  *
     25  */
     26 /*
     27  * pmk1.1
     28  */
     29 /*
     30  * (c) Copyright 1986 HEWLETT-PACKARD COMPANY
     31  *
     32  * To anyone who acknowledges that this file is provided "AS IS"
     33  * without any express or implied warranty:
     34  *     permission to use, copy, modify, and distribute this file
     35  * for any purpose is hereby granted without fee, provided that
     36  * the above copyright notice and this notice appears in all
     37  * copies, and that the name of Hewlett-Packard Company not be
     38  * used in advertising or publicity pertaining to distribution
     39  * of the software without specific, written prior permission.
     40  * Hewlett-Packard Company makes no representations about the
     41  * suitability of this software for any purpose.
     42  */
     43 
     44 /******************************
     45  *  Quad precision functions  *
     46  ******************************/
     47 
     48 /* 32-bit word grabbing functions */
     49 #define Quad_firstword(value) Qallp1(value)
     50 #define Quad_secondword(value) Qallp2(value)
     51 #define Quad_thirdword(value)  Qallp3(value)
     52 #define Quad_fourthword(value)  Qallp4(value)
     53 
     54 
     55 /* This magnitude comparison uses the signless first words and
     56  * the regular part2 words.  The comparison is graphically:
     57  *
     58  *       1st greater?  ----------->|
     59  *                                 |
     60  *       1st less?-----------------+------->|
     61  *                                 |        |
     62  *       2nd greater?------------->|        |
     63  *                                 |        |
     64  *       2nd less?-----------------+------->|
     65  *                                 |        |
     66  *       3rd greater?------------->|        |
     67  *                                 |        |
     68  *       3rd less?-----------------+------->|
     69  *                                 |        |
     70  *       4th greater or equal?---->|        |
     71  *                                 |        |
     72  *                               False     True
     73  */
     74 #define Quad_ismagnitudeless(leftp3,leftp4,rightp1,rightp2,rightp3,rightp4,signlessleft,signlessright) \
     75 /*  Quad_floating_point left, right;          *				\
     76  *  unsigned int signlessleft, signlessright; */			\
     77       ( signlessleft<=signlessright &&					\
     78        (signlessleft<signlessright || (Qallp2(leftp2)<=Qallp2(rightp2) && \
     79 	(Qallp2(leftp2)<Qallp2(rightp2) || (Qallp3(leftp3)<=Qallp3(rightp3) && \
     80 	 (Qallp3(leftp3)<Qallp3(rightp3) || Qallp4(leftp4)<Qallp4(rightp4)))))))
     81 
     82 #define Quad_xor_to_intp1(leftp1,rightp1,result)		\
     83     /* quad_floating_point left, right;				\
     84      * unsigned int result; */					\
     85     result = Qallp1(leftp1) XOR Qallp1(rightp1);
     86 
     87 #define Quad_xor_from_intp1(leftp1,rightp1,result)		\
     88     /* quad_floating_point right, result;			\
     89      * unsigned int left; */					\
     90     Qallp1(resultp1) = left XOR Qallp1(rightp1)
     91 
     92 #define Quad_swap_lower(leftp1,leftp2,leftp3,leftp4,rightp1,rightp2,rightp3,rightp4)  \
     93     /* quad_floating_point left, right; */			\
     94     Qallp2(leftp2)  = Qallp2(leftp2) XOR Qallp2(rightp2)	\
     95     Qallp2(rightp2) = Qallp2(leftp2) XOR Qallp2(rightp2)	\
     96     Qallp2(leftp2)  = Qallp2(leftp2) XOR Qallp2(rightp2)	\
     97     Qallp3(leftp3)  = Qallp3(leftp3) XOR Qallp3(rightp3)	\
     98     Qallp3(rightp3) = Qallp3(leftp3) XOR Qallp3(rightp3)	\
     99     Qallp3(leftp3)  = Qallp3(leftp3) XOR Qallp3(rightp3)	\
    100     Qallp4(leftp4)  = Qallp4(leftp4) XOR Qallp4(rightp4)	\
    101     Qallp4(rightp4) = Qallp4(leftp4) XOR Qallp4(rightp4)	\
    102     Qallp4(leftp4)  = Qallp4(leftp4) XOR Qallp4(rightp4)
    103 
    104 int quad_frnd(quad_floating_point *, quad_floating_point *, unsigned int *);
    105