Bug 1276029 - Add subset of prio.h to PosixNSPR.h so PRFileDesc can be used in SpiderMonkey (r=terrence)
authorLuke Wagner <luke@mozilla.com>
Fri, 15 Jul 2016 12:26:40 -0500
changeset 305086 86a5424096d537c318dd3d90b9f69c3dc6c85bdb
parent 305085 09461dda5ac8cf17b9504d4997fc851c172fb885
child 305087 77fe4e663e345389c4260ea573dbf58afa85da1b
push id79491
push userlwagner@mozilla.com
push dateFri, 15 Jul 2016 23:40:46 +0000
treeherdermozilla-inbound@86a5424096d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs1276029
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1276029 - Add subset of prio.h to PosixNSPR.h so PRFileDesc can be used in SpiderMonkey (r=terrence) MozReview-Commit-ID: JhNhUcg3eC0
config/check_spidermonkey_style.py
js/src/jit/shared/IonAssemblerBufferWithConstantPools.h
js/src/jslock.h
js/src/jspubtd.h
js/src/vm/PosixNSPR.cpp
js/src/vm/PosixNSPR.h
--- a/config/check_spidermonkey_style.py
+++ b/config/check_spidermonkey_style.py
@@ -66,16 +66,18 @@ included_inclnames_to_ignore = set([
     'jsautokw.h',               # generated in $OBJDIR
     'jscustomallocator.h',      # provided by embedders;  allowed to be missing
     'js-config.h',              # generated in $OBJDIR
     'fdlibm.h',                 # fdlibm
     'pratom.h',                 # NSPR
     'prcvar.h',                 # NSPR
     'prerror.h',                # NSPR
     'prinit.h',                 # NSPR
+    'prio.h',                   # NSPR
+    'private/pprio.h',          # NSPR
     'prlink.h',                 # NSPR
     'prlock.h',                 # NSPR
     'prprf.h',                  # NSPR
     'prthread.h',               # NSPR
     'prtypes.h',                # NSPR
     'selfhosted.out.h',         # generated in $OBJDIR
     'shellmoduleloader.out.h',  # generated in $OBJDIR
     'unicode/locid.h',          # ICU
--- a/js/src/jit/shared/IonAssemblerBufferWithConstantPools.h
+++ b/js/src/jit/shared/IonAssemblerBufferWithConstantPools.h
@@ -721,17 +721,17 @@ struct AssemblerBufferWithConstantPools 
             for (size_t i = 0; i < nopFill_; i++)
                 putInt(nopFillInst_);
 
             inhibitNops_ = false;
         }
     }
 
     static const unsigned OOM_FAIL = unsigned(-1);
-    static const unsigned NO_DATA = unsigned(-2);
+    static const unsigned DUMMY_INDEX = unsigned(-2);
 
     // Check if it is possible to add numInst instructions and numPoolEntries
     // constant pool entries without needing to flush the current pool.
     bool hasSpaceForInsts(unsigned numInsts, unsigned numPoolEntries) const
     {
         size_t nextOffset = sizeExcludingCurrentPool();
         // Earliest starting offset for the current pool after adding numInsts.
         // This is the beginning of the pool entries proper, after inserting a
@@ -805,17 +805,17 @@ struct AssemblerBufferWithConstantPools 
                 return OOM_FAIL;
             }
             return result;
         }
 
         // The pool entry index is returned above when allocating an entry, but
         // when not allocating an entry a dummy value is returned - it is not
         // expected to be used by the caller.
-        return NO_DATA;
+        return DUMMY_INDEX;
     }
 
   public:
     // Get the next buffer offset where an instruction would be inserted.
     // This may flush the current constant pool before returning nextOffset().
     BufferOffset nextInstrOffset()
     {
         if (!hasSpaceForInsts(/* numInsts= */ 1, /* numPoolEntries= */ 0)) {
--- a/js/src/jslock.h
+++ b/js/src/jslock.h
@@ -12,18 +12,20 @@
 #ifdef JS_POSIX_NSPR
 
 #include "vm/PosixNSPR.h"
 
 #else /* JS_POSIX_NSPR */
 
 # include "prcvar.h"
 # include "prinit.h"
+# include "prio.h"
 # include "prlock.h"
 # include "prthread.h"
+# include "private/pprio.h"
 
 #endif
 
 inline PRIntervalTime
 DurationToPRInterval(mozilla::TimeDuration duration)
 {
     double millis = duration.ToMilliseconds();
     return millis < double(UINT32_MAX)
--- a/js/src/jspubtd.h
+++ b/js/src/jspubtd.h
@@ -431,9 +431,16 @@ struct PerThreadDataFriendFields
             reinterpret_cast<const char*>(rt) + RuntimeMainThreadOffset);
     }
 
     template <typename T> friend class JS::Rooted;
 };
 
 } /* namespace js */
 
