summaryrefslogtreecommitdiff
path: root/libpthread/nptl/sysdeps/csky/pthread_spin_trylock.S
blob: 2682e4cb9577ca87a57dd423f6103a30cef3dbf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * Copyright (C) 2017 Hangzhou C-SKY Microsystems co.,ltd.
 *
 * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB
 * in this tarball.
 */

#define _ERRNO_H 1
#include <bits/errno.h>
#include <sysdep.h>

.text
ENTRY (pthread_spin_trylock)
	mov	a2, a0
	movi	a0, 0
	movi	a1, 1
	trap	2		// trap 2 use to cmpxchg
	cmpnei	a0, 0
	bf	1f
	movi	a0, EBUSY
1:
	jmp	r15
END (pthread_spin_trylock)