Chroma/chroma/inc/lainlib/mutex/spinlock.h
Curle 58a944ee6e
Add startings of new kernel-side library
Lainlib is libk. It is separate from Helix, which will become the 3D engine common to the kernel and the userspace.
2020-08-31 21:44:54 +01:00

23 lines
451 B
C

#pragma once
/************************
*** Team Kitty, 2020 ***
*** Chroma ***
***********************/
typedef volatile int spinlock_t;
/* A set of macros that acquire and release a mutex spinlock. */
//TODO: this *needs* to be moved to a kernel header.
#define SPINLOCK(name) \
while( !__sync_bool_compare_and_swap(name, 0, 1)); \
__sync_synchronize();
#define SPUNLOCK(name) \
__sync_synchronize(); \
name = 0;