static naRef f_semdown(naContext c, naRef me, int argc, naRef* args) { if(argc > 0 && naGhost_type(args[0]) == &SemType) { naModUnlock(); naSemDown(naGhost_ptr(args[0])); naModLock(); } return naNil(); }
static naRef f_semup(naContext c, naRef me, int argc, naRef* args) { if(argc > 0 && naGhost_type(args[0]) == &SemType) naSemUp(naGhost_ptr(args[0]), 1); return naNil(); }
static naRef f_unlock(naContext c, naRef me, int argc, naRef* args) { if(argc > 0 && naGhost_type(args[0]) == &LockType) naUnlock(naGhost_ptr(args[0])); return naNil(); }
static struct naIOGhost* ioghost(naRef r) { if(naGhost_type(r) == &naIOGhostType && IOGHOST(r)->handle) return naGhost_ptr(r); return 0; }