From e78ad19f6b090c1826c061f95a970450b6784ce2 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 21 Oct 2009 20:26:40 +0000 Subject: [PATCH] Added new methods introduced in freebsd head that encapsulate macros to allow better binary compatibility if the locking way ever changes. These are not really useful, but needed for newer drivers sourcecode. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33714 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../freebsd_network/compat/net/if_var.h | 10 ++++++ src/libs/compat/freebsd_network/if.c | 33 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/libs/compat/freebsd_network/compat/net/if_var.h b/src/libs/compat/freebsd_network/compat/net/if_var.h index eb34267296..067b84b8a0 100644 --- a/src/libs/compat/freebsd_network/compat/net/if_var.h +++ b/src/libs/compat/freebsd_network/compat/net/if_var.h @@ -239,6 +239,16 @@ typedef void if_init_f_t(void *); #define IF_ADDR_LOCK_DESTROY(if) mtx_destroy(&(if)->if_addr_mtx) #define IF_ADDR_LOCK(if) mtx_lock(&(if)->if_addr_mtx) #define IF_ADDR_UNLOCK(if) mtx_unlock(&(if)->if_addr_mtx) + +/* + * Function variations on locking macros intended to be used by loadable + * kernel modules in order to divorce them from the internals of address list + * locking. + */ +void if_addr_rlock(struct ifnet *ifp); /* if_addrhead */ +void if_addr_runlock(struct ifnet *ifp); /* if_addrhead */ +void if_maddr_rlock(struct ifnet *ifp); /* if_multiaddrs */ +void if_maddr_runlock(struct ifnet *ifp); /* if_multiaddrs */ #define IF_ADDR_LOCK_ASSERT(if) mtx_assert(&(if)->if_addr_mtx, MA_OWNED) /* diff --git a/src/libs/compat/freebsd_network/if.c b/src/libs/compat/freebsd_network/if.c index b2f88a0166..f8204024ce 100644 --- a/src/libs/compat/freebsd_network/if.c +++ b/src/libs/compat/freebsd_network/if.c @@ -413,3 +413,36 @@ ether_ioctl(struct ifnet *ifp, u_long command, caddr_t data) return 0; } +/* + * Wrapper functions for struct ifnet address list locking macros. These are + * used by kernel modules to avoid encoding programming interface or binary + * interface assumptions that may be violated when kernel-internal locking + * approaches change. + */ +void +if_addr_rlock(struct ifnet *ifp) +{ + + IF_ADDR_LOCK(ifp); +} + +void +if_addr_runlock(struct ifnet *ifp) +{ + + IF_ADDR_UNLOCK(ifp); +} + +void +if_maddr_rlock(struct ifnet *ifp) +{ + + IF_ADDR_LOCK(ifp); +} + +void +if_maddr_runlock(struct ifnet *ifp) +{ + + IF_ADDR_UNLOCK(ifp); +}