Skip to content

Commit

Permalink
feat(ARM): modify find_first_bit to support building on arm64 (#292)
Browse files Browse the repository at this point in the history
* add(function): modify find_first_bit function to support building on arm64

Related to: openebs/openebs#1295

Modify the find_first_bit function in istgt_lu_disk.c, which is
implemented by using asm and cannot run on arm64. And add the
implementation by using c language.

Signed-off-by: wangzihao <[email protected]>
  • Loading branch information
wangzihao3 authored and vishnuitta committed Nov 20, 2019
1 parent 001d04a commit c3fa155
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/istgt_lu_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ find_first_bit(ISTGT_LU_CMD_Ptr lu_cmd)
nbits >>= 6;
if (!nbits)
continue;
#if defined(__x86_64__)
asm volatile(
" repe; scasq\n"
" jz 1f\n"
Expand All @@ -269,8 +270,21 @@ find_first_bit(ISTGT_LU_CMD_Ptr lu_cmd)
:"=a" (res), "=&c" (d0), "=&D" (d1)
:"0" (0ULL), "1" (nbits), "2" (addr),
[addr] "r" (addr) : "memory");
res_final +=res;
if((unsigned long)res != nbits)
#else
unsigned long idx;
res = 0;
for (idx = 0; idx < nbits; idx++) {
if (addr[idx]) {
res += __builtin_ffsl(addr[idx]) - 1;
break;
} else {
// there is no set bit in this addr part, res should add the bits of addr.
res += sizeof(*addr) << 3;
}
}
#endif
res_final += res;
if ((unsigned long)res != nbits << 6)
return res_final;
}
return res_final;
Expand Down

0 comments on commit c3fa155

Please sign in to comment.