diff options
author | Roland McGrath <roland@gnu.org> | 2003-03-11 09:30:37 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2003-03-11 09:30:37 +0000 |
commit | b33e61633a10a233510f6f49b97b7e2ad15c7311 (patch) | |
tree | 9b6025b692435f629bc771dca74dcfb48e41768a /nptl/sysdeps/ia64 | |
parent | 5d5d5969b17422e3b1af6f88436e91f32a36fd58 (diff) | |
download | glibc-b33e61633a10a233510f6f49b97b7e2ad15c7311.tar glibc-b33e61633a10a233510f6f49b97b7e2ad15c7311.tar.gz glibc-b33e61633a10a233510f6f49b97b7e2ad15c7311.tar.bz2 glibc-b33e61633a10a233510f6f49b97b7e2ad15c7311.zip |
* sysdeps/generic/dl-sysdep.c (_dl_important_hwcaps): If CNT == 1,
allocate space even for the trailing '/'.
Reported by John Reiser <jreiser@BitWagon.com>.
* sysdeps/unix/sysv/linux/ia64/sysdep.h (LOAD_ARGS_6, ASM_ARGS_6,
ASM_CLOBBERS_6): Define.
(ASM_CLOBBERS_5): Use ASM_CLOBBERS_6.
* sysdeps/unix/sysv/linux/ia64/clone2.S (__clone2): Reorder arguments
to match IA-32 order.
* sysdeps/unix/sysv/linux/i386/clone.S: Fix comment.
Diffstat (limited to 'nptl/sysdeps/ia64')
-rw-r--r-- | nptl/sysdeps/ia64/Makefile | 25 | ||||
-rw-r--r-- | nptl/sysdeps/ia64/bits/atomic.h | 93 | ||||
-rw-r--r-- | nptl/sysdeps/ia64/pthread_spin_init.c | 20 | ||||
-rw-r--r-- | nptl/sysdeps/ia64/pthread_spin_lock.c | 36 | ||||
-rw-r--r-- | nptl/sysdeps/ia64/pthread_spin_trylock.c | 28 | ||||
-rw-r--r-- | nptl/sysdeps/ia64/pthread_spin_unlock.c | 31 | ||||
-rw-r--r-- | nptl/sysdeps/ia64/pthreaddef.h | 46 | ||||
-rw-r--r-- | nptl/sysdeps/ia64/tcb-offsets.sym | 4 | ||||
-rw-r--r-- | nptl/sysdeps/ia64/td_ta_map_lwp2thr.c | 44 | ||||
-rw-r--r-- | nptl/sysdeps/ia64/tls.h | 128 |
10 files changed, 455 insertions, 0 deletions
diff --git a/nptl/sysdeps/ia64/Makefile b/nptl/sysdeps/ia64/Makefile new file mode 100644 index 0000000000..3229d3f16d --- /dev/null +++ b/nptl/sysdeps/ia64/Makefile @@ -0,0 +1,25 @@ +# Copyright (C) 2003 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; if not, write to the Free +# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +# 02111-1307 USA. + +ifeq ($(subdir),csu) +gen-as-const-headers += tcb-offsets.sym +endif + +ifeq ($(subdir),nptl) +libpthread-routines += ptw-sysdep ptw-sigblock ptw-sigprocmask +endif diff --git a/nptl/sysdeps/ia64/bits/atomic.h b/nptl/sysdeps/ia64/bits/atomic.h new file mode 100644 index 0000000000..4b1d24f8e7 --- /dev/null +++ b/nptl/sysdeps/ia64/bits/atomic.h @@ -0,0 +1,93 @@ +/* Copyright (C) 2003 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; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <stdint.h> +#include <ia64intrin.h> + +typedef int8_t atomic8_t; +typedef uint8_t uatomic8_t; +typedef int_fast8_t atomic_fast8_t; +typedef uint_fast8_t uatomic_fast8_t; + +typedef int16_t atomic16_t; +typedef uint16_t uatomic16_t; +typedef int_fast16_t atomic_fast16_t; +typedef uint_fast16_t uatomic_fast16_t; + +typedef int32_t atomic32_t; +typedef uint32_t uatomic32_t; +typedef int_fast32_t atomic_fast32_t; +typedef uint_fast32_t uatomic_fast32_t; + +typedef int64_t atomic64_t; +typedef uint64_t uatomic64_t; +typedef int_fast64_t atomic_fast64_t; +typedef uint_fast64_t uatomic_fast64_t; + +typedef intptr_t atomicptr_t; +typedef uintptr_t uatomicptr_t; +typedef intmax_t atomic_max_t; +typedef uintmax_t uatomic_max_t; + + +#define __arch_compare_and_exchange_8_acq(mem, newval, oldval) \ + (abort (), 0) + +#define __arch_compare_and_exchange_16_acq(mem, newval, oldval) \ + (abort (), 0) + +#define __arch_compare_and_exchange_32_acq(mem, newval, oldval) \ + (!__sync_bool_compare_and_swap_si ((int *) (mem), (int) (long) (oldval), \ + (int) (long) (newval))) + +# define __arch_compare_and_exchange_64_acq(mem, newval, oldval) \ + (!__sync_bool_compare_and_swap_di ((long *) (mem), (long) (oldval), \ + (long) (newval))) + +#define __arch_compare_and_exchange_32_val_acq(mem, newval, oldval) \ + __sync_val_compare_and_swap_si ((int *) (mem), (int) (long) (oldval), \ + (int) (long) (newval)) + +# define __arch_compare_and_exchange_64_val_acq(mem, newval, oldval) \ + __sync_val_compare_and_swap_di ((long *) (mem), (long) (oldval), \ + (long) (newval)) + +# define atomic_exchange_and_add(mem, value) \ + ({ \ + __typeof (*mem) __oldval, __val; \ + __typeof (mem) __memp = (mem); \ + __typeof (*mem) __value = (value); \ + \ + __val = *__memp; \ + if (sizeof (*mem) == 4) \ + do \ + __oldval = __val; \ + while ((__val \ + = __arch_compare_and_exchange_32_val_acq (__memp, __oldval, \ + __oldval + __value)) \ + != __oldval); \ + else if (sizeof (*mem) == 8) \ + do \ + __oldval = __val; \ + while ((__val \ + = __arch_compare_and_exchange_64_val_acq (__memp, __oldval, \ + __oldval + __value)) \ + != __oldval); \ + else \ + abort (); \ + __oldval + __value; }) diff --git a/nptl/sysdeps/ia64/pthread_spin_init.c b/nptl/sysdeps/ia64/pthread_spin_init.c new file mode 100644 index 0000000000..c300cd442f --- /dev/null +++ b/nptl/sysdeps/ia64/pthread_spin_init.c @@ -0,0 +1,20 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. + + 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. */ + +/* Not needed. pthread_spin_init is an alias for pthread_spin_unlock. */ diff --git a/nptl/sysdeps/ia64/pthread_spin_lock.c b/nptl/sysdeps/ia64/pthread_spin_lock.c new file mode 100644 index 0000000000..f6b706ae71 --- /dev/null +++ b/nptl/sysdeps/ia64/pthread_spin_lock.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. + + 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 "pthreadP.h" + +int +pthread_spin_lock (lock) + pthread_spinlock_t *lock; +{ + int *p = (int *) lock; + + while (__builtin_expect (__sync_val_compare_and_swap_si (p, 0, 1), 0)) + { + /* Spin without using the atomic instruction. */ + do + __asm __volatile ("" : : : "memory"); + while (*p); + } + return 0; +} diff --git a/nptl/sysdeps/ia64/pthread_spin_trylock.c b/nptl/sysdeps/ia64/pthread_spin_trylock.c new file mode 100644 index 0000000000..b7cbf14782 --- /dev/null +++ b/nptl/sysdeps/ia64/pthread_spin_trylock.c @@ -0,0 +1,28 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. + + 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 <errno.h> +#include "pthreadP.h" + +int +pthread_spin_trylock (lock) + pthread_spinlock_t *lock; +{ + return __sync_val_compare_and_swap_si ((int *) lock, 0, 1) == 0 ? 0 : EBUSY; +} diff --git a/nptl/sysdeps/ia64/pthread_spin_unlock.c b/nptl/sysdeps/ia64/pthread_spin_unlock.c new file mode 100644 index 0000000000..b3f1ff1628 --- /dev/null +++ b/nptl/sysdeps/ia64/pthread_spin_unlock.c @@ -0,0 +1,31 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. + + 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. */ + +/* Ugly hack to avoid the declaration of pthread_spin_init. */ +#define pthread_spin_init pthread_spin_init_XXX +#include "pthreadP.h" +#undef pthread_spin_init + +int +pthread_spin_unlock (pthread_spinlock_t *lock) +{ + *lock = 0; + return 0; +} +strong_alias (pthread_spin_unlock, pthread_spin_init) diff --git a/nptl/sysdeps/ia64/pthreaddef.h b/nptl/sysdeps/ia64/pthreaddef.h new file mode 100644 index 0000000000..8fc58e04d8 --- /dev/null +++ b/nptl/sysdeps/ia64/pthreaddef.h @@ -0,0 +1,46 @@ +/* Copyright (C) 2003 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; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Default stack size. */ +#define ARCH_STACK_DEFAULT_SIZE (32 * 1024 * 1024) + +/* IA-64 uses a normal stack and a register stack. */ +#define NEED_SEPARATE_REGISTER_STACK + +/* Required stack pointer alignment at beginning. */ +#define STACK_ALIGN 16 + +/* Minimal stack size after allocating thread descriptor and guard size. */ +#define MINIMAL_REST_STACK 16384 + +/* Alignment requirement for TCB. */ +#define TCB_ALIGNMENT 16 + +/* The signal used for asynchronous cancelation. */ +#define SIGCANCEL __SIGRTMIN + + +/* Location of current stack frame. */ +#define CURRENT_STACK_FRAME __stack_pointer +register char *__stack_pointer __asm__ ("sp"); + +/* XXX Until we have a better place keep the definitions here. */ + +/* While there is no such syscall. */ +#define __exit_thread_inline(val) \ + INLINE_SYSCALL (exit, 1, (val)) diff --git a/nptl/sysdeps/ia64/tcb-offsets.sym b/nptl/sysdeps/ia64/tcb-offsets.sym new file mode 100644 index 0000000000..69b6b394ed --- /dev/null +++ b/nptl/sysdeps/ia64/tcb-offsets.sym @@ -0,0 +1,4 @@ +#include <sysdep.h> +#include <tls.h> + +MULTIPLE_THREADS_OFFSET offsetof (struct pthread, multiple_threads) - sizeof (struct pthread) diff --git a/nptl/sysdeps/ia64/td_ta_map_lwp2thr.c b/nptl/sysdeps/ia64/td_ta_map_lwp2thr.c new file mode 100644 index 0000000000..0931ce944d --- /dev/null +++ b/nptl/sysdeps/ia64/td_ta_map_lwp2thr.c @@ -0,0 +1,44 @@ +/* Which thread is running on an LWP? IA-64 version. + Copyright (C) 2003 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; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include "thread_dbP.h" +#include <tls.h> + + +td_err_e +td_ta_map_lwp2thr (const td_thragent_t *ta, lwpid_t lwpid, td_thrhandle_t *th) +{ + LOG ("td_ta_map_lwp2thr"); + + /* Test whether the TA parameter is ok. */ + if (! ta_ok (ta)) + return TD_BADTA; + + prgregset_t regs; + if (ps_lgetregs (ta->ph, lwpid, regs) != PS_OK) + return TD_ERR; + + /* IA-64 thread register is r13. */ + th->th_unique = regs[13]; + + /* Found it. Now complete the `td_thrhandle_t' object. */ + th->th_ta_p = (td_thragent_t *) ta; + + return TD_OK; +} diff --git a/nptl/sysdeps/ia64/tls.h b/nptl/sysdeps/ia64/tls.h new file mode 100644 index 0000000000..8a13a59d30 --- /dev/null +++ b/nptl/sysdeps/ia64/tls.h @@ -0,0 +1,128 @@ +/* Definition for thread-local data handling. nptl/IA-64 version. + Copyright (C) 2003 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; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _TLS_H +#define _TLS_H 1 + +#include <dl-sysdep.h> +#ifndef __ASSEMBLER__ +# include <stddef.h> +# include <stdint.h> +# include <stdlib.h> +# include <list.h> + + +/* Type for the dtv. */ +typedef union dtv +{ + size_t counter; + void *pointer; +} dtv_t; + + +typedef struct +{ + dtv_t *dtv; + void *private; +} tcbhead_t; + +# define TLS_MULTIPLE_THREADS_IN_TCB 1 + +#else /* __ASSEMBLER__ */ +# include <tcb-offsets.h> +#endif + + +/* We require TLS support in the tools. */ +#ifndef HAVE_TLS_SUPPORT +# error "TLS support is required." +#endif + +/* Signal that TLS support is available. */ +#define USE_TLS 1 + +/* Alignment requirement for the stack. */ +#define STACK_ALIGN 16 + +#ifndef __ASSEMBLER__ +/* Get system call information. */ +# include <sysdep.h> + +register struct pthread *__thread_self __asm__("r13"); + +/* This is the size of the initial TCB. */ +# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t) + +/* Alignment requirements for the initial TCB. */ +# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t) + +/* This is the size of the TCB. */ +# define TLS_TCB_SIZE sizeof (tcbhead_t) + +/* This is the size we need before TCB. */ +# define TLS_PRE_TCB_SIZE sizeof (struct pthread) + +/* Alignment requirements for the TCB. */ +# define TLS_TCB_ALIGN __alignof__ (struct pthread) + +/* The DTV is allocated at the TP; the TCB is placed elsewhere. */ +# define TLS_DTV_AT_TP 1 + +/* Get the thread descriptor definition. */ +# include <nptl/descr.h> + +/* Install the dtv pointer. The pointer passed is to the element with + index -1 which contain the length. */ +# define INSTALL_DTV(descr, dtvp) \ + ((tcbhead_t *) (descr))->dtv = (dtvp) + 1 + +/* Install new dtv for current thread. */ +# define INSTALL_NEW_DTV(DTV) \ + (((tcbhead_t *)__thread_self)->dtv = (DTV)) + +/* Return dtv of given thread descriptor. */ +# define GET_DTV(descr) \ + (((tcbhead_t *) (descr))->dtv) + +/* Code to initially initialize the thread pointer. This might need + special attention since 'errno' is not yet available and if the + operation can cause a failure 'errno' must not be touched. */ +# define TLS_INIT_TP(thrdescr, secondcall) \ + (__thread_self = (thrdescr), NULL) + +/* Return the address of the dtv for the current thread. */ +# define THREAD_DTV() \ + (((tcbhead_t *)__thread_self)->dtv) + +/* Return the thread descriptor for the current thread. */ +# define THREAD_SELF (__thread_self - 1) + +/* Access to data in the thread descriptor is easy. */ +#define THREAD_GETMEM(descr, member) \ + descr->member +#define THREAD_GETMEM_NC(descr, member, idx) \ + descr->member[idx] +#define THREAD_SETMEM(descr, member, value) \ + descr->member = (value) +#define THREAD_SETMEM_NC(descr, member, idx, value) \ + descr->member[idx] = (value) + +#endif /* __ASSEMBLER__ */ + +#endif /* tls.h */ |