2012-07-27 22:00:39 +08:00
|
|
|
//===-- test.c ------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Sanity test for Go runtime.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2012-07-16 18:34:57 +08:00
|
|
|
|
2012-07-28 02:13:03 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2012-07-16 18:34:57 +08:00
|
|
|
void __tsan_init();
|
|
|
|
void __tsan_fini();
|
2012-07-27 22:00:39 +08:00
|
|
|
void __tsan_go_start(int pgoid, int chgoid, void *pc);
|
|
|
|
void __tsan_go_end(int goid);
|
|
|
|
void __tsan_read(int goid, void *addr, void *pc);
|
|
|
|
void __tsan_write(int goid, void *addr, void *pc);
|
|
|
|
void __tsan_func_enter(int goid, void *pc);
|
|
|
|
void __tsan_func_exit(int goid);
|
|
|
|
void __tsan_malloc(int goid, void *p, unsigned long sz, void *pc);
|
|
|
|
void __tsan_free(void *p);
|
|
|
|
void __tsan_acquire(int goid, void *addr);
|
|
|
|
void __tsan_release(int goid, void *addr);
|
|
|
|
void __tsan_release_merge(int goid, void *addr);
|
2012-07-16 18:34:57 +08:00
|
|
|
|
2012-07-24 20:29:43 +08:00
|
|
|
int __tsan_symbolize(void *pc, char **img, char **rtn, char **file, int *l) {
|
2012-07-16 18:34:57 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-27 22:00:39 +08:00
|
|
|
char buf[10];
|
|
|
|
|
2012-07-16 18:34:57 +08:00
|
|
|
int main(void) {
|
|
|
|
__tsan_init();
|
2012-07-27 22:00:39 +08:00
|
|
|
__tsan_func_enter(0, &main);
|
|
|
|
__tsan_malloc(0, buf, 10, 0);
|
|
|
|
__tsan_release(0, buf);
|
|
|
|
__tsan_release_merge(0, buf);
|
|
|
|
__tsan_go_start(0, 1, 0);
|
|
|
|
__tsan_write(1, buf, 0);
|
|
|
|
__tsan_acquire(1, buf);
|
|
|
|
__tsan_go_end(1);
|
|
|
|
__tsan_read(0, buf, 0);
|
|
|
|
__tsan_free(buf);
|
|
|
|
__tsan_func_exit(0);
|
2012-07-16 18:34:57 +08:00
|
|
|
__tsan_fini();
|
|
|
|
return 0;
|
|
|
|
}
|