1/* BEGIN LICENSE BLOCK 2 * Version: CMPL 1.1 3 * 4 * The contents of this file are subject to the Cisco-style Mozilla Public 5 * License Version 1.1 (the "License"); you may not use this file except 6 * in compliance with the License. You may obtain a copy of the License 7 * at www.eclipse-clp.org/license. 8 * 9 * Software distributed under the License is distributed on an "AS IS" 10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 11 * the License for the specific language governing rights and limitations 12 * under the License. 13 * 14 * The Original Code is The ECLiPSe Constraint Logic Programming System. 15 * The Initial Developer of the Original Code is Cisco Systems, Inc. 16 * Portions created by the Initial Developer are 17 * Copyright (C) 1993-2006 Cisco Systems, Inc. All Rights Reserved. 18 * 19 * Contributor(s): ___________________________________. 20 * 21 * END LICENSE BLOCK */ 22/************************************************************************** 23 * 24 * IDENTIFICATION lock.S 25 * 26 * VERSION $Id: lock.S,v 1.1 2006/09/23 01:56:26 snovello Exp $ 27 * 28 * DESCRIPTION Processor dependent code for spin locks 29 * 30 **************************************************************************/ 31 32/* 33 * int mutex_lock_failed(int *plock) 34 * 35 * Set the lock to non-zero and return zero or non-zero 36 * corresponding to the old value. 37 */ 38 39#include "config.h" 40 41#if !defined(SVR4) && !defined(__ELF__) 42#define mutex_lock_failed _mutex_lock_failed 43#endif 44 45/*******************/ 46#ifdef sparc 47/*******************/ 48 49/* 50 * Some SPARC implementations don't have the swap instruction 51 * (it is emulated by the kernel). Therefore we use ldstub, 52 * which reads a byte into a register and overwrites it with ones. 53 * 54 * .global mutex_lock_failed 55 * mutex_lock_failed: 56 * add %g0,1,%o1 57 * swap [%o0],%o1 58 * retl 59 * xor %o1,1,%o0 60 */ 61 62 .global mutex_lock_failed 63mutex_lock_failed: 64 ldstub [%o0+3],%o1 65 retl 66 add %o1,%g0,%o0 67 68#endif /* sparc */ 69 70 71/*******************/ 72#ifdef mc68000 73/*******************/ 74 75 .text 76 .globl mutex_lock_failed 77mutex_lock_failed: 78 tas sp@(4)@(3) 79 bnes 1f 80 clrl d0 81 rts 821: moveq #1,d0 83 rts 84 85#endif /* mc68000 */ 86 87 88/*******************/ 89#ifdef m88k 90/*******************/ 91 92 version "03.00" 93 file "lock.S" 94 text 95 align 16 96 global mutex_lock_failed 97 type mutex_lock_failed,#function 98 99mutex_lock_failed: 100 or #r8,#r0,1 101 xmem #r8,#r2,#r0 102 jmp.n #r1 103 or #r2,#r0,#r8 104 105#endif /* m88k */ 106 107 108/*******************/ 109#ifdef i386 110/*******************/ 111 112 .text 113 .globl mutex_lock_failed 114mutex_lock_failed: 115 movl 4(%esp),%edx 116 movl $1,%eax 117 xchg %eax,(%edx) 118 ret 119 120#endif /* i386 */ 121 122 123/*******************/ 124#ifdef mips 125/*******************/ 126 127 .text 128 .globl mutex_lock_failed 129mutex_lock_failed: 130 ll $2, 0($4) 131 bne $2, 0, $32 132 li $15, 1 133 sc $15, 0($4) 134 beq $15, 0, $33 135 move $2, $0 136 j $31 137$33: 138 li $2, 1 139$32: 140 j $31 141 142#endif /* mips */ 143 144 145/*******************/ 146#if (defined(_PA_RISC1_0) || defined(_PA_RISC1_1)) 147/*******************/ 148 149; LDCWS instruction requires 16-byte alignment 150 151 .SPACE $TEXT$,SORT=8 152 .SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY,SORT=24 153mutex_lock_failed 154 .PROC 155 .CALLINFO CALLER,FRAME=0,ENTRY_SR=3 156 .ENTRY 157 LDCWS 0(0,%r26),%r31 ;offset 0x0 158 COMICLR,<> 0,%r31,%r28 ;offset 0x4 159 LDI 1,%r28 ;offset 0x8 160 .EXIT 161 BV,N %r0(%r2) ;offset 0xc 162 .PROCEND ;in=26;out=28; 163 164 .SPACE $TEXT$ 165 .SUBSPA $CODE$ 166 .SPACE $PRIVATE$,SORT=16 167 .SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31,SORT=16 168 .SPACE $TEXT$ 169 .SUBSPA $CODE$ 170 .EXPORT mutex_lock_failed,ENTRY,PRIV_LEV=3,ARGW0=GR,RTNVAL=GR 171 .END 172 173#endif /* _PA_RISC1_0 || _PA_RISC1_1 */ 174 175 176/*******************/ 177#ifdef __alpha__ 178/*******************/ 179 180.text 181 .align 3 182 .globl mutex_lock_failed 183 .ent mutex_lock_failed 184mutex_lock_failed: 185 .frame $30,0,$26,0 186 .prologue 0 187 ldl_l $0, 0($16) 188 bne $0, l1 189 bis $31, 0x1, $1 190 stl_c $1, 0($16) 191 beq $1, l1 192 bis $31, $31, $0 193 mb 194 ret $31, ($26), 1 195l1: bis $31, 0x1, $0 196 ret $31, ($26), 1 197 .end mutex_lock_failed 198 199#endif 200 201/*******************/ 202#if 0 /* #ifdef PowerPC */ 203/*******************/ 204atomic register swap 205mutex_lock_failed: 206 lwarx r5, 0, r3 207 stwcx r4, 0, r3 208 bne- mutex_lock_failed: 209#endif 210