Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45938 )
Change subject: lib: add 64-bit versions of clz, __ffs and log2 ......................................................................
Patch Set 1:
(4 comments)
https://review.coreboot.org/c/coreboot/+/45938/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/45938/1//COMMIT_MSG@7 PS1, Line 7: lib Could you add these to libpayload as well so the two stay in sync?
https://review.coreboot.org/c/coreboot/+/45938/1/src/include/lib.h File src/include/lib.h:
https://review.coreboot.org/c/coreboot/+/45938/1/src/include/lib.h@59 PS1, Line 59: long long Why does one of these return `long long` and the others int? I think int makes sense for all of them.
https://review.coreboot.org/c/coreboot/+/45938/1/src/include/lib.h@59 PS1, Line 59: __builtin_clz Careful, this is in and off itself a 32-bit function. The only available options for this are __builtin_clzl() and __builtin_clzll()... I guess even on 64-bit systems `unsigned long long` is still 64 bit, so it's probably fine to use __builtin_clzll() everywhere?
https://review.coreboot.org/c/coreboot/+/45938/1/src/include/lib.h@61 PS1, Line 61: __ffs_64 nit: Linux calls this __ffs64(). Maybe better to use clz64() and __ffs64() for consistency? (Although log2() doesn't match then, Linux doesn't have that one...)