Bug 568068 - fix jscntxt/jsnativestack build breaks on OS/2 (r=wuno)
authorRich Walsh <dragtext@e-vertise.com>
Tue, 01 Jun 2010 14:48:58 -0700
changeset 43220 cc6d850f4028b9a03b5ff6183ffbc1c6d8d924ae
parent 43219 4b0c9535865dffe183c506bb7cf44dddf16b368a
child 43221 6b5e3d5422d9499e6af500d4118d5e2b542b6968
push id13641
push userrsayre@mozilla.com
push dateSun, 06 Jun 2010 19:08:23 +0000
treeherdermozilla-central@5b3604a3cfbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswuno
bugs568068
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 568068 - fix jscntxt/jsnativestack build breaks on OS/2 (r=wuno)
js/src/jscntxt.cpp
js/src/jsnativestack.cpp
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -72,16 +72,19 @@
 #include "jsstr.h"
 #include "jstracer.h"
 #include "jsnativestack.h"
 
 #include "jscntxtinlines.h"
 
 #ifdef XP_WIN
 # include <windows.h>
+#elif defined(XP_OS2)
+# define INCL_DOSMEMMGR
+# include <os2.h>
 #else
 # include <unistd.h>
 # include <sys/mman.h>
 # if !defined(MAP_ANONYMOUS)
 #  if defined(MAP_ANON)
 #   define MAP_ANONYMOUS MAP_ANON
 #  else
 #   define MAP_ANONYMOUS 0
@@ -131,16 +134,22 @@ StackSpace::init()
     if (!p)
         return false;
     void *check = VirtualAlloc(p, COMMIT_BYTES, MEM_COMMIT, PAGE_READWRITE);
     if (p != check)
         return false;
     base = reinterpret_cast<jsval *>(p);
     commitEnd = base + COMMIT_VALS;
     end = base + CAPACITY_VALS;
+#elif defined(XP_OS2)
+    if (DosAllocMem(&p, CAPACITY_BYTES, PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_ANY) &&
+        DosAllocMem(&p, CAPACITY_BYTES, PAG_COMMIT | PAG_READ | PAG_WRITE))
+        return false;
+    base = reinterpret_cast<jsval *>(p);
+    end = base + CAPACITY_VALS;
 #else
     JS_ASSERT(CAPACITY_BYTES % getpagesize() == 0);
     p = mmap(NULL, CAPACITY_BYTES, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
     if (p == MAP_FAILED)
         return false;
     base = reinterpret_cast<jsval *>(p);
     end = base + CAPACITY_VALS;
 #endif
@@ -148,16 +157,18 @@ StackSpace::init()
 }
 
 void
 StackSpace::finish()
 {
 #ifdef XP_WIN
     VirtualFree(base, (commitEnd - base) * sizeof(jsval), MEM_DECOMMIT);
     VirtualFree(base, 0, MEM_RELEASE);
+#elif defined(XP_OS2)
+    DosFreeMem(base);
 #else
     munmap(base, CAPACITY_BYTES);
 #endif
 }
 
 #ifdef XP_WIN
 JS_FRIEND_API(bool)
 StackSpace::bumpCommit(jsval *from, ptrdiff_t nvals) const
--- a/js/src/jsnativestack.cpp
+++ b/js/src/jsnativestack.cpp
@@ -38,16 +38,20 @@
 
 #include <stdlib.h>
 #include "jstypes.h"
 #include "jsnativestack.h"
 
 #ifdef XP_WIN
 # include <windows.h>
 
+#elif defined(XP_OS2)
+# define INCL_DOSPROCESS
+# include <os2.h>
+
 #elif defined(XP_MACOSX) || defined(DARWIN) || defined(XP_UNIX)
 # include <pthread.h>
 
 # if defined(__FreeBSD__)
 #  include <pthread_np.h>
 # endif
 
 #else
@@ -137,17 +141,29 @@ GetNativeStackBaseImpl()
 # elif defined(_WIN32) && defined(__GNUC__)
     NT_TIB* pTib;
     asm ("movl %%fs:0x18, %0\n" : "=r" (pTib));
     return static_cast<void*>(pTib->StackBase);
 
 # endif
 }
 
-#else /* !XP_WIN */
+#elif defined(XP_OS2)
+
+void *
+GetNativeStackBaseImpl()
+{
+    PTIB  ptib;
+    PPIB  ppib;
+
+    DosGetInfoBlocks(&ptib, &ppib);
+    return ptib->tib_pstacklimit;
+}
+
+#else /* XP_UNIX */
 
 void *
 GetNativeStackBaseImpl()
 {
     pthread_t thread = pthread_self();
 # if defined(XP_MACOSX) || defined(DARWIN)
     return pthread_get_stackaddr_np(thread);