aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/asm-arm/div64.h3
-rw-r--r--include/asm-generic/div64.h7
-rw-r--r--include/asm-i386/div64.h4
-rw-r--r--include/asm-m68k/div64.h3
-rw-r--r--include/asm-mips/div64.h11
-rw-r--r--include/asm-um/div64.h1
-rw-r--r--include/asm-xtensa/div64.h6
-rw-r--r--lib/Makefile5
-rw-r--r--lib/div64.c22
-rw-r--r--net/ipv4/tcp_cubic.c23
-rw-r--r--net/ipv4/tcp_yeah.c21
-rw-r--r--net/ipv4/tcp_yeah.h1
-rw-r--r--net/netfilter/xt_connbytes.c16
13 files changed, 60 insertions, 63 deletions
diff --git a/include/asm-arm/div64.h b/include/asm-arm/div64.h
index 37e0a96e8789..0b5f881c3d85 100644
--- a/include/asm-arm/div64.h
+++ b/include/asm-arm/div64.h
@@ -2,6 +2,7 @@
2#define __ASM_ARM_DIV64 2#define __ASM_ARM_DIV64
3 3
4#include <asm/system.h> 4#include <asm/system.h>
5#include <linux/types.h>
5 6
6/* 7/*
7 * The semantics of do_div() are: 8 * The semantics of do_div() are:
@@ -223,4 +224,6 @@
223 224
224#endif 225#endif
225 226
227extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
228
226#endif 229#endif
diff --git a/include/asm-generic/div64.h b/include/asm-generic/div64.h
index 8f4e3193342e..a4a49370793c 100644
--- a/include/asm-generic/div64.h
+++ b/include/asm-generic/div64.h
@@ -30,6 +30,11 @@
30 __rem; \ 30 __rem; \
31 }) 31 })
32 32
33static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor)
34{
35 return dividend / divisor;
36}
37
33#elif BITS_PER_LONG == 32 38#elif BITS_PER_LONG == 32
34 39
35extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor); 40extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
@@ -49,6 +54,8 @@ extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
49 __rem; \ 54 __rem; \
50 }) 55 })
51 56
57extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
58
52#else /* BITS_PER_LONG == ?? */ 59#else /* BITS_PER_LONG == ?? */
53 60
54# error do_div() does not yet support the C64 61# error do_div() does not yet support the C64
diff --git a/include/asm-i386/div64.h b/include/asm-i386/div64.h
index 75c67c785bb8..438e980068bd 100644
--- a/include/asm-i386/div64.h
+++ b/include/asm-i386/div64.h
@@ -1,6 +1,8 @@
1#ifndef __I386_DIV64 1#ifndef __I386_DIV64
2#define __I386_DIV64 2#define __I386_DIV64
3 3
4#include <linux/types.h>
5
4/* 6/*
5 * do_div() is NOT a C function. It wants to return 7 * do_div() is NOT a C function. It wants to return
6 * two values (the quotient and the remainder), but 8 * two values (the quotient and the remainder), but
@@ -45,4 +47,6 @@ div_ll_X_l_rem(long long divs, long div, long *rem)
45 return dum2; 47 return dum2;
46 48
47} 49}
50
51extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
48#endif 52#endif
diff --git a/include/asm-m68k/div64.h b/include/asm-m68k/div64.h
index 9f65de1a2480..33caad1628d4 100644
--- a/include/asm-m68k/div64.h
+++ b/include/asm-m68k/div64.h
@@ -1,6 +1,8 @@
1#ifndef _M68K_DIV64_H 1#ifndef _M68K_DIV64_H
2#define _M68K_DIV64_H 2#define _M68K_DIV64_H
3 3
4#include <linux/types.h>
5
4/* n = n / base; return rem; */ 6/* n = n / base; return rem; */
5 7
6#define do_div(n, base) ({ \ 8#define do_div(n, base) ({ \
@@ -23,4 +25,5 @@
23 __rem; \ 25 __rem; \
24}) 26})
25 27
28extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
26#endif /* _M68K_DIV64_H */ 29#endif /* _M68K_DIV64_H */
diff --git a/include/asm-mips/div64.h b/include/asm-mips/div64.h
index d107832de1b6..66189f5f6399 100644
--- a/include/asm-mips/div64.h
+++ b/include/asm-mips/div64.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 2000, 2004 Maciej W. Rozycki 2 * Copyright (C) 2000, 2004 Maciej W. Rozycki
3 * Copyright (C) 2003 Ralf Baechle 3 * Copyright (C) 2003, 07 Ralf Baechle (ralf@linux-mips.org)
4 * 4 *
5 * This file is subject to the terms and conditions of the GNU General Public 5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive 6 * License. See the file "COPYING" in the main directory of this archive
@@ -9,6 +9,8 @@
9#ifndef _ASM_DIV64_H 9#ifndef _ASM_DIV64_H
10#define _ASM_DIV64_H 10#define _ASM_DIV64_H
11 11
12#include <linux/types.h>
13
12#if (_MIPS_SZLONG == 32) 14#if (_MIPS_SZLONG == 32)
13 15
14#include <asm/compiler.h> 16#include <asm/compiler.h>
@@ -78,6 +80,8 @@
78 __quot = __quot << 32 | __low; \ 80 __quot = __quot << 32 | __low; \
79 (n) = __quot; \ 81 (n) = __quot; \
80 __mod; }) 82 __mod; })
83
84extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
81#endif /* (_MIPS_SZLONG == 32) */ 85#endif /* (_MIPS_SZLONG == 32) */
82 86
83#if (_MIPS_SZLONG == 64) 87#if (_MIPS_SZLONG == 64)
@@ -101,6 +105,11 @@
101 (n) = __quot; \ 105 (n) = __quot; \
102 __mod; }) 106 __mod; })
103 107
108static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor)
109{
110 return dividend / divisor;
111}
112
104#endif /* (_MIPS_SZLONG == 64) */ 113#endif /* (_MIPS_SZLONG == 64) */
105 114
106#endif /* _ASM_DIV64_H */ 115#endif /* _ASM_DIV64_H */
diff --git a/include/asm-um/div64.h b/include/asm-um/div64.h
index 1e17f7409cab..7b73b2cd5b34 100644
--- a/include/asm-um/div64.h
+++ b/include/asm-um/div64.h
@@ -3,4 +3,5 @@
3 3
4#include "asm/arch/div64.h" 4#include "asm/arch/div64.h"
5 5
6extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
6#endif 7#endif
diff --git a/include/asm-xtensa/div64.h b/include/asm-xtensa/div64.h
index c4a105776383..20965e3af1dd 100644
--- a/include/asm-xtensa/div64.h
+++ b/include/asm-xtensa/div64.h
@@ -11,9 +11,15 @@
11#ifndef _XTENSA_DIV64_H 11#ifndef _XTENSA_DIV64_H
12#define _XTENSA_DIV64_H 12#define _XTENSA_DIV64_H
13 13
14#include <linux/types.h>
15
14#define do_div(n,base) ({ \ 16#define do_div(n,base) ({ \
15 int __res = n % ((unsigned int) base); \ 17 int __res = n % ((unsigned int) base); \
16 n /= (unsigned int) base; \ 18 n /= (unsigned int) base; \
17 __res; }) 19 __res; })
18 20
21static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor)
22{
23 return dividend / divisor;
24}
19#endif 25#endif
diff --git a/lib/Makefile b/lib/Makefile
index 992a39ef9ffd..ae57f357fec0 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -4,7 +4,7 @@
4 4
5lib-y := ctype.o string.o vsprintf.o cmdline.o \ 5lib-y := ctype.o string.o vsprintf.o cmdline.o \
6 rbtree.o radix-tree.o dump_stack.o \ 6 rbtree.o radix-tree.o dump_stack.o \
7 idr.o div64.o int_sqrt.o bitmap.o extable.o prio_tree.o \ 7 idr.o int_sqrt.o bitmap.o extable.o prio_tree.o \
8 sha1.o irq_regs.o reciprocal_div.o 8 sha1.o irq_regs.o reciprocal_div.o
9 9
10lib-$(CONFIG_MMU) += ioremap.o 10lib-$(CONFIG_MMU) += ioremap.o
@@ -12,7 +12,8 @@ lib-$(CONFIG_SMP) += cpumask.o
12 12
13lib-y += kobject.o kref.o kobject_uevent.o klist.o 13lib-y += kobject.o kref.o kobject_uevent.o klist.o
14 14
15obj-y += sort.o parser.o halfmd4.o debug_locks.o random32.o bust_spinlocks.o 15obj-y += div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
16 bust_spinlocks.o
16 17
17ifeq ($(CONFIG_DEBUG_KOBJECT),y) 18ifeq ($(CONFIG_DEBUG_KOBJECT),y)
18CFLAGS_kobject.o += -DDEBUG 19CFLAGS_kobject.o += -DDEBUG
diff --git a/lib/div64.c b/lib/div64.c
index 365719f84832..c3d7655cdfb5 100644
--- a/lib/div64.c
+++ b/lib/div64.c
@@ -58,4 +58,26 @@ uint32_t __div64_32(uint64_t *n, uint32_t base)
58 58
59EXPORT_SYMBOL(__div64_32); 59EXPORT_SYMBOL(__div64_32);
60 60
61/* 64bit divisor, dividend and result. dynamic precision */
62uint64_t div64_64(uint64_t dividend, uint64_t divisor)
63{
64 uint32_t d = divisor;
65
66 if (divisor > 0xffffffffULL) {
67 unsigned int shift = fls(divisor >> 32);
68
69 d = divisor >> shift;
70 dividend >>= shift;
71 }
72
73 /* avoid 64 bit division if possible */
74 if (dividend >> 32)
75 do_div(dividend, d);
76 else
77 dividend = (uint32_t) dividend / d;
78
79 return dividend;
80}
81EXPORT_SYMBOL(div64_64);
82
61#endif /* BITS_PER_LONG == 32 */ 83#endif /* BITS_PER_LONG == 32 */
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
index 9a582fb4ef9f..6f08adbda54e 100644
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -51,8 +51,6 @@ MODULE_PARM_DESC(bic_scale, "scale (scaled by 1024) value for bic function (bic_
51module_param(tcp_friendliness, int, 0644); 51module_param(tcp_friendliness, int, 0644);
52MODULE_PARM_DESC(tcp_friendliness, "turn on/off tcp friendliness"); 52MODULE_PARM_DESC(tcp_friendliness, "turn on/off tcp friendliness");
53 53
54#include <asm/div64.h>
55
56/* BIC TCP Parameters */ 54/* BIC TCP Parameters */
57struct bictcp { 55struct bictcp {
58 u32 cnt; /* increase cwnd by 1 after ACKs */ 56 u32 cnt; /* increase cwnd by 1 after ACKs */
@@ -93,27 +91,6 @@ static void bictcp_init(struct sock *sk)
93 tcp_sk(sk)->snd_ssthresh = initial_ssthresh; 91 tcp_sk(sk)->snd_ssthresh = initial_ssthresh;
94} 92}
95 93
96/* 64bit divisor, dividend and result. dynamic precision */
97static inline u_int64_t div64_64(u_int64_t dividend, u_int64_t divisor)
98{
99 u_int32_t d = divisor;
100
101 if (divisor > 0xffffffffULL) {
102 unsigned int shift = fls(divisor >> 32);
103
104 d = divisor >> shift;
105 dividend >>= shift;
106 }
107
108 /* avoid 64 bit division if possible */
109 if (dividend >> 32)
110 do_div(dividend, d);
111 else
112 dividend = (uint32_t) dividend / d;
113
114 return dividend;
115}
116
117/* 94/*
118 * calculate the cubic root of x using Newton-Raphson 95 * calculate the cubic root of x using Newton-Raphson
119 */ 96 */
diff --git a/net/ipv4/tcp_yeah.c b/net/ipv4/tcp_yeah.c
index 815e020e98fe..18355a2608e1 100644
--- a/net/ipv4/tcp_yeah.c
+++ b/net/ipv4/tcp_yeah.c
@@ -73,27 +73,6 @@ static void tcp_yeah_pkts_acked(struct sock *sk, u32 pkts_acked)
73 yeah->pkts_acked = pkts_acked; 73 yeah->pkts_acked = pkts_acked;
74} 74}
75 75
76/* 64bit divisor, dividend and result. dynamic precision */
77static inline u64 div64_64(u64 dividend, u64 divisor)
78{
79 u32 d = divisor;
80
81 if (divisor > 0xffffffffULL) {
82 unsigned int shift = fls(divisor >> 32);
83
84 d = divisor >> shift;
85 dividend >>= shift;
86 }
87
88 /* avoid 64 bit division if possible */
89 if (dividend >> 32)
90 do_div(dividend, d);
91 else
92 dividend = (u32) dividend / d;
93
94 return dividend;
95}
96
97static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, 76static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack,
98 u32 seq_rtt, u32 in_flight, int flag) 77 u32 seq_rtt, u32 in_flight, int flag)
99{ 78{
diff --git a/net/ipv4/tcp_yeah.h b/net/ipv4/tcp_yeah.h
index b3255dba4e2d..a62d82038fd0 100644
--- a/net/ipv4/tcp_yeah.h
+++ b/net/ipv4/tcp_yeah.h
@@ -2,6 +2,7 @@
2#include <linux/module.h> 2#include <linux/module.h>
3#include <linux/skbuff.h> 3#include <linux/skbuff.h>
4#include <linux/inet_diag.h> 4#include <linux/inet_diag.h>
5#include <asm/div64.h>
5 6
6#include <net/tcp.h> 7#include <net/tcp.h>
7 8
diff --git a/net/netfilter/xt_connbytes.c b/net/netfilter/xt_connbytes.c
index 5e32dfa2668b..302043bc41b2 100644
--- a/net/netfilter/xt_connbytes.c
+++ b/net/netfilter/xt_connbytes.c
@@ -24,22 +24,6 @@ MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
24MODULE_DESCRIPTION("iptables match for matching number of pkts/bytes per connection"); 24MODULE_DESCRIPTION("iptables match for matching number of pkts/bytes per connection");
25MODULE_ALIAS("ipt_connbytes"); 25MODULE_ALIAS("ipt_connbytes");
26 26
27/* 64bit divisor, dividend and result. dynamic precision */
28static u_int64_t div64_64(u_int64_t dividend, u_int64_t divisor)
29{
30 u_int32_t d = divisor;
31
32 if (divisor > 0xffffffffULL) {
33 unsigned int shift = fls(divisor >> 32);
34
35 d = divisor >> shift;
36 dividend >>= shift;
37 }
38
39 do_div(dividend, d);
40 return dividend;
41}
42
43static int 27static int
44match(const struct sk_buff *skb, 28match(const struct sk_buff *skb,
45 const struct net_device *in, 29 const struct net_device *in,