1 /* 2 * Copyright 2007, Hugo Santos. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Hugo Santos, hugosantos@gmail.com 7 */ 8 9 #include <KernelExport.h> 10 11 #include <compat/sys/mutex.h> 12 13 14 status_t init_mutexes(void); 15 void uninit_mutexes(void); 16 17 18 // these methods are bit unfriendly, a bit too much panic() around 19 20 struct mutex Giant; 21 22 23 void 24 mtx_init(struct mtx *m, const char *name, const char *type, int opts) 25 { 26 if (opts == MTX_DEF) { 27 if (mutex_init(&m->u.mutex, name) < B_OK) 28 panic("Panic! Dance like it's 1979, we ran out of semaphores"); 29 } else if (opts == MTX_RECURSE) { 30 if (recursive_lock_init(&m->u.recursive, name) < B_OK) 31 panic("Hell just froze as someone was trying to init a recursive mutex."); 32 } else 33 panic("Uh-oh, someone is pressing the wrong buttons"); 34 35 m->type = opts; 36 } 37 38 39 void 40 mtx_destroy(struct mtx *m) 41 { 42 if (m->type == MTX_DEF) { 43 mutex_destroy(&m->u.mutex); 44 } else if (m->type == MTX_RECURSE) { 45 recursive_lock_destroy(&m->u.recursive); 46 } else 47 panic("Uh-oh, someone is pressing the wrong buttons"); 48 } 49 50 51 status_t 52 init_mutexes() 53 { 54 return B_ERROR; 55 } 56 57 58 void 59 uninit_mutexes() 60 { 61 } 62 63