diff options
author | Wolfgang Denk <wd@pollux.denx.de> | 2006-10-24 15:17:18 +0200 |
---|---|---|
committer | Wolfgang Denk <wd@pollux.denx.de> | 2006-10-24 15:17:18 +0200 |
commit | 9748d5a9e8aa8bf6dd576e70894b9996c22f7003 (patch) | |
tree | bfbdfb6f1ef9d24389e19a3b47ecdc7a883af455 /include/asm-avr32/div64.h | |
parent | 8318fbf8cc30418b621ea9f39b84b4c1a08f003a (diff) | |
parent | 3a78e3e75b633ecb6413114ffd11e2f000c4f11e (diff) | |
download | u-boot-imx-9748d5a9e8aa8bf6dd576e70894b9996c22f7003.zip u-boot-imx-9748d5a9e8aa8bf6dd576e70894b9996c22f7003.tar.gz u-boot-imx-9748d5a9e8aa8bf6dd576e70894b9996c22f7003.tar.bz2 |
Merge with /home/wd/git/u-boot/mailing-list/Haavard_Skinnemoen
Diffstat (limited to 'include/asm-avr32/div64.h')
-rw-r--r-- | include/asm-avr32/div64.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/include/asm-avr32/div64.h b/include/asm-avr32/div64.h new file mode 100644 index 0000000..2e0ba83 --- /dev/null +++ b/include/asm-avr32/div64.h @@ -0,0 +1,39 @@ +#ifndef _ASM_GENERIC_DIV64_H +#define _ASM_GENERIC_DIV64_H +/* + * Copyright (C) 2003 Bernardo Innocenti <bernie@develer.com> + * Based on former asm-ppc/div64.h and asm-m68knommu/div64.h + * + * The semantics of do_div() are: + * + * uint32_t do_div(uint64_t *n, uint32_t base) + * { + * uint32_t remainder = *n % base; + * *n = *n / base; + * return remainder; + * } + * + * NOTE: macro parameter n is evaluated multiple times, + * beware of side effects! + */ + +#include <linux/types.h> + +extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor); + +/* The unnecessary pointer compare is there + * to check for type safety (n must be 64bit) + */ +# define do_div(n,base) ({ \ + uint32_t __base = (base); \ + uint32_t __rem; \ + (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \ + if (((n) >> 32) == 0) { \ + __rem = (uint32_t)(n) % __base; \ + (n) = (uint32_t)(n) / __base; \ + } else \ + __rem = __div64_32(&(n), __base); \ + __rem; \ + }) + +#endif /* _ASM_GENERIC_DIV64_H */ |