rcupdate.h revision 293194
1293194Shselasky/*- 2293194Shselasky * Copyright (c) 2016 Mellanox Technologies, Ltd. 3293194Shselasky * All rights reserved. 4293194Shselasky * 5293194Shselasky * Redistribution and use in source and binary forms, with or without 6293194Shselasky * modification, are permitted provided that the following conditions 7293194Shselasky * are met: 8293194Shselasky * 1. Redistributions of source code must retain the above copyright 9293194Shselasky * notice unmodified, this list of conditions, and the following 10293194Shselasky * disclaimer. 11293194Shselasky * 2. Redistributions in binary form must reproduce the above copyright 12293194Shselasky * notice, this list of conditions and the following disclaimer in the 13293194Shselasky * documentation and/or other materials provided with the distribution. 14293194Shselasky * 15293194Shselasky * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16293194Shselasky * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17293194Shselasky * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18293194Shselasky * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19293194Shselasky * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20293194Shselasky * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21293194Shselasky * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22293194Shselasky * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23293194Shselasky * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24293194Shselasky * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25293194Shselasky * 26293194Shselasky * $FreeBSD: head/sys/compat/linuxkpi/common/include/linux/rcupdate.h 293194 2016-01-05 12:22:45Z hselasky $ 27293194Shselasky */ 28293194Shselasky#ifndef _LINUX_RCUPDATE_H_ 29293194Shselasky#define _LINUX_RCUPDATE_H_ 30293194Shselasky 31293194Shselasky#include <sys/param.h> 32293194Shselasky#include <sys/lock.h> 33293194Shselasky#include <sys/sx.h> 34293194Shselasky 35293194Shselaskyextern struct sx linux_global_rcu_lock; 36293194Shselasky 37293194Shselaskystruct rcu_head { 38293194Shselasky}; 39293194Shselasky 40293194Shselaskytypedef void (*rcu_callback_t)(struct rcu_head *); 41293194Shselasky 42293194Shselaskystatic inline void 43293194Shselaskycall_rcu(struct rcu_head *ptr, rcu_callback_t func) 44293194Shselasky{ 45293194Shselasky sx_xlock(&linux_global_rcu_lock); 46293194Shselasky func(ptr); 47293194Shselasky sx_xunlock(&linux_global_rcu_lock); 48293194Shselasky} 49293194Shselasky 50293194Shselaskystatic inline void 51293194Shselaskyrcu_read_lock(void) 52293194Shselasky{ 53293194Shselasky sx_slock(&linux_global_rcu_lock); 54293194Shselasky} 55293194Shselasky 56293194Shselaskystatic inline void 57293194Shselaskyrcu_read_unlock(void) 58293194Shselasky{ 59293194Shselasky sx_sunlock(&linux_global_rcu_lock); 60293194Shselasky} 61293194Shselasky 62293194Shselaskystatic inline void 63293194Shselaskyrcu_barrier(void) 64293194Shselasky{ 65293194Shselasky sx_xlock(&linux_global_rcu_lock); 66293194Shselasky sx_xunlock(&linux_global_rcu_lock); 67293194Shselasky} 68293194Shselasky 69293194Shselaskystatic inline void 70293194Shselaskysynchronize_rcu(void) 71293194Shselasky{ 72293194Shselasky sx_xlock(&linux_global_rcu_lock); 73293194Shselasky sx_xunlock(&linux_global_rcu_lock); 74293194Shselasky} 75293194Shselasky 76293194Shselasky#endif /* _LINUX_RCUPDATE_H_ */ 77