negdi2.c revision 1.1
11.1Schristos/* $NetBSD: negdi2.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */ 21.1Schristos 31.1Schristos/*- 41.1Schristos * Copyright (c) 1992, 1993 51.1Schristos * The Regents of the University of California. All rights reserved. 61.1Schristos * 71.1Schristos * This software was developed by the Computer Systems Engineering group 81.1Schristos * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 91.1Schristos * contributed to Berkeley. 101.1Schristos * 111.1Schristos * Redistribution and use in source and binary forms, with or without 121.1Schristos * modification, are permitted provided that the following conditions 131.1Schristos * are met: 141.1Schristos * 1. Redistributions of source code must retain the above copyright 151.1Schristos * notice, this list of conditions and the following disclaimer. 161.1Schristos * 2. Redistributions in binary form must reproduce the above copyright 171.1Schristos * notice, this list of conditions and the following disclaimer in the 181.1Schristos * documentation and/or other materials provided with the distribution. 191.1Schristos * 3. Neither the name of the University nor the names of its contributors 201.1Schristos * may be used to endorse or promote products derived from this software 211.1Schristos * without specific prior written permission. 221.1Schristos * 231.1Schristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 241.1Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 251.1Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 261.1Schristos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 271.1Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 281.1Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 291.1Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 301.1Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 311.1Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 321.1Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 331.1Schristos * SUCH DAMAGE. 341.1Schristos */ 351.1Schristos 361.1Schristos#include <sys/cdefs.h> 371.1Schristos#if defined(LIBC_SCCS) && !defined(lint) 381.1Schristos#if 0 391.1Schristosstatic char sccsid[] = "@(#)negdi2.c 8.1 (Berkeley) 6/4/93"; 401.1Schristos#else 411.1Schristos__RCSID("$NetBSD: negdi2.c,v 1.1 2005/12/20 19:28:51 christos Exp $"); 421.1Schristos#endif 431.1Schristos#endif /* LIBC_SCCS and not lint */ 441.1Schristos 451.1Schristos#include "quad.h" 461.1Schristos 471.1Schristos/* 481.1Schristos * Return -a (or, equivalently, 0 - a), in quad. See subdi3.c. 491.1Schristos */ 501.1Schristosquad_t 511.1Schristos__negdi2(a) 521.1Schristos quad_t a; 531.1Schristos{ 541.1Schristos union uu aa, res; 551.1Schristos 561.1Schristos aa.q = a; 571.1Schristos res.ul[L] = -aa.ul[L]; 581.1Schristos res.ul[H] = -aa.ul[H] - (res.ul[L] > 0); 591.1Schristos return (res.q); 601.1Schristos} 61