You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2007/10/28 12:32:41 UTC

svn commit: r589339 - /harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c

Author: hindessm
Date: Sun Oct 28 04:32:41 2007
New Revision: 589339

URL: http://svn.apache.org/viewvc?rev=589339&view=rev
Log:
Fix and stubs for FreeBSD.

Modified:
    harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c?rev=589339&r1=589338&r2=589339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c Sun Oct 28 04:32:41 2007
@@ -17,13 +17,16 @@
 
 #include <assert.h>
 #include <apr_atomic.h>
+#if defined(LINUX)
 #include <linux/unistd.h>	// gettid()
+#endif
 #include <sched.h>		// sched_param
 #include <semaphore.h>
 #include <unistd.h>
 
 #include "thread_private.h"
 
+#ifdef LINUX
 #ifdef _syscall0
 _syscall0(pid_t,gettid)
 pid_t gettid(void);
@@ -33,6 +36,7 @@
     return (pid_t)syscall(__NR_gettid);
 }
 #endif
+#endif
 
 /**
  * Creates new thread.
@@ -91,6 +95,17 @@
  */
 int os_thread_set_priority(osthread_t os_thread, int priority)
 {
+#if defined(FREEBSD)
+    /* Not sure why we don't just use this on linux? - MRH */
+    struct sched_param param;
+    int policy;
+    int r = pthread_getschedparam(os_thread, &policy, &param);
+    if (r == 0) {
+        param.sched_priority = priority;
+        r = pthread_setschedparam(os_thread, policy, &param);
+    }
+    return r;
+#else
     // setting thread priority on linux is only supported for current thread
     if (os_thread == pthread_self()) {
 	int r;
@@ -103,6 +118,7 @@
         // setting other thread priority not supported on linux
         return 0;
     }
+#endif
 }
 
 /**
@@ -213,6 +229,9 @@
     clockid_t clock_id;
     struct timespec tp;
     int r;
+#ifdef FREEBSD
+    return EINVAL; /* TOFIX: Implement */
+#else
 
     r = pthread_getcpuclockid(os_thread, &clock_id);
     if (r) return r;
@@ -222,6 +241,7 @@
 
     *puser = tp.tv_sec * 1000000000ULL + tp.tv_nsec;
     return 0;
+#endif
 }
 
 UDATA os_get_foreign_thread_stack_size() {