source: code/trunk/vendor/modernc.org/libc/pthread_all.go@ 822

Last change on this file since 822 was 822, checked in by yakumo.izuru, 22 months ago

Prefer immortal.run over runit and rc.d, use vendored modules
for convenience.

Signed-off-by: Izuru Yakumo <yakumo.izuru@…>

File size: 1.4 KB
Line 
1// Copyright 2021 The Libc 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 !freebsd && !openbsd
6// +build !freebsd,!openbsd
7
8package libc // import "modernc.org/libc"
9
10import (
11 "unsafe"
12
13 "modernc.org/libc/pthread"
14)
15
16// int pthread_attr_init(pthread_attr_t *attr);
17func Xpthread_attr_init(t *TLS, pAttr uintptr) int32 {
18 *(*pthread.Pthread_attr_t)(unsafe.Pointer(pAttr)) = pthread.Pthread_attr_t{}
19 return 0
20}
21
22// The pthread_mutex_init() function shall initialize the mutex referenced by
23// mutex with attributes specified by attr. If attr is NULL, the default mutex
24// attributes are used; the effect shall be the same as passing the address of
25// a default mutex attributes object. Upon successful initialization, the state
26// of the mutex becomes initialized and unlocked.
27//
28// If successful, the pthread_mutex_destroy() and pthread_mutex_init()
29// functions shall return zero; otherwise, an error number shall be returned to
30// indicate the error.
31//
32// int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr);
33func Xpthread_mutex_init(t *TLS, pMutex, pAttr uintptr) int32 {
34 typ := pthread.PTHREAD_MUTEX_DEFAULT
35 if pAttr != 0 {
36 typ = int(X__ccgo_pthreadMutexattrGettype(t, pAttr))
37 }
38 mutexesMu.Lock()
39
40 defer mutexesMu.Unlock()
41
42 mutexes[pMutex] = newMutex(typ)
43 return 0
44}
Note: See TracBrowser for help on using the repository browser.