Bug 1197563 - Polyfill __func__ for MSVC 2013 and earlier. r=froydnj
authorChris Peterson <cpeterson@mozilla.com>
Thu, 20 Aug 2015 23:39:18 -0700
changeset 288040 61993e366ce613026be995d5c6f53c8c093bd40f
parent 288016 3db89a9ca18a469aed47abdce6df62a0615eb898
child 288041 d799977fb4099f31f074babd3ee3edb889a9613a
push id4792
push useryura.zenevich@gmail.com
push dateWed, 26 Aug 2015 20:00:52 +0000
reviewersfroydnj
bugs1197563
milestone43.0a1
Bug 1197563 - Polyfill __func__ for MSVC 2013 and earlier. r=froydnj
dom/camera/CameraCommon.h
dom/devicestorage/nsDeviceStorage.h
dom/media/mediasource/ContainerParser.cpp
dom/media/mediasource/ResourceQueue.cpp
dom/media/mediasource/SourceBufferDecoder.cpp
media/libstagefright/binding/MoofParser.cpp
xpcom/glue/Logging.h
xpcom/threads/MozPromise.h
--- a/dom/camera/CameraCommon.h
+++ b/dom/camera/CameraCommon.h
@@ -2,24 +2,16 @@
 /* vim: set ts=2 et sw=2 tw=40: */
 /* 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 DOM_CAMERA_CAMERACOMMON_H
 #define DOM_CAMERA_CAMERACOMMON_H
 
-#ifndef __func__
-#ifdef __FUNCTION__
-#define __func__ __FUNCTION__
-#else
-#define __func__ __FILE__
-#endif
-#endif
-
 #include "mozilla/Logging.h"
 
 extern PRLogModuleInfo* GetCameraLog();
 #define DOM_CAMERA_LOG( type, ... ) MOZ_LOG(GetCameraLog(), (mozilla::LogLevel)type, ( __VA_ARGS__ ))
 
 #define DOM_CAMERA_LOGA( ... )      DOM_CAMERA_LOG( mozilla::LogLevel::Error, __VA_ARGS__ )
 
 /**
--- a/dom/devicestorage/nsDeviceStorage.h
+++ b/dom/devicestorage/nsDeviceStorage.h
@@ -4,16 +4,17 @@
  * 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 nsDeviceStorage_h
 #define nsDeviceStorage_h
 
 class nsPIDOMWindow;
 #include "mozilla/Attributes.h"
+#include "mozilla/Logging.h"
 #include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
 
 #include "DOMRequest.h"
 #include "DOMCursor.h"
 #include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsDOMClassInfoID.h"
 #include "nsIClassInfo.h"
@@ -37,21 +38,16 @@ class ErrorResult;
 namespace dom {
 class Blob;
 } // namespace dom
 } // namespace mozilla
 
 //#define DS_LOGGING 1
 
 #ifdef DS_LOGGING
-/* Polyfill __func__ on MSVC to pass to the log. */
-#ifdef _MSC_VER
-#define __func__ __FUNCTION__
-#endif
-
 #define DS_LOG_DEBUG(msg, ...)  printf_stderr("[%s:%d] " msg "\n", __func__, __LINE__, ##__VA_ARGS__)
 #define DS_LOG_INFO DS_LOG_DEBUG
 #define DS_LOG_WARN DS_LOG_DEBUG
 #define DS_LOG_ERROR DS_LOG_DEBUG
 #else
 #define DS_LOG_DEBUG(msg, ...)
 #define DS_LOG_INFO(msg, ...)
 #define DS_LOG_WARN(msg, ...)
--- a/dom/media/mediasource/ContainerParser.cpp
+++ b/dom/media/mediasource/ContainerParser.cpp
@@ -17,21 +17,16 @@
 #include "MP4Stream.h"
 #include "mp4_demuxer/AtomType.h"
 #include "mp4_demuxer/ByteReader.h"
 #endif
 #include "SourceBufferResource.h"
 
 extern PRLogModuleInfo* GetMediaSourceSamplesLog();
 
