1// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package glib
3
4import (
5 "github.com/ebitengine/purego"
6
7 "github.com/bnema/puregotk/pkg/core"
8)
9
10var xBitLock func(uintptr, int)
11
12// Sets the indicated @lock_bit in @address. If the bit is already
13// set, this call will block until g_bit_unlock() unsets the
14// corresponding bit.
15//
16// Attempting to lock on two different bits within the same integer is
17// not supported and will very probably cause deadlocks.
18//
19// The value of the bit that is set is (1u << @bit). If @bit is not
20// between 0 and 31 then the result is undefined.
21//
22// This function accesses @address atomically. All other accesses to
23// @address must be atomic in order for this function to work
24// reliably. While @address has a `volatile` qualifier, this is a historical
25// artifact and the argument passed to it should not be `volatile`.
26func BitLock(AddressVar uintptr, LockBitVar int) {
27
28 xBitLock(AddressVar, LockBitVar)
29
30}
31
32var xBitLockAndGet func(uintptr, uint, *int)
33
34// Sets the indicated @lock_bit in @address and atomically returns the new value.
35//
36// This is like [func@GLib.bit_lock], except it can atomically return the new value at
37// @address (right after obtaining the lock). Thus the value returned in @out_val
38// always has the @lock_bit set.
39func BitLockAndGet(AddressVar uintptr, LockBitVar uint, OutValVar *int) {
40
41 xBitLockAndGet(AddressVar, LockBitVar, OutValVar)
42
43}
44
45var xBitTrylock func(uintptr, int) bool
46
47// Sets the indicated @lock_bit in @address, returning %TRUE if
48// successful. If the bit is already set, returns %FALSE immediately.
49//
50// Attempting to lock on two different bits within the same integer is
51// not supported.
52//
53// The value of the bit that is set is (1u << @bit). If @bit is not
54// between 0 and 31 then the result is undefined.
55//
56// This function accesses @address atomically. All other accesses to
57// @address must be atomic in order for this function to work
58// reliably. While @address has a `volatile` qualifier, this is a historical
59// artifact and the argument passed to it should not be `volatile`.
60func BitTrylock(AddressVar uintptr, LockBitVar int) bool {
61
62 cret := xBitTrylock(AddressVar, LockBitVar)
63
64 return cret
65}
66
67var xBitUnlock func(uintptr, int)
68
69// Clears the indicated @lock_bit in @address. If another thread is
70// currently blocked in g_bit_lock() on this same bit then it will be
71// woken up.
72//
73// This function accesses @address atomically. All other accesses to
74// @address must be atomic in order for this function to work
75// reliably. While @address has a `volatile` qualifier, this is a historical
76// artifact and the argument passed to it should not be `volatile`.
77func BitUnlock(AddressVar uintptr, LockBitVar int) {
78
79 xBitUnlock(AddressVar, LockBitVar)
80
81}
82
83var xBitUnlockAndSet func(uintptr, uint, int, int)
84
85// This is like [func@GLib.bit_unlock] but also atomically sets @address to
86// @val.
87//
88// If @preserve_mask is not zero, then the @preserve_mask bits will be
89// preserved in @address and are not set to @val.
90//
91// Note that the @lock_bit bit will always be unset regardless of
92// @val, @preserve_mask and the currently set value in @address.
93func BitUnlockAndSet(AddressVar uintptr, LockBitVar uint, NewValVar int, PreserveMaskVar int) {
94
95 xBitUnlockAndSet(AddressVar, LockBitVar, NewValVar, PreserveMaskVar)
96
97}
98
99var xPointerBitLock func(uintptr, int)
100
101// This is equivalent to g_bit_lock, but working on pointers (or other
102// pointer-sized values).
103//
104// For portability reasons, you may only lock on the bottom 32 bits of
105// the pointer.
106//
107// While @address has a `volatile` qualifier, this is a historical
108// artifact and the argument passed to it should not be `volatile`.
109func PointerBitLock(AddressVar uintptr, LockBitVar int) {
110
111 xPointerBitLock(AddressVar, LockBitVar)
112
113}
114
115var xPointerBitLockAndGet func(uintptr, uint, *uintptr)
116
117// This is equivalent to g_bit_lock, but working on pointers (or other
118// pointer-sized values).
119//
120// For portability reasons, you may only lock on the bottom 32 bits of
121// the pointer.
122func PointerBitLockAndGet(AddressVar uintptr, LockBitVar uint, OutPtrVar *uintptr) {
123
124 xPointerBitLockAndGet(AddressVar, LockBitVar, OutPtrVar)
125
126}
127
128var xPointerBitLockMaskPtr func(uintptr, uint, bool, uintptr, uintptr) uintptr
129
130// This mangles @ptr as g_pointer_bit_lock() and g_pointer_bit_unlock()
131// do.
132func PointerBitLockMaskPtr(PtrVar uintptr, LockBitVar uint, SetVar bool, PreserveMaskVar uintptr, PreservePtrVar uintptr) uintptr {
133
134 cret := xPointerBitLockMaskPtr(PtrVar, LockBitVar, SetVar, PreserveMaskVar, PreservePtrVar)
135
136 return cret
137}
138
139var xPointerBitTrylock func(uintptr, int) bool
140
141// This is equivalent to g_bit_trylock(), but working on pointers (or
142// other pointer-sized values).
143//
144// For portability reasons, you may only lock on the bottom 32 bits of
145// the pointer.
146//
147// While @address has a `volatile` qualifier, this is a historical
148// artifact and the argument passed to it should not be `volatile`.
149func PointerBitTrylock(AddressVar uintptr, LockBitVar int) bool {
150
151 cret := xPointerBitTrylock(AddressVar, LockBitVar)
152
153 return cret
154}
155
156var xPointerBitUnlock func(uintptr, int)
157
158// This is equivalent to g_bit_unlock, but working on pointers (or other
159// pointer-sized values).
160//
161// For portability reasons, you may only lock on the bottom 32 bits of
162// the pointer.
163//
164// While @address has a `volatile` qualifier, this is a historical
165// artifact and the argument passed to it should not be `volatile`.
166func PointerBitUnlock(AddressVar uintptr, LockBitVar int) {
167
168 xPointerBitUnlock(AddressVar, LockBitVar)
169
170}
171
172var xPointerBitUnlockAndSet func(uintptr, uint, uintptr, uintptr)
173
174// This is equivalent to g_pointer_bit_unlock() and atomically setting
175// the pointer value.
176//
177// Note that the lock bit will be cleared from the pointer. If the unlocked
178// pointer that was set is not identical to @ptr, an assertion fails. In other
179// words, @ptr must have @lock_bit unset. This also means, you usually can
180// only use this on the lowest bits.
181func PointerBitUnlockAndSet(AddressVar uintptr, LockBitVar uint, PtrVar uintptr, PreserveMaskVar uintptr) {
182
183 xPointerBitUnlockAndSet(AddressVar, LockBitVar, PtrVar, PreserveMaskVar)
184
185}
186
187func init() {
188 core.SetPackageName("GLIB", "glib-2.0")
189 core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
190 var libs []uintptr
191 for _, libPath := range core.GetPaths("GLIB") {
192 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
193 if err != nil {
194 panic(err)
195 }
196 libs = append(libs, lib)
197 }
198
199 core.PuregoSafeRegister(&xBitLock, libs, "g_bit_lock")
200 core.PuregoSafeRegister(&xBitLockAndGet, libs, "g_bit_lock_and_get")
201 core.PuregoSafeRegister(&xBitTrylock, libs, "g_bit_trylock")
202 core.PuregoSafeRegister(&xBitUnlock, libs, "g_bit_unlock")
203 core.PuregoSafeRegister(&xBitUnlockAndSet, libs, "g_bit_unlock_and_set")
204 core.PuregoSafeRegister(&xPointerBitLock, libs, "g_pointer_bit_lock")
205 core.PuregoSafeRegister(&xPointerBitLockAndGet, libs, "g_pointer_bit_lock_and_get")
206 core.PuregoSafeRegister(&xPointerBitLockMaskPtr, libs, "g_pointer_bit_lock_mask_ptr")
207 core.PuregoSafeRegister(&xPointerBitTrylock, libs, "g_pointer_bit_trylock")
208 core.PuregoSafeRegister(&xPointerBitUnlock, libs, "g_pointer_bit_unlock")
209 core.PuregoSafeRegister(&xPointerBitUnlockAndSet, libs, "g_pointer_bit_unlock_and_set")
210
211}