Files
ftmemsim-valgrind/drd/tests/annotate_ignore_rw.c
Bart Van Assche 6a68dfd48d Added regression test for ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() and
ANNOTATE_IGNORE_READS_AND_WRITES_END().


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10779
2009-08-11 15:00:54 +00:00

51 lines
903 B
C

/* Test program for the annotations that suppress both reads and writes. */
#include <assert.h> /* assert() */
#include <pthread.h>
#include <stdio.h> /* EOF */
#include <unistd.h> /* getopt() */
#include "../../drd/drd.h"
static int s_a;
static int s_b;
static void* thread_func(void* arg)
{
/* Read s_a and modify s_b. */
s_b = s_a;
return NULL;
}
int main(int argc, char** argv)
{
int optchar;
int ign_rw = 1;
pthread_t tid;
while ((optchar = getopt(argc, argv, "r")) != EOF)
{
switch (optchar)
{
case 'r':
ign_rw = 0;
break;
default:
assert(0);
}
}
pthread_create(&tid, 0, thread_func, 0);
if (ign_rw)
ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN();
/* Read s_b and modify s_a. */
s_a = s_b;
if (ign_rw)
ANNOTATE_IGNORE_READS_AND_WRITES_END();
pthread_join(tid, 0);
fprintf(stderr, "Finished.\n");
return 0;
}