1 /* Machine-dependent pthreads configuration and inline functions.
3 Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
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
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
21 #define _PT_MACHINE_H 1
26 # include <stddef.h> /* For offsetof. */
27 # include <stdlib.h> /* For abort(). */
28 # include <asm/prctl.h>
32 # define PT_EI __extern_always_inline
35 /* Get some notion of the current stack. Need not be exactly the top
36 of the stack, just something somewhere in the current frame. */
37 # define CURRENT_STACK_FRAME stack_pointer
38 register char * stack_pointer __asm__ ("%rsp") __attribute_used__;
41 /* Spinlock implementation; required. */
43 testandset (int *__spinlock)
47 __asm__ __volatile__ (
49 : "=r"(ret), "=m"(*__spinlock)
50 : "0"(1), "m"(*__spinlock)
57 /* Compare-and-swap for semaphores. */
58 # define HAS_COMPARE_AND_SWAP
61 __compare_and_swap (long int *__p, long int __oldval, long int __newval)
66 __asm__ __volatile__ ("lock; cmpxchgq %3, %1; sete %0"
67 : "=q" (ret), "=m" (*__p), "=a" (readval)
68 : "r" (__newval), "m" (*__p), "a" (__oldval)
73 #endif /* !__ASSEMBLER__ */
75 /* We want the OS to assign stack addresses. */
76 #define FLOATING_STACKS 1
78 /* Maximum size of the stack if the rlimit is unlimited. */
79 #define ARCH_STACK_MAX_SIZE 32*1024*1024
81 /* The ia32e really want some help to prevent overheating. */
82 #define BUSY_WAIT_NOP __asm__ ("rep; nop")
84 #endif /* pt-machine.h */