#include "spinlock/spinlock.h"
#include "dlmalloc/malloc.h"

void *pico_mutex_init(void) {
  SpinLock *spinlock = dlmalloc(sizeof(*spinlock));
  spinlock_init(spinlock);
  return (void *)spinlock;
}

void pico_mutex_deinit(void *mtx) {
  if (mtx != NULL)
    dlfree(mtx);
}

void pico_mutex_lock(void *mtx) {
  SpinLock *spinlock = (SpinLock *)mtx;
  spinlock_acquire(spinlock);
}

void pico_mutex_unlock(void *mtx) {
  SpinLock *spinlock = (SpinLock *)mtx;
  spinlock_release(spinlock);
}
