introduce sqrt_approx() in -lsys

. use this to avoid -lm dependency in mfs
This commit is contained in:
Ben Gras
2011-07-04 02:51:12 +02:00
parent cf3b75c687
commit 9c01ceb576
5 changed files with 19 additions and 2 deletions

View File

@@ -57,6 +57,7 @@ SRCS= \
sef_signal.c \
ser_putc.c \
spin.c \
sqrt_approx.c \
stacktrace.c \
sys_abort.c \
sys_clear.c \
@@ -127,6 +128,7 @@ SRCS= \
vm_yield_get_block.c \
vprintf.c \
CPPFLAGS.sched_start.c+= -I${MINIXSRCDIR}
.if (${NBSD_LIBC} != "no")

14
lib/libsys/sqrt_approx.c Normal file
View File

@@ -0,0 +1,14 @@
#include <minix/sysutil.h>
u32_t sqrt_approx(u32_t in)
{
int b, v = 0;
for(b = (sizeof(in)*8)/2-1; b >= 0; b--) {
u32_t n = v | (1UL << b);
if(n*n <= in)
v = n;
}
return v;
}