pt-machine.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* Machine-dependent pthreads configuration and inline functions.
  2. FR-V version.
  3. Copyright (C) 2004 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. Contributed by Alexandre Oliva <aoliva@redhat.com>
  6. The GNU C Library is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU Lesser General Public License as
  8. published by the Free Software Foundation; either version 2.1 of the
  9. License, or (at your option) any later version.
  10. The GNU C Library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. Lesser General Public License for more details.
  14. You should have received a copy of the GNU Lesser General Public
  15. License along with the GNU C Library; see the file COPYING.LIB. If
  16. not, write to the Free Software Foundation, Inc.,
  17. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  18. #ifndef _PT_MACHINE_H
  19. #define _PT_MACHINE_H 1
  20. #include <features.h>
  21. #ifndef __ASSEMBLER__
  22. #ifndef PT_EI
  23. # define PT_EI __extern_always_inline
  24. #endif
  25. /* Spinlock implementation; required. */
  26. PT_EI long int
  27. testandset (int *spinlock)
  28. {
  29. int i = 1;
  30. __asm__ ("swap%I0 %M0, %1" : "+m"(*(volatile int *)spinlock), "+r"(i));
  31. return i;
  32. }
  33. /* We want the OS to assign stack addresses. */
  34. #define FLOATING_STACKS 1
  35. /* This symbol is defined by the ABI as the stack size requested by
  36. the main program. */
  37. extern char __stacksize;
  38. #define ARCH_STACK_MAX_SIZE ((unsigned long)&__stacksize)
  39. /* Memory barrier; default is to do nothing */
  40. #define MEMORY_BARRIER() __asm__ __volatile__("membar" : : : "memory")
  41. /* Write barrier. */
  42. #define WRITE_MEMORY_BARRIER() __asm__ __volatile__("membar" : : : "memory")
  43. /* Return the thread descriptor for the current thread. */
  44. register struct _pthread_descr_struct *THREAD_SELF __asm__ ("gr29");
  45. #define THREAD_SELF THREAD_SELF
  46. /* Initialize the thread-unique value. */
  47. #define INIT_THREAD_SELF(descr, nr) \
  48. (THREAD_SELF = descr)
  49. /* Get some notion of the current stack. Need not be exactly the top
  50. of the stack, just something somewhere in the current frame. */
  51. #define CURRENT_STACK_FRAME stack_pointer
  52. register char * stack_pointer __asm__ ("sp");
  53. #endif
  54. #endif /* pt-machine.h */