Blame sysdeps/mips/sys/tas.h

Packit 6c4009
/* Copyright (C) 2000-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
   Contributed by Maciej W. Rozycki <macro@ds2.pg.gda.pl>, 2000.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library.  If not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef _SYS_TAS_H
Packit 6c4009
#define _SYS_TAS_H 1
Packit 6c4009
Packit 6c4009
#include <features.h>
Packit 6c4009
#include <sgidefs.h>
Packit 6c4009
Packit 6c4009
__BEGIN_DECLS
Packit 6c4009
Packit 6c4009
extern int _test_and_set (int *__p, int __v)
Packit 6c4009
     __THROW __attribute__ ((__nomips16__));
Packit 6c4009
Packit 6c4009
#ifdef __USE_EXTERN_INLINES
Packit 6c4009
Packit 6c4009
# ifndef _EXTERN_INLINE
Packit 6c4009
#  define _EXTERN_INLINE __extern_inline
Packit 6c4009
# endif
Packit 6c4009
Packit 6c4009
_EXTERN_INLINE int __attribute__ ((__nomips16__))
Packit 6c4009
__NTH (_test_and_set (int *__p, int __v))
Packit 6c4009
{
Packit 6c4009
  int __r, __t;
Packit 6c4009
Packit 6c4009
  __asm__ __volatile__
Packit 6c4009
    ("/* Inline test and set */\n"
Packit 6c4009
     ".set	push\n\t"
Packit 6c4009
#if _MIPS_SIM == _ABIO32 && __mips < 2
Packit 6c4009
     ".set	mips2\n\t"
Packit 6c4009
#endif
Packit 6c4009
     "sync\n\t"
Packit 6c4009
     "1:\n\t"
Packit 6c4009
     "ll	%0,%3\n\t"
Packit 6c4009
     "move	%1,%4\n\t"
Packit 6c4009
     "beq	%0,%4,2f\n\t"
Packit 6c4009
     "sc	%1,%2\n\t"
Packit 6c4009
     "beqz	%1,1b\n"
Packit 6c4009
     "sync\n\t"
Packit 6c4009
     ".set	pop\n\t"
Packit 6c4009
     "2:\n\t"
Packit 6c4009
     "/* End test and set */"
Packit 6c4009
     : "=&r" (__r), "=&r" (__t), "=m" (*__p)
Packit 6c4009
     : "m" (*__p), "r" (__v)
Packit 6c4009
     : "memory");
Packit 6c4009
Packit 6c4009
  return __r;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#endif /* __USE_EXTERN_INLINES */
Packit 6c4009
Packit 6c4009
__END_DECLS
Packit 6c4009
Packit 6c4009
#endif /* sys/tas.h */