xref: /csrg-svn/lib/libc/quad/cmpdi2.c (revision 54431)
153434Sbostic /*-
253434Sbostic  * Copyright (c) 1992 The Regents of the University of California.
353434Sbostic  * All rights reserved.
453434Sbostic  *
553794Sbostic  * This software was developed by the Computer Systems Engineering group
653794Sbostic  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
753794Sbostic  * contributed to Berkeley.
853794Sbostic  *
953434Sbostic  * %sccs.include.redist.c%
1053434Sbostic  */
1153434Sbostic 
1253434Sbostic #if defined(LIBC_SCCS) && !defined(lint)
13*54431Sbostic static char sccsid[] = "@(#)cmpdi2.c	5.5 (Berkeley) 06/25/92";
1453434Sbostic #endif /* LIBC_SCCS and not lint */
1553434Sbostic 
1653794Sbostic #include "quad.h"
1753459Sbostic 
1853794Sbostic /*
1953794Sbostic  * Return 0, 1, or 2 as a <, =, > b respectively.
2053794Sbostic  * Both a and b are considered signed---which means only the high word is
2153794Sbostic  * signed.
2253794Sbostic  */
2353794Sbostic int
24*54431Sbostic __cmpdi2(a, b)
25*54431Sbostic 	quad_t a, b;
2653434Sbostic {
2753794Sbostic 	union uu aa, bb;
2853434Sbostic 
2953794Sbostic 	aa.q = a;
3053794Sbostic 	bb.q = b;
3153794Sbostic 	return (aa.sl[H] < bb.sl[H] ? 0 : aa.sl[H] > bb.sl[H] ? 2 :
3253794Sbostic 	    aa.ul[L] < bb.ul[L] ? 0 : aa.ul[L] > bb.ul[L] ? 2 : 1);
3353434Sbostic }
34