pt-machine.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Cloned for uClibc by Paul Mundt, December 2003 */
  2. /* Modified by SuperH, Inc. September 2003 */
  3. /* Machine-dependent pthreads configuration and inline functions.
  4. SH5 version.
  5. Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
  6. This file is part of the GNU C Library.
  7. Contributed by Niibe Yutaka <gniibe@m17n.org>.
  8. The GNU C Library is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU Library General Public License as
  10. published by the Free Software Foundation; either version 2 of the
  11. License, or (at your option) any later version.
  12. The GNU C Library is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. Library General Public License for more details.
  16. You should have received a copy of the GNU Library General Public
  17. License along with the GNU C Library; see the file COPYING.LIB. If not,
  18. see <http://www.gnu.org/licenses/>. */
  19. #include "pt-machine.h"
  20. /* Spinlock implementation; required. */
  21. /* The SH5 does not have a suitable test-and-set instruction (SWAP only
  22. operates on an aligned quad word). So we use the SH4 version instead.
  23. This must be seperately compiled in SHcompact mode, so it cannot be
  24. inline. */
  25. long int testandset (int *spinlock)
  26. {
  27. int ret;
  28. __asm__ __volatile__(
  29. "tas.b @%1\n\t"
  30. "movt %0"
  31. : "=r" (ret)
  32. : "r" (spinlock)
  33. : "memory", "cc");
  34. return (ret == 0);
  35. }