Back to index

glibc  2.9
pt-machine.h
Go to the documentation of this file.
00001 /* Machine-dependent pthreads configuration and inline functions.
00002    sparc version.
00003    Copyright (C) 1996-1998, 2000-2003 Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005    Contributed by Richard Henderson <rth@tamu.edu>.
00006 
00007    The GNU C Library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Lesser General Public License as
00009    published by the Free Software Foundation; either version 2.1 of the
00010    License, or (at your option) any later version.
00011 
00012    The GNU C Library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Lesser General Public License for more details.
00016 
00017    You should have received a copy of the GNU Lesser General Public
00018    License along with the GNU C Library; see the file COPYING.LIB.  If not,
00019    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020    Boston, MA 02111-1307, USA.  */
00021 
00022 #ifndef _PT_MACHINE_H
00023 #define _PT_MACHINE_H   1
00024 
00025 #ifndef PT_EI
00026 # define PT_EI extern inline __attribute__ ((always_inline))
00027 #endif
00028 
00029 extern long int testandset (int *spinlock);
00030 extern int __compare_and_swap (long int *p, long int oldval, long int newval);
00031 
00032 /* Spinlock implementation; required.  */
00033 PT_EI long int
00034 testandset (int *spinlock)
00035 {
00036   int ret;
00037 
00038   __asm__ __volatile__("ldstub %1,%0"
00039        : "=r"(ret), "=m"(*spinlock)
00040        : "m"(*spinlock));
00041 
00042   return ret;
00043 }
00044 
00045 
00046 /* Memory barrier; default is to do nothing */
00047 #define MEMORY_BARRIER() __asm__ __volatile__("stbar" : : : "memory")
00048 
00049 
00050 /* Get some notion of the current stack.  Need not be exactly the top
00051    of the stack, just something somewhere in the current frame.  */
00052 #define CURRENT_STACK_FRAME  (stack_pointer + (2 * 64))
00053 register char *stack_pointer __asm__("%sp");
00054 
00055 
00056 /* Registers %g6 and %g7 are reserved by the ABI for "system use".
00057    %g7 is specified in the TLS ABI as thread pointer -- we do the same.  */
00058 struct _pthread_descr_struct;
00059 register struct _pthread_descr_struct *__thread_self __asm__("%g7");
00060 
00061 /* Return the thread descriptor for the current thread.  */
00062 #define THREAD_SELF  __thread_self
00063 
00064 /* Initialize the thread-unique value.  */
00065 #define INIT_THREAD_SELF(descr, nr)  (__thread_self = (descr))
00066 
00067 /* Access to data in the thread descriptor is easy.  */
00068 #define THREAD_GETMEM(descr, member) \
00069   ((void) sizeof (descr), THREAD_SELF->member)
00070 #define THREAD_GETMEM_NC(descr, member) \
00071   ((void) sizeof (descr), THREAD_SELF->member)
00072 #define THREAD_SETMEM(descr, member, value) \
00073   ((void) sizeof (descr), THREAD_SELF->member = (value))
00074 #define THREAD_SETMEM_NC(descr, member, value) \
00075   ((void) sizeof (descr), THREAD_SELF->member = (value))
00076 
00077 /* We want the OS to assign stack addresses.  */
00078 #define FLOATING_STACKS 1
00079 
00080 /* Maximum size of the stack if the rlimit is unlimited.  */
00081 #define ARCH_STACK_MAX_SIZE     8*1024*1024
00082 
00083 #endif /* pt-machine.h */