Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/_rwlock.h
| Show All 22 Lines | |||||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| * SUCH DAMAGE. | * SUCH DAMAGE. | ||||
| */ | */ | ||||
| #ifndef _SYS__RWLOCK_H_ | #ifndef _SYS__RWLOCK_H_ | ||||
| #define _SYS__RWLOCK_H_ | #define _SYS__RWLOCK_H_ | ||||
| #include <sys/_types.h> | |||||
| #include <sys/_lock.h> | |||||
| #include <machine/param.h> | #include <machine/param.h> | ||||
| /* | /* | ||||
| * Reader/writer lock. | * Reader/writer lock. | ||||
| * | * | ||||
| * All reader/writer lock implementations must always have a member | * All reader/writer lock implementations must always have a member | ||||
| * called rw_lock. Other locking primitive structures are not allowed to | * called rw_lock. Other locking primitive structures are not allowed to | ||||
| * use this name for their members. | * use this name for their members. | ||||
| * If this rule needs to change, the bits in the reader/writer lock | * If this rule needs to change, the bits in the reader/writer lock | ||||
| * implementation must be modified appropriately. | * implementation must be modified appropriately. | ||||
| */ | */ | ||||
| struct rwlock { | struct rwlock { | ||||
| struct lock_object lock_object; | struct lock_object lock_object; | ||||
| volatile uintptr_t rw_lock; | volatile __uintptr_t rw_lock; | ||||
| }; | }; | ||||
| /* | /* | ||||
| * Members of struct rwlock_padalign must mirror members of struct rwlock. | * Members of struct rwlock_padalign must mirror members of struct rwlock. | ||||
| * rwlock_padalign rwlocks can use the rwlock(9) API transparently without | * rwlock_padalign rwlocks can use the rwlock(9) API transparently without | ||||
| * modification. | * modification. | ||||
| * Pad-aligned rwlocks used within structures should generally be the | * Pad-aligned rwlocks used within structures should generally be the | ||||
| * first member of the struct. Otherwise, the compiler can generate | * first member of the struct. Otherwise, the compiler can generate | ||||
| * additional padding for the struct to keep a correct alignment for | * additional padding for the struct to keep a correct alignment for | ||||
| * the rwlock. | * the rwlock. | ||||
| */ | */ | ||||
| struct rwlock_padalign { | struct rwlock_padalign { | ||||
| struct lock_object lock_object; | struct lock_object lock_object; | ||||
| volatile uintptr_t rw_lock; | volatile __uintptr_t rw_lock; | ||||
| } __aligned(CACHE_LINE_SIZE); | } __aligned(CACHE_LINE_SIZE); | ||||
| #endif /* !_SYS__RWLOCK_H_ */ | #endif /* !_SYS__RWLOCK_H_ */ | ||||