diff options
author | Andy Wingo <wingo@pobox.com> | 2025-04-11 14:10:41 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2025-04-11 14:10:41 +0200 |
commit | db181e67ff482ab08cbdb0c1a88997b3a886f900 (patch) | |
tree | 6d16fbca515ae3cf506a9d16dbc89c472446e5d9 /libguile/whippet/src/gc-lock.h | |
parent | af96820e072d18c49ac03e80c6f3466d568dc77d (diff) | |
parent | f909438596f63ecd44c5b9a28385260714857361 (diff) | |
download | guile-db181e67ff482ab08cbdb0c1a88997b3a886f900.tar.gz |
Merged Whippet into libguile/whippet
Diffstat (limited to 'libguile/whippet/src/gc-lock.h')
-rw-r--r-- | libguile/whippet/src/gc-lock.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libguile/whippet/src/gc-lock.h b/libguile/whippet/src/gc-lock.h new file mode 100644 index 000000000..89c5f4ac0 --- /dev/null +++ b/libguile/whippet/src/gc-lock.h @@ -0,0 +1,24 @@ +#ifndef GC_LOCK_H +#define GC_LOCK_H + +#include <pthread.h> +#include "gc-assert.h" + +struct gc_lock { + pthread_mutex_t *lock; +}; + +static struct gc_lock +gc_lock_acquire(pthread_mutex_t *lock) { + pthread_mutex_lock(lock); + return (struct gc_lock){ lock }; +} + +static void +gc_lock_release(struct gc_lock *lock) { + GC_ASSERT(lock->lock); + pthread_mutex_unlock(lock->lock); + lock->lock = NULL; +} + +#endif // GC_LOCK_H |