diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2017-06-27 04:21:40 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2017-06-27 04:21:40 +0000 |
commit | 936615752a29ab245708d40782427c25e60a2114 (patch) | |
tree | f43366b59cae9e51da40272eefd1ea71bb3ea055 /libgo/misc/cgo/test/issue6997_linux.c | |
parent | 9913ef5866a64176bac5749080487b0c7d637d4b (diff) | |
download | gcc-936615752a29ab245708d40782427c25e60a2114.zip gcc-936615752a29ab245708d40782427c25e60a2114.tar.gz gcc-936615752a29ab245708d40782427c25e60a2114.tar.bz2 |
libgo: add misc/cgo files
Copy all the misc/cgo files from the gc toolchain into libgo/misc.
These will be used for testing purposes by later changes to the
gotools directory.
Reviewed-on: https://go-review.googlesource.com/46721
From-SVN: r249674
Diffstat (limited to 'libgo/misc/cgo/test/issue6997_linux.c')
-rw-r--r-- | libgo/misc/cgo/test/issue6997_linux.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libgo/misc/cgo/test/issue6997_linux.c b/libgo/misc/cgo/test/issue6997_linux.c new file mode 100644 index 0000000..de803d2 --- /dev/null +++ b/libgo/misc/cgo/test/issue6997_linux.c @@ -0,0 +1,28 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !android + +#include <pthread.h> +#include <stdio.h> +#include <unistd.h> + +static pthread_t thread; + +static void* threadfunc(void* dummy) { + while(1) { + sleep(1); + } +} + +int StartThread() { + return pthread_create(&thread, NULL, &threadfunc, NULL); +} + +int CancelThread() { + void *r; + pthread_cancel(thread); + pthread_join(thread, &r); + return (r == PTHREAD_CANCELED); +} |