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