Home | History | Annotate | Download | only in go
      1 //===-- test.c ------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // Sanity test for Go runtime.
     11 //
     12 //===----------------------------------------------------------------------===//
     13 
     14 #include <stdio.h>
     15 
     16 void __tsan_init(void **thr);
     17 void __tsan_fini();
     18 void __tsan_map_shadow(void *addr, unsigned long size);
     19 void __tsan_go_start(void *thr, void **chthr, void *pc);
     20 void __tsan_go_end(void *thr);
     21 void __tsan_read(void *thr, void *addr, void *pc);
     22 void __tsan_write(void *thr, void *addr, void *pc);
     23 void __tsan_func_enter(void *thr, void *pc);
     24 void __tsan_func_exit(void *thr);
     25 void __tsan_malloc(void *thr, void *p, unsigned long sz, void *pc);
     26 void __tsan_free(void *p);
     27 void __tsan_acquire(void *thr, void *addr);
     28 void __tsan_release(void *thr, void *addr);
     29 void __tsan_release_merge(void *thr, void *addr);
     30 
     31 int __tsan_symbolize(void *pc, char **img, char **rtn, char **file, int *l) {
     32   return 0;
     33 }
     34 
     35 char buf[10];
     36 
     37 int main(void) {
     38   void *thr0 = 0;
     39   __tsan_init(&thr0);
     40   __tsan_map_shadow(buf, sizeof(buf) + 4096);
     41   __tsan_func_enter(thr0, &main);
     42   __tsan_malloc(thr0, buf, 10, 0);
     43   __tsan_release(thr0, buf);
     44   __tsan_release_merge(thr0, buf);
     45   void *thr1 = 0;
     46   __tsan_go_start(thr0, &thr1, 0);
     47   __tsan_write(thr1, buf, 0);
     48   __tsan_acquire(thr1, buf);
     49   __tsan_go_end(thr1);
     50   __tsan_read(thr0, buf, 0);
     51   __tsan_free(buf);
     52   __tsan_func_exit(thr0);
     53   __tsan_fini();
     54   return 0;
     55 }
     56