2003-03-11 06:52:08 +00:00
|
|
|
/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
|
|
|
This file is part of the GNU C Library.
|
|
|
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with the GNU C Library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
02111-1307 USA. */
|
|
|
|
|
|
|
|
#include <sysdep.h>
|
|
|
|
#include <shlib-compat.h>
|
2003-03-12 10:28:07 +00:00
|
|
|
#include <pthread-errnos.h>
|
2003-03-11 06:52:08 +00:00
|
|
|
|
|
|
|
#ifndef UP
|
|
|
|
# define LOCK lock
|
|
|
|
#else
|
|
|
|
# define
|
|
|
|
#endif
|
|
|
|
|
|
|
|
.text
|
|
|
|
|
2003-03-13 01:51:12 +00:00
|
|
|
.globl sem_trywait
|
|
|
|
.type sem_trywait,@function
|
2003-03-11 06:52:08 +00:00
|
|
|
.align 16
|
2003-03-13 01:51:12 +00:00
|
|
|
sem_trywait:
|
2003-03-11 06:52:08 +00:00
|
|
|
movl (%rdi), %eax
|
|
|
|
2: testl %eax, %eax
|
|
|
|
jz 1f
|
|
|
|
|
2003-03-12 05:45:00 +00:00
|
|
|
leaq -1(%rax), %rdx
|
2003-03-11 06:52:08 +00:00
|
|
|
LOCK
|
|
|
|
cmpxchgl %edx, (%rdi)
|
|
|
|
jne 2b
|
|
|
|
|
|
|
|
xorl %eax, %eax
|
|
|
|
retq
|
|
|
|
|
|
|
|
1:
|
|
|
|
#if USE___THREAD
|
|
|
|
movq errno@gottpoff(%rip), %rdx
|
|
|
|
movl $EAGAIN, %fs:(%rdx)
|
|
|
|
#else
|
2003-03-11 19:40:00 +00:00
|
|
|
callq __errno_location@plt
|
2003-03-11 06:52:08 +00:00
|
|
|
movl $EAGAIN, (%rax)
|
|
|
|
#endif
|
|
|
|
orl $-1, %eax
|
|
|
|
retq
|
2003-03-13 01:51:12 +00:00
|
|
|
.size sem_trywait,.-sem_trywait
|
|
|
|
versioned_symbol(libpthread, __new_sem_trywait, sem_trywait, GLIBC_2_1)
|