summaryrefslogtreecommitdiff
path: root/www/firefox52/patches
diff options
context:
space:
mode:
authorryoon <ryoon@pkgsrc.org>2017-04-27 01:55:57 +0000
committerryoon <ryoon@pkgsrc.org>2017-04-27 01:55:57 +0000
commit873f1d29420293ca83d7a8874d6e4209aa7a5ce5 (patch)
tree57141be2f368e7cac9e51535cce1e20c0bd286f5 /www/firefox52/patches
parent20b187516e03bfba4206ef8ceae9e96445064f72 (diff)
downloadpkgsrc-873f1d29420293ca83d7a8874d6e4209aa7a5ce5.tar.gz
Import firefox52-52.1.0 as www/firefox52.
Mozilla Firefox is a free, open-source and cross-platform web browser for Windows, Linux, MacOS X and many other operating systems. It is fast and easy to use, and offers many advantages over other web browsers, such as tabbed browsing and the ability to block pop-up windows. Firefox also offers excellent bookmark and history management, and it can be extended by developers using industry standards such as XML, CSS, JavaScript, C++, etc. Many extensions are available.
Diffstat (limited to 'www/firefox52/patches')
-rw-r--r--www/firefox52/patches/patch-aa249
-rw-r--r--www/firefox52/patches/patch-ao17
-rw-r--r--www/firefox52/patches/patch-as35
-rw-r--r--www/firefox52/patches/patch-build_gyp.mozbuild24
-rw-r--r--www/firefox52/patches/patch-build_moz.configure_init.configure37
-rw-r--r--www/firefox52/patches/patch-build_moz.configure_keyfiles.configure21
-rw-r--r--www/firefox52/patches/patch-build_moz.configure_memory.configure15
-rw-r--r--www/firefox52/patches/patch-build_moz.configure_old.configure25
-rw-r--r--www/firefox52/patches/patch-build_pgo_profileserver.py13
-rw-r--r--www/firefox52/patches/patch-config_Makefile.in27
-rw-r--r--www/firefox52/patches/patch-config_baseconfig.mk21
-rw-r--r--www/firefox52/patches/patch-config_external_moz.build43
-rw-r--r--www/firefox52/patches/patch-config_stl__wrappers_ios8
-rw-r--r--www/firefox52/patches/patch-config_stl__wrappers_ostream8
-rw-r--r--www/firefox52/patches/patch-config_system-headers50
-rw-r--r--www/firefox52/patches/patch-config_system__wrappers_unwind.h9
-rw-r--r--www/firefox52/patches/patch-dom_base_moz.build14
-rw-r--r--www/firefox52/patches/patch-dom_filesystem_compat_FileSystemDirectoryReader.h12
-rw-r--r--www/firefox52/patches/patch-dom_media_AudioStream.cpp38
-rw-r--r--www/firefox52/patches/patch-dom_media_AudioStream.h28
-rw-r--r--www/firefox52/patches/patch-dom_media_moz.build28
-rw-r--r--www/firefox52/patches/patch-dom_media_platforms_ffmpeg_ffvpx_FFVPXRuntimeLinker.cpp39
-rw-r--r--www/firefox52/patches/patch-dom_plugins_ipc_PluginModuleChild.cpp33
-rw-r--r--www/firefox52/patches/patch-dom_plugins_ipc_PluginModuleChild.h15
-rw-r--r--www/firefox52/patches/patch-dom_system_OSFileConstants.cpp33
-rw-r--r--www/firefox52/patches/patch-extensions_spellcheck_hunspell_glue_mozHunspell.cpp21
-rw-r--r--www/firefox52/patches/patch-gfx_cairo_libpixman_src_pixman-arm-neon-asm.S39
-rw-r--r--www/firefox52/patches/patch-gfx_gl_GLContextProviderGLX.cpp16
-rw-r--r--www/firefox52/patches/patch-gfx_graphite2_moz-gr-update.sh30
-rw-r--r--www/firefox52/patches/patch-gfx_graphite2_src_Bidi.cpp18
-rw-r--r--www/firefox52/patches/patch-gfx_moz.build26
-rw-r--r--www/firefox52/patches/patch-gfx_skia_generate__mozbuild.py14
-rw-r--r--www/firefox52/patches/patch-gfx_skia_moz.build14
-rw-r--r--www/firefox52/patches/patch-gfx_thebes_moz.build19
-rw-r--r--www/firefox52/patches/patch-gfx_ycbcr_moz.build15
-rw-r--r--www/firefox52/patches/patch-gfx_ycbcr_yuv__row__arm.S42
-rw-r--r--www/firefox52/patches/patch-image_Downscaler.h33
-rw-r--r--www/firefox52/patches/patch-image_decoders_nsJPEGDecoder.cpp367
-rw-r--r--www/firefox52/patches/patch-intl_hyphenation_glue_hnjalloc.h16
-rw-r--r--www/firefox52/patches/patch-intl_unicharutil_util_moz.build12
-rw-r--r--www/firefox52/patches/patch-ipc_chromium_src_base_atomicops.h15
-rw-r--r--www/firefox52/patches/patch-ipc_chromium_src_base_message__pump__libevent.cc22
-rw-r--r--www/firefox52/patches/patch-ipc_chromium_src_base_platform__thread.h16
-rw-r--r--www/firefox52/patches/patch-ipc_chromium_src_base_platform__thread__posix.cc27
-rw-r--r--www/firefox52/patches/patch-ipc_chromium_src_base_process__util.h14
-rw-r--r--www/firefox52/patches/patch-ipc_chromium_src_base_process__util__posix.cc24
-rw-r--r--www/firefox52/patches/patch-ipc_chromium_src_base_sys__info__posix.cc18
-rw-r--r--www/firefox52/patches/patch-ipc_chromium_src_base_time__posix.cc17
-rw-r--r--www/firefox52/patches/patch-ipc_chromium_src_build_build__config.h24
-rw-r--r--www/firefox52/patches/patch-ipc_chromium_src_chrome_common_transport__dib.h15
-rw-r--r--www/firefox52/patches/patch-ipc_glue_GeckoChildProcessHost.cpp48
-rw-r--r--www/firefox52/patches/patch-js_src_jit_arm_Architecture-arm.cpp15
-rw-r--r--www/firefox52/patches/patch-js_src_jit_none_AtomicOperations-sparc.h261
-rw-r--r--www/firefox52/patches/patch-js_src_moz.build15
-rw-r--r--www/firefox52/patches/patch-js_xpconnect_src_XPCConvert.cpp16
-rw-r--r--www/firefox52/patches/patch-js_xpconnect_src_xpcprivate.h17
-rw-r--r--www/firefox52/patches/patch-media_libcubeb_src_cubeb.c26
-rw-r--r--www/firefox52/patches/patch-media_libcubeb_src_cubeb__alsa.c546
-rw-r--r--www/firefox52/patches/patch-media_libcubeb_src_cubeb__oss.c449
-rw-r--r--www/firefox52/patches/patch-media_libcubeb_src_moz.build28
-rw-r--r--www/firefox52/patches/patch-media_libcubeb_tests_moz.build12
-rw-r--r--www/firefox52/patches/patch-media_libcubeb_update.sh12
-rw-r--r--www/firefox52/patches/patch-media_libsoundtouch_src_cpu__detect__x86.cpp15
-rw-r--r--www/firefox52/patches/patch-media_libsoundtouch_src_soundtouch__perms.h14
-rw-r--r--www/firefox52/patches/patch-media_libtheora_lib_arm_armcpu.c25
-rw-r--r--www/firefox52/patches/patch-media_libtheora_moz.build16
-rw-r--r--www/firefox52/patches/patch-media_libtremor_moz.build12
-rw-r--r--www/firefox52/patches/patch-media_libvorbis_moz.build13
-rw-r--r--www/firefox52/patches/patch-media_libyuv_source_mjpeg__decoder.cc12
-rw-r--r--www/firefox52/patches/patch-media_openmax__dl_dl_api_armCOMM__s.h39
-rw-r--r--www/firefox52/patches/patch-media_webrtc_signaling_test_common.build19
-rw-r--r--www/firefox52/patches/patch-media_webrtc_trunk_webrtc_modules_video__capture_linux_device__info__linux.cc42
-rw-r--r--www/firefox52/patches/patch-media_webrtc_trunk_webrtc_modules_video__capture_linux_video__capture__linux.cc30
-rw-r--r--www/firefox52/patches/patch-media_webrtc_trunk_webrtc_modules_video__capture_video__capture.gypi34
-rw-r--r--www/firefox52/patches/patch-memory_mozalloc_mozalloc__abort.cpp18
-rw-r--r--www/firefox52/patches/patch-mfbt_Poison.cpp20
-rw-r--r--www/firefox52/patches/patch-mobile_android_installer_Makefile.in15
-rw-r--r--www/firefox52/patches/patch-modules_libjar_nsZipArchive.cpp17
-rw-r--r--www/firefox52/patches/patch-mozglue_build_arm.cpp59
-rw-r--r--www/firefox52/patches/patch-mozglue_build_arm.h15
-rw-r--r--www/firefox52/patches/patch-netwerk_dns_moz.build14
-rw-r--r--www/firefox52/patches/patch-rc18
-rw-r--r--www/firefox52/patches/patch-toolkit_components_osfile_modules_osfile__unix__back.jsm15
-rw-r--r--www/firefox52/patches/patch-toolkit_components_osfile_modules_osfile__unix__front.jsm13
-rw-r--r--www/firefox52/patches/patch-toolkit_components_protobuf_src_google_protobuf_stubs_atomicops.h24
-rw-r--r--www/firefox52/patches/patch-toolkit_components_protobuf_src_google_protobuf_stubs_platform__macros.h15
-rw-r--r--www/firefox52/patches/patch-toolkit_components_terminator_nsTerminator.cpp27
-rw-r--r--www/firefox52/patches/patch-toolkit_library_moz.build57
-rw-r--r--www/firefox52/patches/patch-toolkit_modules_GMPUtils.jsm14
-rw-r--r--www/firefox52/patches/patch-toolkit_moz.configure33
-rw-r--r--www/firefox52/patches/patch-toolkit_mozapps_extensions_test_browser_browser__gmpProvider.js14
-rw-r--r--www/firefox52/patches/patch-toolkit_xre_glxtest.cpp16
-rw-r--r--www/firefox52/patches/patch-toolkit_xre_nsEmbedFunctions.cpp24
-rw-r--r--www/firefox52/patches/patch-xpcom_base_nscore.h15
-rw-r--r--www/firefox52/patches/patch-xpcom_build_XPCOMInit.cpp28
-rw-r--r--www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_Makefile.in50
-rw-r--r--www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__arm__netbsd.cpp527
-rw-r--r--www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__asm__mips.S52
-rw-r--r--www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__asm__ppc__netbsd.s25
-rw-r--r--www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__netbsd__m68k.cpp75
-rw-r--r--www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__ppc__netbsd.cpp47
-rw-r--r--www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__sparc64__netbsd.cpp89
-rw-r--r--www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcstubs__arm__netbsd.cpp217
-rw-r--r--www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcstubs__asm__mips.S52
-rw-r--r--www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcstubs__asm__sparc64__netbsd.s71
-rw-r--r--www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcstubs__netbsd__m68k.cpp41
106 files changed, 5149 insertions, 0 deletions
diff --git a/www/firefox52/patches/patch-aa b/www/firefox52/patches/patch-aa
new file mode 100644
index 00000000000..36686e870df
--- /dev/null
+++ b/www/firefox52/patches/patch-aa
@@ -0,0 +1,249 @@
+$NetBSD: patch-aa,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* MOZ_ENABLE_PROFILER_SPS is not for users, Disable it
+* Disable libjpeg-turbo check
+* Add system libraries option
+* Add OSS audio support
+
+--- old-configure.in.orig 2017-03-04 10:47:32.150192599 +0000
++++ old-configure.in
+@@ -2159,11 +2159,7 @@ if test "$MOZ_SYSTEM_JPEG" = 1; then
+ #include <jpeglib.h> ],
+ [ #if JPEG_LIB_VERSION < $MOZJPEG
+ #error "Insufficient JPEG library version ($MOZJPEG required)."
+- #endif
+- #ifndef JCS_EXTENSIONS
+- #error "libjpeg-turbo JCS_EXTENSIONS required"
+- #endif
+- ],
++ #endif ],
+ MOZ_SYSTEM_JPEG=1,
+ AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
+ fi
+@@ -2894,6 +2890,9 @@ if test -n "$MOZ_WEBRTC"; then
+ MOZ_RAW=1
+ MOZ_VPX_ERROR_CONCEALMENT=1
+
++ dnl with libv4l2 we can support more cameras
++ PKG_CHECK_MODULES(MOZ_LIBV4L2, libv4l2)
++
+ dnl enable once Signaling lands
+ MOZ_WEBRTC_SIGNALING=1
+ AC_DEFINE(MOZ_WEBRTC_SIGNALING)
+@@ -2936,7 +2935,7 @@ dnl Use integers over floats for audio o
+ dnl (regarless of the CPU architecture, because audio
+ dnl backends for those platforms don't support floats. We also
+ dnl use integers on ARM with other OS, because it's more efficient.
+-if test "$OS_TARGET" = "Android" -o "$CPU_ARCH" = "arm"; then
++if test -n "$MOZ_INTEGER_SAMPLES"; then
+ MOZ_SAMPLE_TYPE_S16=1
+ AC_DEFINE(MOZ_SAMPLE_TYPE_S16)
+ AC_SUBST(MOZ_SAMPLE_TYPE_S16)
+@@ -3044,6 +3043,111 @@ if test -n "$MOZ_OMX_PLUGIN"; then
+ fi
+ fi
+
++dnl ========================================================
++dnl Check for libogg
++dnl ========================================================
++
++MOZ_ARG_WITH_BOOL(system-ogg,
++[ --with-system-ogg Use system libogg (located with pkgconfig)],
++MOZ_SYSTEM_OGG=1,
++MOZ_SYSTEM_OGG=)
++
++if test -n "$MOZ_SYSTEM_OGG"; then
++ PKG_CHECK_MODULES(MOZ_OGG, ogg >= 1.3.0)
++
++ _SAVE_LIBS=$LIBS
++ LIBS="$LIBS $MOZ_OGG_LIBS"
++ AC_CHECK_FUNC(ogg_set_mem_functions, [],
++ [AC_DEFINE(MOZ_OGG_NO_MEM_REPORTING)])
++ LIBS=$_SAVE_LIBS
++fi
++
++AC_SUBST(MOZ_SYSTEM_OGG)
++
++dnl ========================================================
++dnl Check for libvorbis
++dnl ========================================================
++
++MOZ_ARG_WITH_BOOL(system-vorbis,
++[ --with-system-vorbis Use system libvorbis (located with pkgconfig)],
++MOZ_SYSTEM_VORBIS=1,
++MOZ_SYSTEM_VORBIS=)
++
++if test -n "$MOZ_SYSTEM_VORBIS"; then
++ PKG_CHECK_MODULES(MOZ_VORBIS, vorbis vorbisenc >= 1.3.5)
++fi
++
++AC_SUBST(MOZ_SYSTEM_VORBIS)
++
++dnl ========================================================
++dnl Check for integer-only libvorbis aka tremor
++dnl ========================================================
++
++MOZ_ARG_WITH_BOOL(system-tremor,
++[ --with-system-tremor Use system libtremor (located with pkgconfig)],
++MOZ_SYSTEM_TREMOR=1,
++MOZ_SYSTEM_TREMOR=)
++
++if test -n "$MOZ_SYSTEM_TREMOR"; then
++ PKG_CHECK_MODULES(MOZ_TREMOR, vorbisidec >= 1.2.1)
++fi
++
++AC_SUBST(MOZ_SYSTEM_TREMOR)
++
++dnl ========================================================
++dnl Check for libtheora
++dnl ========================================================
++
++MOZ_ARG_WITH_BOOL(system-theora,
++[ --with-system-theora Use system libtheora (located with pkgconfig)],
++MOZ_SYSTEM_THEORA=1,
++MOZ_SYSTEM_THEORA=)
++
++if test -n "$MOZ_SYSTEM_THEORA"; then
++ PKG_CHECK_MODULES(MOZ_THEORA, theora >= 1.2)
++fi
++
++AC_SUBST(MOZ_SYSTEM_THEORA)
++
++dnl ========================================================
++dnl Check for libSoundTouch
++dnl ========================================================
++
++MOZ_ARG_WITH_BOOL(system-soundtouch,
++[ --with-system-soundtouch Use system libSoundTouch (located with pkgconfig)],
++MOZ_SYSTEM_SOUNDTOUCH=1,
++MOZ_SYSTEM_SOUNDTOUCH=)
++
++if test -n "$MOZ_SYSTEM_SOUNDTOUCH"; then
++ PKG_CHECK_MODULES(MOZ_SOUNDTOUCH, soundtouch >= 1.9.0)
++
++ AC_LANG_SAVE
++ AC_LANG_CPLUSPLUS
++ _SAVE_CXXFLAGS=$CXXFLAGS
++ CXXFLAGS="$CXXFLAGS $MOZ_SOUNDTOUCH_CFLAGS"
++ AC_CACHE_CHECK(for soundtouch sample type,
++ ac_cv_soundtouch_sample_type,
++ [AC_TRY_COMPILE([#include <SoundTouch.h>
++ #ifndef SOUNDTOUCH_INTEGER_SAMPLES
++ #error soundtouch expects float samples
++ #endif],
++ [],
++ [ac_cv_soundtouch_sample_type=short],
++ [ac_cv_soundtouch_sample_type=float])])
++ CXXFLAGS=$_SAVE_CXXFLAGS
++ AC_LANG_RESTORE
++
++ if test \( -n "$MOZ_SAMPLE_TYPE_S16" -a "$ac_cv_soundtouch_sample_type" != short \) \
++ -o \( -n "$MOZ_SAMPLE_TYPE_FLOAT32" -a "$ac_cv_soundtouch_sample_type" != float \) ; then
++ AC_MSG_ERROR([SoundTouch library is built with incompatible sample type. Either rebuild the library with/without --enable-integer-samples, chase default Mozilla sample type or remove --with-system-soundtouch.])
++ fi
++fi
++
++if test -n "$MOZ_SYSTEM_SOUNDTOUCH"; then
++ AC_DEFINE(MOZ_SYSTEM_SOUNDTOUCH)
++fi
++AC_SUBST(MOZ_SYSTEM_SOUNDTOUCH)
++
+ dnl system libvpx Support
+ dnl ========================================================
+ MOZ_ARG_WITH_BOOL(system-libvpx,
+@@ -3208,6 +3312,67 @@ AC_DEFINE(MOZ_WEBM_ENCODER)
+ AC_SUBST(MOZ_WEBM_ENCODER)
+
+ dnl ==================================
++dnl = Check OSS availability
++dnl ==================================
++
++dnl If using Linux, Solaris or BSDs, ensure that OSS is available
++case "$OS_TARGET" in
++Linux|SunOS|DragonFly|FreeBSD|NetBSD|GNU/kFreeBSD)
++ MOZ_OSS=1
++ ;;
++esac
++
++MOZ_ARG_WITH_STRING(oss,
++[ --with-oss[=PFX] Enable OpenSoundSystem support [installed at prefix PFX]],
++ OSSPREFIX=$withval)
++
++if test -n "$OSSPREFIX"; then
++ if test "$OSSPREFIX" != "no"; then
++ MOZ_OSS=1
++ else
++ MOZ_OSS=
++ fi
++fi
++
++_SAVE_CFLAGS=$CFLAGS
++_SAVE_LIBS=$LIBS
++if test -n "$MOZ_OSS"; then
++ dnl Prefer 4Front implementation
++ AC_MSG_CHECKING([MOZ_OSS_CFLAGS])
++ if test "$OSSPREFIX" != "yes"; then
++ oss_conf=${OSSPREFIX%/usr}/etc/oss.conf
++ if test -f "$oss_conf"; then
++ . "$oss_conf"
++ else
++ OSSLIBDIR=$OSSPREFIX/lib/oss
++ fi
++ if test -d "$OSSLIBDIR"; then
++ MOZ_OSS_CFLAGS="$MOZ_OSS_CFLAGS -I$OSSLIBDIR/include"
++ fi
++ fi
++ AC_MSG_RESULT([$MOZ_OSS_CFLAGS])
++
++ CFLAGS="$CFLAGS $MOZ_OSS_CFLAGS"
++ MOZ_CHECK_HEADERS(sys/soundcard.h soundcard.h)
++
++ if test "$ac_cv_header_sys_soundcard_h" != "yes" -a \
++ "$ac_cv_header_soundcard_h" != "yes"; then
++ AC_MSG_ERROR([Need OSS for Ogg, Wave or WebM decoding on $OS_TARGET. Disable with --without-oss.])
++ fi
++
++ dnl Assume NetBSD implementation over SunAudio
++ AC_CHECK_LIB(ossaudio, _oss_ioctl,
++ [AC_DEFINE_UNQUOTED(CUBEB_OSS_DEFAULT_OUTPUT, "/dev/sound")
++ MOZ_OSS_LIBS="$MOZ_OSS_LIBS -lossaudio"])
++fi
++CFLAGS=$_SAVE_CFLAGS
++LIBS=$_SAVE_LIBS
++
++AC_SUBST(MOZ_OSS)
++AC_SUBST_LIST(MOZ_OSS_CFLAGS)
++AC_SUBST_LIST(MOZ_OSS_LIBS)
++
++dnl ==================================
+ dnl = Check alsa availability on Linux
+ dnl ==================================
+
+@@ -5023,6 +5188,27 @@ if test "$USE_FC_FREETYPE"; then
+ fi
+
+ dnl ========================================================
++dnl Check for graphite2
++dnl ========================================================
++if test -n "$MOZ_SYSTEM_GRAPHITE2"; then
++ dnl graphite2.pc has bogus version, check manually
++ _SAVE_CFLAGS=$CFLAGS
++ CFLAGS="$CFLAGS $MOZ_GRAPHITE2_CFLAGS"
++ AC_TRY_COMPILE([ #include <graphite2/Font.h>
++ #define GR2_VERSION_REQUIRE(major,minor,bugfix) \
++ ( GR2_VERSION_MAJOR * 10000 + GR2_VERSION_MINOR \
++ * 100 + GR2_VERSION_BUGFIX >= \
++ (major) * 10000 + (minor) * 100 + (bugfix) )
++ ], [
++ #if !GR2_VERSION_REQUIRE(1,3,8)
++ #error "Insufficient graphite2 version."
++ #endif
++ ], [],
++ [AC_MSG_ERROR([--with-system-graphite2 requested but no working libgraphite2 found])])
++ CFLAGS=$_SAVE_CFLAGS
++fi
++
++dnl ========================================================
+ dnl Check for pixman and cairo
+ dnl ========================================================
+
diff --git a/www/firefox52/patches/patch-ao b/www/firefox52/patches/patch-ao
new file mode 100644
index 00000000000..03b4458865a
--- /dev/null
+++ b/www/firefox52/patches/patch-ao
@@ -0,0 +1,17 @@
+$NetBSD: patch-ao,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* For devel/xulrunner*
+
+--- toolkit/mozapps/installer/packager.mk.orig 2017-04-11 02:13:24.000000000 +0000
++++ toolkit/mozapps/installer/packager.mk
+@@ -139,8 +139,8 @@ endif
+ (cd $(DESTDIR)$(installdir) && tar -xf -)
+ $(NSINSTALL) -D $(DESTDIR)$(bindir)
+ $(RM) -f $(DESTDIR)$(bindir)/$(MOZ_APP_NAME)
+- ln -s $(installdir)/$(MOZ_APP_NAME) $(DESTDIR)$(bindir)
+-ifdef INSTALL_SDK # Here comes the hard part
++ ln -s $(installdir)/$(MOZ_APP_NAME) $(DESTDIR)$(bindir)/${MOZILLA_PKG_NAME}
++ifeq ($(MOZ_APP_NAME),xulrunner)
+ $(NSINSTALL) -D $(DESTDIR)$(includedir)
+ (cd $(DIST)/include && $(TAR) $(TAR_CREATE_FLAGS) - .) | \
+ (cd $(DESTDIR)$(includedir) && tar -xf -)
diff --git a/www/firefox52/patches/patch-as b/www/firefox52/patches/patch-as
new file mode 100644
index 00000000000..fe4697aaf4d
--- /dev/null
+++ b/www/firefox52/patches/patch-as
@@ -0,0 +1,35 @@
+$NetBSD: patch-as,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Treat DragonFly like FreeBSD.
+* Add system ICU support
+
+--- js/src/old-configure.in.orig 2017-01-16 16:16:52.000000000 +0000
++++ js/src/old-configure.in
+@@ -140,6 +140,9 @@ fi
+
+ MOZ_TOOL_VARIABLES
+
++AC_PROG_CPP
++AC_PROG_CXXCPP
++
+ dnl Special win32 checks
+ dnl ========================================================
+
+@@ -1053,7 +1056,7 @@ dnl Checks for header files.
+ dnl ========================================================
+ AC_HEADER_DIRENT
+ case "$target_os" in
+-freebsd*)
++freebsd*|*-*-dragonfly*)
+ # for stuff like -lXshm
+ CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
+ ;;
+@@ -1184,7 +1187,7 @@ then
+ fi
+
+ case "$target" in
+- *-*-freebsd*)
++ *-*-freebsd*|*-*-dragonfly*)
+ AC_DEFINE(_REENTRANT)
+ AC_DEFINE(_THREAD_SAFE)
+ dnl -pthread links in -lpthread, so don't specify it explicitly.
diff --git a/www/firefox52/patches/patch-build_gyp.mozbuild b/www/firefox52/patches/patch-build_gyp.mozbuild
new file mode 100644
index 00000000000..decf485982c
--- /dev/null
+++ b/www/firefox52/patches/patch-build_gyp.mozbuild
@@ -0,0 +1,24 @@
+$NetBSD: patch-build_gyp.mozbuild,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+Hunk #1:
+ Try to add Video4Linux2 support
+
+Hunk #2:
+ On Darwin, don't assume iOS just because the toolkit is not
+ cocoa. Ideally there should be an AC_SUBST just like 'ARM_ARCH' but
+ nothing exists currently.
+
+Hunk #3:
+ MacOS X SDK version should be able to configure with
+ ./configure --enable-macos-target=VER
+
+--- build/gyp.mozbuild.orig 2016-06-06 20:14:57.000000000 +0000
++++ build/gyp.mozbuild
+@@ -14,6 +14,7 @@ gyp_vars = {
+ 'have_ethtool_cmd_speed_hi': 1 if CONFIG['MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI'] else 0,
+ 'include_alsa_audio': 1 if CONFIG['MOZ_ALSA'] else 0,
+ 'include_pulse_audio': 1 if CONFIG['MOZ_PULSEAUDIO'] else 0,
++ 'use_libv4l2': 1 if CONFIG['MOZ_LIBV4L2_LIBS'] else 0,
+ # basic stuff for everything
+ 'include_internal_video_render': 0,
+ 'clang_use_chrome_plugins': 0,
diff --git a/www/firefox52/patches/patch-build_moz.configure_init.configure b/www/firefox52/patches/patch-build_moz.configure_init.configure
new file mode 100644
index 00000000000..cd6d92bfa38
--- /dev/null
+++ b/www/firefox52/patches/patch-build_moz.configure_init.configure
@@ -0,0 +1,37 @@
+$NetBSD: patch-build_moz.configure_init.configure,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- build/moz.configure/init.configure.orig 2016-10-31 20:15:27.000000000 +0000
++++ build/moz.configure/init.configure
+@@ -170,6 +170,7 @@ option(env='PYTHON', nargs=1, help='Pyth
+ @imports(_from='mozbuild.configure.util', _import='LineIO')
+ @imports(_from='mozbuild.virtualenv', _import='VirtualenvManager')
+ @imports(_from='mozbuild.virtualenv', _import='verify_python_version')
++@imports(_from='__builtin__', _import='KeyError')
+ @imports('distutils.sysconfig')
+ def virtualenv_python(env_python, build_env, mozconfig, help):
+ if help:
+@@ -189,6 +190,12 @@ def virtualenv_python(env_python, build_
+ python = mozconfig['vars']['added']['PYTHON']
+ elif 'PYTHON' in mozconfig['vars']['modified']:
+ python = mozconfig['vars']['modified']['PYTHON'][1]
++ for i in ('env', 'vars'):
++ for j in ('added', 'modified'):
++ try:
++ del mozconfig[i][j]['PYTHON']
++ except KeyError:
++ pass
+
+ with LineIO(lambda l: log.error(l)) as out:
+ verify_python_version(out)
+@@ -224,7 +231,10 @@ def virtualenv_python(env_python, build_
+ if python != normsep(sys.executable):
+ log.info('Reexecuting in the virtualenv')
+ if env_python:
+- del os.environ['PYTHON']
++ try:
++ del os.environ['PYTHON']
++ except KeyError:
++ pass
+ # One would prefer to use os.execl, but that's completely borked on
+ # Windows.
+ sys.exit(subprocess.call([python] + sys.argv))
diff --git a/www/firefox52/patches/patch-build_moz.configure_keyfiles.configure b/www/firefox52/patches/patch-build_moz.configure_keyfiles.configure
new file mode 100644
index 00000000000..274af0f93e0
--- /dev/null
+++ b/www/firefox52/patches/patch-build_moz.configure_keyfiles.configure
@@ -0,0 +1,21 @@
+$NetBSD: patch-build_moz.configure_keyfiles.configure,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- build/moz.configure/keyfiles.configure.orig 2017-01-26 04:20:09.000000000 +0000
++++ build/moz.configure/keyfiles.configure
+@@ -18,6 +18,7 @@ def keyfile(desc, help=None, callback=la
+ @checking('for the %s key' % desc, lambda x: x and x is not no_key)
+ @imports(_from='__builtin__', _import='open')
+ @imports(_from='__builtin__', _import='IOError')
++ @imports(_from='os', _import='environ')
+ def keyfile(value):
+ if value:
+ try:
+@@ -28,7 +29,7 @@ def keyfile(desc, help=None, callback=la
+ raise FatalCheckError("'%s' is empty." % value[0])
+ except IOError as e:
+ raise FatalCheckError("'%s': %s." % (value[0], e.strerror))
+- return no_key
++ return environ.get('MOZ_%s_KEY' % desc.upper().replace(' ', '_')) or no_key
+
+ return keyfile
+
diff --git a/www/firefox52/patches/patch-build_moz.configure_memory.configure b/www/firefox52/patches/patch-build_moz.configure_memory.configure
new file mode 100644
index 00000000000..68e18215361
--- /dev/null
+++ b/www/firefox52/patches/patch-build_moz.configure_memory.configure
@@ -0,0 +1,15 @@
+$NetBSD: patch-build_moz.configure_memory.configure,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+Recognise DragonflyBSD
+
+--- build/moz.configure/memory.configure.orig 2017-01-16 16:16:51.000000000 +0000
++++ build/moz.configure/memory.configure
+@@ -66,7 +66,7 @@ def jemalloc_os_define(jemalloc, jemallo
+ return 'MOZ_MEMORY_LINUX'
+ if target.kernel == 'Darwin':
+ return 'MOZ_MEMORY_DARWIN'
+- if target.kernel in ('kFreeBSD', 'FreeBSD', 'NetBSD'):
++ if target.kernel in ('kFreeBSD', 'FreeBSD', 'NetBSD', 'DragonFly'):
+ return 'MOZ_MEMORY_BSD'
+ die('--enable-jemalloc is not supported on %s', target.kernel)
+
diff --git a/www/firefox52/patches/patch-build_moz.configure_old.configure b/www/firefox52/patches/patch-build_moz.configure_old.configure
new file mode 100644
index 00000000000..f293e9b1dd7
--- /dev/null
+++ b/www/firefox52/patches/patch-build_moz.configure_old.configure
@@ -0,0 +1,25 @@
+$NetBSD: patch-build_moz.configure_old.configure,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- build/moz.configure/old.configure.orig 2017-01-23 16:13:47.000000000 +0000
++++ build/moz.configure/old.configure
+@@ -276,6 +276,7 @@ def old_configure_options(*options):
+ '--with-nspr-prefix',
+ '--with-nss-exec-prefix',
+ '--with-nss-prefix',
++ '--with-oss',
+ '--with-pthreads',
+ '--with-qemu-exe',
+ '--with-sixgill',
+@@ -287,7 +288,12 @@ def old_configure_options(*options):
+ '--with-system-libvpx',
+ '--with-system-nspr',
+ '--with-system-nss',
++ '--with-system-ogg',
+ '--with-system-png',
++ '--with-system-soundtouch',
++ '--with-system-theora',
++ '--with-system-tremor',
++ '--with-system-vorbis',
+ '--with-system-zlib',
+ '--with-thumb',
+ '--with-thumb-interwork',
diff --git a/www/firefox52/patches/patch-build_pgo_profileserver.py b/www/firefox52/patches/patch-build_pgo_profileserver.py
new file mode 100644
index 00000000000..e747bf8c5db
--- /dev/null
+++ b/www/firefox52/patches/patch-build_pgo_profileserver.py
@@ -0,0 +1,13 @@
+$NetBSD: patch-build_pgo_profileserver.py,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- build/pgo/profileserver.py.orig 2017-01-16 16:16:51.000000000 +0000
++++ build/pgo/profileserver.py
+@@ -80,7 +80,7 @@ if __name__ == '__main__':
+ env["MOZ_JAR_LOG_FILE"] = os.path.abspath(jarlog)
+ print "jarlog: %s" % env["MOZ_JAR_LOG_FILE"]
+
+- cmdargs = ["http://localhost:%d/index.html" % PORT]
++ cmdargs = ["http://127.0.0.1:%d/index.html" % PORT]
+ runner = FirefoxRunner(profile=profile,
+ binary=build.get_binary_path(where="staged-package"),
+ cmdargs=cmdargs,
diff --git a/www/firefox52/patches/patch-config_Makefile.in b/www/firefox52/patches/patch-config_Makefile.in
new file mode 100644
index 00000000000..9bb6c6d37f9
--- /dev/null
+++ b/www/firefox52/patches/patch-config_Makefile.in
@@ -0,0 +1,27 @@
+$NetBSD: patch-config_Makefile.in,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support system libraries
+
+--- config/Makefile.in.orig 2016-09-19 16:19:29.000000000 +0000
++++ config/Makefile.in
+@@ -41,6 +41,8 @@ export:: $(export-preqs)
+ $(PYTHON) -m mozbuild.action.preprocessor $(DEFINES) $(ACDEFINES) \
+ -DMOZ_TREE_CAIRO=$(MOZ_TREE_CAIRO) \
+ -DMOZ_TREE_PIXMAN=$(MOZ_TREE_PIXMAN) \
++ -DMOZ_SYSTEM_GRAPHITE2=$(MOZ_SYSTEM_GRAPHITE2) \
++ -DMOZ_SYSTEM_HARFBUZZ=$(MOZ_SYSTEM_HARFBUZZ) \
+ -DMOZ_SYSTEM_HUNSPELL=$(MOZ_SYSTEM_HUNSPELL) \
+ -DMOZ_SYSTEM_BZ2=$(MOZ_SYSTEM_BZ2) \
+ -DMOZ_SYSTEM_ZLIB=$(MOZ_SYSTEM_ZLIB) \
+@@ -49,6 +51,11 @@ export:: $(export-preqs)
+ -DMOZ_SYSTEM_LIBEVENT=$(MOZ_SYSTEM_LIBEVENT) \
+ -DMOZ_SYSTEM_LIBVPX=$(MOZ_SYSTEM_LIBVPX) \
+ -DMOZ_SYSTEM_ICU=$(MOZ_SYSTEM_ICU) \
++ -DMOZ_SYSTEM_OGG=$(MOZ_SYSTEM_OGG) \
++ -DMOZ_SYSTEM_THEORA=$(MOZ_SYSTEM_THEORA) \
++ -DMOZ_SYSTEM_VORBIS=$(MOZ_SYSTEM_VORBIS) \
++ -DMOZ_SYSTEM_TREMOR=$(MOZ_SYSTEM_TREMOR) \
++ -DMOZ_SYSTEM_SOUNDTOUCH=$(MOZ_SYSTEM_SOUNDTOUCH) \
+ $(srcdir)/system-headers $(srcdir)/stl-headers | $(PERL) $(topsrcdir)/nsprpub/config/make-system-wrappers.pl system_wrappers
+ $(INSTALL) system_wrappers $(DIST)
+
diff --git a/www/firefox52/patches/patch-config_baseconfig.mk b/www/firefox52/patches/patch-config_baseconfig.mk
new file mode 100644
index 00000000000..6ff7d4dc3b7
--- /dev/null
+++ b/www/firefox52/patches/patch-config_baseconfig.mk
@@ -0,0 +1,21 @@
+$NetBSD: patch-config_baseconfig.mk,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Set pkgsrc directory structure
+
+--- config/baseconfig.mk.orig 2016-09-19 16:19:29.000000000 +0000
++++ config/baseconfig.mk
+@@ -2,10 +2,10 @@
+ # directly in python/mozbuild/mozbuild/base.py for gmake validation.
+ # We thus use INCLUDED_AUTOCONF_MK to enable/disable some parts depending
+ # whether a normal build is happening or whether the check is running.
+-includedir := $(includedir)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
+-idldir = $(datadir)/idl/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
+-installdir = $(libdir)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
+-sdkdir = $(libdir)/$(MOZ_APP_NAME)-devel-$(MOZ_APP_VERSION)
++includedir := $(includedir)/${MOZILLA_PKG_NAME}
++idldir = $(datadir)/idl/${MOZILLA_PKG_NAME}
++installdir = $(libdir)/${MOZILLA_PKG_NAME}
++sdkdir = $(libdir)/${MOZILLA_PKG_NAME}
+ ifeq (.,$(DEPTH))
+ DIST = dist
+ else
diff --git a/www/firefox52/patches/patch-config_external_moz.build b/www/firefox52/patches/patch-config_external_moz.build
new file mode 100644
index 00000000000..47f674b8346
--- /dev/null
+++ b/www/firefox52/patches/patch-config_external_moz.build
@@ -0,0 +1,43 @@
+$NetBSD: patch-config_external_moz.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support system libraries
+
+--- config/external/moz.build.orig 2017-01-23 16:13:47.000000000 +0000
++++ config/external/moz.build
+@@ -21,12 +21,21 @@ if CONFIG['MOZ_UPDATER']:
+ external_dirs += ['modules/brotli']
+ external_dirs += ['modules/woff2']
+
+-if CONFIG['MOZ_VORBIS']:
++if not CONFIG['MOZ_SYSTEM_OGG']:
++ external_dirs += ['media/libogg']
++
++if CONFIG['MOZ_VORBIS'] and not CONFIG['MOZ_SYSTEM_VORBIS']:
+ external_dirs += ['media/libvorbis']
+
+-if CONFIG['MOZ_TREMOR']:
++if CONFIG['MOZ_TREMOR'] and not CONFIG['MOZ_SYSTEM_TREMOR']:
+ external_dirs += ['media/libtremor']
+
++if not CONFIG['MOZ_SYSTEM_THEORA']:
++ external_dirs += ['media/libtheora']
++
++if not CONFIG['MOZ_SYSTEM_SOUNDTOUCH']:
++ external_dirs += ['media/libsoundtouch']
++
+ if CONFIG['MOZ_WEBM_ENCODER']:
+ external_dirs += ['media/libmkv']
+
+@@ -52,12 +61,9 @@ external_dirs += [
+ 'media/kiss_fft',
+ 'media/libcubeb',
+ 'media/libnestegg',
+- 'media/libogg',
+ 'media/libopus',
+- 'media/libtheora',
+ 'media/libspeex_resampler',
+ 'media/libstagefright',
+- 'media/libsoundtouch',
+ 'media/psshparser'
+ ]
+
diff --git a/www/firefox52/patches/patch-config_stl__wrappers_ios b/www/firefox52/patches/patch-config_stl__wrappers_ios
new file mode 100644
index 00000000000..2376dc2a35a
--- /dev/null
+++ b/www/firefox52/patches/patch-config_stl__wrappers_ios
@@ -0,0 +1,8 @@
+$NetBSD: patch-config_stl__wrappers_ios,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- config/stl_wrappers/ios.orig 2013-05-13 18:23:07.000000000 +0000
++++ config/stl_wrappers/ios
+@@ -0,0 +1,3 @@
++#pragma GCC visibility push(default)
++#include_next <ios>
++#pragma GCC visibility pop
diff --git a/www/firefox52/patches/patch-config_stl__wrappers_ostream b/www/firefox52/patches/patch-config_stl__wrappers_ostream
new file mode 100644
index 00000000000..cea2bba4f43
--- /dev/null
+++ b/www/firefox52/patches/patch-config_stl__wrappers_ostream
@@ -0,0 +1,8 @@
+$NetBSD: patch-config_stl__wrappers_ostream,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- config/stl_wrappers/ostream.orig 2013-05-13 18:22:40.000000000 +0000
++++ config/stl_wrappers/ostream
+@@ -0,0 +1,3 @@
++#pragma GCC visibility push(default)
++#include_next <ostream>
++#pragma GCC visibility pop
diff --git a/www/firefox52/patches/patch-config_system-headers b/www/firefox52/patches/patch-config_system-headers
new file mode 100644
index 00000000000..5e82c36abb3
--- /dev/null
+++ b/www/firefox52/patches/patch-config_system-headers
@@ -0,0 +1,50 @@
+$NetBSD: patch-config_system-headers,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Try to support Video4Linux2
+* Resolve libm undefined error
+* Support system libraries
+
+--- config/system-headers.orig 2017-02-23 20:13:58.000000000 +0000
++++ config/system-headers
+@@ -624,6 +624,7 @@ libgnome/libgnome.h
+ libgnomeui/gnome-icon-lookup.h
+ libgnomeui/gnome-icon-theme.h
+ libgnomeui/gnome-ui-init.h
++libv4l2.h
+ limits.h
+ link.h
+ #ifdef ANDROID
+@@ -1267,6 +1268,15 @@ libsn/sn-launcher.h
+ libsn/sn-monitor.h
+ libsn/sn-util.h
+ #endif
++#if MOZ_SYSTEM_GRAPHITE2==1
++graphite2/Font.h
++graphite2/Segment.h
++#endif
++#if MOZ_SYSTEM_HARFBUZZ==1
++harfbuzz/hb-glib.h
++harfbuzz/hb-ot.h
++harfbuzz/hb.h
++#endif
+ #if MOZ_SYSTEM_HUNSPELL==1
+ hunspell.hxx
+ #endif
+@@ -1335,3 +1345,17 @@ unicode/utypes.h
+ libutil.h
+ unwind.h
+ fenv.h
++#if MOZ_SYSTEM_OGG==1
++ogg/ogg.h
++ogg/os_types.h
++#endif
++#if MOZ_SYSTEM_THEORA==1
++theora/theoradec.h
++#endif
++#if MOZ_SYSTEM_VORBIS==1
++vorbis/codec.h
++vorbis/vorbisenc.h
++#endif
++#if MOZ_SYSTEM_TREMOR==1
++tremor/ivorbiscodec.h
++#endif
diff --git a/www/firefox52/patches/patch-config_system__wrappers_unwind.h b/www/firefox52/patches/patch-config_system__wrappers_unwind.h
new file mode 100644
index 00000000000..58b5f0f6977
--- /dev/null
+++ b/www/firefox52/patches/patch-config_system__wrappers_unwind.h
@@ -0,0 +1,9 @@
+$NetBSD: patch-config_system__wrappers_unwind.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- config/system_wrappers/unwind.h.orig 2013-05-13 19:56:18.000000000 +0000
++++ config/system_wrappers/unwind.h
+@@ -0,0 +1,4 @@
++#pragma GCC system_header
++#pragma GCC visibility push(default)
++#include_next <unwind.h>
++#pragma GCC visibility pop
diff --git a/www/firefox52/patches/patch-dom_base_moz.build b/www/firefox52/patches/patch-dom_base_moz.build
new file mode 100644
index 00000000000..b1d1b1f9626
--- /dev/null
+++ b/www/firefox52/patches/patch-dom_base_moz.build
@@ -0,0 +1,14 @@
+$NetBSD: patch-dom_base_moz.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- dom/base/moz.build.orig 2016-10-31 20:15:32.000000000 +0000
++++ dom/base/moz.build
+@@ -457,6 +457,9 @@ if CONFIG['MOZ_BUILD_APP'] in ['browser'
+ if CONFIG['MOZ_X11']:
+ CXXFLAGS += CONFIG['TK_CFLAGS']
+
++if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
++ CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
++
+ GENERATED_FILES += [
+ 'PropertyUseCounterMap.inc',
+ 'UseCounterList.h',
diff --git a/www/firefox52/patches/patch-dom_filesystem_compat_FileSystemDirectoryReader.h b/www/firefox52/patches/patch-dom_filesystem_compat_FileSystemDirectoryReader.h
new file mode 100644
index 00000000000..7decde2ea7c
--- /dev/null
+++ b/www/firefox52/patches/patch-dom_filesystem_compat_FileSystemDirectoryReader.h
@@ -0,0 +1,12 @@
+$NetBSD: patch-dom_filesystem_compat_FileSystemDirectoryReader.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- dom/filesystem/compat/FileSystemDirectoryReader.h.orig 2017-04-11 02:13:18.000000000 +0000
++++ dom/filesystem/compat/FileSystemDirectoryReader.h
+@@ -11,6 +11,7 @@
+ #include "mozilla/ErrorResult.h"
+ #include "mozilla/dom/BindingDeclarations.h"
+ #include "nsCycleCollectionParticipant.h"
++#include "mozilla/dom/FileSystemDirectoryEntry.h"
+ #include "nsWrapperCache.h"
+
+ namespace mozilla {
diff --git a/www/firefox52/patches/patch-dom_media_AudioStream.cpp b/www/firefox52/patches/patch-dom_media_AudioStream.cpp
new file mode 100644
index 00000000000..1abc66ec650
--- /dev/null
+++ b/www/firefox52/patches/patch-dom_media_AudioStream.cpp
@@ -0,0 +1,38 @@
+$NetBSD: patch-dom_media_AudioStream.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- dom/media/AudioStream.cpp.orig 2016-10-31 20:15:33.000000000 +0000
++++ dom/media/AudioStream.cpp
+@@ -115,7 +115,9 @@ AudioStream::AudioStream(DataSource& aSo
+ : mMonitor("AudioStream")
+ , mChannels(0)
+ , mOutChannels(0)
++#ifndef MOZ_SYSTEM_SOUNDTOUCH
+ , mTimeStretcher(nullptr)
++#endif
+ , mDumpFile(nullptr)
+ , mState(INITIALIZED)
+ , mDataSource(aSource)
+@@ -130,9 +132,11 @@ AudioStream::~AudioStream()
+ if (mDumpFile) {
+ fclose(mDumpFile);
+ }
++#ifndef MOZ_SYSTEM_SOUNDTOUCH
+ if (mTimeStretcher) {
+ soundtouch::destroySoundTouchObj(mTimeStretcher);
+ }
++#endif
+ }
+
+ size_t
+@@ -151,7 +155,11 @@ nsresult AudioStream::EnsureTimeStretche
+ {
+ mMonitor.AssertCurrentThreadOwns();
+ if (!mTimeStretcher) {
++#ifdef MOZ_SYSTEM_SOUNDTOUCH
++ mTimeStretcher = new soundtouch::SoundTouch();
++#else
+ mTimeStretcher = soundtouch::createSoundTouchObj();
++#endif
+ mTimeStretcher->setSampleRate(mAudioClock.GetInputRate());
+ mTimeStretcher->setChannels(mOutChannels);
+ mTimeStretcher->setPitch(1.0);
diff --git a/www/firefox52/patches/patch-dom_media_AudioStream.h b/www/firefox52/patches/patch-dom_media_AudioStream.h
new file mode 100644
index 00000000000..6d104333cb5
--- /dev/null
+++ b/www/firefox52/patches/patch-dom_media_AudioStream.h
@@ -0,0 +1,28 @@
+$NetBSD: patch-dom_media_AudioStream.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- dom/media/AudioStream.h.orig 2016-10-31 20:15:33.000000000 +0000
++++ dom/media/AudioStream.h
+@@ -16,7 +16,11 @@
+ #include "mozilla/TimeStamp.h"
+ #include "mozilla/UniquePtr.h"
+ #include "CubebUtils.h"
++#ifdef MOZ_SYSTEM_SOUNDTOUCH
++#include "soundtouch/SoundTouch.h"
++#else
+ #include "soundtouch/SoundTouchFactory.h"
++#endif
+
+ namespace mozilla {
+
+@@ -282,7 +286,11 @@ private:
+ uint32_t mChannels;
+ uint32_t mOutChannels;
+ AudioClock mAudioClock;
++#ifdef MOZ_SYSTEM_SOUNDTOUCH
++ nsAutoPtr<soundtouch::SoundTouch> mTimeStretcher;
++#else
+ soundtouch::SoundTouch* mTimeStretcher;
++#endif
+
+ // Output file for dumping audio
+ FILE* mDumpFile;
diff --git a/www/firefox52/patches/patch-dom_media_moz.build b/www/firefox52/patches/patch-dom_media_moz.build
new file mode 100644
index 00000000000..ded3ac343ba
--- /dev/null
+++ b/www/firefox52/patches/patch-dom_media_moz.build
@@ -0,0 +1,28 @@
+$NetBSD: patch-dom_media_moz.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support system libraries
+
+--- dom/media/moz.build.orig 2017-01-16 16:16:53.000000000 +0000
++++ dom/media/moz.build
+@@ -316,6 +316,21 @@ if CONFIG['MOZ_WEBRTC']:
+
+ DEFINES['MOZILLA_INTERNAL_API'] = True
+
++if CONFIG['MOZ_SYSTEM_OGG']:
++ CXXFLAGS += CONFIG['MOZ_OGG_CFLAGS']
++
++if CONFIG['MOZ_SYSTEM_THEORA']:
++ CXXFLAGS += CONFIG['MOZ_THEORA_CFLAGS']
++
++if CONFIG['MOZ_SYSTEM_VORBIS']:
++ CXXFLAGS += CONFIG['MOZ_VORBIS_CFLAGS']
++
++if CONFIG['MOZ_SYSTEM_TREMOR']:
++ CXXFLAGS += CONFIG['MOZ_TREMOR_CFLAGS']
++
++if CONFIG['MOZ_SYSTEM_SOUNDTOUCH']:
++ CXXFLAGS += CONFIG['MOZ_SOUNDTOUCH_CFLAGS']
++
+ if CONFIG['OS_TARGET'] == 'WINNT':
+ DEFINES['WEBRTC_WIN'] = True
+ else:
diff --git a/www/firefox52/patches/patch-dom_media_platforms_ffmpeg_ffvpx_FFVPXRuntimeLinker.cpp b/www/firefox52/patches/patch-dom_media_platforms_ffmpeg_ffvpx_FFVPXRuntimeLinker.cpp
new file mode 100644
index 00000000000..9f980664f9a
--- /dev/null
+++ b/www/firefox52/patches/patch-dom_media_platforms_ffmpeg_ffvpx_FFVPXRuntimeLinker.cpp
@@ -0,0 +1,39 @@
+$NetBSD: patch-dom_media_platforms_ffmpeg_ffvpx_FFVPXRuntimeLinker.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp.orig 2016-10-14 08:14:07.000000000 +0000
++++ dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
+@@ -11,9 +11,13 @@
+ #include "prmem.h"
+ #include "prlink.h"
+
++#ifdef MOZ_SYSTEM_SOUNDTOUCH
++#include "nsXPCOMPrivate.h" // for XUL_DLL
++#else
+ // We use a known symbol located in lgpllibs to determine its location.
+ // soundtouch happens to be always included in lgpllibs
+ #include "soundtouch/SoundTouch.h"
++#endif
+
+ namespace mozilla
+ {
+@@ -51,6 +55,12 @@ FFVPXRuntimeLinker::Init()
+
+ sLinkStatus = LinkStatus_FAILED;
+
++#ifdef MOZ_SYSTEM_SOUNDTOUCH
++ // We retrieve the path of the XUL library as this is where mozavcodec and
++ // mozavutil libs are located.
++ char* path =
++ PR_GetLibraryFilePathname(XUL_DLL, (PRFuncPtr)&FFVPXRuntimeLinker::Init);
++#else
+ // We retrieve the path of the lgpllibs library as this is where mozavcodec
+ // and mozavutil libs are located.
+ char* lgpllibsname = PR_GetLibraryName(nullptr, "lgpllibs");
+@@ -61,6 +71,7 @@ FFVPXRuntimeLinker::Init()
+ PR_GetLibraryFilePathname(lgpllibsname,
+ (PRFuncPtr)&soundtouch::SoundTouch::getVersionId);
+ PR_FreeLibraryName(lgpllibsname);
++#endif
+ if (!path) {
+ return false;
+ }
diff --git a/www/firefox52/patches/patch-dom_plugins_ipc_PluginModuleChild.cpp b/www/firefox52/patches/patch-dom_plugins_ipc_PluginModuleChild.cpp
new file mode 100644
index 00000000000..afe10cd0b09
--- /dev/null
+++ b/www/firefox52/patches/patch-dom_plugins_ipc_PluginModuleChild.cpp
@@ -0,0 +1,33 @@
+$NetBSD: patch-dom_plugins_ipc_PluginModuleChild.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support Solaris
+
+--- dom/plugins/ipc/PluginModuleChild.cpp.orig 2015-03-27 02:20:27.000000000 +0000
++++ dom/plugins/ipc/PluginModuleChild.cpp
+@@ -320,7 +320,7 @@ PluginModuleChild::InitForChrome(const s
+
+ // TODO: use PluginPRLibrary here
+
+-#if defined(OS_LINUX) || defined(OS_BSD)
++#if defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS)
+ mShutdownFunc =
+ (NP_PLUGINSHUTDOWN) PR_FindFunctionSymbol(mLibrary, "NP_Shutdown");
+
+@@ -1882,7 +1882,7 @@ PluginModuleChild::AnswerNP_GetEntryPoin
+ AssertPluginThread();
+ MOZ_ASSERT(mIsChrome);
+
+-#if defined(OS_LINUX) || defined(OS_BSD)
++#if defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS)
+ return true;
+ #elif defined(OS_WIN) || defined(OS_MACOSX)
+ *_retval = mGetEntryPointsFunc(&mFunctions);
+@@ -1927,7 +1927,7 @@ PluginModuleChild::DoNP_Initialize(const
+ #endif
+
+ NPError result;
+-#if defined(OS_LINUX) || defined(OS_BSD)
++#if defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS)
+ result = mInitializeFunc(&sBrowserFuncs, &mFunctions);
+ #elif defined(OS_WIN) || defined(OS_MACOSX)
+ result = mInitializeFunc(&sBrowserFuncs);
diff --git a/www/firefox52/patches/patch-dom_plugins_ipc_PluginModuleChild.h b/www/firefox52/patches/patch-dom_plugins_ipc_PluginModuleChild.h
new file mode 100644
index 00000000000..49ef6b123f1
--- /dev/null
+++ b/www/firefox52/patches/patch-dom_plugins_ipc_PluginModuleChild.h
@@ -0,0 +1,15 @@
+$NetBSD: patch-dom_plugins_ipc_PluginModuleChild.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support Solaris
+
+--- dom/plugins/ipc/PluginModuleChild.h.orig 2013-05-11 19:19:27.000000000 +0000
++++ dom/plugins/ipc/PluginModuleChild.h
+@@ -325,7 +325,7 @@ private:
+
+ // we get this from the plugin
+ NP_PLUGINSHUTDOWN mShutdownFunc;
+-#if defined(OS_LINUX) || defined(OS_BSD)
++#if defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS)
+ NP_PLUGINUNIXINIT mInitializeFunc;
+ #elif defined(OS_WIN) || defined(OS_MACOSX)
+ NP_PLUGININIT mInitializeFunc;
diff --git a/www/firefox52/patches/patch-dom_system_OSFileConstants.cpp b/www/firefox52/patches/patch-dom_system_OSFileConstants.cpp
new file mode 100644
index 00000000000..18407e60279
--- /dev/null
+++ b/www/firefox52/patches/patch-dom_system_OSFileConstants.cpp
@@ -0,0 +1,33 @@
+$NetBSD: patch-dom_system_OSFileConstants.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- dom/system/OSFileConstants.cpp.orig 2017-01-23 16:13:57.000000000 +0000
++++ dom/system/OSFileConstants.cpp
+@@ -16,14 +16,17 @@
+ #include "dirent.h"
+ #include "poll.h"
+ #include "sys/stat.h"
+-#if defined(ANDROID)
++#if defined(XP_LINUX)
+ #include <sys/vfs.h>
+ #define statvfs statfs
++#define f_frsize f_bsize
+ #else
+ #include "sys/statvfs.h"
++#endif // defined(XP_LINUX)
++#if !defined(ANDROID)
+ #include "sys/wait.h"
+ #include <spawn.h>
+-#endif // defined(ANDROID)
++#endif // !defined(ANDROID)
+ #endif // defined(XP_UNIX)
+
+ #if defined(XP_LINUX)
+@@ -699,7 +702,7 @@ static const dom::ConstantSpec gLibcProp
+
+ { "OSFILE_SIZEOF_STATVFS", JS::Int32Value(sizeof (struct statvfs)) },
+
+- { "OSFILE_OFFSETOF_STATVFS_F_BSIZE", JS::Int32Value(offsetof (struct statvfs, f_bsize)) },
++ { "OSFILE_OFFSETOF_STATVFS_F_FRSIZE", JS::Int32Value(offsetof (struct statvfs, f_frsize)) },
+ { "OSFILE_OFFSETOF_STATVFS_F_BAVAIL", JS::Int32Value(offsetof (struct statvfs, f_bavail)) },
+
+ #endif // defined(XP_UNIX)
diff --git a/www/firefox52/patches/patch-extensions_spellcheck_hunspell_glue_mozHunspell.cpp b/www/firefox52/patches/patch-extensions_spellcheck_hunspell_glue_mozHunspell.cpp
new file mode 100644
index 00000000000..bf0c4753d04
--- /dev/null
+++ b/www/firefox52/patches/patch-extensions_spellcheck_hunspell_glue_mozHunspell.cpp
@@ -0,0 +1,21 @@
+$NetBSD: patch-extensions_spellcheck_hunspell_glue_mozHunspell.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Read pkgsrc hunspell dictionaries
+
+--- extensions/spellcheck/hunspell/glue/mozHunspell.cpp.orig 2017-01-23 16:13:57.000000000 +0000
++++ extensions/spellcheck/hunspell/glue/mozHunspell.cpp
+@@ -381,6 +381,14 @@ mozHunspell::LoadDictionaryList(bool aNo
+ }
+ }
+
++ // load system hunspell dictionaries
++ nsCOMPtr<nsIFile> hunDir;
++ NS_NewNativeLocalFile(NS_LITERAL_CSTRING("%%LOCALBASE%%/share/hunspell"),
++ true, getter_AddRefs(hunDir));
++ if (hunDir) {
++ LoadDictionariesFromDir(hunDir);
++ }
++
+ // find dictionaries from extensions requiring restart
+ nsCOMPtr<nsISimpleEnumerator> dictDirs;
+ rv = dirSvc->Get(DICTIONARY_SEARCH_DIRECTORY_LIST,
diff --git a/www/firefox52/patches/patch-gfx_cairo_libpixman_src_pixman-arm-neon-asm.S b/www/firefox52/patches/patch-gfx_cairo_libpixman_src_pixman-arm-neon-asm.S
new file mode 100644
index 00000000000..15435c74fdd
--- /dev/null
+++ b/www/firefox52/patches/patch-gfx_cairo_libpixman_src_pixman-arm-neon-asm.S
@@ -0,0 +1,39 @@
+$NetBSD: patch-gfx_cairo_libpixman_src_pixman-arm-neon-asm.S,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support NetBSD/earm
+
+--- gfx/cairo/libpixman/src/pixman-arm-neon-asm.S.orig 2015-09-29 21:45:08.000000000 +0000
++++ gfx/cairo/libpixman/src/pixman-arm-neon-asm.S
+@@ -34,6 +34,12 @@
+ * - pixman_composite_over_n_8_0565_asm_neon
+ */
+
++#if defined(__ARM_EABI__) && !defined(__ARM_DWARF_EH__)
++#define UNWIND
++#else
++#define UNWIND @
++#endif
++
+ /* Prevent the stack from becoming executable for no reason... */
+ #if defined(__linux__) && defined(__ELF__)
+ .section .note.GNU-stack,"",%progbits
+@@ -3141,7 +3147,8 @@ pixman_asm_function fname
+ TMP4 .req r9
+ STRIDE .req r2
+
+- .fnstart
++ .cfi_startproc
++ UNWIND .fnstart
+ mov ip, sp
+ .save {r4, r5, r6, r7, r8, r9}
+ push {r4, r5, r6, r7, r8, r9}
+@@ -3244,7 +3251,8 @@ pixman_asm_function fname
+ .endif
+ pop {r4, r5, r6, r7, r8, r9}
+ bx lr
+- .fnend
++ UNWIND .fnend
++ .cfi_endproc
+
+ .unreq OUT
+ .unreq TOP
diff --git a/www/firefox52/patches/patch-gfx_gl_GLContextProviderGLX.cpp b/www/firefox52/patches/patch-gfx_gl_GLContextProviderGLX.cpp
new file mode 100644
index 00000000000..c7e34f7c8ba
--- /dev/null
+++ b/www/firefox52/patches/patch-gfx_gl_GLContextProviderGLX.cpp
@@ -0,0 +1,16 @@
+$NetBSD: patch-gfx_gl_GLContextProviderGLX.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+Fix libGL.so filename on NetBSD,
+see https://bugzilla.mozilla.org/show_bug.cgi?id=1180498
+
+--- gfx/gl/GLContextProviderGLX.cpp.orig 2015-07-01 00:58:10.000000000 +0200
++++ gfx/gl/GLContextProviderGLX.cpp 2015-07-04 21:13:15.000000000 +0200
+@@ -82,7 +82,7 @@
+ // see e.g. bug 608526: it is intrinsically interesting to know whether we have dynamically linked to libGL.so.1
+ // because at least the NVIDIA implementation requires an executable stack, which causes mprotect calls,
+ // which trigger glibc bug http://sourceware.org/bugzilla/show_bug.cgi?id=12225
+-#ifdef __OpenBSD__
++#if defined(__OpenBSD__) || defined(__NetBSD__)
+ libGLfilename = "libGL.so";
+ #else
+ libGLfilename = "libGL.so.1";
diff --git a/www/firefox52/patches/patch-gfx_graphite2_moz-gr-update.sh b/www/firefox52/patches/patch-gfx_graphite2_moz-gr-update.sh
new file mode 100644
index 00000000000..c68abcdf49a
--- /dev/null
+++ b/www/firefox52/patches/patch-gfx_graphite2_moz-gr-update.sh
@@ -0,0 +1,30 @@
+$NetBSD: patch-gfx_graphite2_moz-gr-update.sh,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- gfx/graphite2/moz-gr-update.sh.orig 2016-07-25 20:22:05.000000000 +0000
++++ gfx/graphite2/moz-gr-update.sh
+@@ -1,6 +1,7 @@
+ #!/bin/bash
+
+ # Script used to update the Graphite2 library in the mozilla source tree
++# and bump version for --with-system-graphite2
+
+ # This script lives in gfx/graphite2, along with the library source,
+ # but must be run from the top level of the mozilla-central tree.
+@@ -37,12 +38,16 @@ echo "See" $0 "for update procedure." >>
+ #find gfx/graphite2/ -name "*.cpp" -exec perl -p -i -e "s/<cstdio>/<stdio.h>/;s/Windows.h/windows.h/;" {} \;
+ #find gfx/graphite2/ -name "*.h" -exec perl -p -i -e "s/<cstdio>/<stdio.h>/;s/Windows.h/windows.h/;" {} \;
+
++# chase version for --with-system-graphite2
++perl -p -i -e "s/[0-9]+\,[0-9]+\,[0-9]+/$RELEASE/ and tr/./,/ \
++ if /GR2_VERSION_REQUIRE/" old-configure.in
++
+ # summarize what's been touched
+ echo Updated to $RELEASE.
+ echo Here is what changed in the gfx/graphite2 directory:
+ echo
+
+-hg stat gfx/graphite2
++hg stat old-configure.in gfx/graphite2
+
+ echo
+ echo If gfx/graphite2/src/files.mk has changed, please make corresponding
diff --git a/www/firefox52/patches/patch-gfx_graphite2_src_Bidi.cpp b/www/firefox52/patches/patch-gfx_graphite2_src_Bidi.cpp
new file mode 100644
index 00000000000..fa4eec64346
--- /dev/null
+++ b/www/firefox52/patches/patch-gfx_graphite2_src_Bidi.cpp
@@ -0,0 +1,18 @@
+$NetBSD: patch-gfx_graphite2_src_Bidi.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support Solaris
+
+--- gfx/graphite2/src/Bidi.cpp.orig 2013-05-11 19:19:30.000000000 +0000
++++ gfx/graphite2/src/Bidi.cpp
+@@ -30,6 +30,11 @@ of the License or (at your option) any l
+
+ using namespace graphite2;
+
++#ifdef __sun
++#undef CS
++#undef ES
++#endif
++
+ enum DirCode { // Hungarian: dirc
+ Unk = -1,
+ N = 0, // other neutrals (default) - ON
diff --git a/www/firefox52/patches/patch-gfx_moz.build b/www/firefox52/patches/patch-gfx_moz.build
new file mode 100644
index 00000000000..a0ebdee0373
--- /dev/null
+++ b/www/firefox52/patches/patch-gfx_moz.build
@@ -0,0 +1,26 @@
+$NetBSD: patch-gfx_moz.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- gfx/moz.build.orig 2016-10-31 20:15:31.000000000 +0000
++++ gfx/moz.build
+@@ -7,6 +7,12 @@
+ if CONFIG['MOZ_TREE_CAIRO']:
+ DIRS += ['cairo']
+
++if not CONFIG['MOZ_SYSTEM_GRAPHITE2']:
++ DIRS += ['graphite2/src' ]
++
++if not CONFIG['MOZ_SYSTEM_HARFBUZZ']:
++ DIRS += ['harfbuzz/src']
++
+ DIRS += [
+ '2d',
+ 'ycbcr',
+@@ -15,8 +21,6 @@ DIRS += [
+ 'qcms',
+ 'gl',
+ 'layers',
+- 'graphite2/src',
+- 'harfbuzz/src',
+ 'ots/src',
+ 'thebes',
+ 'ipc',
diff --git a/www/firefox52/patches/patch-gfx_skia_generate__mozbuild.py b/www/firefox52/patches/patch-gfx_skia_generate__mozbuild.py
new file mode 100644
index 00000000000..d916ed914ef
--- /dev/null
+++ b/www/firefox52/patches/patch-gfx_skia_generate__mozbuild.py
@@ -0,0 +1,14 @@
+$NetBSD: patch-gfx_skia_generate__mozbuild.py,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- gfx/skia/generate_mozbuild.py.orig 2017-01-23 16:13:43.000000000 +0000
++++ gfx/skia/generate_mozbuild.py
+@@ -140,6 +140,9 @@ if CONFIG['CLANG_CXX'] or CONFIG['CLANG_
+ '-Wno-unused-private-field',
+ ]
+
++if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
++ CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
++
+ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'android'):
+ CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+ CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
diff --git a/www/firefox52/patches/patch-gfx_skia_moz.build b/www/firefox52/patches/patch-gfx_skia_moz.build
new file mode 100644
index 00000000000..a1d35c79769
--- /dev/null
+++ b/www/firefox52/patches/patch-gfx_skia_moz.build
@@ -0,0 +1,14 @@
+$NetBSD: patch-gfx_skia_moz.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- gfx/skia/moz.build.orig 2017-01-23 16:13:43.000000000 +0000
++++ gfx/skia/moz.build
+@@ -750,6 +750,9 @@ if CONFIG['CLANG_CXX'] or CONFIG['CLANG_
+ '-Wno-unused-private-field',
+ ]
+
++if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
++ CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
++
+ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'android'):
+ CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+ CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
diff --git a/www/firefox52/patches/patch-gfx_thebes_moz.build b/www/firefox52/patches/patch-gfx_thebes_moz.build
new file mode 100644
index 00000000000..d4e7293f8c8
--- /dev/null
+++ b/www/firefox52/patches/patch-gfx_thebes_moz.build
@@ -0,0 +1,19 @@
+$NetBSD: patch-gfx_thebes_moz.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- gfx/thebes/moz.build.orig 2017-01-23 16:13:47.000000000 +0000
++++ gfx/thebes/moz.build
+@@ -266,7 +266,13 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk
+ LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']
+ LOCAL_INCLUDES += ['/media/libyuv/include']
+
+-DEFINES['GRAPHITE2_STATIC'] = True
++if CONFIG['MOZ_SYSTEM_GRAPHITE2']:
++ CXXFLAGS += CONFIG['MOZ_GRAPHITE2_CFLAGS']
++else:
++ DEFINES['GRAPHITE2_STATIC'] = True
++
++if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
++ CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
+
+ if CONFIG['CLANG_CXX']:
+ # Suppress warnings from Skia header files.
diff --git a/www/firefox52/patches/patch-gfx_ycbcr_moz.build b/www/firefox52/patches/patch-gfx_ycbcr_moz.build
new file mode 100644
index 00000000000..e176bf3c89b
--- /dev/null
+++ b/www/firefox52/patches/patch-gfx_ycbcr_moz.build
@@ -0,0 +1,15 @@
+$NetBSD: patch-gfx_ycbcr_moz.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* yuv_row_arm.S requires pre-processor
+
+--- gfx/ycbcr/moz.build.orig 2014-11-26 12:30:03.000000000 +0000
++++ gfx/ycbcr/moz.build
+@@ -63,7 +63,7 @@ else:
+
+ if CONFIG['CPU_ARCH'] == 'arm' and CONFIG['HAVE_ARM_NEON']:
+ SOURCES += [
+- 'yuv_row_arm.s',
++ 'yuv_row_arm.S',
+ ]
+ SOURCES += [
+ 'yuv_convert_arm.cpp',
diff --git a/www/firefox52/patches/patch-gfx_ycbcr_yuv__row__arm.S b/www/firefox52/patches/patch-gfx_ycbcr_yuv__row__arm.S
new file mode 100644
index 00000000000..8dee679b7b6
--- /dev/null
+++ b/www/firefox52/patches/patch-gfx_ycbcr_yuv__row__arm.S
@@ -0,0 +1,42 @@
+$NetBSD: patch-gfx_ycbcr_yuv__row__arm.S,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Copy from yuv_row_arm.s to process it with pre-processor
+
+--- gfx/ycbcr/yuv_row_arm.S.orig 2016-05-12 17:13:08.000000000 +0000
++++ gfx/ycbcr/yuv_row_arm.S
+@@ -2,6 +2,12 @@
+ * 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(__ARM_EABI__) && !defined(__ARM_DWARF_EH__)
++#define UNWIND
++#else
++#define UNWIND @
++#endif
++
+ .arch armv7-a
+ .fpu neon
+ /* Allow to build on targets not supporting neon, and force the object file
+@@ -74,7 +80,8 @@ YCbCr42xToRGB565_DITHER30_CONSTS_NEON:
+ .global ScaleYCbCr42xToRGB565_BilinearY_Row_NEON
+ .type ScaleYCbCr42xToRGB565_BilinearY_Row_NEON, %function
+ .balign 64
+- .fnstart
++ .cfi_startproc
++ UNWIND .fnstart
+ ScaleYCbCr42xToRGB565_BilinearY_Row_NEON:
+ STMFD r13!,{r4-r9,r14} @ 8 words.
+ ADR r14,YCbCr42xToRGB565_DITHER03_CONSTS_NEON
+@@ -296,9 +303,10 @@ s42xbily_neon_tail:
+ s42xbily_neon_done:
+ VPOP {Q4-Q7} @ 16 words.
+ LDMFD r13!,{r4-r9,PC} @ 8 words.
+- .fnend
++ UNWIND .fnend
++ .cfi_endproc
+ .size ScaleYCbCr42xToRGB565_BilinearY_Row_NEON, .-ScaleYCbCr42xToRGB565_BilinearY_Row_NEON
+
+-#if defined(__ELF__)&&defined(__linux__)
++#if defined(__ELF__)&&(defined(__linux__) || defined(__NetBSD__))
+ .section .note.GNU-stack,"",%progbits
+ #endif
diff --git a/www/firefox52/patches/patch-image_Downscaler.h b/www/firefox52/patches/patch-image_Downscaler.h
new file mode 100644
index 00000000000..dbf7851698a
--- /dev/null
+++ b/www/firefox52/patches/patch-image_Downscaler.h
@@ -0,0 +1,33 @@
+$NetBSD: patch-image_Downscaler.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- image/Downscaler.h.orig 2016-10-31 20:15:32.000000000 +0000
++++ image/Downscaler.h
+@@ -154,14 +154,14 @@ private:
+ class Downscaler
+ {
+ public:
+- explicit Downscaler(const nsIntSize&)
++ explicit Downscaler(const nsIntSize&) : mScale(1.0, 1.0)
+ {
+ MOZ_RELEASE_ASSERT(false, "Skia is not enabled");
+ }
+
+- const nsIntSize& OriginalSize() const { return nsIntSize(); }
+- const nsIntSize& TargetSize() const { return nsIntSize(); }
+- const gfxSize& Scale() const { return gfxSize(1.0, 1.0); }
++ const nsIntSize& OriginalSize() const { return mSize; }
++ const nsIntSize& TargetSize() const { return mSize; }
++ const gfxSize& Scale() const { return mScale; }
+
+ nsresult BeginFrame(const nsIntSize&, const Maybe<nsIntRect>&, uint8_t*, bool, bool = false)
+ {
+@@ -177,6 +177,9 @@ public:
+ DownscalerInvalidRect TakeInvalidRect() { return DownscalerInvalidRect(); }
+ void ResetForNextProgressivePass() { }
+ const nsIntSize FrameSize() const { return nsIntSize(0, 0); }
++private:
++ nsIntSize mSize;
++ gfxSize mScale;
+ };
+
+ #endif // MOZ_ENABLE_SKIA
diff --git a/www/firefox52/patches/patch-image_decoders_nsJPEGDecoder.cpp b/www/firefox52/patches/patch-image_decoders_nsJPEGDecoder.cpp
new file mode 100644
index 00000000000..60858024695
--- /dev/null
+++ b/www/firefox52/patches/patch-image_decoders_nsJPEGDecoder.cpp
@@ -0,0 +1,367 @@
+$NetBSD: patch-image_decoders_nsJPEGDecoder.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+Partially revert https://bugzilla.mozilla.org/show_bug.cgi?id=791305
+to allow building against jpeg (not jpeg-turbo).
+
+--- image/decoders/nsJPEGDecoder.cpp.orig 2016-10-31 20:15:32.000000000 +0000
++++ image/decoders/nsJPEGDecoder.cpp
+@@ -28,13 +28,28 @@
+
+ extern "C" {
+ #include "iccjpeg.h"
+-}
+
++#ifdef JCS_EXTENSIONS
+ #if MOZ_BIG_ENDIAN
+ #define MOZ_JCS_EXT_NATIVE_ENDIAN_XRGB JCS_EXT_XRGB
+ #else
+ #define MOZ_JCS_EXT_NATIVE_ENDIAN_XRGB JCS_EXT_BGRX
+ #endif
++#else
++/* Colorspace conversion (copied from jpegint.h) */
++struct jpeg_color_deconverter {
++ JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
++ JMETHOD(void, color_convert, (j_decompress_ptr cinfo,
++ JSAMPIMAGE input_buf, JDIMENSION input_row,
++ JSAMPARRAY output_buf, int num_rows));
++};
++
++METHODDEF(void)
++ycc_rgb_convert_argb (j_decompress_ptr cinfo,
++ JSAMPIMAGE input_buf, JDIMENSION input_row,
++ JSAMPARRAY output_buf, int num_rows);
++#endif
++}
+
+ static void cmyk_convert_rgb(JSAMPROW row, JDIMENSION width);
+
+@@ -360,6 +375,7 @@ nsJPEGDecoder::ReadJPEGData(const char*
+ case JCS_GRAYSCALE:
+ case JCS_RGB:
+ case JCS_YCbCr:
++#ifdef JCS_EXTENSIONS
+ // if we're not color managing we can decode directly to
+ // MOZ_JCS_EXT_NATIVE_ENDIAN_XRGB
+ if (mCMSMode != eCMSMode_All) {
+@@ -368,6 +384,9 @@ nsJPEGDecoder::ReadJPEGData(const char*
+ } else {
+ mInfo.out_color_space = JCS_RGB;
+ }
++#else
++ mInfo.out_color_space = JCS_RGB;
++#endif
+ break;
+ case JCS_CMYK:
+ case JCS_YCCK:
+@@ -441,6 +460,16 @@ nsJPEGDecoder::ReadJPEGData(const char*
+ return Transition::ContinueUnbuffered(State::JPEG_DATA); // I/O suspension
+ }
+
++#ifndef JCS_EXTENSIONS
++ /* Force to use our YCbCr to Packed RGB converter when possible */
++ if (!mTransform && (mCMSMode != eCMSMode_All) &&
++ mInfo.jpeg_color_space == JCS_YCbCr && mInfo.out_color_space == JCS_RGB) {
++ /* Special case for the most common case: transform from YCbCr direct into packed ARGB */
++ mInfo.out_color_components = 4; /* Packed ARGB pixels are always 4 bytes...*/
++ mInfo.cconvert->color_convert = ycc_rgb_convert_argb;
++ }
++#endif
++
+ // If this is a progressive JPEG ...
+ mState = mInfo.buffered_image ?
+ JPEG_DECOMPRESS_PROGRESSIVE : JPEG_DECOMPRESS_SEQUENTIAL;
+@@ -638,7 +667,11 @@ nsJPEGDecoder::OutputScanlines(bool* sus
+
+ MOZ_ASSERT(imageRow, "Should have a row buffer here");
+
++#ifdef JCS_EXTENSIONS
+ if (mInfo.out_color_space == MOZ_JCS_EXT_NATIVE_ENDIAN_XRGB) {
++#else
++ if (mInfo.cconvert->color_convert == ycc_rgb_convert_argb) {
++#endif
+ // Special case: scanline will be directly converted into packed ARGB
+ if (jpeg_read_scanlines(&mInfo, (JSAMPARRAY)&imageRow, 1) != 1) {
+ *suspend = true; // suspend
+@@ -962,6 +995,282 @@ term_source (j_decompress_ptr jd)
+ } // namespace image
+ } // namespace mozilla
+
++#ifndef JCS_EXTENSIONS
++/**************** YCbCr -> Cairo's RGB24/ARGB32 conversion: most common case **************/
++
++/*
++ * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
++ * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
++ * The conversion equations to be implemented are therefore
++ * R = Y + 1.40200 * Cr
++ * G = Y - 0.34414 * Cb - 0.71414 * Cr
++ * B = Y + 1.77200 * Cb
++ * where Cb and Cr represent the incoming values less CENTERJSAMPLE.
++ * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
++ *
++ * To avoid floating-point arithmetic, we represent the fractional constants
++ * as integers scaled up by 2^16 (about 4 digits precision); we have to divide
++ * the products by 2^16, with appropriate rounding, to get the correct answer.
++ * Notice that Y, being an integral input, does not contribute any fraction
++ * so it need not participate in the rounding.
++ *
++ * For even more speed, we avoid doing any multiplications in the inner loop
++ * by precalculating the constants times Cb and Cr for all possible values.
++ * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
++ * for 12-bit samples it is still acceptable. It's not very reasonable for
++ * 16-bit samples, but if you want lossless storage you shouldn't be changing
++ * colorspace anyway.
++ * The Cr=>R and Cb=>B values can be rounded to integers in advance; the
++ * values for the G calculation are left scaled up, since we must add them
++ * together before rounding.
++ */
++
++#define SCALEBITS 16 /* speediest right-shift on some machines */
++
++/* Use static tables for color processing. */
++/* Four tables, each 256 entries of 4 bytes totals 4K which is not bad... */
++
++const int Cr_r_tab[(MAXJSAMPLE+1) * sizeof(int)] ={
++ -0xb3, -0xb2, -0xb1, -0xaf, -0xae, -0xac,
++ -0xab, -0xaa, -0xa8, -0xa7, -0xa5, -0xa4,
++ -0xa3, -0xa1, -0xa0, -0x9e, -0x9d, -0x9c,
++ -0x9a, -0x99, -0x97, -0x96, -0x95, -0x93,
++ -0x92, -0x90, -0x8f, -0x8e, -0x8c, -0x8b,
++ -0x89, -0x88, -0x87, -0x85, -0x84, -0x82,
++ -0x81, -0x80, -0x7e, -0x7d, -0x7b, -0x7a,
++ -0x79, -0x77, -0x76, -0x74, -0x73, -0x72,
++ -0x70, -0x6f, -0x6d, -0x6c, -0x6b, -0x69,
++ -0x68, -0x66, -0x65, -0x64, -0x62, -0x61,
++ -0x5f, -0x5e, -0x5d, -0x5b, -0x5a, -0x58,
++ -0x57, -0x56, -0x54, -0x53, -0x51, -0x50,
++ -0x4f, -0x4d, -0x4c, -0x4a, -0x49, -0x48,
++ -0x46, -0x45, -0x43, -0x42, -0x40, -0x3f,
++ -0x3e, -0x3c, -0x3b, -0x39, -0x38, -0x37,
++ -0x35, -0x34, -0x32, -0x31, -0x30, -0x2e,
++ -0x2d, -0x2b, -0x2a, -0x29, -0x27, -0x26,
++ -0x24, -0x23, -0x22, -0x20, -0x1f, -0x1d,
++ -0x1c, -0x1b, -0x19, -0x18, -0x16, -0x15,
++ -0x14, -0x12, -0x11, -0x0f, -0x0e, -0x0d,
++ -0x0b, -0x0a, -0x08, -0x07, -0x06, -0x04,
++ -0x03, -0x01, 0x00, 0x01, 0x03, 0x04,
++ 0x06, 0x07, 0x08, 0x0a, 0x0b, 0x0d,
++ 0x0e, 0x0f, 0x11, 0x12, 0x14, 0x15,
++ 0x16, 0x18, 0x19, 0x1b, 0x1c, 0x1d,
++ 0x1f, 0x20, 0x22, 0x23, 0x24, 0x26,
++ 0x27, 0x29, 0x2a, 0x2b, 0x2d, 0x2e,
++ 0x30, 0x31, 0x32, 0x34, 0x35, 0x37,
++ 0x38, 0x39, 0x3b, 0x3c, 0x3e, 0x3f,
++ 0x40, 0x42, 0x43, 0x45, 0x46, 0x48,
++ 0x49, 0x4a, 0x4c, 0x4d, 0x4f, 0x50,
++ 0x51, 0x53, 0x54, 0x56, 0x57, 0x58,
++ 0x5a, 0x5b, 0x5d, 0x5e, 0x5f, 0x61,
++ 0x62, 0x64, 0x65, 0x66, 0x68, 0x69,
++ 0x6b, 0x6c, 0x6d, 0x6f, 0x70, 0x72,
++ 0x73, 0x74, 0x76, 0x77, 0x79, 0x7a,
++ 0x7b, 0x7d, 0x7e, 0x80, 0x81, 0x82,
++ 0x84, 0x85, 0x87, 0x88, 0x89, 0x8b,
++ 0x8c, 0x8e, 0x8f, 0x90, 0x92, 0x93,
++ 0x95, 0x96, 0x97, 0x99, 0x9a, 0x9c,
++ 0x9d, 0x9e, 0xa0, 0xa1, 0xa3, 0xa4,
++ 0xa5, 0xa7, 0xa8, 0xaa, 0xab, 0xac,
++ 0xae, 0xaf, 0xb1, 0xb2,
++ };
++
++const int Cb_b_tab[(MAXJSAMPLE+1) * sizeof(int)] ={
++ -0xe3, -0xe1, -0xdf, -0xde, -0xdc, -0xda,
++ -0xd8, -0xd6, -0xd5, -0xd3, -0xd1, -0xcf,
++ -0xce, -0xcc, -0xca, -0xc8, -0xc6, -0xc5,
++ -0xc3, -0xc1, -0xbf, -0xbe, -0xbc, -0xba,
++ -0xb8, -0xb7, -0xb5, -0xb3, -0xb1, -0xaf,
++ -0xae, -0xac, -0xaa, -0xa8, -0xa7, -0xa5,
++ -0xa3, -0xa1, -0x9f, -0x9e, -0x9c, -0x9a,
++ -0x98, -0x97, -0x95, -0x93, -0x91, -0x90,
++ -0x8e, -0x8c, -0x8a, -0x88, -0x87, -0x85,
++ -0x83, -0x81, -0x80, -0x7e, -0x7c, -0x7a,
++ -0x78, -0x77, -0x75, -0x73, -0x71, -0x70,
++ -0x6e, -0x6c, -0x6a, -0x69, -0x67, -0x65,
++ -0x63, -0x61, -0x60, -0x5e, -0x5c, -0x5a,
++ -0x59, -0x57, -0x55, -0x53, -0x52, -0x50,
++ -0x4e, -0x4c, -0x4a, -0x49, -0x47, -0x45,
++ -0x43, -0x42, -0x40, -0x3e, -0x3c, -0x3a,
++ -0x39, -0x37, -0x35, -0x33, -0x32, -0x30,
++ -0x2e, -0x2c, -0x2b, -0x29, -0x27, -0x25,
++ -0x23, -0x22, -0x20, -0x1e, -0x1c, -0x1b,
++ -0x19, -0x17, -0x15, -0x13, -0x12, -0x10,
++ -0x0e, -0x0c, -0x0b, -0x09, -0x07, -0x05,
++ -0x04, -0x02, 0x00, 0x02, 0x04, 0x05,
++ 0x07, 0x09, 0x0b, 0x0c, 0x0e, 0x10,
++ 0x12, 0x13, 0x15, 0x17, 0x19, 0x1b,
++ 0x1c, 0x1e, 0x20, 0x22, 0x23, 0x25,
++ 0x27, 0x29, 0x2b, 0x2c, 0x2e, 0x30,
++ 0x32, 0x33, 0x35, 0x37, 0x39, 0x3a,
++ 0x3c, 0x3e, 0x40, 0x42, 0x43, 0x45,
++ 0x47, 0x49, 0x4a, 0x4c, 0x4e, 0x50,
++ 0x52, 0x53, 0x55, 0x57, 0x59, 0x5a,
++ 0x5c, 0x5e, 0x60, 0x61, 0x63, 0x65,
++ 0x67, 0x69, 0x6a, 0x6c, 0x6e, 0x70,
++ 0x71, 0x73, 0x75, 0x77, 0x78, 0x7a,
++ 0x7c, 0x7e, 0x80, 0x81, 0x83, 0x85,
++ 0x87, 0x88, 0x8a, 0x8c, 0x8e, 0x90,
++ 0x91, 0x93, 0x95, 0x97, 0x98, 0x9a,
++ 0x9c, 0x9e, 0x9f, 0xa1, 0xa3, 0xa5,
++ 0xa7, 0xa8, 0xaa, 0xac, 0xae, 0xaf,
++ 0xb1, 0xb3, 0xb5, 0xb7, 0xb8, 0xba,
++ 0xbc, 0xbe, 0xbf, 0xc1, 0xc3, 0xc5,
++ 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xcf,
++ 0xd1, 0xd3, 0xd5, 0xd6, 0xd8, 0xda,
++ 0xdc, 0xde, 0xdf, 0xe1,
++ };
++
++const int Cr_g_tab[(MAXJSAMPLE+1) * sizeof(int)] ={
++ 0x5b6900, 0x5ab22e, 0x59fb5c, 0x59448a, 0x588db8, 0x57d6e6,
++ 0x572014, 0x566942, 0x55b270, 0x54fb9e, 0x5444cc, 0x538dfa,
++ 0x52d728, 0x522056, 0x516984, 0x50b2b2, 0x4ffbe0, 0x4f450e,
++ 0x4e8e3c, 0x4dd76a, 0x4d2098, 0x4c69c6, 0x4bb2f4, 0x4afc22,
++ 0x4a4550, 0x498e7e, 0x48d7ac, 0x4820da, 0x476a08, 0x46b336,
++ 0x45fc64, 0x454592, 0x448ec0, 0x43d7ee, 0x43211c, 0x426a4a,
++ 0x41b378, 0x40fca6, 0x4045d4, 0x3f8f02, 0x3ed830, 0x3e215e,
++ 0x3d6a8c, 0x3cb3ba, 0x3bfce8, 0x3b4616, 0x3a8f44, 0x39d872,
++ 0x3921a0, 0x386ace, 0x37b3fc, 0x36fd2a, 0x364658, 0x358f86,
++ 0x34d8b4, 0x3421e2, 0x336b10, 0x32b43e, 0x31fd6c, 0x31469a,
++ 0x308fc8, 0x2fd8f6, 0x2f2224, 0x2e6b52, 0x2db480, 0x2cfdae,
++ 0x2c46dc, 0x2b900a, 0x2ad938, 0x2a2266, 0x296b94, 0x28b4c2,
++ 0x27fdf0, 0x27471e, 0x26904c, 0x25d97a, 0x2522a8, 0x246bd6,
++ 0x23b504, 0x22fe32, 0x224760, 0x21908e, 0x20d9bc, 0x2022ea,
++ 0x1f6c18, 0x1eb546, 0x1dfe74, 0x1d47a2, 0x1c90d0, 0x1bd9fe,
++ 0x1b232c, 0x1a6c5a, 0x19b588, 0x18feb6, 0x1847e4, 0x179112,
++ 0x16da40, 0x16236e, 0x156c9c, 0x14b5ca, 0x13fef8, 0x134826,
++ 0x129154, 0x11da82, 0x1123b0, 0x106cde, 0x0fb60c, 0x0eff3a,
++ 0x0e4868, 0x0d9196, 0x0cdac4, 0x0c23f2, 0x0b6d20, 0x0ab64e,
++ 0x09ff7c, 0x0948aa, 0x0891d8, 0x07db06, 0x072434, 0x066d62,
++ 0x05b690, 0x04ffbe, 0x0448ec, 0x03921a, 0x02db48, 0x022476,
++ 0x016da4, 0x00b6d2, 0x000000, -0x00b6d2, -0x016da4, -0x022476,
++ -0x02db48, -0x03921a, -0x0448ec, -0x04ffbe, -0x05b690, -0x066d62,
++ -0x072434, -0x07db06, -0x0891d8, -0x0948aa, -0x09ff7c, -0x0ab64e,
++ -0x0b6d20, -0x0c23f2, -0x0cdac4, -0x0d9196, -0x0e4868, -0x0eff3a,
++ -0x0fb60c, -0x106cde, -0x1123b0, -0x11da82, -0x129154, -0x134826,
++ -0x13fef8, -0x14b5ca, -0x156c9c, -0x16236e, -0x16da40, -0x179112,
++ -0x1847e4, -0x18feb6, -0x19b588, -0x1a6c5a, -0x1b232c, -0x1bd9fe,
++ -0x1c90d0, -0x1d47a2, -0x1dfe74, -0x1eb546, -0x1f6c18, -0x2022ea,
++ -0x20d9bc, -0x21908e, -0x224760, -0x22fe32, -0x23b504, -0x246bd6,
++ -0x2522a8, -0x25d97a, -0x26904c, -0x27471e, -0x27fdf0, -0x28b4c2,
++ -0x296b94, -0x2a2266, -0x2ad938, -0x2b900a, -0x2c46dc, -0x2cfdae,
++ -0x2db480, -0x2e6b52, -0x2f2224, -0x2fd8f6, -0x308fc8, -0x31469a,
++ -0x31fd6c, -0x32b43e, -0x336b10, -0x3421e2, -0x34d8b4, -0x358f86,
++ -0x364658, -0x36fd2a, -0x37b3fc, -0x386ace, -0x3921a0, -0x39d872,
++ -0x3a8f44, -0x3b4616, -0x3bfce8, -0x3cb3ba, -0x3d6a8c, -0x3e215e,
++ -0x3ed830, -0x3f8f02, -0x4045d4, -0x40fca6, -0x41b378, -0x426a4a,
++ -0x43211c, -0x43d7ee, -0x448ec0, -0x454592, -0x45fc64, -0x46b336,
++ -0x476a08, -0x4820da, -0x48d7ac, -0x498e7e, -0x4a4550, -0x4afc22,
++ -0x4bb2f4, -0x4c69c6, -0x4d2098, -0x4dd76a, -0x4e8e3c, -0x4f450e,
++ -0x4ffbe0, -0x50b2b2, -0x516984, -0x522056, -0x52d728, -0x538dfa,
++ -0x5444cc, -0x54fb9e, -0x55b270, -0x566942, -0x572014, -0x57d6e6,
++ -0x588db8, -0x59448a, -0x59fb5c, -0x5ab22e,
++ };
++
++const int Cb_g_tab[(MAXJSAMPLE+1) * sizeof(int)] ={
++ 0x2c8d00, 0x2c34e6, 0x2bdccc, 0x2b84b2, 0x2b2c98, 0x2ad47e,
++ 0x2a7c64, 0x2a244a, 0x29cc30, 0x297416, 0x291bfc, 0x28c3e2,
++ 0x286bc8, 0x2813ae, 0x27bb94, 0x27637a, 0x270b60, 0x26b346,
++ 0x265b2c, 0x260312, 0x25aaf8, 0x2552de, 0x24fac4, 0x24a2aa,
++ 0x244a90, 0x23f276, 0x239a5c, 0x234242, 0x22ea28, 0x22920e,
++ 0x2239f4, 0x21e1da, 0x2189c0, 0x2131a6, 0x20d98c, 0x208172,
++ 0x202958, 0x1fd13e, 0x1f7924, 0x1f210a, 0x1ec8f0, 0x1e70d6,
++ 0x1e18bc, 0x1dc0a2, 0x1d6888, 0x1d106e, 0x1cb854, 0x1c603a,
++ 0x1c0820, 0x1bb006, 0x1b57ec, 0x1affd2, 0x1aa7b8, 0x1a4f9e,
++ 0x19f784, 0x199f6a, 0x194750, 0x18ef36, 0x18971c, 0x183f02,
++ 0x17e6e8, 0x178ece, 0x1736b4, 0x16de9a, 0x168680, 0x162e66,
++ 0x15d64c, 0x157e32, 0x152618, 0x14cdfe, 0x1475e4, 0x141dca,
++ 0x13c5b0, 0x136d96, 0x13157c, 0x12bd62, 0x126548, 0x120d2e,
++ 0x11b514, 0x115cfa, 0x1104e0, 0x10acc6, 0x1054ac, 0x0ffc92,
++ 0x0fa478, 0x0f4c5e, 0x0ef444, 0x0e9c2a, 0x0e4410, 0x0debf6,
++ 0x0d93dc, 0x0d3bc2, 0x0ce3a8, 0x0c8b8e, 0x0c3374, 0x0bdb5a,
++ 0x0b8340, 0x0b2b26, 0x0ad30c, 0x0a7af2, 0x0a22d8, 0x09cabe,
++ 0x0972a4, 0x091a8a, 0x08c270, 0x086a56, 0x08123c, 0x07ba22,
++ 0x076208, 0x0709ee, 0x06b1d4, 0x0659ba, 0x0601a0, 0x05a986,
++ 0x05516c, 0x04f952, 0x04a138, 0x04491e, 0x03f104, 0x0398ea,
++ 0x0340d0, 0x02e8b6, 0x02909c, 0x023882, 0x01e068, 0x01884e,
++ 0x013034, 0x00d81a, 0x008000, 0x0027e6, -0x003034, -0x00884e,
++ -0x00e068, -0x013882, -0x01909c, -0x01e8b6, -0x0240d0, -0x0298ea,
++ -0x02f104, -0x03491e, -0x03a138, -0x03f952, -0x04516c, -0x04a986,
++ -0x0501a0, -0x0559ba, -0x05b1d4, -0x0609ee, -0x066208, -0x06ba22,
++ -0x07123c, -0x076a56, -0x07c270, -0x081a8a, -0x0872a4, -0x08cabe,
++ -0x0922d8, -0x097af2, -0x09d30c, -0x0a2b26, -0x0a8340, -0x0adb5a,
++ -0x0b3374, -0x0b8b8e, -0x0be3a8, -0x0c3bc2, -0x0c93dc, -0x0cebf6,
++ -0x0d4410, -0x0d9c2a, -0x0df444, -0x0e4c5e, -0x0ea478, -0x0efc92,
++ -0x0f54ac, -0x0facc6, -0x1004e0, -0x105cfa, -0x10b514, -0x110d2e,
++ -0x116548, -0x11bd62, -0x12157c, -0x126d96, -0x12c5b0, -0x131dca,
++ -0x1375e4, -0x13cdfe, -0x142618, -0x147e32, -0x14d64c, -0x152e66,
++ -0x158680, -0x15de9a, -0x1636b4, -0x168ece, -0x16e6e8, -0x173f02,
++ -0x17971c, -0x17ef36, -0x184750, -0x189f6a, -0x18f784, -0x194f9e,
++ -0x19a7b8, -0x19ffd2, -0x1a57ec, -0x1ab006, -0x1b0820, -0x1b603a,
++ -0x1bb854, -0x1c106e, -0x1c6888, -0x1cc0a2, -0x1d18bc, -0x1d70d6,
++ -0x1dc8f0, -0x1e210a, -0x1e7924, -0x1ed13e, -0x1f2958, -0x1f8172,
++ -0x1fd98c, -0x2031a6, -0x2089c0, -0x20e1da, -0x2139f4, -0x21920e,
++ -0x21ea28, -0x224242, -0x229a5c, -0x22f276, -0x234a90, -0x23a2aa,
++ -0x23fac4, -0x2452de, -0x24aaf8, -0x250312, -0x255b2c, -0x25b346,
++ -0x260b60, -0x26637a, -0x26bb94, -0x2713ae, -0x276bc8, -0x27c3e2,
++ -0x281bfc, -0x287416, -0x28cc30, -0x29244a, -0x297c64, -0x29d47e,
++ -0x2a2c98, -0x2a84b2, -0x2adccc, -0x2b34e6,
++ };
++
++
++/* We assume that right shift corresponds to signed division by 2 with
++ * rounding towards minus infinity. This is correct for typical "arithmetic
++ * shift" instructions that shift in copies of the sign bit. But some
++ * C compilers implement >> with an unsigned shift. For these machines you
++ * must define RIGHT_SHIFT_IS_UNSIGNED.
++ * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity.
++ * It is only applied with constant shift counts. SHIFT_TEMPS must be
++ * included in the variables of any routine using RIGHT_SHIFT.
++ */
++
++#ifdef RIGHT_SHIFT_IS_UNSIGNED
++#define SHIFT_TEMPS INT32 shift_temp;
++#define RIGHT_SHIFT(x,shft) \
++ ((shift_temp = (x)) < 0 ? \
++ (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \
++ (shift_temp >> (shft)))
++#else
++#define SHIFT_TEMPS
++#define RIGHT_SHIFT(x,shft) ((x) >> (shft))
++#endif
++
++
++METHODDEF(void)
++ycc_rgb_convert_argb (j_decompress_ptr cinfo,
++ JSAMPIMAGE input_buf, JDIMENSION input_row,
++ JSAMPARRAY output_buf, int num_rows)
++{
++ JDIMENSION num_cols = cinfo->output_width;
++ JSAMPLE * range_limit = cinfo->sample_range_limit;
++
++ SHIFT_TEMPS
++
++ /* This is used if we don't have SSE2 */
++
++ while (--num_rows >= 0) {
++ JSAMPROW inptr0 = input_buf[0][input_row];
++ JSAMPROW inptr1 = input_buf[1][input_row];
++ JSAMPROW inptr2 = input_buf[2][input_row];
++ input_row++;
++ uint32_t *outptr = (uint32_t *) *output_buf++;
++ for (JDIMENSION col = 0; col < num_cols; col++) {
++ int y = GETJSAMPLE(inptr0[col]);
++ int cb = GETJSAMPLE(inptr1[col]);
++ int cr = GETJSAMPLE(inptr2[col]);
++ JSAMPLE * range_limit_y = range_limit + y;
++ /* Range-limiting is essential due to noise introduced by DCT losses. */
++ outptr[col] = 0xFF000000 |
++ ( range_limit_y[Cr_r_tab[cr]] << 16 ) |
++ ( range_limit_y[((int) RIGHT_SHIFT(Cb_g_tab[cb] + Cr_g_tab[cr], SCALEBITS))] << 8 ) |
++ ( range_limit_y[Cb_b_tab[cb]] );
++ }
++ }
++}
++#endif
++
++
+ ///*************** Inverted CMYK -> RGB conversion *************************
+ /// Input is (Inverted) CMYK stored as 4 bytes per pixel.
+ /// Output is RGB stored as 3 bytes per pixel.
diff --git a/www/firefox52/patches/patch-intl_hyphenation_glue_hnjalloc.h b/www/firefox52/patches/patch-intl_hyphenation_glue_hnjalloc.h
new file mode 100644
index 00000000000..53903a4a4ad
--- /dev/null
+++ b/www/firefox52/patches/patch-intl_hyphenation_glue_hnjalloc.h
@@ -0,0 +1,16 @@
+$NetBSD: patch-intl_hyphenation_glue_hnjalloc.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support Solaris
+
+--- intl/hyphenation/glue/hnjalloc.h.orig 2015-12-04 00:36:54.000000000 +0000
++++ intl/hyphenation/glue/hnjalloc.h
+@@ -24,6 +24,9 @@
+ */
+
+ #include <stdio.h> /* ensure stdio.h is loaded before our macros */
++#ifdef __sun
++#include <wchar.h>
++#endif
+
+ #undef FILE
+ #define FILE hnjFile
diff --git a/www/firefox52/patches/patch-intl_unicharutil_util_moz.build b/www/firefox52/patches/patch-intl_unicharutil_util_moz.build
new file mode 100644
index 00000000000..8d9983e18dc
--- /dev/null
+++ b/www/firefox52/patches/patch-intl_unicharutil_util_moz.build
@@ -0,0 +1,12 @@
+$NetBSD: patch-intl_unicharutil_util_moz.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- intl/unicharutil/util/moz.build.orig 2016-10-31 20:15:32.000000000 +0000
++++ intl/unicharutil/util/moz.build
+@@ -42,4 +42,7 @@ if CONFIG['_MSC_VER']:
+ if CONFIG['ENABLE_INTL_API']:
+ USE_LIBS += ['icu']
+
++if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
++ CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
++
+ DIST_INSTALL = True
diff --git a/www/firefox52/patches/patch-ipc_chromium_src_base_atomicops.h b/www/firefox52/patches/patch-ipc_chromium_src_base_atomicops.h
new file mode 100644
index 00000000000..2e997e2438c
--- /dev/null
+++ b/www/firefox52/patches/patch-ipc_chromium_src_base_atomicops.h
@@ -0,0 +1,15 @@
+$NetBSD: patch-ipc_chromium_src_base_atomicops.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Avoid invalid cast errors under NetBSD/evbearmv7hf-el.
+
+--- ipc/chromium/src/base/atomicops.h.orig 2014-11-13 22:49:59.000000000 +0000
++++ ipc/chromium/src/base/atomicops.h
+@@ -45,7 +45,7 @@ typedef int64_t Atomic64;
+
+ // Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or
+ // Atomic64 routines below, depending on your architecture.
+-#ifdef OS_OPENBSD
++#if defined(OS_OPENBSD) || (defined(OS_NETBSD) && defined(ARCH_CPU_ARM_FAMILY))
+ #ifdef ARCH_CPU_64_BITS
+ typedef Atomic64 AtomicWord;
+ #else
diff --git a/www/firefox52/patches/patch-ipc_chromium_src_base_message__pump__libevent.cc b/www/firefox52/patches/patch-ipc_chromium_src_base_message__pump__libevent.cc
new file mode 100644
index 00000000000..9f90f7be740
--- /dev/null
+++ b/www/firefox52/patches/patch-ipc_chromium_src_base_message__pump__libevent.cc
@@ -0,0 +1,22 @@
+$NetBSD: patch-ipc_chromium_src_base_message__pump__libevent.cc,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+Allow older libevent
+
+--- ipc/chromium/src/base/message_pump_libevent.cc.orig 2017-02-27 08:10:53.000000000 -0800
++++ ipc/chromium/src/base/message_pump_libevent.cc 2017-03-07 14:06:51.000000000 -0800
+@@ -22,6 +22,7 @@
+
+ // This macro checks that the _EVENT_SIZEOF_* constants defined in
+ // ipc/chromiume/src/third_party/<platform>/event2/event-config.h are correct.
++#if 0
+ #if defined(_EVENT_SIZEOF_SHORT)
+ #define CHECK_EVENT_SIZEOF(TYPE, type) \
+ static_assert(_EVENT_SIZEOF_##TYPE == sizeof(type), \
+@@ -40,6 +41,7 @@ CHECK_EVENT_SIZEOF(PTHREAD_T, pthread_t)
+ CHECK_EVENT_SIZEOF(SHORT, short);
+ CHECK_EVENT_SIZEOF(SIZE_T, size_t);
+ CHECK_EVENT_SIZEOF(VOID_P, void*);
++#endif
+
+ // Lifecycle of struct event
+ // Libevent uses two main data structures:
diff --git a/www/firefox52/patches/patch-ipc_chromium_src_base_platform__thread.h b/www/firefox52/patches/patch-ipc_chromium_src_base_platform__thread.h
new file mode 100644
index 00000000000..7be6d5481b0
--- /dev/null
+++ b/www/firefox52/patches/patch-ipc_chromium_src_base_platform__thread.h
@@ -0,0 +1,16 @@
+$NetBSD: patch-ipc_chromium_src_base_platform__thread.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support Solaris
+
+--- ipc/chromium/src/base/platform_thread.h.orig 2016-05-12 17:13:13.000000000 +0000
++++ ipc/chromium/src/base/platform_thread.h
+@@ -25,6 +25,9 @@ typedef pthread_t PlatformThreadHandle;
+ #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(__GLIBC__)
+ #include <unistd.h>
+ typedef pid_t PlatformThreadId;
++#elif defined(OS_SOLARIS)
++#include <sys/lwp.h>
++typedef lwpid_t PlatformThreadId;
+ #elif defined(OS_BSD)
+ #include <sys/types.h>
+ typedef lwpid_t PlatformThreadId;
diff --git a/www/firefox52/patches/patch-ipc_chromium_src_base_platform__thread__posix.cc b/www/firefox52/patches/patch-ipc_chromium_src_base_platform__thread__posix.cc
new file mode 100644
index 00000000000..fb060a26fd9
--- /dev/null
+++ b/www/firefox52/patches/patch-ipc_chromium_src_base_platform__thread__posix.cc
@@ -0,0 +1,27 @@
+$NetBSD: patch-ipc_chromium_src_base_platform__thread__posix.cc,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support NetBSD
+* Support Solaris
+
+--- ipc/chromium/src/base/platform_thread_posix.cc.orig 2016-05-12 17:13:13.000000000 +0000
++++ ipc/chromium/src/base/platform_thread_posix.cc
+@@ -10,7 +10,9 @@
+ #if defined(OS_MACOSX)
+ #include <mach/mach.h>
+ #elif defined(OS_NETBSD)
++_Pragma("GCC visibility push(default)")
+ #include <lwp.h>
++_Pragma("GCC visibility pop")
+ #elif defined(OS_LINUX)
+ #include <sys/syscall.h>
+ #include <sys/prctl.h>
+@@ -105,7 +107,8 @@ void PlatformThread::SetName(const char*
+ pthread_setname_np(pthread_self(), "%s", (void *)name);
+ #elif defined(OS_BSD) && !defined(__GLIBC__)
+ pthread_set_name_np(pthread_self(), name);
+-#else
++#elif !defined(OS_SOLARIS)
++ prctl(PR_SET_NAME, reinterpret_cast<uintptr_t>(name), 0, 0, 0);
+ #endif
+ }
+ #endif // !OS_MACOSX
diff --git a/www/firefox52/patches/patch-ipc_chromium_src_base_process__util.h b/www/firefox52/patches/patch-ipc_chromium_src_base_process__util.h
new file mode 100644
index 00000000000..2fe1db8d8c3
--- /dev/null
+++ b/www/firefox52/patches/patch-ipc_chromium_src_base_process__util.h
@@ -0,0 +1,14 @@
+$NetBSD: patch-ipc_chromium_src_base_process__util.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- ipc/chromium/src/base/process_util.h.orig 2015-01-09 04:38:16.000000000 +0000
++++ ipc/chromium/src/base/process_util.h
+@@ -41,6 +41,9 @@
+ typedef PROCESSENTRY32 ProcessEntry;
+ typedef IO_COUNTERS IoCounters;
+ #elif defined(OS_POSIX)
++#ifndef NAME_MAX
++#define NAME_MAX _POSIX_NAME_MAX
++#endif
+ // TODO(port): we should not rely on a Win32 structure.
+ struct ProcessEntry {
+ int pid;
diff --git a/www/firefox52/patches/patch-ipc_chromium_src_base_process__util__posix.cc b/www/firefox52/patches/patch-ipc_chromium_src_base_process__util__posix.cc
new file mode 100644
index 00000000000..381be71256e
--- /dev/null
+++ b/www/firefox52/patches/patch-ipc_chromium_src_base_process__util__posix.cc
@@ -0,0 +1,24 @@
+$NetBSD: patch-ipc_chromium_src_base_process__util__posix.cc,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support Solaris
+
+--- ipc/chromium/src/base/process_util_posix.cc.orig 2013-05-11 19:19:32.000000000 +0000
++++ ipc/chromium/src/base/process_util_posix.cc
+@@ -110,7 +110,7 @@ void CloseSuperfluousFds(const base::Inj
+ #if defined(ANDROID)
+ static const rlim_t kSystemDefaultMaxFds = 1024;
+ static const char kFDDir[] = "/proc/self/fd";
+-#elif defined(OS_LINUX)
++#elif defined(OS_LINUX) || defined(OS_SOLARIS)
+ static const rlim_t kSystemDefaultMaxFds = 8192;
+ static const char kFDDir[] = "/proc/self/fd";
+ #elif defined(OS_MACOSX)
+@@ -202,7 +202,7 @@ void CloseSuperfluousFds(const base::Inj
+ // TODO(agl): Remove this function. It's fundamentally broken for multithreaded
+ // apps.
+ void SetAllFDsToCloseOnExec() {
+-#if defined(OS_LINUX)
++#if defined(OS_LINUX) || defined(OS_SOLARIS)
+ const char fd_dir[] = "/proc/self/fd";
+ #elif defined(OS_MACOSX) || defined(OS_BSD)
+ const char fd_dir[] = "/dev/fd";
diff --git a/www/firefox52/patches/patch-ipc_chromium_src_base_sys__info__posix.cc b/www/firefox52/patches/patch-ipc_chromium_src_base_sys__info__posix.cc
new file mode 100644
index 00000000000..ead9d075d70
--- /dev/null
+++ b/www/firefox52/patches/patch-ipc_chromium_src_base_sys__info__posix.cc
@@ -0,0 +1,18 @@
+$NetBSD: patch-ipc_chromium_src_base_sys__info__posix.cc,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support Solaris
+
+--- ipc/chromium/src/base/sys_info_posix.cc.orig 2016-01-15 01:01:44.000000000 +0000
++++ ipc/chromium/src/base/sys_info_posix.cc
+@@ -119,7 +119,11 @@ std::wstring SysInfo::GetEnvVar(const wc
+
+ // static
+ std::string SysInfo::OperatingSystemName() {
++#ifdef OS_SOLARIS
++ struct utsname info;
++#else
+ utsname info;
++#endif
+ if (uname(&info) < 0) {
+ NOTREACHED();
+ return "";
diff --git a/www/firefox52/patches/patch-ipc_chromium_src_base_time__posix.cc b/www/firefox52/patches/patch-ipc_chromium_src_base_time__posix.cc
new file mode 100644
index 00000000000..3cf88262f40
--- /dev/null
+++ b/www/firefox52/patches/patch-ipc_chromium_src_base_time__posix.cc
@@ -0,0 +1,17 @@
+$NetBSD: patch-ipc_chromium_src_base_time__posix.cc,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support Solaris
+
+--- ipc/chromium/src/base/time_posix.cc.orig 2013-05-11 19:19:32.000000000 +0000
++++ ipc/chromium/src/base/time_posix.cc
+@@ -65,8 +65,10 @@ Time Time::FromExploded(bool is_local, c
+ timestruct.tm_wday = exploded.day_of_week; // mktime/timegm ignore this
+ timestruct.tm_yday = 0; // mktime/timegm ignore this
+ timestruct.tm_isdst = -1; // attempt to figure it out
++#ifndef OS_SOLARIS
+ timestruct.tm_gmtoff = 0; // not a POSIX field, so mktime/timegm ignore
+ timestruct.tm_zone = NULL; // not a POSIX field, so mktime/timegm ignore
++#endif
+
+ time_t seconds;
+ #ifdef ANDROID
diff --git a/www/firefox52/patches/patch-ipc_chromium_src_build_build__config.h b/www/firefox52/patches/patch-ipc_chromium_src_build_build__config.h
new file mode 100644
index 00000000000..03688c49c26
--- /dev/null
+++ b/www/firefox52/patches/patch-ipc_chromium_src_build_build__config.h
@@ -0,0 +1,24 @@
+$NetBSD: patch-ipc_chromium_src_build_build__config.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Add Solaris identifier
+
+--- ipc/chromium/src/build/build_config.h.orig 2013-05-11 19:19:32.000000000 +0000
++++ ipc/chromium/src/build/build_config.h
+@@ -27,6 +27,8 @@
+ #define OS_NETBSD 1
+ #elif defined(__OpenBSD__)
+ #define OS_OPENBSD 1
++#elif defined(__sun)
++#define OS_SOLARIS 1
+ #elif defined(_WIN32)
+ #define OS_WIN 1
+ #else
+@@ -42,7 +44,7 @@
+
+ // For access to standard POSIX features, use OS_POSIX instead of a more
+ // specific macro.
+-#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_BSD)
++#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS)
+ #define OS_POSIX 1
+ #endif
+
diff --git a/www/firefox52/patches/patch-ipc_chromium_src_chrome_common_transport__dib.h b/www/firefox52/patches/patch-ipc_chromium_src_chrome_common_transport__dib.h
new file mode 100644
index 00000000000..88e38fe7f12
--- /dev/null
+++ b/www/firefox52/patches/patch-ipc_chromium_src_chrome_common_transport__dib.h
@@ -0,0 +1,15 @@
+$NetBSD: patch-ipc_chromium_src_chrome_common_transport__dib.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support Solaris
+
+--- ipc/chromium/src/chrome/common/transport_dib.h.orig 2013-05-11 19:19:32.000000000 +0000
++++ ipc/chromium/src/chrome/common/transport_dib.h
+@@ -70,7 +70,7 @@ class TransportDIB {
+ typedef base::SharedMemoryHandle Handle;
+ // On Mac, the inode number of the backing file is used as an id.
+ typedef base::SharedMemoryId Id;
+-#elif defined(OS_LINUX)
++#elif defined(OS_LINUX) || defined(OS_SOLARIS)
+ typedef int Handle; // These two ints are SysV IPC shared memory keys
+ typedef int Id;
+ #endif
diff --git a/www/firefox52/patches/patch-ipc_glue_GeckoChildProcessHost.cpp b/www/firefox52/patches/patch-ipc_glue_GeckoChildProcessHost.cpp
new file mode 100644
index 00000000000..5ccf8b23e8c
--- /dev/null
+++ b/www/firefox52/patches/patch-ipc_glue_GeckoChildProcessHost.cpp
@@ -0,0 +1,48 @@
+$NetBSD: patch-ipc_glue_GeckoChildProcessHost.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support Solaris
+* Fix NetBSD linking
+
+--- ipc/glue/GeckoChildProcessHost.cpp.orig 2015-01-09 04:38:16.000000000 +0000
++++ ipc/glue/GeckoChildProcessHost.cpp
+@@ -4,7 +4,13 @@
+ * 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(__NetBSD__)
++_Pragma("GCC visibility push(default)")
++#endif
+ #include "GeckoChildProcessHost.h"
++#if defined(__NetBSD__)
++_Pragma("GCC visibility pop")
++#endif
+
+ #include "base/command_line.h"
+ #include "base/string_util.h"
+@@ -533,7 +539,7 @@ GeckoChildProcessHost::PerformAsyncLaunc
+ // and passing wstrings from one config to the other is unsafe. So
+ // we split the logic here.
+
+-#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD)
++#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD) || defined(OS_SOLARIS)
+ base::environment_map newEnvVars;
+ ChildPrivileges privs = mPrivileges;
+ if (privs == base::PRIVILEGES_DEFAULT) {
+@@ -672,7 +678,7 @@ GeckoChildProcessHost::PerformAsyncLaunc
+ childArgv.push_back(pidstring);
+
+ #if defined(MOZ_CRASHREPORTER)
+-# if defined(OS_LINUX) || defined(OS_BSD)
++# if defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS)
+ int childCrashFd, childCrashRemapFd;
+ if (!CrashReporter::CreateNotificationPipeForChild(
+ &childCrashFd, &childCrashRemapFd))
+@@ -705,7 +711,7 @@ GeckoChildProcessHost::PerformAsyncLaunc
+ childArgv.push_back(childProcessType);
+
+ base::LaunchApp(childArgv, mFileMap,
+-#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD)
++#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD) || defined(OS_SOLARIS)
+ newEnvVars, privs,
+ #endif
+ false, &process, arch);
diff --git a/www/firefox52/patches/patch-js_src_jit_arm_Architecture-arm.cpp b/www/firefox52/patches/patch-js_src_jit_arm_Architecture-arm.cpp
new file mode 100644
index 00000000000..2378dde588b
--- /dev/null
+++ b/www/firefox52/patches/patch-js_src_jit_arm_Architecture-arm.cpp
@@ -0,0 +1,15 @@
+$NetBSD: patch-js_src_jit_arm_Architecture-arm.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support NetBSD/earm
+
+--- js/src/jit/arm/Architecture-arm.cpp.orig 2015-08-24 21:53:12.000000000 +0000
++++ js/src/jit/arm/Architecture-arm.cpp
+@@ -16,7 +16,7 @@
+ #include "jit/arm/Assembler-arm.h"
+ #include "jit/RegisterSets.h"
+
+-#if !defined(__linux__) || defined(ANDROID) || defined(JS_SIMULATOR_ARM)
++#if !defined(__linux__) || defined(ANDROID) || defined(JS_SIMULATOR_ARM) || defined(__NetBSD__)
+ // The Android NDK and B2G do not include the hwcap.h kernel header, and it is not
+ // defined when building the simulator, so inline the header defines we need.
+ # define HWCAP_VFP (1 << 6)
diff --git a/www/firefox52/patches/patch-js_src_jit_none_AtomicOperations-sparc.h b/www/firefox52/patches/patch-js_src_jit_none_AtomicOperations-sparc.h
new file mode 100644
index 00000000000..79b4f7550bb
--- /dev/null
+++ b/www/firefox52/patches/patch-js_src_jit_none_AtomicOperations-sparc.h
@@ -0,0 +1,261 @@
+$NetBSD: patch-js_src_jit_none_AtomicOperations-sparc.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+Part of https://bugzilla.mozilla.org/show_bug.cgi?id=1232150
+
+--- js/src/jit/none/AtomicOperations-sparc.h.orig 2016-08-01 16:14:38.000000000 +0000
++++ js/src/jit/none/AtomicOperations-sparc.h
+@@ -249,3 +249,254 @@ js::jit::RegionLock::release(void* addr)
+ #endif
+
+ #endif // jit_sparc_AtomicOperations_sparc_h
++/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
++ * vim: set ts=8 sts=4 et sw=4 tw=99:
++ * 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/. */
++
++/* For documentation, see jit/AtomicOperations.h */
++
++#ifndef jit_sparc_AtomicOperations_sparc_h
++#define jit_sparc_AtomicOperations_sparc_h
++
++#include "mozilla/Assertions.h"
++#include "mozilla/Types.h"
++
++#if defined(__clang__) || defined(__GNUC__)
++
++// The default implementation tactic for gcc/clang is to use the newer
++// __atomic intrinsics added for use in C++11 <atomic>. Where that
++// isn't available, we use GCC's older __sync functions instead.
++//
++// ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS is kept as a backward
++// compatible option for older compilers: enable this to use GCC's old
++// __sync functions instead of the newer __atomic functions. This
++// will be required for GCC 4.6.x and earlier, and probably for Clang
++// 3.1, should we need to use those versions.
++
++//#define ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
++
++inline bool
++js::jit::AtomicOperations::isLockfree8()
++{
++# ifndef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
++ MOZ_ASSERT(__atomic_always_lock_free(sizeof(int8_t), 0));
++ MOZ_ASSERT(__atomic_always_lock_free(sizeof(int16_t), 0));
++ MOZ_ASSERT(__atomic_always_lock_free(sizeof(int32_t), 0));
++# if defined(__LP64__)
++ MOZ_ASSERT(__atomic_always_lock_free(sizeof(int64_t), 0));
++# endif
++ return true;
++# else
++ return false;
++# endif
++}
++
++inline void
++js::jit::AtomicOperations::fenceSeqCst()
++{
++# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
++ __sync_synchronize();
++# else
++ __atomic_thread_fence(__ATOMIC_SEQ_CST);
++# endif
++}
++
++template<typename T>
++inline T
++js::jit::AtomicOperations::loadSeqCst(T* addr)
++{
++ MOZ_ASSERT(sizeof(T) < 8 || isLockfree8());
++# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
++ __sync_synchronize();
++ T v = *addr;
++ __sync_synchronize();
++# else
++ T v;
++ __atomic_load(addr, &v, __ATOMIC_SEQ_CST);
++# endif
++ return v;
++}
++
++template<typename T>
++inline void
++js::jit::AtomicOperations::storeSeqCst(T* addr, T val)
++{
++ MOZ_ASSERT(sizeof(T) < 8 || isLockfree8());
++# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
++ __sync_synchronize();
++ *addr = val;
++ __sync_synchronize();
++# else
++ __atomic_store(addr, &val, __ATOMIC_SEQ_CST);
++# endif
++}
++
++template<typename T>
++inline T
++js::jit::AtomicOperations::compareExchangeSeqCst(T* addr, T oldval, T newval)
++{
++ MOZ_ASSERT(sizeof(T) < 8 || isLockfree8());
++# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
++ return __sync_val_compare_and_swap(addr, oldval, newval);
++# else
++ __atomic_compare_exchange(addr, &oldval, &newval, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
++ return oldval;
++# endif
++}
++
++template<typename T>
++inline T
++js::jit::AtomicOperations::fetchAddSeqCst(T* addr, T val)
++{
++#if !defined( __LP64__)
++ static_assert(sizeof(T) <= 4, "not available for 8-byte values yet");
++#endif
++# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
++ return __sync_fetch_and_add(addr, val);
++# else
++ return __atomic_fetch_add(addr, val, __ATOMIC_SEQ_CST);
++# endif
++}
++
++template<typename T>
++inline T
++js::jit::AtomicOperations::fetchSubSeqCst(T* addr, T val)
++{
++#if !defined( __LP64__)
++ static_assert(sizeof(T) <= 4, "not available for 8-byte values yet");
++#endif
++# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
++ return __sync_fetch_and_sub(addr, val);
++# else
++ return __atomic_fetch_sub(addr, val, __ATOMIC_SEQ_CST);
++# endif
++}
++
++template<typename T>
++inline T
++js::jit::AtomicOperations::fetchAndSeqCst(T* addr, T val)
++{
++#if !defined( __LP64__)
++ static_assert(sizeof(T) <= 4, "not available for 8-byte values yet");
++#endif
++# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
++ return __sync_fetch_and_and(addr, val);
++# else
++ return __atomic_fetch_and(addr, val, __ATOMIC_SEQ_CST);
++# endif
++}
++
++template<typename T>
++inline T
++js::jit::AtomicOperations::fetchOrSeqCst(T* addr, T val)
++{
++#if !defined( __LP64__)
++ static_assert(sizeof(T) <= 4, "not available for 8-byte values yet");
++#endif
++# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
++ return __sync_fetch_and_or(addr, val);
++# else
++ return __atomic_fetch_or(addr, val, __ATOMIC_SEQ_CST);
++# endif
++}
++
++template<typename T>
++inline T
++js::jit::AtomicOperations::fetchXorSeqCst(T* addr, T val)
++{
++#if !defined( __LP64__)
++ static_assert(sizeof(T) <= 4, "not available for 8-byte values yet");
++#endif
++# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
++ return __sync_fetch_and_xor(addr, val);
++# else
++ return __atomic_fetch_xor(addr, val, __ATOMIC_SEQ_CST);
++# endif
++}
++
++template<typename T>
++inline T
++js::jit::AtomicOperations::loadSafeWhenRacy(T* addr)
++{
++ return *addr; // FIXME (1208663): not yet safe
++}
++
++template<typename T>
++inline void
++js::jit::AtomicOperations::storeSafeWhenRacy(T* addr, T val)
++{
++ *addr = val; // FIXME (1208663): not yet safe
++}
++
++inline void
++js::jit::AtomicOperations::memcpySafeWhenRacy(void* dest, const void* src, size_t nbytes)
++{
++ ::memcpy(dest, src, nbytes); // FIXME (1208663): not yet safe
++}
++
++inline void
++js::jit::AtomicOperations::memmoveSafeWhenRacy(void* dest, const void* src, size_t nbytes)
++{
++ ::memmove(dest, src, nbytes); // FIXME (1208663): not yet safe
++}
++
++template<typename T>
++inline T
++js::jit::AtomicOperations::exchangeSeqCst(T* addr, T val)
++{
++ MOZ_ASSERT(sizeof(T) < 8 || isLockfree8());
++# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
++ T v;
++ __sync_synchronize();
++ do {
++ v = *addr;
++ } while (__sync_val_compare_and_swap(addr, v, val) != v);
++ return v;
++# else
++ T v;
++ __atomic_exchange(addr, &val, &v, __ATOMIC_SEQ_CST);
++ return v;
++# endif
++}
++
++template<size_t nbytes>
++inline void
++js::jit::RegionLock::acquire(void* addr)
++{
++# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
++ while (!__sync_bool_compare_and_swap(&spinlock, 0, 1))
++ ;
++# else
++ uint32_t zero = 0;
++ uint32_t one = 1;
++ while (!__atomic_compare_exchange(&spinlock, &zero, &one, false, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) {
++ zero = 0;
++ continue;
++ }
++# endif
++}
++
++template<size_t nbytes>
++inline void
++js::jit::RegionLock::release(void* addr)
++{
++ MOZ_ASSERT(AtomicOperations::loadSeqCst(&spinlock) == 1, "releasing unlocked region lock");
++# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
++ __sync_sub_and_fetch(&spinlock, 1);
++# else
++ uint32_t zero = 0;
++ __atomic_store(&spinlock, &zero, __ATOMIC_SEQ_CST);
++# endif
++}
++
++# undef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
++
++#elif defined(ENABLE_SHARED_ARRAY_BUFFER)
++
++# error "Either disable JS shared memory, use GCC or Clang, or add code here"
++
++#endif
++
++#endif // jit_sparc_AtomicOperations_sparc_h
diff --git a/www/firefox52/patches/patch-js_src_moz.build b/www/firefox52/patches/patch-js_src_moz.build
new file mode 100644
index 00000000000..395e9510f3e
--- /dev/null
+++ b/www/firefox52/patches/patch-js_src_moz.build
@@ -0,0 +1,15 @@
+$NetBSD: patch-js_src_moz.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- js/src/moz.build.orig 2017-02-09 20:24:38.000000000 +0000
++++ js/src/moz.build
+@@ -735,10 +735,6 @@ OS_LIBS += CONFIG['REALTIME_LIBS']
+ CFLAGS += CONFIG['MOZ_ICU_CFLAGS']
+ CXXFLAGS += CONFIG['MOZ_ICU_CFLAGS']
+
+-NO_EXPAND_LIBS = True
+-
+-DIST_INSTALL = True
+-
+ # Prepare self-hosted JS code for embedding
+ GENERATED_FILES += [('selfhosted.out.h', 'selfhosted.js')]
+ selfhosted = GENERATED_FILES[('selfhosted.out.h', 'selfhosted.js')]
diff --git a/www/firefox52/patches/patch-js_xpconnect_src_XPCConvert.cpp b/www/firefox52/patches/patch-js_xpconnect_src_XPCConvert.cpp
new file mode 100644
index 00000000000..af7d1925a79
--- /dev/null
+++ b/www/firefox52/patches/patch-js_xpconnect_src_XPCConvert.cpp
@@ -0,0 +1,16 @@
+$NetBSD: patch-js_xpconnect_src_XPCConvert.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+Suggested workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1147837
+Avoids a crash on big endian 64 bit architectures.
+
+--- js/xpconnect/src/XPCConvert.cpp.orig 2015-03-21 04:42:37.000000000 +0100
++++ js/xpconnect/src/XPCConvert.cpp 2015-03-30 13:49:16.000000000 +0200
+@@ -134,7 +134,7 @@
+ d.setNumber(*static_cast<const float*>(s));
+ return true;
+ case nsXPTType::T_DOUBLE:
+- d.setNumber(*static_cast<const double*>(s));
++ d.setNumber(CanonicalizeNaN(*static_cast<const double*>(s)));
+ return true;
+ case nsXPTType::T_BOOL :
+ d.setBoolean(*static_cast<const bool*>(s));
diff --git a/www/firefox52/patches/patch-js_xpconnect_src_xpcprivate.h b/www/firefox52/patches/patch-js_xpconnect_src_xpcprivate.h
new file mode 100644
index 00000000000..6cd6e944981
--- /dev/null
+++ b/www/firefox52/patches/patch-js_xpconnect_src_xpcprivate.h
@@ -0,0 +1,17 @@
+$NetBSD: patch-js_xpconnect_src_xpcprivate.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+From commit log 1.1:
+ Instantiate WeakMapPtr explicitly to get the right visibility with
+ clang.
+
+--- js/xpconnect/src/xpcprivate.h.orig 2016-10-31 20:15:38.000000000 +0000
++++ js/xpconnect/src/xpcprivate.h
+@@ -860,6 +860,8 @@ typedef nsTArray<InterpositionWhitelistP
+ /***************************************************************************/
+ // XPCWrappedNativeScope is one-to-one with a JS global object.
+
++extern template class JS_PUBLIC_API(JS::WeakMapPtr)<JSObject*, JSObject*>;
++
+ class nsIAddonInterposition;
+ class nsXPCComponentsBase;
+ class XPCWrappedNativeScope final : public PRCList
diff --git a/www/firefox52/patches/patch-media_libcubeb_src_cubeb.c b/www/firefox52/patches/patch-media_libcubeb_src_cubeb.c
new file mode 100644
index 00000000000..19740db1991
--- /dev/null
+++ b/www/firefox52/patches/patch-media_libcubeb_src_cubeb.c
@@ -0,0 +1,26 @@
+$NetBSD: patch-media_libcubeb_src_cubeb.c,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support OSS audio
+
+--- media/libcubeb/src/cubeb.c.orig 2017-01-23 16:13:54.000000000 +0000
++++ media/libcubeb/src/cubeb.c
+@@ -54,6 +54,9 @@ int audiotrack_init(cubeb ** context, ch
+ #if defined(USE_KAI)
+ int kai_init(cubeb ** context, char const * context_name);
+ #endif
++#if defined(USE_OSS)
++int oss_init(cubeb ** context, char const * context_name);
++#endif
+
+
+ static int
+@@ -141,6 +144,9 @@ cubeb_init(cubeb ** context, char const
+ #if defined(USE_KAI)
+ kai_init,
+ #endif
++#if defined(USE_OSS)
++ oss_init,
++#endif
+ };
+ int i;
+
diff --git a/www/firefox52/patches/patch-media_libcubeb_src_cubeb__alsa.c b/www/firefox52/patches/patch-media_libcubeb_src_cubeb__alsa.c
new file mode 100644
index 00000000000..1abe57a07b5
--- /dev/null
+++ b/www/firefox52/patches/patch-media_libcubeb_src_cubeb__alsa.c
@@ -0,0 +1,546 @@
+$NetBSD: patch-media_libcubeb_src_cubeb__alsa.c,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support alsa audio under NetBSD
+* Avoid https://github.com/kinetiknz/cubeb/issues/226
+
+--- media/libcubeb/src/cubeb_alsa.c.orig 2016-10-31 20:15:39.000000000 +0000
++++ media/libcubeb/src/cubeb_alsa.c
+@@ -7,11 +7,15 @@
+ #undef NDEBUG
+ #define _DEFAULT_SOURCE
+ #define _BSD_SOURCE
++#if defined(__NetBSD__)
++#define _NETBSD_SOURCE
++#endif
+ #define _XOPEN_SOURCE 500
+ #include <pthread.h>
+ #include <sys/time.h>
+ #include <assert.h>
+ #include <limits.h>
++#include <dlfcn.h>
+ #include <poll.h>
+ #include <unistd.h>
+ #include <alsa/asoundlib.h>
+@@ -25,6 +29,50 @@
+
+ #define ALSA_PA_PLUGIN "ALSA <-> PulseAudio PCM I/O Plugin"
+
++#ifdef DISABLE_LIBASOUND_DLOPEN
++#define WRAP(x) x
++#else
++#define WRAP(x) cubeb_##x
++#define MAKE_TYPEDEF(x) static typeof(x) * cubeb_##x
++MAKE_TYPEDEF(snd_config);
++MAKE_TYPEDEF(snd_config_add);
++MAKE_TYPEDEF(snd_config_copy);
++MAKE_TYPEDEF(snd_config_delete);
++MAKE_TYPEDEF(snd_config_get_id);
++MAKE_TYPEDEF(snd_config_get_string);
++MAKE_TYPEDEF(snd_config_imake_integer);
++MAKE_TYPEDEF(snd_config_search);
++MAKE_TYPEDEF(snd_config_search_definition);
++MAKE_TYPEDEF(snd_lib_error_set_handler);
++MAKE_TYPEDEF(snd_pcm_avail_update);
++MAKE_TYPEDEF(snd_pcm_close);
++MAKE_TYPEDEF(snd_pcm_delay);
++MAKE_TYPEDEF(snd_pcm_drain);
++MAKE_TYPEDEF(snd_pcm_frames_to_bytes);
++MAKE_TYPEDEF(snd_pcm_get_params);
++/* snd_pcm_hw_params_alloca is actually a macro */
++/* MAKE_TYPEDEF(snd_pcm_hw_params_alloca); */
++MAKE_TYPEDEF(snd_pcm_hw_params_sizeof);
++#define snd_pcm_hw_params_sizeof cubeb_snd_pcm_hw_params_sizeof
++MAKE_TYPEDEF(snd_pcm_hw_params_any);
++MAKE_TYPEDEF(snd_pcm_hw_params_get_channels_max);
++MAKE_TYPEDEF(snd_pcm_hw_params_get_rate);
++MAKE_TYPEDEF(snd_pcm_hw_params_set_rate_near);
++MAKE_TYPEDEF(snd_pcm_nonblock);
++MAKE_TYPEDEF(snd_pcm_open);
++MAKE_TYPEDEF(snd_pcm_open_lconf);
++MAKE_TYPEDEF(snd_pcm_pause);
++MAKE_TYPEDEF(snd_pcm_poll_descriptors);
++MAKE_TYPEDEF(snd_pcm_poll_descriptors_count);
++MAKE_TYPEDEF(snd_pcm_poll_descriptors_revents);
++MAKE_TYPEDEF(snd_pcm_recover);
++MAKE_TYPEDEF(snd_pcm_set_params);
++MAKE_TYPEDEF(snd_pcm_state);
++MAKE_TYPEDEF(snd_pcm_writei);
++
++#undef MAKE_TYPEDEF
++#endif
++
+ /* ALSA is not thread-safe. snd_pcm_t instances are individually protected
+ by the owning cubeb_stream's mutex. snd_pcm_t creation and destruction
+ is not thread-safe until ALSA 1.0.24 (see alsa-lib.git commit 91c9c8f1),
+@@ -65,6 +113,8 @@ struct cubeb {
+ workaround is not required. */
+ snd_config_t * local_config;
+ int is_pa;
++
++ void * libasound;
+ };
+
+ enum stream_state {
+@@ -260,10 +310,10 @@ alsa_refill_stream(cubeb_stream * stm)
+
+ pthread_mutex_lock(&stm->mutex);
+
+- avail = snd_pcm_avail_update(stm->pcm);
++ avail = WRAP(snd_pcm_avail_update)(stm->pcm);
+ if (avail < 0) {
+- snd_pcm_recover(stm->pcm, avail, 1);
+- avail = snd_pcm_avail_update(stm->pcm);
++ WRAP(snd_pcm_recover)(stm->pcm, avail, 1);
++ avail = WRAP(snd_pcm_avail_update)(stm->pcm);
+ }
+
+ /* Failed to recover from an xrun, this stream must be broken. */
+@@ -286,7 +336,7 @@ alsa_refill_stream(cubeb_stream * stm)
+ return RUNNING;
+ }
+
+- p = calloc(1, snd_pcm_frames_to_bytes(stm->pcm, avail));
++ p = calloc(1, WRAP(snd_pcm_frames_to_bytes)(stm->pcm, avail));
+ assert(p);
+
+ pthread_mutex_unlock(&stm->mutex);
+@@ -312,10 +362,10 @@ alsa_refill_stream(cubeb_stream * stm)
+ b[i] *= stm->volume;
+ }
+ }
+- wrote = snd_pcm_writei(stm->pcm, p, got);
++ wrote = WRAP(snd_pcm_writei)(stm->pcm, p, got);
+ if (wrote < 0) {
+- snd_pcm_recover(stm->pcm, wrote, 1);
+- wrote = snd_pcm_writei(stm->pcm, p, got);
++ WRAP(snd_pcm_recover)(stm->pcm, wrote, 1);
++ wrote = WRAP(snd_pcm_writei)(stm->pcm, p, got);
+ }
+ assert(wrote >= 0 && wrote == got);
+ stm->write_position += wrote;
+@@ -327,7 +377,7 @@ alsa_refill_stream(cubeb_stream * stm)
+
+ /* Fill the remaining buffer with silence to guarantee one full period
+ has been written. */
+- snd_pcm_writei(stm->pcm, (char *) p + got, avail - got);
++ WRAP(snd_pcm_writei)(stm->pcm, (char *) p + got, avail - got);
+
+ set_timeout(&stm->drain_timeout, buffer_time * 1000);
+
+@@ -440,26 +490,26 @@ get_slave_pcm_node(snd_config_t * lconf,
+
+ slave_def = NULL;
+
+- r = snd_config_search(root_pcm, "slave", &slave_pcm);
++ r = WRAP(snd_config_search)(root_pcm, "slave", &slave_pcm);
+ if (r < 0) {
+ return NULL;
+ }
+
+- r = snd_config_get_string(slave_pcm, &string);
++ r = WRAP(snd_config_get_string)(slave_pcm, &string);
+ if (r >= 0) {
+- r = snd_config_search_definition(lconf, "pcm_slave", string, &slave_def);
++ r = WRAP(snd_config_search_definition)(lconf, "pcm_slave", string, &slave_def);
+ if (r < 0) {
+ return NULL;
+ }
+ }
+
+ do {
+- r = snd_config_search(slave_def ? slave_def : slave_pcm, "pcm", &pcm);
++ r = WRAP(snd_config_search)(slave_def ? slave_def : slave_pcm, "pcm", &pcm);
+ if (r < 0) {
+ break;
+ }
+
+- r = snd_config_get_string(slave_def ? slave_def : slave_pcm, &string);
++ r = WRAP(snd_config_get_string)(slave_def ? slave_def : slave_pcm, &string);
+ if (r < 0) {
+ break;
+ }
+@@ -468,7 +518,7 @@ get_slave_pcm_node(snd_config_t * lconf,
+ if (r < 0 || r > (int) sizeof(node_name)) {
+ break;
+ }
+- r = snd_config_search(lconf, node_name, &pcm);
++ r = WRAP(snd_config_search)(lconf, node_name, &pcm);
+ if (r < 0) {
+ break;
+ }
+@@ -477,7 +527,7 @@ get_slave_pcm_node(snd_config_t * lconf,
+ } while (0);
+
+ if (slave_def) {
+- snd_config_delete(slave_def);
++ WRAP(snd_config_delete)(slave_def);
+ }
+
+ return NULL;
+@@ -500,22 +550,22 @@ init_local_config_with_workaround(char c
+
+ lconf = NULL;
+
+- if (snd_config == NULL) {
++ if (*WRAP(snd_config) == NULL) {
+ return NULL;
+ }
+
+- r = snd_config_copy(&lconf, snd_config);
++ r = WRAP(snd_config_copy)(&lconf, *WRAP(snd_config));
+ if (r < 0) {
+ return NULL;
+ }
+
+ do {
+- r = snd_config_search_definition(lconf, "pcm", pcm_name, &pcm_node);
++ r = WRAP(snd_config_search_definition)(lconf, "pcm", pcm_name, &pcm_node);
+ if (r < 0) {
+ break;
+ }
+
+- r = snd_config_get_id(pcm_node, &string);
++ r = WRAP(snd_config_get_id)(pcm_node, &string);
+ if (r < 0) {
+ break;
+ }
+@@ -524,7 +574,7 @@ init_local_config_with_workaround(char c
+ if (r < 0 || r > (int) sizeof(node_name)) {
+ break;
+ }
+- r = snd_config_search(lconf, node_name, &pcm_node);
++ r = WRAP(snd_config_search)(lconf, node_name, &pcm_node);
+ if (r < 0) {
+ break;
+ }
+@@ -535,12 +585,12 @@ init_local_config_with_workaround(char c
+ }
+
+ /* Fetch the PCM node's type, and bail out if it's not the PulseAudio plugin. */
+- r = snd_config_search(pcm_node, "type", &node);
++ r = WRAP(snd_config_search)(pcm_node, "type", &node);
+ if (r < 0) {
+ break;
+ }
+
+- r = snd_config_get_string(node, &string);
++ r = WRAP(snd_config_get_string)(node, &string);
+ if (r < 0) {
+ break;
+ }
+@@ -551,18 +601,18 @@ init_local_config_with_workaround(char c
+
+ /* Don't clobber an explicit existing handle_underrun value, set it only
+ if it doesn't already exist. */
+- r = snd_config_search(pcm_node, "handle_underrun", &node);
++ r = WRAP(snd_config_search)(pcm_node, "handle_underrun", &node);
+ if (r != -ENOENT) {
+ break;
+ }
+
+ /* Disable pcm_pulse's asynchronous underrun handling. */
+- r = snd_config_imake_integer(&node, "handle_underrun", 0);
++ r = WRAP(snd_config_imake_integer)(&node, "handle_underrun", 0);
+ if (r < 0) {
+ break;
+ }
+
+- r = snd_config_add(pcm_node, node);
++ r = WRAP(snd_config_add)(pcm_node, node);
+ if (r < 0) {
+ break;
+ }
+@@ -570,7 +620,7 @@ init_local_config_with_workaround(char c
+ return lconf;
+ } while (0);
+
+- snd_config_delete(lconf);
++ WRAP(snd_config_delete)(lconf);
+
+ return NULL;
+ }
+@@ -582,9 +632,9 @@ alsa_locked_pcm_open(snd_pcm_t ** pcm, s
+
+ pthread_mutex_lock(&cubeb_alsa_mutex);
+ if (local_config) {
+- r = snd_pcm_open_lconf(pcm, CUBEB_ALSA_PCM_NAME, stream, SND_PCM_NONBLOCK, local_config);
++ r = WRAP(snd_pcm_open_lconf)(pcm, CUBEB_ALSA_PCM_NAME, stream, SND_PCM_NONBLOCK, local_config);
+ } else {
+- r = snd_pcm_open(pcm, CUBEB_ALSA_PCM_NAME, stream, SND_PCM_NONBLOCK);
++ r = WRAP(snd_pcm_open)(pcm, CUBEB_ALSA_PCM_NAME, stream, SND_PCM_NONBLOCK);
+ }
+ pthread_mutex_unlock(&cubeb_alsa_mutex);
+
+@@ -597,7 +647,7 @@ alsa_locked_pcm_close(snd_pcm_t * pcm)
+ int r;
+
+ pthread_mutex_lock(&cubeb_alsa_mutex);
+- r = snd_pcm_close(pcm);
++ r = WRAP(snd_pcm_close)(pcm);
+ pthread_mutex_unlock(&cubeb_alsa_mutex);
+
+ return r;
+@@ -654,12 +704,65 @@ alsa_init(cubeb ** context, char const *
+ pthread_attr_t attr;
+ snd_pcm_t * dummy;
+
++ void * libasound = NULL;
++
++#ifndef DISABLE_LIBASOUND_DLOPEN
++ libasound = dlopen("libasound.so", RTLD_LAZY);
++ if (!libasound) {
++ return CUBEB_ERROR;
++ }
++
++#define LOAD(x) do { \
++ cubeb_##x = dlsym(libasound, #x); \
++ if (!cubeb_##x) { \
++ dlclose(libasound); \
++ return CUBEB_ERROR; \
++ } \
++ } while(0)
++
++ LOAD(snd_config);
++ LOAD(snd_config_add);
++ LOAD(snd_config_copy);
++ LOAD(snd_config_delete);
++ LOAD(snd_config_get_id);
++ LOAD(snd_config_get_string);
++ LOAD(snd_config_imake_integer);
++ LOAD(snd_config_search);
++ LOAD(snd_config_search_definition);
++ LOAD(snd_lib_error_set_handler);
++ LOAD(snd_pcm_avail_update);
++ LOAD(snd_pcm_close);
++ LOAD(snd_pcm_delay);
++ LOAD(snd_pcm_drain);
++ LOAD(snd_pcm_frames_to_bytes);
++ LOAD(snd_pcm_get_params);
++ /* snd_pcm_hw_params_alloca is actually a macro */
++ /* LOAD(snd_pcm_hw_params_alloca); */
++ LOAD(snd_pcm_hw_params_sizeof);
++ LOAD(snd_pcm_hw_params_any);
++ LOAD(snd_pcm_hw_params_get_channels_max);
++ LOAD(snd_pcm_hw_params_get_rate);
++ LOAD(snd_pcm_hw_params_set_rate_near);
++ LOAD(snd_pcm_nonblock);
++ LOAD(snd_pcm_open);
++ LOAD(snd_pcm_open_lconf);
++ LOAD(snd_pcm_pause);
++ LOAD(snd_pcm_poll_descriptors);
++ LOAD(snd_pcm_poll_descriptors_count);
++ LOAD(snd_pcm_poll_descriptors_revents);
++ LOAD(snd_pcm_recover);
++ LOAD(snd_pcm_set_params);
++ LOAD(snd_pcm_state);
++ LOAD(snd_pcm_writei);
++
++#undef LOAD
++#endif
+ assert(context);
+ *context = NULL;
+
+ pthread_mutex_lock(&cubeb_alsa_mutex);
+ if (!cubeb_alsa_error_handler_set) {
+- snd_lib_error_set_handler(silent_error_handler);
++ WRAP(snd_lib_error_set_handler)(silent_error_handler);
+ cubeb_alsa_error_handler_set = 1;
+ }
+ pthread_mutex_unlock(&cubeb_alsa_mutex);
+@@ -667,6 +770,8 @@ alsa_init(cubeb ** context, char const *
+ ctx = calloc(1, sizeof(*ctx));
+ assert(ctx);
+
++ ctx->libasound = libasound;
++
+ ctx->ops = &alsa_ops;
+
+ r = pthread_mutex_init(&ctx->mutex, NULL);
+@@ -716,7 +821,7 @@ alsa_init(cubeb ** context, char const *
+ config fails with EINVAL, the PA PCM is too old for this workaround. */
+ if (r == -EINVAL) {
+ pthread_mutex_lock(&cubeb_alsa_mutex);
+- snd_config_delete(ctx->local_config);
++ WRAP(snd_config_delete)(ctx->local_config);
+ pthread_mutex_unlock(&cubeb_alsa_mutex);
+ ctx->local_config = NULL;
+ } else if (r >= 0) {
+@@ -755,9 +860,13 @@ alsa_destroy(cubeb * ctx)
+ pthread_mutex_destroy(&ctx->mutex);
+ free(ctx->fds);
+
++ if (ctx->libasound) {
++ dlclose(ctx->libasound);
++ }
++
+ if (ctx->local_config) {
+ pthread_mutex_lock(&cubeb_alsa_mutex);
+- snd_config_delete(ctx->local_config);
++ WRAP(snd_config_delete)(ctx->local_config);
+ pthread_mutex_unlock(&cubeb_alsa_mutex);
+ }
+
+@@ -836,13 +945,16 @@ alsa_stream_init(cubeb * ctx, cubeb_stre
+ r = pthread_mutex_init(&stm->mutex, NULL);
+ assert(r == 0);
+
++ r = pthread_cond_init(&stm->cond, NULL);
++ assert(r == 0);
++
+ r = alsa_locked_pcm_open(&stm->pcm, SND_PCM_STREAM_PLAYBACK, ctx->local_config);
+ if (r < 0) {
+ alsa_stream_destroy(stm);
+ return CUBEB_ERROR;
+ }
+
+- r = snd_pcm_nonblock(stm->pcm, 1);
++ r = WRAP(snd_pcm_nonblock)(stm->pcm, 1);
+ assert(r == 0);
+
+ latency_us = latency_frames * 1e6 / stm->params.rate;
+@@ -855,7 +967,7 @@ alsa_stream_init(cubeb * ctx, cubeb_stre
+ latency_us = latency_us < min_latency ? min_latency: latency_us;
+ }
+
+- r = snd_pcm_set_params(stm->pcm, format, SND_PCM_ACCESS_RW_INTERLEAVED,
++ r = WRAP(snd_pcm_set_params)(stm->pcm, format, SND_PCM_ACCESS_RW_INTERLEAVED,
+ stm->params.channels, stm->params.rate, 1,
+ latency_us);
+ if (r < 0) {
+@@ -863,20 +975,17 @@ alsa_stream_init(cubeb * ctx, cubeb_stre
+ return CUBEB_ERROR_INVALID_FORMAT;
+ }
+
+- r = snd_pcm_get_params(stm->pcm, &stm->buffer_size, &period_size);
++ r = WRAP(snd_pcm_get_params)(stm->pcm, &stm->buffer_size, &period_size);
+ assert(r == 0);
+
+- stm->nfds = snd_pcm_poll_descriptors_count(stm->pcm);
++ stm->nfds = WRAP(snd_pcm_poll_descriptors_count)(stm->pcm);
+ assert(stm->nfds > 0);
+
+ stm->saved_fds = calloc(stm->nfds, sizeof(struct pollfd));
+ assert(stm->saved_fds);
+- r = snd_pcm_poll_descriptors(stm->pcm, stm->saved_fds, stm->nfds);
++ r = WRAP(snd_pcm_poll_descriptors)(stm->pcm, stm->saved_fds, stm->nfds);
+ assert((nfds_t) r == stm->nfds);
+
+- r = pthread_cond_init(&stm->cond, NULL);
+- assert(r == 0);
+-
+ if (alsa_register_stream(ctx, stm) != 0) {
+ alsa_stream_destroy(stm);
+ return CUBEB_ERROR;
+@@ -902,7 +1011,7 @@ alsa_stream_destroy(cubeb_stream * stm)
+ pthread_mutex_lock(&stm->mutex);
+ if (stm->pcm) {
+ if (stm->state == DRAINING) {
+- snd_pcm_drain(stm->pcm);
++ WRAP(snd_pcm_drain)(stm->pcm);
+ }
+ alsa_locked_pcm_close(stm->pcm);
+ stm->pcm = NULL;
+@@ -944,12 +1053,12 @@ alsa_get_max_channel_count(cubeb * ctx,
+ return CUBEB_ERROR;
+ }
+
+- r = snd_pcm_hw_params_any(stm->pcm, hw_params);
++ r = WRAP(snd_pcm_hw_params_any)(stm->pcm, hw_params);
+ if (r < 0) {
+ return CUBEB_ERROR;
+ }
+
+- r = snd_pcm_hw_params_get_channels_max(hw_params, max_channels);
++ r = WRAP(snd_pcm_hw_params_get_channels_max)(hw_params, max_channels);
+ if (r < 0) {
+ return CUBEB_ERROR;
+ }
+@@ -969,34 +1078,34 @@ alsa_get_preferred_sample_rate(cubeb * c
+
+ /* get a pcm, disabling resampling, so we get a rate the
+ * hardware/dmix/pulse/etc. supports. */
+- r = snd_pcm_open(&pcm, CUBEB_ALSA_PCM_NAME, SND_PCM_STREAM_PLAYBACK, SND_PCM_NO_AUTO_RESAMPLE);
++ r = WRAP(snd_pcm_open)(&pcm, CUBEB_ALSA_PCM_NAME, SND_PCM_STREAM_PLAYBACK, SND_PCM_NO_AUTO_RESAMPLE);
+ if (r < 0) {
+ return CUBEB_ERROR;
+ }
+
+- r = snd_pcm_hw_params_any(pcm, hw_params);
++ r = WRAP(snd_pcm_hw_params_any)(pcm, hw_params);
+ if (r < 0) {
+- snd_pcm_close(pcm);
++ WRAP(snd_pcm_close)(pcm);
+ return CUBEB_ERROR;
+ }
+
+- r = snd_pcm_hw_params_get_rate(hw_params, rate, &dir);
++ r = WRAP(snd_pcm_hw_params_get_rate)(hw_params, rate, &dir);
+ if (r >= 0) {
+ /* There is a default rate: use it. */
+- snd_pcm_close(pcm);
++ WRAP(snd_pcm_close)(pcm);
+ return CUBEB_OK;
+ }
+
+ /* Use a common rate, alsa may adjust it based on hw/etc. capabilities. */
+ *rate = 44100;
+
+- r = snd_pcm_hw_params_set_rate_near(pcm, hw_params, rate, NULL);
++ r = WRAP(snd_pcm_hw_params_set_rate_near)(pcm, hw_params, rate, NULL);
+ if (r < 0) {
+- snd_pcm_close(pcm);
++ WRAP(snd_pcm_close)(pcm);
+ return CUBEB_ERROR;
+ }
+
+- snd_pcm_close(pcm);
++ WRAP(snd_pcm_close)(pcm);
+
+ return CUBEB_OK;
+ }
+@@ -1020,7 +1129,7 @@ alsa_stream_start(cubeb_stream * stm)
+ ctx = stm->context;
+
+ pthread_mutex_lock(&stm->mutex);
+- snd_pcm_pause(stm->pcm, 0);
++ WRAP(snd_pcm_pause)(stm->pcm, 0);
+ gettimeofday(&stm->last_activity, NULL);
+ pthread_mutex_unlock(&stm->mutex);
+
+@@ -1054,7 +1163,7 @@ alsa_stream_stop(cubeb_stream * stm)
+ pthread_mutex_unlock(&ctx->mutex);
+
+ pthread_mutex_lock(&stm->mutex);
+- snd_pcm_pause(stm->pcm, 1);
++ WRAP(snd_pcm_pause)(stm->pcm, 1);
+ pthread_mutex_unlock(&stm->mutex);
+
+ return CUBEB_OK;
+@@ -1070,14 +1179,15 @@ alsa_stream_get_position(cubeb_stream *
+ pthread_mutex_lock(&stm->mutex);
+
+ delay = -1;
+- if (snd_pcm_state(stm->pcm) != SND_PCM_STATE_RUNNING ||
+- snd_pcm_delay(stm->pcm, &delay) != 0) {
++ if (WRAP(snd_pcm_state)(stm->pcm) != SND_PCM_STATE_RUNNING ||
++ WRAP(snd_pcm_delay)(stm->pcm, &delay) != 0) {
+ *position = stm->last_position;
+ pthread_mutex_unlock(&stm->mutex);
+ return CUBEB_OK;
+ }
+
+- assert(delay >= 0);
++ // Comment out to enable alsa-plugins-oss audio playback
++ // assert(delay >= 0);
+
+ *position = 0;
+ if (stm->write_position >= (snd_pcm_uframes_t) delay) {
+@@ -1096,7 +1206,7 @@ alsa_stream_get_latency(cubeb_stream * s
+ snd_pcm_sframes_t delay;
+ /* This function returns the delay in frames until a frame written using
+ snd_pcm_writei is sent to the DAC. The DAC delay should be < 1ms anyways. */
+- if (snd_pcm_delay(stm->pcm, &delay)) {
++ if (WRAP(snd_pcm_delay)(stm->pcm, &delay)) {
+ return CUBEB_ERROR;
+ }
+
diff --git a/www/firefox52/patches/patch-media_libcubeb_src_cubeb__oss.c b/www/firefox52/patches/patch-media_libcubeb_src_cubeb__oss.c
new file mode 100644
index 00000000000..4db599f4b81
--- /dev/null
+++ b/www/firefox52/patches/patch-media_libcubeb_src_cubeb__oss.c
@@ -0,0 +1,449 @@
+$NetBSD: patch-media_libcubeb_src_cubeb__oss.c,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Restore OSS audio support code
+
+--- media/libcubeb/src/cubeb_oss.c.orig 2016-11-29 13:25:18.814351604 +0000
++++ media/libcubeb/src/cubeb_oss.c
+@@ -0,0 +1,442 @@
++/*
++ * Copyright © 2014 Mozilla Foundation
++ *
++ * This program is made available under an ISC-style license. See the
++ * accompanying file LICENSE for details.
++ */
++#if defined(HAVE_SYS_SOUNDCARD_H)
++#include <sys/soundcard.h>
++#else
++#include <soundcard.h>
++#endif
++#include <unistd.h>
++#include <stdlib.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <fcntl.h>
++#include <sys/ioctl.h>
++#include <errno.h>
++#include <pthread.h>
++#include <stdio.h>
++#include <assert.h>
++
++#include "cubeb/cubeb.h"
++#include "cubeb-internal.h"
++
++#ifndef CUBEB_OSS_DEFAULT_OUTPUT
++#define CUBEB_OSS_DEFAULT_OUTPUT "/dev/dsp"
++#endif
++
++#define OSS_BUFFER_SIZE 1024
++
++struct cubeb {
++ struct cubeb_ops const * ops;
++};
++
++struct cubeb_stream {
++ cubeb * context;
++
++ cubeb_data_callback data_callback;
++ cubeb_state_callback state_callback;
++ void * user_ptr;
++ float volume;
++ float panning;
++
++ pthread_mutex_t state_mutex;
++ pthread_cond_t state_cond;
++
++ int running;
++ int stopped;
++ int floating;
++
++ /* These two vars are needed to support old versions of OSS */
++ unsigned int position_bytes;
++ unsigned int last_position_bytes;
++
++ uint64_t written_frags; /* The number of fragments written to /dev/dsp */
++ uint64_t missed_frags; /* fragments output with stopped stream */
++
++ cubeb_stream_params params;
++ int fd;
++ pthread_t th;
++};
++
++static struct cubeb_ops const oss_ops;
++
++int oss_init(cubeb ** context, char const * context_name)
++{
++ cubeb* ctx = (cubeb*)malloc(sizeof(cubeb));
++ ctx->ops = &oss_ops;
++ *context = ctx;
++ return CUBEB_OK;
++}
++
++static void oss_destroy(cubeb *ctx)
++{
++ free(ctx);
++}
++
++static char const * oss_get_backend_id(cubeb * context)
++{
++ static char oss_name[] = "oss";
++ return oss_name;
++}
++
++static int oss_get_max_channel_count(cubeb * ctx, uint32_t * max_channels)
++{
++ *max_channels = 2; /* Let's support only stereo for now */
++ return CUBEB_OK;
++}
++
++static int oss_get_min_latency(cubeb * context, cubeb_stream_params params,
++ uint32_t * latency_ms)
++{
++ /* 40ms is a big enough number to work ok */
++ *latency_ms = 40;
++ return CUBEB_OK;
++}
++
++static int oss_get_preferred_sample_rate(cubeb *context, uint32_t * rate)
++{
++ /* 48000 seems a prefered choice for most audio devices
++ * and a good choice for OSS */
++ *rate = 48000;
++ return CUBEB_OK;
++}
++
++static void run_state_callback(cubeb_stream *stream, cubeb_state state)
++{
++ if (stream->state_callback) {
++ stream->state_callback(stream, stream->user_ptr, state);
++ }
++}
++
++static long run_data_callback(cubeb_stream *stream, void *buffer, long nframes)
++{
++ long got = 0;
++ pthread_mutex_lock(&stream->state_mutex);
++ if (stream->data_callback && stream->running && !stream->stopped) {
++ pthread_mutex_unlock(&stream->state_mutex);
++ got = stream->data_callback(stream, stream->user_ptr, NULL, buffer, nframes);
++ } else {
++ pthread_mutex_unlock(&stream->state_mutex);
++ }
++ return got;
++}
++
++static void apply_volume_int(int16_t* buffer, unsigned int n,
++ float volume, float panning)
++{
++ float left = volume;
++ float right = volume;
++ unsigned int i;
++ int pan[2];
++ if (panning<0) {
++ right *= (1+panning);
++ } else {
++ left *= (1-panning);
++ }
++ pan[0] = 128.0*left;
++ pan[1] = 128.0*right;
++ for(i=0; i<n; i++){
++ buffer[i] = ((int)buffer[i])*pan[i%2]/128;
++ }
++}
++
++static void apply_volume_float(float* buffer, unsigned int n,
++ float volume, float panning)
++{
++ float left = volume;
++ float right = volume;
++ unsigned int i;
++ float pan[2];
++ if (panning<0) {
++ right *= (1+panning);
++ } else {
++ left *= (1-panning);
++ }
++ pan[0] = left;
++ pan[1] = right;
++ for(i=0; i<n; i++){
++ buffer[i] = buffer[i]*pan[i%2];
++ }
++}
++
++
++static void *writer(void *stm)
++{
++ cubeb_stream* stream = (cubeb_stream*)stm;
++ int16_t buffer[OSS_BUFFER_SIZE];
++ float f_buffer[OSS_BUFFER_SIZE];
++ int got;
++ unsigned long i;
++ while (stream->running) {
++ pthread_mutex_lock(&stream->state_mutex);
++ if (stream->stopped) {
++ pthread_mutex_unlock(&stream->state_mutex);
++ run_state_callback(stream, CUBEB_STATE_STOPPED);
++ pthread_mutex_lock(&stream->state_mutex);
++ while (stream->stopped) {
++ pthread_cond_wait(&stream->state_cond, &stream->state_mutex);
++ }
++ pthread_mutex_unlock(&stream->state_mutex);
++ run_state_callback(stream, CUBEB_STATE_STARTED);
++ continue;
++ }
++ pthread_mutex_unlock(&stream->state_mutex);
++ if (stream->floating) {
++ got = run_data_callback(stream, f_buffer,
++ OSS_BUFFER_SIZE/stream->params.channels);
++ apply_volume_float(f_buffer, got*stream->params.channels,
++ stream->volume, stream->panning);
++ for (i=0; i<((unsigned long)got)*stream->params.channels; i++) {
++ /* Clipping is prefered to overflow */
++ if(f_buffer[i]>=1.0){
++ f_buffer[i]=1.0;
++ }
++ if(f_buffer[i]<=-1.0){
++ f_buffer[i]=-1.0;
++ }
++ /* One might think that multipling by 32767.0 is logical but results in clipping */
++ buffer[i] = f_buffer[i]*32767.0;
++ }
++ } else {
++ got = run_data_callback(stream, buffer,
++ OSS_BUFFER_SIZE/stream->params.channels);
++ apply_volume_int(buffer, got*stream->params.channels,
++ stream->volume, stream->panning);
++ }
++ if (got<0) {
++ run_state_callback(stream, CUBEB_STATE_ERROR);
++ break;
++ }
++ if (!got) {
++ run_state_callback(stream, CUBEB_STATE_DRAINED);
++ }
++ if (got) {
++ size_t i = 0;
++ size_t s = got*stream->params.channels*sizeof(int16_t);
++ while (i < s) {
++ ssize_t n = write(stream->fd, ((char*)buffer) + i, s - i);
++ if (n<=0) {
++ run_state_callback(stream, CUBEB_STATE_ERROR);
++ break;
++ }
++ i+=n;
++ }
++ stream->written_frags+=got;
++ }
++ }
++ return NULL;
++}
++
++static void oss_try_set_latency(cubeb_stream* stream, unsigned int latency)
++{
++ unsigned int latency_bytes, n_frag;
++ int frag;
++ /* fragment size of 1024 is a good choice with good chances to be accepted */
++ unsigned int frag_size=1024;
++ unsigned int frag_log=10; /* 2^frag_log = frag_size */
++ latency_bytes =
++ latency*stream->params.rate*stream->params.channels*sizeof(uint16_t)/1000;
++ n_frag = latency_bytes>>frag_log;
++ frag = (n_frag<<16) | frag_log;
++ /* Even if this fails we wish to continue, not checking for errors */
++ ioctl(stream->fd, SNDCTL_DSP_SETFRAGMENT, &frag);
++}
++
++static int oss_stream_init(cubeb * context, cubeb_stream ** stm,
++ char const * stream_name,
++ cubeb_devid input_device,
++ cubeb_stream_params * input_stream_params,
++ cubeb_devid output_device,
++ cubeb_stream_params * output_stream_params,
++ unsigned int latency,
++ cubeb_data_callback data_callback,
++ cubeb_state_callback state_callback, void * user_ptr)
++{
++ cubeb_stream* stream = (cubeb_stream*)malloc(sizeof(cubeb_stream));
++ stream->context = context;
++ stream->data_callback = data_callback;
++ stream->state_callback = state_callback;
++ stream->user_ptr = user_ptr;
++
++ assert(!input_stream_params && "not supported.");
++ if (input_device || output_device) {
++ /* Device selection not yet implemented. */
++ return CUBEB_ERROR_DEVICE_UNAVAILABLE;
++ }
++
++ if ((stream->fd = open(CUBEB_OSS_DEFAULT_OUTPUT, O_WRONLY)) == -1) {
++ free(stream);
++ return CUBEB_ERROR;
++ }
++#define SET(what, to) do { unsigned int i = to; \
++ int j = ioctl(stream->fd, what, &i); \
++ if (j == -1 || i != to) { \
++ close(stream->fd); \
++ free(stream); \
++ return CUBEB_ERROR_INVALID_FORMAT; } } while (0)
++
++ stream->params = *output_stream_params;
++ stream->volume = 1.0;
++ stream->panning = 0.0;
++
++ oss_try_set_latency(stream, latency);
++
++ stream->floating = 0;
++ SET(SNDCTL_DSP_CHANNELS, stream->params.channels);
++ SET(SNDCTL_DSP_SPEED, stream->params.rate);
++ switch (stream->params.format) {
++ case CUBEB_SAMPLE_S16LE:
++ SET(SNDCTL_DSP_SETFMT, AFMT_S16_LE);
++ break;
++ case CUBEB_SAMPLE_S16BE:
++ SET(SNDCTL_DSP_SETFMT, AFMT_S16_BE);
++ break;
++ case CUBEB_SAMPLE_FLOAT32LE:
++ SET(SNDCTL_DSP_SETFMT, AFMT_S16_NE);
++ stream->floating = 1;
++ break;
++ default:
++ close(stream->fd);
++ free(stream);
++ return CUBEB_ERROR;
++ }
++
++
++ pthread_mutex_init(&stream->state_mutex, NULL);
++ pthread_cond_init(&stream->state_cond, NULL);
++
++ stream->running = 1;
++ stream->stopped = 1;
++ stream->position_bytes = 0;
++ stream->last_position_bytes = 0;
++ stream->written_frags = 0;
++ stream->missed_frags = 0;
++
++ pthread_create(&stream->th, NULL, writer, (void*)stream);
++
++ *stm = stream;
++
++ return CUBEB_OK;
++}
++
++static void oss_stream_destroy(cubeb_stream * stream)
++{
++ pthread_mutex_lock(&stream->state_mutex);
++
++ stream->running = 0;
++ stream->stopped = 0;
++ pthread_cond_signal(&stream->state_cond);
++
++ pthread_mutex_unlock(&stream->state_mutex);
++
++ pthread_join(stream->th, NULL);
++
++ pthread_mutex_destroy(&stream->state_mutex);
++ pthread_cond_destroy(&stream->state_cond);
++ close(stream->fd);
++ free(stream);
++}
++
++static int oss_stream_get_latency(cubeb_stream * stream, uint32_t * latency)
++{
++ if (ioctl(stream->fd, SNDCTL_DSP_GETODELAY, latency)==-1) {
++ return CUBEB_ERROR;
++ }
++ /* Convert latency from bytes to frames */
++ *latency /= stream->params.channels*sizeof(int16_t);
++ return CUBEB_OK;
++}
++
++
++static int oss_stream_current_optr(cubeb_stream * stream, uint64_t * position)
++{
++ count_info ci;
++ /* Unfortunately, this ioctl is only available in OSS 4.x */
++#ifdef SNDCTL_DSP_CURRENT_OPTR
++ oss_count_t count;
++ if (ioctl(stream->fd, SNDCTL_DSP_CURRENT_OPTR, &count) != -1) {
++ *position = count.samples;// + count.fifo_samples;
++ return CUBEB_OK;
++ }
++#endif
++ /* Fall back to this ioctl in case the previous one fails */
++ if (ioctl(stream->fd, SNDCTL_DSP_GETOPTR, &ci) == -1) {
++ return CUBEB_ERROR;
++ }
++ /* ci.bytes is only 32 bit and will start to wrap after arithmetic overflow */
++ stream->position_bytes += ci.bytes - stream->last_position_bytes;
++ stream->last_position_bytes = ci.bytes;
++ *position = stream->position_bytes/stream->params.channels/sizeof(int16_t);
++ return CUBEB_OK;
++}
++
++static int oss_stream_get_position(cubeb_stream * stream, uint64_t * position)
++{
++ if ( oss_stream_current_optr(stream, position) == CUBEB_OK ){
++ *position -= stream->missed_frags;
++ return CUBEB_OK;
++ }
++ /* If no correct method to get position works we resort to this */
++ *position = stream->written_frags;
++ return CUBEB_OK;
++}
++
++
++static int oss_stream_start(cubeb_stream * stream)
++{
++ pthread_mutex_lock(&stream->state_mutex);
++ if (stream->stopped) {
++ uint64_t ptr;
++ oss_stream_current_optr(stream, &ptr);
++ stream->missed_frags = ptr - stream->written_frags;
++ stream->stopped = 0;
++ pthread_cond_signal(&stream->state_cond);
++ }
++ pthread_mutex_unlock(&stream->state_mutex);
++ return CUBEB_OK;
++}
++
++static int oss_stream_stop(cubeb_stream * stream)
++{
++ pthread_mutex_lock(&stream->state_mutex);
++ stream->stopped = 1;
++ pthread_mutex_unlock(&stream->state_mutex);
++ return CUBEB_OK;
++}
++
++int oss_stream_set_panning(cubeb_stream * stream, float panning)
++{
++ if (stream->params.channels == 2) {
++ stream->panning=panning;
++ }
++ return CUBEB_OK;
++}
++
++int oss_stream_set_volume(cubeb_stream * stream, float volume)
++{
++ stream->volume=volume;
++ return CUBEB_OK;
++}
++
++static struct cubeb_ops const oss_ops = {
++ .init = oss_init,
++ .get_backend_id = oss_get_backend_id,
++ .get_max_channel_count = oss_get_max_channel_count,
++ .get_min_latency = oss_get_min_latency,
++ .get_preferred_sample_rate = oss_get_preferred_sample_rate,
++ .destroy = oss_destroy,
++ .stream_init = oss_stream_init,
++ .stream_destroy = oss_stream_destroy,
++ .stream_start = oss_stream_start,
++ .stream_stop = oss_stream_stop,
++ .stream_get_position = oss_stream_get_position,
++ .stream_get_latency = oss_stream_get_latency,
++ .stream_set_volume = oss_stream_set_volume,
++ .stream_set_panning = oss_stream_set_panning,
++ .stream_get_current_device = NULL,
++ .stream_device_destroy = NULL,
++ .stream_register_device_changed_callback = NULL
++};
diff --git a/www/firefox52/patches/patch-media_libcubeb_src_moz.build b/www/firefox52/patches/patch-media_libcubeb_src_moz.build
new file mode 100644
index 00000000000..1db9c53ccf0
--- /dev/null
+++ b/www/firefox52/patches/patch-media_libcubeb_src_moz.build
@@ -0,0 +1,28 @@
+$NetBSD: patch-media_libcubeb_src_moz.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Add OSS audio support
+* Support system library
+
+--- media/libcubeb/src/moz.build.orig 2016-10-31 20:15:39.000000000 +0000
++++ media/libcubeb/src/moz.build
+@@ -24,6 +24,12 @@ if CONFIG['MOZ_PULSEAUDIO'] or CONFIG['M
+ 'cubeb_resampler.cpp',
+ ]
+
++if CONFIG['MOZ_OSS']:
++ SOURCES += [
++ 'cubeb_oss.c',
++ ]
++ DEFINES['USE_OSS'] = True
++
+ if CONFIG['MOZ_PULSEAUDIO']:
+ SOURCES += [
+ 'cubeb_pulse.c',
+@@ -81,6 +87,7 @@ if CONFIG['OS_TARGET'] == 'Android':
+
+ FINAL_LIBRARY = 'gkmedias'
+
++CFLAGS += CONFIG['MOZ_OSS_CFLAGS']
+ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
+ if CONFIG['ANDROID_VERSION'] >= '17':
+ LOCAL_INCLUDES += [
diff --git a/www/firefox52/patches/patch-media_libcubeb_tests_moz.build b/www/firefox52/patches/patch-media_libcubeb_tests_moz.build
new file mode 100644
index 00000000000..3dffc6e2678
--- /dev/null
+++ b/www/firefox52/patches/patch-media_libcubeb_tests_moz.build
@@ -0,0 +1,12 @@
+$NetBSD: patch-media_libcubeb_tests_moz.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- media/libcubeb/tests/moz.build.orig 2016-10-31 20:15:39.000000000 +0000
++++ media/libcubeb/tests/moz.build
+@@ -73,7 +73,6 @@ elif CONFIG['OS_TARGET'] == 'OpenBSD':
+ 'sndio',
+ ]
+ else:
+- OS_LIBS += CONFIG['MOZ_ALSA_LIBS']
+ OS_LIBS += CONFIG['MOZ_PULSEAUDIO_LIBS']
+
+ if CONFIG['GNU_CXX']:
diff --git a/www/firefox52/patches/patch-media_libcubeb_update.sh b/www/firefox52/patches/patch-media_libcubeb_update.sh
new file mode 100644
index 00000000000..95ee32b44df
--- /dev/null
+++ b/www/firefox52/patches/patch-media_libcubeb_update.sh
@@ -0,0 +1,12 @@
+$NetBSD: patch-media_libcubeb_update.sh,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- media/libcubeb/update.sh.orig 2016-10-31 20:15:39.000000000 +0000
++++ media/libcubeb/update.sh
+@@ -16,6 +16,7 @@ cp $1/src/cubeb_audiounit.cpp src
+ cp $1/src/cubeb_osx_run_loop.h src
+ cp $1/src/cubeb_jack.cpp src
+ cp $1/src/cubeb_opensl.c src
++cp $1/src/cubeb_oss.c src
+ cp $1/src/cubeb_panner.cpp src
+ cp $1/src/cubeb_panner.h src
+ cp $1/src/cubeb_pulse.c src
diff --git a/www/firefox52/patches/patch-media_libsoundtouch_src_cpu__detect__x86.cpp b/www/firefox52/patches/patch-media_libsoundtouch_src_cpu__detect__x86.cpp
new file mode 100644
index 00000000000..3007730090f
--- /dev/null
+++ b/www/firefox52/patches/patch-media_libsoundtouch_src_cpu__detect__x86.cpp
@@ -0,0 +1,15 @@
+$NetBSD: patch-media_libsoundtouch_src_cpu__detect__x86.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- media/libsoundtouch/src/cpu_detect_x86.cpp.orig 2014-04-18 02:03:48.000000000 +0000
++++ media/libsoundtouch/src/cpu_detect_x86.cpp
+@@ -130,7 +130,9 @@ uint detectCPUextensions(void)
+ #endif
+
+ return res & ~_dwDisabledISA;
+-
++#elif defined(__GNUC__)
++ // No cpuid.h --> no cpuid support
++ return 0;
+ #else
+
+ /// One of these is true:
diff --git a/www/firefox52/patches/patch-media_libsoundtouch_src_soundtouch__perms.h b/www/firefox52/patches/patch-media_libsoundtouch_src_soundtouch__perms.h
new file mode 100644
index 00000000000..b4f419682a8
--- /dev/null
+++ b/www/firefox52/patches/patch-media_libsoundtouch_src_soundtouch__perms.h
@@ -0,0 +1,14 @@
+$NetBSD: patch-media_libsoundtouch_src_soundtouch__perms.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- media/libsoundtouch/src/soundtouch_perms.h.orig 2016-05-12 17:13:16.000000000 +0000
++++ media/libsoundtouch/src/soundtouch_perms.h
+@@ -12,7 +12,9 @@
+
+ #pragma GCC visibility push(default)
+ #include "SoundTouch.h"
++#ifndef MOZ_SYSTEM_SOUNDTOUCH
+ #include "SoundTouchFactory.h"
++#endif
+ #pragma GCC visibility pop
+
+ #endif // MOZILLA_SOUNDTOUCH_PERMS_H
diff --git a/www/firefox52/patches/patch-media_libtheora_lib_arm_armcpu.c b/www/firefox52/patches/patch-media_libtheora_lib_arm_armcpu.c
new file mode 100644
index 00000000000..6d4c1f9d413
--- /dev/null
+++ b/www/firefox52/patches/patch-media_libtheora_lib_arm_armcpu.c
@@ -0,0 +1,25 @@
+$NetBSD: patch-media_libtheora_lib_arm_armcpu.c,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* NetBSD/evbearmv7hf-el's /proc/cpuinfo return empty, use hardcoded flags.
+
+--- media/libtheora/lib/arm/armcpu.c.orig 2014-11-13 22:50:10.000000000 +0000
++++ media/libtheora/lib/arm/armcpu.c
+@@ -107,6 +107,18 @@ ogg_uint32_t oc_cpu_flags_get(void){
+ return flags;
+ }
+
++#elif defined(__NetBSD__)
++ogg_uint32_t oc_cpu_flags_get(void){
++ ogg_uint32_t flags;
++ /* XXX ryoon: I have no idea about ARM CPU extensions detection mechanism
++ under NetBSD/earm.
++ evbearmv6hf-el machine, Raspberry Pi does not have NEON.
++ evbearmv7hf-el machine, CubieBoard2 does not have EDSP.
++ I have no idea about MEDIA.
++ So I will disable all options. */
++ flags=0;
++ return flags;
++}
+ #else
+ /*The feature registers which can tell us what the processor supports are
+ accessible in priveleged modes only, so we can't have a general user-space
diff --git a/www/firefox52/patches/patch-media_libtheora_moz.build b/www/firefox52/patches/patch-media_libtheora_moz.build
new file mode 100644
index 00000000000..f8b98694551
--- /dev/null
+++ b/www/firefox52/patches/patch-media_libtheora_moz.build
@@ -0,0 +1,16 @@
+$NetBSD: patch-media_libtheora_moz.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support system library
+
+--- media/libtheora/moz.build.orig 2016-07-25 20:22:04.000000000 +0000
++++ media/libtheora/moz.build
+@@ -21,6 +21,9 @@ FINAL_LIBRARY = 'gkmedias'
+ # The encoder is currently not included.
+ DEFINES['THEORA_DISABLE_ENCODE'] = True
+
++if CONFIG['MOZ_SYSTEM_OGG']:
++ CFLAGS += CONFIG['MOZ_OGG_CFLAGS']
++
+ # Suppress warnings in third-party code.
+ if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']:
+ CFLAGS += ['-Wno-type-limits']
diff --git a/www/firefox52/patches/patch-media_libtremor_moz.build b/www/firefox52/patches/patch-media_libtremor_moz.build
new file mode 100644
index 00000000000..3230fb2e8ba
--- /dev/null
+++ b/www/firefox52/patches/patch-media_libtremor_moz.build
@@ -0,0 +1,12 @@
+$NetBSD: patch-media_libtremor_moz.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support system library
+
+--- media/libtremor/moz.build.orig 2016-05-12 17:13:17.000000000 +0000
++++ media/libtremor/moz.build
+@@ -9,3 +9,5 @@ with Files('*'):
+
+ DIRS += ['include/tremor', 'lib']
+
++if CONFIG['MOZ_SYSTEM_OGG']:
++ CFLAGS += CONFIG['MOZ_OGG_CFLAGS']
diff --git a/www/firefox52/patches/patch-media_libvorbis_moz.build b/www/firefox52/patches/patch-media_libvorbis_moz.build
new file mode 100644
index 00000000000..a96127237de
--- /dev/null
+++ b/www/firefox52/patches/patch-media_libvorbis_moz.build
@@ -0,0 +1,13 @@
+$NetBSD: patch-media_libvorbis_moz.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support system library
+
+--- media/libvorbis/moz.build.orig 2016-05-12 17:13:17.000000000 +0000
++++ media/libvorbis/moz.build
+@@ -56,3 +56,6 @@ FINAL_LIBRARY = 'gkmedias'
+ # Suppress warnings in third-party code.
+ if CONFIG['GNU_CC']:
+ CFLAGS += ['-Wno-uninitialized']
++
++if CONFIG['MOZ_SYSTEM_OGG']:
++ CFLAGS += CONFIG['MOZ_OGG_CFLAGS']
diff --git a/www/firefox52/patches/patch-media_libyuv_source_mjpeg__decoder.cc b/www/firefox52/patches/patch-media_libyuv_source_mjpeg__decoder.cc
new file mode 100644
index 00000000000..cc543e20a33
--- /dev/null
+++ b/www/firefox52/patches/patch-media_libyuv_source_mjpeg__decoder.cc
@@ -0,0 +1,12 @@
+$NetBSD: patch-media_libyuv_source_mjpeg__decoder.cc,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- media/libyuv/source/mjpeg_decoder.cc.orig 2016-10-31 20:15:24.000000000 +0000
++++ media/libyuv/source/mjpeg_decoder.cc
+@@ -25,7 +25,6 @@
+ #endif
+
+ #endif
+-struct FILE; // For jpeglib.h.
+
+ // C++ build requires extern C for jpeg internals.
+ #ifdef __cplusplus
diff --git a/www/firefox52/patches/patch-media_openmax__dl_dl_api_armCOMM__s.h b/www/firefox52/patches/patch-media_openmax__dl_dl_api_armCOMM__s.h
new file mode 100644
index 00000000000..61b852e20db
--- /dev/null
+++ b/www/firefox52/patches/patch-media_openmax__dl_dl_api_armCOMM__s.h
@@ -0,0 +1,39 @@
+$NetBSD: patch-media_openmax__dl_dl_api_armCOMM__s.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support NetBSD/earm
+
+--- media/openmax_dl/dl/api/armCOMM_s.h.orig 2015-09-29 21:44:56.000000000 +0000
++++ media/openmax_dl/dl/api/armCOMM_s.h
+@@ -11,6 +11,12 @@
+ @// This file was originally licensed as follows. It has been
+ @// relicensed with permission from the copyright holders.
+ @//
++
++#if defined(__ARM_EABI__) && !defined(__ARM_DWARF_EH__)
++#define UNWIND
++#else
++#define UNWIND @
++#endif
+
+ @//
+ @// File Name: armCOMM_s.h
+@@ -175,7 +181,8 @@
+ .object_arch armv4
+ .align 2
+ \name :
+-.fnstart
++ .cfi_startproc
++ UNWIND .fnstart
+ @ Save specified R registers
+ _M_GETRREGLIST \rreg
+ _M_PUSH_RREG
+@@ -202,7 +209,8 @@
+ .endif
+ @ Restore any saved R or D registers.
+ _M_RET
+- .fnend
++ UNWIND .fnend
++ .cfi_endproc
+ .endfunc
+ @ Reset the global stack tracking variables back to their
+ @ initial values.
diff --git a/www/firefox52/patches/patch-media_webrtc_signaling_test_common.build b/www/firefox52/patches/patch-media_webrtc_signaling_test_common.build
new file mode 100644
index 00000000000..b77351aa2f9
--- /dev/null
+++ b/www/firefox52/patches/patch-media_webrtc_signaling_test_common.build
@@ -0,0 +1,19 @@
+$NetBSD: patch-media_webrtc_signaling_test_common.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- media/webrtc/signaling/test/common.build.orig 2016-09-19 16:19:28.000000000 +0000
++++ media/webrtc/signaling/test/common.build
+@@ -96,11 +96,12 @@ if CONFIG['JS_SHARED_LIBRARY']:
+
+ USE_LIBS += ['mozglue']
+
++OS_LIBS += CONFIG['MOZ_LIBV4L2_LIBS']
+ OS_LIBS += CONFIG['MOZ_WEBRTC_X11_LIBS']
+ OS_LIBS += CONFIG['REALTIME_LIBS']
+
+-if CONFIG['MOZ_ALSA']:
+- OS_LIBS += CONFIG['MOZ_ALSA_LIBS']
++if CONFIG['MOZ_OSS']:
++ OS_LIBS += CONFIG['MOZ_OSS_LIBS']
+
+ if CONFIG['MOZ_SYSTEM_JPEG']:
+ OS_LIBS += CONFIG['MOZ_JPEG_LIBS']
diff --git a/www/firefox52/patches/patch-media_webrtc_trunk_webrtc_modules_video__capture_linux_device__info__linux.cc b/www/firefox52/patches/patch-media_webrtc_trunk_webrtc_modules_video__capture_linux_device__info__linux.cc
new file mode 100644
index 00000000000..5aad4f564ed
--- /dev/null
+++ b/www/firefox52/patches/patch-media_webrtc_trunk_webrtc_modules_video__capture_linux_device__info__linux.cc
@@ -0,0 +1,42 @@
+$NetBSD: patch-media_webrtc_trunk_webrtc_modules_video__capture_linux_device__info__linux.cc,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- media/webrtc/trunk/webrtc/modules/video_capture/linux/device_info_linux.cc.orig 2017-01-23 16:13:55.000000000 +0000
++++ media/webrtc/trunk/webrtc/modules/video_capture/linux/device_info_linux.cc
+@@ -25,6 +25,9 @@
+ #else
+ #include <linux/videodev2.h>
+ #endif
++#ifdef HAVE_LIBV4L2
++#include <libv4l2.h>
++#endif
+
+ #include "webrtc/system_wrappers/interface/ref_count.h"
+ #include "webrtc/system_wrappers/interface/trace.h"
+@@ -34,6 +37,15 @@
+ #define BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) )
+ #endif
+
++#ifdef HAVE_LIBV4L2
++#define open v4l2_open
++#define close v4l2_close
++#define dup v4l2_dup
++#define ioctl v4l2_ioctl
++#define mmap v4l2_mmap
++#define munmap v4l2_munmap
++#endif
++
+ namespace webrtc
+ {
+ namespace videocapturemodule
+@@ -274,6 +286,11 @@ int32_t DeviceInfoLinux::GetDeviceName(
+ memset(deviceNameUTF8, 0, deviceNameLength);
+ memcpy(cameraName, cap.card, sizeof(cap.card));
+
++ if (cameraName[0] == '\0')
++ {
++ sprintf(cameraName, "Camera at /dev/video%d", deviceNumber);
++ }
++
+ if (deviceNameLength >= strlen(cameraName))
+ {
+ memcpy(deviceNameUTF8, cameraName, strlen(cameraName));
diff --git a/www/firefox52/patches/patch-media_webrtc_trunk_webrtc_modules_video__capture_linux_video__capture__linux.cc b/www/firefox52/patches/patch-media_webrtc_trunk_webrtc_modules_video__capture_linux_video__capture__linux.cc
new file mode 100644
index 00000000000..2806882f08b
--- /dev/null
+++ b/www/firefox52/patches/patch-media_webrtc_trunk_webrtc_modules_video__capture_linux_video__capture__linux.cc
@@ -0,0 +1,30 @@
+$NetBSD: patch-media_webrtc_trunk_webrtc_modules_video__capture_linux_video__capture__linux.cc,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- media/webrtc/trunk/webrtc/modules/video_capture/linux/video_capture_linux.cc.orig 2016-05-12 17:13:21.000000000 +0000
++++ media/webrtc/trunk/webrtc/modules/video_capture/linux/video_capture_linux.cc
+@@ -25,6 +25,9 @@
+ #else
+ #include <linux/videodev2.h>
+ #endif
++#ifdef HAVE_LIBV4L2
++#include <libv4l2.h>
++#endif
+
+ #include <new>
+
+@@ -33,6 +36,15 @@
+ #include "webrtc/system_wrappers/interface/ref_count.h"
+ #include "webrtc/system_wrappers/interface/trace.h"
+
++#ifdef HAVE_LIBV4L2
++#define open v4l2_open
++#define close v4l2_close
++#define dup v4l2_dup
++#define ioctl v4l2_ioctl
++#define mmap v4l2_mmap
++#define munmap v4l2_munmap
++#endif
++
+ namespace webrtc
+ {
+ namespace videocapturemodule
diff --git a/www/firefox52/patches/patch-media_webrtc_trunk_webrtc_modules_video__capture_video__capture.gypi b/www/firefox52/patches/patch-media_webrtc_trunk_webrtc_modules_video__capture_video__capture.gypi
new file mode 100644
index 00000000000..999fe2d02a0
--- /dev/null
+++ b/www/firefox52/patches/patch-media_webrtc_trunk_webrtc_modules_video__capture_video__capture.gypi
@@ -0,0 +1,34 @@
+$NetBSD: patch-media_webrtc_trunk_webrtc_modules_video__capture_video__capture.gypi,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- media/webrtc/trunk/webrtc/modules/video_capture/video_capture.gypi.orig 2016-09-05 20:12:57.000000000 +0000
++++ media/webrtc/trunk/webrtc/modules/video_capture/video_capture.gypi
+@@ -7,6 +7,9 @@
+ # be found in the AUTHORS file in the root of the source tree.
+
+ {
++ 'variables': {
++ 'use_libv4l2%': 0,
++ },
+ 'targets': [
+ {
+ # Note this library is missing an implementation for the video capture.
+@@ -75,6 +78,19 @@
+ 'linux/video_capture_linux.cc',
+ 'linux/video_capture_linux.h',
+ ],
++ 'conditions': [
++ ['use_libv4l2==1', {
++ 'defines': [
++ 'HAVE_LIBV4L2',
++ ],
++ 'cflags_mozilla': [
++ '$(MOZ_LIBV4L2_CFLAGS)',
++ ],
++ 'libraries': [
++ '-lv4l2',
++ ],
++ }],
++ ],
+ }], # linux
+ ['OS=="mac"', {
+ 'sources': [
diff --git a/www/firefox52/patches/patch-memory_mozalloc_mozalloc__abort.cpp b/www/firefox52/patches/patch-memory_mozalloc_mozalloc__abort.cpp
new file mode 100644
index 00000000000..0aa9f1df778
--- /dev/null
+++ b/www/firefox52/patches/patch-memory_mozalloc_mozalloc__abort.cpp
@@ -0,0 +1,18 @@
+$NetBSD: patch-memory_mozalloc_mozalloc__abort.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support Solaris
+
+--- memory/mozalloc/mozalloc_abort.cpp.orig 2015-08-24 21:53:14.000000000 +0000
++++ memory/mozalloc/mozalloc_abort.cpp
+@@ -68,7 +68,11 @@ void fillAbortMessage(char (&msg)[N], ui
+ //
+ // That segmentation fault will be interpreted as another bug by ASan and as a
+ // result, ASan will just exit(1) instead of aborting.
++#if defined(SOLARIS)
++void std::abort(void)
++#else
+ void abort(void)
++#endif
+ {
+ #ifdef MOZ_WIDGET_ANDROID
+ char msg[64] = {};
diff --git a/www/firefox52/patches/patch-mfbt_Poison.cpp b/www/firefox52/patches/patch-mfbt_Poison.cpp
new file mode 100644
index 00000000000..e4db114bc6a
--- /dev/null
+++ b/www/firefox52/patches/patch-mfbt_Poison.cpp
@@ -0,0 +1,20 @@
+$NetBSD: patch-mfbt_Poison.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Use posix_madvise(3) instead of madvise(3) for Solaris/SunOS.
+ Solaris/SunOS's madvise(3) is not enabled in this context,
+ and its first argument type is different from NetBSD/Linux's one.
+
+--- mfbt/Poison.cpp.orig 2014-11-13 22:50:12.000000000 +0000
++++ mfbt/Poison.cpp
+@@ -129,7 +129,11 @@ ReleaseRegion(void* aRegion, uintptr_t a
+ static bool
+ ProbeRegion(uintptr_t aRegion, uintptr_t aSize)
+ {
++#if !defined(__sun__)
+ if (madvise(reinterpret_cast<void*>(aRegion), aSize, MADV_NORMAL)) {
++#else
++ if (posix_madvise(reinterpret_cast<void*>(aRegion), aSize, MADV_NORMAL)) {
++#endif
+ return true;
+ } else {
+ return false;
diff --git a/www/firefox52/patches/patch-mobile_android_installer_Makefile.in b/www/firefox52/patches/patch-mobile_android_installer_Makefile.in
new file mode 100644
index 00000000000..765cb7b56e2
--- /dev/null
+++ b/www/firefox52/patches/patch-mobile_android_installer_Makefile.in
@@ -0,0 +1,15 @@
+$NetBSD: patch-mobile_android_installer_Makefile.in,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- mobile/android/installer/Makefile.in.orig 2016-07-25 20:22:05.000000000 +0000
++++ mobile/android/installer/Makefile.in
+@@ -69,6 +69,10 @@ BINPATH = bin
+ endif
+ DEFINES += -DBINPATH=$(BINPATH)
+
++ifdef MOZ_DEBUG
++DEFINES += -DMOZ_DEBUG=1
++endif
++
+ ifdef ENABLE_MARIONETTE
+ DEFINES += -DENABLE_MARIONETTE=1
+ endif
diff --git a/www/firefox52/patches/patch-modules_libjar_nsZipArchive.cpp b/www/firefox52/patches/patch-modules_libjar_nsZipArchive.cpp
new file mode 100644
index 00000000000..989f21c8757
--- /dev/null
+++ b/www/firefox52/patches/patch-modules_libjar_nsZipArchive.cpp
@@ -0,0 +1,17 @@
+$NetBSD: patch-modules_libjar_nsZipArchive.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support Solaris
+
+--- modules/libjar/nsZipArchive.cpp.orig 2013-06-18 11:01:37.000000000 +0000
++++ modules/libjar/nsZipArchive.cpp
+@@ -590,7 +590,9 @@ MOZ_WIN_MEM_TRY_BEGIN
+ // Success means optimized jar layout from bug 559961 is in effect
+ uint32_t readaheadLength = xtolong(startp);
+ if (readaheadLength) {
+-#if defined(XP_UNIX)
++#if defined(OS_SOLARIS)
++ posix_madvise(const_cast<uint8_t*>(startp), readaheadLength, POSIX_MADV_WILLNEED);
++#elif defined(XP_UNIX)
+ madvise(const_cast<uint8_t*>(startp), readaheadLength, MADV_WILLNEED);
+ #elif defined(XP_WIN)
+ if (aFd) {
diff --git a/www/firefox52/patches/patch-mozglue_build_arm.cpp b/www/firefox52/patches/patch-mozglue_build_arm.cpp
new file mode 100644
index 00000000000..1649bda13fa
--- /dev/null
+++ b/www/firefox52/patches/patch-mozglue_build_arm.cpp
@@ -0,0 +1,59 @@
+$NetBSD: patch-mozglue_build_arm.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support NetBSD/earm
+
+--- mozglue/build/arm.cpp.orig 2016-08-01 16:14:43.000000000 +0000
++++ mozglue/build/arm.cpp
+@@ -13,10 +13,13 @@
+ // we don't compile one of these detection methods. The detection code here is
+ // based on the CPU detection in libtheora.
+
+-# if defined(__linux__) || defined(ANDROID)
++# if defined(__linux__) || defined(ANDROID) || defined(__NetBSD__)
+ # include <stdio.h>
+ # include <stdlib.h>
+ # include <string.h>
++# if defined(__NetBSD__)
++# include <sys/sysctl.h>
++# endif
+
+ enum{
+ MOZILLA_HAS_EDSP_FLAG=1,
+@@ -25,6 +28,29 @@ enum{
+ MOZILLA_HAS_NEON_FLAG=8
+ };
+
++# if defined(__NetBSD__)
++static unsigned
++get_arm_cpu_flags(void)
++{
++ unsigned flags = 0;
++ size_t len;
++ int flag;
++
++ len = sizeof(flag);
++ if (sysctlbyname("machdep.simdex_present", &flag, &len, NULL, 0) == 0 && flag) {
++ flags |= MOZILLA_HAS_ARMV6_FLAG;
++ flags |= MOZILLA_HAS_EDSP_FLAG;
++ }
++
++ len = sizeof(flag);
++ if (sysctlbyname("machdep.neon_present", &flag, &len, NULL, 0) == 0 && flag) {
++ flags |= MOZILLA_HAS_ARMV7_FLAG;
++ flags |= MOZILLA_HAS_NEON_FLAG;
++ }
++
++ return flags;
++}
++# else
+ static unsigned
+ get_arm_cpu_flags(void)
+ {
+@@ -89,6 +115,7 @@ get_arm_cpu_flags(void)
+ }
+ return flags;
+ }
++# endif
+
+ // Cache a local copy so we only have to read /proc/cpuinfo once.
+ static unsigned arm_cpu_flags = get_arm_cpu_flags();
diff --git a/www/firefox52/patches/patch-mozglue_build_arm.h b/www/firefox52/patches/patch-mozglue_build_arm.h
new file mode 100644
index 00000000000..f5424ae53f0
--- /dev/null
+++ b/www/firefox52/patches/patch-mozglue_build_arm.h
@@ -0,0 +1,15 @@
+$NetBSD: patch-mozglue_build_arm.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support NetBSD/earm
+
+--- mozglue/build/arm.h.orig 2015-09-29 21:45:02.000000000 +0000
++++ mozglue/build/arm.h
+@@ -76,7 +76,7 @@
+ # endif
+
+ // Currently we only have CPU detection for Linux via /proc/cpuinfo
+-# if defined(__linux__) || defined(ANDROID)
++# if defined(__linux__) || defined(ANDROID) || defined(__NetBSD__)
+ # define MOZILLA_ARM_HAVE_CPUID_DETECTION 1
+ # endif
+
diff --git a/www/firefox52/patches/patch-netwerk_dns_moz.build b/www/firefox52/patches/patch-netwerk_dns_moz.build
new file mode 100644
index 00000000000..563f6de147e
--- /dev/null
+++ b/www/firefox52/patches/patch-netwerk_dns_moz.build
@@ -0,0 +1,14 @@
+$NetBSD: patch-netwerk_dns_moz.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- netwerk/dns/moz.build.orig 2016-10-31 20:15:27.000000000 +0000
++++ netwerk/dns/moz.build
+@@ -66,6 +66,9 @@ LOCAL_INCLUDES += [
+ '/netwerk/base',
+ ]
+
++if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
++ CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
++
+ if CONFIG['ENABLE_INTL_API']:
+ DEFINES['IDNA2008'] = True
+ USE_LIBS += ['icu']
diff --git a/www/firefox52/patches/patch-rc b/www/firefox52/patches/patch-rc
new file mode 100644
index 00000000000..b7d77db8f6e
--- /dev/null
+++ b/www/firefox52/patches/patch-rc
@@ -0,0 +1,18 @@
+$NetBSD: patch-rc,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Fix application name
+
+--- browser/branding/unofficial/locales/en-US/brand.dtd.orig 2015-08-24 21:53:06.000000000 +0000
++++ browser/branding/unofficial/locales/en-US/brand.dtd
+@@ -2,8 +2,8 @@
+ - 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/. -->
+
+-<!ENTITY brandShorterName "Nightly">
+-<!ENTITY brandShortName "Nightly">
+-<!ENTITY brandFullName "Nightly">
++<!ENTITY brandShorterName "Browser">
++<!ENTITY brandShortName "Browser">
++<!ENTITY brandFullName "Browser">
+ <!ENTITY vendorShortName "Mozilla">
+ <!ENTITY trademarkInfo.part1 " ">
diff --git a/www/firefox52/patches/patch-toolkit_components_osfile_modules_osfile__unix__back.jsm b/www/firefox52/patches/patch-toolkit_components_osfile_modules_osfile__unix__back.jsm
new file mode 100644
index 00000000000..90d418b71c5
--- /dev/null
+++ b/www/firefox52/patches/patch-toolkit_components_osfile_modules_osfile__unix__back.jsm
@@ -0,0 +1,15 @@
+$NetBSD: patch-toolkit_components_osfile_modules_osfile__unix__back.jsm,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- toolkit/components/osfile/modules/osfile_unix_back.jsm.orig 2016-07-25 20:22:06.000000000 +0000
++++ toolkit/components/osfile/modules/osfile_unix_back.jsm
+@@ -228,8 +228,8 @@
+ let statvfs = new SharedAll.HollowStructure("statvfs",
+ Const.OSFILE_SIZEOF_STATVFS);
+
+- statvfs.add_field_at(Const.OSFILE_OFFSETOF_STATVFS_F_BSIZE,
+- "f_bsize", Type.unsigned_long.implementation);
++ statvfs.add_field_at(Const.OSFILE_OFFSETOF_STATVFS_F_FRSIZE,
++ "f_frsize", Type.unsigned_long.implementation);
+ statvfs.add_field_at(Const.OSFILE_OFFSETOF_STATVFS_F_BAVAIL,
+ "f_bavail", Type.fsblkcnt_t.implementation);
+
diff --git a/www/firefox52/patches/patch-toolkit_components_osfile_modules_osfile__unix__front.jsm b/www/firefox52/patches/patch-toolkit_components_osfile_modules_osfile__unix__front.jsm
new file mode 100644
index 00000000000..cc49925fe9d
--- /dev/null
+++ b/www/firefox52/patches/patch-toolkit_components_osfile_modules_osfile__unix__front.jsm
@@ -0,0 +1,13 @@
+$NetBSD: patch-toolkit_components_osfile_modules_osfile__unix__front.jsm,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- toolkit/components/osfile/modules/osfile_unix_front.jsm.orig 2016-05-12 17:13:27.000000000 +0000
++++ toolkit/components/osfile/modules/osfile_unix_front.jsm
+@@ -399,7 +399,7 @@
+ throw_on_negative("statvfs", (UnixFile.statvfs || UnixFile.statfs)(sourcePath, fileSystemInfoPtr));
+
+ let bytes = new Type.uint64_t.implementation(
+- fileSystemInfo.f_bsize * fileSystemInfo.f_bavail);
++ fileSystemInfo.f_frsize * fileSystemInfo.f_bavail);
+
+ return bytes.value;
+ };
diff --git a/www/firefox52/patches/patch-toolkit_components_protobuf_src_google_protobuf_stubs_atomicops.h b/www/firefox52/patches/patch-toolkit_components_protobuf_src_google_protobuf_stubs_atomicops.h
new file mode 100644
index 00000000000..c124ca7780b
--- /dev/null
+++ b/www/firefox52/patches/patch-toolkit_components_protobuf_src_google_protobuf_stubs_atomicops.h
@@ -0,0 +1,24 @@
+$NetBSD: patch-toolkit_components_protobuf_src_google_protobuf_stubs_atomicops.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- toolkit/components/protobuf/src/google/protobuf/stubs/atomicops.h.orig 2016-07-25 20:22:06.000000000 +0000
++++ toolkit/components/protobuf/src/google/protobuf/stubs/atomicops.h
+@@ -76,6 +76,11 @@ typedef intptr_t Atomic64;
+ #endif
+ #endif
+
++#if defined(__NetBSD__) && defined(__arm__)
++// NetBSD/arm uses long for intptr_t, which fails -fpermissive checks. So
++// explicitly use int32 here instead.
++typedef int32 AtomicWord;
++#else
+ // Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or
+ // Atomic64 routines below, depending on your architecture.
+ #if defined(__OpenBSD__) && !defined(GOOGLE_PROTOBUF_ARCH_64_BIT)
+@@ -83,6 +88,7 @@ typedef Atomic32 AtomicWord;
+ #else
+ typedef intptr_t AtomicWord;
+ #endif
++#endif
+
+ // Atomically execute:
+ // result = *ptr;
diff --git a/www/firefox52/patches/patch-toolkit_components_protobuf_src_google_protobuf_stubs_platform__macros.h b/www/firefox52/patches/patch-toolkit_components_protobuf_src_google_protobuf_stubs_platform__macros.h
new file mode 100644
index 00000000000..7a91af25f2a
--- /dev/null
+++ b/www/firefox52/patches/patch-toolkit_components_protobuf_src_google_protobuf_stubs_platform__macros.h
@@ -0,0 +1,15 @@
+$NetBSD: patch-toolkit_components_protobuf_src_google_protobuf_stubs_platform__macros.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support Solaris
+
+--- toolkit/components/protobuf/src/google/protobuf/stubs/platform_macros.h.orig 2015-09-11 00:23:02.000000000 +0000
++++ toolkit/components/protobuf/src/google/protobuf/stubs/platform_macros.h
+@@ -67,7 +67,7 @@
+ #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
+ #elif defined(sparc)
+ #define GOOGLE_PROTOBUF_ARCH_SPARC 1
+-#ifdef SOLARIS_64BIT_ENABLED
++#if (defined(sun) && defined(SOLARIS_64BIT_ENABLED)) || __LP64__
+ #define GOOGLE_PROTOBUF_ARCH_64_BIT 1
+ #else
+ #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
diff --git a/www/firefox52/patches/patch-toolkit_components_terminator_nsTerminator.cpp b/www/firefox52/patches/patch-toolkit_components_terminator_nsTerminator.cpp
new file mode 100644
index 00000000000..c47e803826e
--- /dev/null
+++ b/www/firefox52/patches/patch-toolkit_components_terminator_nsTerminator.cpp
@@ -0,0 +1,27 @@
+$NetBSD: patch-toolkit_components_terminator_nsTerminator.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Fix segfault on exit under NetBSD
+
+--- toolkit/components/terminator/nsTerminator.cpp.orig 2016-06-15 21:54:53.514370128 +0000
++++ toolkit/components/terminator/nsTerminator.cpp
+@@ -36,7 +36,7 @@
+ #if defined(XP_WIN)
+ #include <windows.h>
+ #else
+-#include <unistd.h>
++#include <time.h>
+ #endif
+
+ #include "mozilla/ArrayUtils.h"
+@@ -147,7 +147,10 @@ RunWatchdog(void* arg)
+ #if defined(XP_WIN)
+ Sleep(1000 /* ms */);
+ #else
+- usleep(1000000 /* usec */);
++ struct timespec tickd;
++ tickd.tv_sec = 1;
++ tickd.tv_nsec = 0;
++ nanosleep(&tickd, NULL);
+ #endif
+
+ if (gHeartbeat++ < timeToLive) {
diff --git a/www/firefox52/patches/patch-toolkit_library_moz.build b/www/firefox52/patches/patch-toolkit_library_moz.build
new file mode 100644
index 00000000000..c3bcc7c355a
--- /dev/null
+++ b/www/firefox52/patches/patch-toolkit_library_moz.build
@@ -0,0 +1,57 @@
+$NetBSD: patch-toolkit_library_moz.build,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support system libraries
+* Restore OSS support
+
+--- toolkit/library/moz.build.orig 2017-02-11 00:39:16.000000000 +0000
++++ toolkit/library/moz.build
+@@ -215,6 +215,7 @@ if CONFIG['OS_ARCH'] == 'Linux' and CONF
+ ]
+
+ OS_LIBS += CONFIG['MOZ_CAIRO_OSLIBS']
++OS_LIBS += CONFIG['MOZ_LIBV4L2_LIBS']
+ OS_LIBS += CONFIG['MOZ_WEBRTC_X11_LIBS']
+
+ if CONFIG['SERVO_TARGET_DIR']:
+@@ -229,9 +230,30 @@ if CONFIG['MOZ_SYSTEM_JPEG']:
+ if CONFIG['MOZ_SYSTEM_PNG']:
+ OS_LIBS += CONFIG['MOZ_PNG_LIBS']
+
++if CONFIG['MOZ_SYSTEM_GRAPHITE2']:
++ OS_LIBS += CONFIG['MOZ_GRAPHITE2_LIBS']
++
++if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
++ OS_LIBS += CONFIG['MOZ_HARFBUZZ_LIBS']
++
+ if CONFIG['MOZ_SYSTEM_HUNSPELL']:
+ OS_LIBS += CONFIG['MOZ_HUNSPELL_LIBS']
+
++if CONFIG['MOZ_SYSTEM_OGG']:
++ OS_LIBS += CONFIG['MOZ_OGG_LIBS']
++
++if CONFIG['MOZ_SYSTEM_THEORA']:
++ OS_LIBS += CONFIG['MOZ_THEORA_LIBS']
++
++if CONFIG['MOZ_SYSTEM_VORBIS']:
++ OS_LIBS += CONFIG['MOZ_VORBIS_LIBS']
++
++if CONFIG['MOZ_SYSTEM_TREMOR']:
++ OS_LIBS += CONFIG['MOZ_TREMOR_LIBS']
++
++if CONFIG['MOZ_SYSTEM_SOUNDTOUCH']:
++ OS_LIBS += CONFIG['MOZ_SOUNDTOUCH_LIBS']
++
+ if CONFIG['MOZ_SYSTEM_LIBEVENT']:
+ OS_LIBS += CONFIG['MOZ_LIBEVENT_LIBS']
+
+@@ -241,8 +263,8 @@ if CONFIG['MOZ_SYSTEM_LIBVPX']:
+ if not CONFIG['MOZ_TREE_PIXMAN']:
+ OS_LIBS += CONFIG['MOZ_PIXMAN_LIBS']
+
+-if CONFIG['MOZ_ALSA']:
+- OS_LIBS += CONFIG['MOZ_ALSA_LIBS']
++if CONFIG['MOZ_OSS']:
++ OS_LIBS += CONFIG['MOZ_OSS_LIBS']
+
+ if CONFIG['HAVE_CLOCK_MONOTONIC']:
+ OS_LIBS += CONFIG['REALTIME_LIBS']
diff --git a/www/firefox52/patches/patch-toolkit_modules_GMPUtils.jsm b/www/firefox52/patches/patch-toolkit_modules_GMPUtils.jsm
new file mode 100644
index 00000000000..873a8a01eee
--- /dev/null
+++ b/www/firefox52/patches/patch-toolkit_modules_GMPUtils.jsm
@@ -0,0 +1,14 @@
+$NetBSD: patch-toolkit_modules_GMPUtils.jsm,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Enable Google widevine CDM for NetBSD
+
+--- toolkit/modules/GMPUtils.jsm.orig 2016-08-10 20:27:55.000000000 +0000
++++ toolkit/modules/GMPUtils.jsm
+@@ -92,6 +92,7 @@ this.GMPUtils = {
+ // Mac OSX, and Linux.
+ return AppConstants.isPlatformAndVersionAtLeast("win", "6") ||
+ AppConstants.platform == "macosx" ||
++ AppConstants.platform == "netbsd" ||
+ AppConstants.platform == "linux";
+ }
+
diff --git a/www/firefox52/patches/patch-toolkit_moz.configure b/www/firefox52/patches/patch-toolkit_moz.configure
new file mode 100644
index 00000000000..21c75d52954
--- /dev/null
+++ b/www/firefox52/patches/patch-toolkit_moz.configure
@@ -0,0 +1,33 @@
+$NetBSD: patch-toolkit_moz.configure,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Enable widevide CDM for NetBSD
+
+--- toolkit/moz.configure.orig 2017-01-23 16:13:54.000000000 +0000
++++ toolkit/moz.configure
+@@ -338,6 +338,26 @@ add_old_configure_assignment('FT2_LIBS',
+ add_old_configure_assignment('FT2_CFLAGS',
+ delayed_getattr(ft2_info, 'cflags'))
+
++# Graphite2
++# ==============================================================
++option('--with-system-graphite2',
++ help="Use system graphite2 (located with pkgconfig)")
++
++system_graphite2 = pkg_check_modules('MOZ_GRAPHITE2', 'graphite2',
++ when='--with-system-graphite2')
++
++set_config('MOZ_SYSTEM_GRAPHITE2', depends_if(system_graphite2)(lambda _: True))
++
++# HarfBuzz
++# ==============================================================
++option('--with-system-harfbuzz',
++ help="Use system harfbuzz (located with pkgconfig)")
++
++system_harfbuzz = pkg_check_modules('MOZ_HARFBUZZ', 'harfbuzz >= 1.4.1',
++ when='--with-system-harfbuzz')
++
++set_config('MOZ_SYSTEM_HARFBUZZ', depends_if(system_harfbuzz)(lambda _: True))
++
+ # Apple platform decoder support
+ # ==============================================================
+ @depends(toolkit)
diff --git a/www/firefox52/patches/patch-toolkit_mozapps_extensions_test_browser_browser__gmpProvider.js b/www/firefox52/patches/patch-toolkit_mozapps_extensions_test_browser_browser__gmpProvider.js
new file mode 100644
index 00000000000..124e9ea3145
--- /dev/null
+++ b/www/firefox52/patches/patch-toolkit_mozapps_extensions_test_browser_browser__gmpProvider.js
@@ -0,0 +1,14 @@
+$NetBSD: patch-toolkit_mozapps_extensions_test_browser_browser__gmpProvider.js,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Enable Google widevine CDM for NetBSD
+
+--- toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js.orig 2016-08-10 04:19:24.000000000 +0000
++++ toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js
+@@ -390,6 +390,7 @@ add_task(function* testEmeSupport() {
+ } else if (addon.id == GMPScope.WIDEVINE_ID) {
+ if (AppConstants.isPlatformAndVersionAtLeast("win", "6") ||
+ AppConstants.platform == "macosx" ||
++ AppConstants.platform == "netbsd" ||
+ AppConstants.platform == "linux") {
+ Assert.ok(item, "Widevine supported, found add-on element.");
+ } else {
diff --git a/www/firefox52/patches/patch-toolkit_xre_glxtest.cpp b/www/firefox52/patches/patch-toolkit_xre_glxtest.cpp
new file mode 100644
index 00000000000..808008d7a19
--- /dev/null
+++ b/www/firefox52/patches/patch-toolkit_xre_glxtest.cpp
@@ -0,0 +1,16 @@
+$NetBSD: patch-toolkit_xre_glxtest.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+Fix libGL filename on NetBSD,
+see https://bugzilla.mozilla.org/show_bug.cgi?id=1180498
+
+--- toolkit/xre/glxtest.cpp.orig 2015-07-04 20:26:15.000000000 +0200
++++ toolkit/xre/glxtest.cpp 2015-07-04 20:26:15.000000000 +0200
+@@ -124,7 +124,7 @@ void glxtest()
+ fatal_error("The MOZ_AVOID_OPENGL_ALTOGETHER environment variable is defined");
+
+ ///// Open libGL and load needed symbols /////
+-#ifdef __OpenBSD__
++#if defined(__OpenBSD__) || defined(__NetBSD__)
+ #define LIBGL_FILENAME "libGL.so"
+ #else
+ #define LIBGL_FILENAME "libGL.so.1"
diff --git a/www/firefox52/patches/patch-toolkit_xre_nsEmbedFunctions.cpp b/www/firefox52/patches/patch-toolkit_xre_nsEmbedFunctions.cpp
new file mode 100644
index 00000000000..e53a0a885cd
--- /dev/null
+++ b/www/firefox52/patches/patch-toolkit_xre_nsEmbedFunctions.cpp
@@ -0,0 +1,24 @@
+$NetBSD: patch-toolkit_xre_nsEmbedFunctions.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support Solaris
+
+--- toolkit/xre/nsEmbedFunctions.cpp.orig 2013-05-11 19:19:55.000000000 +0000
++++ toolkit/xre/nsEmbedFunctions.cpp
+@@ -239,7 +239,7 @@ XRE_SetRemoteExceptionHandler(const char
+ {
+ #if defined(XP_WIN) || defined(XP_MACOSX)
+ return CrashReporter::SetRemoteExceptionHandler(nsDependentCString(aPipe));
+-#elif defined(OS_LINUX)
++#elif defined(OS_LINUX) || defined(OS_SOLARIS)
+ return CrashReporter::SetRemoteExceptionHandler();
+ #else
+ # error "OOP crash reporter unsupported on this platform"
+@@ -351,7 +351,7 @@ XRE_InitChildProcess(int aArgc,
+ // Bug 684322 will add better visibility into this condition
+ NS_WARNING("Could not setup crash reporting\n");
+ }
+-# elif defined(OS_LINUX)
++# elif defined(OS_LINUX) || defined(OS_SOLARIS)
+ // on POSIX, |crashReporterArg| is "true" if crash reporting is
+ // enabled, false otherwise
+ if (0 != strcmp("false", crashReporterArg) &&
diff --git a/www/firefox52/patches/patch-xpcom_base_nscore.h b/www/firefox52/patches/patch-xpcom_base_nscore.h
new file mode 100644
index 00000000000..3b1197e6880
--- /dev/null
+++ b/www/firefox52/patches/patch-xpcom_base_nscore.h
@@ -0,0 +1,15 @@
+$NetBSD: patch-xpcom_base_nscore.h,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support llvm/clang
+
+--- xpcom/base/nscore.h.orig 2014-05-29 23:31:50.000000000 +0000
++++ xpcom/base/nscore.h
+@@ -114,7 +114,7 @@
+ * NS_HIDDEN_(int) NS_FASTCALL func2(char *foo);
+ */
+
+-#if defined(__i386__) && defined(__GNUC__)
++#if defined(__i386__) && defined(__GNUC__) && !(defined(__clang__) && __clang_major__ == 3 && __clang_minor__ == 4 && __clang_patchlevel__ == 0)
+ #define NS_FASTCALL __attribute__ ((regparm (3), stdcall))
+ #define NS_CONSTRUCTOR_FASTCALL __attribute__ ((regparm (3), stdcall))
+ #elif defined(XP_WIN) && !defined(_WIN64)
diff --git a/www/firefox52/patches/patch-xpcom_build_XPCOMInit.cpp b/www/firefox52/patches/patch-xpcom_build_XPCOMInit.cpp
new file mode 100644
index 00000000000..a20bff5a05d
--- /dev/null
+++ b/www/firefox52/patches/patch-xpcom_build_XPCOMInit.cpp
@@ -0,0 +1,28 @@
+$NetBSD: patch-xpcom_build_XPCOMInit.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- xpcom/build/XPCOMInit.cpp.orig 2016-10-31 20:15:39.000000000 +0000
++++ xpcom/build/XPCOMInit.cpp
+@@ -137,7 +137,9 @@ extern nsresult nsStringInputStreamConst
+
+ #include "mozilla/ipc/GeckoChildProcessHost.h"
+
++#ifndef MOZ_OGG_NO_MEM_REPORTING
+ #include "ogg/ogg.h"
++#endif
+ #if defined(MOZ_VPX) && !defined(MOZ_VPX_NO_MEM_REPORTING)
+ #if defined(HAVE_STDINT_H)
+ // mozilla-config.h defines HAVE_STDINT_H, and then it's defined *again* in
+@@ -638,11 +640,13 @@ NS_InitXPCOM2(nsIServiceManager** aResul
+ // this oddness.
+ mozilla::SetICUMemoryFunctions();
+
++#ifndef MOZ_OGG_NO_MEM_REPORTING
+ // Do the same for libogg.
+ ogg_set_mem_functions(OggReporter::CountingMalloc,
+ OggReporter::CountingCalloc,
+ OggReporter::CountingRealloc,
+ OggReporter::CountingFree);
++#endif
+
+ #if defined(MOZ_VPX) && !defined(MOZ_VPX_NO_MEM_REPORTING)
+ // And for VPX.
diff --git a/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_Makefile.in b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_Makefile.in
new file mode 100644
index 00000000000..b789c99023c
--- /dev/null
+++ b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_Makefile.in
@@ -0,0 +1,50 @@
+$NetBSD: patch-xpcom_reflect_xptcall_md_unix_Makefile.in,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+* Support NetBSD/sparc64
+
+--- xpcom/reflect/xptcall/md/unix/Makefile.in.orig 2015-08-24 21:53:22.000000000 +0000
++++ xpcom/reflect/xptcall/md/unix/Makefile.in
+@@ -42,6 +42,43 @@ ifeq ($(OS_ARCH),AIX)
+ CXXFLAGS := $(filter-out $(MOZ_OPTIMIZE_FLAGS), $(CXXFLAGS))
+ endif
+
++######################################################################
++# SPARC
++######################################################################
++#
++# Linux/SPARC
++#
++ifeq ($(OS_ARCH),Linux)
++ifneq (,$(findstring sparc,$(OS_TEST)))
++ASFILES := xptcinvoke_asm_sparc_linux_GCC3.s xptcstubs_asm_sparc_solaris.s
++endif
++endif
++#
++# NetBSD/SPARC
++#
++ifeq ($(OS_ARCH)$(OS_TEST),NetBSDsparc)
++ASFILES := xptcinvoke_asm_sparc_netbsd.s xptcstubs_asm_sparc_netbsd.s
++endif
++#
++# OpenBSD/SPARC
++#
++ifeq ($(OS_ARCH)$(OS_TEST),OpenBSDsparc)
++ASFILES := xptcinvoke_asm_sparc_openbsd.s xptcstubs_asm_sparc_openbsd.s
++endif
++#
++# OpenBSD/SPARC64
++#
++ifneq (,$(filter OpenBSDsparc64 FreeBSDsparc64,$(OS_ARCH)$(OS_TEST)))
++ASFILES := xptcinvoke_asm_sparc64_openbsd.s xptcstubs_asm_sparc64_openbsd.s
++endif
++#
++# NetBSD/SPARC64
++#
++ifeq ($(OS_ARCH)$(OS_TEST),NetBSDsparc64)
++CPPSRCS := xptcinvoke_sparc64_netbsd.cpp xptcstubs_sparc64_openbsd.cpp
++ASFILES := xptcinvoke_asm_sparc64_openbsd.s xptcstubs_asm_sparc64_netbsd.s
++endif
++
+ include $(topsrcdir)/config/rules.mk
+
+ ifeq ($(OS_ARCH),Linux)
diff --git a/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__arm__netbsd.cpp b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__arm__netbsd.cpp
new file mode 100644
index 00000000000..09084c49179
--- /dev/null
+++ b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__arm__netbsd.cpp
@@ -0,0 +1,527 @@
+$NetBSD: patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__arm__netbsd.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- xpcom/reflect/xptcall/md/unix/xptcinvoke_arm_netbsd.cpp.orig 2014-11-13 22:50:21.000000000 +0000
++++ xpcom/reflect/xptcall/md/unix/xptcinvoke_arm_netbsd.cpp
+@@ -7,82 +7,92 @@
+
+ #include "xptcprivate.h"
+
+-// Remember that these 'words' are 32bit DWORDS
++#include "mozilla/Compiler.h"
+
+-static uint32_t
+-invoke_count_words(uint32_t paramCount, nsXPTCVariant* s)
++#ifndef __ARM_PCS_VFP
++
++/* This function copies a 64-bits word from dw to the given pointer in
++ * a buffer delimited by start and end, possibly wrapping around the
++ * buffer boundaries, and/or properly aligning the data at 64-bits word
++ * boundaries (for EABI).
++ * start and end are both assumed to be 64-bits aligned.
++ * Returns a pointer to the second 32-bits word copied (to accomodate
++ * the invoke_copy_to_stack loop).
++ */
++static uint32_t *
++copy_double_word(uint32_t *start, uint32_t *current, uint32_t *end, uint64_t *dw)
+ {
+- uint32_t result = 0;
+- for(uint32_t i = 0; i < paramCount; i++, s++)
+- {
+- if(s->IsPtrData())
+- {
+- result++;
+- continue;
+- }
+- switch(s->type)
+- {
+- case nsXPTType::T_I8 :
+- case nsXPTType::T_I16 :
+- case nsXPTType::T_I32 :
+- result++;
+- break;
+- case nsXPTType::T_I64 :
+- result+=2;
+- break;
+- case nsXPTType::T_U8 :
+- case nsXPTType::T_U16 :
+- case nsXPTType::T_U32 :
+- result++;
+- break;
+- case nsXPTType::T_U64 :
+- result+=2;
+- break;
+- case nsXPTType::T_FLOAT :
+- result++;
+- break;
+- case nsXPTType::T_DOUBLE :
+- result+=2;
+- break;
+- case nsXPTType::T_BOOL :
+- case nsXPTType::T_CHAR :
+- case nsXPTType::T_WCHAR :
+- result++;
+- break;
+- default:
+- // all the others are plain pointer types
+- result++;
+- break;
+- }
++#ifdef __ARM_EABI__
++ /* Aligning the pointer for EABI */
++ current = (uint32_t *)(((uint32_t)current + 7) & ~7);
++ /* Wrap when reaching the end of the buffer */
++ if (current == end) current = start;
++#else
++ /* On non-EABI, 64-bits values are not aligned and when we reach the end
++ * of the buffer, we need to write half of the data at the end, and the
++ * other half at the beginning. */
++ if (current == end - 1) {
++ *current = ((uint32_t*)dw)[0];
++ *start = ((uint32_t*)dw)[1];
++ return start;
+ }
+- return result;
++#endif
++
++ *((uint64_t*) current) = *dw;
++ return current + 1;
+ }
+
+-static void
+-invoke_copy_to_stack(uint32_t* d, uint32_t paramCount, nsXPTCVariant* s)
++/* See stack_space comment in NS_InvokeByIndex to see why this needs not to
++ * be static on DEBUG builds. */
++#ifndef DEBUG
++static
++#endif
++void
++invoke_copy_to_stack(uint32_t* stk, uint32_t *end,
++ uint32_t paramCount, nsXPTCVariant* s)
+ {
++ /* The stack buffer is 64-bits aligned. The end argument points to its end.
++ * The caller is assumed to create a stack buffer of at least four 32-bits
++ * words.
++ * We use the last three 32-bit words to store the values for r1, r2 and r3
++ * for the method call, i.e. the first words for arguments passing.
++ */
++ uint32_t *d = end - 3;
+ for(uint32_t i = 0; i < paramCount; i++, d++, s++)
+ {
++ /* Wrap when reaching the end of the stack buffer */
++ if (d == end) d = stk;
++ NS_ASSERTION(d >= stk && d < end,
++ "invoke_copy_to_stack is copying outside its given buffer");
+ if(s->IsPtrData())
+ {
+ *((void**)d) = s->ptr;
+ continue;
+ }
++ // According to the ARM EABI, integral types that are smaller than a word
++ // are to be sign/zero-extended to a full word and treated as 4-byte values.
++
+ switch(s->type)
+ {
+- case nsXPTType::T_I8 : *((int8_t*) d) = s->val.i8; break;
+- case nsXPTType::T_I16 : *((int16_t*) d) = s->val.i16; break;
++ case nsXPTType::T_I8 : *((int32_t*) d) = s->val.i8; break;
++ case nsXPTType::T_I16 : *((int32_t*) d) = s->val.i16; break;
+ case nsXPTType::T_I32 : *((int32_t*) d) = s->val.i32; break;
+- case nsXPTType::T_I64 : *((int64_t*) d) = s->val.i64; d++; break;
+- case nsXPTType::T_U8 : *((uint8_t*) d) = s->val.u8; break;
+- case nsXPTType::T_U16 : *((uint16_t*)d) = s->val.u16; break;
++ case nsXPTType::T_I64 :
++ d = copy_double_word(stk, d, end, (uint64_t *)&s->val.i64);
++ break;
++ case nsXPTType::T_U8 : *((uint32_t*)d) = s->val.u8; break;
++ case nsXPTType::T_U16 : *((uint32_t*)d) = s->val.u16; break;
+ case nsXPTType::T_U32 : *((uint32_t*)d) = s->val.u32; break;
+- case nsXPTType::T_U64 : *((uint64_t*)d) = s->val.u64; d++; break;
++ case nsXPTType::T_U64 :
++ d = copy_double_word(stk, d, end, (uint64_t *)&s->val.u64);
++ break;
+ case nsXPTType::T_FLOAT : *((float*) d) = s->val.f; break;
+- case nsXPTType::T_DOUBLE : *((double*) d) = s->val.d; d++; break;
+- case nsXPTType::T_BOOL : *((bool*) d) = s->val.b; break;
+- case nsXPTType::T_CHAR : *((char*) d) = s->val.c; break;
+- case nsXPTType::T_WCHAR : *((wchar_t*) d) = s->val.wc; break;
++ case nsXPTType::T_DOUBLE :
++ d = copy_double_word(stk, d, end, (uint64_t *)&s->val.d);
++ break;
++ case nsXPTType::T_BOOL : *((int32_t*) d) = s->val.b; break;
++ case nsXPTType::T_CHAR : *((int32_t*) d) = s->val.c; break;
++ case nsXPTType::T_WCHAR : *((int32_t*) d) = s->val.wc; break;
+ default:
+ // all the others are plain pointer types
+ *((void**)d) = s->val.p;
+@@ -91,47 +101,27 @@ invoke_copy_to_stack(uint32_t* d, uint32
+ }
+ }
+
+-extern "C"
+-struct my_params_struct {
+- nsISupports* that;
+- uint32_t Index;
+- uint32_t Count;
+- nsXPTCVariant* params;
+- uint32_t fn_count;
+- uint32_t fn_copy;
+-};
++typedef nsresult (*vtable_func)(nsISupports *, uint32_t, uint32_t, uint32_t);
+
+-XPTC_PUBLIC_API(nsresult)
+-XPTC_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
++EXPORT_XPCOM_API(nsresult)
++NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
+ uint32_t paramCount, nsXPTCVariant* params)
+ {
+- uint32_t result;
+- struct my_params_struct my_params;
+- my_params.that = that;
+- my_params.Index = methodIndex;
+- my_params.Count = paramCount;
+- my_params.params = params;
+- my_params.fn_copy = (uint32_t) &invoke_copy_to_stack;
+- my_params.fn_count = (uint32_t) &invoke_count_words;
+
+ /* This is to call a given method of class that.
+ * The parameters are in params, the number is in paramCount.
+ * The routine will issue calls to count the number of words
+ * required for argument passing and to copy the arguments to
+ * the stack.
+- * Since APCS passes the first 3 params in r1-r3, we need to
+- * load the first three words from the stack and correct the stack
+- * pointer (sp) in the appropriate way. This means:
+- *
+- * 1.) more than 3 arguments: load r1-r3, correct sp and remember No.
+- * of bytes left on the stack in r4
+- *
+- * 2.) <= 2 args: load r1-r3 (we won't be causing a stack overflow I hope),
+- * restore sp as if nothing had happened and set the marker r4 to zero.
+- *
+- * Afterwards sp will be restored using the value in r4 (which is not a temporary register
+- * and will be preserved by the function/method called according to APCS [ARM Procedure
+- * Calling Standard]).
++ * ACPS passes the first 3 params in r1-r3 (with exceptions for 64-bits
++ * arguments), and the remaining goes onto the stack.
++ * We allocate a buffer on the stack for a "worst case" estimate of how much
++ * stack might be needed for EABI, i.e. twice the number of parameters.
++ * The end of this buffer will be used to store r1 to r3, so that the start
++ * of the stack is the remaining parameters.
++ * The magic here is to call the method with "that" and three 32-bits
++ * arguments corresponding to r1-r3, so that the compiler generates the
++ * proper function call. The stack will also contain the remaining arguments.
+ *
+ * !!! IMPORTANT !!!
+ * This routine makes assumptions about the vtable layout of the c++ compiler. It's implemented
+@@ -139,43 +129,272 @@ XPTC_InvokeByIndex(nsISupports* that, ui
+ *
+ */
+
+- __asm__ __volatile__(
+- "ldr r1, [%1, #12] \n\t" /* prepare to call invoke_count_words */
+- "ldr ip, [%1, #16] \n\t" /* r0=paramCount, r1=params */
+- "ldr r0, [%1, #8] \n\t"
+- "mov lr, pc \n\t" /* call it... */
+- "mov pc, ip \n\t"
+- "mov r4, r0, lsl #2 \n\t" /* This is the amount of bytes needed. */
+- "sub sp, sp, r4 \n\t" /* use stack space for the args... */
+- "mov r0, sp \n\t" /* prepare a pointer an the stack */
+- "ldr r1, [%1, #8] \n\t" /* =paramCount */
+- "ldr r2, [%1, #12] \n\t" /* =params */
+- "ldr ip, [%1, #20] \n\t" /* =invoke_copy_to_stack */
+- "mov lr, pc \n\t" /* copy args to the stack like the */
+- "mov pc, ip \n\t" /* compiler would. */
+- "ldr r0, [%1] \n\t" /* =that */
+- "ldr r1, [r0, #0] \n\t" /* get that->vtable offset */
+- "ldr r2, [%1, #4] \n\t"
+- "add r2, r1, r2, lsl #3\n\t" /* a vtable_entry(x)=8 + (8 bytes * x) */
+- "add r2, r2, #8 \n\t" /* with this compilers */
+- "ldr r3, [r2] \n\t" /* get virtual offset from vtable */
+- "mov r3, r3, lsl #16 \n\t"
+- "add r0, r0, r3, asr #16\n\t"
+- "ldr ip, [r2, #4] \n\t" /* get method address from vtable */
+- "cmp r4, #12 \n\t" /* more than 3 arguments??? */
+- "ldmgtia sp!, {r1, r2, r3}\n\t" /* yes: load arguments for r1-r3 */
+- "subgt r4, r4, #12 \n\t" /* and correct the stack pointer */
+- "ldmleia sp, {r1, r2, r3}\n\t" /* no: load r1-r3 from stack */
+- "addle sp, sp, r4 \n\t" /* and restore stack pointer */
+- "movle r4, #0 \n\t" /* a mark for restoring sp */
+- "mov lr, pc \n\t" /* call mathod */
+- "mov pc, ip \n\t"
+- "add sp, sp, r4 \n\t" /* restore stack pointer */
+- "mov %0, r0 \n\t" /* the result... */
+- : "=r" (result)
+- : "r" (&my_params)
+- : "r0", "r1", "r2", "r3", "r4", "ip", "lr"
+- );
+-
+- return result;
++ vtable_func *vtable, func;
++ int base_size = (paramCount > 1) ? paramCount : 2;
++
++/* !!! IMPORTANT !!!
++ * On DEBUG builds, the NS_ASSERTION used in invoke_copy_to_stack needs to use
++ * the stack to pass the 5th argument to NS_DebugBreak. When invoke_copy_to_stack
++ * is inlined, this can result, depending on the compiler and flags, in the
++ * stack pointer not pointing at stack_space when the method is called at the
++ * end of this function. More generally, any function call requiring stack
++ * allocation of arguments is unsafe to be inlined in this function.
++ */
++ uint32_t *stack_space = (uint32_t *) __builtin_alloca(base_size * 8);
++
++ invoke_copy_to_stack(stack_space, &stack_space[base_size * 2],
++ paramCount, params);
++
++ vtable = *reinterpret_cast<vtable_func **>(that);
++ func = vtable[methodIndex];
++
++ return func(that, stack_space[base_size * 2 - 3],
++ stack_space[base_size * 2 - 2],
++ stack_space[base_size * 2 - 1]);
+ }
++
++#else /* __ARM_PCS_VFP */
++
++/* "Procedure Call Standard for the ARM Architecture" document, sections
++ * "5.5 Parameter Passing" and "6.1.2 Procedure Calling" contain all the
++ * needed information.
++ *
++ * http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf
++ */
++
++#if defined(__thumb__) && !defined(__thumb2__)
++#error "Thumb1 is not supported"
++#endif
++
++#ifndef __ARMEL__
++#error "Only little endian compatibility was tested"
++#endif
++
++/*
++ * Allocation of integer function arguments initially to registers r1-r3
++ * and then to stack. Handling of 'this' argument which goes to r0 registers
++ * is handled separately and does not belong to these two inline functions.
++ *
++ * The doubleword arguments are allocated to even:odd
++ * register pairs or get aligned at 8-byte boundary on stack. The "holes"
++ * which may appear as a result of this realignment remain unused.
++ *
++ * 'ireg_args' - pointer to the current position in the buffer,
++ * corresponding to the register arguments
++ * 'stack_args' - pointer to the current position in the buffer,
++ * corresponding to the arguments on stack
++ * 'end' - pointer to the end of the registers argument
++ * buffer (it is guaranteed to be 8-bytes aligned)
++ */
++
++static inline void copy_word(uint32_t* &ireg_args,
++ uint32_t* &stack_args,
++ uint32_t* end,
++ uint32_t data)
++{
++ if (ireg_args < end) {
++ *ireg_args = data;
++ ireg_args++;
++ } else {
++ *stack_args = data;
++ stack_args++;
++ }
++}
++
++static inline void copy_dword(uint32_t* &ireg_args,
++ uint32_t* &stack_args,
++ uint32_t* end,
++ uint64_t data)
++{
++ if (ireg_args + 1 < end) {
++ if ((uint32_t)ireg_args & 4) {
++ ireg_args++;
++ }
++ *(uint64_t *)ireg_args = data;
++ ireg_args += 2;
++ } else {
++ if ((uint32_t)stack_args & 4) {
++ stack_args++;
++ }
++ *(uint64_t *)stack_args = data;
++ stack_args += 2;
++ }
++}
++
++/*
++ * Allocation of floating point arguments to VFP registers (s0-s15, d0-d7).
++ *
++ * Unlike integer registers allocation, "back-filling" needs to be
++ * supported. For example, the third floating point argument in the
++ * following function is going to be allocated to s1 register, back-filling
++ * the "hole":
++ * void f(float s0, double d1, float s1)
++ *
++ * Refer to the "Procedure Call Standard for the ARM Architecture" document
++ * for more details.
++ *
++ * 'vfp_s_args' - pointer to the current position in the buffer with
++ * the next unallocated single precision register
++ * 'vfp_d_args' - pointer to the current position in the buffer with
++ * the next unallocated double precision register,
++ * it has the same value as 'vfp_s_args' when back-filling
++ * is not used
++ * 'end' - pointer to the end of the vfp registers argument
++ * buffer (it is guaranteed to be 8-bytes aligned)
++ *
++ * Mozilla bugtracker has a test program attached which be used for
++ * experimenting with VFP registers allocation code and testing its
++ * correctness:
++ * https://bugzilla.mozilla.org/show_bug.cgi?id=601914#c19
++ */
++
++static inline bool copy_vfp_single(float* &vfp_s_args, double* &vfp_d_args,
++ float* end, float data)
++{
++ if (vfp_s_args >= end)
++ return false;
++
++ *vfp_s_args = data;
++ vfp_s_args++;
++ if (vfp_s_args < (float *)vfp_d_args) {
++ // It was the case of back-filling, now the next free single precision
++ // register should overlap with the next free double precision register
++ vfp_s_args = (float *)vfp_d_args;
++ } else if (vfp_s_args > (float *)vfp_d_args) {
++ // also update the pointer to the next free double precision register
++ vfp_d_args++;
++ }
++ return true;
++}
++
++static inline bool copy_vfp_double(float* &vfp_s_args, double* &vfp_d_args,
++ float* end, double data)
++{
++ if (vfp_d_args >= (double *)end) {
++ // The back-filling continues only so long as no VFP CPRC has been
++ // allocated to a slot on the stack. Basically no VFP registers can
++ // be allocated after this point.
++ vfp_s_args = end;
++ return false;
++ }
++
++ if (vfp_s_args == (float *)vfp_d_args) {
++ // also update the pointer to the next free single precision register
++ vfp_s_args += 2;
++ }
++ *vfp_d_args = data;
++ vfp_d_args++;
++ return true;
++}
++
++static void
++invoke_copy_to_stack(uint32_t* stk, uint32_t *end,
++ uint32_t paramCount, nsXPTCVariant* s)
++{
++ uint32_t *ireg_args = end - 3;
++ float *vfp_s_args = (float *)end;
++ double *vfp_d_args = (double *)end;
++ float *vfp_end = vfp_s_args + 16;
++
++ for (uint32_t i = 0; i < paramCount; i++, s++) {
++ if (s->IsPtrData()) {
++ copy_word(ireg_args, stk, end, (uint32_t)s->ptr);
++ continue;
++ }
++ // According to the ARM EABI, integral types that are smaller than a word
++ // are to be sign/zero-extended to a full word and treated as 4-byte values
++ switch (s->type)
++ {
++ case nsXPTType::T_FLOAT:
++ if (!copy_vfp_single(vfp_s_args, vfp_d_args, vfp_end, s->val.f)) {
++ copy_word(end, stk, end, reinterpret_cast<uint32_t&>(s->val.f));
++ }
++ break;
++ case nsXPTType::T_DOUBLE:
++ if (!copy_vfp_double(vfp_s_args, vfp_d_args, vfp_end, s->val.d)) {
++ copy_dword(end, stk, end, reinterpret_cast<uint64_t&>(s->val.d));
++ }
++ break;
++ case nsXPTType::T_I8: copy_word(ireg_args, stk, end, s->val.i8); break;
++ case nsXPTType::T_I16: copy_word(ireg_args, stk, end, s->val.i16); break;
++ case nsXPTType::T_I32: copy_word(ireg_args, stk, end, s->val.i32); break;
++ case nsXPTType::T_I64: copy_dword(ireg_args, stk, end, s->val.i64); break;
++ case nsXPTType::T_U8: copy_word(ireg_args, stk, end, s->val.u8); break;
++ case nsXPTType::T_U16: copy_word(ireg_args, stk, end, s->val.u16); break;
++ case nsXPTType::T_U32: copy_word(ireg_args, stk, end, s->val.u32); break;
++ case nsXPTType::T_U64: copy_dword(ireg_args, stk, end, s->val.u64); break;
++ case nsXPTType::T_BOOL: copy_word(ireg_args, stk, end, s->val.b); break;
++ case nsXPTType::T_CHAR: copy_word(ireg_args, stk, end, s->val.c); break;
++ case nsXPTType::T_WCHAR: copy_word(ireg_args, stk, end, s->val.wc); break;
++ default:
++ // all the others are plain pointer types
++ copy_word(ireg_args, stk, end, reinterpret_cast<uint32_t>(s->val.p));
++ break;
++ }
++ }
++}
++
++typedef uint32_t (*vtable_func)(nsISupports *, uint32_t, uint32_t, uint32_t);
++
++EXPORT_XPCOM_API(nsresult)
++NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
++ uint32_t paramCount, nsXPTCVariant* params)
++{
++ vtable_func *vtable = *reinterpret_cast<vtable_func **>(that);
++ vtable_func func = vtable[methodIndex];
++ // 'register uint32_t result asm("r0")' could be used here, but it does not
++ // seem to be reliable in all cases: http://gcc.gnu.org/PR46164
++ nsresult result;
++ asm (
++ "mov r3, sp\n"
++ "mov %[stack_space_size], %[param_count_plus_2], lsl #3\n"
++ "tst r3, #4\n" /* check stack alignment */
++
++ "add %[stack_space_size], #(4 * 16)\n" /* space for VFP registers */
++ "mov r3, %[params]\n"
++
++ "it ne\n"
++ "addne %[stack_space_size], %[stack_space_size], #4\n"
++ "sub r0, sp, %[stack_space_size]\n" /* allocate space on stack */
++
++ "sub r2, %[param_count_plus_2], #2\n"
++ "mov sp, r0\n"
++
++ "add r1, r0, %[param_count_plus_2], lsl #3\n"
++ "blx %[invoke_copy_to_stack]\n"
++
++ "add ip, sp, %[param_count_plus_2], lsl #3\n"
++ "mov r0, %[that]\n"
++ "ldmdb ip, {r1, r2, r3}\n"
++ "vldm ip, {d0, d1, d2, d3, d4, d5, d6, d7}\n"
++ "blx %[func]\n"
++
++ "add sp, sp, %[stack_space_size]\n" /* cleanup stack */
++ "mov %[stack_space_size], r0\n" /* it's actually 'result' variable */
++ : [stack_space_size] "=&r" (result)
++ : [func] "r" (func),
++ [that] "r" (that),
++ [params] "r" (params),
++ [param_count_plus_2] "r" (paramCount + 2),
++ [invoke_copy_to_stack] "r" (invoke_copy_to_stack)
++ : "cc", "memory",
++ // Mark all the scratch registers as clobbered because they may be
++ // modified by the functions, called from this inline assembly block
++ "r0", "r1", "r2", "r3", "ip", "lr",
++ "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
++ // Also unconditionally mark d16-d31 registers as clobbered even though
++ // they actually don't exist in vfpv2 and vfpv3-d16 variants. There is
++ // no way to identify VFP variant using preprocessor at the momemnt
++ // (see http://gcc.gnu.org/PR46128 for more details), but fortunately
++ // current versions of gcc do not seem to complain about these registers
++ // even when this code is compiled with '-mfpu=vfpv3-d16' option.
++ // If gcc becomes more strict in the future and/or provides a way to
++ // identify VFP variant, the following d16-d31 registers list needs
++ // to be wrapped into some #ifdef
++ "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23",
++ "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31"
++ );
++ return result;
++}
++
++#endif
diff --git a/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__asm__mips.S b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__asm__mips.S
new file mode 100644
index 00000000000..7de7d232764
--- /dev/null
+++ b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__asm__mips.S
@@ -0,0 +1,52 @@
+$NetBSD: patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__asm__mips.S,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_mips.S.orig 2014-10-11 09:06:50.000000000 +0000
++++ xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_mips.S
+@@ -16,6 +16,47 @@
+ #include <sys/asm.h>
+ #endif
+
++#ifdef __NetBSD__
++# include <machine/regdef.h>
++# include <machine/asm.h>
++# ifndef fp
++# define fp s8
++# endif
++# ifndef PTRLOG
++# if SZREG == 4
++# define PTRLOG 2
++# else
++# define PTRLOG 3
++# endif
++# endif
++# ifndef SETUP_GP
++# if defined(__mips_o32)
++# define SETUP_GP \
++ .set push; \
++ .set noreorder; \
++ .cpload t9; \
++ .set pop
++# define SAVE_GP(x) \
++ .cprestore x
++# else
++# define SETUP_GP
++# define SAVE_GP(x)
++# endif
++# endif
++# ifndef ALSZ
++# if defined(__mips_n32) || defined(__mips_n64)
++# define ALSZ 15
++# define ALMASK ~15
++# else
++# define ALSZ 7
++# define ALMASK ~7
++# endif
++# endif
++#else
++# include <sys/regdef.h>
++# include <sys/asm.h>
++#endif
++
+ # NARGSAVE is the argument space in the callers frame, including extra
+ # 'shadowed' space for the argument registers. The minimum of 4
+ # argument slots is sometimes predefined in the header files.
diff --git a/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__asm__ppc__netbsd.s b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__asm__ppc__netbsd.s
new file mode 100644
index 00000000000..b71d8ef154e
--- /dev/null
+++ b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__asm__ppc__netbsd.s
@@ -0,0 +1,25 @@
+$NetBSD: patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__asm__ppc__netbsd.s,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_ppc_netbsd.s.orig 2014-10-11 09:06:50.000000000 +0000
++++ xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_ppc_netbsd.s
+@@ -20,15 +20,15 @@
+
+ .section ".text"
+ .align 2
+- .globl XPTC_InvokeByIndex
+- .type XPTC_InvokeByIndex,@function
++ .globl NS_InvokeByIndex_P
++ .type NS_InvokeByIndex_P,@function
+
+ #
+-# XPTC_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
+-# uint32_t paramCount, nsXPTCVariant* params)
++# NS_InvokeByIndex_P(nsISupports* that, PRUint32 methodIndex,
++# PRUint32 paramCount, nsXPTCVariant* params)
+ #
+
+-XPTC_InvokeByIndex:
++NS_InvokeByIndex_P:
+ stwu sp,-32(sp) # setup standard stack frame
+ mflr r0 # save LR
+ stw r3,8(sp) # r3 <= that
diff --git a/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__netbsd__m68k.cpp b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__netbsd__m68k.cpp
new file mode 100644
index 00000000000..4622fcf8834
--- /dev/null
+++ b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__netbsd__m68k.cpp
@@ -0,0 +1,75 @@
+$NetBSD: patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__netbsd__m68k.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- xpcom/reflect/xptcall/md/unix/xptcinvoke_netbsd_m68k.cpp.orig 2014-10-11 09:06:50.000000000 +0000
++++ xpcom/reflect/xptcall/md/unix/xptcinvoke_netbsd_m68k.cpp
+@@ -100,6 +100,15 @@ extern "C" {
+ }
+ }
+
++/*
++ * SYMBOL PREFIX must be "_" for aout symbols and "" for ELF
++ */
++#ifndef __ELF__
++#define SYMBOLPREFIX "_"
++#else
++#define SYMBOLPREFIX
++#endif
++
+ XPTC_PUBLIC_API(nsresult)
+ XPTC_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
+ uint32_t paramCount, nsXPTCVariant* params)
+@@ -107,30 +116,30 @@ XPTC_InvokeByIndex(nsISupports* that, ui
+ uint32_t result;
+
+ __asm__ __volatile__(
+- "movl %4, sp@-\n\t"
+- "movl %3, sp@-\n\t"
+- "jbsr _invoke_count_words\n\t" /* count words */
+- "addql #8, sp\n\t"
+- "lsll #2, d0\n\t" /* *= 4 */
+- "movl sp, a2\n\t" /* save original sp */
+- "subl d0, sp\n\t" /* make room for params */
+- "movl sp, a0\n\t"
+- "movl %4, sp@-\n\t"
+- "movl %3, sp@-\n\t"
+- "movl a0, sp@-\n\t"
+- "jbsr _invoke_copy_to_stack\n\t" /* copy params */
+- "addl #12, sp\n\t"
+- "movl %1, a0\n\t"
+- "movl a0@, a1\n\t"
+- "movl %2, d0\n\t" /* function index */
+- "movl a0, d1\n\t"
+- "movw a1@(8,d0:l:8), a0\n\t"
+- "addl a0, d1\n\t"
+- "movl a1@(12,d0:l:8), a1\n\t"
+- "movl d1, sp@-\n\t"
+- "jbsr a1@\n\t"
+- "movl a2, sp\n\t" /* restore original sp */
+- "movl d0, %0\n\t"
++ "movl %4, %%sp@-\n\t"
++ "movl %3, %%sp@-\n\t"
++ "jbsr "SYMBOLPREFIX"invoke_count_words\n\t" /* count words */
++ "addql #8, %%sp\n\t"
++ "lsll #2, %%d0\n\t" /* *= 4 */
++ "movl %%sp, %%a2\n\t" /* save original sp */
++ "subl %%d0, %%sp\n\t" /* make room for params */
++ "movl %%sp, %%a0\n\t"
++ "movl %4, %%sp@-\n\t"
++ "movl %3, %%sp@-\n\t"
++ "movl %%a0, %%sp@-\n\t"
++ "jbsr "SYMBOLPREFIX"invoke_copy_to_stack\n\t" /* copy params */
++ "addl #12, %%sp\n\t"
++ "movl %1, %%a0\n\t"
++ "movl %%a0@, %%a1\n\t"
++ "movl %2, %%d0\n\t" /* function index */
++ "movl %%a0, %%d1\n\t"
++ "movw %%a1@(8,%%d0:l:8), %%a0\n\t"
++ "addl %%a0, %%d1\n\t"
++ "movl %%a1@(12,%%d0:l:8), %%a1\n\t"
++ "movl %%d1, %%sp@-\n\t"
++ "jbsr %%a1@\n\t"
++ "movl %%a2, %%sp\n\t" /* restore original sp */
++ "movl %%d0, %0\n\t"
+ : "=g" (result) /* %0 */
+ : "g" (that), /* %1 */
+ "g" (methodIndex), /* %2 */
diff --git a/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__ppc__netbsd.cpp b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__ppc__netbsd.cpp
new file mode 100644
index 00000000000..f7e30f8eb1c
--- /dev/null
+++ b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__ppc__netbsd.cpp
@@ -0,0 +1,47 @@
+$NetBSD: patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__ppc__netbsd.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- xpcom/reflect/xptcall/md/unix/xptcinvoke_ppc_netbsd.cpp.orig 2014-10-11 09:06:50.000000000 +0000
++++ xpcom/reflect/xptcall/md/unix/xptcinvoke_ppc_netbsd.cpp
+@@ -5,9 +5,9 @@
+
+ // Platform specific code to invoke XPCOM methods on native objects
+
+-// The purpose of XPTC_InvokeByIndex() is to map a platform
++// The purpose of NS_InvokeByIndex_P() is to map a platform
+ // indepenpent call to the platform ABI. To do that,
+-// XPTC_InvokeByIndex() has to determine the method to call via vtable
++// NS_InvokeByIndex_P() has to determine the method to call via vtable
+ // access. The parameters for the method are read from the
+ // nsXPTCVariant* and prepared for the native ABI. For the Linux/PPC
+ // ABI this means that the first 8 integral and floating point
+@@ -72,8 +72,10 @@ invoke_copy_to_stack(uint32_t* d,
+ if ((uint32_t) d & 4) d++; // doubles are 8-byte aligned on stack
+ *((double*) d) = s->val.d;
+ d += 2;
++#if __GXX_ABI_VERSION < 100
+ if (gpr < GPR_COUNT)
+ gpr += 2;
++#endif
+ }
+ }
+ else if (!s->IsPtrData() && s->type == nsXPTType::T_FLOAT) {
+@@ -82,8 +84,10 @@ invoke_copy_to_stack(uint32_t* d,
+ else {
+ *((float*) d) = s->val.f;
+ d += 1;
++#if __GXX_ABI_VERSION < 100
+ if (gpr < GPR_COUNT)
+ gpr += 1;
++#endif
+ }
+ }
+ else if (!s->IsPtrData() && (s->type == nsXPTType::T_I64
+@@ -110,6 +114,6 @@ invoke_copy_to_stack(uint32_t* d,
+ }
+
+ extern "C"
+-XPTC_PUBLIC_API(nsresult)
+-XPTC_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
++EXPORT_XPCOM_API(nsresult)
++NS_InvokeByIndex_P(nsISupports* that, PRUint32 methodIndex,
+ uint32_t paramCount, nsXPTCVariant* params);
diff --git a/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__sparc64__netbsd.cpp b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__sparc64__netbsd.cpp
new file mode 100644
index 00000000000..338383d4c47
--- /dev/null
+++ b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__sparc64__netbsd.cpp
@@ -0,0 +1,89 @@
+$NetBSD: patch-xpcom_reflect_xptcall_md_unix_xptcinvoke__sparc64__netbsd.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- xpcom/reflect/xptcall/md/unix/xptcinvoke_sparc64_netbsd.cpp.orig 2014-10-14 18:49:14.000000000 +0000
++++ xpcom/reflect/xptcall/md/unix/xptcinvoke_sparc64_netbsd.cpp
+@@ -0,0 +1,84 @@
++/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
++ *
++ * The contents of this file are subject to the Netscape Public
++ * License Version 1.1 (the "License"); you may not use this file
++ * except in compliance with the License. You may obtain a copy of
++ * the License at http://www.mozilla.org/NPL/
++ *
++ * Software distributed under the License is distributed on an "AS
++ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
++ * implied. See the License for the specific language governing
++ * rights and limitations under the License.
++ *
++ * The Original Code is mozilla.org code.
++ *
++ * The Initial Developer of the Original Code is Netscape
++ * Communications Corporation. Portions created by Netscape are
++ * Copyright (C) 1998 Netscape Communications Corporation. All
++ * Rights Reserved.
++ *
++ * Contributor(s):
++ */
++
++/* Platform specific code to invoke XPCOM methods on native objects */
++
++#include "xptcprivate.h"
++
++#if !defined(__sparc64__) && !defined(_LP64)
++#error "This code is for Sparc64 only"
++#endif
++
++extern "C" PRUint32
++invoke_copy_to_stack(PRUint64* d, PRUint32 paramCount, nsXPTCVariant* s)
++{
++ /*
++ We need to copy the parameters for this function to locals and use them
++ from there since the parameters occupy the same stack space as the stack
++ we're trying to populate.
++ */
++ PRUint64 *l_d = d;
++ nsXPTCVariant *l_s = s;
++ PRUint64 l_paramCount = paramCount;
++ PRUint64 regCount = 0; // return the number of registers to load from the stack
++
++ for(PRUint64 i = 0; i < l_paramCount; i++, l_d++, l_s++)
++ {
++ if (regCount < 5) regCount++;
++
++ if (l_s->IsPtrData())
++ {
++ *l_d = (PRUint64)l_s->ptr;
++ continue;
++ }
++ switch (l_s->type)
++ {
++ case nsXPTType::T_I8 : *((PRInt64*)l_d) = l_s->val.i8; break;
++ case nsXPTType::T_I16 : *((PRInt64*)l_d) = l_s->val.i16; break;
++ case nsXPTType::T_I32 : *((PRInt64*)l_d) = l_s->val.i32; break;
++ case nsXPTType::T_I64 : *((PRInt64*)l_d) = l_s->val.i64; break;
++
++ case nsXPTType::T_U8 : *((PRUint64*)l_d) = l_s->val.u8; break;
++ case nsXPTType::T_U16 : *((PRUint64*)l_d) = l_s->val.u16; break;
++ case nsXPTType::T_U32 : *((PRUint64*)l_d) = l_s->val.u32; break;
++ case nsXPTType::T_U64 : *((PRUint64*)l_d) = l_s->val.u64; break;
++
++ /* in the case of floats, we want to put the bits in to the
++ 64bit space right justified... floats in the paramter array on
++ sparcv9 use odd numbered registers.. %f1, %f3, so we have to skip
++ the space that would be occupied by %f0, %f2, etc.
++ */
++ case nsXPTType::T_FLOAT : *(((float*)l_d) + 1) = l_s->val.f; break;
++ case nsXPTType::T_DOUBLE: *((double*)l_d) = l_s->val.d; break;
++ case nsXPTType::T_BOOL : *((PRInt64*)l_d) = l_s->val.b; break;
++ case nsXPTType::T_CHAR : *((PRUint64*)l_d) = l_s->val.c; break;
++ case nsXPTType::T_WCHAR : *((PRInt64*)l_d) = l_s->val.wc; break;
++
++ default:
++ // all the others are plain pointer types
++ *((void**)l_d) = l_s->val.p;
++ break;
++ }
++ }
++
++ return regCount;
++}
diff --git a/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcstubs__arm__netbsd.cpp b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcstubs__arm__netbsd.cpp
new file mode 100644
index 00000000000..139f1fc173c
--- /dev/null
+++ b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcstubs__arm__netbsd.cpp
@@ -0,0 +1,217 @@
+$NetBSD: patch-xpcom_reflect_xptcall_md_unix_xptcstubs__arm__netbsd.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- xpcom/reflect/xptcall/md/unix/xptcstubs_arm_netbsd.cpp.orig 2014-11-26 12:30:27.000000000 +0000
++++ xpcom/reflect/xptcall/md/unix/xptcstubs_arm_netbsd.cpp
+@@ -6,15 +6,32 @@
+ /* Implement shared vtbl methods. */
+
+ #include "xptcprivate.h"
++#include "xptiprivate.h"
+
+-nsresult ATTRIBUTE_USED
++/* Specify explicitly a symbol for this function, don't try to guess the c++ mangled symbol. */
++static nsresult PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args) asm("_PrepareAndDispatch")
++ATTRIBUTE_USED;
++
++#ifdef __ARM_EABI__
++#define DOUBLEWORD_ALIGN(p) ((uint32_t *)((((uint32_t)(p)) + 7) & 0xfffffff8))
++#else
++#define DOUBLEWORD_ALIGN(p) (p)
++#endif
++
++// Apple's iOS toolchain is lame and does not support .cfi directives.
++#ifdef __APPLE__
++#define CFI(str)
++#else
++#define CFI(str) str
++#endif
++
++static nsresult
+ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
+ {
+ #define PARAM_BUFFER_COUNT 16
+
+ nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
+ nsXPTCMiniVariant* dispatchParams = nullptr;
+- nsIInterfaceInfo* iface_info = nullptr;
+ const nsXPTMethodInfo* info;
+ uint8_t paramCount;
+ uint8_t i;
+@@ -22,12 +39,7 @@ PrepareAndDispatch(nsXPTCStubBase* self,
+
+ NS_ASSERTION(self,"no self");
+
+- self->GetInterfaceInfo(&iface_info);
+- NS_ASSERTION(iface_info,"no interface info");
+-
+- iface_info->GetMethodInfo(uint16_t(methodIndex), &info);
+- NS_ASSERTION(info,"no interface info");
+-
++ self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info);
+ paramCount = info->GetParamCount();
+
+ // setup variant array pointer
+@@ -55,13 +67,16 @@ PrepareAndDispatch(nsXPTCStubBase* self,
+ case nsXPTType::T_I8 : dp->val.i8 = *((int8_t*) ap); break;
+ case nsXPTType::T_I16 : dp->val.i16 = *((int16_t*) ap); break;
+ case nsXPTType::T_I32 : dp->val.i32 = *((int32_t*) ap); break;
+- case nsXPTType::T_I64 : dp->val.i64 = *((int64_t*) ap); ap++; break;
++ case nsXPTType::T_I64 : ap = DOUBLEWORD_ALIGN(ap);
++ dp->val.i64 = *((int64_t*) ap); ap++; break;
+ case nsXPTType::T_U8 : dp->val.u8 = *((uint8_t*) ap); break;
+ case nsXPTType::T_U16 : dp->val.u16 = *((uint16_t*)ap); break;
+ case nsXPTType::T_U32 : dp->val.u32 = *((uint32_t*)ap); break;
+- case nsXPTType::T_U64 : dp->val.u64 = *((uint64_t*)ap); ap++; break;
++ case nsXPTType::T_U64 : ap = DOUBLEWORD_ALIGN(ap);
++ dp->val.u64 = *((uint64_t*)ap); ap++; break;
+ case nsXPTType::T_FLOAT : dp->val.f = *((float*) ap); break;
+- case nsXPTType::T_DOUBLE : dp->val.d = *((double*) ap); ap++; break;
++ case nsXPTType::T_DOUBLE : ap = DOUBLEWORD_ALIGN(ap);
++ dp->val.d = *((double*) ap); ap++; break;
+ case nsXPTType::T_BOOL : dp->val.b = *((bool*) ap); break;
+ case nsXPTType::T_CHAR : dp->val.c = *((char*) ap); break;
+ case nsXPTType::T_WCHAR : dp->val.wc = *((wchar_t*) ap); break;
+@@ -71,9 +86,7 @@ PrepareAndDispatch(nsXPTCStubBase* self,
+ }
+ }
+
+- result = self->CallMethod((uint16_t)methodIndex, info, dispatchParams);
+-
+- NS_RELEASE(iface_info);
++ result = self->mOuter->CallMethod((uint16_t)methodIndex, info, dispatchParams);
+
+ if(dispatchParams != paramBuffer)
+ delete [] dispatchParams;
+@@ -82,26 +95,114 @@ PrepareAndDispatch(nsXPTCStubBase* self,
+ }
+
+ /*
+- * These stubs move just move the values passed in registers onto the stack,
+- * so they are contiguous with values passed on the stack, and then calls
+- * PrepareAndDispatch() to do the dirty work.
++ * This is our shared stub.
++ *
++ * r0 = Self.
++ *
++ * The Rules:
++ * We pass an (undefined) number of arguments into this function.
++ * The first 3 C++ arguments are in r1 - r3, the rest are built
++ * by the calling function on the stack.
++ *
++ * We are allowed to corrupt r0 - r3, ip, and lr.
++ *
++ * Other Info:
++ * We pass the stub number in using `ip'.
++ *
++ * Implementation:
++ * - We save r1 to r3 inclusive onto the stack, which will be
++ * immediately below the caller saved arguments.
++ * - setup r2 (PrepareAndDispatch's args pointer) to point at
++ * the base of all these arguments
++ * - Save LR (for the return address)
++ * - Set r1 (PrepareAndDispatch's methodindex argument) from ip
++ * - r0 is passed through (self)
++ * - Call PrepareAndDispatch
++ * - When the call returns, we return by loading the PC off the
++ * stack, and undoing the stack (one instruction)!
++ *
+ */
++__asm__ ("\n"
++ ".text\n"
++ ".align 2\n"
++ "SharedStub:\n"
++ CFI(".cfi_startproc\n")
++ "stmfd sp!, {r1, r2, r3}\n"
++ CFI(".cfi_def_cfa_offset 12\n")
++ CFI(".cfi_offset r3, -4\n")
++ CFI(".cfi_offset r2, -8\n")
++ CFI(".cfi_offset r1, -12\n")
++ "mov r2, sp\n"
++ "str lr, [sp, #-4]!\n"
++ CFI(".cfi_def_cfa_offset 16\n")
++ CFI(".cfi_offset lr, -16\n")
++ "mov r1, ip\n"
++ "bl _PrepareAndDispatch\n"
++ "ldr pc, [sp], #16\n"
++ CFI(".cfi_endproc\n"));
++
++/*
++ * Create sets of stubs to call the SharedStub.
++ * We don't touch the stack here, nor any registers, other than IP.
++ * IP is defined to be corruptable by a called function, so we are
++ * safe to use it.
++ *
++ * This will work with or without optimisation.
++ */
++
++/*
++ * Note : As G++3 ABI contains the length of the functionname in the
++ * mangled name, it is difficult to get a generic assembler mechanism like
++ * in the G++ 2.95 case.
++ * Create names would be like :
++ * _ZN14nsXPTCStubBase5Stub9Ev
++ * _ZN14nsXPTCStubBase6Stub13Ev
++ * _ZN14nsXPTCStubBase7Stub144Ev
++ * Use the assembler directives to get the names right...
++ */
++
++#define STUB_ENTRY(n) \
++ __asm__( \
++ ".section \".text\"\n" \
++" .align 2\n" \
++" .iflt ("#n" - 10)\n" \
++" .globl _ZN14nsXPTCStubBase5Stub"#n"Ev\n" \
++" .type _ZN14nsXPTCStubBase5Stub"#n"Ev,#function\n" \
++"_ZN14nsXPTCStubBase5Stub"#n"Ev:\n" \
++" .else\n" \
++" .iflt ("#n" - 100)\n" \
++" .globl _ZN14nsXPTCStubBase6Stub"#n"Ev\n" \
++" .type _ZN14nsXPTCStubBase6Stub"#n"Ev,#function\n" \
++"_ZN14nsXPTCStubBase6Stub"#n"Ev:\n" \
++" .else\n" \
++" .iflt ("#n" - 1000)\n" \
++" .globl _ZN14nsXPTCStubBase7Stub"#n"Ev\n" \
++" .type _ZN14nsXPTCStubBase7Stub"#n"Ev,#function\n" \
++"_ZN14nsXPTCStubBase7Stub"#n"Ev:\n" \
++" .else\n" \
++" .err \"stub number "#n"> 1000 not yet supported\"\n" \
++" .endif\n" \
++" .endif\n" \
++" .endif\n" \
++" mov ip, #"#n"\n" \
++" b SharedStub\n\t");
++
++#if 0
++/*
++ * This part is left in as comment : this is how the method definition
++ * should look like.
++ */
++
++#define STUB_ENTRY(n) \
++nsresult nsXPTCStubBase::Stub##n () \
++{ \
++ __asm__ ( \
++" mov ip, #"#n"\n" \
++" b SharedStub\n\t"); \
++ return 0; /* avoid warnings */ \
++}
++#endif
+
+-#define STUB_ENTRY(n) \
+-__asm__( \
+- ".global _Stub"#n"__14nsXPTCStubBase\n\t" \
+-"_Stub"#n"__14nsXPTCStubBase:\n\t" \
+- "stmfd sp!, {r1, r2, r3} \n\t" \
+- "mov ip, sp \n\t" \
+- "stmfd sp!, {fp, ip, lr, pc} \n\t" \
+- "sub fp, ip, #4 \n\t" \
+- "mov r1, #"#n" \n\t" /* = methodIndex */ \
+- "add r2, sp, #16 \n\t" \
+- "bl _PrepareAndDispatch__FP14nsXPTCStubBaseUiPUi \n\t" \
+- "ldmea fp, {fp, sp, lr} \n\t" \
+- "add sp, sp, #12 \n\t" \
+- "mov pc, lr \n\t" \
+-);
+
+ #define SENTINEL_ENTRY(n) \
+ nsresult nsXPTCStubBase::Sentinel##n() \
diff --git a/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcstubs__asm__mips.S b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcstubs__asm__mips.S
new file mode 100644
index 00000000000..096c52d976f
--- /dev/null
+++ b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcstubs__asm__mips.S
@@ -0,0 +1,52 @@
+$NetBSD: patch-xpcom_reflect_xptcall_md_unix_xptcstubs__asm__mips.S,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- xpcom/reflect/xptcall/md/unix/xptcstubs_asm_mips.S.orig 2014-10-11 09:06:50.000000000 +0000
++++ xpcom/reflect/xptcall/md/unix/xptcstubs_asm_mips.S
+@@ -14,6 +14,47 @@
+ #include <sys/asm.h>
+ #endif
+
++#ifdef __NetBSD__
++# include <machine/regdef.h>
++# include <machine/asm.h>
++# ifndef fp
++# define fp s8
++# endif
++# ifndef PTRLOG
++# if SZREG == 4
++# define PTRLOG 2
++# else
++# define PTRLOG 3
++# endif
++# endif
++# ifndef SETUP_GP
++# if defined(__mips_o32)
++# define SETUP_GP \
++ .set push; \
++ .set noreorder; \
++ .cpload t9; \
++ .set pop
++# define SAVE_GP(x) \
++ .cprestore x
++# else
++# define SETUP_GP
++# define SAVE_GP(x)
++# endif
++# endif
++# ifndef ALSZ
++# if defined(__mips_n32) || defined(__mips_n64)
++# define ALSZ 15
++# define ALMASK ~15
++# else
++# define ALSZ 7
++# define ALMASK ~7
++# endif
++# endif
++#else
++# include <sys/regdef.h>
++# include <sys/asm.h>
++#endif
++
+ # NARGSAVE is the argument space in the callers frame, including extra
+ # 'shadowed' space for the argument registers. The minimum of 4
+ # argument slots is sometimes predefined in the header files.
diff --git a/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcstubs__asm__sparc64__netbsd.s b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcstubs__asm__sparc64__netbsd.s
new file mode 100644
index 00000000000..03ab133df3e
--- /dev/null
+++ b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcstubs__asm__sparc64__netbsd.s
@@ -0,0 +1,71 @@
+$NetBSD: patch-xpcom_reflect_xptcall_md_unix_xptcstubs__asm__sparc64__netbsd.s,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- xpcom/reflect/xptcall/md/unix/xptcstubs_asm_sparc64_netbsd.s.orig 2014-10-14 18:49:14.000000000 +0000
++++ xpcom/reflect/xptcall/md/unix/xptcstubs_asm_sparc64_netbsd.s
+@@ -0,0 +1,66 @@
++/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
++ *
++ * The contents of this file are subject to the Netscape Public
++ * License Version 1.1 (the "License"); you may not use this file
++ * except in compliance with the License. You may obtain a copy of
++ * the License at http://www.mozilla.org/NPL/
++ *
++ * Software distributed under the License is distributed on an "AS
++ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
++ * implied. See the License for the specific language governing
++ * rights and limitations under the License.
++ *
++ * The Original Code is mozilla.org code.
++ *
++ * The Initial Developer of the Original Code is Netscape
++ * Communications Corporation. Portions created by Netscape are
++ * Copyright (C) 1999 Netscape Communications Corporation. All
++ * Rights Reserved.
++ *
++ * Contributor(s):
++ */
++
++ .global SharedStub
++
++/*
++ in the frame for the function that called SharedStub are the
++ rest of the parameters we need
++
++*/
++
++SharedStub:
++! we don't create a new frame yet, but work within the frame of the calling
++! function to give ourselves the other parameters we want
++
++ mov %o0, %o1 ! shuffle the index up to 2nd place
++ mov %i0, %o0 ! the original 'this'
++ add %fp, 0x7ff + 136, %o2 ! previous stack top adjusted to the first argument slot (beyond 'this')
++
++! save off the original incoming parameters that arrived in
++! registers, the ABI guarantees the space for us to do this
++ stx %i1, [%fp + 0x7ff + 136]
++ stx %i2, [%fp + 0x7ff + 144]
++ stx %i3, [%fp + 0x7ff + 152]
++ stx %i4, [%fp + 0x7ff + 160]
++ stx %i5, [%fp + 0x7ff + 168]
++! now we can build our own stack frame
++ save %sp,-(128 + 64),%sp ! room for the register window and
++ ! struct pointer, rounded up to 0 % 64
++! our function now appears to have been called
++! as SharedStub(nsISupports* that, PRUint32 index, PRUint32* args)
++! so we can just copy these through
++
++ mov %i0, %o0
++ mov %i1, %o1
++ mov %i2, %o2
++ call PrepareAndDispatch
++ nop
++ mov %o0,%i0 ! propagate return value
++ b .LL1
++ nop
++.LL1:
++ ret
++ restore
++
++ .size SharedStub, .-SharedStub
++ .type SharedStub, #function
diff --git a/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcstubs__netbsd__m68k.cpp b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcstubs__netbsd__m68k.cpp
new file mode 100644
index 00000000000..98ad77a1092
--- /dev/null
+++ b/www/firefox52/patches/patch-xpcom_reflect_xptcall_md_unix_xptcstubs__netbsd__m68k.cpp
@@ -0,0 +1,41 @@
+$NetBSD: patch-xpcom_reflect_xptcall_md_unix_xptcstubs__netbsd__m68k.cpp,v 1.1 2017/04/27 01:55:57 ryoon Exp $
+
+--- xpcom/reflect/xptcall/md/unix/xptcstubs_netbsd_m68k.cpp.orig 2014-10-11 09:06:50.000000000 +0000
++++ xpcom/reflect/xptcall/md/unix/xptcstubs_netbsd_m68k.cpp
+@@ -91,17 +91,27 @@ extern "C" {
+ }
+ }
+
++/*
++ * Beware: use % instead of %% for register identifiers in a preprocessor macro
++ * SYMBOL PREFIX must be "_" for aout and "" for ELF
++ */
++#ifndef __ELF__
++#define SYMBOLPREFIX "_"
++#else
++#define SYMBOLPREFIX
++#endif
++
+ #define STUB_ENTRY(n) \
+ __asm__( \
+- ".global _Stub"#n"__14nsXPTCStubBase\n\t" \
+-"_Stub"#n"__14nsXPTCStubBase:\n\t" \
+- "link a6,#0 \n\t" \
+- "lea a6@(12), a0 \n\t" /* pointer to args */ \
+- "movl a0, sp@- \n\t" \
+- "movl #"#n", sp@- \n\t" /* method index */ \
+- "movl a6@(8), sp@- \n\t" /* this */ \
+- "jbsr _PrepareAndDispatch \n\t" \
+- "unlk a6 \n\t" \
++ ".global "SYMBOLPREFIX"Stub"#n"__14nsXPTCStubBase\n\t" \
++SYMBOLPREFIX"Stub"#n"__14nsXPTCStubBase:\n\t" \
++ "link %a6,#0 \n\t" \
++ "lea %a6@(12), %a0 \n\t" /* pointer to args */ \
++ "movl %a0, %sp@- \n\t" \
++ "movl #"#n", %sp@- \n\t" /* method index */ \
++ "movl %a6@(8), %sp@- \n\t" /* this */ \
++ "jbsr "SYMBOLPREFIX"PrepareAndDispatch\n\t" \
++ "unlk %a6 \n\t" \
+ "rts \n\t" \
+ );
+