divdi3.c (348238dbd42306d9fb5d89ab393b840572cfeb0f) divdi3.c (4a8dea8cf97aab33f4e6a11afcc64dd9562f3bfd)
1/*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This software was developed by the Computer Systems Engineering group
6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7 * contributed to Berkeley.
8 *

--- 27 unchanged lines hidden (view full) ---

36
37#include <libkern/quad.h>
38
39/*
40 * Divide two signed quads.
41 * ??? if -1/2 should produce -1 on this machine, this code is wrong
42 */
43quad_t
1/*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This software was developed by the Computer Systems Engineering group
6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7 * contributed to Berkeley.
8 *

--- 27 unchanged lines hidden (view full) ---

36
37#include <libkern/quad.h>
38
39/*
40 * Divide two signed quads.
41 * ??? if -1/2 should produce -1 on this machine, this code is wrong
42 */
43quad_t
44__divdi3(a, b)
45 quad_t a, b;
44__divdi3(quad_t a, quad_t b)
46{
47 u_quad_t ua, ub, uq;
48 int neg;
49
50 if (a < 0)
51 ua = -(u_quad_t)a, neg = 1;
52 else
53 ua = a, neg = 0;
54 if (b < 0)
55 ub = -(u_quad_t)b, neg ^= 1;
56 else
57 ub = b;
58 uq = __qdivrem(ua, ub, (u_quad_t *)0);
59 return (neg ? -uq : uq);
60}
45{
46 u_quad_t ua, ub, uq;
47 int neg;
48
49 if (a < 0)
50 ua = -(u_quad_t)a, neg = 1;
51 else
52 ua = a, neg = 0;
53 if (b < 0)
54 ub = -(u_quad_t)b, neg ^= 1;
55 else
56 ub = b;
57 uq = __qdivrem(ua, ub, (u_quad_t *)0);
58 return (neg ? -uq : uq);
59}