x86 JNI compiler and unit tests.
Change-Id: I4c2e10328961a2e8e27c90777fe2a93737b21143
diff --git a/src/thread.cc b/src/thread.cc
index 60e977f..7c76f4c 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -2,11 +2,11 @@
#include "src/thread.h"
+#include <pthread.h>
+#include <sys/mman.h>
#include <algorithm>
#include <cerrno>
#include <list>
-#include <pthread.h>
-#include <sys/mman.h>
#include "src/runtime.h"
#include "src/utils.h"
@@ -18,7 +18,7 @@
Mutex* Mutex::Create(const char* name) {
Mutex* mu = new Mutex(name);
int result = pthread_mutex_init(&mu->lock_impl_, NULL);
- CHECK(result == 0);
+ CHECK_EQ(0, result);
return mu;
}
@@ -79,6 +79,8 @@
result = pthread_attr_destroy(&attr);
CHECK_EQ(result, 0);
+ InitCpu();
+
return new_thread;
}
@@ -100,6 +102,8 @@
PLOG(FATAL) << "pthread_setspecific failed";
}
+ InitCpu();
+
return thread;
}
@@ -125,6 +129,24 @@
return true;
}
+static const char* kStateNames[] = {
+ "New",
+ "Runnable",
+ "Blocked",
+ "Waiting",
+ "TimedWaiting",
+ "Native",
+ "Terminated",
+};
+std::ostream& operator<<(std::ostream& os, const Thread::State& state) {
+ if (state >= Thread::kNew && state <= Thread::kTerminated) {
+ os << kStateNames[state-Thread::kNew];
+ } else {
+ os << "State[" << static_cast<int>(state) << "]";
+ }
+ return os;
+}
+
ThreadList* ThreadList::Create() {
return new ThreadList;
}