[LTP] Pre-release LTP build

Cyril Hrubis chrubis@suse.cz
Tue Apr 12 14:23:07 CEST 2016


Hi!
> As for RHEL5.6 it's only i386. I was able to compile x86_64, ia64, ppc/ppc64
> and s390/s390x with no changes.
> 
> Any of these two allow it to compile on x86:
> 1. -march=i486 (or higher)
> 2.
> diff --git a/lib/tst_atomic.c b/lib/tst_atomic.c
> new file mode 100644
> index 0000000..601fd6c
> --- /dev/null
> +++ b/lib/tst_atomic.c
> @@ -0,0 +1,8 @@
> +#if defined(__i386__)
> +unsigned int __sync_add_and_fetch_4(unsigned int *v, unsigned value)
> +{
> +       register int val = value;
> +       __asm__ __volatile__ ( "lock xadd %1,%0" : "=m" (*v), "=r" (val) : "1" (val) : "memory");
> +       return val + value;
> +}
> +#endif
> 
> According to gcc docs it should only make external call to above function,
> when it's not provided natively, so it works as fallback.

Accordingly to:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=34115

It does not work with gcc 4.1 when the builtin is returned directly at
the end of the function.

So storing the return value to a variable may fix that as well.

But I would prefer having fallback definition over working around
compiler bugs.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list