Bug 942334 - Build hal in unified mode; r=cjones
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 25 Nov 2013 14:57:18 -0500
changeset 157431 2f60d2a1c4fb28a43e29fcd806b1b2e2790b0096
parent 157430 6cfc4f26a183fa3f71933b891951f62cfb7119de
child 157432 cf22f2ea191ec6a4a0fde9e18802c8efc0f6dfdb
push id36712
push usereakhgari@mozilla.com
push dateMon, 25 Nov 2013 22:54:55 +0000
treeherdermozilla-inbound@cf22f2ea191e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs942334
milestone28.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 942334 - Build hal in unified mode; r=cjones
hal/HalImpl.h
hal/HalWakeLock.cpp
hal/cocoa/smslib.mm
hal/moz.build
hal/windows/WindowsGamepad.cpp
--- a/hal/HalImpl.h
+++ b/hal/HalImpl.h
@@ -2,16 +2,20 @@
 /* vim: set sw=2 ts=8 et ft=cpp : */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_HalImpl_h
 #define mozilla_HalImpl_h
 
+#ifdef MOZ_UNIFIED_BUILD
+#error Cannot use HalImpl.h in unified builds.
+#endif
+
 #define MOZ_HAL_NAMESPACE hal_impl
 #undef mozilla_Hal_h
 #undef mozilla_HalInternal_h
 #include "Hal.h"
 #include "HalInternal.h"
 #undef MOZ_HAL_NAMESPACE
 
 #endif // mozilla_HalImpl_h
