1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

sync: fix C.pthread_mutex_t struct typedef is missing in darwin (fix: #15491) (#15845)

This commit is contained in:
shove 2022-09-23 14:48:05 +08:00 committed by GitHub
parent 5c716afb39
commit 6ec931c781
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

@ -30,6 +30,18 @@ fn C.pthread_cond_wait(voidptr, voidptr) int
fn C.pthread_cond_timedwait(voidptr, voidptr, voidptr) int fn C.pthread_cond_timedwait(voidptr, voidptr, voidptr) int
fn C.pthread_cond_destroy(voidptr) int fn C.pthread_cond_destroy(voidptr) int
[typedef]
struct C.pthread_mutex_t {}
[typedef]
struct C.pthread_rwlock_t {}
[typedef]
struct C.pthread_rwlockattr_t {}
[typedef]
struct C.sem_t {}
// [init_with=new_mutex] // TODO: implement support for this struct attribute, and disallow Mutex{} from outside the sync.new_mutex() function. // [init_with=new_mutex] // TODO: implement support for this struct attribute, and disallow Mutex{} from outside the sync.new_mutex() function.
[heap] [heap]
pub struct Mutex { pub struct Mutex {

View File

@ -1,3 +1,5 @@
import sync
fn test_array_of_floats() { fn test_array_of_floats() {
// f64 array // f64 array
aa := [1.2, 3.4, 5.67] aa := [1.2, 3.4, 5.67]
@ -444,3 +446,20 @@ fn test_fixed_array_of_function() {
println(a) println(a)
assert '$a' == '[fn (string), fn (string)]' assert '$a' == '[fn (string), fn (string)]'
} }
struct CTypeDefStruct {
mutex &sync.Mutex
}
fn test_c_struct_typedef() {
$if macos || linux {
c := CTypeDefStruct{
mutex: sync.new_mutex()
}
assert c.str() == r'CTypeDefStruct{
mutex: &sync.Mutex{
mutex: pthread_mutex_t{}
}
}'
}
}