negdi2.c revision 165903
1218Sconklin/*-
2218Sconklin * Copyright (c) 1992, 1993
3218Sconklin *	The Regents of the University of California.  All rights reserved.
4218Sconklin *
5218Sconklin * This software was developed by the Computer Systems Engineering group
6218Sconklin * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7218Sconklin * contributed to Berkeley.
8218Sconklin *
9218Sconklin * Redistribution and use in source and binary forms, with or without
10218Sconklin * modification, are permitted provided that the following conditions
11218Sconklin * are met:
12218Sconklin * 1. Redistributions of source code must retain the above copyright
13218Sconklin *    notice, this list of conditions and the following disclaimer.
14218Sconklin * 2. Redistributions in binary form must reproduce the above copyright
15218Sconklin *    notice, this list of conditions and the following disclaimer in the
16218Sconklin *    documentation and/or other materials provided with the distribution.
17218Sconklin * 4. Neither the name of the University nor the names of its contributors
18218Sconklin *    may be used to endorse or promote products derived from this software
19218Sconklin *    without specific prior written permission.
20218Sconklin *
21218Sconklin * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22218Sconklin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23218Sconklin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24218Sconklin * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25218Sconklin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26218Sconklin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27218Sconklin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28218Sconklin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29218Sconklin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30218Sconklin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31218Sconklin * SUCH DAMAGE.
32218Sconklin */
33218Sconklin
34218Sconklin#if defined(LIBC_SCCS) && !defined(lint)
35218Sconklinstatic char sccsid[] = "@(#)negdi2.c	8.1 (Berkeley) 6/4/93";
36218Sconklin#endif /* LIBC_SCCS and not lint */
37218Sconklin#include <sys/cdefs.h>
38218Sconklin__FBSDID("$FreeBSD: head/lib/libc/quad/negdi2.c 165903 2007-01-09 00:28:16Z imp $");
39218Sconklin
40218Sconklin#include "quad.h"
41218Sconklin
42218Sconklin/*
43218Sconklin * Return -a (or, equivalently, 0 - a), in quad.  See subdi3.c.
44218Sconklin */
45218Sconklinquad_t
46218Sconklin__negdi2(a)
47218Sconklin	quad_t a;
48218Sconklin{
49218Sconklin	union uu aa, res;
50218Sconklin
51218Sconklin	aa.q = a;
52218Sconklin	res.ul[L] = -aa.ul[L];
53218Sconklin	res.ul[H] = -aa.ul[H] - (res.ul[L] > 0);
54218Sconklin	return (res.q);
55218Sconklin}
56218Sconklin