about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Holk <eholk@mozilla.com>2011-06-28 11:34:20 -0700
committerGraydon Hoare <graydon@mozilla.com>2011-06-28 16:12:33 -0700
commit02f6645fca946fd7cb9f55036c05a908f0567ceb (patch)
tree88d71ff1fd10f3f8312f2c8a1041d7eeaf0251e4
parent2f84987a48c3625670cd62321f0e3dcb5c0e8768 (diff)
downloadrust-02f6645fca946fd7cb9f55036c05a908f0567ceb.tar.gz
rust-02f6645fca946fd7cb9f55036c05a908f0567ceb.zip
Moved win32_require to the kernel.
-rw-r--r--src/rt/rust.cpp6
-rw-r--r--src/rt/rust_dom.cpp19
-rw-r--r--src/rt/rust_dom.h4
-rw-r--r--src/rt/rust_kernel.cpp19
-rw-r--r--src/rt/rust_kernel.h6
-rw-r--r--src/rt/rust_timer.cpp7
-rw-r--r--src/rt/rust_util.h6
7 files changed, 34 insertions, 33 deletions
diff --git a/src/rt/rust.cpp b/src/rt/rust.cpp
index 19f114d29a9..c2a56d993d8 100644
--- a/src/rt/rust.cpp
+++ b/src/rt/rust.cpp
@@ -23,16 +23,16 @@ command_line_args : public kernel_owned<command_line_args>
 #if defined(__WIN32__)
         LPCWSTR cmdline = GetCommandLineW();
         LPWSTR *wargv = CommandLineToArgvW(cmdline, &argc);
-        task->dom->win32_require("CommandLineToArgvW", wargv != NULL);
+        kernel->win32_require("CommandLineToArgvW", wargv != NULL);
         argv = (char **) kernel->malloc(sizeof(char*) * argc);
         for (int i = 0; i < argc; ++i) {
             int n_chars = WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1,
                                               NULL, 0, NULL, NULL);
-            task->dom->win32_require("WideCharToMultiByte(0)", n_chars != 0);
+            kernel->win32_require("WideCharToMultiByte(0)", n_chars != 0);
             argv[i] = (char *) kernel->malloc(n_chars);
             n_chars = WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1,
                                           argv[i], n_chars, NULL, NULL);
-            task->dom->win32_require("WideCharToMultiByte(1)", n_chars != 0);
+            kernel->win32_require("WideCharToMultiByte(1)", n_chars != 0);
         }
         LocalFree(wargv);
 #endif
diff --git a/src/rt/rust_dom.cpp b/src/rt/rust_dom.cpp
index d89cb181fb8..ac3c3a82a40 100644
--- a/src/rt/rust_dom.cpp
+++ b/src/rt/rust_dom.cpp
@@ -74,25 +74,6 @@ rust_dom::fail() {
     rval = 1;
 }
 
-#ifdef __WIN32__
-void
-rust_dom::win32_require(LPCTSTR fn, BOOL ok) {
-    if (!ok) {
-        LPTSTR buf;
-        DWORD err = GetLastError();
-        FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
-                      FORMAT_MESSAGE_FROM_SYSTEM |
-                      FORMAT_MESSAGE_IGNORE_INSERTS,
-                      NULL, err,
-                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                      (LPTSTR) &buf, 0, NULL );
-        DLOG_ERR(this, dom, "%s failed with error %ld: %s", fn, err, buf);
-        LocalFree((HLOCAL)buf);
-        I(this, ok);
-    }
-}
-#endif
-
 size_t
 rust_dom::number_of_live_tasks() {
     return running_tasks.length() + blocked_tasks.length();
diff --git a/src/rt/rust_dom.h b/src/rt/rust_dom.h
index b936a0e580a..04a42b5fb01 100644
--- a/src/rt/rust_dom.h
+++ b/src/rt/rust_dom.h
@@ -75,10 +75,6 @@ struct rust_dom : public kernel_owned<rust_dom>, rc_base<rust_dom>
 
     void drain_incoming_message_queue(bool process);
 
-#ifdef __WIN32__
-    void win32_require(LPCTSTR fn, BOOL ok);
-#endif
-
     rust_crate_cache *get_cache();
     size_t number_of_live_tasks();
 
diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp
index 5e495b8c822..ee709fb191f 100644
--- a/src/rt/rust_kernel.cpp
+++ b/src/rt/rust_kernel.cpp
@@ -245,6 +245,25 @@ int rust_kernel::start_task_threads(int num_threads)
     return dom->rval;
 }
 
