]> Cypherpunks repositories - gostls13.git/commit
runtime/cgo: initialize our pthread_create wrapper earlier on openbsd
authorShenghou Ma <minux@golang.org>
Thu, 1 Jan 2015 01:30:57 +0000 (20:30 -0500)
committerMinux Ma <minux@golang.org>
Thu, 1 Jan 2015 02:52:34 +0000 (02:52 +0000)
commit77cd6197d7561ab7ccbf5d892efb6f97d929546a
tree4058c56027ed8b6dd79c18f06be19b3458a3d6f5
parent76b2f06ee54f92b104412bdf9fefd8e7915969d3
runtime/cgo: initialize our pthread_create wrapper earlier on openbsd

This is a genuine bug exposed by our test for issue 9456: our wrapper
for pthread_create is not initialized until we initialize cgo itself,
but it is possible that a static constructor could call pthread_create,
and in that case, it will be calling a nil function pointer.

Fix that by also initializing the sys_pthread_create function pointer
inside our pthread_create wrapper function, and use a pthread_once to
make sure it is only initialized once.

Fix build for openbsd.

Change-Id: Ica4da2c21fcaec186fdd3379128ef46f0e767ed7
Reviewed-on: https://go-review.googlesource.com/2232
Reviewed-by: David Crawshaw <crawshaw@golang.org>
src/runtime/cgo/gcc_openbsd_386.c
src/runtime/cgo/gcc_openbsd_amd64.c