153443Sbostic /*- 253443Sbostic * Copyright (c) 1992 The Regents of the University of California. 353443Sbostic * All rights reserved. 453443Sbostic * 553443Sbostic * %sccs.include.redist.c% 653443Sbostic */ 753443Sbostic 853443Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*53459Sbostic static char sccsid[] = "@(#)negdi2.c 5.3 (Berkeley) 05/12/92"; 1053443Sbostic #endif /* LIBC_SCCS and not lint */ 1153443Sbostic 12*53459Sbostic /* Copyright (C) 1989, 1992 Free Software Foundation, Inc. 13*53459Sbostic 14*53459Sbostic This file is part of GNU CC. 15*53459Sbostic 16*53459Sbostic GNU CC is free software; you can redistribute it and/or modify 17*53459Sbostic it under the terms of the GNU General Public License as published by 18*53459Sbostic the Free Software Foundation; either version 2, or (at your option) 19*53459Sbostic any later version. 20*53459Sbostic 21*53459Sbostic GNU CC is distributed in the hope that it will be useful, 22*53459Sbostic but WITHOUT ANY WARRANTY; without even the implied warranty of 23*53459Sbostic MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24*53459Sbostic GNU General Public License for more details. 25*53459Sbostic 26*53459Sbostic You should have received a copy of the GNU General Public License 27*53459Sbostic along with GNU CC; see the file COPYING. If not, write to 28*53459Sbostic the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 29*53459Sbostic 30*53459Sbostic /* As a special exception, if you link this library with files 31*53459Sbostic compiled with GCC to produce an executable, this does not cause 32*53459Sbostic the resulting executable to be covered by the GNU General Public License. 33*53459Sbostic This exception does not however invalidate any other reasons why 34*53459Sbostic the executable file might be covered by the GNU General Public License. */ 35*53459Sbostic 3653443Sbostic #include "longlong.h" 3753443Sbostic 3853443Sbostic static int bneg (); 3953443Sbostic 4053443Sbostic long long 4153443Sbostic __negdi2 (u) 4253443Sbostic long long u; 4353443Sbostic { 4453443Sbostic unsigned long a[2], b[2]; 4553443Sbostic long_long w; 4653443Sbostic long_long uu; 4753443Sbostic 4853443Sbostic uu.ll = u; 4953443Sbostic 5053443Sbostic a[HIGH] = uu.s.high; 5153443Sbostic a[LOW] = uu.s.low; 5253443Sbostic 5353443Sbostic bneg (a, b, sizeof b); 5453443Sbostic 5553443Sbostic w.s.high = b[HIGH]; 5653443Sbostic w.s.low = b[LOW]; 5753443Sbostic return w.ll; 5853443Sbostic } 5953443Sbostic 6053443Sbostic static int 6153443Sbostic bneg (a, b, n) 6253443Sbostic unsigned short *a, *b; 6353458Sbostic unsigned long n; 6453443Sbostic { 6553443Sbostic signed long acc; 6653443Sbostic int i; 6753443Sbostic 6853443Sbostic n /= sizeof (short); 6953443Sbostic 7053443Sbostic acc = 0; 7153443Sbostic for (i = little_end (n); is_not_msd (i, n); i = next_msd (i)) 7253443Sbostic { 7353443Sbostic acc -= a[i]; 7453443Sbostic b[i] = acc & low16; 7553443Sbostic acc = acc >> 16; 7653443Sbostic } 7753443Sbostic return acc; 7853443Sbostic } 79