/*- * Copyright (c) 1992 The Regents of the University of California. * All rights reserved. * * This software was developed by the Computer Systems Engineering group * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and * contributed to Berkeley. * * %sccs.include.redist.c% */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)moddi3.c 5.5 (Berkeley) 06/25/92"; #endif /* LIBC_SCCS and not lint */ #include "quad.h" /* * Return remainder after dividing two signed quads. * * XXX * If -1/2 should produce -1 on this machine, this code is wrong. */ quad_t __moddi3(a, b) quad_t a, b; { u_quad_t ua, ub, ur; int neg; if (a < 0) ua = -(u_quad_t)a, neg = 1; else ua = a, neg = 0; if (b < 0) ub = -(u_quad_t)b, neg ^= 1; else ub = b; (void)__qdivrem(ua, ub, &ur); return (neg ? -ur : ur); }