ia64/linux-2.6.18-xen.hg

annotate lib/div64.c @ 871:9cbcc9008446

xen/x86: don't initialize cpu_data[]'s apicid field on generic code

Afaict, this is not only redundant with the intialization done in
drivers/xen/core/smpboot.c, but actually results - at least for
secondary CPUs - in the Xen-specific value written to be later
overwritten with whatever the generic code determines (with no
guarantee that the two values are identical).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 14 10:09:15 2009 +0100 (2009-05-14)
parents 831230e53067
children
rev   line source
ian@0 1 /*
ian@0 2 * Copyright (C) 2003 Bernardo Innocenti <bernie@develer.com>
ian@0 3 *
ian@0 4 * Based on former do_div() implementation from asm-parisc/div64.h:
ian@0 5 * Copyright (C) 1999 Hewlett-Packard Co
ian@0 6 * Copyright (C) 1999 David Mosberger-Tang <davidm@hpl.hp.com>
ian@0 7 *
ian@0 8 *
ian@0 9 * Generic C version of 64bit/32bit division and modulo, with
ian@0 10 * 64bit result and 32bit remainder.
ian@0 11 *
ian@0 12 * The fast case for (n>>32 == 0) is handled inline by do_div().
ian@0 13 *
ian@0 14 * Code generated for this function might be very inefficient
ian@0 15 * for some CPUs. __div64_32() can be overridden by linking arch-specific
ian@0 16 * assembly versions such as arch/ppc/lib/div64.S and arch/sh/lib/div64.S.
ian@0 17 */
ian@0 18
ian@0 19 #include <linux/types.h>
ian@0 20 #include <linux/module.h>
ian@0 21 #include <asm/div64.h>
ian@0 22
ian@0 23 /* Not needed on 64bit architectures */
ian@0 24 #if BITS_PER_LONG == 32
ian@0 25
ian@0 26 uint32_t __div64_32(uint64_t *n, uint32_t base)
ian@0 27 {
ian@0 28 uint64_t rem = *n;
ian@0 29 uint64_t b = base;
ian@0 30 uint64_t res, d = 1;
ian@0 31 uint32_t high = rem >> 32;
ian@0 32
ian@0 33 /* Reduce the thing a bit first */
ian@0 34 res = 0;
ian@0 35 if (high >= base) {
ian@0 36 high /= base;
ian@0 37 res = (uint64_t) high << 32;
ian@0 38 rem -= (uint64_t) (high*base) << 32;
ian@0 39 }
ian@0 40
ian@0 41 while ((int64_t)b > 0 && b < rem) {
ian@0 42 b = b+b;
ian@0 43 d = d+d;
ian@0 44 }
ian@0 45
ian@0 46 do {
ian@0 47 if (rem >= b) {
ian@0 48 rem -= b;
ian@0 49 res += d;
ian@0 50 }
ian@0 51 b >>= 1;
ian@0 52 d >>= 1;
ian@0 53 } while (d);
ian@0 54
ian@0 55 *n = res;
ian@0 56 return rem;
ian@0 57 }
ian@0 58
ian@0 59 EXPORT_SYMBOL(__div64_32);
ian@0 60
ian@0 61 #endif /* BITS_PER_LONG == 32 */