pt-machine.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Machine-dependent pthreads configuration and inline functions.
  2. Copyright (C) 1996, 1998, 2000, 2002 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Richard Henderson <rth@tamu.edu>.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License as
  7. published by the Free Software Foundation; either version 2.1 of the
  8. License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; see the file COPYING.LIB. If
  15. not, write to the Free Software Foundation, Inc.,
  16. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. #ifndef _PT_MACHINE_H
  18. #define _PT_MACHINE_H 1
  19. #ifndef PT_EI
  20. # define PT_EI extern inline
  21. #endif
  22. extern long int testandset (int *spinlock);
  23. #include <asm/unistd.h>
  24. /* Spinlock implementation; required. */
  25. /* The semantics of the TESTSET instruction cannot be guaranteed. We cannot
  26. easily move all locks used by linux kernel to non-cacheable memory.
  27. EXCPT 0x4 is used to trap into kernel to do the atomic testandset.
  28. It's ugly. But it's the only thing we can do now.
  29. The handler of EXCPT 0x4 expects the address of the lock is passed through
  30. R0. And the result is returned by R0. */
  31. PT_EI long int
  32. testandset (int *spinlock)
  33. {
  34. long int res;
  35. asm volatile ("R0 = %2; P0 = %4; EXCPT 0; %0 = R0;"
  36. : "=d" (res), "=m" (*spinlock)
  37. : "d" (spinlock), "m" (*spinlock),
  38. "ida" (__NR_bfin_spinlock)
  39. :"R0", "P0", "cc");
  40. return res;
  41. }
  42. #endif /* pt-machine.h */