[kaffe] CVS kaffe (robilad): fixed volatile qualifier compiler warnings

Kaffe CVS cvs-commits at kaffe.org
Fri Apr 14 11:08:37 PDT 2006


PatchSet 7220 
Date: 2006/04/14 18:01:01
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
fixed volatile qualifier compiler warnings

2006-04-14  Dalibor Topic  <robilad at kaffe.org>

* kaffe/kaffevm/ksem.h,
kaffe/kaffevm/ksem.c (ksem_put, ksem_get),
kaffe/kaffevm/locks.c (getHeavyLock, putHeavyLock, slowLockMutex,
slowUnlockMutex, locks_internal_slowUnlockMutexIfHeld,
locks_internal_waitCond, locks_internal_signalCond,
locks_internal_broadcastCond, locks_internal_lockMutex) Removed
volatile qualifiers and casts to fix compiler warnings.

Members: 
	ChangeLog:1.4726->1.4727 
	kaffe/kaffevm/ksem.c:INITIAL->1.16 
	kaffe/kaffevm/ksem.h:INITIAL->1.14 
	kaffe/kaffevm/locks.c:1.70->1.71 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4726 kaffe/ChangeLog:1.4727
--- kaffe/ChangeLog:1.4726	Thu Apr 13 21:15:35 2006
+++ kaffe/ChangeLog	Fri Apr 14 18:01:01 2006
@@ -1,3 +1,13 @@
+2006-04-14  Dalibor Topic  <robilad at kaffe.org>
+
+	* kaffe/kaffevm/ksem.h,
+	kaffe/kaffevm/ksem.c (ksem_put, ksem_get),
+	kaffe/kaffevm/locks.c (getHeavyLock, putHeavyLock, slowLockMutex,
+	slowUnlockMutex, locks_internal_slowUnlockMutexIfHeld, 
+	locks_internal_waitCond, locks_internal_signalCond, 
+	locks_internal_broadcastCond, locks_internal_lockMutex) Removed
+	volatile qualifiers and casts to fix compiler warnings.
+	
 2006-04-13  Riccardo Mottola <riccardo at kaffe.org>
 
 	* libraries/javalib/awt-implementations/kaffe/java/awt/Component.java:
===================================================================
Checking out kaffe/kaffe/kaffevm/ksem.c
RCS:  /home/cvs/kaffe/kaffe/kaffe/kaffevm/ksem.c,v
VERS: 1.16
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/kaffe/kaffevm/ksem.c	Fri Apr 14 18:08:36 2006
@@ -0,0 +1,101 @@
+/*
+ * ksem.c
+ *
+ * Copyright (c) 200
+ *	University of Utah.  All Rights Reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution 
+ * of this file. 
+ */
+
+#include "debug.h"
+#include "ksem.h"
+#include "support.h"
+
+#ifndef THREAD_SYSTEM_HAS_KSEM
+
+/*
+ * Initialize the just-allocated Ksem.  This function is only invoked
+ * by the threading system when a new thread is allocated.
+ */
+void
+ksem_init(Ksem* sem)
+{
+	assert(sem != NULL);
+	
+	jmutex_initialise(&(sem->mux));
+	jcondvar_initialise(&(sem->cv));
+	sem->count = 0;
+}
+
+/**
+ * Use a stored wakeup from the semaphore.  Block if none
+ * are available.  Can wait with a timeout.  (If timeout is 0, then
+ * do not timeout in wait.)
+ * Spurious wakeups are not handled here.
+ *
+ * @param sem Semaphore to wait for.
+ * @param timeout The number of milliseconds to wait if different of 0.
+ * If timeout is null, wait indefinitely.
+ * @return true if the semaphore was acquired, returns false if
+ * we timed-out in wait and semaphore still wasn't available.
+ */
+jboolean
+ksem_get(Ksem* sem, jlong timeout)
+{
+	jboolean r;
+
+	assert(sem != NULL);
+	
+	r = true;
+
+	if (timeout == 0)
+	  timeout = NOTIMEOUT;
+
+	DBG(KSEM,
+		dprintf("ksem_get sp=%p\n", &r);
+	);
+
+	KMUTEX(lock)(&sem->mux);
+	/* If no stored wakeups, then sleep. */
+	if (sem->count == 0) {
+	  (void)KCONDVAR(wait)(&sem->cv, &sem->mux, timeout);
+	}
+
+	/* Use a stored wakeup if available. */
+	if (sem->count > 0) {
+	  sem->count--;
+	  r = true;
+	}
+	else {
+	  /* Still no stored wakeup means we waited and timedout. */
+	  r = false;
+	}
+	assert(sem->count >= 0);
+	KMUTEX(unlock)(&sem->mux);
+	return (r);
+}
+
+/*
+ * Store a wakeup in the semaphore.  Wakeup one thread blocked
+ * on the cv (if any).
+ */
+void
+ksem_put(Ksem* sem)
+{
+	assert(sem != NULL);
+	KMUTEX(lock)(&sem->mux);
+        sem->count++;
+	KCONDVAR(signal)(&sem->cv, &sem->mux);
+	KMUTEX(unlock)(&sem->mux);
+}
+
+void
+ksem_destroy(Ksem* sem)
+{
+	assert(sem != NULL);
+	KMUTEX(destroy)(&(sem->mux));
+	KCONDVAR(destroy)(&(sem->cv));
+}
+
+#endif
===================================================================
Checking out kaffe/kaffe/kaffevm/ksem.h
RCS:  /home/cvs/kaffe/kaffe/kaffe/kaffevm/ksem.h,v
VERS: 1.14
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/kaffe/kaffevm/ksem.h	Fri Apr 14 18:08:37 2006
@@ -0,0 +1,57 @@
+/*
+ * ksem.h
+ *
+ * Copyright (c) 200
+ *	University of Utah.  All Rights Reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution 
+ * of this file. 
+ */
+
+#ifndef kaffevm_ksem_h
+#define kaffevm_ksem_h
+
+#include "config-std.h"
+#include "gtypes.h"
+#include "jsyscall.h"
+
+/*
+ * The ksem interface.
+ */
+struct Ksem;
+
+/*
+ * Include the system locking layer interface.  See if it gives us
+ * Ksem's or jmutex/jcondvar's (see FAQ.locks).
+ */
+
+#include "lock-impl.h"
+
+/*
+ * Threading packages for Kaffe have two choices for implementing
+ * Ksems.  They can either implement the ksem interface directly
+ * (useful if the underlying system has semaphore support).  Or they
+ * can provide the jmutex/jcondvar interface.  See FAQ/FAQ.locks
+ * for more information.
+ *
+ * If it doesn't provide KSEM, then assume it provides jmutex/jcondvar
+ * and use that.
+ */
+#ifndef THREAD_SYSTEM_HAS_KSEM
+
+extern void ksem_init(struct Ksem* sem);
+extern void ksem_put(struct Ksem* sem);
+extern jboolean ksem_get(struct Ksem* sem, jlong timeout);
+extern void ksem_destroy(struct Ksem* sem);
+
+/*
+ * Present POSIX mutex+condvar as a binary semaphore.
+ */
+typedef struct Ksem {
+	jmutex		mux;
+	jcondvar	cv;
+	int		count;
+} Ksem;
+
+#endif /* !defined(JTHREAD_HAS_KSEM) */
+#endif /* kaffevm_ksem_h */
Index: kaffe/kaffe/kaffevm/locks.c
diff -u kaffe/kaffe/kaffevm/locks.c:1.70 kaffe/kaffe/kaffevm/locks.c:1.71
--- kaffe/kaffe/kaffevm/locks.c:1.70	Sat Mar 11 11:09:51 2006
+++ kaffe/kaffe/kaffevm/locks.c	Fri Apr 14 18:01:06 2006
@@ -71,10 +71,10 @@
 
 #define IS_HEAVY_LOCK(ptr) ((((uintp)ptr)&1)==1)
 
