...

Text file src/runtime/cgo/gcc_stack_darwin.c

Documentation: runtime/cgo

     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#include <pthread.h>
     6#include "libcgo.h"
     7
     8void
     9x_cgo_getstackbound(uintptr bounds[2])
    10{
    11	void* addr;
    12	size_t size;
    13	pthread_t p;
    14
    15	p = pthread_self();
    16	addr = pthread_get_stackaddr_np(p); // high address (!)
    17	size = pthread_get_stacksize_np(p);
    18
    19	// bounds points into the Go stack. TSAN can't see the synchronization
    20	// in Go around stack reuse.
    21	_cgo_tsan_acquire();
    22	bounds[0] = (uintptr)addr - size;
    23	bounds[1] = (uintptr)addr;
    24	_cgo_tsan_release();
    25}

View as plain text