introduce sqrt_approx() in -lsys
. use this to avoid -lm dependency in mfs
This commit is contained in:
		
							parent
							
								
									cf3b75c687
								
							
						
					
					
						commit
						9c01ceb576
					
				| @ -65,6 +65,7 @@ _PROTOTYPE( u32_t tsc_get_khz, (void)); | |||||||
| _PROTOTYPE( u32_t micros_to_ticks, (u32_t micros)); | _PROTOTYPE( u32_t micros_to_ticks, (u32_t micros)); | ||||||
| _PROTOTYPE( void ser_putc, (char c)); | _PROTOTYPE( void ser_putc, (char c)); | ||||||
| _PROTOTYPE( void get_randomness, (struct k_randomness *, int)); | _PROTOTYPE( void get_randomness, (struct k_randomness *, int)); | ||||||
|  | _PROTOTYPE( u32_t sqrt_approx, (u32_t)); | ||||||
| 
 | 
 | ||||||
| #define asynsend(ep, msg) asynsend3(ep, msg, 0) | #define asynsend(ep, msg) asynsend3(ep, msg, 0) | ||||||
| _PROTOTYPE( int asynsend3, (endpoint_t ep, message *msg, int flags)); | _PROTOTYPE( int asynsend3, (endpoint_t ep, message *msg, int flags)); | ||||||
|  | |||||||
| @ -57,6 +57,7 @@ SRCS=  \ | |||||||
| 	sef_signal.c \
 | 	sef_signal.c \
 | ||||||
| 	ser_putc.c \
 | 	ser_putc.c \
 | ||||||
| 	spin.c \
 | 	spin.c \
 | ||||||
|  | 	sqrt_approx.c \
 | ||||||
| 	stacktrace.c \
 | 	stacktrace.c \
 | ||||||
| 	sys_abort.c \
 | 	sys_abort.c \
 | ||||||
| 	sys_clear.c \
 | 	sys_clear.c \
 | ||||||
| @ -127,6 +128,7 @@ SRCS=  \ | |||||||
| 	vm_yield_get_block.c \
 | 	vm_yield_get_block.c \
 | ||||||
| 	vprintf.c \
 | 	vprintf.c \
 | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| CPPFLAGS.sched_start.c+=	-I${MINIXSRCDIR} | CPPFLAGS.sched_start.c+=	-I${MINIXSRCDIR} | ||||||
| 
 | 
 | ||||||
| .if (${NBSD_LIBC} != "no") | .if (${NBSD_LIBC} != "no") | ||||||
|  | |||||||
							
								
								
									
										14
									
								
								lib/libsys/sqrt_approx.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								lib/libsys/sqrt_approx.c
									
									
									
									
									
										Normal 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; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| @ -6,7 +6,7 @@ SRCS=	cache.c device.c link.c \ | |||||||
| 	write.c inode.c main.c path.c super.c | 	write.c inode.c main.c path.c super.c | ||||||
| 
 | 
 | ||||||
| DPADD+=	${LIBM} ${LIBSYS} | DPADD+=	${LIBM} ${LIBSYS} | ||||||
| LDADD+=	-lm -lsys | LDADD+= -lsys | ||||||
| 
 | 
 | ||||||
| MAN= | MAN= | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -601,7 +601,7 @@ PRIVATE int bufs_heuristic(struct super_block *sp) | |||||||
|   /* heuristic for a desired cache size based on FS usage;
 |   /* heuristic for a desired cache size based on FS usage;
 | ||||||
|    * but never bigger than half of the total filesystem |    * but never bigger than half of the total filesystem | ||||||
|    */ |    */ | ||||||
|   kb_fsmax = sqrt(kbytes_used_fs)*40; |   kb_fsmax = sqrt_approx(kbytes_used_fs)*40; | ||||||
|   kb_fsmax = MIN(kb_fsmax, kbytes_total_fs/2); |   kb_fsmax = MIN(kb_fsmax, kbytes_total_fs/2); | ||||||
| 
 | 
 | ||||||
|   /* heuristic for a maximum usage - 10% of remaining memory */ |   /* heuristic for a maximum usage - 10% of remaining memory */ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Ben Gras
						Ben Gras