2022-05-27 13:38:45 +02:00
|
|
|
// SPDX-License-Identifier: Zlib
|
|
|
|
// SPDX-FileCopyrightText: 2002-2006 Marcus Geelnard
|
|
|
|
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy
|
|
|
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
2022-04-19 17:49:43 +02:00
|
|
|
|
2023-01-21 14:09:12 +01:00
|
|
|
package goglfw
|
2022-04-19 17:49:43 +02:00
|
|
|
|
|
|
|
func (t *tls) create() error {
|
|
|
|
if t.win32.allocated {
|
2023-01-21 14:09:12 +01:00
|
|
|
panic("goglfw: TLS must not be allocated")
|
2022-04-19 17:49:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
i, err := _TlsAlloc()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
t.win32.index = i
|
|
|
|
t.win32.allocated = true
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *tls) destroy() error {
|
|
|
|
if t.win32.allocated {
|
|
|
|
if err := _TlsFree(t.win32.index); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
t.win32.allocated = false
|
|
|
|
t.win32.index = 0
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *tls) get() (uintptr, error) {
|
|
|
|
if !t.win32.allocated {
|
2023-01-21 14:09:12 +01:00
|
|
|
panic("goglfw: TLS must be allocated")
|
2022-04-19 17:49:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return _TlsGetValue(t.win32.index)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *tls) set(value uintptr) error {
|
|
|
|
if !t.win32.allocated {
|
2023-01-21 14:09:12 +01:00
|
|
|
panic("goglfw: TLS must be allocated")
|
2022-04-19 17:49:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return _TlsSetValue(t.win32.index, value)
|
|
|
|
}
|