mutex.h revision 1.1
11.1Skochi/* $NetBSD: mutex.h,v 1.1 2008/03/20 09:09:20 kochi 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 * 3. All advertising materials mentioning features or use of this software 191.1Skochi * must display the following acknowledgement: 201.1Skochi * This product includes software developed by the NetBSD 211.1Skochi * Foundation, Inc. and its contributors. 221.1Skochi * 4. Neither the name of The NetBSD Foundation nor the names of its 231.1Skochi * contributors may be used to endorse or promote products derived 241.1Skochi * from this software without specific prior written permission. 251.1Skochi * 261.1Skochi * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 271.1Skochi * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 281.1Skochi * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 291.1Skochi * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 301.1Skochi * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 311.1Skochi * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 321.1Skochi * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 331.1Skochi * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 341.1Skochi * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 351.1Skochi * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 361.1Skochi * POSSIBILITY OF SUCH DAMAGE. 371.1Skochi*/ 381.1Skochi 391.1Skochi#ifndef _IA64_MUTEX_H_ 401.1Skochi#define _IA64_MUTEX_H_ 411.1Skochi 421.1Skochistruct kmutex { 431.1Skochi union { 441.1Skochi volatile uintptr_t mtxa_owner; 451.1Skochi#ifdef __MUTEX_PRIVATE 461.1Skochi struct { 471.1Skochi volatile uint8_t mtxs_dummy; 481.1Skochi ipl_cookie_t mtxs_ipl; 491.1Skochi __cpu_simple_lock_t mtxs_lock; 501.1Skochi volatile uint8_t mtxs_unused; 511.1Skochi } s; 521.1Skochi#endif 531.1Skochi } u; 541.1Skochi}; 551.1Skochi 561.1Skochi#ifdef __MUTEX_PRIVATE 571.1Skochi 581.1Skochi/* uintptr_t */ 591.1Skochi#define mtx_owner u.mtxa_owner 601.1Skochi/* ipl_cookie_t */ 611.1Skochi#define mtx_ipl u.s.mtxs_ipl 621.1Skochi/* __cpu_simple_lock_t */ 631.1Skochi#define mtx_lock u.s.mtxs_lock 641.1Skochi 651.1Skochi/* XXX when we implement mutex_enter()/mutex_exit(), uncomment this 661.1Skochi#define __HAVE_MUTEX_STUBS 1 671.1Skochi*/ 681.1Skochi/* XXX when we implement mutex_spin_enter()/mutex_spin_exit(), uncomment this 691.1Skochi#define __HAVE_SPIN_MUTEX_STUBS 1 701.1Skochi*/ 711.1Skochi#define __HAVE_SIMPLE_MUTEXES 1 721.1Skochi 731.1Skochi/* 741.1Skochi * MUTEX_RECEIVE: no memory barrier required, atomic_cas implies a load fence. 751.1Skochi */ 761.1Skochi#define MUTEX_RECEIVE(mtx) /* nothing */ 771.1Skochi 781.1Skochi/* 791.1Skochi * MUTEX_GIVE: no memory barrier required, as _lock_cas() will take care of it. 801.1Skochi */ 811.1Skochi#define MUTEX_GIVE(mtx) /* nothing */ 821.1Skochi 831.1Skochi#define MUTEX_CAS(ptr, old, new) \ 841.1Skochi (atomic_cas_ulong((volatile unsigned long *)(ptr), (old), (new)) == (old)) 851.1Skochi 861.1Skochi#endif /* __MUTEX_PRIVATE */ 871.1Skochi 881.1Skochi#endif /* _IA64_MUTEX_H_ */ 89