1 // Copyright 2010 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.
8 runtime_initlock(Lock *l)
10 if(pthread_mutex_init(&l->mutex, NULL) != 0)
11 runtime_throw("pthread_mutex_init failed");
17 if(pthread_mutex_lock(&l->mutex) != 0)
18 runtime_throw("lock failed");
22 runtime_unlock(Lock *l)
24 if(pthread_mutex_unlock(&l->mutex) != 0)
25 runtime_throw("unlock failed");
29 runtime_destroylock(Lock *l)
31 pthread_mutex_destroy(&l->mutex);
35 runtime_trylock(Lock *l)
37 return pthread_mutex_trylock(&l->mutex) == 0;