mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-10 11:04:58 -06:00
tests/tcg/s390x: Test TEST AND SET
Add a small test to prevent regressions. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-ID: <20240318202722.20675-2-iii@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
272fba9779
commit
f9b29c6364
2 changed files with 36 additions and 0 deletions
|
@ -47,6 +47,7 @@ TESTS+=add-logical-with-carry
|
||||||
TESTS+=lae
|
TESTS+=lae
|
||||||
TESTS+=cvd
|
TESTS+=cvd
|
||||||
TESTS+=cvb
|
TESTS+=cvb
|
||||||
|
TESTS+=ts
|
||||||
|
|
||||||
cdsg: CFLAGS+=-pthread
|
cdsg: CFLAGS+=-pthread
|
||||||
cdsg: LDFLAGS+=-pthread
|
cdsg: LDFLAGS+=-pthread
|
||||||
|
|
35
tests/tcg/s390x/ts.c
Normal file
35
tests/tcg/s390x/ts.c
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Test the TEST AND SET instruction.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static int ts(char *p)
|
||||||
|
{
|
||||||
|
int cc;
|
||||||
|
|
||||||
|
asm("ts %[p]\n"
|
||||||
|
"ipm %[cc]"
|
||||||
|
: [cc] "=r" (cc)
|
||||||
|
, [p] "+Q" (*p)
|
||||||
|
: : "cc");
|
||||||
|
|
||||||
|
return (cc >> 28) & 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
|
||||||
|
c = 0x80;
|
||||||
|
assert(ts(&c) == 1);
|
||||||
|
assert(c == 0xff);
|
||||||
|
|
||||||
|
c = 0x7f;
|
||||||
|
assert(ts(&c) == 0);
|
||||||
|
assert(c == 0xff);
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue