Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(349)

Side by Side Diff: misc/cgo/test/cthread_unix.c

Issue 13213043: cgo: enable cgo on dragonfly
Patch Set: diff -r 2aef8fd83bbd https://go.googlecode.com/hg Created 11 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | misc/cgo/testso/cgoso.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Go Authors. All rights reserved. 1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build darwin freebsd linux netbsd openbsd 5 // +build darwin dragonfly freebsd linux netbsd openbsd
6 6
7 #include <pthread.h> 7 #include <pthread.h>
8 #include "_cgo_export.h" 8 #include "_cgo_export.h"
9 9
10 static void* 10 static void*
11 addThread(void *p) 11 addThread(void *p)
12 { 12 {
13 int i, max; 13 int i, max;
14 ········ 14 ········
15 max = *(int*)p; 15 max = *(int*)p;
16 for(i=0; i<max; i++) 16 for(i=0; i<max; i++)
17 Add(i); 17 Add(i);
18 return 0; 18 return 0;
19 } 19 }
20 20
21 void 21 void
22 doAdd(int max, int nthread) 22 doAdd(int max, int nthread)
23 { 23 {
24 enum { MaxThread = 20 }; 24 enum { MaxThread = 20 };
25 int i; 25 int i;
26 pthread_t thread_id[MaxThread]; 26 pthread_t thread_id[MaxThread];
27 ········ 27 ········
28 if(nthread > MaxThread) 28 if(nthread > MaxThread)
29 nthread = MaxThread; 29 nthread = MaxThread;
30 for(i=0; i<nthread; i++) 30 for(i=0; i<nthread; i++)
31 pthread_create(&thread_id[i], 0, addThread, &max); 31 pthread_create(&thread_id[i], 0, addThread, &max);
32 for(i=0; i<nthread; i++) 32 for(i=0; i<nthread; i++)
33 pthread_join(thread_id[i], 0);·········· 33 pthread_join(thread_id[i], 0);··········
34 } 34 }
OLDNEW
« no previous file with comments | « no previous file | misc/cgo/testso/cgoso.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b