Plan 9 from Bell Labs’s /sys/src/ape/lib/ap/riscv64/tas.s

Copyright © 2021 Plan 9 Foundation
Distributed under the MIT License.
Download the Plan 9 distribution.


/*
 *	risc-v test-and-set
 *	assumes the standard A extension
 */

#include "/riscv64/include/atom.h"

#define ARG	8

#define MASK(w)	((1<<(w))-1)

/* atomically set *keyp non-zero and return previous contents */
TEXT _tas(SB), $-4			/* int _tas(ulong *keyp) */
	MOV	$1, R10
	FENCE_RW
	AMOW(Amoswap, AQ|RL, 10, ARG, ARG) /* R10->(R(ARG)), old (R(ARG))->ARG */
	FENCE_RW
	RET

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@plan9.bell-labs.com.