summaryrefslogtreecommitdiff
path: root/nptl/sysdeps/unix/sysv/linux/powerpc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
commit0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch)
tree2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /nptl/sysdeps/unix/sysv/linux/powerpc
parent7d58530341304d403a6626d7f7a1913165fe2f32 (diff)
2.5-18.1
Diffstat (limited to 'nptl/sysdeps/unix/sysv/linux/powerpc')
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h90
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h30
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h118
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S12
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h41
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S12
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h16
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstack.c51
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c48
9 files changed, 373 insertions, 45 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h
new file mode 100644
index 0000000000..ab95fb57ee
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h
@@ -0,0 +1,90 @@
+/* Minimum guaranteed maximum values for system limits. Linux/PPC version.
+ Copyright (C) 1993-1998,2000,2002-2004,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* The kernel header pollutes the namespace with the NR_OPEN symbol
+ and defines LINK_MAX although filesystems have different maxima. A
+ similar thing is true for OPEN_MAX: the limit can be changed at
+ runtime and therefore the macro must not be defined. Remove this
+ after including the header if necessary. */
+#ifndef NR_OPEN
+# define __undef_NR_OPEN
+#endif
+#ifndef LINK_MAX
+# define __undef_LINK_MAX
+#endif
+#ifndef OPEN_MAX
+# define __undef_OPEN_MAX
+#endif
+
+/* The kernel sources contain a file with all the needed information. */
+#include <linux/limits.h>
+
+/* Have to remove NR_OPEN? */
+#ifdef __undef_NR_OPEN
+# undef NR_OPEN
+# undef __undef_NR_OPEN
+#endif
+/* Have to remove LINK_MAX? */
+#ifdef __undef_LINK_MAX
+# undef LINK_MAX
+# undef __undef_LINK_MAX
+#endif
+/* Have to remove OPEN_MAX? */
+#ifdef __undef_OPEN_MAX
+# undef OPEN_MAX
+# undef __undef_OPEN_MAX
+#endif
+
+/* The number of data keys per process. */
+#define _POSIX_THREAD_KEYS_MAX 128
+/* This is the value this implementation supports. */
+#define PTHREAD_KEYS_MAX 1024
+
+/* Controlling the iterations of destructors for thread-specific data. */
+#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
+/* Number of iterations this implementation does. */
+#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
+
+/* The number of threads per process. */
+#define _POSIX_THREAD_THREADS_MAX 64
+/* We have no predefined limit on the number of threads. */
+#undef PTHREAD_THREADS_MAX
+
+/* Maximum amount by which a process can descrease its asynchronous I/O
+ priority level. */
+#define AIO_PRIO_DELTA_MAX 20
+
+/* Minimum size for a thread. At least two pages for systems with 64k
+ pages. */
+#define PTHREAD_STACK_MIN 131072
+
+/* Maximum number of timer expiration overruns. */
+#define DELAYTIMER_MAX 2147483647
+
+/* Maximum tty name length. */
+#define TTY_NAME_MAX 32
+
+/* Maximum login name length. This is arbitrary. */
+#define LOGIN_NAME_MAX 256
+
+/* Maximum host name length. */
+#define HOST_NAME_MAX 64
+
+/* Maximum message queue priority level. */
+#define MQ_PRIO_MAX 32768
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
index 90c0695697..a7150f6aef 100644
--- a/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
@@ -1,5 +1,5 @@
/* Machine-specific pthread type layouts. PowerPC version.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Paul Mackerras <paulus@au.ibm.com>, 2003.
@@ -58,11 +58,25 @@ typedef union
} pthread_attr_t;
+#if __WORDSIZE == 64
+typedef struct __pthread_internal_list
+{
+ struct __pthread_internal_list *__prev;
+ struct __pthread_internal_list *__next;
+} __pthread_list_t;
+#else
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+#endif
+
+
/* Data structures for mutex handling. The structure of the attribute
type is deliberately not exposed. */
typedef union
{
- struct
+ struct __pthread_mutex_s
{
int __lock;
unsigned int __count;
@@ -73,10 +87,18 @@ typedef union
/* KIND must stay at this position in the structure to maintain
binary compatibility. */
int __kind;
-#if __WORDSIZE != 64
+#if __WORDSIZE == 64
+ int __spins;
+ __pthread_list_t __list;
+# define __PTHREAD_MUTEX_HAVE_PREV 1
+#else
unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
#endif
- int __spins;
} __data;
char __size[__SIZEOF_PTHREAD_MUTEX_T];
long int __align;
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
index 2bee000730..0136b97595 100644
--- a/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Paul Mackerras <paulus@au.ibm.com>, 2003.
@@ -13,7 +13,7 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Libr \ary; if not, write to the Free
+ License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
@@ -33,6 +33,11 @@
#define FUTEX_WAKE 1
#define FUTEX_REQUEUE 3
#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
/* Initializer for compatibility lock. */
#define LLL_MUTEX_LOCK_INITIALIZER (0)
@@ -67,6 +72,17 @@
INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
})
+#define lll_robust_mutex_dead(futexv) \
+ do \
+ { \
+ INTERNAL_SYSCALL_DECL (__err); \
+ int *__futexp = &(futexv); \
+ \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ INTERNAL_SYSCALL (futex, __err, 4, __futexp, FUTEX_WAKE, 1, 0); \
+ } \
+ while (0)
+
/* Returns non-zero if error happened, zero if success. */
#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val) \
({ \
@@ -79,16 +95,43 @@
INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
})
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, \
+ (futexp), FUTEX_WAKE_OP, (nr_wake), \
+ (nr_wake2), (futexp2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
#ifdef UP
# define __lll_acq_instr ""
# define __lll_rel_instr ""
#else
# define __lll_acq_instr "isync"
-# define __lll_rel_instr "sync"
+# ifdef _ARCH_PWR4
+/*
+ * Newer powerpc64 processors support the new "light weight" sync (lwsync)
+ * So if the build is using -mcpu=[power4,power5,power5+,970] we can
+ * safely use lwsync.
+ */
+# define __lll_rel_instr "lwsync"
+# else
+/*
+ * Older powerpc32 processors don't support the new "light weight"
+ * sync (lwsync). So the only safe option is to use normal sync
+ * for all powerpc32 applications.
+ */
+# define __lll_rel_instr "sync"
+# endif
#endif
-/* Set *futex to 1 if it is 0, atomically. Returns the old value */
-#define __lll_trylock(futex) \
+/* Set *futex to ID if it is 0, atomically. Returns the old value */
+#define __lll_robust_trylock(futex, id) \
({ int __val; \
__asm __volatile ("1: lwarx %0,0,%2\n" \
" cmpwi 0,%0,0\n" \
@@ -97,31 +140,26 @@
" bne- 1b\n" \
"2: " __lll_acq_instr \
: "=&r" (__val), "=m" (*futex) \
- : "r" (futex), "r" (1), "m" (*futex) \
+ : "r" (futex), "r" (id), "m" (*futex) \
: "cr0", "memory"); \
__val; \
})
+#define lll_robust_mutex_trylock(lock, id) __lll_robust_trylock (&(lock), id)
+
+/* Set *futex to 1 if it is 0, atomically. Returns the old value */
+#define __lll_trylock(futex) __lll_robust_trylock (futex, 1)
+
#define lll_mutex_trylock(lock) __lll_trylock (&(lock))
/* Set *futex to 2 if it is 0, atomically. Returns the old value */
-#define __lll_cond_trylock(futex) \
- ({ int __val; \
- __asm __volatile ("1: lwarx %0,0,%2\n" \
- " cmpwi 0,%0,0\n" \
- " bne 2f\n" \
- " stwcx. %3,0,%2\n" \
- " bne- 1b\n" \
- "2: " __lll_acq_instr \
- : "=&r" (__val), "=m" (*futex) \
- : "r" (futex), "r" (2), "m" (*futex) \
- : "cr0", "memory"); \
- __val; \
- })
+#define __lll_cond_trylock(futex) __lll_robust_trylock (futex, 2)
+
#define lll_mutex_cond_trylock(lock) __lll_cond_trylock (&(lock))
extern void __lll_lock_wait (int *futex) attribute_hidden;
+extern int __lll_robust_lock_wait (int *futex) attribute_hidden;
#define lll_mutex_lock(lock) \
(void) ({ \
@@ -131,6 +169,16 @@ extern void __lll_lock_wait (int *futex) attribute_hidden;
__lll_lock_wait (__futex); \
})
+#define lll_robust_mutex_lock(lock, id) \
+ ({ \
+ int *__futex = &(lock); \
+ int __val = 0; \
+ if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \
+ 0), 0)) \
+ __val = __lll_robust_lock_wait (__futex); \
+ __val; \
+ })
+
#define lll_mutex_cond_lock(lock) \
(void) ({ \
int *__futex = &(lock); \
@@ -139,8 +187,22 @@ extern void __lll_lock_wait (int *futex) attribute_hidden;
__lll_lock_wait (__futex); \
})
+#define lll_robust_mutex_cond_lock(lock, id) \
+ ({ \
+ int *__futex = &(lock); \
+ int __val = 0; \
+ int __id = id | FUTEX_WAITERS; \
+ if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, __id,\
+ 0), 0)) \
+ __val = __lll_robust_lock_wait (__futex); \
+ __val; \
+ })
+
+
extern int __lll_timedlock_wait
(int *futex, const struct timespec *) attribute_hidden;
+extern int __lll_robust_timedlock_wait
+ (int *futex, const struct timespec *) attribute_hidden;
#define lll_mutex_timedlock(lock, abstime) \
({ \
@@ -152,6 +214,16 @@ extern int __lll_timedlock_wait
__val; \
})
+#define lll_robust_mutex_timedlock(lock, abstime, id) \
+ ({ \
+ int *__futex = &(lock); \
+ int __val = 0; \
+ if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \
+ 0), 0)) \
+ __val = __lll_robust_timedlock_wait (__futex, abstime); \
+ __val; \
+ })
+
#define lll_mutex_unlock(lock) \
((void) ({ \
int *__futex = &(lock); \
@@ -160,6 +232,14 @@ extern int __lll_timedlock_wait
lll_futex_wake (__futex, 1); \
}))
+#define lll_robust_mutex_unlock(lock) \
+ ((void) ({ \
+ int *__futex = &(lock); \
+ int __val = atomic_exchange_rel (__futex, 0); \
+ if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \
+ lll_futex_wake (__futex, 1); \
+ }))
+
#define lll_mutex_unlock_force(lock) \
((void) ({ \
int *__futex = &(lock); \
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S
index e19579e842..675a997e97 100644
--- a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S
@@ -1,3 +1,9 @@
-#define RESET_PID
-#include <tcb-offsets.h>
-#include <sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S>
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <clone.S>
+#else
+# define RESET_PID
+# include_next <clone.S>
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
index 7f5ba4aeef..3752abc870 100644
--- a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
@@ -1,5 +1,5 @@
/* Cancellable system call stubs. Linux/PowerPC version.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Franz Sirl <Franz.Sirl-kernel@lauterbach.com>, 2003.
@@ -15,8 +15,8 @@
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA
+ 02110-1301 USA. */
#include <sysdep.h>
#include <tls.h>
@@ -30,7 +30,6 @@
# define PSEUDO(name, syscall_name, args) \
.section ".text"; \
ENTRY (name) \
- cfi_startproc; \
SINGLE_THREAD_P; \
bne- .Lpseudo_cancel; \
.type __##syscall_name##_nocancel,@function; \
@@ -45,6 +44,7 @@
mflr 9; \
stw 9,52(1); \
cfi_offset (lr, 4); \
+ CGOTSETUP; \
DOCARGS_##args; /* save syscall args around CENABLE. */ \
CENABLE; \
stw 3,16(1); /* store CENABLE return value (MASK). */ \
@@ -58,10 +58,10 @@
lwz 4,52(1); \
lwz 0,12(1); /* restore CR/R3. */ \
lwz 3,8(1); \
+ CGOTRESTORE; \
mtlr 4; \
mtcr 0; \
- addi 1,1,48; \
- cfi_endproc;
+ addi 1,1,48;
# define DOCARGS_0
# define UNDOCARGS_0
@@ -84,15 +84,30 @@
# define DOCARGS_6 stw 8,40(1); DOCARGS_5
# define UNDOCARGS_6 lwz 8,40(1); UNDOCARGS_5
+# define CGOTSETUP
+# define CGOTRESTORE
+
# ifdef IS_IN_libpthread
-# define CENABLE bl JUMPTARGET(__pthread_enable_asynccancel)
-# define CDISABLE bl JUMPTARGET(__pthread_disable_asynccancel)
+# define CENABLE bl __pthread_enable_asynccancel@local
+# define CDISABLE bl __pthread_disable_asynccancel@local
# elif !defined NOT_IN_libc
-# define CENABLE bl JUMPTARGET(__libc_enable_asynccancel)
-# define CDISABLE bl JUMPTARGET(__libc_disable_asynccancel)
+# define CENABLE bl __libc_enable_asynccancel@local
+# define CDISABLE bl __libc_disable_asynccancel@local
# elif defined IS_IN_librt
# define CENABLE bl JUMPTARGET(__librt_enable_asynccancel)
# define CDISABLE bl JUMPTARGET(__librt_disable_asynccancel)
+# if defined HAVE_AS_REL16 && defined PIC
+# undef CGOTSETUP
+# define CGOTSETUP \
+ bcl 20,31,1f; \
+ 1: stw 30,44(1); \
+ mflr 30; \
+ addis 30,30,_GLOBAL_OFFSET_TABLE-1b@ha; \
+ addi 30,30,_GLOBAL_OFFSET_TABLE-1b@l
+# undef CGOTRESTORE
+# define CGOTRESTORE \
+ lwz 30,44(1)
+# endif
# else
# error Unsupported library
# endif
@@ -113,3 +128,9 @@
# define NO_CANCELLATION 1
#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S
index f87adf4737..675a997e97 100644
--- a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S
@@ -1,3 +1,9 @@
-#define RESET_PID
-#include <tcb-offsets.h>
-#include <sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S>
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <clone.S>
+#else
+# define RESET_PID
+# include_next <clone.S>
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
index 226aaafdce..707765ab58 100644
--- a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
@@ -1,5 +1,5 @@
/* Cancellable system call stubs. Linux/PowerPC64 version.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Franz Sirl <Franz.Sirl-kernel@lauterbach.com>, 2003.
@@ -15,8 +15,8 @@
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA
+ 02110-1301 USA. */
#include <sysdep.h>
#include <tls.h>
@@ -36,7 +36,6 @@
# define PSEUDO(name, syscall_name, args) \
.section ".text"; \
ENTRY (name) \
- cfi_startproc; \
SINGLE_THREAD_P; \
bne- .Lpseudo_cancel; \
.type DASHDASHPFX(syscall_name##_nocancel),@function; \
@@ -66,8 +65,7 @@
ld 3,64(1); \
mtlr 9; \
mtcr 0; \
- addi 1,1,128; \
- cfi_endproc;
+ addi 1,1,128;
# define DOCARGS_0
# define UNDOCARGS_0
@@ -119,3 +117,9 @@
# define NO_CANCELLATION 1
#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstack.c b/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstack.c
new file mode 100644
index 0000000000..8aa971ab9a
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstack.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include "pthreadP.h"
+
+
+int
+__pthread_attr_setstack (attr, stackaddr, stacksize)
+ pthread_attr_t *attr;
+ void *stackaddr;
+ size_t stacksize;
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Catch invalid sizes. */
+ if (stacksize < 16384)
+ return EINVAL;
+
+#ifdef EXTRA_PARAM_CHECKS
+ EXTRA_PARAM_CHECKS;
+#endif
+
+ iattr->stacksize = stacksize;
+ iattr->stackaddr = (char *) stackaddr + stacksize;
+ iattr->flags |= ATTR_FLAG_STACKADDR;
+
+ return 0;
+}
+strong_alias (__pthread_attr_setstack, pthread_attr_setstack)
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c b/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c
new file mode 100644
index 0000000000..ea8c95981e
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include "pthreadP.h"
+
+
+int
+__pthread_attr_setstacksize (attr, stacksize)
+ pthread_attr_t *attr;
+ size_t stacksize;
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Catch invalid sizes. */
+ if (stacksize < 16384)
+ return EINVAL;
+
+ size_t ps = __getpagesize ();
+ if (stacksize < 2 * ps)
+ stacksize = 2 * ps;
+
+ iattr->stacksize = stacksize;
+
+ return 0;
+}
+strong_alias (__pthread_attr_setstacksize, pthread_attr_setstacksize)