bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pthread headers


From: Michael Banck
Subject: Re: pthread headers
Date: Tue, 18 Jan 2005 00:06:53 +0100
User-agent: Mutt/1.5.6+20040523i

On Fri, Jan 14, 2005 at 09:52:56PM +0100, Alfred M. Szmidt wrote:
> Why didn't you declare macro's for `extern __inline__' and use the
> already provided ones like __PT_SPIN_INLINE in
> sysdeps/generic/bits/pthread.h?

Robert Millan sent in a patch which does exactly this some time ago
(see http://lists.gnu.org/archive/html/bug-hurd/2003-03/msg00025.html
and http://bugs.debian.org/184344). 

I added a ChangeLog entry (Robert said that was alright) and according
to him, he has papers assigned for the Hurd. Maybe you want to consider
this patch.


cheers,

Michael


2003-03-11  Robert Millan  <rmh@debian.org>

        * include/pthread/pthread.h (_EXTERN_INLINE) 
        [__USE_EXTERN_INLINES, !_EXTERN_INLINE]: New macro.
        (pthread_spin_destroy): Use it as return value type.
        (pthread_spin_init): Likewise.
        (pthread_spin_lock): Likewise.
        (pthread_spin_unlock): Likewise.
        (__pthread_mutex_trylock): Likewise.
        (pthread_mutex_lock): Likewise.
        (pthread_mutex_trylock): Likewise.
        * sysdeps/generic/bits/pthread.h (_EXTERN_INLINE) 
        [__USE_EXTERN_INLINES, !_EXTERN_INLINE]: New macro.
        (pthread_equal): Use it as return value type.
        * sysdeps/i386/bits/spin-lock.h (__pthread_spin_lock): Use
        __PT_SPIN_INLINE instead of `extern inline' as return value
        type.
        * sysdeps/l4/hurd/pt-sysdep.h (_EXTERN_INLINE)
        [__USE_EXTERN_INLINES, !_EXTERN_INLINE]: New macro.
        (_pthread_self): Use it as return value type.
        * sysdeps/mach/bits/spin-lock.h (__pthread_spin_lock): Use
        __PT_SPIN_INLINE instead of `extern inline' as return value
        type.
        * sysdeps/mach/hurd/pt-sysdep.h (_EXTERN_INLINE)
        [__USE_EXTERN_INLINES, !_EXTERN_INLINE]: New macro.
        (__pthread_stack_dealloc): Use it as return value type.

diff -ur hurd.old/libpthread/include/pthread/pthread.h 
hurd/libpthread/include/pthread/pthread.h
--- hurd.old/libpthread/include/pthread/pthread.h       2002-11-10 
18:00:40.000000000 +0100
+++ hurd/libpthread/include/pthread/pthread.h   2003-03-09 14:41:03.000000000 
+0100
@@ -420,31 +420,35 @@
 
 # ifdef __USE_EXTERN_INLINES
 
-extern inline int
+# ifndef _EXTERN_INLINE
+#  define _EXTERN_INLINE extern __inline
+# endif
+
+_EXTERN_INLINE int
 pthread_spin_destroy (pthread_spinlock_t *__lock)
 {
   return __pthread_spin_destroy (__lock);
 }
 
-extern inline int
+_EXTERN_INLINE int
 pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
 {
   return __pthread_spin_init (__lock, __pshared);
 }
 
-extern inline int
+_EXTERN_INLINE int
 pthread_spin_lock (pthread_spinlock_t *__lock)
 {
   return __pthread_spin_lock (__lock);
 }
 
-extern inline int
+_EXTERN_INLINE int
 pthread_spin_trylock (pthread_spinlock_t *__lock)
 {
   return __pthread_spin_trylock (__lock);
 }
 
-extern inline int
+_EXTERN_INLINE int
 pthread_spin_unlock (pthread_spinlock_t *__lock)
 {
   return __pthread_spin_unlock (__lock);
diff -ur hurd.old/libpthread/sysdeps/generic/bits/mutex.h 
hurd/libpthread/sysdeps/generic/bits/mutex.h
--- hurd.old/libpthread/sysdeps/generic/bits/mutex.h    2002-10-11 
01:05:05.000000000 +0200
+++ hurd/libpthread/sysdeps/generic/bits/mutex.h        2003-03-09 
14:37:34.000000000 +0100
@@ -108,7 +108,7 @@
   return _pthread_mutex_lock (__mutex);
 }
 
-extern inline int
+_EXTERN_INLINE int
 __pthread_mutex_trylock (struct __pthread_mutex *__mutex)
 {
   extern int _pthread_mutex_trylock (struct __pthread_mutex *);
@@ -120,13 +120,13 @@
   return _pthread_mutex_trylock (__mutex);
 }
 
-extern inline int
+_EXTERN_INLINE int
 pthread_mutex_lock (struct __pthread_mutex *__mutex)
 {
   return __pthread_mutex_lock (__mutex);
 }
 
-extern inline int
+_EXTERN_INLINE int
 pthread_mutex_trylock (struct __pthread_mutex *__mutex)
 {
   return __pthread_mutex_trylock (__mutex);
diff -ur hurd.old/libpthread/sysdeps/generic/bits/pthread.h 
hurd/libpthread/sysdeps/generic/bits/pthread.h
--- hurd.old/libpthread/sysdeps/generic/bits/pthread.h  2002-10-11 
01:05:05.000000000 +0200
+++ hurd/libpthread/sysdeps/generic/bits/pthread.h      2003-03-09 
14:44:48.000000000 +0100
@@ -22,12 +22,20 @@
 
 typedef int pthread_t;
 
+#ifdef __USE_EXTERN_INLINES
+
+# ifndef _EXTERN_INLINE
+#  define _EXTERN_INLINE extern __inline
+# endif
+
 /* Return true if __T1 and __T2 both name the same thread.  Otherwise,
    false.  */
-extern inline int
+_EXTERN_INLINE int
 pthread_equal (pthread_t __t1, pthread_t __t2)
 {
   return __t1 == __t2;
 }
 
+#endif /* __USE_EXTERN_INLINES  */
+
 #endif /* bits/pthread.h */
diff -ur hurd.old/libpthread/sysdeps/i386/bits/spin-lock.h 
hurd/libpthread/sysdeps/i386/bits/spin-lock.h
--- hurd.old/libpthread/sysdeps/i386/bits/spin-lock.h   2002-10-11 
01:05:05.000000000 +0200
+++ hurd/libpthread/sysdeps/i386/bits/spin-lock.h       2003-03-09 
14:49:55.000000000 +0100
@@ -74,10 +74,10 @@
   return __locked ? __EBUSY : 0;
 }
 
-extern inline int __pthread_spin_lock (__pthread_spinlock_t *__lock);
+__PT_SPIN_INLINE int __pthread_spin_lock (__pthread_spinlock_t *__lock);
 extern int _pthread_spin_lock (__pthread_spinlock_t *__lock);
 
-extern inline int
+__PT_SPIN_INLINE int
 __pthread_spin_lock (__pthread_spinlock_t *__lock)
 {
   if (__pthread_spin_trylock (__lock))
diff -ur hurd.old/libpthread/sysdeps/l4/hurd/pt-sysdep.h 
hurd/libpthread/sysdeps/l4/hurd/pt-sysdep.h
--- hurd.old/libpthread/sysdeps/l4/hurd/pt-sysdep.h     2002-10-11 
01:05:05.000000000 +0200
+++ hurd/libpthread/sysdeps/l4/hurd/pt-sysdep.h 2003-03-09 14:48:11.000000000 
+0100
@@ -34,17 +34,25 @@
   L4_ThreadId_t threadid; \
   L4_Word_t my_errno;
 
-extern inline struct __pthread *
+#ifdef __USE_EXTERN_INLINES
+
+# ifndef _EXTERN_INLINE
+#  define _EXTERN_INLINE extern __inline
+# endif
+
+_EXTERN_INLINE struct __pthread *
 _pthread_self (void)
 {
   return (struct __pthread *) L4_MyUserDefinedHandle ();
 }
 
-extern inline void
+_EXTERN_INLINE void
 __pthread_stack_dealloc (void *stackaddr, size_t stacksize)
 {
   /* XXX: can only implement this once we have a working memory manager.  */
   return;
 }
 
+#endif /* __USE_EXTERN_INLINES  */
+
 #endif /* pt-sysdep.h */
diff -ur hurd.old/libpthread/sysdeps/mach/bits/spin-lock.h 
hurd/libpthread/sysdeps/mach/bits/spin-lock.h
--- hurd.old/libpthread/sysdeps/mach/bits/spin-lock.h   2002-10-11 
01:05:05.000000000 +0200
+++ hurd/libpthread/sysdeps/mach/bits/spin-lock.h       2003-03-09 
14:50:51.000000000 +0100
@@ -70,10 +70,10 @@
   return __spin_try_lock (__lock) ? 0 : __EBUSY;
 }
 
-extern inline int __pthread_spin_lock (__pthread_spinlock_t *__lock);
+__PT_SPIN_INLINE int __pthread_spin_lock (__pthread_spinlock_t *__lock);
 extern int _pthread_spin_lock (__pthread_spinlock_t *__lock);
 
-extern inline int
+__PT_SPIN_INLINE int
 __pthread_spin_lock (__pthread_spinlock_t *__lock)
 {
   if (__pthread_spin_trylock (__lock))
diff -ur hurd.old/libpthread/sysdeps/mach/hurd/pt-sysdep.h 
hurd/libpthread/sysdeps/mach/hurd/pt-sysdep.h
--- hurd.old/libpthread/sysdeps/mach/hurd/pt-sysdep.h   2002-11-19 
18:00:53.000000000 +0100
+++ hurd/libpthread/sysdeps/mach/hurd/pt-sysdep.h       2003-03-09 
14:54:49.000000000 +0100
@@ -52,12 +52,21 @@
           thread;                                                  \
          })
 
-extern inline void
+
+#ifdef __USE_EXTERN_INLINES
+                                                                               
 
+# ifndef _EXTERN_INLINE
+#  define _EXTERN_INLINE extern __inline
+# endif
+
+_EXTERN_INLINE void
 __pthread_stack_dealloc (void *stackaddr, size_t stacksize)
 {
   __vm_deallocate (__mach_task_self (), (vm_offset_t) stackaddr, stacksize);
 }
 
+#endif /* __USE_EXTERN_INLINES  */
+
 /* Change thread THREAD's program counter to PC if SET_PC is true and
    its stack pointer to SP if SET_IP is true.  */
 extern int __thread_set_pcsp (thread_t thread,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]