diff options
Diffstat (limited to 'sysdeps/mach')
| -rw-r--r-- | sysdeps/mach/bits/spin-lock-inline.h | 90 | ||||
| -rw-r--r-- | sysdeps/mach/bits/spin-lock.h | 65 | ||||
| -rw-r--r-- | sysdeps/mach/hurd/ia32/pt-machdep.c (renamed from sysdeps/mach/hurd/i386/pt-machdep.c) | 0 | ||||
| -rw-r--r-- | sysdeps/mach/hurd/ia32/pt-setup.c (renamed from sysdeps/mach/hurd/i386/pt-setup.c) | 10 | ||||
| -rw-r--r-- | sysdeps/mach/hurd/pt-docancel.c | 4 | ||||
| -rw-r--r-- | sysdeps/mach/hurd/pt-sysdep.h | 5 | ||||
| -rw-r--r-- | sysdeps/mach/pt-thread-alloc.c | 7 | ||||
| -rw-r--r-- | sysdeps/mach/pt-thread-halt.c | 10 | ||||
| -rw-r--r-- | sysdeps/mach/pt-timedblock.c | 6 |
9 files changed, 115 insertions, 82 deletions
diff --git a/sysdeps/mach/bits/spin-lock-inline.h b/sysdeps/mach/bits/spin-lock-inline.h new file mode 100644 index 00000000..f9f7c299 --- /dev/null +++ b/sysdeps/mach/bits/spin-lock-inline.h @@ -0,0 +1,90 @@ +/* Definitions of user-visible names for spin locks. + Copyright (C) 1994, 1997, 2002, 2008, 2009 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 _BITS_SPIN_LOCK_INLINE_H +#define _BITS_SPIN_LOCK_INLINE_H 1 + +#include <features.h> +#include <bits/spin-lock.h> +#include <machine-lock.h> /* This does all the work. */ + +__BEGIN_DECLS + +#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES + +# ifndef __EBUSY +# include <errno.h> +# define __EBUSY EBUSY +# endif + +# ifndef __PT_SPIN_INLINE +# define __PT_SPIN_INLINE __extern_inline +# endif + +__PT_SPIN_INLINE int __pthread_spin_destroy (__pthread_spinlock_t *__lock); + +__PT_SPIN_INLINE int +__pthread_spin_destroy (__pthread_spinlock_t *__lock) +{ + return 0; +} + +__PT_SPIN_INLINE int __pthread_spin_init (__pthread_spinlock_t *__lock, + int __pshared); + +__PT_SPIN_INLINE int +__pthread_spin_init (__pthread_spinlock_t *__lock, int __pshared) +{ + *__lock = __PTHREAD_SPIN_LOCK_INITIALIZER; + return 0; +} + +__PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock); + +__PT_SPIN_INLINE int +__pthread_spin_trylock (__pthread_spinlock_t *__lock) +{ + return __spin_try_lock (__lock) ? 0 : __EBUSY; +} + +__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock); +extern int _pthread_spin_lock (__pthread_spinlock_t *__lock); + +__extern_inline int +__pthread_spin_lock (__pthread_spinlock_t *__lock) +{ + if (__pthread_spin_trylock (__lock)) + return _pthread_spin_lock (__lock); + return 0; +} + +__PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock); + +__PT_SPIN_INLINE int +__pthread_spin_unlock (__pthread_spinlock_t *__lock) +{ + __spin_unlock (__lock); + return 0; +} + +#endif /* Use extern inlines or force inlines. */ + +__END_DECLS + +#endif /* bits/spin-lock.h */ diff --git a/sysdeps/mach/bits/spin-lock.h b/sysdeps/mach/bits/spin-lock.h index e137c244..537dac9d 100644 --- a/sysdeps/mach/bits/spin-lock.h +++ b/sysdeps/mach/bits/spin-lock.h @@ -1,5 +1,5 @@ /* Definitions of user-visible names for spin locks. - Copyright (C) 1994, 1997, 2002 Free Software Foundation, Inc. + Copyright (C) 1994, 1997, 2002, 2008, 2009 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 @@ -29,69 +29,10 @@ __BEGIN_DECLS typedef __spin_lock_t __pthread_spinlock_t; /* Initializer for a spin lock object. */ -#ifndef __SPIN_LOCK_INITIALIZER -#error __SPIN_LOCK_INITIALIZER undefined: should be defined by <lock-intern.h>. +#ifndef __PTHREAD_SPIN_LOCK_INITIALIZER +#error __PTHREAD_SPIN_LOCK_INITIALIZER undefined: should be defined by <lock-intern.h>. #endif -#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES - -# ifndef __EBUSY -# include <errno.h> -# define __EBUSY EBUSY -# endif - -# ifndef __PT_SPIN_INLINE -# define __PT_SPIN_INLINE extern __inline -# endif - -__PT_SPIN_INLINE int __pthread_spin_destroy (__pthread_spinlock_t *__lock); - -__PT_SPIN_INLINE int -__pthread_spin_destroy (__pthread_spinlock_t *__lock) -{ - return 0; -} - -__PT_SPIN_INLINE int __pthread_spin_init (__pthread_spinlock_t *__lock, - int __pshared); - -__PT_SPIN_INLINE int -__pthread_spin_init (__pthread_spinlock_t *__lock, int __pshared) -{ - *__lock = __SPIN_LOCK_INITIALIZER; - return 0; -} - -__PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock); - -__PT_SPIN_INLINE int -__pthread_spin_trylock (__pthread_spinlock_t *__lock) -{ - return __spin_try_lock (__lock) ? 0 : __EBUSY; -} - -extern __inline int __pthread_spin_lock (__pthread_spinlock_t *__lock); -extern int _pthread_spin_lock (__pthread_spinlock_t *__lock); - -extern __inline int -__pthread_spin_lock (__pthread_spinlock_t *__lock) -{ - if (__pthread_spin_trylock (__lock)) - return _pthread_spin_lock (__lock); - return 0; -} - -__PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock); - -__PT_SPIN_INLINE int -__pthread_spin_unlock (__pthread_spinlock_t *__lock) -{ - __spin_unlock (__lock); - return 0; -} - -#endif /* Use extern inlines or force inlines. */ - __END_DECLS #endif /* bits/spin-lock.h */ diff --git a/sysdeps/mach/hurd/i386/pt-machdep.c b/sysdeps/mach/hurd/ia32/pt-machdep.c index f3c8cf50..f3c8cf50 100644 --- a/sysdeps/mach/hurd/i386/pt-machdep.c +++ b/sysdeps/mach/hurd/ia32/pt-machdep.c diff --git a/sysdeps/mach/hurd/i386/pt-setup.c b/sysdeps/mach/hurd/ia32/pt-setup.c index 020f677a..5420dc8e 100644 --- a/sysdeps/mach/hurd/i386/pt-setup.c +++ b/sysdeps/mach/hurd/ia32/pt-setup.c @@ -1,5 +1,5 @@ /* Setup thread stack. Hurd/i386 version. - Copyright (C) 2000, 2002, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2000, 2002, 2005, 2007, 2008 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 @@ -58,13 +58,15 @@ stack_setup (struct __pthread *thread, top -= __hurd_threadvar_max; /* Save the self pointer. */ - top[_HURD_THREADVAR_THREAD] = (void *) thread; + top[_HURD_THREADVAR_THREAD] = (uintptr_t) thread; if (start_routine) { /* And then the call frame. */ - *--top = (uintptr_t) arg; /* Argument to START_ROUTINE. */ - *--top = (uintptr_t) start_routine; + top -= 2; + top = (uintptr_t *) ((uintptr_t) top & ~0xf); + top[1] = (uintptr_t) arg; /* Argument to START_ROUTINE. */ + top[0] = (uintptr_t) start_routine; *--top = 0; /* Fake return address. */ } diff --git a/sysdeps/mach/hurd/pt-docancel.c b/sysdeps/mach/hurd/pt-docancel.c index 84f04c0c..105c6fda 100644 --- a/sysdeps/mach/hurd/pt-docancel.c +++ b/sysdeps/mach/hurd/pt-docancel.c @@ -1,5 +1,5 @@ /* Cancel a thread. - Copyright (C) 2002, 2007 Free Software Foundation, Inc. + Copyright (C) 2002, 2007, 2008 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 @@ -33,7 +33,7 @@ __pthread_do_cancel (struct __pthread *p) mach_port_t ktid; int me; - assert (p->cancel_pending = 1); + assert (p->cancel_pending == 1); assert (p->cancel_state == PTHREAD_CANCEL_ENABLE); ktid = __mach_thread_self (); diff --git a/sysdeps/mach/hurd/pt-sysdep.h b/sysdeps/mach/hurd/pt-sysdep.h index f652b687..13e235d9 100644 --- a/sysdeps/mach/hurd/pt-sysdep.h +++ b/sysdeps/mach/hurd/pt-sysdep.h @@ -1,5 +1,5 @@ /* Internal defenitions for pthreads library. - Copyright (C) 2000, 2002, 2007 Free Software Foundation, Inc. + Copyright (C) 2000, 2002, 2007, 2008 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 @@ -32,7 +32,8 @@ #define PTHREAD_SYSDEP_MEMBERS \ thread_t kernel_thread; \ - mach_msg_header_t wakeupmsg; + mach_msg_header_t wakeupmsg; \ + int have_kernel_resources; #define _HURD_THREADVAR_THREAD _HURD_THREADVAR_DYNAMIC_USER diff --git a/sysdeps/mach/pt-thread-alloc.c b/sysdeps/mach/pt-thread-alloc.c index 1acba98a..3d7c0465 100644 --- a/sysdeps/mach/pt-thread-alloc.c +++ b/sysdeps/mach/pt-thread-alloc.c @@ -1,5 +1,5 @@ /* Start thread. Mach version. - Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc. + Copyright (C) 2000, 2002, 2005, 2008 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 @@ -63,6 +63,9 @@ create_wakeupmsg (struct __pthread *thread) int __pthread_thread_alloc (struct __pthread *thread) { + if (thread->have_kernel_resources) + return 0; + error_t err; err = create_wakeupmsg (thread); @@ -97,5 +100,7 @@ __pthread_thread_alloc (struct __pthread *thread) return EAGAIN; } + thread->have_kernel_resources = 1; + return 0; } diff --git a/sysdeps/mach/pt-thread-halt.c b/sysdeps/mach/pt-thread-halt.c index 9f860247..973cde1e 100644 --- a/sysdeps/mach/pt-thread-halt.c +++ b/sysdeps/mach/pt-thread-halt.c @@ -30,14 +30,8 @@ being halted, thus the last action should be halting the thread itself. */ void -__pthread_thread_halt (struct __pthread *thread, int need_dealloc) +__pthread_thread_halt (struct __pthread *thread) { - error_t err; - thread_t tid = thread->kernel_thread; - - if (need_dealloc) - __pthread_dealloc (thread); - - err = __thread_terminate (tid); + error_t err = __thread_terminate (thread->kernel_thread); assert_perror (err); } diff --git a/sysdeps/mach/pt-timedblock.c b/sysdeps/mach/pt-timedblock.c index ddb8baec..6f547265 100644 --- a/sysdeps/mach/pt-timedblock.c +++ b/sysdeps/mach/pt-timedblock.c @@ -51,11 +51,11 @@ __pthread_timedblock (struct __pthread *thread, timeout = (abstime->tv_sec - now.tv_sec) * 1000; if (((abstime->tv_nsec + 999) / 1000) >= now.tv_usec) - timeout -= (((abstime->tv_nsec + 999) / 1000) - now.tv_usec + 999) / 1000; + timeout += (((abstime->tv_nsec + 999) / 1000) - now.tv_usec + 999) / 1000; else /* Need to do a carry. */ - timeout -= 1000 + ((abstime->tv_nsec + 999999) / 1000000) - - (now.tv_usec + 999) / 1000; + timeout -= (now.tv_usec + 999) / 1000 - + ((abstime->tv_nsec + 999999) / 1000000); err = __mach_msg (&msg, MACH_RCV_MSG | MACH_RCV_TIMEOUT, 0, sizeof msg, thread->wakeupmsg.msgh_remote_port, |
