153435Sbostic /*- 253435Sbostic * Copyright (c) 1992 The Regents of the University of California. 353435Sbostic * All rights reserved. 453435Sbostic * 553794Sbostic * This software was developed by the Computer Systems Engineering group 653794Sbostic * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 753794Sbostic * contributed to Berkeley. 853794Sbostic * 953435Sbostic * %sccs.include.redist.c% 1053435Sbostic */ 1153435Sbostic 1253435Sbostic #if defined(LIBC_SCCS) && !defined(lint) 13*54431Sbostic static char sccsid[] = "@(#)divdi3.c 5.4 (Berkeley) 06/25/92"; 1453435Sbostic #endif /* LIBC_SCCS and not lint */ 1553435Sbostic 1653794Sbostic #include "quad.h" 1753459Sbostic 1853794Sbostic /* 1953794Sbostic * Divide two signed quads. 2053794Sbostic * ??? if -1/2 should produce -1 on this machine, this code is wrong 2153794Sbostic */ 22*54431Sbostic quad_t 23*54431Sbostic __divdi3(a, b) 24*54431Sbostic quad_t a, b; 2553794Sbostic { 26*54431Sbostic u_quad_t ua, ub, uq; 2753794Sbostic int neg; 2853459Sbostic 2953794Sbostic if (a < 0) 30*54431Sbostic ua = -(u_quad_t)a, neg = 1; 3153794Sbostic else 3253794Sbostic ua = a, neg = 0; 3353794Sbostic if (b < 0) 34*54431Sbostic ub = -(u_quad_t)b, neg ^= 1; 3553794Sbostic else 3653794Sbostic ub = b; 37*54431Sbostic uq = __qdivrem(ua, ub, (u_quad_t *)0); 3853794Sbostic return (neg ? -uq : uq); 3953435Sbostic } 40