1
0
mirror of https://github.com/golang/go synced 2024-11-18 10:34:51 -07:00
go/misc/cgo/test/cthread_unix.c
Clément Chigot 125d187f9a cmd/dist, misc/cgo: enable tests for aix/ppc64
Some cgo tests aren't yet available on aix/ppc64.
-shared and -static don't work as expected and will be fixed latter.

Updates #30565

Change-Id: Ic59cabe685cb1cbdf89a8d1d1a1d2c4b0e8ef442
Reviewed-on: https://go-review.googlesource.com/c/go/+/164018
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-20 14:38:44 +00:00

35 lines
682 B
C

// Copyright 2013 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 aix darwin dragonfly freebsd linux netbsd openbsd solaris
#include <pthread.h>
#include "_cgo_export.h"
static void*
addThread(void *p)
{
int i, max;
max = *(int*)p;
for(i=0; i<max; i++)
Add(i);
return 0;
}
void
doAdd(int max, int nthread)
{
enum { MaxThread = 20 };
int i;
pthread_t thread_id[MaxThread];
if(nthread > MaxThread)
nthread = MaxThread;
for(i=0; i<nthread; i++)
pthread_create(&thread_id[i], 0, addThread, &max);
for(i=0; i<nthread; i++)
pthread_join(thread_id[i], 0);
}