...

Text file src/runtime/testdata/testprogcgo/bindm.c

Documentation: runtime/testdata/testprogcgo

     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
    15static 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
    24void 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}

View as plain text