mirror of
https://github.com/drasko/codezero.git
synced 2026-04-21 19:29:05 +02:00
Initial commit
This commit is contained in:
16
tasks/libmem/tests/clz.c
Normal file
16
tasks/libmem/tests/clz.c
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
#include <l4/macros.h>
|
||||
#include <l4/types.h>
|
||||
#include <l4/config.h>
|
||||
|
||||
/* Emulation of CLZ (count leading zeroes) instruction */
|
||||
unsigned int __clz(unsigned int bitvector)
|
||||
{
|
||||
unsigned int x = 0;
|
||||
while((!(bitvector & ((unsigned)1 << 31))) && (x < 32)) {
|
||||
bitvector <<= 1;
|
||||
x++;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user