svn commit: r314772 - head/sys/compat/linuxkpi/common/include/linux

Hans Petter Selasky hselasky at FreeBSD.org
Mon Mar 6 12:22:07 UTC 2017


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)
 {


More information about the svn-src-head mailing list