Implement DECLARE_RWSEM() macro in the LinuxKPI to initialize a

Read-Write semaphore during module init time.

MFC after:		1 week
Sponsored by:		Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2017-03-06 12:22:05 +00:00
parent 684bcfec89
commit 19bf8ef562

View file

@ -35,6 +35,7 @@
#include <sys/lock.h>
#include <sys/sx.h>
#include <sys/libkern.h>
#include <sys/kernel.h>
struct rw_semaphore {
struct sx sx;
@ -61,6 +62,14 @@ struct rw_semaphore {
#define _rwsem_name(...) __rwsem_name(__VA_ARGS__)
#define rwsem_name(name) _rwsem_name(name, __FILE__, __LINE__)
#define DECLARE_RWSEM(name) \
struct rw_semaphore name; \
static void name##_rwsem_init(void *arg) \
{ \
linux_init_rwsem(&name, rwsem_name(#name)) \
} \
SYSINIT(name, SI_SUB_LOCKS, SI_ORDER_SECOND, name##_rwsem_init, NULL)
static inline void
linux_init_rwsem(struct rw_semaphore *rw, const char *name)
{