mirror of
https://github.com/glebarez/go-sqlite.git
synced 2025-10-16 04:40:43 +08:00
libtest: configure mutexes
This commit is contained in:
17
lib/mutex.go
17
lib/mutex.go
@@ -21,22 +21,25 @@ func init() {
|
||||
panic(fmt.Errorf("sqlite: thread safety configuration error"))
|
||||
}
|
||||
|
||||
varArgs := libc.Xmalloc(tls, types.Size_t(unsafe.Sizeof(uintptr(0))))
|
||||
if varArgs == 0 {
|
||||
panic(fmt.Errorf("cannot allocate memory"))
|
||||
}
|
||||
switch fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH) {
|
||||
case "linux/amd64":
|
||||
// experimental pthreads support currently only on linux/amd64
|
||||
default:
|
||||
varArgs := libc.Xmalloc(tls, types.Size_t(unsafe.Sizeof(uintptr(0))))
|
||||
if varArgs == 0 {
|
||||
panic(fmt.Errorf("cannot allocate memory"))
|
||||
}
|
||||
|
||||
// experimental pthreads support currently only on linux/amd64
|
||||
if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" {
|
||||
// int sqlite3_config(int, ...);
|
||||
if rc := Xsqlite3_config(tls, SQLITE_CONFIG_MUTEX, libc.VaList(varArgs, uintptr(unsafe.Pointer(&mutexMethods)))); rc != SQLITE_OK {
|
||||
p := Xsqlite3_errstr(tls, rc)
|
||||
str := libc.GoString(p)
|
||||
panic(fmt.Errorf("sqlite: failed to configure mutex methods: %v", str))
|
||||
}
|
||||
|
||||
libc.Xfree(tls, varArgs)
|
||||
}
|
||||
|
||||
libc.Xfree(tls, varArgs)
|
||||
tls.Close()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user