Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Mar 2017 12:22:06 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r314772 - head/sys/compat/linuxkpi/common/include/linux
Message-ID:  <201703061222.v26CM6ej045160@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Mon Mar  6 12:22:05 2017
New Revision: 314772
URL: https://svnweb.freebsd.org/changeset/base/314772

Log:
  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

Modified:
  head/sys/compat/linuxkpi/common/include/linux/rwsem.h

Modified: head/sys/compat/linuxkpi/common/include/linux/rwsem.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/rwsem.h	Mon Mar  6 12:20:56 2017	(r314771)
+++ head/sys/compat/linuxkpi/common/include/linux/rwsem.h	Mon Mar  6 12:22:05 2017	(r314772)
@@ -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)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703061222.v26CM6ej045160>