TCP: Fixed RTO update and dup ACKs generation.
[haiku.git] / src / libs / compat / freebsd_network / mutex.c
blobd7589a8cbe72b85cb5696df8903f679913493750
1 /*
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.
5 */
8 #include "device.h"
10 #include <compat/sys/mutex.h>
13 // these methods are bit unfriendly, a bit too much panic() around
15 struct mtx Giant;
16 struct rw_lock ifnet_rwlock;
17 struct mtx gIdStoreLock;
20 void
21 mtx_init(struct mtx *mutex, const char *name, const char *type,
22 int options)
24 if ((options & MTX_RECURSE) != 0) {
25 recursive_lock_init_etc(&mutex->u.recursive, name,
26 MUTEX_FLAG_CLONE_NAME);
27 } else {
28 mutex_init_etc(&mutex->u.mutex.lock, name, MUTEX_FLAG_CLONE_NAME);
29 mutex->u.mutex.owner = -1;
32 mutex->type = options;
36 void
37 mtx_destroy(struct mtx *mutex)
39 if ((mutex->type & MTX_RECURSE) != 0)
40 recursive_lock_destroy(&mutex->u.recursive);
41 else
42 mutex_destroy(&mutex->u.mutex.lock);
46 status_t
47 init_mutexes()
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);
53 return B_OK;
57 void
58 uninit_mutexes()
60 mtx_destroy(&Giant);
61 rw_lock_destroy(&ifnet_rwlock);
62 mtx_destroy(&gIdStoreLock);