Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[NET]: div64_64 consolidate (rev3)

Here is the current version of the 64 bit divide common code.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Stephen Hemminger and committed by
David S. Miller
3927f2e8 9d729f72

+60 -63
+3
include/asm-arm/div64.h
··· 2 2 #define __ASM_ARM_DIV64 3 3 4 4 #include <asm/system.h> 5 + #include <linux/types.h> 5 6 6 7 /* 7 8 * The semantics of do_div() are: ··· 223 222 }) 224 223 225 224 #endif 225 + 226 + extern uint64_t div64_64(uint64_t dividend, uint64_t divisor); 226 227 227 228 #endif
+7
include/asm-generic/div64.h
··· 30 30 __rem; \ 31 31 }) 32 32 33 + static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor) 34 + { 35 + return dividend / divisor; 36 + } 37 + 33 38 #elif BITS_PER_LONG == 32 34 39 35 40 extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor); ··· 53 48 __rem = __div64_32(&(n), __base); \ 54 49 __rem; \ 55 50 }) 51 + 52 + extern uint64_t div64_64(uint64_t dividend, uint64_t divisor); 56 53 57 54 #else /* BITS_PER_LONG == ?? */ 58 55
+4
include/asm-i386/div64.h
··· 1 1 #ifndef __I386_DIV64 2 2 #define __I386_DIV64 3 3 4 + #include <linux/types.h> 5 + 4 6 /* 5 7 * do_div() is NOT a C function. It wants to return 6 8 * two values (the quotient and the remainder), but ··· 47 45 return dum2; 48 46 49 47 } 48 + 49 + extern uint64_t div64_64(uint64_t dividend, uint64_t divisor); 50 50 #endif
+3
include/asm-m68k/div64.h
··· 1 1 #ifndef _M68K_DIV64_H 2 2 #define _M68K_DIV64_H 3 3 4 + #include <linux/types.h> 5 + 4 6 /* n = n / base; return rem; */ 5 7 6 8 #define do_div(n, base) ({ \ ··· 25 23 __rem; \ 26 24 }) 27 25 26 + extern uint64_t div64_64(uint64_t dividend, uint64_t divisor); 28 27 #endif /* _M68K_DIV64_H */
+10 -1
include/asm-mips/div64.h
··· 1 1 /* 2 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 5 * This file is subject to the terms and conditions of the GNU General Public 6 6 * License. See the file "COPYING" in the main directory of this archive ··· 8 8 */ 9 9 #ifndef _ASM_DIV64_H 10 10 #define _ASM_DIV64_H 11 + 12 + #include <linux/types.h> 11 13 12 14 #if (_MIPS_SZLONG == 32) 13 15 ··· 80 78 __quot = __quot << 32 | __low; \ 81 79 (n) = __quot; \ 82 80 __mod; }) 81 + 82 + extern uint64_t div64_64(uint64_t dividend, uint64_t divisor); 83 83 #endif /* (_MIPS_SZLONG == 32) */ 84 84 85 85 #if (_MIPS_SZLONG == 64) ··· 104 100 \ 105 101 (n) = __quot; \ 106 102 __mod; }) 103 + 104 + static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor) 105 + { 106 + return dividend / divisor; 107 + } 107 108 108 109 #endif /* (_MIPS_SZLONG == 64) */ 109 110
+1
include/asm-um/div64.h
··· 3 3 4 4 #include "asm/arch/div64.h" 5 5 6 + extern uint64_t div64_64(uint64_t dividend, uint64_t divisor); 6 7 #endif
+6
include/asm-xtensa/div64.h
··· 11 11 #ifndef _XTENSA_DIV64_H 12 12 #define _XTENSA_DIV64_H 13 13 14 + #include <linux/types.h> 15 + 14 16 #define do_div(n,base) ({ \ 15 17 int __res = n % ((unsigned int) base); \ 16 18 n /= (unsigned int) base; \ 17 19 __res; }) 18 20 21 + static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor) 22 + { 23 + return dividend / divisor; 24 + } 19 25 #endif
+3 -2
lib/Makefile
··· 4 4 5 5 lib-y := ctype.o string.o vsprintf.o cmdline.o \ 6 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 8 sha1.o irq_regs.o reciprocal_div.o 9 9 10 10 lib-$(CONFIG_MMU) += ioremap.o ··· 12 12 13 13 lib-y += kobject.o kref.o kobject_uevent.o klist.o 14 14 15 - obj-y += sort.o parser.o halfmd4.o debug_locks.o random32.o bust_spinlocks.o 15 + obj-y += div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ 16 + bust_spinlocks.o 16 17 17 18 ifeq ($(CONFIG_DEBUG_KOBJECT),y) 18 19 CFLAGS_kobject.o += -DDEBUG
+22
lib/div64.c
··· 58 58 59 59 EXPORT_SYMBOL(__div64_32); 60 60 61 + /* 64bit divisor, dividend and result. dynamic precision */ 62 + uint64_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 + } 81 + EXPORT_SYMBOL(div64_64); 82 + 61 83 #endif /* BITS_PER_LONG == 32 */
-23
net/ipv4/tcp_cubic.c
··· 51 51 module_param(tcp_friendliness, int, 0644); 52 52 MODULE_PARM_DESC(tcp_friendliness, "turn on/off tcp friendliness"); 53 53 54 - #include <asm/div64.h> 55 - 56 54 /* BIC TCP Parameters */ 57 55 struct bictcp { 58 56 u32 cnt; /* increase cwnd by 1 after ACKs */ ··· 89 91 bictcp_reset(inet_csk_ca(sk)); 90 92 if (initial_ssthresh) 91 93 tcp_sk(sk)->snd_ssthresh = initial_ssthresh; 92 - } 93 - 94 - /* 64bit divisor, dividend and result. dynamic precision */ 95 - static inline u_int64_t div64_64(u_int64_t dividend, u_int64_t divisor) 96 - { 97 - u_int32_t d = divisor; 98 - 99 - if (divisor > 0xffffffffULL) { 100 - unsigned int shift = fls(divisor >> 32); 101 - 102 - d = divisor >> shift; 103 - dividend >>= shift; 104 - } 105 - 106 - /* avoid 64 bit division if possible */ 107 - if (dividend >> 32) 108 - do_div(dividend, d); 109 - else 110 - dividend = (uint32_t) dividend / d; 111 - 112 - return dividend; 113 94 } 114 95 115 96 /*
-21
net/ipv4/tcp_yeah.c
··· 73 73 yeah->pkts_acked = pkts_acked; 74 74 } 75 75 76 - /* 64bit divisor, dividend and result. dynamic precision */ 77 - static 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 - 97 76 static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, 98 77 u32 seq_rtt, u32 in_flight, int flag) 99 78 {
+1
net/ipv4/tcp_yeah.h
··· 2 2 #include <linux/module.h> 3 3 #include <linux/skbuff.h> 4 4 #include <linux/inet_diag.h> 5 + #include <asm/div64.h> 5 6 6 7 #include <net/tcp.h> 7 8
-16
net/netfilter/xt_connbytes.c
··· 24 24 MODULE_DESCRIPTION("iptables match for matching number of pkts/bytes per connection"); 25 25 MODULE_ALIAS("ipt_connbytes"); 26 26 27 - /* 64bit divisor, dividend and result. dynamic precision */ 28 - static 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 - 43 27 static int 44 28 match(const struct sk_buff *skb, 45 29 const struct net_device *in,