⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 div64.h

📁 U-boot源码 ARM7启动代码
💻 H
字号:
#ifndef __ASM_ARM_DIV64#define __ASM_ARM_DIV64/* Copy of the kernel header */// #include <asm/system.h>/* * This is used to ensure the compiler did actually allocate the register we * asked it for some inline assembly sequences.  Apparently we can't trust * the compiler from one version to another so a bit of paranoia won't hurt. * This string is meant to be concatenated with the inline asm string and * will cause compilation to stop on mismatch. * (for details, see gcc PR 15089) */#define __asmeq(x, y)  ".ifnc " x "," y " ; .err ; .endif\n\t"/* * 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; * } * * In other words, a 64-bit dividend with a 32-bit divisor producing * a 64-bit result and a 32-bit remainder.  To accomplish this optimally * we call a special __do_div64 helper with completely non standard * calling convention for arguments and results (beware). */#ifdef __ARMEB__#define __xh "r0"#define __xl "r1"#else#define __xl "r0"#define __xh "r1"#endif#define do_div(n,base)						\({								\	register unsigned int __base      asm("r4") = base;	\	register unsigned long long __n   asm("r0") = n;	\	register unsigned long long __res asm("r2");		\	register unsigned int __rem       asm(__xh);		\	asm(	__asmeq("%0", __xh)				\		__asmeq("%1", "r2")				\		__asmeq("%2", "r0")				\		__asmeq("%3", "r4")				\		"bl	__do_div64"				\		: "=r" (__rem), "=r" (__res)			\		: "r" (__n), "r" (__base)			\		: "ip", "lr", "cc");				\	n = __res;						\	__rem;							\})#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -