This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Use _pthread_fastlock more widely



I think this change should be uncontroversial.  The motivation
is so we can use a different struct _pthread_fastlock definition
on hppa.  That patch will follow.  BTW, the Changelog entry is for
linuxthreads/Changelog; is this correct procedure?

2001-02-02  John S. Marvin  <jsm@udlkern.fc.hp.com>

	* semaphore.h: Use struct _pthread_fastlock as an element of
	sem_t instead of an identical struct.
	* rwlock.c: Remove casts.
	* semaphore.c: Likewise.

diff -urNx CVS glibc-223/linuxthreads/rwlock.c glibc-merge/linuxthreads/rwlock.c
--- glibc-223/linuxthreads/rwlock.c	Mon Jan 15 14:35:20 2001
+++ glibc-merge/linuxthreads/rwlock.c	Fri Feb  2 04:58:54 2001
@@ -36,9 +36,9 @@
   pthread_rwlock_t *rwlock = obj;
   int did_remove = 0;
 
-  __pthread_lock((struct _pthread_fastlock *) &rwlock->__rw_lock, NULL);
+  __pthread_lock(&rwlock->__rw_lock, NULL);
   did_remove = remove_from_queue(&rwlock->__rw_read_waiting, th);
-  __pthread_unlock((struct _pthread_fastlock *) &rwlock->__rw_lock);
+  __pthread_unlock(&rwlock->__rw_lock);
 
   return did_remove;
 }
@@ -48,9 +48,9 @@
   pthread_rwlock_t *rwlock = obj;
   int did_remove = 0;
 
-  __pthread_lock((struct _pthread_fastlock *) &rwlock->__rw_lock, NULL);
+  __pthread_lock(&rwlock->__rw_lock, NULL);
   did_remove = remove_from_queue(&rwlock->__rw_write_waiting, th);
-  __pthread_unlock((struct _pthread_fastlock *) &rwlock->__rw_lock);
+  __pthread_unlock(&rwlock->__rw_lock);
 
   return did_remove;
 }
diff -urNx CVS glibc-223/linuxthreads/semaphore.c glibc-merge/linuxthreads/semaphore.c
--- glibc-223/linuxthreads/semaphore.c	Tue Apr 24 14:10:57 2001
+++ glibc-merge/linuxthreads/semaphore.c	Wed Apr 25 17:05:52 2001
@@ -33,7 +33,7 @@
     errno = ENOSYS;
     return -1;
   }
-  __pthread_init_lock((struct _pthread_fastlock *) &sem->__sem_lock);
+  __pthread_init_lock(&sem->__sem_lock);
   sem->__sem_value = value;
   sem->__sem_waiting = NULL;
   return 0;
@@ -48,9 +48,9 @@
   sem_t *sem = obj;
   int did_remove = 0;
 
-  __pthread_lock((struct _pthread_fastlock *) &sem->__sem_lock, self);
+  __pthread_lock(&sem->__sem_lock, self);
   did_remove = remove_from_queue(&sem->__sem_waiting, th);
-  __pthread_unlock((struct _pthread_fastlock *) &sem->__sem_lock);
+  __pthread_unlock(&sem->__sem_lock);
 
   return did_remove;
 }
@@ -66,10 +66,10 @@
   extr.pu_object = sem;
   extr.pu_extricate_func = new_sem_extricate_func;
 
-  __pthread_lock((struct _pthread_fastlock *) &sem->__sem_lock, self);
+  __pthread_lock(&sem->__sem_lock, self);
   if (sem->__sem_value > 0) {
     sem->__sem_value--;
-    __pthread_unlock((struct _pthread_fastlock *) &sem->__sem_lock);
+    __pthread_unlock(&sem->__sem_lock);
     return 0;
   }
   /* Register extrication interface */
@@ -81,7 +81,7 @@
     enqueue(&sem->__sem_waiting, self);
   else
     already_canceled = 1;
-  __pthread_unlock((struct _pthread_fastlock *) &sem->__sem_lock);
+  __pthread_unlock(&sem->__sem_lock);
 
   if (already_canceled) {
     __pthread_set_own_extricate_if(self, 0);
@@ -121,7 +121,7 @@
 {
   int retval;
 
-  __pthread_lock((struct _pthread_fastlock *) &sem->__sem_lock, NULL);
+  __pthread_lock(&sem->__sem_lock, NULL);
   if (sem->__sem_value == 0) {
     errno = EAGAIN;
     retval = -1;
@@ -129,7 +129,7 @@
     sem->__sem_value--;
     retval = 0;
   }
-  __pthread_unlock((struct _pthread_fastlock *) &sem->__sem_lock);
+  __pthread_unlock(&sem->__sem_lock);
   return retval;
 }
 
@@ -140,19 +140,19 @@
   struct pthread_request request;
 
   if (THREAD_GETMEM(self, p_in_sighandler) == NULL) {
-    __pthread_lock((struct _pthread_fastlock *) &sem->__sem_lock, self);
+    __pthread_lock(&sem->__sem_lock, self);
     if (sem->__sem_waiting == NULL) {
       if (sem->__sem_value >= SEM_VALUE_MAX) {
         /* Overflow */
         errno = ERANGE;
-        __pthread_unlock((struct _pthread_fastlock *) &sem->__sem_lock);
+        __pthread_unlock(&sem->__sem_lock);
         return -1;
       }
       sem->__sem_value++;
-      __pthread_unlock((struct _pthread_fastlock *) &sem->__sem_lock);
+      __pthread_unlock(&sem->__sem_lock);
     } else {
       th = dequeue(&sem->__sem_waiting);
-      __pthread_unlock((struct _pthread_fastlock *) &sem->__sem_lock);
+      __pthread_unlock(&sem->__sem_lock);
       th->p_sem_avail = 1;
       WRITE_MEMORY_BARRIER();
       restart(th);
@@ -214,17 +214,17 @@
   int already_canceled = 0;
   int spurious_wakeup_count;
 
-  __pthread_lock((struct _pthread_fastlock *) &sem->__sem_lock, self);
+  __pthread_lock(&sem->__sem_lock, self);
   if (sem->__sem_value > 0) {
     --sem->__sem_value;
-    __pthread_unlock((struct _pthread_fastlock *) &sem->__sem_lock);
+    __pthread_unlock(&sem->__sem_lock);
     return 0;
   }
 
   if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) {
     /* The standard requires that if the function would block and the
        time value is illegal, the function returns with an error.  */
-    __pthread_unlock((struct _pthread_fastlock *) &sem->__sem_lock);
+    __pthread_unlock(&sem->__sem_lock);
     return EINVAL;
   }
 
@@ -241,7 +241,7 @@
     enqueue(&sem->__sem_waiting, self);
   else
     already_canceled = 1;
-  __pthread_unlock((struct _pthread_fastlock *) &sem->__sem_lock);
+  __pthread_unlock(&sem->__sem_lock);
 
   if (already_canceled) {
     __pthread_set_own_extricate_if(self, 0);
@@ -257,9 +257,9 @@
 	/* __pthread_lock will queue back any spurious restarts that
 	   may happen to it. */
 
-	__pthread_lock((struct _pthread_fastlock *)&sem->__sem_lock, self);
+	__pthread_lock(&sem->__sem_lock, self);
 	was_on_queue = remove_from_queue(&sem->__sem_waiting, self);
-	__pthread_unlock((struct _pthread_fastlock *)&sem->__sem_lock);
+	__pthread_unlock(&sem->__sem_lock);
 
 	if (was_on_queue) {
 	  __pthread_set_own_extricate_if(self, 0);
diff -urNx CVS glibc-223/linuxthreads/semaphore.h glibc-merge/linuxthreads/semaphore.h
--- glibc-223/linuxthreads/semaphore.h	Tue Apr 24 14:10:57 2001
+++ glibc-merge/linuxthreads/semaphore.h	Fri Feb  2 04:58:54 2001
@@ -31,11 +31,7 @@
 /* System specific semaphore definition.  */
 typedef struct
 {
-  struct
-  {
-    long int __status;
-    int __spinlock;
-  } __sem_lock;
+  struct _pthread_fastlock __sem_lock;
   int __sem_value;
   _pthread_descr __sem_waiting;
 } sem_t;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]