1 /* Machine-dependent pthreads configuration and inline functions.
3 Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
4 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
5 This file is part of the GNU C Library.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 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 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; see the file COPYING.LIB. If not,
19 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 #define _PT_MACHINE_H 1
26 # define PT_EI extern inline __attribute__ ((always_inline))
29 extern long int testandset (int *spinlock
);
30 extern int __compare_and_swap (long int *p
, long int oldval
, long int newval
);
32 /* For multiprocessor systems, we want to ensure all memory accesses
33 are completed before we reset a lock. On other systems, we still
34 need to make sure that the compiler has flushed everything to memory. */
35 #define MEMORY_BARRIER() __asm__ __volatile__ ("bcr 15,0" : : : "memory")
37 /* Spinlock implementation; required. */
39 testandset (int *spinlock
)
49 : "=&d" (ret
), "+m" (*spinlock
)
56 /* Get some notion of the current stack. Need not be exactly the top
57 of the stack, just something somewhere in the current frame. */
58 #define CURRENT_STACK_FRAME stack_pointer
59 register char * stack_pointer
__asm__ ("15");
62 /* Return the thread descriptor for the current thread. */
63 # define THREAD_SELF ((pthread_descr) __builtin_thread_pointer ())
65 /* Initialize the thread-unique value. */
66 #define INIT_THREAD_SELF(descr, nr) __builtin_set_thread_pointer (descr)
68 /* Return the thread descriptor for the current thread.
69 64 bit S/390 uses access register 0 and 1 as "thread register". */
70 #define THREAD_SELF ({ \
71 register pthread_descr __self; \
72 __asm__ (" ear %0,%%a0\n" \
79 /* Initialize the thread-unique value. */
80 #define INIT_THREAD_SELF(descr, nr) ({ \
81 __asm__ (" sar %%a1,%0\n" \
84 : : "d" (descr) : "0" ); \
88 /* Access to data in the thread descriptor is easy. */
89 #define THREAD_GETMEM(descr, member) \
90 ((void) sizeof (descr), THREAD_SELF->member)
91 #define THREAD_GETMEM_NC(descr, member) \
92 ((void) sizeof (descr), THREAD_SELF->member)
93 #define THREAD_SETMEM(descr, member, value) \
94 ((void) sizeof (descr), THREAD_SELF->member = (value))
95 #define THREAD_SETMEM_NC(descr, member, value) \
96 ((void) sizeof (descr), THREAD_SELF->member = (value))
98 /* We want the OS to assign stack addresses. */
99 #define FLOATING_STACKS 1
101 /* Maximum size of the stack if the rlimit is unlimited. */
102 #define ARCH_STACK_MAX_SIZE 8*1024*1024
104 /* Compare-and-swap for semaphores. */
106 #define HAS_COMPARE_AND_SWAP
109 __compare_and_swap(long int *p
, long int oldval
, long int newval
)
113 __asm__
__volatile__(
119 : "=&d" (retval
), "+m" (*p
)
120 : "d" (oldval
) , "d" (newval
)
125 #endif /* pt-machine.h */