add cortex-v7a support
How To Run: see TencentOS-tiny\board\ALPHA_I.MX_emmc_256ddr\README.md TODO Next: 1. VFP support 2. fault diagnosis support 3. qemu vexpress ca9 support 4. raspberry pi support 5. SMP support
This commit is contained in:
52
board/ALPHA_I.MX_emmc_256ddr/stdio/lib/div64.c
Normal file
52
board/ALPHA_I.MX_emmc_256ddr/stdio/lib/div64.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2003 Bernardo Innocenti <bernie@develer.com>
|
||||
*
|
||||
* Based on former do_div() implementation from asm-parisc/div64.h:
|
||||
* Copyright (C) 1999 Hewlett-Packard Co
|
||||
* Copyright (C) 1999 David Mosberger-Tang <davidm@hpl.hp.com>
|
||||
*
|
||||
*
|
||||
* Generic C version of 64bit/32bit division and modulo, with
|
||||
* 64bit result and 32bit remainder.
|
||||
*
|
||||
* The fast case for (n>>32 == 0) is handled inline by do_div().
|
||||
*
|
||||
* Code generated for this function might be very inefficient
|
||||
* for some CPUs. __div64_32() can be overridden by linking arch-specific
|
||||
* assembly versions such as arch/powerpc/lib/div64.S and arch/sh/lib/div64.S.
|
||||
*/
|
||||
|
||||
#include "div64.h"
|
||||
|
||||
unsigned int __div64_32(unsigned long long *n, unsigned int base)
|
||||
{
|
||||
unsigned long long rem = *n;
|
||||
unsigned long long b = base;
|
||||
unsigned long long res, d = 1;
|
||||
unsigned int high = rem >> 32;
|
||||
|
||||
/* Reduce the thing a bit first */
|
||||
res = 0;
|
||||
if (high >= base) {
|
||||
high /= base;
|
||||
res = (unsigned long long ) high << 32;
|
||||
rem -= (unsigned long long ) (high*base) << 32;
|
||||
}
|
||||
|
||||
while ((signed long long )b > 0 && b < rem) {
|
||||
b = b+b;
|
||||
d = d+d;
|
||||
}
|
||||
|
||||
do {
|
||||
if (rem >= b) {
|
||||
rem -= b;
|
||||
res += d;
|
||||
}
|
||||
b >>= 1;
|
||||
d >>= 1;
|
||||
} while (d);
|
||||
|
||||
*n = res;
|
||||
return rem;
|
||||
}
|
Reference in New Issue
Block a user