From 7f4c4d76a430039cdba33d7d0e188ba4e03714ce Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Fri, 27 Nov 2015 20:49:55 -0800 Subject: [PATCH] Bug 1228947 - Replace mfbt/Constants.h with math.h. r=roc --- configure.in | 1 + .../compiledtest/TestAudioPacketizer.cpp | 1 - dom/media/webaudio/blink/Biquad.cpp | 7 +---- dom/media/webaudio/blink/DenormalDisabler.h | 1 - .../blink/DynamicsCompressorKernel.cpp | 2 +- dom/svg/SVGContentUtils.h | 1 - .../gonk/GonkGPSGeolocationProvider.cpp | 2 +- gfx/2d/Blur.cpp | 1 - gfx/2d/DrawCommand.h | 3 --- gfx/2d/DrawTargetD2D.cpp | 2 +- gfx/2d/FilterNodeSoftware.cpp | 2 -- gfx/2d/PathD2D.cpp | 1 - gfx/2d/PathHelpers.cpp | 4 --- gfx/2d/PathHelpers.h | 3 ++- gfx/2d/image_operations.cpp | 1 - gfx/2d/moz.build | 5 +--- gfx/layers/apz/src/AsyncPanZoomController.cpp | 1 - gfx/thebes/gfxContext.cpp | 3 --- gfx/thebes/gfxPrefs.h | 2 +- js/src/configure.in | 1 + js/src/jsmath.cpp | 1 - js/src/jsmath.h | 27 ++----------------- layout/svg/nsSVGUtils.h | 2 -- media/libcubeb/src/moz.build | 1 + mfbt/Constants.h | 16 ----------- mfbt/moz.build | 1 - widget/windows/nsWinGesture.cpp | 3 ++- xpcom/ds/nsMathUtils.h | 2 -- 28 files changed, 15 insertions(+), 82 deletions(-) delete mode 100644 mfbt/Constants.h diff --git a/configure.in b/configure.in index ae80552be70..ab6b0701e1d 100644 --- a/configure.in +++ b/configure.in @@ -552,6 +552,7 @@ case "$target" in AC_DEFINE(_CRT_SECURE_NO_WARNINGS) AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS) + AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI. if test "$_CC_MAJOR_VERSION" = "18" -a "$_CC_BUILD_VERSION" -ge "30723"; then _CC_SUITE=12 diff --git a/dom/media/compiledtest/TestAudioPacketizer.cpp b/dom/media/compiledtest/TestAudioPacketizer.cpp index 08bf94e0121..c223ba67547 100644 --- a/dom/media/compiledtest/TestAudioPacketizer.cpp +++ b/dom/media/compiledtest/TestAudioPacketizer.cpp @@ -5,7 +5,6 @@ #include #include -#define _USE_MATH_DEFINES #include #include "../AudioPacketizer.h" diff --git a/dom/media/webaudio/blink/Biquad.cpp b/dom/media/webaudio/blink/Biquad.cpp index a8be73c7cbd..38c92ff1132 100644 --- a/dom/media/webaudio/blink/Biquad.cpp +++ b/dom/media/webaudio/blink/Biquad.cpp @@ -26,16 +26,11 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -// For M_PI -// VS2015 requires to be used; doesn't seem to honor -// _USE_MATH_DEFINES. -#define _USE_MATH_DEFINES -#include - #include "Biquad.h" #include #include +#include namespace WebCore { diff --git a/dom/media/webaudio/blink/DenormalDisabler.h b/dom/media/webaudio/blink/DenormalDisabler.h index 34a56069abe..241220732df 100644 --- a/dom/media/webaudio/blink/DenormalDisabler.h +++ b/dom/media/webaudio/blink/DenormalDisabler.h @@ -25,7 +25,6 @@ #ifndef DenormalDisabler_h #define DenormalDisabler_h -#define _USE_MATH_DEFINES #include #include diff --git a/dom/media/webaudio/blink/DynamicsCompressorKernel.cpp b/dom/media/webaudio/blink/DynamicsCompressorKernel.cpp index 4812c9a546b..e5b4aba2f2a 100644 --- a/dom/media/webaudio/blink/DynamicsCompressorKernel.cpp +++ b/dom/media/webaudio/blink/DynamicsCompressorKernel.cpp @@ -30,9 +30,9 @@ #include "DenormalDisabler.h" #include +#include #include "mozilla/FloatingPoint.h" -#include "mozilla/Constants.h" #include "WebAudioUtils.h" using namespace std; diff --git a/dom/svg/SVGContentUtils.h b/dom/svg/SVGContentUtils.h index fcf8fcde340..41f3e93cf0b 100644 --- a/dom/svg/SVGContentUtils.h +++ b/dom/svg/SVGContentUtils.h @@ -8,7 +8,6 @@ #define MOZILLA_SVGCONTENTUTILS_H // include math.h to pick up definition of M_ maths defines e.g. M_PI -#define _USE_MATH_DEFINES #include #include "mozilla/gfx/2D.h" // for StrokeOptions diff --git a/dom/system/gonk/GonkGPSGeolocationProvider.cpp b/dom/system/gonk/GonkGPSGeolocationProvider.cpp index 982d71fe1a1..c17ac15d712 100644 --- a/dom/system/gonk/GonkGPSGeolocationProvider.cpp +++ b/dom/system/gonk/GonkGPSGeolocationProvider.cpp @@ -16,12 +16,12 @@ #include "GonkGPSGeolocationProvider.h" +#include #include #include #include "GeolocationUtil.h" #include "mozstumbler/MozStumbler.h" -#include "mozilla/Constants.h" #include "mozilla/Preferences.h" #include "mozilla/Services.h" #include "nsContentUtils.h" diff --git a/gfx/2d/Blur.cpp b/gfx/2d/Blur.cpp index a669906c0a3..381f92328d5 100644 --- a/gfx/2d/Blur.cpp +++ b/gfx/2d/Blur.cpp @@ -11,7 +11,6 @@ #include #include "mozilla/CheckedInt.h" -#include "mozilla/Constants.h" #include "2D.h" #include "DataSurfaceHelpers.h" diff --git a/gfx/2d/DrawCommand.h b/gfx/2d/DrawCommand.h index 135548b9c6d..eb303dd5859 100644 --- a/gfx/2d/DrawCommand.h +++ b/gfx/2d/DrawCommand.h @@ -6,8 +6,6 @@ #ifndef MOZILLA_GFX_DRAWCOMMAND_H_ #define MOZILLA_GFX_DRAWCOMMAND_H_ - -#define _USE_MATH_DEFINES #include #include "2D.h" @@ -592,5 +590,4 @@ public: } // namespace mozilla - #endif /* MOZILLA_GFX_DRAWCOMMAND_H_ */ diff --git a/gfx/2d/DrawTargetD2D.cpp b/gfx/2d/DrawTargetD2D.cpp index e60dcef9b28..f1e2731090a 100644 --- a/gfx/2d/DrawTargetD2D.cpp +++ b/gfx/2d/DrawTargetD2D.cpp @@ -16,12 +16,12 @@ #include "Logging.h" #include "Tools.h" #include -#include "mozilla/Constants.h" #include "FilterNodeSoftware.h" #include "FilterNodeD2D1.h" #include "ExtendInputEffectD2D1.h" +#include #include // decltype is not usable for overloaded functions. diff --git a/gfx/2d/FilterNodeSoftware.cpp b/gfx/2d/FilterNodeSoftware.cpp index 2e16c5dc782..c55e01f5ade 100644 --- a/gfx/2d/FilterNodeSoftware.cpp +++ b/gfx/2d/FilterNodeSoftware.cpp @@ -3,8 +3,6 @@ * 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/. */ -#define _USE_MATH_DEFINES - #include #include "DataSurfaceHelpers.h" #include "FilterNodeSoftware.h" diff --git a/gfx/2d/PathD2D.cpp b/gfx/2d/PathD2D.cpp index 69706c79d45..59e7e82c14e 100644 --- a/gfx/2d/PathD2D.cpp +++ b/gfx/2d/PathD2D.cpp @@ -8,7 +8,6 @@ #include #include "DrawTargetD2D.h" #include "Logging.h" -#include "mozilla/Constants.h" namespace mozilla { namespace gfx { diff --git a/gfx/2d/PathHelpers.cpp b/gfx/2d/PathHelpers.cpp index a7bf5b46e72..49c344b4271 100644 --- a/gfx/2d/PathHelpers.cpp +++ b/gfx/2d/PathHelpers.cpp @@ -3,9 +3,6 @@ * 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/. */ -#define _USE_MATH_DEFINES -#include - #include "PathHelpers.h" namespace mozilla { @@ -278,4 +275,3 @@ MaxStrokeExtents(const StrokeOptions& aStrokeOptions, } // namespace gfx } // namespace mozilla - diff --git a/gfx/2d/PathHelpers.h b/gfx/2d/PathHelpers.h index 7a4fac98975..1eb2d1c7999 100644 --- a/gfx/2d/PathHelpers.h +++ b/gfx/2d/PathHelpers.h @@ -7,9 +7,10 @@ #define MOZILLA_GFX_PATHHELPERS_H_ #include "2D.h" -#include "mozilla/Constants.h" #include "UserData.h" +#include + namespace mozilla { namespace gfx { diff --git a/gfx/2d/image_operations.cpp b/gfx/2d/image_operations.cpp index 7d9b44da04f..d25ff304fbc 100644 --- a/gfx/2d/image_operations.cpp +++ b/gfx/2d/image_operations.cpp @@ -28,7 +28,6 @@ #include "base/basictypes.h" -#define _USE_MATH_DEFINES #include #include #include diff --git a/gfx/2d/moz.build b/gfx/2d/moz.build index b426e0dd67c..ef90a2a9dbe 100644 --- a/gfx/2d/moz.build +++ b/gfx/2d/moz.build @@ -146,6 +146,7 @@ UNIFIED_SOURCES += [ 'Matrix.cpp', 'Path.cpp', 'PathCairo.cpp', + 'PathHelpers.cpp', 'PathRecording.cpp', 'Quaternion.cpp', 'RecordedEvent.cpp', @@ -156,10 +157,6 @@ UNIFIED_SOURCES += [ 'SourceSurfaceRawData.cpp', ] -SOURCES += [ - 'PathHelpers.cpp', # Uses _USE_MATH_DEFINES -] - if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': EXPORTS.mozilla.gfx += [ 'QuartzSupport.h', diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 10462563ca3..9b72f217d6f 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -29,7 +29,6 @@ #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc #include "mozilla/BasicEvents.h" // for Modifiers, MODIFIER_* #include "mozilla/ClearOnShutdown.h" // for ClearOnShutdown -#include "mozilla/Constants.h" // for M_PI #include "mozilla/EventForwards.h" // for nsEventStatus_* #include "mozilla/Preferences.h" // for Preferences #include "mozilla/ReentrantMonitor.h" // for ReentrantMonitorAutoEnter, etc diff --git a/gfx/thebes/gfxContext.cpp b/gfx/thebes/gfxContext.cpp index cea96efb85b..8b6e89dca52 100644 --- a/gfx/thebes/gfxContext.cpp +++ b/gfx/thebes/gfxContext.cpp @@ -3,9 +3,6 @@ * 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/. */ -#ifdef _MSC_VER -#define _USE_MATH_DEFINES -#endif #include #include "mozilla/Alignment.h" diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h index b71327e4f54..31646a3bc29 100644 --- a/gfx/thebes/gfxPrefs.h +++ b/gfx/thebes/gfxPrefs.h @@ -6,9 +6,9 @@ #ifndef GFX_PREFS_H #define GFX_PREFS_H +#include // for M_PI #include #include "mozilla/Assertions.h" -#include "mozilla/Constants.h" // for M_PI // First time gfxPrefs::GetSingleton() needs to be called on the main thread, // before any of the methods accessing the values are used, but after diff --git a/js/src/configure.in b/js/src/configure.in index f4df313a6ca..25b4ae847e5 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -373,6 +373,7 @@ case "$target" in AC_DEFINE(_CRT_SECURE_NO_WARNINGS) AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS) + AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI. if test "$_CC_MAJOR_VERSION" = "18"; then _CC_SUITE=12 diff --git a/js/src/jsmath.cpp b/js/src/jsmath.cpp index 817a3fb8d53..7d5b11054df 100644 --- a/js/src/jsmath.cpp +++ b/js/src/jsmath.cpp @@ -10,7 +10,6 @@ #include "jsmath.h" -#include "mozilla/Constants.h" #include "mozilla/FloatingPoint.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/MemoryReporting.h" diff --git a/js/src/jsmath.h b/js/src/jsmath.h index 76c486d6f8f..2250af8237c 100644 --- a/js/src/jsmath.h +++ b/js/src/jsmath.h @@ -9,32 +9,9 @@ #include "mozilla/MemoryReporting.h" -#include "NamespaceImports.h" +#include -#ifndef M_PI -# define M_PI 3.14159265358979323846 -#endif -#ifndef M_E -# define M_E 2.7182818284590452354 -#endif -#ifndef M_LOG2E -# define M_LOG2E 1.4426950408889634074 -#endif -#ifndef M_LOG10E -# define M_LOG10E 0.43429448190325182765 -#endif -#ifndef M_LN2 -# define M_LN2 0.69314718055994530942 -#endif -#ifndef M_LN10 -# define M_LN10 2.30258509299404568402 -#endif -#ifndef M_SQRT2 -# define M_SQRT2 1.41421356237309504880 -#endif -#ifndef M_SQRT1_2 -# define M_SQRT1_2 0.70710678118654752440 -#endif +#include "NamespaceImports.h" namespace js { diff --git a/layout/svg/nsSVGUtils.h b/layout/svg/nsSVGUtils.h index 03062111fbc..69b0ba5b395 100644 --- a/layout/svg/nsSVGUtils.h +++ b/layout/svg/nsSVGUtils.h @@ -7,7 +7,6 @@ #define NS_SVGUTILS_H // include math.h to pick up definition of M_ maths defines e.g. M_PI -#define _USE_MATH_DEFINES #include #include "DrawMode.h" @@ -25,7 +24,6 @@ #include "nsISupportsBase.h" #include "nsMathUtils.h" #include "nsStyleStruct.h" -#include "mozilla/Constants.h" #include class gfxContext; diff --git a/media/libcubeb/src/moz.build b/media/libcubeb/src/moz.build index a01a4ced249..caeb98023e8 100644 --- a/media/libcubeb/src/moz.build +++ b/media/libcubeb/src/moz.build @@ -49,6 +49,7 @@ if CONFIG['OS_TARGET'] == 'WINNT': ] DEFINES['USE_WINMM'] = True DEFINES['USE_WASAPI'] = True + CXXFLAGS += ['-wd4005'] # C4005: '_USE_MATH_DEFINES' : macro redefinition if CONFIG['OS_TARGET'] == 'Android': SOURCES += ['cubeb_opensl.c'] diff --git a/mfbt/Constants.h b/mfbt/Constants.h deleted file mode 100644 index 86bbb6b3544..00000000000 --- a/mfbt/Constants.h +++ /dev/null @@ -1,16 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* 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/. */ - -/* mfbt math constants. */ - -#ifndef mozilla_Constants_h -#define mozilla_Constants_h - -#ifndef M_PI -# define M_PI 3.14159265358979323846 -#endif - -#endif /* mozilla_Constants_h */ diff --git a/mfbt/moz.build b/mfbt/moz.build index d35a202ae4d..67c276df3d6 100644 --- a/mfbt/moz.build +++ b/mfbt/moz.build @@ -30,7 +30,6 @@ EXPORTS.mozilla = [ 'CheckedInt.h', 'Compiler.h', 'Compression.h', - 'Constants.h', 'DebugOnly.h', 'decimal/Decimal.h', 'double-conversion/double-conversion.h', diff --git a/widget/windows/nsWinGesture.cpp b/widget/windows/nsWinGesture.cpp index 7ae8aced136..d90110a2f87 100644 --- a/widget/windows/nsWinGesture.cpp +++ b/widget/windows/nsWinGesture.cpp @@ -12,11 +12,12 @@ #include "nsUXThemeData.h" #include "nsIDOMSimpleGestureEvent.h" #include "nsIDOMWheelEvent.h" -#include "mozilla/Constants.h" #include "mozilla/MouseEvents.h" #include "mozilla/Preferences.h" #include "mozilla/TouchEvents.h" +#include + using namespace mozilla; using namespace mozilla::widget; diff --git a/xpcom/ds/nsMathUtils.h b/xpcom/ds/nsMathUtils.h index 8a067ae14e6..b10b8144e96 100644 --- a/xpcom/ds/nsMathUtils.h +++ b/xpcom/ds/nsMathUtils.h @@ -7,8 +7,6 @@ #ifndef nsMathUtils_h__ #define nsMathUtils_h__ -#define _USE_MATH_DEFINES /* needed for M_ constants on Win32 */ - #include "nscore.h" #include #include