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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-m68k/] [div64.h] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1276 phoenix
#ifndef _M68K_DIV64_H
2
#define _M68K_DIV64_H
3
 
4
/* n = n / base; return rem; */
5
 
6
#if 1
7
#define do_div(n, base) ({                                      \
8
        union {                                                 \
9
                unsigned long n32[2];                           \
10
                unsigned long long n64;                         \
11
        } __n;                                                  \
12
        unsigned long __rem, __upper;                           \
13
                                                                \
14
        __n.n64 = (n);                                          \
15
        if ((__upper = __n.n32[0])) {                            \
16
                asm ("divul.l %2,%1:%0"                         \
17
                        : "=d" (__n.n32[0]), "=d" (__upper)      \
18
                        : "d" (base), "0" (__n.n32[0]));  \
19
        }                                                       \
20
        asm ("divu.l %2,%1:%0"                                  \
21
                : "=d" (__n.n32[1]), "=d" (__rem)               \
22
                : "d" (base), "1" (__upper), "0" (__n.n32[1]));  \
23
        (n) = __n.n64;                                          \
24
        __rem;                                                  \
25
})
26
#else
27
#define do_div(n,base) ({                                       \
28
        int __res;                                              \
29
        __res = ((unsigned long) n) % (unsigned) base;          \
30
        n = ((unsigned long) n) / (unsigned) base;              \
31
        __res;                                                  \
32
})
33
#endif
34
 
35
#endif /* _M68K_DIV64_H */

powered by: WebSVN 2.1.0

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