mutex.h revision 1.4
11.4Skiyohara/* $NetBSD: mutex.h,v 1.4 2009/07/20 04:41:37 kiyohara Exp $ */ 21.1Skochi 31.1Skochi/*- 41.1Skochi * Copyright (c) 2008 The NetBSD Foundation, Inc. 51.1Skochi * All rights reserved. 61.1Skochi * 71.1Skochi * This code is derived from software contributed to The NetBSD Foundation 81.1Skochi * by Takayoshi Kochi. 91.1Skochi * 101.1Skochi * Redistribution and use in source and binary forms, with or without 111.1Skochi * modification, are permitted provided that the following conditions 121.1Skochi * are met: 131.1Skochi * 1. Redistributions of source code must retain the above copyright 141.1Skochi * notice, this list of conditions and the following disclaimer. 151.1Skochi * 2. Redistributions in binary form must reproduce the above copyright 161.1Skochi * notice, this list of conditions and the following disclaimer in the 171.1Skochi * documentation and/or other materials provided with the distribution. 181.1Skochi * 191.1Skochi * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Skochi * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Skochi * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Skochi * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Skochi * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Skochi * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Skochi * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Skochi * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Skochi * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Skochi * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Skochi * POSSIBILITY OF SUCH DAMAGE. 301.2Skochi */ 311.1Skochi 321.1Skochi#ifndef _IA64_MUTEX_H_ 331.1Skochi#define _IA64_MUTEX_H_ 341.1Skochi 351.4Skiyohara#ifndef __MUTEX_PRIVATE 361.4Skiyohara 371.1Skochistruct kmutex { 381.4Skiyohara uintptr_t mtx_pad1; 391.4Skiyohara uint32_t mtx_pad2[2]; 401.1Skochi}; 411.1Skochi 421.4Skiyohara#else 431.4Skiyohara 441.4Skiyoharastruct kmutex { 451.4Skiyohara volatile uintptr_t mtx_owner; 461.4Skiyohara ipl_cookie_t mtx_ipl; 471.4Skiyohara __cpu_simple_lock_t mtx_lock; 481.4Skiyohara}; 491.1Skochi 501.1Skochi 511.1Skochi/* XXX when we implement mutex_enter()/mutex_exit(), uncomment this 521.1Skochi#define __HAVE_MUTEX_STUBS 1 531.1Skochi*/ 541.1Skochi/* XXX when we implement mutex_spin_enter()/mutex_spin_exit(), uncomment this 551.1Skochi#define __HAVE_SPIN_MUTEX_STUBS 1 561.1Skochi*/ 571.1Skochi#define __HAVE_SIMPLE_MUTEXES 1 581.1Skochi 591.1Skochi/* 601.1Skochi * MUTEX_RECEIVE: no memory barrier required, atomic_cas implies a load fence. 611.1Skochi */ 621.1Skochi#define MUTEX_RECEIVE(mtx) /* nothing */ 631.1Skochi 641.1Skochi/* 651.1Skochi * MUTEX_GIVE: no memory barrier required, as _lock_cas() will take care of it. 661.1Skochi */ 671.1Skochi#define MUTEX_GIVE(mtx) /* nothing */ 681.1Skochi 691.1Skochi#define MUTEX_CAS(ptr, old, new) \ 701.1Skochi (atomic_cas_ulong((volatile unsigned long *)(ptr), (old), (new)) == (old)) 711.1Skochi 721.1Skochi#endif /* __MUTEX_PRIVATE */ 731.1Skochi 741.1Skochi#endif /* _IA64_MUTEX_H_ */ 75