#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>

void *Thread1(void *p) {
  *(int*)p = 42;
  return 0;
}

void *Thread2(void *p) {
  *(int*)p = 44;
  return 0;
}

void *alloc() {
  return malloc(99);
}

void *AllocThread(void* arg) {
  return alloc();
}

int main() {
  void *p = 0;
  pthread_t t[2];
  pthread_create(&t[0], 0, AllocThread, 0);
  pthread_join(t[0], &p);
  fprintf(stderr, "addr=%p\n", p);
  pthread_create(&t[0], 0, Thread1, (char*)p + 16);
  pthread_create(&t[1], 0, Thread2, (char*)p + 16);
  pthread_join(t[0], 0);
  pthread_join(t[1], 0);
  return 0;
}

// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
// CHECK: WARNING: ThreadSanitizer: data race
// ...
// CHECK:   Location is heap block of size 99 at [[ADDR]] allocated by thread 1:
// CHECK:     #0 alloc
// CHECK:     #1 AllocThread
// ...
// CHECK:   Thread 1 (finished) created at:
// CHECK:     #0 pthread_create
// CHECK:     #1 main

#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>

void *Thread1(void *p) {
  *(int*)p = 42;
  return 0;
}

void *Thread2(void *p) {
  *(int*)p = 44;;
  return 0;
}

void *alloc() {
  return malloc(99);
}

void *AllocThread(void*) {
  return alloc();
}

int main() {
  void *p = 0;
  pthread_t t[2];
  pthread_create(&t[0], 0, AllocThread, 0);
  pthread_join(t[0], &p);
  fprintf(stderr, "addr=%p\n", p);
  pthread_create(&t[0], 0, Thread1, (char*)p + 16);
  pthread_create(&t[1], 0, Thread2, (char*)p + 16);
  pthread_join(t[0], 0);
  pthread_join(t[1], 0);
  return 0;
}

// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
// CHECK: WARNING: ThreadSanitizer: data race
//...
// CHECK:   Location is heap block of size 99 at [[ADDR]] allocated by thread 1:
// CHECK:     #0 alloc
// CHECK:     #1 AllocThread
//...
// CHECK:   Thread 1 (finished) created at:
// CHECK:     #0 pthread_create
// CHECK:     #1 main


--- 
+++ 
@@ -8,7 +8,7 @@
 }
 
 void *Thread2(void *p) {
-  *(int*)p = 44;;
+  *(int*)p = 44;
   return 0;
 }
 
@@ -16,7 +16,7 @@
   return malloc(99);
 }
 
-void *AllocThread(void*) {
+void *AllocThread(void* arg) {
   return alloc();
 }
 
@@ -35,12 +35,11 @@
 
 // CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
 // CHECK: WARNING: ThreadSanitizer: data race
-//...
+// ...
 // CHECK:   Location is heap block of size 99 at [[ADDR]] allocated by thread 1:
 // CHECK:     #0 alloc
 // CHECK:     #1 AllocThread
-//...
+// ...
 // CHECK:   Thread 1 (finished) created at:
 // CHECK:     #0 pthread_create
 // CHECK:     #1 main
-
[TSan] Fix style warinings in output test

git-svn-id: c199f293c43da69278bea8e88f92242bf3aa95f7@162980 91177308-0d34-0410-b5e6-96231b3b80d8
