Text file src/internal/runtime/atomic/sys_nonlinux_arm.s

     1  // Copyright 2015 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build !linux
     6  
     7  #include "textflag.h"
     8  
     9  // TODO(minux): this is only valid for ARMv6+
    10  // func armcas(ptr *int32, old int32, new int32) bool
    11  // Atomically:
    12  //	if *ptr == old {
    13  //		*ptr = new
    14  //		return true
    15  //	} else {
    16  //		return false
    17  //	}
    18  TEXT	·Cas(SB),NOSPLIT,$0
    19  	JMP	·armcas(SB)
    20  
    21  // Non-linux OSes support only single processor machines before ARMv7.
    22  // So we don't need memory barriers if goarm < 7. And we fail loud at
    23  // startup (runtime.checkgoarm) if it is a multi-processor but goarm < 7.
    24  
    25  TEXT	·Load(SB),NOSPLIT|NOFRAME,$0-8
    26  	MOVW	addr+0(FP), R0
    27  	MOVW	(R0), R1
    28  
    29  	MOVB	runtime·goarm(SB), R11
    30  	CMP	$7, R11
    31  	BLT	2(PC)
    32  	DMB	MB_ISH
    33  
    34  	MOVW	R1, ret+4(FP)
    35  	RET
    36  
    37  TEXT	·Store(SB),NOSPLIT,$0-8
    38  	MOVW	addr+0(FP), R1
    39  	MOVW	v+4(FP), R2
    40  
    41  	MOVB	runtime·goarm(SB), R8
    42  	CMP	$7, R8
    43  	BLT	2(PC)
    44  	DMB	MB_ISH
    45  
    46  	MOVW	R2, (R1)
    47  
    48  	CMP	$7, R8
    49  	BLT	2(PC)
    50  	DMB	MB_ISH
    51  	RET
    52  
    53  TEXT	·Load8(SB),NOSPLIT|NOFRAME,$0-5
    54  	MOVW	addr+0(FP), R0
    55  	MOVB	(R0), R1
    56  
    57  	MOVB	runtime·goarm(SB), R11
    58  	CMP	$7, R11
    59  	BLT	2(PC)
    60  	DMB	MB_ISH
    61  
    62  	MOVB	R1, ret+4(FP)
    63  	RET
    64  
    65  TEXT	·Store8(SB),NOSPLIT,$0-5
    66  	MOVW	addr+0(FP), R1
    67  	MOVB	v+4(FP), R2
    68  
    69  	MOVB	runtime·goarm(SB), R8
    70  	CMP	$7, R8
    71  	BLT	2(PC)
    72  	DMB	MB_ISH
    73  
    74  	MOVB	R2, (R1)
    75  
    76  	CMP	$7, R8
    77  	BLT	2(PC)
    78  	DMB	MB_ISH
    79  	RET
    80  
    81  

View as plain text