xref: /aosp_15_r20/external/compiler-rt/test/tsan/sunrpc.cc (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2*7c3d14c8STreehugger Robot 
3*7c3d14c8STreehugger Robot #include <pthread.h>
4*7c3d14c8STreehugger Robot #include <rpc/types.h>
5*7c3d14c8STreehugger Robot #include <rpc/xdr.h>
6*7c3d14c8STreehugger Robot #include <stdio.h>
7*7c3d14c8STreehugger Robot 
thr(void * p)8*7c3d14c8STreehugger Robot void *thr(void *p) {
9*7c3d14c8STreehugger Robot   XDR xdrs;
10*7c3d14c8STreehugger Robot   char buf[100];
11*7c3d14c8STreehugger Robot   xdrmem_create(&xdrs, buf, sizeof(buf), XDR_ENCODE);
12*7c3d14c8STreehugger Robot   xdr_destroy(&xdrs);
13*7c3d14c8STreehugger Robot   return 0;
14*7c3d14c8STreehugger Robot }
15*7c3d14c8STreehugger Robot 
main(int argc,char * argv[])16*7c3d14c8STreehugger Robot int main(int argc, char *argv[]) {
17*7c3d14c8STreehugger Robot   pthread_t th[2];
18*7c3d14c8STreehugger Robot   pthread_create(&th[0], 0, thr, 0);
19*7c3d14c8STreehugger Robot   pthread_create(&th[1], 0, thr, 0);
20*7c3d14c8STreehugger Robot   pthread_join(th[0], 0);
21*7c3d14c8STreehugger Robot   pthread_join(th[1], 0);
22*7c3d14c8STreehugger Robot   fprintf(stderr, "DONE\n");
23*7c3d14c8STreehugger Robot   // CHECK: DONE
24*7c3d14c8STreehugger Robot   return 0;
25*7c3d14c8STreehugger Robot }
26