2 * Copyright 2009, Colin Günther, coling@gmx.de.
3 * Copyright 2007, Hugo Santos. All Rights Reserved.
4 * Distributed under the terms of the MIT License.
10 #include <compat/sys/mutex.h>
13 // these methods are bit unfriendly, a bit too much panic() around
16 struct rw_lock ifnet_rwlock
;
17 struct mtx gIdStoreLock
;
21 mtx_init(struct mtx
*mutex
, const char *name
, const char *type
,
24 if ((options
& MTX_RECURSE
) != 0) {
25 recursive_lock_init_etc(&mutex
->u
.recursive
, name
,
26 MUTEX_FLAG_CLONE_NAME
);
28 mutex_init_etc(&mutex
->u
.mutex
.lock
, name
, MUTEX_FLAG_CLONE_NAME
);
29 mutex
->u
.mutex
.owner
= -1;
32 mutex
->type
= options
;
37 mtx_destroy(struct mtx
*mutex
)
39 if ((mutex
->type
& MTX_RECURSE
) != 0)
40 recursive_lock_destroy(&mutex
->u
.recursive
);
42 mutex_destroy(&mutex
->u
.mutex
.lock
);
49 mtx_init(&Giant
, "Banana Giant", NULL
, MTX_DEF
);
50 rw_lock_init(&ifnet_rwlock
, "gDevices");
51 mtx_init(&gIdStoreLock
, "Identity Store", NULL
, MTX_DEF
);
61 rw_lock_destroy(&ifnet_rwlock
);
62 mtx_destroy(&gIdStoreLock
);