xref: /csrg-svn/lib/libc/quad/cmpdi2.c (revision 61157)
153434Sbostic /*-
2*61157Sbostic  * Copyright (c) 1992, 1993
3*61157Sbostic  *	The Regents of the University of California.  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*61157Sbostic static char sccsid[] = "@(#)cmpdi2.c	8.1 (Berkeley) 06/04/93";
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
__cmpdi2(a,b)2454431Sbostic __cmpdi2(a, b)
2554431Sbostic 	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