From b3e9d9b24e7daee2133a67ea067103ad6a4e18e7 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Sat, 9 Mar 2002 03:54:52 +0000 Subject: [PATCH] added asm/div64.h compatibility header so comedi can use 64 bit integer division macro --- include/asm/div64.h | 63 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 include/asm/div64.h diff --git a/include/asm/div64.h b/include/asm/div64.h new file mode 100644 index 00000000..778f61ed --- /dev/null +++ b/include/asm/div64.h @@ -0,0 +1,63 @@ +/*************************************************************************** + asm/div64.h + ------------------- + + + copyright : (C) 2002 by Frank Mori Hess + email : fmhess@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef _DIV64_COMPAT_H +#define _DIV64_COMPAT_H + +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0) + +extern inline u64 my_ull_div(u64 numerator, unsigned long denominator) +{ + u32 value; + u64 remainder, temp, answer = 0; + unsigned int shift; + static const u32 max_u32 = 0xffffffff; + + remainder = numerator; + + while(remainder >= denominator) + { + shift = 0; + numerator = remainder; + // shift most significant bits into 32 bit variable + while(numerator > max_u32) + { + numerator >>= 1; + shift++; + } + value = numerator; + value /= denominator; + temp = ((u64) value) << shift; + answer += temp; + remainder -= temp * denominator; + } + + return answer; +} + +#define do_div(n, base) ((n) = my_ull_div(n, base)) + +#else + +#include_next + +#endif + +#endif // _DIV64_COMPAT_H -- 2.26.2