pt-machine.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Machine-dependent pthreads configuration and inline functions.
  2. sparc version.
  3. Copyright (C) 1996-1998, 2000-2003 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. Contributed by Richard Henderson <rth@tamu.edu>.
  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, see <http://www.gnu.org/licenses/>. */
  17. #ifndef _PT_MACHINE_H
  18. #define _PT_MACHINE_H 1
  19. #ifndef PT_EI
  20. # define PT_EI __extern_always_inline
  21. #endif
  22. extern long int testandset (int *spinlock);
  23. extern int __compare_and_swap (long int *p, long int oldval, long int newval);
  24. /* Spinlock implementation; required. */
  25. PT_EI long int
  26. testandset (int *spinlock)
  27. {
  28. int ret;
  29. __asm__ __volatile__("ldstub %1,%0"
  30. : "=r"(ret), "=m"(*spinlock)
  31. : "m"(*spinlock));
  32. return ret;
  33. }
  34. /* Memory barrier; default is to do nothing */
  35. #define MEMORY_BARRIER() __asm__ __volatile__("stbar" : : : "memory")
  36. /* Get some notion of the current stack. Need not be exactly the top
  37. of the stack, just something somewhere in the current frame. */
  38. #define CURRENT_STACK_FRAME (stack_pointer + (2 * 64))
  39. register char *stack_pointer __asm__("%sp");
  40. /* Registers %g6 and %g7 are reserved by the ABI for "system use".
  41. %g7 is specified in the TLS ABI as thread pointer -- we do the same. */
  42. struct _pthread_descr_struct;
  43. register struct _pthread_descr_struct *__thread_self __asm__("%g7");
  44. /* Return the thread descriptor for the current thread. */
  45. #define THREAD_SELF __thread_self
  46. /* Initialize the thread-unique value. */
  47. #define INIT_THREAD_SELF(descr, nr) (__thread_self = (descr))
  48. /* Access to data in the thread descriptor is easy. */
  49. #define THREAD_GETMEM(descr, member) \
  50. ((void) sizeof (descr), THREAD_SELF->member)
  51. #define THREAD_GETMEM_NC(descr, member) \
  52. ((void) sizeof (descr), THREAD_SELF->member)
  53. #define THREAD_SETMEM(descr, member, value) \
  54. ((void) sizeof (descr), THREAD_SELF->member = (value))
  55. #define THREAD_SETMEM_NC(descr, member, value) \
  56. ((void) sizeof (descr), THREAD_SELF->member = (value))
  57. /* We want the OS to assign stack addresses. */
  58. #define FLOATING_STACKS 1
  59. /* Maximum size of the stack if the rlimit is unlimited. */
  60. #define ARCH_STACK_MAX_SIZE 8*1024*1024
  61. #endif /* pt-machine.h */