linux(4): Fix gcc buld.

gcc failed as it didn't inlined the builtins and generates calls to
the libgcc, ld can't find libgcc as cross-toolchain libgcc is not installed.
To avoid this add internal vDSO ffs functions without optimized builtins.

Reported by:		jhb
MFC after:		2 weeks
This commit is contained in:
Dmitry Chagin 2021-07-29 09:52:33 +03:00
parent 272144ab41
commit f337940144
5 changed files with 34 additions and 4 deletions

View File

@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$");
#include <sys/vdso.h>
#undef _KERNEL
#include <stdbool.h>
#include <strings.h>
#include <machine/atomic.h>
#include <machine/stdarg.h>

View File

@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$");
#include <sys/vdso.h>
#undef _KERNEL
#include <stdbool.h>
#include <strings.h>
#include <machine/atomic.h>
#include <machine/stdarg.h>

View File

@ -38,7 +38,6 @@ __FBSDID("$FreeBSD$");
#include <sys/vdso.h>
#undef _KERNEL
#include <stdbool.h>
#include <strings.h>
#include <machine/atomic.h>
#include <machine/stdarg.h>

View File

@ -26,6 +26,40 @@
* SUCH DAMAGE.
*/
static int
fls(int mask)
{
if (mask == 0)
return (0);
return ((__builtin_clz(mask) ^ 0x1f) + 1);
}
#ifdef _LP64
static int
ffsl(long mask)
{
int bit;
if (mask == 0)
return (0);
for (bit = 1; !(mask & 1); bit++)
mask = (unsigned long)mask >> 1;
return (bit);
}
#else
static int
ffsll(long long mask)
{
int bit;
if (mask == 0)
return (0);
for (bit = 1; !(mask & 1); bit++)
mask = (unsigned long long)mask >> 1;
return (bit);
}
#endif
static int
__vdso_native_to_linux_timespec(struct l_timespec *lts,

View File

@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$");
#include <sys/vdso.h>
#undef _KERNEL
#include <stdbool.h>
#include <strings.h>
#include <machine/atomic.h>
#include <machine/stdarg.h>