--- a/hal/HalWakeLock.cpp
+++ b/hal/HalWakeLock.cpp
@@ -249,17 +249,17 @@ ModifyWakeLock(const nsAString& aTopic,
   }
 
   if (sActiveListeners &&
       (oldState != ComputeWakeLockState(totalCount.numLocks,
                                         totalCount.numHidden) ||
        processWasLocked != (processCount.numLocks > 0))) {
 
     WakeLockInformation info;
-    GetWakeLockInfo(aTopic, &info);
+    hal::GetWakeLockInfo(aTopic, &info);
     NotifyWakeLockChange(info);
   }
 }
 
 void
 GetWakeLockInfo(const nsAString& aTopic, WakeLockInformation* aWakeLockInfo)
 {
   if (sIsShuttingDown) {
--- a/hal/cocoa/smslib.mm
+++ b/hal/cocoa/smslib.mm
@@ -289,16 +289,17 @@ static float onegs[3];			// X, Y and Z o
 // Name of configuration for given axis' oneg (axis specified by integer)
 #define ONEG_NAME(a) [NSString stringWithFormat:@"%@-Axis-One-g", INT_TO_AXIS(a)]
 // Name of "Is calibrated" preference
 #define CALIBRATED_NAME (@"Calibrated")
 // Application domain for SeisMac library
 #define APP_ID ((CFStringRef)@"com.suitable.SeisMacLib")
 
 // These #defines make the accelStartup code a LOT easier to read.
+#undef LOG
 #define LOG(message) \
 	if (logObject) { \
 		[logObject performSelector:logSelector withObject:message]; \
 	}
 #define LOG_ARG(format, var1) \
 	if (logObject) { \
 		[logObject performSelector:logSelector \
 			withObject:[NSString stringWithFormat:format, var1]]; \
--- a/hal/moz.build
+++ b/hal/moz.build
@@ -16,145 +16,158 @@ EXPORTS.mozilla += [
     'HalSandbox.h',
     'HalScreenConfiguration.h',
     'HalSensor.h',
     'HalTypes.h',
     'HalWakeLock.h',
 ]
 
 TEST_DIRS += ['tests']
-SOURCES += [
-    'Hal.cpp',
+UNIFIED_SOURCES += [
     'HalWakeLock.cpp',
     'sandbox/SandboxHal.cpp',
     'WindowIdentifier.cpp',
 ]
 
+# Hal.cpp cannot be built in unified mode because it relies on HalImpl.h.
+SOURCES += [
+    'Hal.cpp',
+]
+
 if CONFIG['MOZ_GAMEPAD_BACKEND'] == 'stub':
-    SOURCES += [
+    UNIFIED_SOURCES += [
         'fallback/FallbackGamepad.cpp'
     ]
 elif CONFIG['MOZ_GAMEPAD_BACKEND'] == 'cocoa':
-    SOURCES += [
+    UNIFIED_SOURCES += [
         'cocoa/CocoaGamepad.cpp'
     ]
 elif CONFIG['MOZ_GAMEPAD_BACKEND'] == 'windows':
-    SOURCES += [
+    UNIFIED_SOURCES += [
         'windows/WindowsGamepad.cpp'
     ]
 elif CONFIG['MOZ_GAMEPAD_BACKEND'] == 'linux':
-    SOURCES += [
+    UNIFIED_SOURCES += [
         'linux/LinuxGamepad.cpp'
     ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
-    SOURCES += [
-        'android/AndroidHal.cpp',
+    UNIFIED_SOURCES += [
         'android/AndroidSensor.cpp',
         'fallback/FallbackAlarm.cpp',
         'fallback/FallbackPower.cpp',
         'linux/LinuxMemory.cpp',
     ]
+    # AndroidHal.cpp cannot be built in unified mode because it relies on HalImpl.h.
+    SOURCES += [
+        'android/AndroidHal.cpp',
+    ]
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
-    SOURCES += [
+    UNIFIED_SOURCES += [
         'gonk/GonkDiskSpaceWatcher.cpp',
         'gonk/GonkFMRadio.cpp',
-        'gonk/GonkHal.cpp',
         'gonk/GonkSensor.cpp',
         'gonk/GonkSwitch.cpp',
         'gonk/UeventPoller.cpp',
         'linux/LinuxMemory.cpp',
         'linux/LinuxPower.cpp',
     ]
+    # GonkHal.cpp cannot be built in unified mode because it relies on HalImpl.h.
+    SOURCES += [
+        'gonk/GonkHal.cpp',
+    ]
 elif CONFIG['OS_TARGET'] == 'Linux':
-    SOURCES += [
+    UNIFIED_SOURCES += [
         'fallback/FallbackAlarm.cpp',
         'fallback/FallbackScreenConfiguration.cpp',
         'fallback/FallbackSensor.cpp',
         'fallback/FallbackVibration.cpp',
         'linux/LinuxMemory.cpp',
         'linux/LinuxPower.cpp',
     ]
     if CONFIG['MOZ_ENABLE_DBUS']:
-        SOURCES += [
+        UNIFIED_SOURCES += [
             'linux/UPowerClient.cpp',
         ]
     else:
-        SOURCES += [
+        UNIFIED_SOURCES += [
             'fallback/FallbackBattery.cpp',
         ]
 elif CONFIG['OS_TARGET'] == 'WINNT':
-    SOURCES += [
+    UNIFIED_SOURCES += [
         'fallback/FallbackAlarm.cpp',
         'fallback/FallbackMemory.cpp',
         'fallback/FallbackPower.cpp',
         'fallback/FallbackScreenConfiguration.cpp',
         'fallback/FallbackVibration.cpp',
-        'windows/WindowsBattery.cpp',
         'windows/WindowsSensor.cpp',
     ]
+    # WindowsBattery.cpp cannot be built in unified mode because it relies on HalImpl.h.
+    SOURCES += [
+        'windows/WindowsBattery.cpp',
+    ]
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
-    SOURCES += [
+    UNIFIED_SOURCES += [
         'cocoa/CocoaBattery.cpp',
         'fallback/FallbackAlarm.cpp',
         'fallback/FallbackMemory.cpp',
         'fallback/FallbackPower.cpp',
         'fallback/FallbackScreenConfiguration.cpp',
         'fallback/FallbackVibration.cpp',
     ]
 elif CONFIG['OS_TARGET'] in ('OpenBSD', 'NetBSD', 'FreeBSD', 'DragonFly'):
-    SOURCES += [
+    UNIFIED_SOURCES += [
         'fallback/FallbackAlarm.cpp',
         'fallback/FallbackMemory.cpp',
         'fallback/FallbackPower.cpp',
         'fallback/FallbackScreenConfiguration.cpp',
         'fallback/FallbackSensor.cpp',
         'fallback/FallbackVibration.cpp',
     ]
     if CONFIG['MOZ_ENABLE_DBUS']:
-        SOURCES += [
+        UNIFIED_SOURCES += [
             'linux/UPowerClient.cpp',
         ]
     else:
-        SOURCES += [
+        UNIFIED_SOURCES += [
             'fallback/FallbackBattery.cpp',
         ]
 else:
-    SOURCES += [
+    UNIFIED_SOURCES += [
         'fallback/FallbackAlarm.cpp',
         'fallback/FallbackBattery.cpp',
         'fallback/FallbackMemory.cpp',
         'fallback/FallbackPower.cpp',
         'fallback/FallbackScreenConfiguration.cpp',
         'fallback/FallbackSensor.cpp',
         'fallback/FallbackVibration.cpp',
     ]
 
 # Fallbacks for backends implemented on Gonk only.
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
-    SOURCES += [
+    UNIFIED_SOURCES += [
         'fallback/FallbackDiskSpaceWatcher.cpp',
         'fallback/FallbackFactoryReset.cpp',
         'fallback/FallbackFMRadio.cpp',
         'fallback/FallbackLights.cpp',
         'fallback/FallbackProcessPriority.cpp',
         'fallback/FallbackScreenPower.cpp',
         'fallback/FallbackSwitch.cpp',
         'fallback/FallbackTime.cpp',
         'fallback/FallbackWakeLocks.cpp',
     ]
 
 # Fallbacks for backends implemented on Android only.
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
-    SOURCES += [
+    UNIFIED_SOURCES += [
         'fallback/FallbackNetwork.cpp',
     ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
-    SOURCES += [
+    UNIFIED_SOURCES += [
         'cocoa/CocoaSensor.mm',
         'cocoa/smslib.mm',
     ]
 
 IPDL_SOURCES = [
     'sandbox/PHal.ipdl',
 ]
 
--- a/hal/windows/WindowsGamepad.cpp
+++ b/hal/windows/WindowsGamepad.cpp
@@ -316,18 +316,18 @@ private:
   nsTArray<HANDLE> mEvents;
 
   LPDIRECTINPUT8 dinput;
 
   nsRefPtr<Observer> mObserver;
 };
 
 WindowsGamepadService::WindowsGamepadService()
-  : mThreadExitEvent(CreateEvent(nullptr, FALSE, FALSE, nullptr)),
-    mThreadRescanEvent(CreateEvent(nullptr, FALSE, FALSE, nullptr)),
+  : mThreadExitEvent(CreateEventW(nullptr, FALSE, FALSE, nullptr)),
+    mThreadRescanEvent(CreateEventW(nullptr, FALSE, FALSE, nullptr)),
     mThread(nullptr),
     dinput(nullptr) {
   mObserver = new Observer(*this);
   // Initialize DirectInput
   CoInitialize(nullptr);
   if (CoCreateInstance(CLSID_DirectInput8,
                        nullptr,
                        CLSCTX_INPROC_SERVER,
@@ -411,17 +411,17 @@ WindowsGamepadService::EnumCallback(LPCD
     gamepad.device->EnumObjects(EnumObjectsCallback, &gamepad, DIDFT_AXIS);
     // Set up structure for setting buffer size for buffered data
     dp.diph.dwHeaderSize = sizeof(DIPROPHEADER);
     dp.diph.dwSize = sizeof(DIPROPDWORD);
     dp.diph.dwObj = 0;
     dp.diph.dwHow = DIPH_DEVICE;
     dp.dwData = 64; // arbitrary
     // Create event so DInput can signal us when there's new data.
-    gamepad.event = CreateEvent(nullptr, FALSE, FALSE, nullptr);
+    gamepad.event = CreateEventW(nullptr, FALSE, FALSE, nullptr);
     // Set data format, event notification, and acquire device
     if (gamepad.device->SetDataFormat(&c_dfDIJoystick) == DI_OK &&
         gamepad.device->SetProperty(DIPROP_BUFFERSIZE, &dp.diph) == DI_OK &&
         gamepad.device->SetEventNotification(gamepad.event) == DI_OK &&
         gamepad.device->Acquire() == DI_OK) {
       self->mGamepads.AppendElement(gamepad);
       // Inform the GamepadService
       nsRefPtr<GamepadChangeEvent> event =