OpenCores
URL https://opencores.org/ocsvn/openarty/openarty/trunk

Subversion Repositories openarty

[/] [openarty/] [trunk/] [sw/] [zlib/] [umod.c] - Blame information for rev 54

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 54 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    umod.c
4
//
5
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
6
//
7
// Purpose:     This is a temporary file--a crutch if you will--until a similar
8
//              capability is merged into GCC.  Right now, GCC has no way of
9
//      taking the module of two 64-bit numbers, and this routine provides that
10
//      capability.
11
//
12
//      This routine is required by and used by newlib's printf in order to
13
//      print decimal numbers (%d) to an IO stream.
14
//
15
//      Once gcc is properly patched, this will be removed from the 
16
//      repository.
17
//
18
// Creator:     Dan Gisselquist, Ph.D.
19
//              Gisselquist Technology, LLC
20
//
21
////////////////////////////////////////////////////////////////////////////////
22
//
23
// Copyright (C) 2017, Gisselquist Technology, LLC
24
//
25
// This program is free software (firmware): you can redistribute it and/or
26
// modify it under the terms of  the GNU General Public License as published
27
// by the Free Software Foundation, either version 3 of the License, or (at
28
// your option) any later version.
29
//
30
// This program is distributed in the hope that it will be useful, but WITHOUT
31
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
32
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
33
// for more details.
34
//
35
// You should have received a copy of the GNU General Public License along
36
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
37
// target there if the PDF file isn't present.)  If not, see
38
// <http://www.gnu.org/licenses/> for a copy.
39
//
40
// License:     GPL, v3, as defined and found on www.gnu.org,
41
//              http://www.gnu.org/licenses/gpl.html
42
//
43
//
44
////////////////////////////////////////////////////////////////////////////////
45
//
46
//
47
#include <stdint.h>
48
 
49
 
50
unsigned long __udivdi3(unsigned long, unsigned long);
51
 
52
__attribute((noinline))
53
unsigned long __umoddi3(unsigned long a, unsigned long b) {
54
        unsigned long   r;
55
 
56
        // Return a modulo b, or a%b in C syntax
57
        r = __udivdi3(a, b);
58
        r = r * b;
59
        r = a - r;
60
        return r;
61
}
62
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.