gcc/tests/smoke-test/tm.c
DistroBaker 8230ff782d Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/gcc.git#ac8f498836cb54282caf6ee9c6bb0c179029c18c
2021-01-12 08:17:11 +00:00

35 lines
589 B
C

extern void *malloc (__SIZE_TYPE__) __attribute__((malloc,transaction_safe));
static int __attribute__((transaction_safe))
something (void)
{
return 0;
}
struct large { int foo[500]; };
int
main (void)
{
int *p;
struct large *lp;
__transaction_atomic {
p = malloc (sizeof (*p) * 100);
lp = malloc (sizeof (*lp) * 100);
/* No instrumentation necessary; P and LP are transaction local. */
p[5] = 123;
lp->foo[66] = 123;
if (something ())
__transaction_cancel;
}
__transaction_relaxed {
++p[5];
}
return ( (p[5] == 124) ? 0 : 1 );
}