1 /*- 2 * Copyright (c) 1992 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #if defined(LIBC_SCCS) && !defined(lint) 9 static char sccsid[] = "@(#)negdi2.c 5.2 (Berkeley) 05/12/92"; 10 #endif /* LIBC_SCCS and not lint */ 11 12 #include "longlong.h" 13 14 static int bneg (); 15 16 long long 17 __negdi2 (u) 18 long long u; 19 { 20 unsigned long a[2], b[2]; 21 long_long w; 22 long_long uu; 23 24 uu.ll = u; 25 26 a[HIGH] = uu.s.high; 27 a[LOW] = uu.s.low; 28 29 bneg (a, b, sizeof b); 30 31 w.s.high = b[HIGH]; 32 w.s.low = b[LOW]; 33 return w.ll; 34 } 35 36 static int 37 bneg (a, b, n) 38 unsigned short *a, *b; 39 unsigned long n; 40 { 41 signed long acc; 42 int i; 43 44 n /= sizeof (short); 45 46 acc = 0; 47 for (i = little_end (n); is_not_msd (i, n); i = next_msd (i)) 48 { 49 acc -= a[i]; 50 b[i] = acc & low16; 51 acc = acc >> 16; 52 } 53 return acc; 54 } 55