1 #include <u.h> 2 #include <libc.h> 3 #include "iotrack.h" 4 #include "dat.h" 5 #include "fns.h" 6 7 void 8 lock(Lock *l) 9 { 10 if (l->key) 11 panic("lock"); 12 l->key = 1; 13 } 14 15 void 16 unlock(Lock *l) 17 { 18 if (!l->key) 19 panic("unlock"); 20 l->key = 0; 21 } 22 23 int 24 canlock(Lock *l) 25 { 26 if (l->key) 27 return 0; 28 l->key = 1; 29 return 1; 30 } 31