+#ifdef __WIN32__
+void
+rust_kernel::win32_require(LPCTSTR fn, BOOL ok) {
+    if (!ok) {
+        LPTSTR buf;
+        DWORD err = GetLastError();
+        FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+                      FORMAT_MESSAGE_FROM_SYSTEM |
+                      FORMAT_MESSAGE_IGNORE_INSERTS,
+                      NULL, err,
+                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                      (LPTSTR) &buf, 0, NULL );
+        DLOG_ERR(dom, dom, "%s failed with error %ld: %s", fn, err, buf);
+        LocalFree((HLOCAL)buf);
+        I(dom, ok);
+    }
+}
+#endif
+
 rust_task_thread::rust_task_thread(int id, rust_kernel *owner)
     : id(id), owner(owner)
 {
diff --git a/src/rt/rust_kernel.h b/src/rt/rust_kernel.h
index 5e03d8072d6..b3befab28d2 100644
--- a/src/rt/rust_kernel.h
+++ b/src/rt/rust_kernel.h
@@ -110,10 +110,14 @@ public:
     void *malloc(size_t size);
     void free(void *mem);
 
-    // TODO: this should go away
+    // FIXME: this should go away
     inline rust_dom *get_domain() const { return dom; }
 
     int start_task_threads(int num_threads);
+
+#ifdef __WIN32__
+    void win32_require(LPCTSTR fn, BOOL ok);
+#endif
 };
 
 class rust_task_thread : public rust_thread {
diff --git a/src/rt/rust_timer.cpp b/src/rt/rust_timer.cpp
index 79cb1615bbc..2d732a23591 100644
--- a/src/rt/rust_timer.cpp
+++ b/src/rt/rust_timer.cpp
@@ -57,7 +57,7 @@ rust_timer::rust_timer(rust_dom *dom) :
     DLOG(dom, timer, "creating timer for domain 0x%" PRIxPTR, dom);
 #if defined(__WIN32__)
     thread = CreateThread(NULL, 0, timer_loop, this, 0, NULL);
-    dom->win32_require("CreateThread", thread != NULL);
+    dom->kernel->win32_require("CreateThread", thread != NULL);
     if (RUNNING_ON_VALGRIND)
         Sleep(10);
 #else
@@ -70,8 +70,9 @@ rust_timer::rust_timer(rust_dom *dom) :
 rust_timer::~rust_timer() {
     exit_flag = 1;
 #if defined(__WIN32__)
-    dom->win32_require("WaitForSingleObject",
-            WaitForSingleObject(thread, INFINITE) == WAIT_OBJECT_0);
+    dom->kernel->win32_require("WaitForSingleObject",
+                               WaitForSingleObject(thread, INFINITE) == 
+                               WAIT_OBJECT_0);
 #else
     pthread_join(thread, NULL);
 #endif
diff --git a/src/rt/rust_util.h b/src/rt/rust_util.h
index 260f7eb9d5d..bd888c108f1 100644
--- a/src/rt/rust_util.h
+++ b/src/rt/rust_util.h
@@ -134,15 +134,15 @@ isaac_init(rust_dom *dom, randctx *rctx)
 #ifdef __WIN32__
         {
             HCRYPTPROV hProv;
-            dom->win32_require
+            dom->kernel->win32_require
                 (_T("CryptAcquireContext"),
                  CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL,
                                      CRYPT_VERIFYCONTEXT|CRYPT_SILENT));
-            dom->win32_require
+            dom->kernel->win32_require
                 (_T("CryptGenRandom"),
                  CryptGenRandom(hProv, sizeof(rctx->randrsl),
                                 (BYTE*)(&rctx->randrsl)));
-            dom->win32_require
+            dom->kernel->win32_require
                 (_T("CryptReleaseContext"),
                  CryptReleaseContext(hProv, 0));
         }