386BSD 0.1 development
authorWilliam F. Jolitz <wjolitz@soda.berkeley.edu>
Tue, 22 Jan 1991 06:57:20 +0000 (22:57 -0800)
committerWilliam F. Jolitz <wjolitz@soda.berkeley.edu>
Tue, 22 Jan 1991 06:57:20 +0000 (22:57 -0800)
Work on file usr/src/usr.bin/gcc/gnulib/longlong/negdi2.c

Co-Authored-By: Lynne Greer Jolitz <ljolitz@cardio.ucsf.edu>
Synthesized-from: 386BSD-0.1

usr/src/usr.bin/gcc/gnulib/longlong/negdi2.c [new file with mode: 0644]

diff --git a/usr/src/usr.bin/gcc/gnulib/longlong/negdi2.c b/usr/src/usr.bin/gcc/gnulib/longlong/negdi2.c
new file mode 100644 (file)
index 0000000..068392a
--- /dev/null
@@ -0,0 +1,43 @@
+#include "longlong.h"
+
+static int bneg ();
+
+long long 
+__negdi2 (u)
+     long long u;
+{
+  unsigned long a[2], b[2];
+  long_long w;
+  long_long uu;
+
+  uu.ll = u;
+
+  a[HIGH] = uu.s.high;
+  a[LOW] = uu.s.low;
+
+  bneg (a, b, sizeof b);
+
+  w.s.high = b[HIGH];
+  w.s.low = b[LOW];
+  return w.ll;
+}
+
+static int
+bneg (a, b, n)
+     unsigned short *a, *b;
+     size_t n;
+{
+  signed long acc;
+  int i;
+
+  n /= sizeof (short);
+
+  acc = 0;
+  for (i = little_end (n); is_not_msd (i, n); i = next_msd (i))
+    {
+      acc -= a[i];
+      b[i] = acc & low16;
+      acc = acc >> 16;
+    }
+  return acc;
+}