Bug 1254373: Make TestDemon build on Windows; r=billm, a=npotb
authorAaron Klotz <aklotz@mozilla.com>
Thu, 10 Mar 2016 17:32:16 -0700
changeset 310342 f7fa7681a39f62831fc2047704cd8a24e24edffb
parent 310341 f78fc14ce33f92577a0d686e25f1a0d0db226b37
child 310343 46df2ac4c6b4e9ca7cb48f2c920a8678b332c2c4
push id9335
push useraklotz@mozilla.com
push dateTue, 29 Mar 2016 21:07:13 +0000
treeherdermozilla-aurora@f7fa7681a39f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm, npotb
bugs1254373
milestone47.0a2
Bug 1254373: Make TestDemon build on Windows; r=billm, a=npotb 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