fixed log_2 for ARM arch

This commit is contained in:
eddyem
2015-02-09 08:34:17 +03:00
parent b53a659d40
commit c14be0eb90
6 changed files with 189 additions and 20 deletions

View File

@@ -455,12 +455,8 @@ void copy_buf_to_file(uint8_t *buffer, int *cmd){
}
static inline uint32_t log_2(const uint32_t x) {
uint32_t y;
asm ( "\tbsr %1, %0\n"
: "=r"(y)
: "r" (x)
);
return y;
if(x == 0) return 0;
return (31 - __builtin_clz (x));
}
#define log2(x) ((int)log_2((uint32_t)x))

View File

@@ -117,12 +117,8 @@ size_t read_tty(){
}
static inline uint32_t log_2(const uint32_t x){
uint32_t y;
asm ( "\tbsr %1, %0\n"
: "=r"(y)
: "r" (x)
);
return y;
if(x == 0) return 0;
return (31 - __builtin_clz (x));
}
int send_command(uint8_t *ninebytes);