Bug 1254373: Make TestDemon build on Windows; r=billm
authorAaron Klotz <aklotz@mozilla.com>
Thu, 10 Mar 2016 17:32:16 -0700
changeset 288294 399aee6215e33899a4dfe214f19ecaa6d6fcbb42
parent 288293 80d84efa1d0c79b19a086f312a358cd5891fa198
child 288295 fa1daaba023bb75fcb6fe9509d71a5d658e6d92c
push id73373
push useraklotz@mozilla.com
push dateFri, 11 Mar 2016 17:57:55 +0000
treeherdermozilla-inbound@399aee6215e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1254373
milestone48.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 1254373: Make TestDemon build on Windows; r=billm MozReview-Commit-ID: GtgAVfDYhtk
ipc/ipdl/test/cxx/TestDemon.cpp
--- a/ipc/ipdl/test/cxx/TestDemon.cpp
+++ b/ipc/ipdl/test/cxx/TestDemon.cpp
@@ -1,20 +1,21 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * vim: sw=4 ts=4 et :
  */
 #include "TestDemon.h"
 
 #include <stdlib.h>
-#include <sys/time.h>
 
 #include "IPDLUnitTests.h"      // fail etc.
 #if defined(OS_POSIX)
+#include <sys/time.h>
 #include <unistd.h>
 #else
+#include <time.h>
 #include <windows.h>
 #endif
 
 template<>
 struct RunnableMethodTraits<mozilla::_ipdltest::TestDemonParent>
 {
     static void RetainCallee(mozilla::_ipdltest::TestDemonParent* obj) { }
     static void ReleaseCallee(mozilla::_ipdltest::TestDemonParent* obj) { }
@@ -29,25 +30,29 @@ struct RunnableMethodTraits<mozilla::_ip
 
 namespace mozilla {
 namespace _ipdltest {
 
 const int kMaxStackHeight = 4;
 
 static LazyLogModule sLogModule("demon");
 
-#define DEMON_LOG(args...) MOZ_LOG(sLogModule, LogLevel::Debug, (args))
+#define DEMON_LOG(...) MOZ_LOG(sLogModule, LogLevel::Debug, (__VA_ARGS__))
 
 static int gStackHeight = 0;
 static bool gFlushStack = false;
 
 static int
 Choose(int count)
 {
+#if defined(OS_POSIX)
   return random() % count;
+#else
+  return rand() % count;
+#endif
 }
 
 //-----------------------------------------------------------------------------
 // parent
 
 TestDemonParent::TestDemonParent()
  : mDone(false),
    mIncoming(),
@@ -63,17 +68,21 @@ TestDemonParent::~TestDemonParent()
 
 void
 TestDemonParent::Main()
 {
   if (!getenv("MOZ_TEST_IPC_DEMON")) {
     QuitParent();
     return;
   }
+#if defined(OS_POSIX)
   srandom(time(nullptr));
+#else
+  srand(time(nullptr));
+#endif
 
   DEMON_LOG("Start demon");
 
   if (!SendStart())
 	fail("sending Start");
 
   RunUnlimitedSequence();
 }
@@ -264,17 +273,21 @@ TestDemonChild::TestDemonChild()
 TestDemonChild::~TestDemonChild()
 {
   MOZ_COUNT_DTOR(TestDemonChild);
 }
 
 bool
 TestDemonChild::RecvStart()
 {
+#ifdef OS_POSIX
   srandom(time(nullptr));
+#else
+  srand(time(nullptr));
+#endif
 
   DEMON_LOG("RecvStart");
 
   RunUnlimitedSequence();
   return true;
 }
 
 #ifdef DEBUG