Skip to content

Commit 4f4a9c7

Browse files
committed
runtime: correct GoCheckBindM's C declaration in EnsureBindM test
The test file has a C declaration which doesn't match the actual definition. Remove it and include "_cgo_export.h" to have the right declaration. Change-Id: Iddf6d8883ee0e439147c7027029dd3e352ef090d Reviewed-on: https://go-review.googlesource.com/c/go/+/482975 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
1 parent 7f5af09 commit 4f4a9c7

File tree

2 files changed

+35
-29
lines changed

2 files changed

+35
-29
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2023 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build !plan9 && !windows
6+
7+
#include <stdint.h>
8+
#include <pthread.h>
9+
#include <unistd.h>
10+
#include "_cgo_export.h"
11+
12+
#define CTHREADS 2
13+
#define CHECKCALLS 100
14+
15+
static void* checkBindMThread(void* thread) {
16+
int i;
17+
for (i = 0; i < CHECKCALLS; i++) {
18+
GoCheckBindM((uintptr_t)thread);
19+
usleep(1);
20+
}
21+
return NULL;
22+
}
23+
24+
void CheckBindM() {
25+
int i;
26+
pthread_t s[CTHREADS];
27+
28+
for (i = 0; i < CTHREADS; i++) {
29+
pthread_create(&s[i], NULL, checkBindMThread, &s[i]);
30+
}
31+
for (i = 0; i < CTHREADS; i++) {
32+
pthread_join(s[i], NULL);
33+
}
34+
}

src/runtime/testdata/testprogcgo/bindm.go

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,7 @@
1010
package main
1111

1212
/*
13-
#include <stdint.h>
14-
#include <pthread.h>
15-
#include <unistd.h>
16-
17-
extern void GoCheckBindM();
18-
19-
#define CTHREADS 2
20-
#define CHECKCALLS 100
21-
22-
static void* checkBindMThread(void* thread) {
23-
int i;
24-
for (i = 0; i < CHECKCALLS; i++) {
25-
GoCheckBindM((uintptr_t)thread);
26-
usleep(1);
27-
}
28-
return NULL;
29-
}
30-
31-
static void CheckBindM() {
32-
int i;
33-
pthread_t s[CTHREADS];
34-
35-
for (i = 0; i < CTHREADS; i++) {
36-
pthread_create(&s[i], NULL, checkBindMThread, &s[i]);
37-
}
38-
for (i = 0; i < CTHREADS; i++) {
39-
pthread_join(s[i], NULL);
40-
}
41-
}
13+
extern void CheckBindM();
4214
*/
4315
import "C"
4416

0 commit comments

Comments
 (0)