From: Twaik Yont <9674930+twaik@users.noreply.github.com> Android NDK fails to build ntdll because ffs() is used without including <strings.h>, leading to an implicit function declaration error under C99: ``` .../dlls/ntdll/unix/unix_private.h:660:26: error: call to undeclared function 'ffs'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 660 | idx = idx * 32 + ffs( ~ldt_bitmap[idx] ) - 1; | ^ 1 error generated. make: *** [Makefile:250029: dlls/ntdll/unix/loadorder.o] Error 1 ``` Wine does not use <strings.h>, and other parts of the tree already rely on __builtin_ffs() for the same purpose. Replace ffs() with __builtin_ffs() in ldt_alloc_entry() to avoid the undeclared symbol on Android and to stay consistent with existing usage. The builtin maps directly to the compiler intrinsic and preserves the original semantics. Signed-off-by: Twaik Yont <9674930+twaik@users.noreply.github.com> --- dlls/ntdll/unix/unix_private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 10f6bb2c63c..51e2e4f98a8 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -658,7 +658,7 @@ static inline WORD ldt_alloc_entry( LDT_ENTRY entry ) for (idx = 0; idx < ARRAY_SIZE(ldt_bitmap); idx++) { if (ldt_bitmap[idx] == ~0u) continue; - idx = idx * 32 + ffs( ~ldt_bitmap[idx] ) - 1; + idx = idx * 32 + __builtin_ffs( ~ldt_bitmap[idx] ) - 1; return ldt_update_entry( (idx << 3) | 7, entry ); } return 0; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10067