+MOZ_BEGIN_EXTERN_C
+
+// Defined in NSPR prio.h.
+typedef struct PRFileDesc PRFileDesc;
+
+MOZ_END_EXTERN_C
+
 #endif /* jspubtd_h */
--- a/js/src/vm/PosixNSPR.cpp
+++ b/js/src/vm/PosixNSPR.cpp
@@ -365,9 +365,51 @@ PR_WaitCondVar(PRCondVar* cvar, PRInterv
 
         int result = pthread_cond_timedwait(&cvar->cond(), &cvar->lock()->mutex(), &ts);
         if (result == 0 || result == ETIMEDOUT)
             return PR_SUCCESS;
         return PR_FAILURE;
     }
 }
 
+int32_t
+PR_FileDesc2NativeHandle(PRFileDesc* fd)
+{
+    MOZ_CRASH("PR_FileDesc2NativeHandle");
+}
+
+PRStatus
+PR_GetOpenFileInfo(PRFileDesc *fd, PRFileInfo *info)
+{
+    MOZ_CRASH("PR_GetOpenFileInfo");
+}
+
+int32_t
+PR_Seek(PRFileDesc *fd, int32_t offset, PRSeekWhence whence)
+{
+    MOZ_CRASH("PR_Seek");
+}
+
+PRFileMap*
+PR_CreateFileMap(PRFileDesc *fd, int64_t size, PRFileMapProtect prot)
+{
+    MOZ_CRASH("PR_CreateFileMap");
+}
+
+void*
+PR_MemMap(PRFileMap *fmap, int64_t offset, uint32_t len)
+{
+    MOZ_CRASH("PR_MemMap");
+}
+
+PRStatus
+PR_MemUnmap(void *addr, uint32_t len)
+{
+    MOZ_CRASH("PR_MemUnmap");
+}
+
+PRStatus
+PR_CloseFileMap(PRFileMap *fmap)
+{
+    MOZ_CRASH("PR_CloseFileMap");
+}
+
 #endif /* JS_POSIX_NSPR */
--- a/js/src/vm/PosixNSPR.h
+++ b/js/src/vm/PosixNSPR.h
@@ -5,17 +5,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef vm_PosixNSPR_h
 #define vm_PosixNSPR_h
 
 #ifdef JS_POSIX_NSPR
 
 #include <pthread.h>
-#include <stdint.h>
+
+#include "jspubtd.h"
 
 namespace nspr {
 class Thread;
 class Lock;
 class CondVar;
 };
 
 typedef nspr::Thread PRThread;
@@ -133,11 +134,63 @@ uint32_t
 PR_MicrosecondsToInterval(uint32_t micro);
 
 uint32_t
 PR_TicksPerSecond();
 
 PRStatus
 PR_WaitCondVar(PRCondVar* cvar, PRIntervalTime timeout);
 
+int32_t
+PR_FileDesc2NativeHandle(PRFileDesc* fd);
+
+enum PRFileType
+{
+    PR_FILE_FILE = 1,
+    PR_FILE_DIRECTORY = 2,
+    PR_FILE_OTHER = 3
+};
+
+struct PRFileInfo
+{
+    PRFileType type;
+    int32_t size;
+    int64_t creationTime;
+    int64_t modifyTime;
+};
+
+PRStatus
+PR_GetOpenFileInfo(PRFileDesc *fd, PRFileInfo *info);
+
+enum PRSeekWhence
+{
+    PR_SEEK_SET = 0,
+    PR_SEEK_CUR = 1,
+    PR_SEEK_END = 2
+};
+
+int32_t
+PR_Seek(PRFileDesc *fd, int32_t offset, PRSeekWhence whence);
+
+enum PRFileMapProtect
+{
+    PR_PROT_READONLY,
+    PR_PROT_READWRITE,
+    PR_PROT_WRITECOPY
+};
+
+struct PRFileMap;
+
+PRFileMap*
+PR_CreateFileMap(PRFileDesc *fd, int64_t size, PRFileMapProtect prot);
+
+void*
+PR_MemMap(PRFileMap *fmap, int64_t offset, uint32_t len);
+
+PRStatus
+PR_MemUnmap(void *addr, uint32_t len);
+
+PRStatus
+PR_CloseFileMap(PRFileMap *fmap);
+
 #endif /* JS_POSIX_NSPR */
 
 #endif /* vm_PosixNSPR_h */