cmpdi2.c revision 1573
117359Swosch/*-
217359Swosch * Copyright (c) 1992, 1993
317359Swosch *	The Regents of the University of California.  All rights reserved.
417359Swosch *
517359Swosch * This software was developed by the Computer Systems Engineering group
632822Syokota * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
717359Swosch * contributed to Berkeley.
817359Swosch *
917359Swosch * Redistribution and use in source and binary forms, with or without
1017359Swosch * modification, are permitted provided that the following conditions
1117359Swosch * are met:
1217359Swosch * 1. Redistributions of source code must retain the above copyright
1317359Swosch *    notice, this list of conditions and the following disclaimer.
1417359Swosch * 2. Redistributions in binary form must reproduce the above copyright
1517359Swosch *    notice, this list of conditions and the following disclaimer in the
1617359Swosch *    documentation and/or other materials provided with the distribution.
1717359Swosch * 3. All advertising materials mentioning features or use of this software
1817359Swosch *    must display the following acknowledgement:
1917359Swosch *	This product includes software developed by the University of
2017359Swosch *	California, Berkeley and its contributors.
2117359Swosch * 4. Neither the name of the University nor the names of its contributors
2217359Swosch *    may be used to endorse or promote products derived from this software
2317359Swosch *    without specific prior written permission.
2417359Swosch *
2517359Swosch * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2617359Swosch * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2717359Swosch * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2817359Swosch * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2917359Swosch * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3017359Swosch * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3117359Swosch * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3217359Swosch * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3317359Swosch * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3417359Swosch * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3517359Swosch * SUCH DAMAGE.
3617359Swosch */
3717359Swosch
3817359Swosch#if defined(LIBC_SCCS) && !defined(lint)
3917359Swoschstatic char sccsid[] = "@(#)cmpdi2.c	8.1 (Berkeley) 6/4/93";
4017359Swosch#endif /* LIBC_SCCS and not lint */
4117359Swosch
4217359Swosch#include "quad.h"
4317359Swosch
4417359Swosch/*
4517359Swosch * Return 0, 1, or 2 as a <, =, > b respectively.
4617359Swosch * Both a and b are considered signed---which means only the high word is
4717359Swosch * signed.
4817359Swosch */
4917359Swoschint
5017359Swosch__cmpdi2(a, b)
5117359Swosch	quad_t a, b;
5217359Swosch{
5317359Swosch	union uu aa, bb;
5417359Swosch
5517359Swosch	aa.q = a;
5617359Swosch	bb.q = b;
5717359Swosch	return (aa.sl[H] < bb.sl[H] ? 0 : aa.sl[H] > bb.sl[H] ? 2 :
5817359Swosch	    aa.ul[L] < bb.ul[L] ? 0 : aa.ul[L] > bb.ul[L] ? 2 : 1);
5917359Swosch}
6017359Swosch