Hi, I have a question. I used '__builtin_ctz' function in arm compiler and it worked well, but I don't know which header file contains '__builtin_ctz' function. Do you know which header file is needed to use '__builtin_ctz' function?
as the name implies, a builtin is a compiler intrinsnic, they're not provided by a header. They are "builtin" to the compiler as it were.
Thank you for answering my question. Then can't I find the implementation of builtin functions?
not without the source code of the compiler. These aren't real functions, they are generated internally by the compiler.
You can apparently find it (eventually) in the gcc source code. It wasn't as easy as it should have been.Check out ...gcc-arm-src-10.3-2021.10/src/gcc/libgcc/config/arm/lib1funcs.S
the 32bit function is actually called "ctzsi2":
ARM_FUNC_START ctzsi2 rsb r1, r0, #0 and r0, r0, r1# if defined (__ARM_FEATURE_CLZ) clz r0, r0 rsb r0, r0, #31 RET
rsb r1, r0, #0
and r0, r0, r1
# if defined (__ARM_FEATURE_CLZ)
clz r0, r0
rsb r0, r0, #31
The source code is rather obscured by conditionals for the various ARM architectures, and doesn't seem to have any comments. You may be better off compiling for your desired target system and looking at the disassembly.