-/* Polyfill __func__ on MSVC to pass to the log. */
-#ifdef _MSC_VER
-#define __func__ __FUNCTION__
-#endif
-
 #define STRINGIFY(x) #x
 #define TOSTRING(x) STRINGIFY(x)
 #define MSE_DEBUG(name, arg, ...) MOZ_LOG(GetMediaSourceSamplesLog(), mozilla::LogLevel::Debug, (TOSTRING(name) "(%p:%s)::%s: " arg, this, mType.get(), __func__, ##__VA_ARGS__))
 #define MSE_DEBUGV(name, arg, ...) MOZ_LOG(GetMediaSourceSamplesLog(), mozilla::LogLevel::Verbose, (TOSTRING(name) "(%p:%s)::%s: " arg, this, mType.get(), __func__, ##__VA_ARGS__))
 
 namespace mozilla {
 
 ContainerParser::ContainerParser(const nsACString& aType)
--- a/dom/media/mediasource/ResourceQueue.cpp
+++ b/dom/media/mediasource/ResourceQueue.cpp
@@ -7,21 +7,16 @@
 #include "ResourceQueue.h"
 #include "nsDeque.h"
 #include "MediaData.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/Logging.h"
 
 extern PRLogModuleInfo* GetSourceBufferResourceLog();
 
-/* Polyfill __func__ on MSVC to pass to the log. */
-#ifdef _MSC_VER
-#define __func__ __FUNCTION__
-#endif
-
 #define SBR_DEBUG(arg, ...) MOZ_LOG(GetSourceBufferResourceLog(), mozilla::LogLevel::Debug, ("ResourceQueue(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
 #define SBR_DEBUGV(arg, ...) MOZ_LOG(GetSourceBufferResourceLog(), mozilla::LogLevel::Verbose, ("ResourceQueue(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
 
 namespace mozilla {
 
 ResourceItem::ResourceItem(MediaByteBuffer* aData)
   : mData(aData)
 {
--- a/dom/media/mediasource/SourceBufferDecoder.cpp
+++ b/dom/media/mediasource/SourceBufferDecoder.cpp
@@ -6,20 +6,16 @@
 
 #include "MediaSourceUtils.h"
 #include "SourceBufferDecoder.h"
 #include "mozilla/Logging.h"
 #include "AbstractMediaDecoder.h"
 #include "MediaDecoderReader.h"
 
 extern PRLogModuleInfo* GetMediaSourceLog();
-/* Polyfill __func__ on MSVC to pass to the log. */
-#ifdef _MSC_VER
-#define __func__ __FUNCTION__
-#endif
 
 #define MSE_DEBUG(arg, ...) MOZ_LOG(GetMediaSourceLog(), mozilla::LogLevel::Debug, ("SourceBufferDecoder(%p:%s)::%s: " arg, this, mResource->GetContentType().get(), __func__, ##__VA_ARGS__))
 
 namespace mozilla {
 
 class ReentrantMonitor;
 
 namespace layers {
--- a/media/libstagefright/binding/MoofParser.cpp
+++ b/media/libstagefright/binding/MoofParser.cpp
@@ -8,21 +8,16 @@
 #include <limits>
 #include "Intervals.h"
 
 #include "mozilla/Logging.h"
 
 #if defined(MOZ_FMP4)
 extern PRLogModuleInfo* GetDemuxerLog();
 
-/* Polyfill __func__ on MSVC to pass to the log. */
-#ifdef _MSC_VER
-#define __func__ __FUNCTION__
-#endif
-
 #define STRINGIFY(x) #x
 #define TOSTRING(x) STRINGIFY(x)
 #define LOG(name, arg, ...) MOZ_LOG(GetDemuxerLog(), mozilla::LogLevel::Debug, (TOSTRING(name) "(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
 #else
 #define LOG(...)
 #endif
 
 namespace mp4_demuxer
--- a/xpcom/glue/Logging.h
+++ b/xpcom/glue/Logging.h
@@ -61,10 +61,20 @@ inline bool log_test(const PRLogModuleIn
     if (MOZ_LOG_TEST(_module,_level)) { \
       PR_LogPrint _args;         \
     }                     \
   PR_END_MACRO
 
 #undef PR_LOG
 #undef PR_LOG_TEST
 
+/*
+ * __func__ was standardized in C++11 and is supported by clang, gcc, and MSVC
+ * 2015. Here we polyfill __func__ for earlier versions of MSVC.
+ * http://blogs.msdn.com/b/vcblog/archive/2015/06/19/c-11-14-17-features-in-vs-2015-rtm.aspx
+ */
+#ifdef _MSC_VER
+#  if _MSC_VER < 1900
+#    define __func__ __FUNCTION__
+#  endif
+#endif
+
 #endif // mozilla_logging_h
-
--- a/xpcom/threads/MozPromise.h
+++ b/xpcom/threads/MozPromise.h
@@ -3,33 +3,26 @@
 /* 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/. */
 
 #if !defined(MozPromise_h_)
 #define MozPromise_h_
 
 #include "mozilla/AbstractThread.h"
-#include "mozilla/DebugOnly.h"
 #include "mozilla/IndexSequence.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/Tuple.h"
-#include "mozilla/unused.h"
 
 #include "nsTArray.h"
 #include "nsThreadUtils.h"
 
-/* Polyfill __func__ on MSVC for consumers to pass to the MozPromise API. */
-#ifdef _MSC_VER
-#define __func__ __FUNCTION__
-#endif
-
 namespace mozilla {
 
 extern PRLogModuleInfo* gMozPromiseLog;
 
 #define PROMISE_LOG(x, ...) \
   MOZ_ASSERT(gMozPromiseLog); \
   MOZ_LOG(gMozPromiseLog, mozilla::LogLevel::Debug, (x, ##__VA_ARGS__))