1f7355c36SMarcel Moolenaar /*- 2f7355c36SMarcel Moolenaar * Copyright (c) 1992, 1993 3f7355c36SMarcel Moolenaar * The Regents of the University of California. All rights reserved. 4f7355c36SMarcel Moolenaar * 5f7355c36SMarcel Moolenaar * This software was developed by the Computer Systems Engineering group 6f7355c36SMarcel Moolenaar * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7f7355c36SMarcel Moolenaar * contributed to Berkeley. 8f7355c36SMarcel Moolenaar * 9f7355c36SMarcel Moolenaar * Redistribution and use in source and binary forms, with or without 10f7355c36SMarcel Moolenaar * modification, are permitted provided that the following conditions 11f7355c36SMarcel Moolenaar * are met: 12f7355c36SMarcel Moolenaar * 1. Redistributions of source code must retain the above copyright 13f7355c36SMarcel Moolenaar * notice, this list of conditions and the following disclaimer. 14f7355c36SMarcel Moolenaar * 2. Redistributions in binary form must reproduce the above copyright 15f7355c36SMarcel Moolenaar * notice, this list of conditions and the following disclaimer in the 16f7355c36SMarcel Moolenaar * documentation and/or other materials provided with the distribution. 17*fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors 18f7355c36SMarcel Moolenaar * may be used to endorse or promote products derived from this software 19f7355c36SMarcel Moolenaar * without specific prior written permission. 20f7355c36SMarcel Moolenaar * 21f7355c36SMarcel Moolenaar * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22f7355c36SMarcel Moolenaar * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23f7355c36SMarcel Moolenaar * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24f7355c36SMarcel Moolenaar * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25f7355c36SMarcel Moolenaar * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26f7355c36SMarcel Moolenaar * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27f7355c36SMarcel Moolenaar * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28f7355c36SMarcel Moolenaar * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29f7355c36SMarcel Moolenaar * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30f7355c36SMarcel Moolenaar * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31f7355c36SMarcel Moolenaar * SUCH DAMAGE. 32f7355c36SMarcel Moolenaar */ 33f7355c36SMarcel Moolenaar 34f7355c36SMarcel Moolenaar #include <sys/cdefs.h> 35f7355c36SMarcel Moolenaar __FBSDID("$FreeBSD$"); 36f7355c36SMarcel Moolenaar 37f7355c36SMarcel Moolenaar #include <libkern/quad.h> 38f7355c36SMarcel Moolenaar 39f7355c36SMarcel Moolenaar /* 40f7355c36SMarcel Moolenaar * Return 0, 1, or 2 as a <, =, > b respectively. 41f7355c36SMarcel Moolenaar * Both a and b are considered signed---which means only the high word is 42f7355c36SMarcel Moolenaar * signed. 43f7355c36SMarcel Moolenaar */ 44f7355c36SMarcel Moolenaar int 45f7355c36SMarcel Moolenaar __cmpdi2(a, b) 46f7355c36SMarcel Moolenaar quad_t a, b; 47f7355c36SMarcel Moolenaar { 48f7355c36SMarcel Moolenaar union uu aa, bb; 49f7355c36SMarcel Moolenaar 50f7355c36SMarcel Moolenaar aa.q = a; 51f7355c36SMarcel Moolenaar bb.q = b; 52f7355c36SMarcel Moolenaar return (aa.sl[H] < bb.sl[H] ? 0 : aa.sl[H] > bb.sl[H] ? 2 : 53f7355c36SMarcel Moolenaar aa.ul[L] < bb.ul[L] ? 0 : aa.ul[L] > bb.ul[L] ? 2 : 1); 54f7355c36SMarcel Moolenaar } 55