-static volatile iLock *
-getHeavyLock(volatile iLock* volatile * lkp, volatile iLock *heavyLock)
+static iLock *
+getHeavyLock(iLock** lkp, iLock *heavyLock)
 {
-  volatile iLock *lk;
+  iLock *lk;
   iLock *newLock;
 
   DBG(SLOWLOCKS,
@@ -193,7 +193,7 @@
  * so there's no need for locked instructions.
  */
 static void
-putHeavyLock(volatile iLock* lk)
+putHeavyLock(iLock* lk)
 {
   DBG(SLOWLOCKS,
       dprintf("  putHeavyLock(lk=%p, th=%p)\n", 
@@ -213,9 +213,9 @@
  * If we can't lock it we suspend until we can.
  */
 static void
-slowLockMutex(volatile iLock* volatile * lkp, iLock *heavyLock)
+slowLockMutex(iLock** lkp, iLock *heavyLock)
 {
-  volatile iLock* lk;
+  iLock* lk;
   jthread_t cur = KTHREAD(current) ();
   threadData *tdata;
   int r;
@@ -274,9 +274,9 @@
  * a fast thin lock.
  */
 static void
-slowUnlockMutex(volatile iLock* volatile * lkp, iLock *heavyLock)
+slowUnlockMutex(iLock** lkp, iLock *heavyLock)
 {
-  volatile iLock* lk;
+  iLock* lk;
   jthread_t tid;
   jthread_t cur = KTHREAD(current)();
 
@@ -329,7 +329,7 @@
 void
 locks_internal_slowUnlockMutexIfHeld(iLock** lkp, iLock *heavyLock)
 {
-  volatile iLock* lk;
+  iLock* lk;
   volatile void* holder;
   jthread_t cur = KTHREAD(current)();
   
@@ -350,18 +350,18 @@
     return;
 
   /* ok, it is a heavy lock and it is acquired by someone. */
-  lk = getHeavyLock((volatile iLock *volatile *)lkp, heavyLock);
+  lk = getHeavyLock(lkp, heavyLock);
   holder = lk->holder;
   putHeavyLock(lk);
   
   if (holder == cur)
-    slowUnlockMutex((volatile iLock *volatile *)lkp, heavyLock);
+    slowUnlockMutex(lkp, heavyLock);
 }
 
 jboolean
 locks_internal_waitCond(iLock** lkp, iLock *heavyLock, jlong timeout)
 {
-  volatile iLock* lk;
+  iLock* lk;
   volatile void* holder;
   jthread_t cur = KTHREAD(current)();
   volatile jthread_t *ptr;
@@ -374,7 +374,7 @@
 	      *lkp, (long)timeout, KTHREAD(current)());
       );
   
-  lk = getHeavyLock((volatile iLock *volatile *)lkp, heavyLock);
+  lk = getHeavyLock(lkp, heavyLock);
   holder = lk->holder;
   
   /* I must be holding the damn thing */
@@ -393,12 +393,12 @@
   lk->lockCount = 1;
 
   putHeavyLock(lk);
-  slowUnlockMutex((volatile iLock *volatile *)lkp, heavyLock);
+  slowUnlockMutex(lkp, heavyLock);
   r = KSEM(get)(&tdata->sem, timeout);
   
   /* Timeout */
   if (r == false) {
-    lk = getHeavyLock((volatile iLock *volatile *)lkp, heavyLock);
+    lk = getHeavyLock(lkp, heavyLock);
     /* Remove myself from CV or MUX queue - if I'm * not on either
      * then I should wait on myself to remove any pending signal.
      */
@@ -423,7 +423,7 @@
     putHeavyLock(lk);
   }
   
-  slowLockMutex((volatile iLock *volatile *)lkp, heavyLock);
+  slowLockMutex(lkp, heavyLock);
   /* This is safe as no other thread touches the lockcount if it is not
    * owning the lock.
    */
@@ -435,7 +435,7 @@
 void
 locks_internal_signalCond(iLock** lkp, iLock *heavyLock)
 {
-  volatile iLock* lk;
+  iLock* lk;
   jthread_t tid;
   
   DBG(SLOWLOCKS,
@@ -443,7 +443,7 @@
 	      *lkp, KTHREAD(current)());
       );
   
-  lk = getHeavyLock((volatile iLock *volatile *)lkp, heavyLock);
+  lk = getHeavyLock(lkp, heavyLock);
   
   if (lk->holder != KTHREAD(current)()) {
     putHeavyLock(lk);
@@ -466,7 +466,7 @@
 void
 locks_internal_broadcastCond(iLock** lkp, iLock *heavyLock)
 {
-  volatile iLock* lk;
+  iLock* lk;
   jthread_t tid;
   
   DBG(SLOWLOCKS,
@@ -474,7 +474,7 @@
 	      *lkp, KTHREAD(current)());
       );
   
-  lk = getHeavyLock((volatile iLock *volatile *)lkp, heavyLock);
+  lk = getHeavyLock(lkp, heavyLock);
 
   if (lk->holder != KTHREAD(current)()) {
     putHeavyLock(lk);
@@ -504,7 +504,7 @@
 locks_internal_lockMutex(iLock** lkp, iLock *heavyLock)
 {  
   if (!COMPARE_AND_EXCHANGE(lkp, LOCKFREE, (iLock *)KTHREAD(current)()))
-      slowLockMutex((volatile iLock *volatile *)lkp, heavyLock);
+      slowLockMutex(lkp, heavyLock);
 }
 
 /*
@@ -516,7 +516,7 @@
 {
   /* slowUnlockMutex should be fast enough. */
   if (!COMPARE_AND_EXCHANGE(lkp, (iLock *)KTHREAD(current)(), LOCKFREE))
-    slowUnlockMutex((volatile iLock * volatile *)lkp, heavyLock);
+    slowUnlockMutex(lkp, heavyLock);
 }
 
 void
@@ -561,7 +561,7 @@
 	}
     }
 #endif
-  slowLockMutex((volatile iLock * volatile *)&obj->lock, NULL);
+  slowLockMutex(&obj->lock, NULL);
 #if defined(ENABLE_JVMPI)
   if( JVMPI_EVENT_ISENABLED(JVMPI_EVENT_MONITOR_CONTENDED_ENTERED) && isContention)
     {
@@ -591,7 +591,7 @@
 	}
     }
 #endif
-  slowUnlockMutex((volatile iLock *volatile *)&obj->lock, NULL);
+  slowUnlockMutex(&obj->lock, NULL);
 }
 
 void




More information about the kaffe mailing list