From c99cffd412a041586e8a475bbb75212f3746ca1d Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sun, 11 Aug 2019 02:31:34 +0000 Subject: strace: Probe for __builtin_popcount --- pkg/strace/config.h | 2 +- pkg/strace/gen.lua | 9 +++++++-- probe/HAVE___BUILTIN_POPCOUNT | 4 ++++ probe/gen.lua | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 probe/HAVE___BUILTIN_POPCOUNT diff --git a/pkg/strace/config.h b/pkg/strace/config.h index cfb2197b..435fc77a 100644 --- a/pkg/strace/config.h +++ b/pkg/strace/config.h @@ -536,7 +536,7 @@ /* #undef HAVE_USTAT_H */ #define HAVE_UTIMENSAT 1 /* #undef HAVE__STATIC_ASSERT */ -#define HAVE___BUILTIN_POPCOUNT 1 +/* probe HAVE___BUILTIN_POPCOUNT */ #define HAVE___KERNEL_LONG_T 1 #define HAVE___KERNEL_ULONG_T 1 /* #undef HPPA */ diff --git a/pkg/strace/gen.lua b/pkg/strace/gen.lua index b48aecae..f5874e7e 100644 --- a/pkg/strace/gen.lua +++ b/pkg/strace/gen.lua @@ -1,6 +1,5 @@ cflags{ '-D HAVE_CONFIG_H', - '-I $dir', -- it is important that the arch-specific directory is searched first '-I $srcdir/linux/x86_64', '-I $srcdir/linux', @@ -8,6 +7,11 @@ cflags{ '-I $outdir', } +build('cat', '$outdir/config.h', { + '$builddir/probe/HAVE___BUILTIN_POPCOUNT', + '$dir/config.h', +}) + build('cpp', '$outdir/ioctl_iocdef.i', '$srcdir/ioctl_iocdef.c') build('sed', '$outdir/ioctl_iocdef.h', '$outdir/ioctl_iocdef.i', { expr=[[-n 's/^DEFINE HOST/#define /p']], @@ -39,7 +43,7 @@ end) local mpers = lines('mpers.txt') for _, f in ipairs(mpers) do - build('cpp', '$outdir/'..f..'.mpers.i', '$srcdir/'..f, { + build('cpp', '$outdir/'..f..'.mpers.i', {'$srcdir/'..f, '|', '$outdir/config.h'}, { cflags='$cflags -DIN_MPERS_BOOTSTRAP', }) end @@ -327,6 +331,7 @@ build('sed', '$outdir/sys_func.h', expand{'$srcdir/', {libsrcs, srcs}}, { }) pkg.deps = { + '$outdir/config.h', '$outdir/ioctlent0.h', '$outdir/ioctlent1.h', '$outdir/ioctlent2.h', diff --git a/probe/HAVE___BUILTIN_POPCOUNT b/probe/HAVE___BUILTIN_POPCOUNT new file mode 100644 index 00000000..0ec4e656 --- /dev/null +++ b/probe/HAVE___BUILTIN_POPCOUNT @@ -0,0 +1,4 @@ +unsigned x = 0; +int main(void) { + return __builtin_popcount(x); +} diff --git a/probe/gen.lua b/probe/gen.lua index 082f697e..ab2cb3d2 100644 --- a/probe/gen.lua +++ b/probe/gen.lua @@ -7,6 +7,7 @@ probe('HAVE__MM_MOVEMASK_EPI8') probe('HAVE__THREAD_LOCAL') probe('HAVE___BUILTIN_CLZ') probe('HAVE___BUILTIN_CTZL') +probe('HAVE___BUILTIN_POPCOUNT') local function probesize(var) build('probesize', '$outdir/'..var, {'$dir/'..var, '|', 'scripts/probe-size.sh'}, {var=var}) -- cgit v1.2.3