Files
ftmemsim-valgrind/none/tests/amd64/xadd.c
Carl Love 0689c096e5 This commit is for Bugzilla 334836. The Bugzilla contains patch 3 of 3
to add PPC64 LE support.  The other two patches can be found in Bugzillas
334384 and 334834.  Note, there are no VEX changes in this patch.


PP64 Little Endian test case fixes.

This patch adds new LE and BE expect files where needed.  In other
cases, the test was fixed to run correctly on LE and BE using based on
testing to see which platform is being used.

Where practical, the test cases have been changed so that the output
produced for BE	 and LE will be identical.  The test cases that require
a major rewrite to make the output identical for BE and LE simply
had an additional expect file added.

Signed-off-by: Carl Love <carll@us.ibm.com>


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14240
2014-08-07 23:49:27 +00:00

50 lines
994 B
C

#include "config.h"
#include <stdio.h>
#include <assert.h>
/* Simple test program, no race.
Tests the 'xadd' exchange-and-add instruction with {r,r} operands, which is rarely generated by compilers. */
#undef PLAT_x86_linux
#undef PLAT_amd64_linux
#undef PLAT_ppc32_linux
#undef PLAT_ppc64be_linux
#if defined(__i386__)
# define PLAT_x86_linux 1
#elif defined(__x86_64__)
# define PLAT_amd64_linux 1
#endif
#if defined(PLAT_amd64_linux) || defined(PLAT_x86_linux)
# define XADD_R_R(_addr,_lval) \
__asm__ __volatile__( \
"xadd %1, %0" \
: /*out*/ "=r"(_lval),"=r"(_addr) \
: /*in*/ "0"(_lval),"1"(_addr) \
: "flags" \
)
#else
# error "Unsupported architecture"
#endif
int main ( void )
{
long d = 20, s = 2;
long xadd_r_r_res;
#define XADD_R_R_RES 42
XADD_R_R(s, d);
xadd_r_r_res = s + d;
assert(xadd_r_r_res == XADD_R_R_RES);
if (xadd_r_r_res == XADD_R_R_RES)
printf("success\n");
else
printf("failure\n");
return xadd_r_r_res;
}