pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/mail/thunderbird115
Module Name: pkgsrc
Committed By: ryoon
Date: Tue Oct 1 14:21:38 UTC 2024
Added Files:
pkgsrc/mail/thunderbird115: DESCR Makefile PLIST distinfo
mozilla-common.mk options.mk
pkgsrc/mail/thunderbird115/files: cubeb_sun.c desktop.in
patch-ipc_src_Makefile
third__party_rust_encoding__rs_.cargo-checksum.json
pkgsrc/mail/thunderbird115/patches:
patch-browser_app_profile_firefox.js
patch-build_moz.configure_init.configure
patch-build_moz.configure_rust.configure
patch-comm_third__party_botan_configure.py
patch-comm_third__party_libgcrypt_configure
patch-config_gcc-stl-wrapper.template.h
patch-config_makefiles_rust.mk patch-dom_base_nsAttrName.h
patch-dom_webtransport_api_WebTransportDatagramDuplexStream.cpp
patch-gfx_angle_checkout_src_common_third__party_smhasher_src_PMurHash.cpp
patch-gfx_angle_checkout_src_compiler_translator_InfoSink.h
patch-gfx_cairo_cairo_src_cairo-type1-subset.c
patch-gfx_skia_skia_src_core_SkCpu.cpp
patch-ipc_chromium_src_base_message__pump__libevent.cc
patch-ipc_chromium_src_base_platform__thread__posix.cc
patch-ipc_glue_GeckoChildProcessHost.cpp patch-js_public_Utility.h
patch-js_src_jsfriendapi.h patch-js_src_util_NativeStack.cpp
patch-llvm18 patch-media_ffvpx_libavutil_arm_bswap.h
patch-media_libcubeb_src_cubeb__sun.c patch-media_libpng_pngpriv.h
patch-media_libtheora_lib_info.c
patch-nsprpub_pr_src_pthreads_ptsynch.c patch-old-configure.in
patch-rust-1.78.0 patch-security_nss_lib_freebl_mpi_mpi.c
patch-servo_components_style__traits_values.rs
patch-servo_ports_geckolib_cbindgen.toml
patch-third__party_libwebrtc_modules_video__capture_linux_device__info__v4l2.cc
patch-third__party_rust_libc_src_unix_bsd_netbsdlike_netbsd_mod.rs
patch-third__party_sqlite3_src_moz.build
patch-third__party_wasm2c_src_prebuilt_wasm2c__source__includes.cc
patch-toolkit_components_terminator_nsTerminator.cpp
patch-toolkit_modules_subprocess_subprocess__shared__unix.js
patch-toolkit_moz.configure
patch-toolkit_mozapps_installer_packager.mk
patch-widget_gtk_DMABufSurface.cpp patch-xpcom_base_nscore.h
Log Message:
mail/thunderbird115: import thunderbird115-115.15.0
Thunderbird is a free email, news, and chat application with support for
add-ons, derived from the Mozilla Firefox web browser.
This package tracks 115 ESR release branch.
To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 pkgsrc/mail/thunderbird115/DESCR \
pkgsrc/mail/thunderbird115/Makefile pkgsrc/mail/thunderbird115/PLIST \
pkgsrc/mail/thunderbird115/distinfo \
pkgsrc/mail/thunderbird115/mozilla-common.mk \
pkgsrc/mail/thunderbird115/options.mk
cvs rdiff -u -r0 -r1.1 pkgsrc/mail/thunderbird115/files/cubeb_sun.c \
pkgsrc/mail/thunderbird115/files/desktop.in \
pkgsrc/mail/thunderbird115/files/patch-ipc_src_Makefile \
pkgsrc/mail/thunderbird115/files/third__party_rust_encoding__rs_.cargo-checksum.json
cvs rdiff -u -r0 -r1.1 \
pkgsrc/mail/thunderbird115/patches/patch-browser_app_profile_firefox.js \
pkgsrc/mail/thunderbird115/patches/patch-build_moz.configure_init.configure \
pkgsrc/mail/thunderbird115/patches/patch-build_moz.configure_rust.configure \
pkgsrc/mail/thunderbird115/patches/patch-comm_third__party_botan_configure.py \
pkgsrc/mail/thunderbird115/patches/patch-comm_third__party_libgcrypt_configure \
pkgsrc/mail/thunderbird115/patches/patch-config_gcc-stl-wrapper.template.h \
pkgsrc/mail/thunderbird115/patches/patch-config_makefiles_rust.mk \
pkgsrc/mail/thunderbird115/patches/patch-dom_base_nsAttrName.h \
pkgsrc/mail/thunderbird115/patches/patch-dom_webtransport_api_WebTransportDatagramDuplexStream.cpp \
pkgsrc/mail/thunderbird115/patches/patch-gfx_angle_checkout_src_common_third__party_smhasher_src_PMurHash.cpp \
pkgsrc/mail/thunderbird115/patches/patch-gfx_angle_checkout_src_compiler_translator_InfoSink.h \
pkgsrc/mail/thunderbird115/patches/patch-gfx_cairo_cairo_src_cairo-type1-subset.c \
pkgsrc/mail/thunderbird115/patches/patch-gfx_skia_skia_src_core_SkCpu.cpp \
pkgsrc/mail/thunderbird115/patches/patch-ipc_chromium_src_base_message__pump__libevent.cc \
pkgsrc/mail/thunderbird115/patches/patch-ipc_chromium_src_base_platform__thread__posix.cc \
pkgsrc/mail/thunderbird115/patches/patch-ipc_glue_GeckoChildProcessHost.cpp \
pkgsrc/mail/thunderbird115/patches/patch-js_public_Utility.h \
pkgsrc/mail/thunderbird115/patches/patch-js_src_jsfriendapi.h \
pkgsrc/mail/thunderbird115/patches/patch-js_src_util_NativeStack.cpp \
pkgsrc/mail/thunderbird115/patches/patch-llvm18 \
pkgsrc/mail/thunderbird115/patches/patch-media_ffvpx_libavutil_arm_bswap.h \
pkgsrc/mail/thunderbird115/patches/patch-media_libcubeb_src_cubeb__sun.c \
pkgsrc/mail/thunderbird115/patches/patch-media_libpng_pngpriv.h \
pkgsrc/mail/thunderbird115/patches/patch-media_libtheora_lib_info.c \
pkgsrc/mail/thunderbird115/patches/patch-nsprpub_pr_src_pthreads_ptsynch.c \
pkgsrc/mail/thunderbird115/patches/patch-old-configure.in \
pkgsrc/mail/thunderbird115/patches/patch-rust-1.78.0 \
pkgsrc/mail/thunderbird115/patches/patch-security_nss_lib_freebl_mpi_mpi.c \
pkgsrc/mail/thunderbird115/patches/patch-servo_components_style__traits_values.rs \
pkgsrc/mail/thunderbird115/patches/patch-servo_ports_geckolib_cbindgen.toml \
pkgsrc/mail/thunderbird115/patches/patch-third__party_libwebrtc_modules_video__capture_linux_device__info__v4l2.cc \
pkgsrc/mail/thunderbird115/patches/patch-third__party_rust_libc_src_unix_bsd_netbsdlike_netbsd_mod.rs \
pkgsrc/mail/thunderbird115/patches/patch-third__party_sqlite3_src_moz.build \
pkgsrc/mail/thunderbird115/patches/patch-third__party_wasm2c_src_prebuilt_wasm2c__source__includes.cc \
pkgsrc/mail/thunderbird115/patches/patch-toolkit_components_terminator_nsTerminator.cpp \
pkgsrc/mail/thunderbird115/patches/patch-toolkit_modules_subprocess_subprocess__shared__unix.js \
pkgsrc/mail/thunderbird115/patches/patch-toolkit_moz.configure \
pkgsrc/mail/thunderbird115/patches/patch-toolkit_mozapps_installer_packager.mk \
pkgsrc/mail/thunderbird115/patches/patch-widget_gtk_DMABufSurface.cpp \
pkgsrc/mail/thunderbird115/patches/patch-xpcom_base_nscore.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Added files:
Index: pkgsrc/mail/thunderbird115/DESCR
diff -u /dev/null pkgsrc/mail/thunderbird115/DESCR:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/DESCR Tue Oct 1 14:21:36 2024
@@ -0,0 +1,2 @@
+Thunderbird is a free email, news, and chat application with support for
+add-ons, derived from the Mozilla Firefox web browser.
Index: pkgsrc/mail/thunderbird115/Makefile
diff -u /dev/null pkgsrc/mail/thunderbird115/Makefile:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/Makefile Tue Oct 1 14:21:36 2024
@@ -0,0 +1,132 @@
+# $NetBSD: Makefile,v 1.1 2024/10/01 14:21:36 ryoon Exp $
+
+DISTNAME= thunderbird-${TB_VER}.source
+PKGNAME= thunderbird115-${TB_VER}
+TB_VER= 115.15.0
+CATEGORIES= mail
+MASTER_SITES= ${MASTER_SITE_MOZILLA:=thunderbird/releases/${TB_VER}/source/}
+EXTRACT_SUFX= .tar.xz
+
+MAINTAINER= pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE= https://www.thunderbird.net/en-US/
+COMMENT= Organize, secure and customize your mail
+LICENSE= mpl-1.1
+
+# As of 2023-08 on netbsd-10 amd64, this package required 22G of space
+# in WRKDIR (noted because it is egregiously and unexpectedly large,
+# overflowing even a biggish tmpfs).
+
+USE_TOOLS+= unzip pax
+WRKSRC= ${WRKDIR}/${DISTNAME:S/.source//}
+MOZILLA_DIR= # empty
+PLIST_SRC+= ${PLIST_SRC_DFLT}
+
+DEPENDS+= libotr-[0-9]*:../../chat/libotr
+
+ALL_ENV+= MOZ_APP_NAME=${MOZILLA_NAME}
+
+CONFIG_GUESS_OVERRIDE+= comm/ldap/sdks/c-sdk/config/autoconf/config.guess
+CONFIG_SUB_OVERRIDE+= comm/ldap/sdks/c-sdk/config/autoconf/config.sub
+
+CONFIGURE_ARGS+= --enable-application=comm/mail
+# Disable WebRTC support for Thunderbird unconditionally.
+CONFIGURE_ARGS+= --disable-webrtc
+CONFIGURE_ARGS+= --with-app-name=${MOZILLA_NAME}
+
+NOT_PAX_MPROTECT_SAFE+= lib/${MOZILLA_NAME}/${MOZILLA_NAME}
+NOT_PAX_MPROTECT_SAFE+= lib/${MOZILLA_NAME}/${MOZILLA_NAME}-bin
+
+LDFLAGS+= ${COMPILER_RPATH_FLAG}${PREFIX}/lib/${MOZILLA_NAME}
+
+# Workaround for https://bugs.llvm.org/show_bug.cgi?id=46366
+BUILDLINK_TRANSFORM.NetBSD+= rm:-fexperimental-new-pass-manager
+
+BUILDLINK_TRANSFORM.SunOS+= rm:-Wl,-rpath-link,${WRKDIR}/build/dist/bin
+BUILDLINK_TRANSFORM.SunOS+= rm:-Wl,-rpath-link,${PREFIX}/lib
+
+.include "../../mk/bsd.prefs.mk"
+
+CHECK_WRKREF_SKIP+= lib/${MOZILLA_NAME}/omni.ja
+
+#
+# Generate list of subst entries for various .cargo-checksum.json files. These
+# are all handled together in one big substitution to simplify things rather
+# than one substitution entry per file, but are kept separate below to ease
+# updating and verification.
+#
+
+CKSUM_CRATES+= third_party/rust/libc
+
+# patch-third__party_rust_libc_src_unix_bsd_netbsdlike_netbsd_mod.rs
+CKSUMS+= 107a4aa396b8383c66e0ace2f941450b4b69146558cdc4d9fbe33eeab51760f1
+CKSUMS+= 3aa5bbc6bec675641c8cb02342022256435ea4f958bfa3832344dba6847ba5ea
+
+#CKSUM_CRATES+= third_party/rust/getrandom
+
+# patch-third__party_rust_getrandom_src_lib.rs
+#CKSUMS+= 0e52f6bde42d7bb05c297ce1c25b9879d61b28caba98f6226a152bff538db6c2
+#CKSUMS+= 394425b4ba03c21c494e64d993678f7014575b1e3d590b9ee452b5c2d83ec4ac
+
+SUBST_CLASSES+= cksum
+SUBST_STAGE.cksum= pre-configure
+.for crate in ${CKSUM_CRATES}
+SUBST_FILES.cksum+= ${crate}/.cargo-checksum.json
+.endfor
+.for from to in ${CKSUMS}
+SUBST_SED.cksum+= -e 's,${from},${to},g'
+.endfor
+
+SUBST_CLASSES+= netbsdtag
+SUBST_STAGE.netbsdtag= pre-configure
+SUBST_FILES.netbsdtag= comm/third_party/rnp/src/librekey/key_store_pgp.cpp
+SUBST_SED.netbsdtag= -e 's/__NetBSD__/__NEVER__/'
+
+SUBST_CLASSES+= rust178
+SUBST_STAGE.rust178= pre-configure
+SUBST_MESSAGE.rust178= Clearing cargo checksums
+SUBST_FILES.rust178= third_party/rust/bindgen/.cargo-checksum.json
+SUBST_FILES.rust178+= third_party/rust/any_all_workaround/.cargo-checksum.json
+SUBST_FILES.rust178+= third_party/rust/encoding_rs/.cargo-checksum.json
+SUBST_SED.rust178= -e 's/\("files":{\)[^}]*/\1/'
+
+post-extract:
+ ${CP} ${FILESDIR}/cubeb_sun.c ${WRKSRC}/media/libcubeb/src/cubeb_sun.c
+ # patch(1) of NetBSD 9 cannot handle long line.
+ ${CP} ${FILESDIR}/third__party_rust_encoding__rs_.cargo-checksum.json \
+ ${WRKSRC}/third_party/rust/encoding_rs/.cargo-checksum.json
+
+pre-configure:
+ cd ${WRKSRC} && mkdir -p ${OBJDIR}
+# cd ${WRKSRC}${MOZILLA_DIR} && autoconf-2.13 old-configure.in > old-configure
+# cd ${WRKSRC}${MOZILLA_DIR}/js/src && autoconf-2.13 old-configure.in > old-configure
+ touch ${WRKSRC}/.mozconfig
+
+do-build:
+# XXX for some reason it doesn't work unless -j is explicitly specified
+ ${_ULIMIT_CMD} cd ${WRKSRC}/${OBJDIR} && ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} -j${_MAKE_JOBS_N:U1}
+
+MOZILLA= thunderbird115
+MOZILLA_NAME= ${PKGBASE}
+post-build:
+ ${SED} -e 's|@MOZILLA@|${MOZILLA}|g' \
+ -e 's|@MOZILLA_NAME@|${MOZILLA_NAME}|g' \
+ -e 's|@MOZILLA_ICON@|${MOZILLA_NAME}.png|g' \
+ < ${FILESDIR}/desktop.in \
+ > ${WRKDIR}/desktop
+
+INSTALLATION_DIRS+= lib/${MOZILLA_NAME}/extensions
+INSTALLATION_DIRS+= share/applications share/pixmaps
+post-install:
+ ${ECHO} '#! /bin/sh' > ${DESTDIR}${PREFIX}/bin/${MOZILLA_NAME}
+ ${ECHO} '${PREFIX}/lib/${MOZILLA_NAME}/${MOZILLA_NAME} "$$@"' >> \
+ ${DESTDIR}${PREFIX}/bin/${MOZILLA_NAME}
+ ${CHMOD} 755 ${DESTDIR}${PREFIX}/bin/${MOZILLA_NAME}
+ ${INSTALL_DATA} ${WRKDIR}/desktop \
+ ${DESTDIR}${PREFIX}/share/applications/${MOZILLA_NAME}.desktop
+ ${INSTALL_DATA} ${WRKSRC}/${OBJDIR}/dist/${MOZILLA_NAME}/chrome/icons/default/default48.png \
+ ${DESTDIR}${PREFIX}/share/pixmaps/${MOZILLA_NAME}.png
+
+.include "mozilla-common.mk"
+.include "options.mk"
+.include "../../sysutils/desktop-file-utils/desktopdb.mk"
+.include "../../mk/bsd.pkg.mk"
Index: pkgsrc/mail/thunderbird115/PLIST
diff -u /dev/null pkgsrc/mail/thunderbird115/PLIST:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/PLIST Tue Oct 1 14:21:36 2024
@@ -0,0 +1,46 @@
+@comment $NetBSD: PLIST,v 1.1 2024/10/01 14:21:36 ryoon Exp $
+bin/thunderbird115
+lib/thunderbird115/application.ini
+lib/thunderbird115/chrome/icons/default/calendar-alarm-dialog.png
+lib/thunderbird115/chrome/icons/default/calendar-general-dialog.png
+lib/thunderbird115/chrome/icons/default/default128.png
+lib/thunderbird115/chrome/icons/default/default16.png
+lib/thunderbird115/chrome/icons/default/default22.png
+lib/thunderbird115/chrome/icons/default/default24.png
+lib/thunderbird115/chrome/icons/default/default256.png
+lib/thunderbird115/chrome/icons/default/default32.png
+lib/thunderbird115/chrome/icons/default/default48.png
+lib/thunderbird115/chrome/icons/default/default64.png
+lib/thunderbird115/chrome/icons/default/msgcomposeWindow16.png
+lib/thunderbird115/chrome/icons/default/msgcomposeWindow24.png
+lib/thunderbird115/chrome/icons/default/msgcomposeWindow32.png
+lib/thunderbird115/chrome/icons/default/msgcomposeWindow48.png
+lib/thunderbird115/defaults/messenger/mailViews.dat
+lib/thunderbird115/defaults/pref/channel-prefs.js
+lib/thunderbird115/dependentlibs.list
+lib/thunderbird115/glxtest
+lib/thunderbird115/isp/Bogofilter.sfd
+lib/thunderbird115/isp/DSPAM.sfd
+lib/thunderbird115/isp/POPFile.sfd
+lib/thunderbird115/isp/SpamAssassin.sfd
+lib/thunderbird115/isp/SpamPal.sfd
+lib/thunderbird115/liblgpllibs.so
+lib/thunderbird115/libmozavcodec.so
+lib/thunderbird115/libmozavutil.so
+lib/thunderbird115/libmozgtk.so
+lib/thunderbird115/libmozsqlite3.so
+${PLIST.wayland}lib/thunderbird115/libmozwayland.so
+lib/thunderbird115/librnp.so
+lib/thunderbird115/libxul.so
+lib/thunderbird115/omni.ja
+lib/thunderbird115/pingsender
+lib/thunderbird115/platform.ini
+lib/thunderbird115/plugin-container
+lib/thunderbird115/removed-files
+lib/thunderbird115/rnp-cli
+lib/thunderbird115/rnpkeys
+lib/thunderbird115/thunderbird115
+lib/thunderbird115/thunderbird115-bin
+lib/thunderbird115/vaapitest
+share/applications/thunderbird115.desktop
+share/pixmaps/thunderbird115.png
Index: pkgsrc/mail/thunderbird115/distinfo
diff -u /dev/null pkgsrc/mail/thunderbird115/distinfo:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/distinfo Tue Oct 1 14:21:36 2024
@@ -0,0 +1,45 @@
+$NetBSD: distinfo,v 1.1 2024/10/01 14:21:36 ryoon Exp $
+
+BLAKE2s (thunderbird-115.15.0.source.tar.xz) = 22682e0f3cf826f9ac60bda6b8840309346ccd4890fb47be38b48a59f8d3cb5a
+SHA512 (thunderbird-115.15.0.source.tar.xz) = b161b99e09b6d1ba833f77264e35034ad199438b4fc88d244a6b68c84693fa2e90fbab60dafb827a2e23b37c484f9843a58751d93826ba7cdd0391114d253de2
+Size (thunderbird-115.15.0.source.tar.xz) = 534455612 bytes
+SHA1 (patch-browser_app_profile_firefox.js) = d53fae5544563888d030af7483f00283a712235c
+SHA1 (patch-build_moz.configure_init.configure) = 07cb75fad7c2f354b3d1e02e3f6e49cca119f20a
+SHA1 (patch-build_moz.configure_rust.configure) = 72c5fa2e9d1022325d038832cca2e35f7213116d
+SHA1 (patch-comm_third__party_botan_configure.py) = 262f560c514d221d0df15a1906100b5e716bfdab
+SHA1 (patch-comm_third__party_libgcrypt_configure) = c5ca8a8b44c485f81139b54d341ac044189d98d3
+SHA1 (patch-config_gcc-stl-wrapper.template.h) = ec0afe1b7d97dc0c305f9f7c197f9a7d7c32e629
+SHA1 (patch-config_makefiles_rust.mk) = def6fcd317cee79ed11c1606c3c63159750243b8
+SHA1 (patch-dom_base_nsAttrName.h) = 4e2326542d4dbba1ac2af5b33505267ee177b094
+SHA1 (patch-dom_webtransport_api_WebTransportDatagramDuplexStream.cpp) = b8ea4e8382fb03be6e31b3943a52a95f1a767954
+SHA1 (patch-gfx_angle_checkout_src_common_third__party_smhasher_src_PMurHash.cpp) = d08f170629dda585dc3e11706688527fe3dc0e78
+SHA1 (patch-gfx_angle_checkout_src_compiler_translator_InfoSink.h) = 8ddf031923ea7edfd8e51c5ff334870d531fecb5
+SHA1 (patch-gfx_cairo_cairo_src_cairo-type1-subset.c) = 6d5b8788d65e742515c4313113fb72372d093dcc
+SHA1 (patch-gfx_skia_skia_src_core_SkCpu.cpp) = 62d0d3a41fd0302c7b066ed60b15ed9db9f485de
+SHA1 (patch-ipc_chromium_src_base_message__pump__libevent.cc) = 9de765c6ba6ddf9db9161d10aac57ddbad20075c
+SHA1 (patch-ipc_chromium_src_base_platform__thread__posix.cc) = 64475f51534ac683c5b42bcbbd767db87d0ef87b
+SHA1 (patch-ipc_glue_GeckoChildProcessHost.cpp) = fa503231403a18e4ca6947fcd9985dcd28f83d0c
+SHA1 (patch-js_public_Utility.h) = 7e97b7feca65de88972286364aaa003ca690f4ad
+SHA1 (patch-js_src_jsfriendapi.h) = e013337469254e2a9e598bd070528f0f654acccb
+SHA1 (patch-js_src_util_NativeStack.cpp) = 338fdf6aa34101f6a41d07b303d4a8426c483d5b
+SHA1 (patch-llvm18) = d349d2f2311b95d42e92476b232b79bdd49cece4
+SHA1 (patch-media_ffvpx_libavutil_arm_bswap.h) = 5a7ad4d38165d49d44862ade846cb79de026867e
+SHA1 (patch-media_libcubeb_src_cubeb__sun.c) = 789312b0511f2667ab7ee581f066b6ecc129ad4f
+SHA1 (patch-media_libpng_pngpriv.h) = 5c49119b0e555c9daca64799ff03f3fa8fa05ded
+SHA1 (patch-media_libtheora_lib_info.c) = 96f3d3824459186476102a4598d07cf6f6a704ef
+SHA1 (patch-nsprpub_pr_src_pthreads_ptsynch.c) = 20b208c5ab4bfea5d49d79c19fc610867da0c4c7
+SHA1 (patch-old-configure.in) = d59d276124e1f95d9e144b8f7099abcf6de0489a
+SHA1 (patch-rust-1.78.0) = aa83482a831ab2ee8b38f57c1b7873719e5f8b5b
+SHA1 (patch-security_nss_lib_freebl_mpi_mpi.c) = 0cbf185955c77c9438ced0c294fbc8e4824797bf
+SHA1 (patch-servo_components_style__traits_values.rs) = 6e1efb51bd68168abfa960b5e2541b3f46a49bf0
+SHA1 (patch-servo_ports_geckolib_cbindgen.toml) = f87b82cf179651199599f7b8c5d4feaa11b1f781
+SHA1 (patch-third__party_libwebrtc_modules_video__capture_linux_device__info__v4l2.cc) = 8848fb05c1e8b45234f74db71602a8a84c0404a4
+SHA1 (patch-third__party_rust_libc_src_unix_bsd_netbsdlike_netbsd_mod.rs) = e9378a3868ddb628213c3a37e2177257c2344bc3
+SHA1 (patch-third__party_sqlite3_src_moz.build) = b26856a4b87aa12211575d9982f62dc899474b52
+SHA1 (patch-third__party_wasm2c_src_prebuilt_wasm2c__source__includes.cc) = 99d0db944f0c2d0c623460991efd423d9127c988
+SHA1 (patch-toolkit_components_terminator_nsTerminator.cpp) = f80a0844ca37dda91a8cf38d6a542f152657901a
+SHA1 (patch-toolkit_modules_subprocess_subprocess__shared__unix.js) = d718759e59910228cc3729e359f328b47aff5eb4
+SHA1 (patch-toolkit_moz.configure) = b6a367c34b0187ac2e731b3d6265eb145b82e2ca
+SHA1 (patch-toolkit_mozapps_installer_packager.mk) = 407fe861dd9b82a88a6f5c0ed1e519a3c0e67251
+SHA1 (patch-widget_gtk_DMABufSurface.cpp) = 719924359f9c25db2f7c8e9da1040197b3aae37e
+SHA1 (patch-xpcom_base_nscore.h) = 6e6f2d564d8d6121c178c2567cce8ac2ebe8610b
Index: pkgsrc/mail/thunderbird115/mozilla-common.mk
diff -u /dev/null pkgsrc/mail/thunderbird115/mozilla-common.mk:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/mozilla-common.mk Tue Oct 1 14:21:36 2024
@@ -0,0 +1,262 @@
+# $NetBSD: mozilla-common.mk,v 1.1 2024/10/01 14:21:36 ryoon Exp $
+#
+# common Makefile fragment for mozilla packages based on gecko 2.0.
+#
+# used by www/firefox/Makefile
+
+.include "../../mk/bsd.prefs.mk"
+
+PYTHON_VERSIONS_INCOMPATIBLE= 27
+PYTHON_FOR_BUILD_ONLY= tool
+ALL_ENV+= PYTHON3=${PYTHONBIN}
+
+REPLACE_PYTHON= build/cargo-linker
+
+HAS_CONFIGURE= yes
+CONFIGURE_ARGS+= --prefix=${PREFIX}
+USE_TOOLS+= pkg-config perl gmake gm4 unzip zip # autoconf213
+UNLIMIT_RESOURCES+= datasize virtualsize
+
+OVERRIDE_GNU_CONFIG_SCRIPTS= yes
+OVERRIDE_DIRDEPTH= 4
+
+USE_LANGUAGES+= c c++
+
+# XXX: As of 114.0.2
+# For nested constant initializer support in rlbox, requires 8.
+GCC_REQD+= 8
+# To find vscanf, vfscanf, isblank and so on under NetBSD 9.
+CFLAGS.NetBSD+= -D_NETBSD_SOURCE
+
+TOOL_DEPENDS+= cbindgen>=0.24.3:../../devel/cbindgen
+
+TOOL_DEPENDS+= nodejs-[0-9]*:../../lang/nodejs
+
+# malloc_usable_size()
+LDFLAGS.NetBSD+= -ljemalloc
+
+.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
+TOOL_DEPENDS+= nasm>=2.14:../../devel/nasm
+TOOL_DEPENDS+= yasm>=1.1:../../devel/yasm
+CFLAGS+= -msse2
+.endif
+
+# This is to work around build failures where an upstream configuration script
+# is confused by having more than one approximate match to MACHINE_GNU_PLATFORM
+# "i486" when attempting to select the Rust compiler target.
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-i386)
+CONFIGURE_ARGS+= --target=i586-unknown-netbsd
+CONFIGURE_ARGS+= --host=i586-unknown-netbsd
+.elif ${MACHINE_PLATFORM:MSunOS-*-x86_64}
+CONFIGURE_ARGS+= --host=x86_64-unknown-illumos
+CONFIGURE_ARGS+= --target=x86_64-unknown-illumos
+.else
+CONFIGURE_ARGS+= --target=${MACHINE_GNU_PLATFORM}
+CONFIGURE_ARGS+= --host=${MACHINE_GNU_PLATFORM}
+.endif
+
+CONFIGURE_ENV+= BINDGEN_CFLAGS="-isystem${PREFIX}/include/nspr \
+ -isystem${X11BASE}/include/pixman-1"
+
+do-test:
+ cd ${WRKSRC}/${OBJDIR}/dist/bin && \
+ ./run-mozilla.sh ${WRKSRC}/mach check-spidermonkey
+
+# tar(1) of OpenBSD 5.5 has no --exclude command line option.
+.if ${OPSYS} == "OpenBSD"
+TOOLS_PLATFORM.tar= ${TOOLS_PATH.bsdtar}
+USE_TOOLS+= bsdtar
+.else
+USE_TOOLS+= tar
+.endif
+
+.if ${MACHINE_ARCH} == "i386"
+# This is required for SSE2 code under i386.
+CFLAGS+= -mstackrealign
+.endif
+
+CHECK_PORTABILITY_SKIP+= ${MOZILLA_DIR}security/nss/tests/*/*.sh
+CHECK_PORTABILITY_SKIP+= ${MOZILLA_DIR}js/src/tests/update-test262.sh
+CHECK_PORTABILITY_SKIP+= ${MOZILLA_DIR}intl/icu/source/configure
+CHECK_PORTABILITY_SKIP+= ${MOZILLA_DIR}browser/components/loop/run-all-loop-tests.sh
+CHECK_PORTABILITY_SKIP+= ${MOZILLA_DIR}browser/extensions/loop/run-all-loop-tests.sh
+CHECK_PORTABILITY_SKIP+= ${MOZILLA_DIR}third_party/libwebrtc/tools_webrtc/iwyu/apply-iwyu
+
+CONFIGURE_ARGS+= --enable-release
+# Disable Rust SIMD option to fix build with lang/rust-1.33.0
+# This should be enabled later again.
+#CONFIGURE_ARGS+= --enable-rust-simd
+CONFIGURE_ARGS+= --disable-tests
+# Mozilla Bug 1432751
+#CONFIGURE_ARGS+= --enable-system-cairo
+CONFIGURE_ARGS+= --enable-system-pixman
+CONFIGURE_ARGS+= --with-system-libvpx
+CONFIGURE_ARGS+= --enable-system-ffi
+#CONFIGURE_ARGS+= --with-system-icu
+#CONFIGURE_ARGS+= --with-intl-api
+CONFIGURE_ARGS+= --without-system-icu
+CONFIGURE_ARGS+= --with-system-nss
+CONFIGURE_ARGS+= --with-system-nspr
+#CONFIGURE_ARGS+= --with-system-jpeg
+CONFIGURE_ARGS+= --with-system-zlib
+CONFIGURE_ARGS+= --with-system-libevent
+CONFIGURE_ARGS+= --disable-crashreporter
+CONFIGURE_ARGS+= --enable-chrome-format=omni
+CONFIGURE_ARGS+= --with-system-webp
+
+#CONFIGURE_ARGS+= --enable-readline
+CONFIGURE_ARGS+= --disable-icf
+CONFIGURE_ARGS+= --disable-updater
+
+.include "../../mk/compiler.mk"
+
+.if empty(PKGSRC_COMPILER:Mclang)
+# Set path to "clang for cbindgen" when target compiler is not clang.
+CONFIGURE_ARGS+= --with-clang-path=${PREFIX}/bin/clang
+.endif
+CONFIGURE_ARGS+= --with-libclang-path=${PREFIX}/lib
+
+# RLBox WASM sandbox
+.if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "i386"
+# For wasm-ld command
+TOOL_DEPENDS+= lld-[0-9]*:../../devel/lld
+.include "../../lang/wasi-libc/buildlink3.mk"
+.include "../../lang/wasi-libcxx/buildlink3.mk"
+.include "../../lang/wasi-compiler-rt/buildlink3.mk"
+CONFIGURE_ARGS+= --with-wasi-sysroot=${PREFIX}/wasi
+CONFIGURE_ENV+= WASM_CC=${PREFIX}/bin/clang
+CONFIGURE_ENV+= WASM_CXX=${PREFIX}/bin/clang++
+.else
+CONFIGURE_ARGS+= --without-wasm-sandboxed-libraries
+.endif
+
+.include "../../sysutils/pciutils/libname.mk"
+SUBST_CLASSES+= fix-libpci-soname
+SUBST_STAGE.fix-libpci-soname= pre-configure
+SUBST_MESSAGE.fix-libpci-soname= Fixing libpci soname
+SUBST_FILES.fix-libpci-soname+= ${MOZILLA_DIR}toolkit/xre/glxtest/glxtest.cpp
+SUBST_SED.fix-libpci-soname+= -e 's,"libpci.so, "lib${PCIUTILS_LIBNAME}.so,'
+
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-i386)
+SQLITE3OPTFLAG= '-O0',
+.else
+SQLITE3OPTFLAG= # empty
+.endif
+SUBST_CLASSES+= sqlite3-opt
+SUBST_STAGE.sqlite3-opt= pre-configure
+SUBST_MESSAGE.sqlite3-opt= Fixing segfault in libmozsqlite3.so
+SUBST_FILES.sqlite3-opt+= ${MOZILLA_DIR}third_party/sqlite3/src/moz.build
+SUBST_VARS.sqlite3-opt+= SQLITE3OPTFLAG
+
+# Do not pass '-j1 -j1' for MAKE_JOBS=1 for NetBSD 9.3 or earlier.
+RUST_MAKE_JOBS= # empty by default
+.if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} < 090400
+. if defined(MAKE_JOBS) && !empty(MAKE_JOBS) && !(defined(MAKE_JOBS_SAFE) && ${MAKE_JOBS_SAFE:U:tl} == no)
+. if ${MAKE_JOBS} > 1
+RUST_MAKE_JOBS= -j1 # for MAKE_JOBS=1, RUST_MAKE_JOBS should be empty.
+. endif
+. endif
+.endif
+
+SUBST_CLASSES+= njobs
+SUBST_STAGE.njobs= pre-configure
+SUBST_MESSAGE.njobs= Setting MAKE_JOBS for cairo
+SUBST_FILES.njobs+= ${MOZILLA_DIR}config/makefiles/rust.mk
+SUBST_VARS.njobs+= RUST_MAKE_JOBS
+
+# Workaround for link of libxul.so as of 96.0.
+# There are too many -ldl under third_paty/libwebrtc.
+.include "../../mk/dlopen.buildlink3.mk"
+BUILDLINK_TRANSFORM+= opt:-ldl:${BUILDLINK_LDADD.dl:Q}
+
+CONFIG_GUESS_OVERRIDE+= ${MOZILLA_DIR}build/autoconf/config.guess
+CONFIG_GUESS_OVERRIDE+= ${MOZILLA_DIR}js/src/build/autoconf/config.guess
+CONFIG_GUESS_OVERRIDE+= ${MOZILLA_DIR}nsprpub/build/autoconf/config.guess
+CONFIG_GUESS_OVERRIDE+= ${MOZILLA_DIR}/js/ctypes/libffi/config.guess
+CONFIG_SUB_OVERRIDE+= ${MOZILLA_DIR}build/autoconf/config.sub
+CONFIG_SUB_OVERRIDE+= ${MOZILLA_DIR}js/src/build/autoconf/config.sub
+CONFIG_SUB_OVERRIDE+= ${MOZILLA_DIR}nsprpub/build/autoconf/config.sub
+CONFIG_SUB_OVERRIDE+= ${MOZILLA_DIR}/js/ctypes/libffi/config.sub
+
+CONFIGURE_ENV+= CPP=${CPP:Q}
+ALL_ENV+= SHELL=${CONFIG_SHELL:Q}
+ALL_ENV+= MOZ_APP_NAME=${MOZILLA}
+
+# Build outside ${WRKSRC}
+# Try to avoid conflict with config/makefiles/xpidl/Makefile.in
+.if ${MAINTAINER_INTERNAL:Uno} == "yes"
+OBJDIR= ../no-node-build
+.else
+OBJDIR= ../build
+.endif
+CONFIGURE_DIRS= ${OBJDIR}
+CONFIGURE_SCRIPT= ${WRKSRC}/configure
+
+PLIST_VARS+= ffvpx
+
+.if ${MACHINE_ARCH} == "aarch64" || \
+ ${MACHINE_ARCH:M*arm*} || \
+ ${MACHINE_ARCH} == "i386" || \
+ ${MACHINE_ARCH} == "x86_64"
+PLIST.ffvpx= yes # see media/ffvpx/ffvpxcommon.mozbuild
+.endif
+
+# See ${WRKSRC}/security/sandbox/mac/Sandbox.mm: On Darwin, sandboxing
+# support is only available when the toolkit is cairo-cocoa.
+CONFIGURE_ARGS.Darwin+= --disable-sandbox
+
+# Makefiles sometimes call "rm -f" without more arguments. Kludge around ...
+.PHONY: create-rm-wrapper
+pre-configure: create-rm-wrapper
+create-rm-wrapper:
+ printf '#!/bin/sh\n[ "$$*" = "-f" ] && exit 0\nexec /bin/rm $$@\n' > \
+ ${WRAPPER_DIR}/bin/rm
+ chmod +x ${WRAPPER_DIR}/bin/rm
+
+# The configure test for __thread succeeds, but later we end up with:
+# dist/bin/libxul.so: undefined reference to `__tls_get_addr'
+CONFIGURE_ENV.NetBSD+= ac_cv_thread_keyword=no
+# In unspecified case, clock_gettime(CLOCK_MONOTONIC, ...) fails.
+CONFIGURE_ENV.NetBSD+= ac_cv_clock_monotonic=
+
+.include "../../sysutils/pciutils/buildlink3.mk"
+.include "../../mk/atomic64.mk"
+BUILDLINK_API_DEPENDS.libevent+= libevent>=1.1
+.include "../../devel/libevent/buildlink3.mk"
+.include "../../devel/libffi/buildlink3.mk"
+BUILDLINK_API_DEPENDS.nspr+= nspr>=4.34
+.include "../../devel/nspr/buildlink3.mk"
+#.include "../../textproc/icu/buildlink3.mk"
+BUILDLINK_API_DEPENDS.nss+= nss>=3.90
+.include "../../devel/nss/buildlink3.mk"
+.include "../../devel/zlib/buildlink3.mk"
+#.include "../../mk/jpeg.buildlink3.mk"
+.include "../../graphics/MesaLib/buildlink3.mk"
+#BUILDLINK_API_DEPENDS.cairo+= cairo>=1.10.2nb4
+#.include "../../graphics/cairo/buildlink3.mk"
+BUILDLINK_API_DEPENDS.libwebp+= libwebp>=1.0.2
+.include "../../graphics/libwebp/buildlink3.mk"
+BUILDLINK_DEPMETHOD.clang= build
+.include "../../lang/clang/buildlink3.mk"
+RUST_REQ= 1.66.0
+.include "../../lang/rust/rust.mk"
+.include "../../multimedia/libvpx/buildlink3.mk"
+.include "../../net/libIDL/buildlink3.mk"
+# TODO: check again, pkgsrc has hunspell 1.7
+# was: textproc/hunspell 1.3 is too old
+#.include "../../textproc/hunspell/buildlink3.mk"
+.include "../../multimedia/ffmpeg6/buildlink3.mk"
+.include "../../x11/libXt/buildlink3.mk"
+.include "../../x11/libXtst/buildlink3.mk"
+BUILDLINK_API_DEPENDS.pixman+= pixman>=0.25.2
+.include "../../x11/pixman/buildlink3.mk"
+.include "../../x11/gtk3/buildlink3.mk"
+PLIST_VARS+= wayland
+.if ${PKG_BUILD_OPTIONS.gtk3:Mwayland}
+CONFIGURE_ARGS+= --enable-default-toolkit=cairo-gtk3-x11-wayland
+PLIST.wayland= yes
+.else
+CONFIGURE_ARGS+= --enable-default-toolkit=cairo-gtk3
+.endif
+.include "../../lang/python/batteries-included.mk"
+.include "../../lang/python/application.mk"
Index: pkgsrc/mail/thunderbird115/options.mk
diff -u /dev/null pkgsrc/mail/thunderbird115/options.mk:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/options.mk Tue Oct 1 14:21:36 2024
@@ -0,0 +1,65 @@
+# $NetBSD: options.mk,v 1.1 2024/10/01 14:21:36 ryoon Exp $
+
+PKG_OPTIONS_VAR= PKG_OPTIONS.thunderbird115
+
+PKG_SUPPORTED_OPTIONS= alsa dbus debug mozilla-jemalloc \
+ official-mozilla-branding pulseaudio
+
+PLIST_VARS+= debug jemalloc
+
+.if ${OPSYS} == "Linux"
+PKG_SUGGESTED_OPTIONS+= alsa pulseaudio mozilla-jemalloc dbus
+.else
+PKG_SUGGESTED_OPTIONS+= dbus
+.endif
+
+.include "../../mk/bsd.options.mk"
+
+.if !empty(PKG_OPTIONS:Malsa)
+CONFIGURE_ARGS+= --enable-alsa
+.include "../../audio/alsa-lib/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-alsa
+.endif
+
+.if !empty(PKG_OPTIONS:Mmozilla-jemalloc)
+PLIST.jemalloc= yes
+CONFIGURE_ARGS+= --enable-jemalloc
+.else
+CONFIGURE_ARGS+= --disable-jemalloc
+.endif
+
+.if !empty(PKG_OPTIONS:Mdebug)
+CONFIGURE_ARGS+= --enable-debug --enable-debug-symbols --disable-optimize
+CONFIGURE_ARGS+= --disable-install-strip
+PLIST.debug= yes
+.else
+CONFIGURE_ARGS+= --disable-debug
+CONFIGURE_ARGS+= --enable-optimize=-O2
+CONFIGURE_ARGS+= --enable-install-strip
+BUILDLINK_TRANSFORM+= rm:-g
+.endif
+
+.if !empty(PKG_OPTIONS:Mpulseaudio)
+.include "../../audio/pulseaudio/buildlink3.mk"
+CONFIGURE_ARGS+= --enable-pulseaudio
+.else
+CONFIGURE_ARGS+= --disable-pulseaudio
+.endif
+
+.if !empty(PKG_OPTIONS:Mdbus)
+.include "../../sysutils/dbus-glib/buildlink3.mk"
+CONFIGURE_ARGS+= --enable-dbus
+.else
+CONFIGURE_ARGS+= --disable-dbus
+.endif
+
+.if !empty(PKG_OPTIONS:Mofficial-mozilla-branding)
+CONFIGURE_ARGS+= --enable-official-branding
+LICENSE= mozilla-trademark-license
+RESTRICTED= Trademark holder prohibits distribution of modified versions.
+NO_BIN_ON_CDROM= ${RESTRICTED}
+NO_BIN_ON_FTP= ${RESTRICTED}
+.else
+CONFIGURE_ARGS+= --disable-official-branding
+.endif
Index: pkgsrc/mail/thunderbird115/files/cubeb_sun.c
diff -u /dev/null pkgsrc/mail/thunderbird115/files/cubeb_sun.c:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/files/cubeb_sun.c Tue Oct 1 14:21:36 2024
@@ -0,0 +1,752 @@
+/*
+ * Copyright © 2019 Nia Alarie
+ *
+ * This program is made available under an ISC-style license. See the
+ * accompanying file LICENSE for details.
+ */
+#include <sys/audioio.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include "cubeb/cubeb.h"
+#include "cubeb-internal.h"
+
+#define BYTES_TO_FRAMES(bytes, channels) \
+ (bytes / (channels * sizeof(int16_t)))
+
+#define FRAMES_TO_BYTES(frames, channels) \
+ (frames * (channels * sizeof(int16_t)))
+
+/* Default to 4 + 1 for the default device. */
+#ifndef SUN_DEVICE_COUNT
+#define SUN_DEVICE_COUNT (5)
+#endif
+
+/* Supported well by most hardware. */
+#ifndef SUN_PREFER_RATE
+#define SUN_PREFER_RATE (48000)
+#endif
+
+/* Standard acceptable minimum. */
+#ifndef SUN_LATENCY_MS
+#define SUN_LATENCY_MS (40)
+#endif
+
+#ifndef SUN_DEFAULT_DEVICE
+#define SUN_DEFAULT_DEVICE "/dev/audio"
+#endif
+
+#ifndef SUN_POLL_TIMEOUT
+#define SUN_POLL_TIMEOUT (1000)
+#endif
+
+#ifndef SUN_BUFFER_FRAMES
+#define SUN_BUFFER_FRAMES (32)
+#endif
+
+/*
+ * Supported on NetBSD regardless of hardware.
+ */
+
+#ifndef SUN_MAX_CHANNELS
+# ifdef __NetBSD__
+# define SUN_MAX_CHANNELS (12)
+# else
+# define SUN_MAX_CHANNELS (2)
+# endif
+#endif
+
+#ifndef SUN_MIN_RATE
+#define SUN_MIN_RATE (1000)
+#endif
+
+#ifndef SUN_MAX_RATE
+#define SUN_MAX_RATE (192000)
+#endif
+
+static struct cubeb_ops const sun_ops;
+
+struct cubeb {
+ struct cubeb_ops const * ops;
+};
+
+struct cubeb_stream {
+ struct cubeb * context;
+ void * user_ptr;
+ pthread_t thread;
+ pthread_mutex_t mutex; /* protects running, volume, frames_written */
+ int floating;
+ int running;
+ int play_fd;
+ int record_fd;
+ float volume;
+ struct audio_info p_info; /* info for the play fd */
+ struct audio_info r_info; /* info for the record fd */
+ cubeb_data_callback data_cb;
+ cubeb_state_callback state_cb;
+ int16_t * play_buf;
+ int16_t * record_buf;
+ float * f_play_buf;
+ float * f_record_buf;
+ char input_name[32];
+ char output_name[32];
+ uint64_t frames_written;
+ uint64_t blocks_written;
+};
+
+int
+sun_init(cubeb ** context, char const * context_name)
+{
+ cubeb * c;
+
+ (void)context_name;
+ if ((c = calloc(1, sizeof(cubeb))) == NULL) {
+ return CUBEB_ERROR;
+ }
+ c->ops = &sun_ops;
+ *context = c;
+ return CUBEB_OK;
+}
+
+static void
+sun_destroy(cubeb * context)
+{
+ free(context);
+}
+
+static char const *
+sun_get_backend_id(cubeb * context)
+{
+ return "sun";
+}
+
+static int
+sun_get_preferred_sample_rate(cubeb * context, uint32_t * rate)
+{
+ (void)context;
+
+ *rate = SUN_PREFER_RATE;
+ return CUBEB_OK;
+}
+
+static int
+sun_get_max_channel_count(cubeb * context, uint32_t * max_channels)
+{
+ (void)context;
+
+ *max_channels = SUN_MAX_CHANNELS;
+ return CUBEB_OK;
+}
+
+static int
+sun_get_min_latency(cubeb * context, cubeb_stream_params params,
+ uint32_t * latency_frames)
+{
+ (void)context;
+
+ *latency_frames = SUN_LATENCY_MS * params.rate / 1000;
+ return CUBEB_OK;
+}
+
+static int
+sun_get_hwinfo(const char * device, struct audio_info * format,
+ int * props, struct audio_device * dev)
+{
+ int fd = -1;
+
+ if ((fd = open(device, O_RDONLY)) == -1) {
+ goto error;
+ }
+#ifdef AUDIO_GETFORMAT
+ if (ioctl(fd, AUDIO_GETFORMAT, format) != 0) {
+ goto error;
+ }
+#endif
+#ifdef AUDIO_GETPROPS
+ if (ioctl(fd, AUDIO_GETPROPS, props) != 0) {
+ goto error;
+ }
+#endif
+ if (ioctl(fd, AUDIO_GETDEV, dev) != 0) {
+ goto error;
+ }
+ close(fd);
+ return CUBEB_OK;
+error:
+ if (fd != -1) {
+ close(fd);
+ }
+ return CUBEB_ERROR;
+}
+
+/*
+ * XXX: PR kern/54264
+ */
+static int
+sun_prinfo_verify_sanity(struct audio_prinfo * prinfo)
+{
+ return prinfo->precision >= 8 && prinfo->precision <= 32 &&
+ prinfo->channels >= 1 && prinfo->channels < SUN_MAX_CHANNELS &&
+ prinfo->sample_rate < SUN_MAX_RATE && prinfo->sample_rate > SUN_MIN_RATE;
+}
+
+static int
+sun_enumerate_devices(cubeb * context, cubeb_device_type type,
+ cubeb_device_collection * collection)
+{
+ unsigned i;
+ cubeb_device_info device = {0};
+ char dev[16] = SUN_DEFAULT_DEVICE;
+ char dev_friendly[64];
+ struct audio_info hwfmt;
+ struct audio_device hwname;
+ struct audio_prinfo *prinfo = NULL;
+ int hwprops;
+
+ collection->device = calloc(SUN_DEVICE_COUNT, sizeof(cubeb_device_info));
+ if (collection->device == NULL) {
+ return CUBEB_ERROR;
+ }
+ collection->count = 0;
+
+ for (i = 0; i < SUN_DEVICE_COUNT; ++i) {
+ if (i > 0) {
+ (void)snprintf(dev, sizeof(dev), "/dev/audio%u", i - 1);
+ }
+ if (sun_get_hwinfo(dev, &hwfmt, &hwprops, &hwname) != CUBEB_OK) {
+ continue;
+ }
+#ifdef AUDIO_GETPROPS
+ device.type = 0;
+ if ((hwprops & AUDIO_PROP_CAPTURE) != 0 &&
+ sun_prinfo_verify_sanity(&hwfmt.record)) {
+ /* the device supports recording, probably */
+ device.type |= CUBEB_DEVICE_TYPE_INPUT;
+ }
+ if ((hwprops & AUDIO_PROP_PLAYBACK) != 0 &&
+ sun_prinfo_verify_sanity(&hwfmt.play)) {
+ /* the device supports playback, probably */
+ device.type |= CUBEB_DEVICE_TYPE_OUTPUT;
+ }
+ switch (device.type) {
+ case 0:
+ /* device doesn't do input or output, aliens probably involved */
+ continue;
+ case CUBEB_DEVICE_TYPE_INPUT:
+ if ((type & CUBEB_DEVICE_TYPE_INPUT) == 0) {
+ /* this device is input only, not scanning for those, skip it */
+ continue;
+ }
+ break;
+ case CUBEB_DEVICE_TYPE_OUTPUT:
+ if ((type & CUBEB_DEVICE_TYPE_OUTPUT) == 0) {
+ /* this device is output only, not scanning for those, skip it */
+ continue;
+ }
+ break;
+ }
+ if ((type & CUBEB_DEVICE_TYPE_INPUT) != 0) {
+ prinfo = &hwfmt.record;
+ }
+ if ((type & CUBEB_DEVICE_TYPE_OUTPUT) != 0) {
+ prinfo = &hwfmt.play;
+ }
+#endif
+ if (i > 0) {
+ (void)snprintf(dev_friendly, sizeof(dev_friendly), "%s %s %s (%d)",
+ hwname.name, hwname.version, hwname.config, i - 1);
+ } else {
+ (void)snprintf(dev_friendly, sizeof(dev_friendly), "%s %s %s (default)",
+ hwname.name, hwname.version, hwname.config);
+ }
+ device.devid = (void *)(uintptr_t)i;
+ device.device_id = strdup(dev);
+ device.friendly_name = strdup(dev_friendly);
+ device.group_id = strdup(dev);
+ device.vendor_name = strdup(hwname.name);
+ device.type = type;
+ device.state = CUBEB_DEVICE_STATE_ENABLED;
+ device.preferred = (i == 0) ? CUBEB_DEVICE_PREF_ALL : CUBEB_DEVICE_PREF_NONE;
+#ifdef AUDIO_GETFORMAT
+ device.max_channels = prinfo->channels;
+ device.default_rate = prinfo->sample_rate;
+#else
+ device.max_channels = 2;
+ device.default_rate = SUN_PREFER_RATE;
+#endif
+ device.default_format = CUBEB_DEVICE_FMT_S16NE;
+ device.format = CUBEB_DEVICE_FMT_S16NE;
+ device.min_rate = SUN_MIN_RATE;
+ device.max_rate = SUN_MAX_RATE;
+ device.latency_lo = SUN_LATENCY_MS * SUN_MIN_RATE / 1000;
+ device.latency_hi = SUN_LATENCY_MS * SUN_MAX_RATE / 1000;
+ collection->device[collection->count++] = device;
+ }
+ return CUBEB_OK;
+}
+
+static int
+sun_device_collection_destroy(cubeb * context,
+ cubeb_device_collection * collection)
+{
+ unsigned i;
+
+ for (i = 0; i < collection->count; ++i) {
+ free((char *)collection->device[i].device_id);
+ free((char *)collection->device[i].friendly_name);
+ free((char *)collection->device[i].group_id);
+ free((char *)collection->device[i].vendor_name);
+ }
+ free(collection->device);
+ return CUBEB_OK;
+}
+
+static int
+sun_copy_params(int fd, cubeb_stream * stream, cubeb_stream_params * params,
+ struct audio_info * info, struct audio_prinfo * prinfo)
+{
+ prinfo->channels = params->channels;
+ prinfo->sample_rate = params->rate;
+ prinfo->precision = 16;
+#ifdef AUDIO_ENCODING_SLINEAR_LE
+ switch (params->format) {
+ case CUBEB_SAMPLE_S16LE:
+ prinfo->encoding = AUDIO_ENCODING_SLINEAR_LE;
+ break;
+ case CUBEB_SAMPLE_S16BE:
+ prinfo->encoding = AUDIO_ENCODING_SLINEAR_BE;
+ break;
+ case CUBEB_SAMPLE_FLOAT32NE:
+ stream->floating = 1;
+ prinfo->encoding = AUDIO_ENCODING_SLINEAR;
+ break;
+ default:
+ LOG("Unsupported format");
+ return CUBEB_ERROR_INVALID_FORMAT;
+ }
+#else
+ switch (params->format) {
+ case CUBEB_SAMPLE_S16NE:
+ prinfo->encoding = AUDIO_ENCODING_LINEAR;
+ break;
+ case CUBEB_SAMPLE_FLOAT32NE:
+ stream->floating = 1;
+ prinfo->encoding = AUDIO_ENCODING_LINEAR;
+ break;
+ default:
+ LOG("Unsupported format");
+ return CUBEB_ERROR_INVALID_FORMAT;
+ }
+#endif
+ if (ioctl(fd, AUDIO_SETINFO, info) == -1) {
+ return CUBEB_ERROR;
+ }
+ if (ioctl(fd, AUDIO_GETINFO, info) == -1) {
+ return CUBEB_ERROR;
+ }
+ return CUBEB_OK;
+}
+
+static int
+sun_stream_stop(cubeb_stream * s)
+{
+ pthread_mutex_lock(&s->mutex);
+ if (s->running) {
+ s->running = 0;
+ pthread_mutex_unlock(&s->mutex);
+ pthread_join(s->thread, NULL);
+ } else {
+ pthread_mutex_unlock(&s->mutex);
+ }
+ return CUBEB_OK;
+}
+
+static void
+sun_stream_destroy(cubeb_stream * s)
+{
+ pthread_mutex_destroy(&s->mutex);
+ sun_stream_stop(s);
+ if (s->play_fd != -1) {
+ close(s->play_fd);
+ }
+ if (s->record_fd != -1) {
+ close(s->record_fd);
+ }
+ free(s->f_play_buf);
+ free(s->f_record_buf);
+ free(s->play_buf);
+ free(s->record_buf);
+ free(s);
+}
+
+static void
+sun_float_to_linear(float * in, int16_t * out,
+ unsigned channels, long frames, float vol)
+{
+ unsigned i, sample_count = frames * channels;
+ float multiplier = vol * 0x8000;
+
+ for (i = 0; i < sample_count; ++i) {
+ int32_t sample = lrintf(in[i] * multiplier);
+ if (sample < -0x8000) {
+ out[i] = -0x8000;
+ } else if (sample > 0x7fff) {
+ out[i] = 0x7fff;
+ } else {
+ out[i] = sample;
+ }
+ }
+}
+
+static void
+sun_linear_to_float(int16_t * in, float * out,
+ unsigned channels, long frames)
+{
+ unsigned i, sample_count = frames * channels;
+
+ for (i = 0; i < sample_count; ++i) {
+ out[i] = (1.0 / 0x8000) * in[i];
+ }
+}
+
+static void
+sun_linear_set_vol(int16_t * buf, unsigned channels, long frames, float vol)
+{
+ unsigned i, sample_count = frames * channels;
+ int32_t multiplier = vol * 0x8000;
+
+ for (i = 0; i < sample_count; ++i) {
+ buf[i] = (buf[i] * multiplier) >> 15;
+ }
+}
+
+static void *
+sun_io_routine(void * arg)
+{
+ cubeb_stream *s = arg;
+ cubeb_state state = CUBEB_STATE_STARTED;
+ size_t to_read = 0;
+ long to_write = 0;
+ size_t write_ofs = 0;
+ size_t read_ofs = 0;
+ int drain = 0;
+
+ s->state_cb(s, s->user_ptr, CUBEB_STATE_STARTED);
+ while (state != CUBEB_STATE_ERROR) {
+ pthread_mutex_lock(&s->mutex);
+ if (!s->running) {
+ pthread_mutex_unlock(&s->mutex);
+ state = CUBEB_STATE_STOPPED;
+ break;
+ }
+ pthread_mutex_unlock(&s->mutex);
+ if (s->floating) {
+ if (s->record_fd != -1) {
+ sun_linear_to_float(s->record_buf, s->f_record_buf,
+ s->r_info.record.channels, SUN_BUFFER_FRAMES);
+ }
+ to_write = s->data_cb(s, s->user_ptr,
+ s->f_record_buf, s->f_play_buf, SUN_BUFFER_FRAMES);
+ if (to_write == CUBEB_ERROR) {
+ state = CUBEB_STATE_ERROR;
+ break;
+ }
+ if (s->play_fd != -1) {
+ pthread_mutex_lock(&s->mutex);
+ sun_float_to_linear(s->f_play_buf, s->play_buf,
+ s->p_info.play.channels, to_write, s->volume);
+ pthread_mutex_unlock(&s->mutex);
+ }
+ } else {
+ to_write = s->data_cb(s, s->user_ptr,
+ s->record_buf, s->play_buf, SUN_BUFFER_FRAMES);
+ if (to_write == CUBEB_ERROR) {
+ state = CUBEB_STATE_ERROR;
+ break;
+ }
+ if (s->play_fd != -1) {
+ pthread_mutex_lock(&s->mutex);
+ sun_linear_set_vol(s->play_buf, s->p_info.play.channels, to_write, s->volume);
+ pthread_mutex_unlock(&s->mutex);
+ }
+ }
+ if (to_write < SUN_BUFFER_FRAMES) {
+ drain = 1;
+ }
+ to_write = s->play_fd != -1 ? to_write : 0;
+ to_read = s->record_fd != -1 ? SUN_BUFFER_FRAMES : 0;
+ write_ofs = 0;
+ read_ofs = 0;
+ while (to_write > 0 || to_read > 0) {
+ size_t bytes;
+ ssize_t n, frames;
+
+ if (to_write > 0) {
+ bytes = FRAMES_TO_BYTES(to_write, s->p_info.play.channels);
+ if ((n = write(s->play_fd, s->play_buf + write_ofs, bytes)) < 0) {
+ state = CUBEB_STATE_ERROR;
+ break;
+ }
+ frames = BYTES_TO_FRAMES(n, s->p_info.play.channels);
+ pthread_mutex_lock(&s->mutex);
+ s->frames_written += frames;
+ pthread_mutex_unlock(&s->mutex);
+ to_write -= frames;
+ write_ofs += frames;
+ }
+ if (to_read > 0) {
+ bytes = FRAMES_TO_BYTES(to_read, s->r_info.record.channels);
+ if ((n = read(s->record_fd, s->record_buf + read_ofs, bytes)) < 0) {
+ state = CUBEB_STATE_ERROR;
+ break;
+ }
+ frames = BYTES_TO_FRAMES(n, s->r_info.record.channels);
+ to_read -= frames;
+ read_ofs += frames;
+ }
+ }
+ if (drain && state != CUBEB_STATE_ERROR) {
+ state = CUBEB_STATE_DRAINED;
+ break;
+ }
+ }
+ s->state_cb(s, s->user_ptr, state);
+ return NULL;
+}
+
+static int
+sun_stream_init(cubeb * context,
+ cubeb_stream ** stream,
+ 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 latency_frames,
+ cubeb_data_callback data_callback,
+ cubeb_state_callback state_callback,
+ void * user_ptr)
+{
+ int ret = CUBEB_OK;
+ cubeb_stream *s = NULL;
+
+ (void)stream_name;
+ if ((s = calloc(1, sizeof(cubeb_stream))) == NULL) {
+ ret = CUBEB_ERROR;
+ goto error;
+ }
+ s->record_fd = -1;
+ s->play_fd = -1;
+ if (input_device != 0) {
+ snprintf(s->input_name, sizeof(s->input_name),
+ "/dev/audio%zu", (uintptr_t)input_device - 1);
+ } else {
+ snprintf(s->input_name, sizeof(s->input_name), "%s", SUN_DEFAULT_DEVICE);
+ }
+ if (output_device != 0) {
+ snprintf(s->output_name, sizeof(s->output_name),
+ "/dev/audio%zu", (uintptr_t)output_device - 1);
+ } else {
+ snprintf(s->output_name, sizeof(s->output_name), "%s", SUN_DEFAULT_DEVICE);
+ }
+ if (input_stream_params != NULL) {
+ if (input_stream_params->prefs & CUBEB_STREAM_PREF_LOOPBACK) {
+ LOG("Loopback not supported");
+ ret = CUBEB_ERROR_NOT_SUPPORTED;
+ goto error;
+ }
+ if (s->record_fd == -1) {
+ if ((s->record_fd = open(s->input_name, O_RDONLY)) == -1) {
+ LOG("Audio device cannot be opened as read-only");
+ ret = CUBEB_ERROR_DEVICE_UNAVAILABLE;
+ goto error;
+ }
+ }
+ AUDIO_INITINFO(&s->r_info);
+#ifdef AUMODE_RECORD
+ s->r_info.mode = AUMODE_RECORD;
+#endif
+ if ((ret = sun_copy_params(s->record_fd, s, input_stream_params,
+ &s->r_info, &s->r_info.record)) != CUBEB_OK) {
+ LOG("Setting record params failed");
+ goto error;
+ }
+ }
+ if (output_stream_params != NULL) {
+ if (output_stream_params->prefs & CUBEB_STREAM_PREF_LOOPBACK) {
+ LOG("Loopback not supported");
+ ret = CUBEB_ERROR_NOT_SUPPORTED;
+ goto error;
+ }
+ if (s->play_fd == -1) {
+ if ((s->play_fd = open(s->output_name, O_WRONLY)) == -1) {
+ LOG("Audio device cannot be opened as write-only");
+ ret = CUBEB_ERROR_DEVICE_UNAVAILABLE;
+ goto error;
+ }
+ }
+ AUDIO_INITINFO(&s->p_info);
+#ifdef AUMODE_PLAY
+ s->p_info.mode = AUMODE_PLAY;
+#endif
+ if ((ret = sun_copy_params(s->play_fd, s, output_stream_params,
+ &s->p_info, &s->p_info.play)) != CUBEB_OK) {
+ LOG("Setting play params failed");
+ goto error;
+ }
+ }
+ s->context = context;
+ s->volume = 1.0;
+ s->state_cb = state_callback;
+ s->data_cb = data_callback;
+ s->user_ptr = user_ptr;
+ if (pthread_mutex_init(&s->mutex, NULL) != 0) {
+ LOG("Failed to create mutex");
+ goto error;
+ }
+ if (s->play_fd != -1 && (s->play_buf = calloc(SUN_BUFFER_FRAMES,
+ s->p_info.play.channels * sizeof(int16_t))) == NULL) {
+ ret = CUBEB_ERROR;
+ goto error;
+ }
+ if (s->record_fd != -1 && (s->record_buf = calloc(SUN_BUFFER_FRAMES,
+ s->r_info.record.channels * sizeof(int16_t))) == NULL) {
+ ret = CUBEB_ERROR;
+ goto error;
+ }
+ if (s->floating) {
+ if (s->play_fd != -1 && (s->f_play_buf = calloc(SUN_BUFFER_FRAMES,
+ s->p_info.play.channels * sizeof(float))) == NULL) {
+ ret = CUBEB_ERROR;
+ goto error;
+ }
+ if (s->record_fd != -1 && (s->f_record_buf = calloc(SUN_BUFFER_FRAMES,
+ s->r_info.record.channels * sizeof(float))) == NULL) {
+ ret = CUBEB_ERROR;
+ goto error;
+ }
+ }
+ *stream = s;
+ return CUBEB_OK;
+error:
+ if (s != NULL) {
+ sun_stream_destroy(s);
+ }
+ return ret;
+}
+
+static int
+sun_stream_start(cubeb_stream * s)
+{
+ s->running = 1;
+ if (pthread_create(&s->thread, NULL, sun_io_routine, s) != 0) {
+ LOG("Couldn't create thread");
+ return CUBEB_ERROR;
+ }
+ return CUBEB_OK;
+}
+
+static int
+sun_stream_get_position(cubeb_stream * s, uint64_t * position)
+{
+#ifdef AUDIO_GETOOFFS
+ struct audio_offset offset;
+
+ if (ioctl(s->play_fd, AUDIO_GETOOFFS, &offset) == -1) {
+ return CUBEB_ERROR;
+ }
+ s->blocks_written += offset.deltablks;
+ *position = BYTES_TO_FRAMES(s->blocks_written * s->p_info.blocksize,
+ s->p_info.play.channels);
+ return CUBEB_OK;
+#else
+ pthread_mutex_lock(&s->mutex);
+ *position = s->frames_written;
+ pthread_mutex_unlock(&s->mutex);
+ return CUBEB_OK;
+#endif
+}
+
+static int
+sun_stream_get_latency(cubeb_stream * stream, uint32_t * latency)
+{
+#ifdef AUDIO_GETBUFINFO
+ struct audio_info info;
+
+ if (ioctl(stream->play_fd, AUDIO_GETBUFINFO, &info) == -1) {
+ return CUBEB_ERROR;
+ }
+
+ *latency = BYTES_TO_FRAMES(info.play.seek + info.blocksize / 2,
+ info.play.channels);
+ return CUBEB_OK;
+#else
+ cubeb_stream_params params;
+
+ params.rate = stream->p_info.play.sample_rate;
+
+ return sun_get_min_latency(NULL, params, latency);
+#endif
+}
+
+static int
+sun_stream_set_volume(cubeb_stream * stream, float volume)
+{
+ pthread_mutex_lock(&stream->mutex);
+ stream->volume = volume;
+ pthread_mutex_unlock(&stream->mutex);
+ return CUBEB_OK;
+}
+
+static int
+sun_get_current_device(cubeb_stream * stream, cubeb_device ** const device)
+{
+ *device = calloc(1, sizeof(cubeb_device));
+ if (*device == NULL) {
+ return CUBEB_ERROR;
+ }
+ (*device)->input_name = stream->record_fd != -1 ?
+ strdup(stream->input_name) : NULL;
+ (*device)->output_name = stream->play_fd != -1 ?
+ strdup(stream->output_name) : NULL;
+ return CUBEB_OK;
+}
+
+static int
+sun_stream_device_destroy(cubeb_stream * stream, cubeb_device * device)
+{
+ (void)stream;
+ free(device->input_name);
+ free(device->output_name);
+ free(device);
+ return CUBEB_OK;
+}
+
+static struct cubeb_ops const sun_ops = {
+ .init = sun_init,
+ .get_backend_id = sun_get_backend_id,
+ .get_max_channel_count = sun_get_max_channel_count,
+ .get_min_latency = sun_get_min_latency,
+ .get_preferred_sample_rate = sun_get_preferred_sample_rate,
+ .enumerate_devices = sun_enumerate_devices,
+ .device_collection_destroy = sun_device_collection_destroy,
+ .destroy = sun_destroy,
+ .stream_init = sun_stream_init,
+ .stream_destroy = sun_stream_destroy,
+ .stream_start = sun_stream_start,
+ .stream_stop = sun_stream_stop,
+ .stream_reset_default_device = NULL,
+ .stream_get_position = sun_stream_get_position,
+ .stream_get_latency = sun_stream_get_latency,
+ .stream_set_volume = sun_stream_set_volume,
+ .stream_set_panning = NULL,
+ .stream_get_current_device = sun_get_current_device,
+ .stream_device_destroy = sun_stream_device_destroy,
+ .stream_register_device_changed_callback = NULL,
+ .register_device_collection_changed = NULL
+};
Index: pkgsrc/mail/thunderbird115/files/desktop.in
diff -u /dev/null pkgsrc/mail/thunderbird115/files/desktop.in:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/files/desktop.in Tue Oct 1 14:21:36 2024
@@ -0,0 +1,12 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=@MOZILLA_NAME@
+GenericName=Mail Client
+Comment=Mail client and News Reader
+Exec=@MOZILLA@ %U
+Icon=@MOZILLA_ICON@
+StartupNotify=false
+Terminal=false
+Type=Application
+Categories=Application;Network;Email;
+MimeType=x-scheme-handler/mailto;
Index: pkgsrc/mail/thunderbird115/files/patch-ipc_src_Makefile
diff -u /dev/null pkgsrc/mail/thunderbird115/files/patch-ipc_src_Makefile:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/files/patch-ipc_src_Makefile Tue Oct 1 14:21:36 2024
@@ -0,0 +1,16 @@
+diff --git a/ipc/src/Makefile b/ipc/src/Makefile
+index 4546c3e..2e0998d 100644
+--- a/ipc/src/Makefile
++++ b/ipc/src/Makefile
+@@ -49,6 +49,11 @@ ifeq ($(OS_TARGET),WINNT)
+ OBJ_SUFF = obj
+ endif
+
++ifeq ($(OS_ARCH),SunOS)
++LDFLAGS += -shared -Wl,-Bsymbolic
++CFLAGS += -fPIC
++endif
++
+ source = subprocess.c
+ objfiles = subprocess.$(OBJ_SUFF)
+ libname = $(DLL_PREFIX)subprocess-$(CPU_ARCH)$(DLL_SUFFIX)
Index: pkgsrc/mail/thunderbird115/files/third__party_rust_encoding__rs_.cargo-checksum.json
diff -u /dev/null pkgsrc/mail/thunderbird115/files/third__party_rust_encoding__rs_.cargo-checksum.json:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/files/third__party_rust_encoding__rs_.cargo-checksum.json Tue Oct 1 14:21:36 2024
@@ -0,0 +1 @@
+{"files":{"CONTRIBUTING.md":"ca1901f3e8532fb4cec894fd3664f0eaa898c0c4b961d1b992d1ed54eacf362a","COPYRIGHT":"11789f45bb180841cd362a5eee6789c68ddb573a11105e30768c308a6add0190","Cargo.toml":"22a4d210c92dae9f32c6944ef340ee8fdd027f99c081577e8907123e2a93383e","Ideas.md":"b7452893f500163868d8de52c09addaf91e1632454ed02e892c467ed7ec39dbd","LICENSE-APACHE":"cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","LICENSE-MIT":"3fa4ca83dcc9237839b1bdeb2e6d16bdfb5ec0c5ce42b24694d8bbf0dcbef72c","LICENSE-WHATWG":"838118388fe5c2e7f1dbbaeed13e1c7f3ebf88be91319c7c1d77c18e987d1a50","README.md":"1d08aefcb92afa81b18154049c9abbcad4540a23f7172e9f9bbed5af33f1a087","ci/miri.sh":"43cb8d82f49e3bfe2d2274b6ccd6f0714a4188ccef0cecc040829883cfdbee25","doc/Big5.txt":"f73a2edc5cb6c2d140ba6e07f4542e1c4a234950378acde1df93480f0ca0be0b","doc/EUC-JP.txt":"ee2818b907d0137f40a9ab9fd525fc700a44dbdddb6cf0c157a656566bae4bf1","doc/EUC-KR.txt":"71d9e2ccf3b124e8bdfb433c8cf2773fd878077038d0cec3c7237a50f4a78a30","doc/GB
K.txt":"c1b522b5a799884e5001da661f42c5a8f4d0acb9ef1d74b206f22b5f65365606","doc/IBM866.txt":"a5a433e804d0f83af785015179fbc1d9b0eaf1f7960efcd04093e136b51fbd0e","doc/ISO-2022-JP.txt":"af86684f5a8f0e2868d7b2c292860140c3d2e5527530ca091f1b28198e8e2fe6","doc/ISO-8859-10.txt":"6d3949ad7c81ca176895101ed81a1db7df1060d64e262880b94bd31bb344ab4d","doc/ISO-8859-13.txt":"3951dd89cf93f7729148091683cf8511f4529388b7dc8dcd0d62eaed55be93fa","doc/ISO-8859-14.txt":"3d330784a0374fd255a38b47949675cc7168c800530534b0a01cac6edc623adc","doc/ISO-8859-15.txt":"24b1084aab5127a85aab99153f86e24694d0a3615f53b5ce23683f97cf66c47a","doc/ISO-8859-16.txt":"ce0272559b92ba76d7a7e476f6424ae4a5cc72e75b183611b08392e44add4d25","doc/ISO-8859-2.txt":"18ceff88c13d1b5ba455a3919b1e3de489045c4c3d2dd7e8527c125c75d54aad","doc/ISO-8859-3.txt":"21798404c68f4f5db59223362f24999da96968c0628427321fccce7d2849a130","doc/ISO-8859-4.txt":"d27f6520c6c5bfbcc19176b71d081cdb3bccde1622bb3e420d5680e812632d53","doc/ISO-8859-5.txt":"a10ec8d6ea7a78ad15d
a7275f6cb1a3365118527e28f9af6d0d5830501303f3a","doc/ISO-8859-6.txt":"ccda8a2efc96115336bdd77776637b9712425e44fbcf745353b9057fbef144e7","doc/ISO-8859-7.txt":"17900fa1f27a445958f0a77d7d9056be375a6bd7ee4492aa680c7c1500bab85e","doc/ISO-8859-8-I.txt":"8357555646d54265a9b9ffa3e68b08d132312f1561c60108ff9b8b1167b6ecf2","doc/ISO-8859-8.txt":"72cd6f3afb7b4a9c16a66a362473315770b7755d72c86c870e52fc3eba86c8af","doc/KOI8-R.txt":"839cf19a38da994488004ed7814b1f6151640156a9a2af02bf2efca745fb5966","doc/KOI8-U.txt":"0cc76624ed1f024183e2298b7e019957da2c70c8ca06e0fc4e6f353f50a5054f","doc/Shift_JIS.txt":"34c49141818cb9ddbcf59cc858f78a79be8ad148d563f26415108ae1f148443f","doc/UTF-16BE.txt":"e2e280d8acbaa6d2a6b3569d60e17500a285f2baa0df3363dd85537cd5a1ef8f","doc/UTF-16LE.txt":"70bdc170e3fc5298ba68f10125fb5eeb8b077036cc96bb4416c4de396f6d76c1","doc/UTF-8.txt":"ea7bae742e613010ced002cf4b601a737d2203fad65e115611451bc4428f548a","doc/gb18030.txt":"dc71378a8f07a2d8659f69ee81fb8791fef56ba86f124b429978285237bb4a7b","
doc/macintosh.txt":"57491e53866711b4672d9b9ff35380b9dac9e0d8e3d6c20bdd6140603687c023","doc/replacement.txt":"4b6c3bbd7999d9d4108a281594bd02d13607e334a95465afff8c2c08d395f0e4","doc/windows-1250.txt":"61296bb6a21cdab602300d32ecfba434cb82de5ac3bc88d58710d2f125e28d39","doc/windows-1251.txt":"7deea1c61dea1485c8ff02db2c7d578db7a9aab63ab1cfd02ec04b515864689e","doc/windows-1252.txt":"933ef3bdddfce5ee132b9f1a1aa8b47423d2587bbe475b19028d0a6d38e180b6","doc/windows-1253.txt":"1a38748b88e99071a5c7b3d5456ead4caedeabab50d50d658be105bc113714de","doc/windows-1254.txt":"f8372f86c6f8d642563cd6ddc025260553292a39423df1683a98670bd7bf2b47","doc/windows-1255.txt":"4e5852494730054e2da258a74e1b9d780abbcdd8ce22ebc218ca2efe9e90493d","doc/windows-1256.txt":"c0879c5172abedead302a406e8f60d9cd9598694a0ffa4fd288ffe4fef7b8ea1","doc/windows-1257.txt":"c28a0c9f964fcb2b46d21f537c402446501a2800670481d6abf9fd9e9018d523","doc/windows-1258.txt":"5019ae4d61805c79aacbf17c93793342dbb098d65a1837783bc3e2c6d6a23602","doc/windows
-874.txt":"4ef0e4501c5feba8b17aee1818602ed44b36ca8475db771ce2fc16d392cabecc","doc/x-mac-cyrillic.txt":"58be154d8a888ca3d484b83b44f749823ef339ab27f14d90ca9a856f5050a8bd","doc/x-user-defined.txt":"f9cd07c4321bf5cfb0be4bdddd251072999b04a6cf7a6f5bc63709a84e2c1ffc","generate-encoding-data.py":"be989dd25c6b946e3e8745fdc8e8a80fcf24b3be99ad0b4b78153ba3f6ab6310","rustfmt.toml":"85c1a3b4382fd89e991cbb81b70fb52780472edc064c963943cdaaa56e0a2030","src/ascii.rs":"588e38b01e666d5e7462617ea7e90a108d608dec9e016f3d273ac0744af2e05d","src/big5.rs":"ec6e2913011a38e9a3e825a1731f139a7ca1d5b264fefae51a3cc1a68a57cef9","src/data.rs":"8a617cc57032092d65850eb27e00de687c80aea3299e839a1f58b42d0b35abf3","src/euc_jp.rs":"32047f5b540188c4cb19c07165f846b9786a09f18e315ed3e9bda1293dae52aa","src/euc_kr.rs":"9b25afc72d9378700eecfac58d55ad1c5946d6cd0ccde2c29c08200ef2de6bb9","src/gb18030.rs":"808587168d73f0c80f8520f0ca9b161866ed2efeb17a05e85fdf3b8efe7ba28a","src/handles.rs":"b08cef1f5785bb6a4822f2e844c6df1b046b737b7a075e4
593eaa8c4208e9fe2","src/iso_2022_jp.rs":"9bb485e82574f4b7d4b2364f0ff276acb6a0bc111758420a3b0ec5e04c196652","src/lib.rs":"834f44b670ec48ee82c0e12223d1567313fdd9f88bca5f4b117c82c1828f559f","src/macros.rs":"200997f8870de8bfd8cdc475e92115df42108c0df661e49d3d1cbc32056e1d99","src/mem.rs":"948571137d3b151df8db4fb2c733e74ae595d055cdf0ad83abcab9341d6adabe","src/replacement.rs":"7660b34a53f8c1ca2bdfa0e51e843ec28326950952ad8bc96569feb93ac62308","src/shift_jis.rs":"6951ae67e36b1a12fa3a30734957f444d8b1b4ae0e2bde52060b29bd0f16d9d9","src/simd_funcs.rs":"05c6e77af74bfe73cd39a752067c11425d6b46e5da419910f54bf75a5c02a984","src/single_byte.rs":"3ad87116fb339434a4b58e8f2b15485f2b66b9f7814d708f16194ed08f6d6ccf","src/test_data/big5_in.txt":"4c5a8691f8dc717311889c63894026d2fb62725a86c4208ca274a9cc8d42a503","src/test_data/big5_in_ref.txt":"99d399e17750cf9c7cf30bb253dbfe35b81c4fcbdead93cfa48b1429213473c7","src/test_data/big5_out.txt":"6193ca97c297aa20e09396038d18e938bb7ea331c26f0f2454097296723a0b13","src/tes
t_data/big5_out_ref.txt":"36567691f557df144f6cc520015a87038dfa156f296fcf103b56ae9a718be1fc","src/test_data/euc_kr_in.txt":"c86a7224f3215fa0d04e685622a752fdc72763e8ae076230c7fd62de57ec4074","src/test_data/euc_kr_in_ref.txt":"1f419f4ca47d708b54c73c461545a022ae2e20498fdbf8005a483d752a204883","src/test_data/euc_kr_out.txt":"e7f32e026f70be1e1b58e0047baf7d3d2c520269c4f9b9992e158b4decb0a1a3","src/test_data/euc_kr_out_ref.txt":"c9907857980b20b8e9e3b584482ed6567a2be6185d72237b6322f0404944924e","src/test_data/gb18030_in.txt":"ab7231b2d3e9afacdbd7d7f3b9e5361a7ff9f7e1cfdb4f3bd905b9362b309e53","src/test_data/gb18030_in_ref.txt":"dc5069421adca2043c55f5012b55a76fdff651d22e6e699fd0978f8d5706815c","src/test_data/gb18030_out.txt":"f0208d527f5ca63de7d9a0323be8d5cf12d8a104b2943d92c2701f0c3364dac1","src/test_data/gb18030_out_ref.txt":"6819fe47627e4ea01027003fc514b9f21a1322e732d7f1fb92cc6c5455bc6c07","src/test_data/iso_2022_jp_in.txt":"cd24bbdcb1834e25db54646fbf4c41560a13dc7540f6be3dba4f5d97d44513af","sr
c/test_data/iso_2022_jp_in_ref.txt":"3dc4e6a5e06471942d086b16c9440945e78415f6f3f47e43717e4bc2eac2cdf5","src/test_data/iso_2022_jp_out.txt":"9b6f015329dda6c3f9ee5ce6dbd6fa9c89acc21283e886836c78b8d833480c21","src/test_data/iso_2022_jp_out_ref.txt":"78cb260093a20116ad9a42f43b05d1848c5ab100b6b9a850749809e943884b35","src/test_data/jis0208_in.txt":"6df3030553ffb0a6615bb33dc8ea9dca6d9623a9028e2ffec754ce3c3da824cc","src/test_data/jis0208_in_ref.txt":"3dc4e6a5e06471942d086b16c9440945e78415f6f3f47e43717e4bc2eac2cdf5","src/test_data/jis0208_out.txt":"4ec24477e1675ce750733bdc3c5add1cd27b6bd4ce1f09289564646e9654e857","src/test_data/jis0208_out_ref.txt":"c3e1cef5032b2b1d93a406f31ff940c4e2dfe8859b8b17ca2761fee7a75a0e48","src/test_data/jis0212_in.txt":"c011f0dd72bd7c8cd922df9374ef8d2769a77190514c77f6c62b415852eeb9fe","src/test_data/jis0212_in_ref.txt":"7d9458b3d2f73e7092a7f505c08ce1d233dde18aa679fbcf9889256239cc9e06","src/test_data/shift_jis_in.txt":"02e389ccef0dd2122e63f503899402cb7f797912c2444cc8
0ab93131116c5524","src/test_data/shift_jis_in_ref.txt":"512f985950ca902e643c88682dba9708b7c38d3c5ec2925168ab00ac94ab19f9","src/test_data/shift_jis_out.txt":"5fbc44da7bf639bf6cfe0fa1fd3eba7102b88f81919c9ea991302712f69426fb","src/test_data/shift_jis_out_ref.txt":"466322c6fed8286c64582731755290c2296508efdd258826e6279686649b481f","src/test_labels_names.rs":"23a2e11b02b3b8d15fb5613a625e3edb2c61e70e3c581abfd638719a4088200d","src/testing.rs":"f59e671e95a98a56f6b573e8c6be4d71e670bf52f7e20eb1605d990aafa1894e","src/utf_16.rs":"c071a147fad38d750c2c247e141b76b929a48007b99f26b2922b9caecdaf2f25","src/utf_8.rs":"7b7d887b347f1aefa03246b028a36a72758a4ce76c28f3b45c19467851aa7839","src/variant.rs":"1fab5363588a1554a7169de8731ea9cded7ac63ea35caabdd1c27a8dde68c27b","src/x_user_defined.rs":"9456ca46168ef86c98399a2536f577ef7be3cdde90c0c51392d8ac48519d3fae"},"package":"b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59"}
Index: pkgsrc/mail/thunderbird115/patches/patch-browser_app_profile_firefox.js
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-browser_app_profile_firefox.js:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-browser_app_profile_firefox.js Tue Oct 1 14:21:36 2024
@@ -0,0 +1,17 @@
+$NetBSD: patch-browser_app_profile_firefox.js,v 1.1 2024/10/01 14:21:36 ryoon Exp $
+
+--- browser/app/profile/firefox.js.orig 2020-08-28 21:32:23.000000000 +0000
++++ browser/app/profile/firefox.js
+@@ -1921,6 +1921,12 @@ pref("fission.frontend.simulate-messages
+ pref("toolkit.coverage.enabled", false);
+ pref("toolkit.coverage.endpoint.base", "https://coverage.mozilla.org");
+
++// Select UI locale from LANG/LC_MESSAGE environmental variables
++pref("intl.locale.requested", "");
++
++// Enable system addons, for example langpacks from www/firefox-l10n
++pref("extensions.autoDisableScopes", 11);
++
+ // Discovery prefs
+ pref("browser.discovery.enabled", true);
+ pref("browser.discovery.containers.enabled", true);
Index: pkgsrc/mail/thunderbird115/patches/patch-build_moz.configure_init.configure
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-build_moz.configure_init.configure:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-build_moz.configure_init.configure Tue Oct 1 14:21:36 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-build_moz.configure_init.configure,v 1.1 2024/10/01 14:21:36 ryoon Exp $
+
+Support illumos triple.
+
+--- build/moz.configure/init.configure.orig 2024-05-10 08:33:53.315533784 +0000
++++ build/moz.configure/init.configure
+@@ -475,6 +475,8 @@ def split_triplet(triplet, allow_msvc=Fa
+ canonical_os = canonical_kernel = "OpenBSD"
+ elif os.startswith("solaris"):
+ canonical_os = canonical_kernel = "SunOS"
++ elif os.startswith("illumos"):
++ canonical_os = canonical_kernel = "SunOS"
+ elif os.startswith("wasi") and allow_wasi:
+ canonical_os = canonical_kernel = "WASI"
+ else:
Index: pkgsrc/mail/thunderbird115/patches/patch-build_moz.configure_rust.configure
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-build_moz.configure_rust.configure:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-build_moz.configure_rust.configure Tue Oct 1 14:21:36 2024
@@ -0,0 +1,12 @@
+$NetBSD: patch-build_moz.configure_rust.configure,v 1.1 2024/10/01 14:21:36 ryoon Exp $
+
+--- build/moz.configure/rust.configure.orig 2020-08-28 21:32:29.000000000 +0000
++++ build/moz.configure/rust.configure
+@@ -385,6 +385,7 @@ def detect_rustc_target(
+ for c in candidates
+ if c.target.raw_os == host_or_target.raw_os
+ and c.target.raw_cpu == host_or_target.raw_cpu
++ and not c.rust_target.endswith("-rumprun-netbsd")
+ ]
+ if len(narrowed) == 1:
+ return narrowed[0].rust_target
Index: pkgsrc/mail/thunderbird115/patches/patch-comm_third__party_botan_configure.py
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-comm_third__party_botan_configure.py:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-comm_third__party_botan_configure.py Tue Oct 1 14:21:36 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-comm_third__party_botan_configure.py,v 1.1 2024/10/01 14:21:36 ryoon Exp $
+
+* pkgsrc uses clang as c++.
+
+--- comm/third_party/botan/configure.py.orig 2020-08-28 21:34:19.000000000 +0000
++++ comm/third_party/botan/configure.py
+@@ -2940,7 +2940,7 @@ def set_defaults_for_unset_options(optio
+ return 'clang'
+ if cc_bin.find('-g++') != -1 or cc_bin.find('g++') != -1:
+ return 'gcc'
+- return None
++ return 'clang'
+
+ if options.compiler is None and options.compiler_binary is not None:
+ options.compiler = deduce_compiler_type_from_cc_bin(options.compiler_binary)
Index: pkgsrc/mail/thunderbird115/patches/patch-comm_third__party_libgcrypt_configure
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-comm_third__party_libgcrypt_configure:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-comm_third__party_libgcrypt_configure Tue Oct 1 14:21:36 2024
@@ -0,0 +1,13 @@
+$NetBSD: patch-comm_third__party_libgcrypt_configure,v 1.1 2024/10/01 14:21:36 ryoon Exp $
+
+--- comm/third_party/libgcrypt/configure.orig 2022-12-20 00:50:23.000000000 +0000
++++ comm/third_party/libgcrypt/configure
+@@ -17460,7 +17460,7 @@ CFLAGS="$CFLAGS -maltivec -mvsx -mcrypto
+
+ if test "$gcry_cv_cc_ppc_altivec" = "no" &&
+ test "$mpi_cpu_arch" = "ppc" &&
+- test "$try_asm_modules" == "yes" ; then
++ test "$try_asm_modules" = "yes" ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports PowerPC AltiVec/VSX/crypto intrinsics with extra GCC flags" >&5
+ $as_echo_n "checking whether compiler supports PowerPC AltiVec/VSX/crypto intrinsics with extra GCC flags... " >&6; }
+ if ${gcry_cv_cc_ppc_altivec_cflags+:} false; then :
Index: pkgsrc/mail/thunderbird115/patches/patch-config_gcc-stl-wrapper.template.h
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-config_gcc-stl-wrapper.template.h:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-config_gcc-stl-wrapper.template.h Tue Oct 1 14:21:36 2024
@@ -0,0 +1,31 @@
+$NetBSD: patch-config_gcc-stl-wrapper.template.h,v 1.1 2024/10/01 14:21:36 ryoon Exp $
+
+--- config/gcc-stl-wrapper.template.h.orig 2020-08-28 21:32:29.000000000 +0000
++++ config/gcc-stl-wrapper.template.h
+@@ -32,8 +32,8 @@
+ // limits) and bug 1694575 (iosfwd).
+ // Please be careful when adding more exceptions, especially regarding
+ // the header not directly or indirectly including <new>.
+-#ifndef moz_dont_include_mozalloc_for_cstdlib
+-# define moz_dont_include_mozalloc_for_cstdlib
++#ifndef moz_dont_include_mozalloc_for_${HEADER}
++# define moz_dont_include_mozalloc_for_${HEADER}
+ #endif
+
+ #ifndef moz_dont_include_mozalloc_for_cmath
+@@ -55,7 +55,7 @@
+ // Include mozalloc after the STL header and all other headers it includes
+ // have been preprocessed.
+ #if !defined(MOZ_INCLUDE_MOZALLOC_H) && \
+- !defined(moz_dont_include_mozalloc_for_${HEADER})
++ !defined(moz_dont_include_mozalloc_for_cstdlib)
+ # define MOZ_INCLUDE_MOZALLOC_H
+ # define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
+ #endif
+@@ -84,4 +84,6 @@
+ # include "mozilla/throw_gcc.h"
+ #endif
+
++#undef moz_dont_include_mzalloc_for_${HEADER}
++
+ #endif // if mozilla_${HEADER}_h
Index: pkgsrc/mail/thunderbird115/patches/patch-config_makefiles_rust.mk
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-config_makefiles_rust.mk:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-config_makefiles_rust.mk Tue Oct 1 14:21:36 2024
@@ -0,0 +1,30 @@
+$NetBSD: patch-config_makefiles_rust.mk,v 1.1 2024/10/01 14:21:36 ryoon Exp $
+
+NetBSD doesn't get along with parallel rust builds (it causes issues
+with ld.so) which are the default. Force -j1.
+
+Expand -Clto=thin for all to avoid out-of-memory errors.
+
+--- config/makefiles/rust.mk.orig 2024-08-01 19:52:10.000000000 +0000
++++ config/makefiles/rust.mk
+@@ -60,6 +60,9 @@ ifdef MOZ_TSAN
+ cargo_build_flags += -Zbuild-std=std,panic_abort
+ RUSTFLAGS += -Zsanitizer=thread
+ endif
++ifeq ($(OS_ARCH),NetBSD)
++cargo_build_flags += @RUST_MAKE_JOBS@
++endif
+
+ rustflags_sancov =
+ ifdef LIBFUZZER
+@@ -91,9 +94,7 @@ ifndef MOZ_LTO_RUST_CROSS
+ ifndef rustflags_sancov
+ # Never enable when coverage is enabled to work around https://github.com/rust-lang/rust/issues/90045.
+ ifndef MOZ_CODE_COVERAGE
+-ifeq (,$(findstring gkrust_gtest,$(RUST_LIBRARY_FILE)))
+-cargo_rustc_flags += -Clto$(if $(filter full,$(MOZ_LTO_RUST_CROSS)),=fat)
+-endif
++cargo_rustc_flags += -Clto=thin
+ # We need -Cembed-bitcode=yes for all crates when using -Clto.
+ RUSTFLAGS += -Cembed-bitcode=yes
+ endif
Index: pkgsrc/mail/thunderbird115/patches/patch-dom_base_nsAttrName.h
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-dom_base_nsAttrName.h:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-dom_base_nsAttrName.h Tue Oct 1 14:21:36 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-dom_base_nsAttrName.h,v 1.1 2024/10/01 14:21:36 ryoon Exp $
+
+--- dom/base/nsAttrName.h.orig 2020-08-28 21:32:30.000000000 +0000
++++ dom/base/nsAttrName.h
+@@ -16,6 +16,10 @@
+ #include "mozilla/dom/NodeInfo.h"
+ #include "nsAtom.h"
+ #include "nsDOMString.h"
++#ifdef __NetBSD__
++/* This is also a macro which causes problems with cbindgen */
++#undef uintptr_t
++#endif
+
+ #define NS_ATTRNAME_NODEINFO_BIT 1
+ class nsAttrName {
Index: pkgsrc/mail/thunderbird115/patches/patch-dom_webtransport_api_WebTransportDatagramDuplexStream.cpp
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-dom_webtransport_api_WebTransportDatagramDuplexStream.cpp:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-dom_webtransport_api_WebTransportDatagramDuplexStream.cpp Tue Oct 1 14:21:37 2024
@@ -0,0 +1,16 @@
+$NetBSD: patch-dom_webtransport_api_WebTransportDatagramDuplexStream.cpp,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+Make isnan() available via "using std::isnan;", as that's
+apparently needed at least on netbsd-10 to bring isnan() into scope.
+
+--- dom/webtransport/api/WebTransportDatagramDuplexStream.cpp.orig 2023-08-14 18:19:46.000000000 +0000
++++ dom/webtransport/api/WebTransportDatagramDuplexStream.cpp
+@@ -10,6 +10,8 @@
+ #include "mozilla/dom/Promise-inl.h"
+ #include "mozilla/dom/WebTransportLog.h"
+
++using std::isnan;
++
+ namespace mozilla::dom {
+
+ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WebTransportDatagramDuplexStream, mGlobal,
Index: pkgsrc/mail/thunderbird115/patches/patch-gfx_angle_checkout_src_common_third__party_smhasher_src_PMurHash.cpp
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-gfx_angle_checkout_src_common_third__party_smhasher_src_PMurHash.cpp:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-gfx_angle_checkout_src_common_third__party_smhasher_src_PMurHash.cpp Tue Oct 1 14:21:37 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-gfx_angle_checkout_src_common_third__party_smhasher_src_PMurHash.cpp,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- gfx/angle/checkout/src/common/third_party/smhasher/src/PMurHash.cpp.orig 2020-08-28 21:32:36.000000000 +0000
++++ gfx/angle/checkout/src/common/third_party/smhasher/src/PMurHash.cpp
+@@ -91,8 +91,8 @@ on big endian machines, or a byte-by-byt
+ /* gcc 'may' define __LITTLE_ENDIAN__ or __BIG_ENDIAN__ to 1 (Note the trailing __),
+ * or even _LITTLE_ENDIAN or _BIG_ENDIAN (Note the single _ prefix) */
+ #if !defined(__BYTE_ORDER)
+-# if defined(__LITTLE_ENDIAN__) && __LITTLE_ENDIAN__ == 1 || \
+- defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN == 1
++# if defined(__LITTLE_ENDIAN__) && __LITTLE_ENDIAN__-0 == 1 || \
++ defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN-0 == 1
+ # define __BYTE_ORDER __LITTLE_ENDIAN
+ # elif defined(__BIG_ENDIAN__) && __BIG_ENDIAN__ == 1 || defined(_BIG_ENDIAN) && _BIG_ENDIAN == 1
+ # define __BYTE_ORDER __BIG_ENDIAN
Index: pkgsrc/mail/thunderbird115/patches/patch-gfx_angle_checkout_src_compiler_translator_InfoSink.h
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-gfx_angle_checkout_src_compiler_translator_InfoSink.h:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-gfx_angle_checkout_src_compiler_translator_InfoSink.h Tue Oct 1 14:21:37 2024
@@ -0,0 +1,13 @@
+$NetBSD: patch-gfx_angle_checkout_src_compiler_translator_InfoSink.h,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- gfx/angle/checkout/src/compiler/translator/InfoSink.h.orig 2020-08-28 21:32:36.000000000 +0000
++++ gfx/angle/checkout/src/compiler/translator/InfoSink.h
+@@ -7,7 +7,7 @@
+ #ifndef COMPILER_TRANSLATOR_INFOSINK_H_
+ #define COMPILER_TRANSLATOR_INFOSINK_H_
+
+-#include <math.h>
++#include <cmath>
+ #include <stdlib.h>
+ #include "GLSLANG/ShaderLang.h"
+ #include "compiler/translator/Common.h"
Index: pkgsrc/mail/thunderbird115/patches/patch-gfx_cairo_cairo_src_cairo-type1-subset.c
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-gfx_cairo_cairo_src_cairo-type1-subset.c:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-gfx_cairo_cairo_src_cairo-type1-subset.c Tue Oct 1 14:21:37 2024
@@ -0,0 +1,13 @@
+$NetBSD: patch-gfx_cairo_cairo_src_cairo-type1-subset.c,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- gfx/cairo/cairo/src/cairo-type1-subset.c.orig 2020-08-28 21:32:36.000000000 +0000
++++ gfx/cairo/cairo/src/cairo-type1-subset.c
+@@ -254,7 +254,7 @@ cairo_type1_font_subset_find_segments (c
+ font->eexec_segment = (char *) p + font->header_segment_size;
+ font->eexec_segment_is_ascii = TRUE;
+ for (i = 0; i < 4; i++) {
+- if (!_cairo_isxdigit (font->eexec_segment[i]))
++ if (!_cairo_isxdigit ((unsigned char) font->eexec_segment[i]))
+ font->eexec_segment_is_ascii = FALSE;
+ }
+ }
Index: pkgsrc/mail/thunderbird115/patches/patch-gfx_skia_skia_src_core_SkCpu.cpp
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-gfx_skia_skia_src_core_SkCpu.cpp:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-gfx_skia_skia_src_core_SkCpu.cpp Tue Oct 1 14:21:37 2024
@@ -0,0 +1,13 @@
+$NetBSD: patch-gfx_skia_skia_src_core_SkCpu.cpp,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- gfx/skia/skia/src/core/SkCpu.cpp.orig 2020-08-28 21:32:36.000000000 +0000
++++ gfx/skia/skia/src/core/SkCpu.cpp
+@@ -72,7 +72,7 @@
+ return features;
+ }
+
+-#elif defined(SK_CPU_ARM64) && __has_include(<sys/auxv.h>)
++#elif defined(SK_CPU_ARM64) && __has_include(<sys/auxv.h>) && !defined(__NetBSD__)
+ #include <sys/auxv.h>
+
+ static uint32_t read_cpu_features() {
Index: pkgsrc/mail/thunderbird115/patches/patch-ipc_chromium_src_base_message__pump__libevent.cc
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-ipc_chromium_src_base_message__pump__libevent.cc:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-ipc_chromium_src_base_message__pump__libevent.cc Tue Oct 1 14:21:37 2024
@@ -0,0 +1,20 @@
+$NetBSD: patch-ipc_chromium_src_base_message__pump__libevent.cc,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- ipc/chromium/src/base/message_pump_libevent.cc.orig 2020-08-28 21:32:41.000000000 +0000
++++ ipc/chromium/src/base/message_pump_libevent.cc
+@@ -24,6 +24,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), \
+@@ -44,6 +45,7 @@ CHECK_EVENT_SIZEOF(SHORT, short);
+ CHECK_EVENT_SIZEOF(SIZE_T, size_t);
+ CHECK_EVENT_SIZEOF(TIME_T, time_t);
+ CHECK_EVENT_SIZEOF(VOID_P, void*);
++#endif
+
+ // Lifecycle of struct event
+ // Libevent uses two main data structures:
Index: pkgsrc/mail/thunderbird115/patches/patch-ipc_chromium_src_base_platform__thread__posix.cc
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-ipc_chromium_src_base_platform__thread__posix.cc:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-ipc_chromium_src_base_platform__thread__posix.cc Tue Oct 1 14:21:37 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-ipc_chromium_src_base_platform__thread__posix.cc,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- ipc/chromium/src/base/platform_thread_posix.cc.orig 2020-08-28 21:32:41.000000000 +0000
++++ ipc/chromium/src/base/platform_thread_posix.cc
+@@ -12,7 +12,9 @@
+ #if defined(OS_MACOSX)
+ # include <mach/mach.h>
+ #elif defined(OS_NETBSD)
+-# include <lwp.h>
++_Pragma("GCC visibility push(default)")
++#include <lwp.h>
++_Pragma("GCC visibility pop")
+ #elif defined(OS_LINUX)
+ # include <sys/syscall.h>
+ # include <sys/prctl.h>
Index: pkgsrc/mail/thunderbird115/patches/patch-ipc_glue_GeckoChildProcessHost.cpp
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-ipc_glue_GeckoChildProcessHost.cpp:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-ipc_glue_GeckoChildProcessHost.cpp Tue Oct 1 14:21:37 2024
@@ -0,0 +1,18 @@
+$NetBSD: patch-ipc_glue_GeckoChildProcessHost.cpp,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- ipc/glue/GeckoChildProcessHost.cpp.orig 2020-08-28 21:32:41.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/process_util.h"
Index: pkgsrc/mail/thunderbird115/patches/patch-js_public_Utility.h
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-js_public_Utility.h:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-js_public_Utility.h Tue Oct 1 14:21:37 2024
@@ -0,0 +1,24 @@
+$NetBSD: patch-js_public_Utility.h,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- js/public/Utility.h.orig 2024-07-15 21:09:40.000000000 +0000
++++ js/public/Utility.h
+@@ -478,9 +478,6 @@ static inline void js_free(void* p) {
+ #define JS_DECLARE_NEW_METHODS(NEWNAME, ALLOCATOR, QUALIFIERS) \
+ template <class T, typename... Args> \
+ QUALIFIERS T* MOZ_HEAP_ALLOCATOR NEWNAME(Args&&... args) { \
+- static_assert( \
+- alignof(T) <= alignof(max_align_t), \
+- "over-aligned type is not supported by JS_DECLARE_NEW_METHODS"); \
+ void* memory = ALLOCATOR(sizeof(T)); \
+ return MOZ_LIKELY(memory) ? new (memory) T(std::forward<Args>(args)...) \
+ : nullptr; \
+@@ -497,9 +494,6 @@ static inline void js_free(void* p) {
+ #define JS_DECLARE_NEW_ARENA_METHODS(NEWNAME, ALLOCATOR, QUALIFIERS) \
+ template <class T, typename... Args> \
+ QUALIFIERS T* MOZ_HEAP_ALLOCATOR NEWNAME(arena_id_t arena, Args&&... args) { \
+- static_assert( \
+- alignof(T) <= alignof(max_align_t), \
+- "over-aligned type is not supported by JS_DECLARE_NEW_ARENA_METHODS"); \
+ void* memory = ALLOCATOR(arena, sizeof(T)); \
+ return MOZ_LIKELY(memory) ? new (memory) T(std::forward<Args>(args)...) \
+ : nullptr; \
Index: pkgsrc/mail/thunderbird115/patches/patch-js_src_jsfriendapi.h
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-js_src_jsfriendapi.h:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-js_src_jsfriendapi.h Tue Oct 1 14:21:37 2024
@@ -0,0 +1,12 @@
+$NetBSD: patch-js_src_jsfriendapi.h,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- js/src/jsfriendapi.h.orig 2020-08-28 21:32:42.000000000 +0000
++++ js/src/jsfriendapi.h
+@@ -7,6 +7,7 @@
+ #ifndef jsfriendapi_h
+ #define jsfriendapi_h
+
++#include <stdarg.h>
+ #include "jspubtd.h"
+
+ #include "js/CallArgs.h"
Index: pkgsrc/mail/thunderbird115/patches/patch-js_src_util_NativeStack.cpp
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-js_src_util_NativeStack.cpp:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-js_src_util_NativeStack.cpp Tue Oct 1 14:21:37 2024
@@ -0,0 +1,30 @@
+$NetBSD: patch-js_src_util_NativeStack.cpp,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- js/src/util/NativeStack.cpp.orig 2020-08-28 21:32:56.000000000 +0000
++++ js/src/util/NativeStack.cpp
+@@ -13,7 +13,7 @@
+ # if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+ # include <pthread_np.h>
+ # endif
+-# if defined(SOLARIS) || defined(AIX)
++# if defined(__sun) || defined(AIX)
+ # include <ucontext.h>
+ # endif
+ # if defined(ANDROID) && !defined(__aarch64__)
+@@ -40,7 +40,7 @@ void* js::GetNativeStackBaseImpl() {
+ return static_cast<void*>(pTib->StackBase);
+ }
+
+-#elif defined(SOLARIS)
++#elif defined(__sun)
+
+ static_assert(JS_STACK_GROWTH_DIRECTION < 0);
+
+@@ -128,6 +128,7 @@ void* js::GetNativeStackBaseImpl() {
+ # elif defined(PTHREAD_NP_H) || defined(_PTHREAD_NP_H_) || defined(NETBSD)
+ /* e.g. on FreeBSD 4.8 or newer, neundorf%kde.org@localhost */
+ pthread_attr_get_np(thread, &sattr);
++# elif defined(__sun)
+ # else
+ /*
+ * FIXME: this function is non-portable;
Index: pkgsrc/mail/thunderbird115/patches/patch-llvm18
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-llvm18:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-llvm18 Tue Oct 1 14:21:37 2024
@@ -0,0 +1,199 @@
+From cd10f3ba0d83f34ca978cc4c7a552b72fdd068aa Mon Sep 17 00:00:00 2001
+From: David Tolnay <dtolnay%gmail.com@localhost>
+Date: Tue, 28 Nov 2023 11:18:39 -0800
+Subject: [PATCH 1/2] Flatten cursor.kind() matching in Item::parse down to one
+ match
+
+---
+ bindgen/ir/item.rs | 84 ++++++++++++++++++++++------------------------
+ 1 file changed, 41 insertions(+), 43 deletions(-)
+
+diff --git bindgen/ir/item.rs bindgen/ir/item.rs
+index 0556452bfa..4f2d361e51 100644
+--- third_party/rust/bindgen/ir/item.rs
++++ third_party/rust/bindgen/ir/item.rs
+@@ -1427,53 +1427,52 @@
+ }
+ }
+
+- // Guess how does clang treat extern "C" blocks?
+- if cursor.kind() == CXCursor_UnexposedDecl {
+- Err(ParseError::Recurse)
+- } else {
++ match cursor.kind() {
++ // Guess how does clang treat extern "C" blocks?
++ CXCursor_UnexposedDecl => Err(ParseError::Recurse),
++
+ // We allowlist cursors here known to be unhandled, to prevent being
+ // too noisy about this.
+- match cursor.kind() {
+- CXCursor_MacroDefinition |
+- CXCursor_MacroExpansion |
+- CXCursor_UsingDeclaration |
+- CXCursor_UsingDirective |
+- CXCursor_StaticAssert |
+- CXCursor_FunctionTemplate => {
+- debug!(
+- "Unhandled cursor kind {:?}: {:?}",
+- cursor.kind(),
+- cursor
+- );
+- }
+- CXCursor_InclusionDirective => {
+- let file = cursor.get_included_file_name();
+- match file {
+- None => {
+- warn!(
+- "Inclusion of a nameless file in {:?}",
+- cursor
+- );
+- }
+- Some(filename) => {
+- ctx.include_file(filename);
+- }
+- }
+- }
+- _ => {
+- // ignore toplevel operator overloads
+- let spelling = cursor.spelling();
+- if !spelling.starts_with("operator") {
++ CXCursor_MacroDefinition |
++ CXCursor_MacroExpansion |
++ CXCursor_UsingDeclaration |
++ CXCursor_UsingDirective |
++ CXCursor_StaticAssert |
++ CXCursor_FunctionTemplate => {
++ debug!(
++ "Unhandled cursor kind {:?}: {:?}",
++ cursor.kind(),
++ cursor
++ );
++ Err(ParseError::Continue)
++ }
++ CXCursor_InclusionDirective => {
++ let file = cursor.get_included_file_name();
++ match file {
++ None => {
+ warn!(
+- "Unhandled cursor kind {:?}: {:?}",
+- cursor.kind(),
++ "Inclusion of a nameless file in {:?}",
+ cursor
+ );
+ }
++ Some(filename) => {
++ ctx.include_file(filename);
++ }
+ }
++ Err(ParseError::Continue)
++ }
++ _ => {
++ // ignore toplevel operator overloads
++ let spelling = cursor.spelling();
++ if !spelling.starts_with("operator") {
++ warn!(
++ "Unhandled cursor kind {:?}: {:?}",
++ cursor.kind(),
++ cursor
++ );
++ }
++ Err(ParseError::Continue)
+ }
+-
+- Err(ParseError::Continue)
+ }
+ }
+
+
+From 2997017b5a3065b83e9d76f0080d6cb99c94c0c1 Mon Sep 17 00:00:00 2001
+From: David Tolnay <dtolnay%gmail.com@localhost>
+Date: Tue, 28 Nov 2023 11:21:18 -0800
+Subject: [PATCH 2/2] Handle CXCursor_LinkageSpec in Clang 18+
+
+---
+ bindgen/ir/item.rs | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git bindgen/ir/item.rs bindgen/ir/item.rs
+index 4f2d361e51..dd587b088b 100644
+--- third_party/rust/bindgen/ir/item.rs
++++ third_party/rust/bindgen/ir/item.rs
+@@ -1433,8 +1433,11 @@ impl Item {
+ }
+
+ match cursor.kind() {
+- // Guess how does clang treat extern "C" blocks?
+- CXCursor_UnexposedDecl => Err(ParseError::Recurse),
++ // On Clang 18+, extern "C" is reported accurately as a LinkageSpec.
++ // Older LLVM treat it as UnexposedDecl.
++ CXCursor_LinkageSpec | CXCursor_UnexposedDecl => {
++ Err(ParseError::Recurse)
++ }
+
+ // We allowlist cursors here known to be unhandled, to prevent being
+ // too noisy about this.
+diff --git dom/media/gmp-plugin-openh264/gmp-fake-openh264.cpp dom/media/gmp-plugin-openh264/gmp-fake-openh264.cpp
+--- dom/media/gmp-plugin-openh264/gmp-fake-openh264.cpp
++++ dom/media/gmp-plugin-openh264/gmp-fake-openh264.cpp
+@@ -97,11 +97,11 @@
+ uint32_t width_;
+ uint32_t height_;
+ uint8_t y_;
+ uint8_t u_;
+ uint8_t v_;
+- uint32_t timestamp_;
++ uint64_t timestamp_;
+ } idr_nalu;
+ };
+ #pragma pack(pop)
+
+ #define ENCODED_FRAME_MAGIC 0x004000b8
+diff --git dom/media/gtest/TestGMPRemoveAndDelete.cpp dom/media/gtest/TestGMPRemoveAndDelete.cpp
+--- dom/media/gtest/TestGMPRemoveAndDelete.cpp
++++ dom/media/gtest/TestGMPRemoveAndDelete.cpp
+@@ -359,11 +359,11 @@
+ uint32_t width_;
+ uint32_t height_;
+ uint8_t y_;
+ uint8_t u_;
+ uint8_t v_;
+- uint32_t timestamp_;
++ uint64_t timestamp_;
+ } idr_nalu;
+ };
+ #pragma pack(pop)
+
+ GMPVideoFrame* absFrame;
+diff --git dom/media/webrtc/libwebrtcglue/WebrtcGmpVideoCodec.h dom/media/webrtc/libwebrtcglue/WebrtcGmpVideoCodec.h
+--- dom/media/webrtc/libwebrtcglue/WebrtcGmpVideoCodec.h
++++ dom/media/webrtc/libwebrtcglue/WebrtcGmpVideoCodec.h
+@@ -300,11 +300,11 @@
+
+ struct InputImageData {
+ int64_t timestamp_us;
+ };
+ // Map rtp time -> input image data
+- DataMutex<std::map<uint32_t, InputImageData>> mInputImageMap;
++ DataMutex<std::map<uint64_t, InputImageData>> mInputImageMap;
+
+ MediaEventProducer<uint64_t> mInitPluginEvent;
+ MediaEventProducer<uint64_t> mReleasePluginEvent;
+ };
+
+diff --git dom/media/webrtc/libwebrtcglue/WebrtcGmpVideoCodec.cpp dom/media/webrtc/libwebrtcglue/WebrtcGmpVideoCodec.cpp
+--- dom/media/webrtc/libwebrtcglue/WebrtcGmpVideoCodec.cpp
++++ dom/media/webrtc/libwebrtcglue/WebrtcGmpVideoCodec.cpp
+@@ -538,11 +538,11 @@
+ return;
+ }
+
+ webrtc::VideoFrameType ft;
+ GmpFrameTypeToWebrtcFrameType(aEncodedFrame->FrameType(), &ft);
+- uint32_t timestamp = (aEncodedFrame->TimeStamp() * 90ll + 999) / 1000;
++ uint64_t timestamp = (aEncodedFrame->TimeStamp() * 90ll + 999) / 1000;
+
+ GMP_LOG_DEBUG("GMP Encoded: %" PRIu64 ", type %d, len %d",
+ aEncodedFrame->TimeStamp(), aEncodedFrame->BufferType(),
+ aEncodedFrame->Size());
+
+
Index: pkgsrc/mail/thunderbird115/patches/patch-media_ffvpx_libavutil_arm_bswap.h
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-media_ffvpx_libavutil_arm_bswap.h:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-media_ffvpx_libavutil_arm_bswap.h Tue Oct 1 14:21:37 2024
@@ -0,0 +1,20 @@
+$NetBSD: patch-media_ffvpx_libavutil_arm_bswap.h,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- media/ffvpx/libavutil/arm/bswap.h.orig 2020-08-28 21:33:11.000000000 +0000
++++ media/ffvpx/libavutil/arm/bswap.h
+@@ -23,6 +23,8 @@
+ #include "config.h"
+ #include "libavutil/attributes.h"
+
++#ifndef __aarch64__
++
+ #ifdef __ARMCC_VERSION
+
+ #if HAVE_ARMV6
+@@ -64,4 +66,6 @@ static av_always_inline av_const uint32_
+
+ #endif /* __ARMCC_VERSION */
+
++#endif /* __aarch64__ */
++
+ #endif /* AVUTIL_ARM_BSWAP_H */
Index: pkgsrc/mail/thunderbird115/patches/patch-media_libcubeb_src_cubeb__sun.c
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-media_libcubeb_src_cubeb__sun.c:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-media_libcubeb_src_cubeb__sun.c Tue Oct 1 14:21:37 2024
@@ -0,0 +1,520 @@
+$NetBSD: patch-media_libcubeb_src_cubeb__sun.c,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- media/libcubeb/src/cubeb_sun.c.orig 2023-02-16 16:57:29.457010148 +0000
++++ media/libcubeb/src/cubeb_sun.c
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright © 2019 Nia Alarie
++ * Copyright © 2019-2020 Nia Alarie <nia%NetBSD.org@localhost>
+ *
+ * This program is made available under an ISC-style license. See the
+ * accompanying file LICENSE for details.
+@@ -9,19 +9,14 @@
+ #include <fcntl.h>
+ #include <unistd.h>
+ #include <pthread.h>
++#include <stdbool.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+-#include <math.h>
++#include <limits.h>
+ #include "cubeb/cubeb.h"
+ #include "cubeb-internal.h"
+
+-#define BYTES_TO_FRAMES(bytes, channels) \
+- (bytes / (channels * sizeof(int16_t)))
+-
+-#define FRAMES_TO_BYTES(frames, channels) \
+- (frames * (channels * sizeof(int16_t)))
+-
+ /* Default to 4 + 1 for the default device. */
+ #ifndef SUN_DEVICE_COUNT
+ #define SUN_DEVICE_COUNT (5)
+@@ -41,10 +36,6 @@
+ #define SUN_DEFAULT_DEVICE "/dev/audio"
+ #endif
+
+-#ifndef SUN_POLL_TIMEOUT
+-#define SUN_POLL_TIMEOUT (1000)
+-#endif
+-
+ #ifndef SUN_BUFFER_FRAMES
+ #define SUN_BUFFER_FRAMES (32)
+ #endif
+@@ -75,26 +66,26 @@ struct cubeb {
+ struct cubeb_ops const * ops;
+ };
+
++struct sun_stream {
++ char name[32];
++ int fd;
++ void * buf;
++ struct audio_info info;
++ unsigned frame_size; /* precision in bytes * channels */
++ bool floating;
++};
++
+ struct cubeb_stream {
+ struct cubeb * context;
+ void * user_ptr;
+ pthread_t thread;
+ pthread_mutex_t mutex; /* protects running, volume, frames_written */
+- int floating;
+- int running;
+- int play_fd;
+- int record_fd;
++ bool running;
+ float volume;
+- struct audio_info p_info; /* info for the play fd */
+- struct audio_info r_info; /* info for the record fd */
++ struct sun_stream play;
++ struct sun_stream record;
+ cubeb_data_callback data_cb;
+ cubeb_state_callback state_cb;
+- int16_t * play_buf;
+- int16_t * record_buf;
+- float * f_play_buf;
+- float * f_record_buf;
+- char input_name[32];
+- char output_name[32];
+ uint64_t frames_written;
+ uint64_t blocks_written;
+ };
+@@ -312,18 +303,19 @@ sun_copy_params(int fd, cubeb_stream * s
+ {
+ prinfo->channels = params->channels;
+ prinfo->sample_rate = params->rate;
+- prinfo->precision = 16;
+ #ifdef AUDIO_ENCODING_SLINEAR_LE
+ switch (params->format) {
+ case CUBEB_SAMPLE_S16LE:
+ prinfo->encoding = AUDIO_ENCODING_SLINEAR_LE;
++ prinfo->precision = 16;
+ break;
+ case CUBEB_SAMPLE_S16BE:
+ prinfo->encoding = AUDIO_ENCODING_SLINEAR_BE;
++ prinfo->precision = 16;
+ break;
+ case CUBEB_SAMPLE_FLOAT32NE:
+- stream->floating = 1;
+ prinfo->encoding = AUDIO_ENCODING_SLINEAR;
++ prinfo->precision = 32;
+ break;
+ default:
+ LOG("Unsupported format");
+@@ -333,10 +325,11 @@ sun_copy_params(int fd, cubeb_stream * s
+ switch (params->format) {
+ case CUBEB_SAMPLE_S16NE:
+ prinfo->encoding = AUDIO_ENCODING_LINEAR;
++ prinfo->precision = 16;
+ break;
+ case CUBEB_SAMPLE_FLOAT32NE:
+- stream->floating = 1;
+ prinfo->encoding = AUDIO_ENCODING_LINEAR;
++ prinfo->precision = 32;
+ break;
+ default:
+ LOG("Unsupported format");
+@@ -357,7 +350,7 @@ sun_stream_stop(cubeb_stream * s)
+ {
+ pthread_mutex_lock(&s->mutex);
+ if (s->running) {
+- s->running = 0;
++ s->running = false;
+ pthread_mutex_unlock(&s->mutex);
+ pthread_join(s->thread, NULL);
+ } else {
+@@ -371,53 +364,50 @@ sun_stream_destroy(cubeb_stream * s)
+ {
+ pthread_mutex_destroy(&s->mutex);
+ sun_stream_stop(s);
+- if (s->play_fd != -1) {
+- close(s->play_fd);
++ if (s->play.fd != -1) {
++ close(s->play.fd);
+ }
+- if (s->record_fd != -1) {
+- close(s->record_fd);
++ if (s->record.fd != -1) {
++ close(s->record.fd);
+ }
+- free(s->f_play_buf);
+- free(s->f_record_buf);
+- free(s->play_buf);
+- free(s->record_buf);
++ free(s->play.buf);
++ free(s->record.buf);
+ free(s);
+ }
+
+ static void
+-sun_float_to_linear(float * in, int16_t * out,
+- unsigned channels, long frames, float vol)
++sun_float_to_linear32(void * buf, unsigned sample_count, float vol)
+ {
+- unsigned i, sample_count = frames * channels;
+- float multiplier = vol * 0x8000;
+-
+- for (i = 0; i < sample_count; ++i) {
+- int32_t sample = lrintf(in[i] * multiplier);
+- if (sample < -0x8000) {
+- out[i] = -0x8000;
+- } else if (sample > 0x7fff) {
+- out[i] = 0x7fff;
+- } else {
+- out[i] = sample;
+- }
++ float * in = buf;
++ int32_t * out = buf;
++ int32_t * tail = out + sample_count;
++
++ while (out < tail) {
++ float f = *(in++) * vol;
++ if (f < -1.0)
++ f = -1.0;
++ else if (f > 1.0)
++ f = 1.0;
++ *(out++) = f * (float)INT32_MAX;
+ }
+ }
+
+ static void
+-sun_linear_to_float(int16_t * in, float * out,
+- unsigned channels, long frames)
++sun_linear32_to_float(void * buf, unsigned sample_count)
+ {
+- unsigned i, sample_count = frames * channels;
++ int32_t * in = buf;
++ float * out = buf;
++ float * tail = out + sample_count;
+
+- for (i = 0; i < sample_count; ++i) {
+- out[i] = (1.0 / 0x8000) * in[i];
++ while (out < tail) {
++ *(out++) = (1.0 / 0x80000000) * *(in++);
+ }
+ }
+
+ static void
+-sun_linear_set_vol(int16_t * buf, unsigned channels, long frames, float vol)
++sun_linear16_set_vol(int16_t * buf, unsigned sample_count, float vol)
+ {
+- unsigned i, sample_count = frames * channels;
++ unsigned i;
+ int32_t multiplier = vol * 0x8000;
+
+ for (i = 0; i < sample_count; ++i) {
+@@ -445,41 +435,36 @@ sun_io_routine(void * arg)
+ break;
+ }
+ pthread_mutex_unlock(&s->mutex);
+- if (s->floating) {
+- if (s->record_fd != -1) {
+- sun_linear_to_float(s->record_buf, s->f_record_buf,
+- s->r_info.record.channels, SUN_BUFFER_FRAMES);
+- }
+- to_write = s->data_cb(s, s->user_ptr,
+- s->f_record_buf, s->f_play_buf, SUN_BUFFER_FRAMES);
+- if (to_write == CUBEB_ERROR) {
+- state = CUBEB_STATE_ERROR;
+- break;
+- }
+- if (s->play_fd != -1) {
+- pthread_mutex_lock(&s->mutex);
+- sun_float_to_linear(s->f_play_buf, s->play_buf,
+- s->p_info.play.channels, to_write, s->volume);
+- pthread_mutex_unlock(&s->mutex);
+- }
+- } else {
+- to_write = s->data_cb(s, s->user_ptr,
+- s->record_buf, s->play_buf, SUN_BUFFER_FRAMES);
+- if (to_write == CUBEB_ERROR) {
+- state = CUBEB_STATE_ERROR;
+- break;
+- }
+- if (s->play_fd != -1) {
+- pthread_mutex_lock(&s->mutex);
+- sun_linear_set_vol(s->play_buf, s->p_info.play.channels, to_write, s->volume);
+- pthread_mutex_unlock(&s->mutex);
++ if (s->record.fd != -1 && s->record.floating) {
++ sun_linear32_to_float(s->record.buf,
++ s->record.info.record.channels * SUN_BUFFER_FRAMES);
++ }
++ to_write = s->data_cb(s, s->user_ptr,
++ s->record.buf, s->play.buf, SUN_BUFFER_FRAMES);
++ if (to_write == CUBEB_ERROR) {
++ state = CUBEB_STATE_ERROR;
++ break;
++ }
++ if (s->play.fd != -1) {
++ float vol;
++
++ pthread_mutex_lock(&s->mutex);
++ vol = s->volume;
++ pthread_mutex_unlock(&s->mutex);
++
++ if (s->play.floating) {
++ sun_float_to_linear32(s->play.buf,
++ s->play.info.play.channels * to_write, vol);
++ } else {
++ sun_linear16_set_vol(s->play.buf,
++ s->play.info.play.channels * to_write, vol);
+ }
+ }
+ if (to_write < SUN_BUFFER_FRAMES) {
+ drain = 1;
+ }
+- to_write = s->play_fd != -1 ? to_write : 0;
+- to_read = s->record_fd != -1 ? SUN_BUFFER_FRAMES : 0;
++ to_write = s->play.fd != -1 ? to_write : 0;
++ to_read = s->record.fd != -1 ? SUN_BUFFER_FRAMES : 0;
+ write_ofs = 0;
+ read_ofs = 0;
+ while (to_write > 0 || to_read > 0) {
+@@ -487,27 +472,27 @@ sun_io_routine(void * arg)
+ ssize_t n, frames;
+
+ if (to_write > 0) {
+- bytes = FRAMES_TO_BYTES(to_write, s->p_info.play.channels);
+- if ((n = write(s->play_fd, s->play_buf + write_ofs, bytes)) < 0) {
++ bytes = to_write * s->play.frame_size;
++ if ((n = write(s->play.fd, (uint8_t *)s->play.buf + write_ofs, bytes)) < 0) {
+ state = CUBEB_STATE_ERROR;
+ break;
+ }
+- frames = BYTES_TO_FRAMES(n, s->p_info.play.channels);
++ frames = n / s->play.frame_size;
+ pthread_mutex_lock(&s->mutex);
+ s->frames_written += frames;
+ pthread_mutex_unlock(&s->mutex);
+ to_write -= frames;
+- write_ofs += frames;
++ write_ofs += n;
+ }
+ if (to_read > 0) {
+- bytes = FRAMES_TO_BYTES(to_read, s->r_info.record.channels);
+- if ((n = read(s->record_fd, s->record_buf + read_ofs, bytes)) < 0) {
++ bytes = to_read * s->record.frame_size;
++ if ((n = read(s->record.fd, (uint8_t *)s->record.buf + read_ofs, bytes)) < 0) {
+ state = CUBEB_STATE_ERROR;
+ break;
+ }
+- frames = BYTES_TO_FRAMES(n, s->r_info.record.channels);
++ frames = n / s->record.frame_size;
+ to_read -= frames;
+- read_ofs += frames;
++ read_ofs += n;
+ }
+ }
+ if (drain && state != CUBEB_STATE_ERROR) {
+@@ -536,23 +521,24 @@ sun_stream_init(cubeb * context,
+ cubeb_stream *s = NULL;
+
+ (void)stream_name;
++ (void)latency_frames;
+ if ((s = calloc(1, sizeof(cubeb_stream))) == NULL) {
+ ret = CUBEB_ERROR;
+ goto error;
+ }
+- s->record_fd = -1;
+- s->play_fd = -1;
++ s->record.fd = -1;
++ s->play.fd = -1;
+ if (input_device != 0) {
+- snprintf(s->input_name, sizeof(s->input_name),
++ snprintf(s->record.name, sizeof(s->record.name),
+ "/dev/audio%zu", (uintptr_t)input_device - 1);
+ } else {
+- snprintf(s->input_name, sizeof(s->input_name), "%s", SUN_DEFAULT_DEVICE);
++ snprintf(s->record.name, sizeof(s->record.name), "%s", SUN_DEFAULT_DEVICE);
+ }
+ if (output_device != 0) {
+- snprintf(s->output_name, sizeof(s->output_name),
++ snprintf(s->play.name, sizeof(s->play.name),
+ "/dev/audio%zu", (uintptr_t)output_device - 1);
+ } else {
+- snprintf(s->output_name, sizeof(s->output_name), "%s", SUN_DEFAULT_DEVICE);
++ snprintf(s->play.name, sizeof(s->play.name), "%s", SUN_DEFAULT_DEVICE);
+ }
+ if (input_stream_params != NULL) {
+ if (input_stream_params->prefs & CUBEB_STREAM_PREF_LOOPBACK) {
+@@ -560,22 +546,23 @@ sun_stream_init(cubeb * context,
+ ret = CUBEB_ERROR_NOT_SUPPORTED;
+ goto error;
+ }
+- if (s->record_fd == -1) {
+- if ((s->record_fd = open(s->input_name, O_RDONLY)) == -1) {
+- LOG("Audio device cannot be opened as read-only");
++ if (s->record.fd == -1) {
++ if ((s->record.fd = open(s->record.name, O_RDONLY)) == -1) {
++ LOG("Audio device could not be opened as read-only");
+ ret = CUBEB_ERROR_DEVICE_UNAVAILABLE;
+ goto error;
+ }
+ }
+- AUDIO_INITINFO(&s->r_info);
++ AUDIO_INITINFO(&s->record.info);
+ #ifdef AUMODE_RECORD
+- s->r_info.mode = AUMODE_RECORD;
++ s->record.info.mode = AUMODE_RECORD;
+ #endif
+- if ((ret = sun_copy_params(s->record_fd, s, input_stream_params,
+- &s->r_info, &s->r_info.record)) != CUBEB_OK) {
++ if ((ret = sun_copy_params(s->record.fd, s, input_stream_params,
++ &s->record.info, &s->record.info.record)) != CUBEB_OK) {
+ LOG("Setting record params failed");
+ goto error;
+ }
++ s->record.floating = (input_stream_params->format == CUBEB_SAMPLE_FLOAT32NE);
+ }
+ if (output_stream_params != NULL) {
+ if (output_stream_params->prefs & CUBEB_STREAM_PREF_LOOPBACK) {
+@@ -583,22 +570,23 @@ sun_stream_init(cubeb * context,
+ ret = CUBEB_ERROR_NOT_SUPPORTED;
+ goto error;
+ }
+- if (s->play_fd == -1) {
+- if ((s->play_fd = open(s->output_name, O_WRONLY)) == -1) {
+- LOG("Audio device cannot be opened as write-only");
++ if (s->play.fd == -1) {
++ if ((s->play.fd = open(s->play.name, O_WRONLY)) == -1) {
++ LOG("Audio device could not be opened as write-only");
+ ret = CUBEB_ERROR_DEVICE_UNAVAILABLE;
+ goto error;
+ }
+ }
+- AUDIO_INITINFO(&s->p_info);
++ AUDIO_INITINFO(&s->play.info);
+ #ifdef AUMODE_PLAY
+- s->p_info.mode = AUMODE_PLAY;
++ s->play.info.mode = AUMODE_PLAY;
+ #endif
+- if ((ret = sun_copy_params(s->play_fd, s, output_stream_params,
+- &s->p_info, &s->p_info.play)) != CUBEB_OK) {
++ if ((ret = sun_copy_params(s->play.fd, s, output_stream_params,
++ &s->play.info, &s->play.info.play)) != CUBEB_OK) {
+ LOG("Setting play params failed");
+ goto error;
+ }
++ s->play.floating = (output_stream_params->format == CUBEB_SAMPLE_FLOAT32NE);
+ }
+ s->context = context;
+ s->volume = 1.0;
+@@ -609,28 +597,20 @@ sun_stream_init(cubeb * context,
+ LOG("Failed to create mutex");
+ goto error;
+ }
+- if (s->play_fd != -1 && (s->play_buf = calloc(SUN_BUFFER_FRAMES,
+- s->p_info.play.channels * sizeof(int16_t))) == NULL) {
++ s->play.frame_size = s->play.info.play.channels *
++ (s->play.info.play.precision / 8);
++ if (s->play.fd != -1 &&
++ (s->play.buf = calloc(SUN_BUFFER_FRAMES, s->play.frame_size)) == NULL) {
+ ret = CUBEB_ERROR;
+ goto error;
+ }
+- if (s->record_fd != -1 && (s->record_buf = calloc(SUN_BUFFER_FRAMES,
+- s->r_info.record.channels * sizeof(int16_t))) == NULL) {
++ s->record.frame_size = s->record.info.record.channels *
++ (s->record.info.record.precision / 8);
++ if (s->record.fd != -1 &&
++ (s->record.buf = calloc(SUN_BUFFER_FRAMES, s->record.frame_size)) == NULL) {
+ ret = CUBEB_ERROR;
+ goto error;
+ }
+- if (s->floating) {
+- if (s->play_fd != -1 && (s->f_play_buf = calloc(SUN_BUFFER_FRAMES,
+- s->p_info.play.channels * sizeof(float))) == NULL) {
+- ret = CUBEB_ERROR;
+- goto error;
+- }
+- if (s->record_fd != -1 && (s->f_record_buf = calloc(SUN_BUFFER_FRAMES,
+- s->r_info.record.channels * sizeof(float))) == NULL) {
+- ret = CUBEB_ERROR;
+- goto error;
+- }
+- }
+ *stream = s;
+ return CUBEB_OK;
+ error:
+@@ -643,7 +623,7 @@ error:
+ static int
+ sun_stream_start(cubeb_stream * s)
+ {
+- s->running = 1;
++ s->running = true;
+ if (pthread_create(&s->thread, NULL, sun_io_routine, s) != 0) {
+ LOG("Couldn't create thread");
+ return CUBEB_ERROR;
+@@ -657,12 +637,11 @@ sun_stream_get_position(cubeb_stream * s
+ #ifdef AUDIO_GETOOFFS
+ struct audio_offset offset;
+
+- if (ioctl(s->play_fd, AUDIO_GETOOFFS, &offset) == -1) {
++ if (ioctl(s->play.fd, AUDIO_GETOOFFS, &offset) == -1) {
+ return CUBEB_ERROR;
+ }
+ s->blocks_written += offset.deltablks;
+- *position = BYTES_TO_FRAMES(s->blocks_written * s->p_info.blocksize,
+- s->p_info.play.channels);
++ *position = (s->blocks_written * s->play.info.blocksize) / s->play.frame_size;
+ return CUBEB_OK;
+ #else
+ pthread_mutex_lock(&s->mutex);
+@@ -673,22 +652,21 @@ sun_stream_get_position(cubeb_stream * s
+ }
+
+ static int
+-sun_stream_get_latency(cubeb_stream * stream, uint32_t * latency)
++sun_stream_get_latency(cubeb_stream * s, uint32_t * latency)
+ {
+ #ifdef AUDIO_GETBUFINFO
+ struct audio_info info;
+
+- if (ioctl(stream->play_fd, AUDIO_GETBUFINFO, &info) == -1) {
++ if (ioctl(s->play.fd, AUDIO_GETBUFINFO, &info) == -1) {
+ return CUBEB_ERROR;
+ }
+
+- *latency = BYTES_TO_FRAMES(info.play.seek + info.blocksize / 2,
+- info.play.channels);
++ *latency = (info.play.seek + info.blocksize) / s->play.frame_size;
+ return CUBEB_OK;
+ #else
+ cubeb_stream_params params;
+
+- params.rate = stream->p_info.play.sample_rate;
++ params.rate = stream->play.info.play.sample_rate;
+
+ return sun_get_min_latency(NULL, params, latency);
+ #endif
+@@ -710,10 +688,10 @@ sun_get_current_device(cubeb_stream * st
+ if (*device == NULL) {
+ return CUBEB_ERROR;
+ }
+- (*device)->input_name = stream->record_fd != -1 ?
+- strdup(stream->input_name) : NULL;
+- (*device)->output_name = stream->play_fd != -1 ?
+- strdup(stream->output_name) : NULL;
++ (*device)->input_name = stream->record.fd != -1 ?
++ strdup(stream->record.name) : NULL;
++ (*device)->output_name = stream->play.fd != -1 ?
++ strdup(stream->play.name) : NULL;
+ return CUBEB_OK;
+ }
+
+@@ -740,11 +718,11 @@ static struct cubeb_ops const sun_ops =
+ .stream_destroy = sun_stream_destroy,
+ .stream_start = sun_stream_start,
+ .stream_stop = sun_stream_stop,
+- .stream_reset_default_device = NULL,
+ .stream_get_position = sun_stream_get_position,
+ .stream_get_latency = sun_stream_get_latency,
++ .stream_get_input_latency = NULL,
+ .stream_set_volume = sun_stream_set_volume,
+- .stream_set_panning = NULL,
++ .stream_set_name = NULL,
+ .stream_get_current_device = sun_get_current_device,
+ .stream_device_destroy = sun_stream_device_destroy,
+ .stream_register_device_changed_callback = NULL,
Index: pkgsrc/mail/thunderbird115/patches/patch-media_libpng_pngpriv.h
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-media_libpng_pngpriv.h:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-media_libpng_pngpriv.h Tue Oct 1 14:21:37 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-media_libpng_pngpriv.h,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- media/libpng/pngpriv.h.orig 2020-08-28 21:33:11.000000000 +0000
++++ media/libpng/pngpriv.h
+@@ -36,8 +36,10 @@
+ * still required (as of 2011-05-02.)
+ */
+ #ifndef _POSIX_SOURCE
++#if !defined(__sun) || (__STDC_VERSION__-0 < 199901L)
+ # define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
+ #endif
++#endif
+
+ #ifndef PNG_VERSION_INFO_ONLY
+ /* Standard library headers not required by png.h: */
Index: pkgsrc/mail/thunderbird115/patches/patch-media_libtheora_lib_info.c
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-media_libtheora_lib_info.c:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-media_libtheora_lib_info.c Tue Oct 1 14:21:37 2024
@@ -0,0 +1,13 @@
+$NetBSD: patch-media_libtheora_lib_info.c,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- media/libtheora/lib/info.c.orig 2020-08-28 21:32:52.000000000 +0000
++++ media/libtheora/lib/info.c
+@@ -29,7 +29,7 @@
+ static int oc_tagcompare(const char *_s1,const char *_s2,int _n){
+ int c;
+ for(c=0;c<_n;c++){
+- if(toupper(_s1[c])!=toupper(_s2[c]))return !0;
++ if(toupper((unsigned char)_s1[c])!=toupper((unsigned char)_s2[c]))return !0;
+ }
+ return _s1[c]!='=';
+ }
Index: pkgsrc/mail/thunderbird115/patches/patch-nsprpub_pr_src_pthreads_ptsynch.c
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-nsprpub_pr_src_pthreads_ptsynch.c:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-nsprpub_pr_src_pthreads_ptsynch.c Tue Oct 1 14:21:37 2024
@@ -0,0 +1,104 @@
+$NetBSD: patch-nsprpub_pr_src_pthreads_ptsynch.c,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- nsprpub/pr/src/pthreads/ptsynch.c.orig 2020-08-28 21:33:00.000000000 +0000
++++ nsprpub/pr/src/pthreads/ptsynch.c
+@@ -25,6 +25,13 @@ static pthread_condattr_t _pt_cvar_attr;
+ extern PTDebug pt_debug; /* this is shared between several modules */
+ #endif /* defined(DEBUG) */
+
++/* XXX, pthread_equal() is misused to compare non-valid thread pointers */
++static int
++pt_pthread_equal(pthread_t t1, pthread_t t2)
++{
++ return t1 == t2;
++}
++
+ #if defined(FREEBSD)
+ /*
+ * On older versions of FreeBSD, pthread_mutex_trylock returns EDEADLK.
+@@ -197,9 +204,9 @@ PR_IMPLEMENT(PRStatus) PR_Unlock(PRLock
+ PR_ASSERT(lock != NULL);
+ PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(lock->mutex));
+ PR_ASSERT(PR_TRUE == lock->locked);
+- PR_ASSERT(pthread_equal(lock->owner, self));
++ PR_ASSERT(pt_pthread_equal(lock->owner, self));
+
+- if (!lock->locked || !pthread_equal(lock->owner, self)) {
++ if (!lock->locked || !pt_pthread_equal(lock->owner, self)) {
+ return PR_FAILURE;
+ }
+
+@@ -225,7 +232,7 @@ PR_IMPLEMENT(void) PR_AssertCurrentThrea
+ * to the correctness of PR_AssertCurrentThreadOwnsLock(), but
+ * this particular order makes the assertion more likely to
+ * catch errors. */
+- PR_ASSERT(lock->locked && pthread_equal(lock->owner, pthread_self()));
++ PR_ASSERT(lock->locked && pt_pthread_equal(lock->owner, pthread_self()));
+ }
+
+ /**************************************************************/
+@@ -281,7 +288,7 @@ static void pt_PostNotifyToCvar(PRCondVa
+ _PT_Notified *notified = &cvar->lock->notified;
+
+ PR_ASSERT(PR_TRUE == cvar->lock->locked);
+- PR_ASSERT(pthread_equal(cvar->lock->owner, pthread_self()));
++ PR_ASSERT(pt_pthread_equal(cvar->lock->owner, pthread_self()));
+ PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(cvar->lock->mutex));
+
+ while (1)
+@@ -369,7 +376,7 @@ PR_IMPLEMENT(PRStatus) PR_WaitCondVar(PR
+ PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(cvar->lock->mutex));
+ PR_ASSERT(PR_TRUE == cvar->lock->locked);
+ /* and it better be by us */
+- PR_ASSERT(pthread_equal(cvar->lock->owner, pthread_self()));
++ PR_ASSERT(pt_pthread_equal(cvar->lock->owner, pthread_self()));
+
+ if (_PT_THREAD_INTERRUPTED(thred)) {
+ goto aborted;
+@@ -582,7 +589,7 @@ PR_IMPLEMENT(PRIntn) PR_GetMonitorEntryC
+
+ rv = pthread_mutex_lock(&mon->lock);
+ PR_ASSERT(0 == rv);
+- if (pthread_equal(mon->owner, self)) {
++ if (pt_pthread_equal(mon->owner, self)) {
+ count = mon->entryCount;
+ }
+ rv = pthread_mutex_unlock(&mon->lock);
+@@ -598,7 +605,7 @@ PR_IMPLEMENT(void) PR_AssertCurrentThrea
+ rv = pthread_mutex_lock(&mon->lock);
+ PR_ASSERT(0 == rv);
+ PR_ASSERT(mon->entryCount != 0 &&
+- pthread_equal(mon->owner, pthread_self()));
++ pt_pthread_equal(mon->owner, pthread_self()));
+ rv = pthread_mutex_unlock(&mon->lock);
+ PR_ASSERT(0 == rv);
+ #endif
+@@ -614,7 +621,7 @@ PR_IMPLEMENT(void) PR_EnterMonitor(PRMon
+ PR_ASSERT(0 == rv);
+ if (mon->entryCount != 0)
+ {
+- if (pthread_equal(mon->owner, self)) {
++ if (pt_pthread_equal(mon->owner, self)) {
+ goto done;
+ }
+ while (mon->entryCount != 0)
+@@ -646,8 +653,8 @@ PR_IMPLEMENT(PRStatus) PR_ExitMonitor(PR
+ PR_ASSERT(0 == rv);
+ /* the entries should be > 0 and we'd better be the owner */
+ PR_ASSERT(mon->entryCount > 0);
+- PR_ASSERT(pthread_equal(mon->owner, self));
+- if (mon->entryCount == 0 || !pthread_equal(mon->owner, self))
++ PR_ASSERT(pt_pthread_equal(mon->owner, self));
++ if (mon->entryCount == 0 || !pt_pthread_equal(mon->owner, self))
+ {
+ rv = pthread_mutex_unlock(&mon->lock);
+ PR_ASSERT(0 == rv);
+@@ -695,7 +702,7 @@ PR_IMPLEMENT(PRStatus) PR_Wait(PRMonitor
+ /* the entries better be positive */
+ PR_ASSERT(mon->entryCount > 0);
+ /* and it better be owned by us */
+- PR_ASSERT(pthread_equal(mon->owner, pthread_self()));
++ PR_ASSERT(pt_pthread_equal(mon->owner, pthread_self()));
+
+ /* tuck these away 'till later */
+ saved_entries = mon->entryCount;
Index: pkgsrc/mail/thunderbird115/patches/patch-old-configure.in
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-old-configure.in:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-old-configure.in Tue Oct 1 14:21:37 2024
@@ -0,0 +1,24 @@
+$NetBSD: patch-old-configure.in,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- old-configure.in.orig 2020-08-28 21:33:19.000000000 +0000
++++ old-configure.in
+@@ -681,6 +681,19 @@ fi
+
+ AC_CHECK_LIB(socket, socket)
+
++dnl ==================================
++dnl = Check sunaudio availability
++dnl ==================================
++
++dnl If using Solaris or NetBSD, ensure that sunaudio is available
++case "$OS_TARGET" in
++SunOS|NetBSD)
++ MOZ_SUNAUDIO=1
++ ;;
++esac
++
++AC_SUBST(MOZ_SUNAUDIO)
++
+ dnl ========================================================
+ dnl = pthread support
+ dnl = Start by checking whether the system support pthreads
Index: pkgsrc/mail/thunderbird115/patches/patch-rust-1.78.0
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-rust-1.78.0:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-rust-1.78.0 Tue Oct 1 14:21:37 2024
@@ -0,0 +1,3564 @@
+Adapted from https://hg.mozilla.org/mozilla-central/rev/1db2ef126a6a
+--
+
+# HG changeset patch
+# User Henri Sivonen <hsivonen%hsivonen.fi@localhost>
+# Date 1714462184 0
+# Node ID 1db2ef126a6a8555dbf50345e16492c977b42e92
+# Parent a545e84b3674c4878f2e618b7bce23058f2ac690
+Bug 1882209 - Update encoding_rs to 0.8.34 to deal with rustc changes. r=glandium,supply-chain-reviewers
+
+Differential Revision: https://phabricator.services.mozilla.com/D207167
+
+diff --git a/.cargo/config.in b/.cargo/config.in
+--- .cargo/config.in
++++ .cargo/config.in
+@@ -35,31 +35,31 @@ git = "https://github.com/gfx-rs/wgpu"
+ rev = "f71a1bc736fde37509262ca03e91d8f56a13aeb5"
+ replace-with = "vendored-sources"
+
+ [source."git+https://github.com/glandium/warp?rev=4af45fae95bc98b0eba1ef0db17e1dac471bb23d"]
+ git = "https://github.com/glandium/warp"
+ rev = "4af45fae95bc98b0eba1ef0db17e1dac471bb23d"
+ replace-with = "vendored-sources"
+
++[source."git+https://github.com/hsivonen/any_all_workaround?rev=7fb1b7034c9f172aade21ee1c8554e8d8a48af80"]
++git = "https://github.com/hsivonen/any_all_workaround"
++rev = "7fb1b7034c9f172aade21ee1c8554e8d8a48af80"
++replace-with = "vendored-sources"
++
+ [source."git+https://github.com/hsivonen/chardetng?rev=3484d3e3ebdc8931493aa5df4d7ee9360a90e76b"]
+ git = "https://github.com/hsivonen/chardetng"
+ rev = "3484d3e3ebdc8931493aa5df4d7ee9360a90e76b"
+ replace-with = "vendored-sources"
+
+ [source."git+https://github.com/hsivonen/chardetng_c?rev=ed8a4c6f900a90d4dbc1d64b856e61490a1c3570"]
+ git = "https://github.com/hsivonen/chardetng_c"
+ rev = "ed8a4c6f900a90d4dbc1d64b856e61490a1c3570"
+ replace-with = "vendored-sources"
+
+-[source."git+https://github.com/hsivonen/packed_simd?rev=e588ceb568878e1a3156ea9ce551d5b63ef0cdc4"]
+-git = "https://github.com/hsivonen/packed_simd"
+-rev = "e588ceb568878e1a3156ea9ce551d5b63ef0cdc4"
+-replace-with = "vendored-sources"
+-
+ [source."git+https://github.com/jfkthame/mapped_hyph.git?rev=c7651a0cffff41996ad13c44f689bd9cd2192c01"]
+ git = "https://github.com/jfkthame/mapped_hyph.git"
+ rev = "c7651a0cffff41996ad13c44f689bd9cd2192c01"
+ replace-with = "vendored-sources"
+
+ [source."git+https://github.com/mozilla-spidermonkey/jsparagus?rev=64ba08e24749616de2344112f226d1ef4ba893ae"]
+ git = "https://github.com/mozilla-spidermonkey/jsparagus"
+ rev = "64ba08e24749616de2344112f226d1ef4ba893ae"
+diff --git a/Cargo.lock b/Cargo.lock
+--- Cargo.lock
++++ Cargo.lock
+@@ -80,16 +80,25 @@ dependencies = [
+ name = "android_system_properties"
+ version = "0.1.5"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
+ dependencies = [
+ "libc",
+ ]
+
++[[package]]
++name = "any_all_workaround"
++version = "0.1.0"
++source = "git+https://github.com/hsivonen/any_all_workaround?rev=7fb1b7034c9f172aade21ee1c8554e8d8a48af80#7fb1b7034c9f172aade21ee1c8554e8d8a48af80"
++dependencies = [
++ "cfg-if 1.0.0",
++ "version_check",
++]
++
+ [[package]]
+ name = "anyhow"
+ version = "1.0.69"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800"
+
+ [[package]]
+ name = "app_services_logger"
+@@ -1431,22 +1440,22 @@ dependencies = [
+ "encoding_rs",
+ "nserror",
+ "nsstring",
+ "xmldecl",
+ ]
+
+ [[package]]
+ name = "encoding_rs"
+-version = "0.8.33"
++version = "0.8.34"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+-checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1"
++checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59"
+ dependencies = [
++ "any_all_workaround",
+ "cfg-if 1.0.0",
+- "packed_simd",
+ ]
+
+ [[package]]
+ name = "enum-primitive-derive"
+ version = "0.2.2"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ checksum = "c375b9c5eadb68d0a6efee2999fef292f45854c3444c86f09d8ab086ba942b0e"
+ dependencies = [
+@@ -3901,25 +3910,16 @@ checksum = "8d91edf4fbb970279443471345a4e8c491bf05bb283b3e6c88e4e606fd8c181b"
+ [[package]]
+ name = "oxilangtag-ffi"
+ version = "0.1.0"
+ dependencies = [
+ "nsstring",
+ "oxilangtag",
+ ]
+
+-[[package]]
+-name = "packed_simd"
+-version = "0.3.9"
+-source = "git+https://github.com/hsivonen/packed_simd?rev=e588ceb568878e1a3156ea9ce551d5b63ef0cdc4#e588ceb568878e1a3156ea9ce551d5b63ef0cdc4"
+-dependencies = [
+- "cfg-if 1.0.0",
+- "num-traits",
+-]
+-
+ [[package]]
+ name = "parking_lot"
+ version = "0.11.2"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
+ dependencies = [
+ "instant",
+ "lock_api",
+diff --git a/Cargo.toml b/Cargo.toml
+--- Cargo.toml
++++ Cargo.toml
+@@ -154,22 +154,22 @@ rure = { path = "third_party/rust/rure" }
+
+ # 0.31.1 but without rust-cssparser#342.
+ # TODO: Remove these, and just use v0.31.1 once bug 1836219 lands
+ # (which will get syn 2 into the tree).
+ cssparser = { path = "third_party/rust/cssparser" }
+ cssparser-macros = { path = "third_party/rust/cssparser-macros" }
+
+ # Other overrides
++any_all_workaround = { git = "https://github.com/hsivonen/any_all_workaround", rev = "7fb1b7034c9f172aade21ee1c8554e8d8a48af80" }
+ chardetng = { git = "https://github.com/hsivonen/chardetng", rev="3484d3e3ebdc8931493aa5df4d7ee9360a90e76b" }
+ chardetng_c = { git = "https://github.com/hsivonen/chardetng_c", rev="ed8a4c6f900a90d4dbc1d64b856e61490a1c3570" }
+ coremidi = { git = "https://github.com/chris-zen/coremidi.git", rev="fc68464b5445caf111e41f643a2e69ccce0b4f83" }
+ firefox-on-glean = { path = "toolkit/components/glean/api" }
+ libudev-sys = { path = "dom/webauthn/libudev-sys" }
+-packed_simd = { git = "https://github.com/hsivonen/packed_simd", rev = "e588ceb568878e1a3156ea9ce551d5b63ef0cdc4" }
+ midir = { git = "https://github.com/mozilla/midir.git", rev = "519e651241e867af3391db08f9ae6400bc023e18" }
+ # warp 0.3.3 + https://github.com/seanmonstar/warp/pull/1007
+ warp = { git = "https://github.com/glandium/warp", rev = "4af45fae95bc98b0eba1ef0db17e1dac471bb23d" }
+
+ # application-services overrides to make updating them all simpler.
+ interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "86c84c217036c12283d19368867323a66bf35883" }
+ sql-support = { git = "https://github.com/mozilla/application-services", rev = "86c84c217036c12283d19368867323a66bf35883" }
+ sync15 = { git = "https://github.com/mozilla/application-services", rev = "86c84c217036c12283d19368867323a66bf35883" }
+diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml
+--- supply-chain/audits.toml
++++ supply-chain/audits.toml
+@@ -596,16 +596,29 @@ who = "Mike Hommey <mh+mozilla@glandium.
+ criteria = "safe-to-deploy"
+ delta = "0.1.2 -> 0.1.4"
+
+ [[audits.android_system_properties]]
+ who = "Mike Hommey <mh+mozilla%glandium.org@localhost>"
+ criteria = "safe-to-deploy"
+ delta = "0.1.4 -> 0.1.5"
+
++[[audits.any_all_workaround]]
++who = "Henri Sivonen <hsivonen%hsivonen.fi@localhost>"
++criteria = "safe-to-deploy"
++version = "0.1.0"
++notes = "The little code that is in this crate I reviewed and modified from packed_simd (which has previously been vendored in full instead of just this small part)."
++
++[[audits.any_all_workaround]]
++who = "Henri Sivonen <hsivonen%hsivonen.fi@localhost>"
++criteria = "safe-to-deploy"
++delta = "0.1.0 -> 0.1.0@git:7fb1b7034c9f172aade21ee1c8554e8d8a48af80"
++importable = false
++notes = "This is a trivial workaround copied from elsewhere in m-c, specifically qcms."
++
+ [[audits.anyhow]]
+ who = "Mike Hommey <mh+mozilla%glandium.org@localhost>"
+ criteria = "safe-to-deploy"
+ delta = "1.0.57 -> 1.0.61"
+
+ [[audits.anyhow]]
+ who = "Bobby Holley <bobbyholley%gmail.com@localhost>"
+ criteria = "safe-to-deploy"
+diff --git a/supply-chain/config.toml b/supply-chain/config.toml
+--- supply-chain/config.toml
++++ supply-chain/config.toml
+@@ -14,16 +14,20 @@ url = "https://raw.githubusercontent.com
+ url = "https://raw.githubusercontent.com/google/supply-chain/main/audits.toml"
+
+ [imports.isrg]
+ url = "https://raw.githubusercontent.com/divviup/libprio-rs/main/supply-chain/audits.toml"
+
+ [imports.mozilla]
+ url = "https://raw.githubusercontent.com/mozilla/supply-chain/main/audits.toml"
+
++[policy.any_all_workaround]
++audit-as-crates-io = true
++notes = "This is the upstream code plus the ARM intrinsics workaround from qcms, see bug 1882209."
++
+ [policy.autocfg]
+ audit-as-crates-io = true
+ notes = "This is the upstream code plus a few local fixes, see bug 1685697."
+
+ [policy.chardetng]
+ audit-as-crates-io = true
+ notes = "This is a crate Henri wrote which is also published. We should probably update Firefox to tip and certify that."
+
+diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock
+--- supply-chain/imports.lock
++++ supply-chain/imports.lock
+@@ -115,16 +115,23 @@ user-name = "David Tolnay"
+
+ [[publisher.encoding_rs]]
+ version = "0.8.33"
+ when = "2023-08-23"
+ user-id = 4484
+ user-login = "hsivonen"
+ user-name = "Henri Sivonen"
+
++[[publisher.encoding_rs]]
++version = "0.8.34"
++when = "2024-04-10"
++user-id = 4484
++user-login = "hsivonen"
++user-name = "Henri Sivonen"
++
+ [[publisher.etagere]]
+ version = "0.2.7"
+ when = "2022-05-04"
+ user-id = 1281
+ user-login = "nical"
+ user-name = "Nicolas Silva"
+
+ [[publisher.euclid]]
+diff --git a/third_party/rust/any_all_workaround/.cargo-checksum.json b/third_party/rust/any_all_workaround/.cargo-checksum.json
+new file mode 100644
+--- /dev/null
++++ third_party/rust/any_all_workaround/.cargo-checksum.json
+@@ -0,0 +1,1 @@
++{"files":{"Cargo.toml":"f8c127449dc9432d404c21c99833e4617ab88a797445af249a7fe3c989985d6d","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","LICENSE-MIT-QCMS":"36d847ae882f6574ebc72f56a4f354e4f104fde4a584373496482e97d52d31bc","README.md":"4c617b8ced3a27b7edecf0e5e41ed451c04e88dab529e7a35fccc4e1551efbd7","build.rs":"56b29ab6da3e49075bfd0a7b690267c8016298bf0d332e2e68bbaf19decbbf71","src/lib.rs":"7118106690b9d25c5d0a3e2079feb83d76f1d434d0da36b9d0351806d27c850d"},"package":null}
+\ No newline at end of file
+diff --git a/third_party/rust/any_all_workaround/Cargo.toml b/third_party/rust/any_all_workaround/Cargo.toml
+new file mode 100644
+--- /dev/null
++++ third_party/rust/any_all_workaround/Cargo.toml
+@@ -0,0 +1,28 @@
++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
++#
++# When uploading crates to the registry Cargo will automatically
++# "normalize" Cargo.toml files for maximal compatibility
++# with all versions of Cargo and also rewrite `path` dependencies
++# to registry (e.g., crates.io) dependencies.
++#
++# If you are reading this file be aware that the original Cargo.toml
++# will likely look very different (and much more reasonable).
++# See Cargo.toml.orig for the original contents.
++
++[package]
++edition = "2021"
++name = "any_all_workaround"
++version = "0.1.0"
++authors = ["Henri Sivonen <hsivonen%hsivonen.fi@localhost>"]
++description = "Workaround for bad LLVM codegen for boolean reductions on 32-bit ARM"
++homepage = "https://docs.rs/any_all_workaround/"
++documentation = "https://docs.rs/any_all_workaround/"
++readme = "README.md"
++license = "MIT OR Apache-2.0"
++repository = "https://github.com/hsivonen/any_all_workaround"
++
++[dependencies]
++cfg-if = "1.0"
++
++[build-dependencies]
++version_check = "0.9"
+diff --git a/third_party/rust/packed_simd/LICENSE-APACHE b/third_party/rust/any_all_workaround/LICENSE-APACHE
+rename from third_party/rust/packed_simd/LICENSE-APACHE
+rename to third_party/rust/any_all_workaround/LICENSE-APACHE
+diff --git a/third_party/rust/packed_simd/LICENSE-MIT b/third_party/rust/any_all_workaround/LICENSE-MIT
+rename from third_party/rust/packed_simd/LICENSE-MIT
+rename to third_party/rust/any_all_workaround/LICENSE-MIT
+diff --git a/third_party/rust/any_all_workaround/LICENSE-MIT-QCMS b/third_party/rust/any_all_workaround/LICENSE-MIT-QCMS
+new file mode 100644
+--- /dev/null
++++ third_party/rust/any_all_workaround/LICENSE-MIT-QCMS
+@@ -0,0 +1,21 @@
++qcms
++Copyright (C) 2009-2024 Mozilla Corporation
++Copyright (C) 1998-2007 Marti Maria
++
++Permission is hereby granted, free of charge, to any person obtaining
++a copy of this software and associated documentation files (the "Software"),
++to deal in the Software without restriction, including without limitation
++the rights to use, copy, modify, merge, publish, distribute, sublicense,
++and/or sell copies of the Software, and to permit persons to whom the Software
++is furnished to do so, subject to the following conditions:
++
++The above copyright notice and this permission notice shall be included in
++all copies or substantial portions of the Software.
++
++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
++THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+diff --git a/third_party/rust/any_all_workaround/README.md b/third_party/rust/any_all_workaround/README.md
+new file mode 100644
+--- /dev/null
++++ third_party/rust/any_all_workaround/README.md
+@@ -0,0 +1,13 @@
++# any_all_workaround
++
++This is a workaround for bad codegen ([Rust bug](https://github.com/rust-lang/portable-simd/issues/146), [LLVM bug](https://github.com/llvm/llvm-project/issues/50466)) for the `any()` and `all()`
reductions for NEON-backed SIMD vectors on 32-bit ARM. On other platforms these delegate to `any()` and `all()` in `core::simd`.
++
++The plan is to abandon this crate once the LLVM bug is fixed or `core::simd` works around the LLVM bug.
++
++The code is forked from the [`packed_simd` crate](https://raw.githubusercontent.com/hsivonen/packed_simd/d938e39bee9bc5c222f5f2f2a0df9e53b5ce36ae/src/codegen/reductions/mask/arm.rs).
++
++This crate requires Nightly Rust as it depends on the `portable_simd` feature.
++
++# License
++
++`MIT OR Apache-2.0`, since that's how `packed_simd` is licensed. (The ARM intrinsics Rust version workaround is from qcms, see LICENSE-MIT-QCMS.)
+diff --git a/third_party/rust/any_all_workaround/build.rs b/third_party/rust/any_all_workaround/build.rs
+new file mode 100644
+--- /dev/null
++++ third_party/rust/any_all_workaround/build.rs
+@@ -0,0 +1,7 @@
++extern crate version_check as rustc;
++
++fn main() {
++ if rustc::is_min_version("1.78.0").unwrap_or(false) {
++ println!("cargo:rustc-cfg=stdsimd_split");
++ }
++}
+diff --git a/third_party/rust/any_all_workaround/src/lib.rs b/third_party/rust/any_all_workaround/src/lib.rs
+new file mode 100644
+--- /dev/null
++++ third_party/rust/any_all_workaround/src/lib.rs
+@@ -0,0 +1,110 @@
++// This code began as a fork of
++// https://raw.githubusercontent.com/rust-lang/packed_simd/d938e39bee9bc5c222f5f2f2a0df9e53b5ce36ae/src/codegen/reductions/mask/arm.rs
++// which didn't have a license header on the file, but Cargo.toml said "MIT OR Apache-2.0".
++// See LICENSE-MIT and LICENSE-APACHE.
++
++#![no_std]
++#![feature(portable_simd)]
++#![cfg_attr(
++ all(
++ stdsimd_split,
++ target_arch = "arm",
++ target_endian = "little",
++ target_feature = "neon",
++ target_feature = "v7"
++ ),
++ feature(stdarch_arm_neon_intrinsics)
++)]
++#![cfg_attr(
++ all(
++ not(stdsimd_split),
++ target_arch = "arm",
++ target_endian = "little",
++ target_feature = "neon",
++ target_feature = "v7"
++ ),
++ feature(stdsimd)
++)]
++
++use cfg_if::cfg_if;
++use core::simd::mask16x8;
++use core::simd::mask32x4;
++use core::simd::mask8x16;
++
++cfg_if! {
++ if #[cfg(all(target_arch = "arm", target_endian = "little", target_feature = "neon", target_feature = "v7"))] {
++ use core::simd::mask8x8;
++ use core::simd::mask16x4;
++ use core::simd::mask32x2;
++ macro_rules! arm_128_v7_neon_impl {
++ ($all:ident, $any:ident, $id:ident, $half:ident, $vpmin:ident, $vpmax:ident) => {
++ #[inline]
++ pub fn $all(s: $id) -> bool {
++ use core::arch::arm::$vpmin;
++ use core::mem::transmute;
++ unsafe {
++ union U {
++ halves: ($half, $half),
++ vec: $id,
++ }
++ let halves = U { vec: s }.halves;
++ let h: $half = transmute($vpmin(transmute(halves.0), transmute(halves.1)));
++ h.all()
++ }
++ }
++ #[inline]
++ pub fn $any(s: $id) -> bool {
++ use core::arch::arm::$vpmax;
++ use core::mem::transmute;
++ unsafe {
++ union U {
++ halves: ($half, $half),
++ vec: $id,
++ }
++ let halves = U { vec: s }.halves;
++ let h: $half = transmute($vpmax(transmute(halves.0), transmute(halves.1)));
++ h.any()
++ }
++ }
++ }
++ }
++ } else {
++ macro_rules! arm_128_v7_neon_impl {
++ ($all:ident, $any:ident, $id:ident, $half:ident, $vpmin:ident, $vpmax:ident) => {
++ #[inline(always)]
++ pub fn $all(s: $id) -> bool {
++ s.all()
++ }
++ #[inline(always)]
++ pub fn $any(s: $id) -> bool {
++ s.any()
++ }
++ }
++ }
++ }
++}
++
++arm_128_v7_neon_impl!(
++ all_mask8x16,
++ any_mask8x16,
++ mask8x16,
++ mask8x8,
++ vpmin_u8,
++ vpmax_u8
++);
++arm_128_v7_neon_impl!(
++ all_mask16x8,
++ any_mask16x8,
++ mask16x8,
++ mask16x4,
++ vpmin_u16,
++ vpmax_u16
++);
++arm_128_v7_neon_impl!(
++ all_mask32x4,
++ any_mask32x4,
++ mask32x4,
++ mask32x2,
++ vpmin_u32,
++ vpmax_u32
++);
+diff --git a/third_party/rust/encoding_rs/Cargo.toml b/third_party/rust/encoding_rs/Cargo.toml
+--- third_party/rust/encoding_rs/Cargo.toml
++++ third_party/rust/encoding_rs/Cargo.toml
+@@ -6,18 +6,19 @@
+ # to registry (e.g., crates.io) dependencies.
+ #
+ # If you are reading this file be aware that the original Cargo.toml
+ # will likely look very different (and much more reasonable).
+ # See Cargo.toml.orig for the original contents.
+
+ [package]
+ edition = "2018"
++rust-version = "1.36"
+ name = "encoding_rs"
+-version = "0.8.33"
++version = "0.8.34"
+ authors = ["Henri Sivonen <hsivonen%hsivonen.fi@localhost>"]
+ description = "A Gecko-oriented implementation of the Encoding Standard"
+ homepage = "https://docs.rs/encoding_rs/"
+ documentation = "https://docs.rs/encoding_rs/"
+ readme = "README.md"
+ keywords = [
+ "encoding",
+ "web",
+@@ -31,23 +32,23 @@ categories = [
+ "internationalization",
+ ]
+ license = "(Apache-2.0 OR MIT) AND BSD-3-Clause"
+ repository = "https://github.com/hsivonen/encoding_rs"
+
+ [profile.release]
+ lto = true
+
++[dependencies.any_all_workaround]
++version = "0.1.0"
++optional = true
++
+ [dependencies.cfg-if]
+ version = "1.0"
+
+-[dependencies.packed_simd]
+-version = "0.3.9"
+-optional = true
+-
+ [dependencies.serde]
+ version = "1.0"
+ optional = true
+
+ [dev-dependencies.bincode]
+ version = "1.0"
+
+ [dev-dependencies.serde_derive]
+@@ -69,15 +70,9 @@ fast-legacy-encode = [
+ "fast-hanja-encode",
+ "fast-kanji-encode",
+ "fast-gb-hanzi-encode",
+ "fast-big5-hanzi-encode",
+ ]
+ less-slow-big5-hanzi-encode = []
+ less-slow-gb-hanzi-encode = []
+ less-slow-kanji-encode = []
+-simd-accel = [
+- "packed_simd",
+- "packed_simd/into_bits",
+-]
+-
+-[badges.travis-ci]
+-repository = "hsivonen/encoding_rs"
++simd-accel = ["any_all_workaround"]
+diff --git a/third_party/rust/encoding_rs/README.md b/third_party/rust/encoding_rs/README.md
+--- third_party/rust/encoding_rs/README.md
++++ third_party/rust/encoding_rs/README.md
+@@ -162,50 +162,36 @@ wrappers.
+ * [C++](https://github.com/hsivonen/recode_cpp)
+
+ ## Optional features
+
+ There are currently these optional cargo features:
+
+ ### `simd-accel`
+
+-Enables SIMD acceleration using the nightly-dependent `packed_simd` crate.
++Enables SIMD acceleration using the nightly-dependent `portable_simd` standard
++library feature.
+
+ This is an opt-in feature, because enabling this feature _opts out_ of Rust's
+ guarantees of future compilers compiling old code (aka. "stability story").
+
+ Currently, this has not been tested to be an improvement except for these
+-targets:
++targets and enabling the `simd-accel` feature is expected to break the build
++on other targets:
+
+ * x86_64
+ * i686
+ * aarch64
+ * thumbv7neon
+
+ If you use nightly Rust, you use targets whose first component is one of the
+ above, and you are prepared _to have to revise your configuration when updating
+ Rust_, you should enable this feature. Otherwise, please _do not_ enable this
+ feature.
+
+-_Note!_ If you are compiling for a target that does not have 128-bit SIMD
+-enabled as part of the target definition and you are enabling 128-bit SIMD
+-using `-C target_feature`, you need to enable the `core_arch` Cargo feature
+-for `packed_simd` to compile a crates.io snapshot of `core_arch` instead of
+-using the standard-library copy of `core::arch`, because the `core::arch`
+-module of the pre-compiled standard library has been compiled with the
+-assumption that the CPU doesn't have 128-bit SIMD. At present this applies
+-mainly to 32-bit ARM targets whose first component does not include the
+-substring `neon`.
+-
+-The encoding_rs side of things has not been properly set up for POWER,
+-PowerPC, MIPS, etc., SIMD at this time, so even if you were to follow
+-the advice from the previous paragraph, you probably shouldn't use
+-the `simd-accel` option on the less mainstream architectures at this
+-time.
+-
+ Used by Firefox.
+
+ ### `serde`
+
+ Enables support for serializing and deserializing `&'static Encoding`-typed
+ struct fields using [Serde][1].
+
+ [1]: https://serde.rs/
+@@ -376,18 +362,19 @@ It is a goal to support the latest stabl
+ the version of Rust that's used for Firefox Nightly.
+
+ At this time, there is no firm commitment to support a version older than
+ what's required by Firefox, and there is no commitment to treat MSRV changes
+ as semver-breaking, because this crate depends on `cfg-if`, which doesn't
+ appear to treat MSRV changes as semver-breaking, so it would be useless for
+ this crate to treat MSRV changes as semver-breaking.
+
+-As of 2021-02-04, MSRV appears to be Rust 1.36.0 for using the crate and
++As of 2024-04-04, MSRV appears to be Rust 1.36.0 for using the crate and
+ 1.42.0 for doc tests to pass without errors about the global allocator.
++With the `simd-accel` feature, the MSRV is even higher.
+
+ ## Compatibility with rust-encoding
+
+ A compatibility layer that implements the rust-encoding API on top of
+ encoding_rs is
+ [provided as a separate crate](https://github.com/hsivonen/encoding_rs_compat)
+ (cannot be uploaded to crates.io). The compatibility layer was originally
+ written with the assuption that Firefox would need it, but it is not currently
+@@ -441,20 +428,27 @@ To regenerate the generated code:
+ - [x] Implement the rust-encoding API in terms of encoding_rs.
+ - [x] Add SIMD acceleration for Aarch64.
+ - [x] Investigate the use of NEON on 32-bit ARM.
+ - [ ] ~Investigate Björn Höhrmann's lookup table acceleration for UTF-8 as
+ adapted to Rust in rust-encoding.~
+ - [x] Add actually fast CJK encode options.
+ - [ ] ~Investigate [Bob Steagall's lookup table acceleration for
UTF-8](https://github.com/BobSteagall/CppNow2018/blob/master/FastConversionFromUTF-8/Fast%20Conversion%20From%20UTF-8%20with%20C%2B%2B%2C%20DFAs%2C%20and%20SSE%20Intrinsics%20-%20Bob%20Steagall%20-%20C%2B%2BNow%202018.pdf).~
+ - [x] Provide a build mode that works without `alloc` (with lesser API surface).
+-- [ ] Migrate to `std::simd` once it is stable and declare 1.0.
++- [x] Migrate to `std::simd` ~once it is stable and declare 1.0.~
++- [ ] Migrate `unsafe` slice access by larger types than `u8`/`u16` to `align_to`.
+
+ ## Release Notes
+
++### 0.8.34
++
++* Use the `portable_simd` nightly feature of the standard library instead of the `packed_simd` crate. Only affects the `simd-accel` optional nightly feature.
++* Internal documentation improvements and minor code improvements around `unsafe`.
++* Added `rust-version` to `Cargo.toml`.
++
+ ### 0.8.33
+
+ * Use `packed_simd` instead of `packed_simd_2` again now that updates are back under the `packed_simd` name. Only affects the `simd-accel` optional nightly feature.
+
+ ### 0.8.32
+
+ * Removed `build.rs`. (This removal should resolve false positives reported by some antivirus products. This may break some build configurations that have opted out of Rust's guarantees against
future build breakage.)
+ * Internal change to what API is used for reinterpreting the lane configuration of SIMD vectors.
+diff --git a/third_party/rust/encoding_rs/src/ascii.rs b/third_party/rust/encoding_rs/src/ascii.rs
+--- third_party/rust/encoding_rs/src/ascii.rs
++++ third_party/rust/encoding_rs/src/ascii.rs
+@@ -46,71 +46,87 @@ cfg_if! {
+ #[allow(dead_code)]
+ #[inline(always)]
+ fn likely(b: bool) -> bool {
+ b
+ }
+ }
+ }
+
++// Safety invariants for masks: data & mask = 0 for valid ASCII or basic latin utf-16
++
+ // `as` truncates, so works on 32-bit, too.
+ #[allow(dead_code)]
+ pub const ASCII_MASK: usize = 0x8080_8080_8080_8080u64 as usize;
+
+ // `as` truncates, so works on 32-bit, too.
+ #[allow(dead_code)]
+ pub const BASIC_LATIN_MASK: usize = 0xFF80_FF80_FF80_FF80u64 as usize;
+
+ #[allow(unused_macros)]
+ macro_rules! ascii_naive {
+ ($name:ident, $src_unit:ty, $dst_unit:ty) => {
++ /// Safety: src and dst must have len_unit elements and be aligned
++ /// Safety-usable invariant: will return Some() when it fails
++ /// to convert. The first value will be a u8 that is > 127.
+ #[inline(always)]
+ pub unsafe fn $name(
+ src: *const $src_unit,
+ dst: *mut $dst_unit,
+ len: usize,
+ ) -> Option<($src_unit, usize)> {
+ // Yes, manually omitting the bound check here matters
+ // a lot for perf.
+ for i in 0..len {
++ // Safety: len invariant used here
+ let code_unit = *(src.add(i));
++ // Safety: Upholds safety-usable invariant here
+ if code_unit > 127 {
+ return Some((code_unit, i));
+ }
++ // Safety: len invariant used here
+ *(dst.add(i)) = code_unit as $dst_unit;
+ }
+ return None;
+ }
+ };
+ }
+
+ #[allow(unused_macros)]
+ macro_rules! ascii_alu {
+ ($name:ident,
++ // safety invariant: src/dst MUST be u8
+ $src_unit:ty,
+ $dst_unit:ty,
++ // Safety invariant: stride_fn must consume and produce two usizes, and return the index of the first non-ascii when it fails
+ $stride_fn:ident) => {
++ /// Safety: src and dst must have len elements, src is valid for read, dst is valid for
++ /// write
++ /// Safety-usable invariant: will return Some() when it fails
++ /// to convert. The first value will be a u8 that is > 127.
+ #[cfg_attr(feature = "cargo-clippy", allow(never_loop, cast_ptr_alignment))]
+ #[inline(always)]
+ pub unsafe fn $name(
+ src: *const $src_unit,
+ dst: *mut $dst_unit,
+ len: usize,
+ ) -> Option<($src_unit, usize)> {
+ let mut offset = 0usize;
+ // This loop is only broken out of as a `goto` forward
+ loop {
++ // Safety: until_alignment becomes the number of bytes we need to munch until we are aligned to usize
+ let mut until_alignment = {
+ // Check if the other unit aligns if we move the narrower unit
+ // to alignment.
+ // if ::core::mem::size_of::<$src_unit>() == ::core::mem::size_of::<$dst_unit>() {
+ // ascii_to_ascii
+ let src_alignment = (src as usize) & ALU_ALIGNMENT_MASK;
+ let dst_alignment = (dst as usize) & ALU_ALIGNMENT_MASK;
+ if src_alignment != dst_alignment {
++ // Safety: bails early and ends up in the naïve branch where usize-alignment doesn't matter
+ break;
+ }
+ (ALU_ALIGNMENT - src_alignment) & ALU_ALIGNMENT_MASK
+ // } else if ::core::mem::size_of::<$src_unit>() < ::core::mem::size_of::<$dst_unit>() {
+ // ascii_to_basic_latin
+ // let src_until_alignment = (ALIGNMENT - ((src as usize) & ALIGNMENT_MASK)) & ALIGNMENT_MASK;
+ // if (dst.add(src_until_alignment) as usize) & ALIGNMENT_MASK != 0 {
+ // break;
+@@ -129,74 +145,104 @@ macro_rules! ascii_alu {
+ // Moving pointers to alignment seems to be a pessimization on
+ // x86_64 for operations that have UTF-16 as the internal
+ // Unicode representation. However, since it seems to be a win
+ // on ARM (tested ARMv7 code running on ARMv8 [rpi3]), except
+ // mixed results when encoding from UTF-16 and since x86 and
+ // x86_64 should be using SSE2 in due course, keeping the move
+ // to alignment here. It would be good to test on more ARM CPUs
+ // and on real MIPS and POWER hardware.
++ //
++ // Safety: This is the naïve code once again, for `until_alignment` bytes
+ while until_alignment != 0 {
+ let code_unit = *(src.add(offset));
+ if code_unit > 127 {
++ // Safety: Upholds safety-usable invariant here
+ return Some((code_unit, offset));
+ }
+ *(dst.add(offset)) = code_unit as $dst_unit;
++ // Safety: offset is the number of bytes copied so far
+ offset += 1;
+ until_alignment -= 1;
+ }
+ let len_minus_stride = len - ALU_STRIDE_SIZE;
+ loop {
++ // Safety: num_ascii is known to be a byte index of a non-ascii byte due to stride_fn's invariant
+ if let Some(num_ascii) = $stride_fn(
++ // Safety: These are known to be valid and aligned since we have at
++ // least ALU_STRIDE_SIZE data in these buffers, and offset is the
++ // number of elements copied so far, which according to the
++ // until_alignment calculation above will cause both src and dst to be
++ // aligned to usize after this add
+ src.add(offset) as *const usize,
+ dst.add(offset) as *mut usize,
+ ) {
+ offset += num_ascii;
++ // Safety: Upholds safety-usable invariant here by indexing into non-ascii byte
+ return Some((*(src.add(offset)), offset));
+ }
++ // Safety: offset continues to be the number of bytes copied so far, and
++ // maintains usize alignment for the next loop iteration
+ offset += ALU_STRIDE_SIZE;
++ // Safety: This is `offset > len - stride. This loop will continue as long as
++ // `offset <= len - stride`, which means there are `stride` bytes to still be read.
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ }
+ break;
+ }
++
++ // Safety: This is the naïve code, same as ascii_naive, and has no requirements
++ // other than src/dst being valid for the the right lens
+ while offset < len {
++ // Safety: len invariant used here
+ let code_unit = *(src.add(offset));
+ if code_unit > 127 {
++ // Safety: Upholds safety-usable invariant here
+ return Some((code_unit, offset));
+ }
++ // Safety: len invariant used here
+ *(dst.add(offset)) = code_unit as $dst_unit;
+ offset += 1;
+ }
+ None
+ }
+ };
+ }
+
+ #[allow(unused_macros)]
+ macro_rules! basic_latin_alu {
+ ($name:ident,
++ // safety invariant: use u8 for src/dest for ascii, and u16 for basic_latin
+ $src_unit:ty,
+ $dst_unit:ty,
++ // safety invariant: stride function must munch ALU_STRIDE_SIZE*size(src_unit) bytes off of src and
++ // write ALU_STRIDE_SIZE*size(dst_unit) bytes to dst
+ $stride_fn:ident) => {
++ /// Safety: src and dst must have len elements, src is valid for read, dst is valid for
++ /// write
++ /// Safety-usable invariant: will return Some() when it fails
++ /// to convert. The first value will be a u8 that is > 127.
+ #[cfg_attr(
+ feature = "cargo-clippy",
+ allow(never_loop, cast_ptr_alignment, cast_lossless)
+ )]
+ #[inline(always)]
+ pub unsafe fn $name(
+ src: *const $src_unit,
+ dst: *mut $dst_unit,
+ len: usize,
+ ) -> Option<($src_unit, usize)> {
+ let mut offset = 0usize;
+ // This loop is only broken out of as a `goto` forward
+ loop {
++ // Safety: until_alignment becomes the number of bytes we need to munch from src/dest until we are aligned to usize
++ // We ensure basic-latin has the same alignment as ascii, starting with ascii since it is smaller.
+ let mut until_alignment = {
+ // Check if the other unit aligns if we move the narrower unit
+ // to alignment.
+ // if ::core::mem::size_of::<$src_unit>() == ::core::mem::size_of::<$dst_unit>() {
+ // ascii_to_ascii
+ // let src_alignment = (src as usize) & ALIGNMENT_MASK;
+ // let dst_alignment = (dst as usize) & ALIGNMENT_MASK;
+ // if src_alignment != dst_alignment {
+@@ -232,66 +278,89 @@ macro_rules! basic_latin_alu {
+ // Moving pointers to alignment seems to be a pessimization on
+ // x86_64 for operations that have UTF-16 as the internal
+ // Unicode representation. However, since it seems to be a win
+ // on ARM (tested ARMv7 code running on ARMv8 [rpi3]), except
+ // mixed results when encoding from UTF-16 and since x86 and
+ // x86_64 should be using SSE2 in due course, keeping the move
+ // to alignment here. It would be good to test on more ARM CPUs
+ // and on real MIPS and POWER hardware.
++ //
++ // Safety: This is the naïve code once again, for `until_alignment` bytes
+ while until_alignment != 0 {
+ let code_unit = *(src.add(offset));
+ if code_unit > 127 {
++ // Safety: Upholds safety-usable invariant here
+ return Some((code_unit, offset));
+ }
+ *(dst.add(offset)) = code_unit as $dst_unit;
++ // Safety: offset is the number of bytes copied so far
+ offset += 1;
+ until_alignment -= 1;
+ }
+ let len_minus_stride = len - ALU_STRIDE_SIZE;
+ loop {
+ if !$stride_fn(
++ // Safety: These are known to be valid and aligned since we have at
++ // least ALU_STRIDE_SIZE data in these buffers, and offset is the
++ // number of elements copied so far, which according to the
++ // until_alignment calculation above will cause both src and dst to be
++ // aligned to usize after this add
+ src.add(offset) as *const usize,
+ dst.add(offset) as *mut usize,
+ ) {
+ break;
+ }
++ // Safety: offset continues to be the number of bytes copied so far, and
++ // maintains usize alignment for the next loop iteration
+ offset += ALU_STRIDE_SIZE;
++ // Safety: This is `offset > len - stride. This loop will continue as long as
++ // `offset <= len - stride`, which means there are `stride` bytes to still be read.
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ }
+ break;
+ }
++ // Safety: This is the naïve code once again, for leftover bytes
+ while offset < len {
++ // Safety: len invariant used here
+ let code_unit = *(src.add(offset));
+ if code_unit > 127 {
++ // Safety: Upholds safety-usable invariant here
+ return Some((code_unit, offset));
+ }
++ // Safety: len invariant used here
+ *(dst.add(offset)) = code_unit as $dst_unit;
+ offset += 1;
+ }
+ None
+ }
+ };
+ }
+
+ #[allow(unused_macros)]
+ macro_rules! latin1_alu {
++ // safety invariant: stride function must munch ALU_STRIDE_SIZE*size(src_unit) bytes off of src and
++ // write ALU_STRIDE_SIZE*size(dst_unit) bytes to dst
+ ($name:ident, $src_unit:ty, $dst_unit:ty, $stride_fn:ident) => {
++ /// Safety: src and dst must have len elements, src is valid for read, dst is valid for
++ /// write
+ #[cfg_attr(
+ feature = "cargo-clippy",
+ allow(never_loop, cast_ptr_alignment, cast_lossless)
+ )]
+ #[inline(always)]
+ pub unsafe fn $name(src: *const $src_unit, dst: *mut $dst_unit, len: usize) {
+ let mut offset = 0usize;
+ // This loop is only broken out of as a `goto` forward
+ loop {
++ // Safety: until_alignment becomes the number of bytes we need to munch from src/dest until we are aligned to usize
++ // We ensure the UTF-16 side has the same alignment as the Latin-1 side, starting with Latin-1 since it is smaller.
+ let mut until_alignment = {
+ if ::core::mem::size_of::<$src_unit>() < ::core::mem::size_of::<$dst_unit>() {
+ // unpack
+ let src_until_alignment = (ALU_ALIGNMENT
+ - ((src as usize) & ALU_ALIGNMENT_MASK))
+ & ALU_ALIGNMENT_MASK;
+ if (dst.wrapping_add(src_until_alignment) as usize) & ALU_ALIGNMENT_MASK
+ != 0
+@@ -308,373 +377,485 @@ macro_rules! latin1_alu {
+ != 0
+ {
+ break;
+ }
+ dst_until_alignment
+ }
+ };
+ if until_alignment + ALU_STRIDE_SIZE <= len {
++ // Safety: This is the naïve code once again, for `until_alignment` bytes
+ while until_alignment != 0 {
+ let code_unit = *(src.add(offset));
+ *(dst.add(offset)) = code_unit as $dst_unit;
++ // Safety: offset is the number of bytes copied so far
+ offset += 1;
+ until_alignment -= 1;
+ }
+ let len_minus_stride = len - ALU_STRIDE_SIZE;
+ loop {
+ $stride_fn(
++ // Safety: These are known to be valid and aligned since we have at
++ // least ALU_STRIDE_SIZE data in these buffers, and offset is the
++ // number of elements copied so far, which according to the
++ // until_alignment calculation above will cause both src and dst to be
++ // aligned to usize after this add
+ src.add(offset) as *const usize,
+ dst.add(offset) as *mut usize,
+ );
++ // Safety: offset continues to be the number of bytes copied so far, and
++ // maintains usize alignment for the next loop iteration
+ offset += ALU_STRIDE_SIZE;
++ // Safety: This is `offset > len - stride. This loop will continue as long as
++ // `offset <= len - stride`, which means there are `stride` bytes to still be read.
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ }
+ break;
+ }
++ // Safety: This is the naïve code once again, for leftover bytes
+ while offset < len {
++ // Safety: len invariant used here
+ let code_unit = *(src.add(offset));
+ *(dst.add(offset)) = code_unit as $dst_unit;
+ offset += 1;
+ }
+ }
+ };
+ }
+
+ #[allow(unused_macros)]
+ macro_rules! ascii_simd_check_align {
+ (
+ $name:ident,
+ $src_unit:ty,
+ $dst_unit:ty,
++ // Safety: This function must require aligned src/dest that are valid for reading/writing SIMD_STRIDE_SIZE src_unit/dst_unit
+ $stride_both_aligned:ident,
++ // Safety: This function must require aligned/unaligned src/dest that are valid for reading/writing SIMD_STRIDE_SIZE src_unit/dst_unit
+ $stride_src_aligned:ident,
++ // Safety: This function must require unaligned/aligned src/dest that are valid for reading/writing SIMD_STRIDE_SIZE src_unit/dst_unit
+ $stride_dst_aligned:ident,
++ // Safety: This function must require unaligned src/dest that are valid for reading/writing SIMD_STRIDE_SIZE src_unit/dst_unit
+ $stride_neither_aligned:ident
+ ) => {
++ /// Safety: src/dst must be valid for reads/writes of `len` elements of their units.
++ ///
++ /// Safety-usable invariant: will return Some() when it encounters non-ASCII, with the first element in the Some being
++ /// guaranteed to be non-ASCII (> 127), and the second being the offset where it is found
+ #[inline(always)]
+ pub unsafe fn $name(
+ src: *const $src_unit,
+ dst: *mut $dst_unit,
+ len: usize,
+ ) -> Option<($src_unit, usize)> {
+ let mut offset = 0usize;
++ // Safety: if this check succeeds we're valid for reading/writing at least `SIMD_STRIDE_SIZE` elements.
+ if SIMD_STRIDE_SIZE <= len {
+ let len_minus_stride = len - SIMD_STRIDE_SIZE;
+ // XXX Should we first process one stride unconditionally as unaligned to
+ // avoid the cost of the branchiness below if the first stride fails anyway?
+ // XXX Should we just use unaligned SSE2 access unconditionally? It seems that
+ // on Haswell, it would make sense to just use unaligned and not bother
+ // checking. Need to benchmark older architectures before deciding.
+ let dst_masked = (dst as usize) & SIMD_ALIGNMENT_MASK;
++ // Safety: checking whether src is aligned
+ if ((src as usize) & SIMD_ALIGNMENT_MASK) == 0 {
++ // Safety: Checking whether dst is aligned
+ if dst_masked == 0 {
+ loop {
++ // Safety: We're valid to read/write SIMD_STRIDE_SIZE elements and have the appropriate alignments
+ if !$stride_both_aligned(src.add(offset), dst.add(offset)) {
+ break;
+ }
+ offset += SIMD_STRIDE_SIZE;
++ // Safety: This is `offset > len - SIMD_STRIDE_SIZE` which means we always have at least `SIMD_STRIDE_SIZE` elements to munch next time.
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ } else {
+ loop {
++ // Safety: We're valid to read/write SIMD_STRIDE_SIZE elements and have the appropriate alignments
+ if !$stride_src_aligned(src.add(offset), dst.add(offset)) {
+ break;
+ }
+ offset += SIMD_STRIDE_SIZE;
++ // Safety: This is `offset > len - SIMD_STRIDE_SIZE` which means we always have at least `SIMD_STRIDE_SIZE` elements to munch next time.
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ }
+ } else {
+ if dst_masked == 0 {
+ loop {
++ // Safety: We're valid to read/write SIMD_STRIDE_SIZE elements and have the appropriate alignments
+ if !$stride_dst_aligned(src.add(offset), dst.add(offset)) {
+ break;
+ }
+ offset += SIMD_STRIDE_SIZE;
++ // Safety: This is `offset > len - SIMD_STRIDE_SIZE` which means we always have at least `SIMD_STRIDE_SIZE` elements to munch next time.
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ } else {
+ loop {
++ // Safety: We're valid to read/write SIMD_STRIDE_SIZE elements and have the appropriate alignments
+ if !$stride_neither_aligned(src.add(offset), dst.add(offset)) {
+ break;
+ }
+ offset += SIMD_STRIDE_SIZE;
++ // Safety: This is `offset > len - SIMD_STRIDE_SIZE` which means we always have at least `SIMD_STRIDE_SIZE` elements to munch next time.
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ }
+ }
+ }
+ while offset < len {
++ // Safety: uses len invariant here and below
+ let code_unit = *(src.add(offset));
+ if code_unit > 127 {
++ // Safety: upholds safety-usable invariant
+ return Some((code_unit, offset));
+ }
+ *(dst.add(offset)) = code_unit as $dst_unit;
+ offset += 1;
+ }
+ None
+ }
+ };
+ }
+
+ #[allow(unused_macros)]
+ macro_rules! ascii_simd_check_align_unrolled {
+ (
+ $name:ident,
+ $src_unit:ty,
+ $dst_unit:ty,
++ // Safety: This function must require aligned src/dest that are valid for reading/writing SIMD_STRIDE_SIZE src_unit/dst_unit
+ $stride_both_aligned:ident,
++ // Safety: This function must require aligned/unaligned src/dest that are valid for reading/writing SIMD_STRIDE_SIZE src_unit/dst_unit
+ $stride_src_aligned:ident,
++ // Safety: This function must require unaligned src/dest that are valid for reading/writing SIMD_STRIDE_SIZE src_unit/dst_unit
+ $stride_neither_aligned:ident,
++ // Safety: This function must require aligned src/dest that are valid for reading/writing 2*SIMD_STRIDE_SIZE src_unit/dst_unit
+ $double_stride_both_aligned:ident,
++ // Safety: This function must require aligned/unaligned src/dest that are valid for reading/writing 2*SIMD_STRIDE_SIZE src_unit/dst_unit
+ $double_stride_src_aligned:ident
+ ) => {
+- #[inline(always)]
++ /// Safety: src/dst must be valid for reads/writes of `len` elements of their units.
++ ///
++ /// Safety-usable invariant: will return Some() when it encounters non-ASCII, with the first element in the Some being
++ /// guaranteed to be non-ASCII (> 127), and the second being the offset where it is found #[inline(always)]
+ pub unsafe fn $name(
+ src: *const $src_unit,
+ dst: *mut $dst_unit,
+ len: usize,
+ ) -> Option<($src_unit, usize)> {
+ let unit_size = ::core::mem::size_of::<$src_unit>();
+ let mut offset = 0usize;
+ // This loop is only broken out of as a goto forward without
+ // actually looping
+ 'outer: loop {
++ // Safety: if this check succeeds we're valid for reading/writing at least `SIMD_STRIDE_SIZE` elements.
+ if SIMD_STRIDE_SIZE <= len {
+ // First, process one unaligned
++ // Safety: this is safe to call since we're valid for this read/write
+ if !$stride_neither_aligned(src, dst) {
+ break 'outer;
+ }
+ offset = SIMD_STRIDE_SIZE;
+
+ // We have now seen 16 ASCII bytes. Let's guess that
+ // there will be enough more to justify more expense
+ // in the case of non-ASCII.
+ // Use aligned reads for the sake of old microachitectures.
++ //
++ // Safety: this correctly calculates the number of src_units that need to be read before the remaining list is aligned.
++ // This is less that SIMD_ALIGNMENT, which is also SIMD_STRIDE_SIZE (as documented)
+ let until_alignment = ((SIMD_ALIGNMENT
+ - ((src.add(offset) as usize) & SIMD_ALIGNMENT_MASK))
+ & SIMD_ALIGNMENT_MASK)
+ / unit_size;
+- // This addition won't overflow, because even in the 32-bit PAE case the
++ // Safety: This addition won't overflow, because even in the 32-bit PAE case the
+ // address space holds enough code that the slice length can't be that
+ // close to address space size.
+ // offset now equals SIMD_STRIDE_SIZE, hence times 3 below.
++ //
++ // Safety: if this check succeeds we're valid for reading/writing at least `2 * SIMD_STRIDE_SIZE` elements plus `until_alignment`.
++ // The extra SIMD_STRIDE_SIZE in the condition is because `offset` is already `SIMD_STRIDE_SIZE`.
+ if until_alignment + (SIMD_STRIDE_SIZE * 3) <= len {
+ if until_alignment != 0 {
++ // Safety: this is safe to call since we're valid for this read/write (and more), and don't care about alignment
++ // This will copy over bytes that get decoded twice since it's not incrementing `offset` by SIMD_STRIDE_SIZE. This is fine.
+ if !$stride_neither_aligned(src.add(offset), dst.add(offset)) {
+ break;
+ }
+ offset += until_alignment;
+ }
++ // Safety: At this point we're valid for reading/writing 2*SIMD_STRIDE_SIZE elements
++ // Safety: Now `offset` is aligned for `src`
+ let len_minus_stride_times_two = len - (SIMD_STRIDE_SIZE * 2);
++ // Safety: This is whether dst is aligned
+ let dst_masked = (dst.add(offset) as usize) & SIMD_ALIGNMENT_MASK;
+ if dst_masked == 0 {
+ loop {
++ // Safety: both are aligned, we can call the aligned function. We're valid for reading/writing double stride from the initial condition
++ // and the loop break condition below
+ if let Some(advance) =
+ $double_stride_both_aligned(src.add(offset), dst.add(offset))
+ {
+ offset += advance;
+ let code_unit = *(src.add(offset));
++ // Safety: uses safety-usable invariant on ascii_to_ascii_simd_double_stride to return
++ // guaranteed non-ascii
+ return Some((code_unit, offset));
+ }
+ offset += SIMD_STRIDE_SIZE * 2;
++ // Safety: This is `offset > len - 2 * SIMD_STRIDE_SIZE` which means we always have at least `2 * SIMD_STRIDE_SIZE` elements to munch next time.
+ if offset > len_minus_stride_times_two {
+ break;
+ }
+ }
++ // Safety: We're valid for reading/writing one more, and can still assume alignment
+ if offset + SIMD_STRIDE_SIZE <= len {
+ if !$stride_both_aligned(src.add(offset), dst.add(offset)) {
+ break 'outer;
+ }
+ offset += SIMD_STRIDE_SIZE;
+ }
+ } else {
+ loop {
++ // Safety: only src is aligned here. We're valid for reading/writing double stride from the initial condition
++ // and the loop break condition below
+ if let Some(advance) =
+ $double_stride_src_aligned(src.add(offset), dst.add(offset))
+ {
+ offset += advance;
+ let code_unit = *(src.add(offset));
++ // Safety: uses safety-usable invariant on ascii_to_ascii_simd_double_stride to return
++ // guaranteed non-ascii
+ return Some((code_unit, offset));
+ }
+ offset += SIMD_STRIDE_SIZE * 2;
++ // Safety: This is `offset > len - 2 * SIMD_STRIDE_SIZE` which means we always have at least `2 * SIMD_STRIDE_SIZE` elements to munch next time.
++
+ if offset > len_minus_stride_times_two {
+ break;
+ }
+ }
++ // Safety: We're valid for reading/writing one more, and can still assume alignment
+ if offset + SIMD_STRIDE_SIZE <= len {
+ if !$stride_src_aligned(src.add(offset), dst.add(offset)) {
+ break 'outer;
+ }
+ offset += SIMD_STRIDE_SIZE;
+ }
+ }
+ } else {
+ // At most two iterations, so unroll
+ if offset + SIMD_STRIDE_SIZE <= len {
++ // Safety: The check above ensures we're allowed to read/write this, and we don't use alignment
+ if !$stride_neither_aligned(src.add(offset), dst.add(offset)) {
+ break;
+ }
+ offset += SIMD_STRIDE_SIZE;
+ if offset + SIMD_STRIDE_SIZE <= len {
++ // Safety: The check above ensures we're allowed to read/write this, and we don't use alignment
+ if !$stride_neither_aligned(src.add(offset), dst.add(offset)) {
+ break;
+ }
+ offset += SIMD_STRIDE_SIZE;
+ }
+ }
+ }
+ }
+ break 'outer;
+ }
+ while offset < len {
++ // Safety: relies straightforwardly on the `len` invariant
+ let code_unit = *(src.add(offset));
+ if code_unit > 127 {
++ // Safety-usable invariant upheld here
+ return Some((code_unit, offset));
+ }
+ *(dst.add(offset)) = code_unit as $dst_unit;
+ offset += 1;
+ }
+ None
+ }
+ };
+ }
+
+ #[allow(unused_macros)]
+ macro_rules! latin1_simd_check_align {
+ (
+ $name:ident,
+ $src_unit:ty,
+ $dst_unit:ty,
++ // Safety: This function must require aligned src/dest that are valid for reading/writing SIMD_STRIDE_SIZE src_unit/dst_unit
+ $stride_both_aligned:ident,
++ // Safety: This function must require aligned/unaligned src/dest that are valid for reading/writing SIMD_STRIDE_SIZE src_unit/dst_unit
+ $stride_src_aligned:ident,
++ // Safety: This function must require unaligned/aligned src/dest that are valid for reading/writing SIMD_STRIDE_SIZE src_unit/dst_unit
+ $stride_dst_aligned:ident,
++ // Safety: This function must require unaligned src/dest that are valid for reading/writing SIMD_STRIDE_SIZE src_unit/dst_unit
+ $stride_neither_aligned:ident
++
+ ) => {
++ /// Safety: src/dst must be valid for reads/writes of `len` elements of their units.
+ #[inline(always)]
+ pub unsafe fn $name(src: *const $src_unit, dst: *mut $dst_unit, len: usize) {
+ let mut offset = 0usize;
++ // Safety: if this check succeeds we're valid for reading/writing at least `SIMD_STRIDE_SIZE` elements.
+ if SIMD_STRIDE_SIZE <= len {
+ let len_minus_stride = len - SIMD_STRIDE_SIZE;
++ // Whether dst is aligned
+ let dst_masked = (dst as usize) & SIMD_ALIGNMENT_MASK;
++ // Whether src is aligned
+ if ((src as usize) & SIMD_ALIGNMENT_MASK) == 0 {
+ if dst_masked == 0 {
+ loop {
++ // Safety: Both were aligned, we can use the aligned function
+ $stride_both_aligned(src.add(offset), dst.add(offset));
+ offset += SIMD_STRIDE_SIZE;
++ // Safety: This is `offset > len - SIMD_STRIDE_SIZE`, which means in the next iteration we're valid for
++ // reading/writing at least SIMD_STRIDE_SIZE elements.
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ } else {
+ loop {
++ // Safety: src was aligned, dst was not
+ $stride_src_aligned(src.add(offset), dst.add(offset));
+ offset += SIMD_STRIDE_SIZE;
++ // Safety: This is `offset > len - SIMD_STRIDE_SIZE`, which means in the next iteration we're valid for
++ // reading/writing at least SIMD_STRIDE_SIZE elements.
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ }
+ } else {
+ if dst_masked == 0 {
+ loop {
++ // Safety: src was aligned, dst was not
+ $stride_dst_aligned(src.add(offset), dst.add(offset));
+ offset += SIMD_STRIDE_SIZE;
++ // Safety: This is `offset > len - SIMD_STRIDE_SIZE`, which means in the next iteration we're valid for
++ // reading/writing at least SIMD_STRIDE_SIZE elements.
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ } else {
+ loop {
++ // Safety: Neither were aligned
+ $stride_neither_aligned(src.add(offset), dst.add(offset));
+ offset += SIMD_STRIDE_SIZE;
++ // Safety: This is `offset > len - SIMD_STRIDE_SIZE`, which means in the next iteration we're valid for
++ // reading/writing at least SIMD_STRIDE_SIZE elements.
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ }
+ }
+ }
+ while offset < len {
++ // Safety: relies straightforwardly on the `len` invariant
+ let code_unit = *(src.add(offset));
+ *(dst.add(offset)) = code_unit as $dst_unit;
+ offset += 1;
+ }
+ }
+ };
+ }
+
+ #[allow(unused_macros)]
+ macro_rules! latin1_simd_check_align_unrolled {
+ (
+ $name:ident,
+ $src_unit:ty,
+ $dst_unit:ty,
++ // Safety: This function must require aligned src/dest that are valid for reading/writing SIMD_STRIDE_SIZE src_unit/dst_unit
+ $stride_both_aligned:ident,
++ // Safety: This function must require aligned/unaligned src/dest that are valid for reading/writing SIMD_STRIDE_SIZE src_unit/dst_unit
+ $stride_src_aligned:ident,
++ // Safety: This function must require unaligned/aligned src/dest that are valid for reading/writing SIMD_STRIDE_SIZE src_unit/dst_unit
+ $stride_dst_aligned:ident,
++ // Safety: This function must require unaligned src/dest that are valid for reading/writing SIMD_STRIDE_SIZE src_unit/dst_unit
+ $stride_neither_aligned:ident
+ ) => {
++ /// Safety: src/dst must be valid for reads/writes of `len` elements of their units.
+ #[inline(always)]
+ pub unsafe fn $name(src: *const $src_unit, dst: *mut $dst_unit, len: usize) {
+ let unit_size = ::core::mem::size_of::<$src_unit>();
+ let mut offset = 0usize;
++ // Safety: if this check succeeds we're valid for reading/writing at least `SIMD_STRIDE_SIZE` elements.
+ if SIMD_STRIDE_SIZE <= len {
++ // Safety: this correctly calculates the number of src_units that need to be read before the remaining list is aligned.
++ // This is by definition less than SIMD_STRIDE_SIZE.
+ let mut until_alignment = ((SIMD_STRIDE_SIZE
+ - ((src as usize) & SIMD_ALIGNMENT_MASK))
+ & SIMD_ALIGNMENT_MASK)
+ / unit_size;
+ while until_alignment != 0 {
++ // Safety: This is a straightforward copy, since until_alignment is < SIMD_STRIDE_SIZE < len, this is in-bounds
+ *(dst.add(offset)) = *(src.add(offset)) as $dst_unit;
+ offset += 1;
+ until_alignment -= 1;
+ }
++ // Safety: here offset will be `until_alignment`, i.e. enough to align `src`.
+ let len_minus_stride = len - SIMD_STRIDE_SIZE;
++ // Safety: if this check succeeds we're valid for reading/writing at least `2 * SIMD_STRIDE_SIZE` elements.
+ if offset + SIMD_STRIDE_SIZE * 2 <= len {
+ let len_minus_stride_times_two = len_minus_stride - SIMD_STRIDE_SIZE;
++ // Safety: at this point src is known to be aligned at offset, dst is not.
+ if (dst.add(offset) as usize) & SIMD_ALIGNMENT_MASK == 0 {
+ loop {
++ // Safety: We checked alignment of dst above, we can use the alignment functions. We're allowed to read/write 2*SIMD_STRIDE_SIZE elements, which we do.
+ $stride_both_aligned(src.add(offset), dst.add(offset));
+ offset += SIMD_STRIDE_SIZE;
+ $stride_both_aligned(src.add(offset), dst.add(offset));
+ offset += SIMD_STRIDE_SIZE;
++ // Safety: This is `offset > len - 2 * SIMD_STRIDE_SIZE` which means we always have at least `2 * SIMD_STRIDE_SIZE` elements to munch next time.
+ if offset > len_minus_stride_times_two {
+ break;
+ }
+ }
+ } else {
+ loop {
++ // Safety: we ensured alignment of src already.
+ $stride_src_aligned(src.add(offset), dst.add(offset));
+ offset += SIMD_STRIDE_SIZE;
+ $stride_src_aligned(src.add(offset), dst.add(offset));
+ offset += SIMD_STRIDE_SIZE;
++ // Safety: This is `offset > len - 2 * SIMD_STRIDE_SIZE` which means we always have at least `2 * SIMD_STRIDE_SIZE` elements to munch next time.
+ if offset > len_minus_stride_times_two {
+ break;
+ }
+ }
+ }
+ }
++ // Safety: This is `offset > len - SIMD_STRIDE_SIZE` which means we are valid to munch SIMD_STRIDE_SIZE more elements, which we do
+ if offset < len_minus_stride {
+ $stride_src_aligned(src.add(offset), dst.add(offset));
+ offset += SIMD_STRIDE_SIZE;
+ }
+ }
+ while offset < len {
++ // Safety: uses len invariant here and below
+ let code_unit = *(src.add(offset));
+ // On x86_64, this loop autovectorizes but in the pack
+ // case there are instructions whose purpose is to make sure
+ // each u16 in the vector is truncated before packing. However,
+ // since we don't care about saturating behavior of SSE2 packing
+ // when the input isn't Latin1, those instructions are useless.
+ // Unfortunately, using the `assume` intrinsic to lie to the
+ // optimizer doesn't make LLVM omit the trunctation that we
+@@ -688,138 +869,180 @@ macro_rules! latin1_simd_check_align_unr
+ offset += 1;
+ }
+ }
+ };
+ }
+
+ #[allow(unused_macros)]
+ macro_rules! ascii_simd_unalign {
++ // Safety: stride_neither_aligned must be a function that requires src/dest be valid for unaligned reads/writes for SIMD_STRIDE_SIZE elements of type src_unit/dest_unit
+ ($name:ident, $src_unit:ty, $dst_unit:ty, $stride_neither_aligned:ident) => {
++ /// Safety: src and dst must be valid for reads/writes of len elements of type src_unit/dst_unit
++ ///
++ /// Safety-usable invariant: will return Some() when it encounters non-ASCII, with the first element in the Some being
++ /// guaranteed to be non-ASCII (> 127), and the second being the offset where it is found
+ #[inline(always)]
+ pub unsafe fn $name(
+ src: *const $src_unit,
+ dst: *mut $dst_unit,
+ len: usize,
+ ) -> Option<($src_unit, usize)> {
+ let mut offset = 0usize;
++ // Safety: if this check succeeds we're valid for reading/writing at least `stride` elements.
+ if SIMD_STRIDE_SIZE <= len {
+ let len_minus_stride = len - SIMD_STRIDE_SIZE;
+ loop {
++ // Safety: We know we're valid for `stride` reads/writes, so we can call this function. We don't need alignment.
+ if !$stride_neither_aligned(src.add(offset), dst.add(offset)) {
+ break;
+ }
+ offset += SIMD_STRIDE_SIZE;
++ // This is `offset > len - stride` which means we always have at least `stride` elements to munch next time.
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ }
+ while offset < len {
++ // Safety: Uses len invariant here and below
+ let code_unit = *(src.add(offset));
+ if code_unit > 127 {
++ // Safety-usable invariant upheld here
+ return Some((code_unit, offset));
+ }
+ *(dst.add(offset)) = code_unit as $dst_unit;
+ offset += 1;
+ }
+ None
+ }
+ };
+ }
+
+ #[allow(unused_macros)]
+ macro_rules! latin1_simd_unalign {
++ // Safety: stride_neither_aligned must be a function that requires src/dest be valid for unaligned reads/writes for SIMD_STRIDE_SIZE elements of type src_unit/dest_unit
+ ($name:ident, $src_unit:ty, $dst_unit:ty, $stride_neither_aligned:ident) => {
++ /// Safety: src and dst must be valid for unaligned reads/writes of len elements of type src_unit/dst_unit
+ #[inline(always)]
+ pub unsafe fn $name(src: *const $src_unit, dst: *mut $dst_unit, len: usize) {
+ let mut offset = 0usize;
++ // Safety: if this check succeeds we're valid for reading/writing at least `stride` elements.
+ if SIMD_STRIDE_SIZE <= len {
+ let len_minus_stride = len - SIMD_STRIDE_SIZE;
+ loop {
++ // Safety: We know we're valid for `stride` reads/writes, so we can call this function. We don't need alignment.
+ $stride_neither_aligned(src.add(offset), dst.add(offset));
+ offset += SIMD_STRIDE_SIZE;
++ // This is `offset > len - stride` which means we always have at least `stride` elements to munch next time.
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ }
+ while offset < len {
++ // Safety: Uses len invariant here
+ let code_unit = *(src.add(offset));
+ *(dst.add(offset)) = code_unit as $dst_unit;
+ offset += 1;
+ }
+ }
+ };
+ }
+
+ #[allow(unused_macros)]
+ macro_rules! ascii_to_ascii_simd_stride {
++ // Safety: load/store must be valid for 16 bytes of read/write, which may be unaligned. (candidates: `(load|store)(16|8)_(unaligned|aligned)` functions)
+ ($name:ident, $load:ident, $store:ident) => {
++ /// Safety: src and dst must be valid for 16 bytes of read/write according to
++ /// the $load/$store fn, which may allow for unaligned reads/writes or require
++ /// alignment to either 16x8 or u8x16.
+ #[inline(always)]
+ pub unsafe fn $name(src: *const u8, dst: *mut u8) -> bool {
+ let simd = $load(src);
+ if !simd_is_ascii(simd) {
+ return false;
+ }
+ $store(dst, simd);
+ true
+ }
+ };
+ }
+
+ #[allow(unused_macros)]
+ macro_rules! ascii_to_ascii_simd_double_stride {
++ // Safety: store must be valid for 32 bytes of write, which may be unaligned (candidates: `store(8|16)_(aligned|unaligned)`)
+ ($name:ident, $store:ident) => {
++ /// Safety: src must be valid for 32 bytes of aligned u8x16 read
++ /// dst must be valid for 32 bytes of unaligned write according to
++ /// the $store fn, which may allow for unaligned writes or require
++ /// alignment to either 16x8 or u8x16.
++ ///
++ /// Safety-usable invariant: Returns Some(index) if the element at `index` is invalid ASCII
+ #[inline(always)]
+ pub unsafe fn $name(src: *const u8, dst: *mut u8) -> Option<usize> {
+ let first = load16_aligned(src);
+ let second = load16_aligned(src.add(SIMD_STRIDE_SIZE));
+ $store(dst, first);
+ if unlikely(!simd_is_ascii(first | second)) {
++ // Safety: mask_ascii produces a mask of all the high bits.
+ let mask_first = mask_ascii(first);
+ if mask_first != 0 {
++ // Safety: on little endian systems this will be the number of ascii bytes
++ // before the first non-ascii, i.e. valid for indexing src
++ // TODO SAFETY: What about big-endian systems?
+ return Some(mask_first.trailing_zeros() as usize);
+ }
+ $store(dst.add(SIMD_STRIDE_SIZE), second);
+ let mask_second = mask_ascii(second);
++ // Safety: on little endian systems this will be the number of ascii bytes
++ // before the first non-ascii, i.e. valid for indexing src
+ return Some(SIMD_STRIDE_SIZE + mask_second.trailing_zeros() as usize);
+ }
+ $store(dst.add(SIMD_STRIDE_SIZE), second);
+ None
+ }
+ };
+ }
+
+ #[allow(unused_macros)]
+ macro_rules! ascii_to_basic_latin_simd_stride {
++ // Safety: load/store must be valid for 16 bytes of read/write, which may be unaligned. (candidates: `(load|store)(16|8)_(unaligned|aligned)` functions)
+ ($name:ident, $load:ident, $store:ident) => {
++ /// Safety: src and dst must be valid for 16/32 bytes of read/write according to
++ /// the $load/$store fn, which may allow for unaligned reads/writes or require
++ /// alignment to either 16x8 or u8x16.
+ #[inline(always)]
+ pub unsafe fn $name(src: *const u8, dst: *mut u16) -> bool {
+ let simd = $load(src);
+ if !simd_is_ascii(simd) {
+ return false;
+ }
+ let (first, second) = simd_unpack(simd);
+ $store(dst, first);
+ $store(dst.add(8), second);
+ true
+ }
+ };
+ }
+
+ #[allow(unused_macros)]
+ macro_rules! ascii_to_basic_latin_simd_double_stride {
++ // Safety: store must be valid for 16 bytes of write, which may be unaligned
+ ($name:ident, $store:ident) => {
++ /// Safety: src must be valid for 2*SIMD_STRIDE_SIZE bytes of aligned reads,
++ /// aligned to either 16x8 or u8x16.
++ /// dst must be valid for 2*SIMD_STRIDE_SIZE bytes of aligned or unaligned reads
+ #[inline(always)]
+ pub unsafe fn $name(src: *const u8, dst: *mut u16) -> Option<usize> {
+ let first = load16_aligned(src);
+ let second = load16_aligned(src.add(SIMD_STRIDE_SIZE));
+ let (a, b) = simd_unpack(first);
+ $store(dst, a);
++ // Safety: divide by 2 since it's a u16 pointer
+ $store(dst.add(SIMD_STRIDE_SIZE / 2), b);
+ if unlikely(!simd_is_ascii(first | second)) {
+ let mask_first = mask_ascii(first);
+ if mask_first != 0 {
+ return Some(mask_first.trailing_zeros() as usize);
+ }
+ let (c, d) = simd_unpack(second);
+ $store(dst.add(SIMD_STRIDE_SIZE), c);
+@@ -832,47 +1055,59 @@ macro_rules! ascii_to_basic_latin_simd_d
+ $store(dst.add(SIMD_STRIDE_SIZE + (SIMD_STRIDE_SIZE / 2)), d);
+ None
+ }
+ };
+ }
+
+ #[allow(unused_macros)]
+ macro_rules! unpack_simd_stride {
++ // Safety: load/store must be valid for 16 bytes of read/write, which may be unaligned. (candidates: `(load|store)(16|8)_(unaligned|aligned)` functions)
+ ($name:ident, $load:ident, $store:ident) => {
++ /// Safety: src and dst must be valid for 16 bytes of read/write according to
++ /// the $load/$store fn, which may allow for unaligned reads/writes or require
++ /// alignment to either 16x8 or u8x16.
+ #[inline(always)]
+ pub unsafe fn $name(src: *const u8, dst: *mut u16) {
+ let simd = $load(src);
+ let (first, second) = simd_unpack(simd);
+ $store(dst, first);
+ $store(dst.add(8), second);
+ }
+ };
+ }
+
+ #[allow(unused_macros)]
+ macro_rules! basic_latin_to_ascii_simd_stride {
++ // Safety: load/store must be valid for 16 bytes of read/write, which may be unaligned. (candidates: `(load|store)(16|8)_(unaligned|aligned)` functions)
+ ($name:ident, $load:ident, $store:ident) => {
++ /// Safety: src and dst must be valid for 32/16 bytes of read/write according to
++ /// the $load/$store fn, which may allow for unaligned reads/writes or require
++ /// alignment to either 16x8 or u8x16.
+ #[inline(always)]
+ pub unsafe fn $name(src: *const u16, dst: *mut u8) -> bool {
+ let first = $load(src);
+ let second = $load(src.add(8));
+ if simd_is_basic_latin(first | second) {
+ $store(dst, simd_pack(first, second));
+ true
+ } else {
+ false
+ }
+ }
+ };
+ }
+
+ #[allow(unused_macros)]
+ macro_rules! pack_simd_stride {
++ // Safety: load/store must be valid for 16 bytes of read/write, which may be unaligned. (candidates: `(load|store)(16|8)_(unaligned|aligned)` functions)
+ ($name:ident, $load:ident, $store:ident) => {
++ /// Safety: src and dst must be valid for 32/16 bytes of read/write according to
++ /// the $load/$store fn, which may allow for unaligned reads/writes or require
++ /// alignment to either 16x8 or u8x16.
+ #[inline(always)]
+ pub unsafe fn $name(src: *const u16, dst: *mut u8) {
+ let first = $load(src);
+ let second = $load(src.add(8));
+ $store(dst, simd_pack(first, second));
+ }
+ };
+ }
+@@ -888,24 +1123,28 @@ cfg_if! {
+ // pub const ALIGNMENT: usize = 8;
+
+ pub const ALU_STRIDE_SIZE: usize = 16;
+
+ pub const ALU_ALIGNMENT: usize = 8;
+
+ pub const ALU_ALIGNMENT_MASK: usize = 7;
+
++ // Safety for stride macros: We stick to the load8_aligned/etc family of functions. We consistently produce
++ // neither_unaligned variants using only unaligned inputs.
+ ascii_to_ascii_simd_stride!(ascii_to_ascii_stride_neither_aligned, load16_unaligned, store16_unaligned);
+
+ ascii_to_basic_latin_simd_stride!(ascii_to_basic_latin_stride_neither_aligned, load16_unaligned, store8_unaligned);
+ unpack_simd_stride!(unpack_stride_neither_aligned, load16_unaligned, store8_unaligned);
+
+ basic_latin_to_ascii_simd_stride!(basic_latin_to_ascii_stride_neither_aligned, load8_unaligned, store16_unaligned);
+ pack_simd_stride!(pack_stride_neither_aligned, load8_unaligned, store16_unaligned);
+
++ // Safety for conversion macros: We use the unalign macro with unalign functions above. All stride functions were produced
++ // by stride macros that universally munch a single SIMD_STRIDE_SIZE worth of elements.
+ ascii_simd_unalign!(ascii_to_ascii, u8, u8, ascii_to_ascii_stride_neither_aligned);
+ ascii_simd_unalign!(ascii_to_basic_latin, u8, u16, ascii_to_basic_latin_stride_neither_aligned);
+ ascii_simd_unalign!(basic_latin_to_ascii, u16, u8, basic_latin_to_ascii_stride_neither_aligned);
+ latin1_simd_unalign!(unpack_latin1, u8, u16, unpack_stride_neither_aligned);
+ latin1_simd_unalign!(pack_latin1, u16, u8, pack_stride_neither_aligned);
+ } else if #[cfg(all(feature = "simd-accel", target_endian = "little", target_feature = "neon"))] {
+ // SIMD with different instructions for aligned and unaligned loads and stores.
+ //
+@@ -914,16 +1153,19 @@ cfg_if! {
+ // but the benchmark results I see don't agree.
+
+ pub const SIMD_STRIDE_SIZE: usize = 16;
+
+ pub const MAX_STRIDE_SIZE: usize = 16;
+
+ pub const SIMD_ALIGNMENT_MASK: usize = 15;
+
++ // Safety for stride macros: We stick to the load8_aligned/etc family of functions. We consistently name
++ // aligned/unaligned functions according to src/dst being aligned/unaligned
++
+ ascii_to_ascii_simd_stride!(ascii_to_ascii_stride_both_aligned, load16_aligned, store16_aligned);
+ ascii_to_ascii_simd_stride!(ascii_to_ascii_stride_src_aligned, load16_aligned, store16_unaligned);
+ ascii_to_ascii_simd_stride!(ascii_to_ascii_stride_dst_aligned, load16_unaligned, store16_aligned);
+ ascii_to_ascii_simd_stride!(ascii_to_ascii_stride_neither_aligned, load16_unaligned, store16_unaligned);
+
+ ascii_to_basic_latin_simd_stride!(ascii_to_basic_latin_stride_both_aligned, load16_aligned, store8_aligned);
+ ascii_to_basic_latin_simd_stride!(ascii_to_basic_latin_stride_src_aligned, load16_aligned, store8_unaligned);
+ ascii_to_basic_latin_simd_stride!(ascii_to_basic_latin_stride_dst_aligned, load16_unaligned, store8_aligned);
+@@ -939,36 +1181,43 @@ cfg_if! {
+ basic_latin_to_ascii_simd_stride!(basic_latin_to_ascii_stride_dst_aligned, load8_unaligned, store16_aligned);
+ basic_latin_to_ascii_simd_stride!(basic_latin_to_ascii_stride_neither_aligned, load8_unaligned, store16_unaligned);
+
+ pack_simd_stride!(pack_stride_both_aligned, load8_aligned, store16_aligned);
+ pack_simd_stride!(pack_stride_src_aligned, load8_aligned, store16_unaligned);
+ pack_simd_stride!(pack_stride_dst_aligned, load8_unaligned, store16_aligned);
+ pack_simd_stride!(pack_stride_neither_aligned, load8_unaligned, store16_unaligned);
+
++ // Safety for conversion macros: We use the correct pattern of both/src/dst/neither here. All stride functions were produced
++ // by stride macros that universally munch a single SIMD_STRIDE_SIZE worth of elements.
++
+ ascii_simd_check_align!(ascii_to_ascii, u8, u8, ascii_to_ascii_stride_both_aligned, ascii_to_ascii_stride_src_aligned, ascii_to_ascii_stride_dst_aligned,
ascii_to_ascii_stride_neither_aligned);
+ ascii_simd_check_align!(ascii_to_basic_latin, u8, u16, ascii_to_basic_latin_stride_both_aligned, ascii_to_basic_latin_stride_src_aligned, ascii_to_basic_latin_stride_dst_aligned,
ascii_to_basic_latin_stride_neither_aligned);
+ ascii_simd_check_align!(basic_latin_to_ascii, u16, u8, basic_latin_to_ascii_stride_both_aligned, basic_latin_to_ascii_stride_src_aligned, basic_latin_to_ascii_stride_dst_aligned,
basic_latin_to_ascii_stride_neither_aligned);
+ latin1_simd_check_align!(unpack_latin1, u8, u16, unpack_stride_both_aligned, unpack_stride_src_aligned, unpack_stride_dst_aligned, unpack_stride_neither_aligned);
+ latin1_simd_check_align!(pack_latin1, u16, u8, pack_stride_both_aligned, pack_stride_src_aligned, pack_stride_dst_aligned, pack_stride_neither_aligned);
+ } else if #[cfg(all(feature = "simd-accel", target_feature = "sse2"))] {
+ // SIMD with different instructions for aligned and unaligned loads and stores.
+ //
+ // Newer microarchitectures are not supposed to have a performance difference between
+ // aligned and unaligned SSE2 loads and stores when the address is actually aligned,
+ // but the benchmark results I see don't agree.
+
+ pub const SIMD_STRIDE_SIZE: usize = 16;
+
++ /// Safety-usable invariant: This should be identical to SIMD_STRIDE_SIZE (used by ascii_simd_check_align_unrolled)
+ pub const SIMD_ALIGNMENT: usize = 16;
+
+ pub const MAX_STRIDE_SIZE: usize = 16;
+
+ pub const SIMD_ALIGNMENT_MASK: usize = 15;
+
++ // Safety for stride macros: We stick to the load8_aligned/etc family of functions. We consistently name
++ // aligned/unaligned functions according to src/dst being aligned/unaligned
++
+ ascii_to_ascii_simd_double_stride!(ascii_to_ascii_simd_double_stride_both_aligned, store16_aligned);
+ ascii_to_ascii_simd_double_stride!(ascii_to_ascii_simd_double_stride_src_aligned, store16_unaligned);
+
+ ascii_to_basic_latin_simd_double_stride!(ascii_to_basic_latin_simd_double_stride_both_aligned, store8_aligned);
+ ascii_to_basic_latin_simd_double_stride!(ascii_to_basic_latin_simd_double_stride_src_aligned, store8_unaligned);
+
+ ascii_to_ascii_simd_stride!(ascii_to_ascii_stride_both_aligned, load16_aligned, store16_aligned);
+ ascii_to_ascii_simd_stride!(ascii_to_ascii_stride_src_aligned, load16_aligned, store16_unaligned);
+@@ -984,33 +1233,43 @@ cfg_if! {
+ basic_latin_to_ascii_simd_stride!(basic_latin_to_ascii_stride_both_aligned, load8_aligned, store16_aligned);
+ basic_latin_to_ascii_simd_stride!(basic_latin_to_ascii_stride_src_aligned, load8_aligned, store16_unaligned);
+ basic_latin_to_ascii_simd_stride!(basic_latin_to_ascii_stride_dst_aligned, load8_unaligned, store16_aligned);
+ basic_latin_to_ascii_simd_stride!(basic_latin_to_ascii_stride_neither_aligned, load8_unaligned, store16_unaligned);
+
+ pack_simd_stride!(pack_stride_both_aligned, load8_aligned, store16_aligned);
+ pack_simd_stride!(pack_stride_src_aligned, load8_aligned, store16_unaligned);
+
++ // Safety for conversion macros: We use the correct pattern of both/src/dst/neither/double_both/double_src here. All stride functions were produced
++ // by stride macros that universally munch a single SIMD_STRIDE_SIZE worth of elements.
++
+ ascii_simd_check_align_unrolled!(ascii_to_ascii, u8, u8, ascii_to_ascii_stride_both_aligned, ascii_to_ascii_stride_src_aligned, ascii_to_ascii_stride_neither_aligned,
ascii_to_ascii_simd_double_stride_both_aligned, ascii_to_ascii_simd_double_stride_src_aligned);
+ ascii_simd_check_align_unrolled!(ascii_to_basic_latin, u8, u16, ascii_to_basic_latin_stride_both_aligned, ascii_to_basic_latin_stride_src_aligned,
ascii_to_basic_latin_stride_neither_aligned, ascii_to_basic_latin_simd_double_stride_both_aligned, ascii_to_basic_latin_simd_double_stride_src_aligned);
+
+ ascii_simd_check_align!(basic_latin_to_ascii, u16, u8, basic_latin_to_ascii_stride_both_aligned, basic_latin_to_ascii_stride_src_aligned, basic_latin_to_ascii_stride_dst_aligned,
basic_latin_to_ascii_stride_neither_aligned);
+ latin1_simd_check_align_unrolled!(unpack_latin1, u8, u16, unpack_stride_both_aligned, unpack_stride_src_aligned, unpack_stride_dst_aligned, unpack_stride_neither_aligned);
+ latin1_simd_check_align_unrolled!(pack_latin1, u16, u8, pack_stride_both_aligned, pack_stride_src_aligned, pack_stride_dst_aligned, pack_stride_neither_aligned);
+ } else if #[cfg(all(target_endian = "little", target_pointer_width = "64"))] {
+ // Aligned ALU word, little-endian, 64-bit
+
++ /// Safety invariant: this is the amount of bytes consumed by
++ /// unpack_alu. This will be twice the pointer width, as it consumes two usizes.
++ /// This is also the number of bytes produced by pack_alu.
++ /// This is also the number of u16 code units produced/consumed by unpack_alu/pack_alu respectively.
+ pub const ALU_STRIDE_SIZE: usize = 16;
+
+ pub const MAX_STRIDE_SIZE: usize = 16;
+
++ // Safety invariant: this is the pointer width in bytes
+ pub const ALU_ALIGNMENT: usize = 8;
+
++ // Safety invariant: this is a mask for getting the bits of a pointer not aligned to ALU_ALIGNMENT
+ pub const ALU_ALIGNMENT_MASK: usize = 7;
+
++ /// Safety: dst must point to valid space for writing four `usize`s
+ #[inline(always)]
+ unsafe fn unpack_alu(word: usize, second_word: usize, dst: *mut usize) {
+ let first = ((0x0000_0000_FF00_0000usize & word) << 24) |
+ ((0x0000_0000_00FF_0000usize & word) << 16) |
+ ((0x0000_0000_0000_FF00usize & word) << 8) |
+ (0x0000_0000_0000_00FFusize & word);
+ let second = ((0xFF00_0000_0000_0000usize & word) >> 8) |
+ ((0x00FF_0000_0000_0000usize & word) >> 16) |
+@@ -1019,22 +1278,24 @@ cfg_if! {
+ let third = ((0x0000_0000_FF00_0000usize & second_word) << 24) |
+ ((0x0000_0000_00FF_0000usize & second_word) << 16) |
+ ((0x0000_0000_0000_FF00usize & second_word) << 8) |
+ (0x0000_0000_0000_00FFusize & second_word);
+ let fourth = ((0xFF00_0000_0000_0000usize & second_word) >> 8) |
+ ((0x00FF_0000_0000_0000usize & second_word) >> 16) |
+ ((0x0000_FF00_0000_0000usize & second_word) >> 24) |
+ ((0x0000_00FF_0000_0000usize & second_word) >> 32);
++ // Safety: fn invariant used here
+ *dst = first;
+ *(dst.add(1)) = second;
+ *(dst.add(2)) = third;
+ *(dst.add(3)) = fourth;
+ }
+
++ /// Safety: dst must point to valid space for writing two `usize`s
+ #[inline(always)]
+ unsafe fn pack_alu(first: usize, second: usize, third: usize, fourth: usize, dst: *mut usize) {
+ let word = ((0x00FF_0000_0000_0000usize & second) << 8) |
+ ((0x0000_00FF_0000_0000usize & second) << 16) |
+ ((0x0000_0000_00FF_0000usize & second) << 24) |
+ ((0x0000_0000_0000_00FFusize & second) << 32) |
+ ((0x00FF_0000_0000_0000usize & first) >> 24) |
+ ((0x0000_00FF_0000_0000usize & first) >> 16) |
+@@ -1043,70 +1304,88 @@ cfg_if! {
+ let second_word = ((0x00FF_0000_0000_0000usize & fourth) << 8) |
+ ((0x0000_00FF_0000_0000usize & fourth) << 16) |
+ ((0x0000_0000_00FF_0000usize & fourth) << 24) |
+ ((0x0000_0000_0000_00FFusize & fourth) << 32) |
+ ((0x00FF_0000_0000_0000usize & third) >> 24) |
+ ((0x0000_00FF_0000_0000usize & third) >> 16) |
+ ((0x0000_0000_00FF_0000usize & third) >> 8) |
+ (0x0000_0000_0000_00FFusize & third);
++ // Safety: fn invariant used here
+ *dst = word;
+ *(dst.add(1)) = second_word;
+ }
+ } else if #[cfg(all(target_endian = "little", target_pointer_width = "32"))] {
+ // Aligned ALU word, little-endian, 32-bit
+
++ /// Safety invariant: this is the amount of bytes consumed by
++ /// unpack_alu. This will be twice the pointer width, as it consumes two usizes.
++ /// This is also the number of bytes produced by pack_alu.
++ /// This is also the number of u16 code units produced/consumed by unpack_alu/pack_alu respectively.
+ pub const ALU_STRIDE_SIZE: usize = 8;
+
+ pub const MAX_STRIDE_SIZE: usize = 8;
+
++ // Safety invariant: this is the pointer width in bytes
+ pub const ALU_ALIGNMENT: usize = 4;
+
++ // Safety invariant: this is a mask for getting the bits of a pointer not aligned to ALU_ALIGNMENT
+ pub const ALU_ALIGNMENT_MASK: usize = 3;
+
++ /// Safety: dst must point to valid space for writing four `usize`s
+ #[inline(always)]
+ unsafe fn unpack_alu(word: usize, second_word: usize, dst: *mut usize) {
+ let first = ((0x0000_FF00usize & word) << 8) |
+ (0x0000_00FFusize & word);
+ let second = ((0xFF00_0000usize & word) >> 8) |
+ ((0x00FF_0000usize & word) >> 16);
+ let third = ((0x0000_FF00usize & second_word) << 8) |
+ (0x0000_00FFusize & second_word);
+ let fourth = ((0xFF00_0000usize & second_word) >> 8) |
+ ((0x00FF_0000usize & second_word) >> 16);
++ // Safety: fn invariant used here
+ *dst = first;
+ *(dst.add(1)) = second;
+ *(dst.add(2)) = third;
+ *(dst.add(3)) = fourth;
+ }
+
++ /// Safety: dst must point to valid space for writing two `usize`s
+ #[inline(always)]
+ unsafe fn pack_alu(first: usize, second: usize, third: usize, fourth: usize, dst: *mut usize) {
+ let word = ((0x00FF_0000usize & second) << 8) |
+ ((0x0000_00FFusize & second) << 16) |
+ ((0x00FF_0000usize & first) >> 8) |
+ (0x0000_00FFusize & first);
+ let second_word = ((0x00FF_0000usize & fourth) << 8) |
+ ((0x0000_00FFusize & fourth) << 16) |
+ ((0x00FF_0000usize & third) >> 8) |
+ (0x0000_00FFusize & third);
++ // Safety: fn invariant used here
+ *dst = word;
+ *(dst.add(1)) = second_word;
+ }
+ } else if #[cfg(all(target_endian = "big", target_pointer_width = "64"))] {
+ // Aligned ALU word, big-endian, 64-bit
+
++ /// Safety invariant: this is the amount of bytes consumed by
++ /// unpack_alu. This will be twice the pointer width, as it consumes two usizes.
++ /// This is also the number of bytes produced by pack_alu.
++ /// This is also the number of u16 code units produced/consumed by unpack_alu/pack_alu respectively.
+ pub const ALU_STRIDE_SIZE: usize = 16;
+
+ pub const MAX_STRIDE_SIZE: usize = 16;
+
++ // Safety invariant: this is the pointer width in bytes
+ pub const ALU_ALIGNMENT: usize = 8;
+
++ // Safety invariant: this is a mask for getting the bits of a pointer not aligned to ALU_ALIGNMENT
+ pub const ALU_ALIGNMENT_MASK: usize = 7;
+
++ /// Safety: dst must point to valid space for writing four `usize`s
+ #[inline(always)]
+ unsafe fn unpack_alu(word: usize, second_word: usize, dst: *mut usize) {
+ let first = ((0xFF00_0000_0000_0000usize & word) >> 8) |
+ ((0x00FF_0000_0000_0000usize & word) >> 16) |
+ ((0x0000_FF00_0000_0000usize & word) >> 24) |
+ ((0x0000_00FF_0000_0000usize & word) >> 32);
+ let second = ((0x0000_0000_FF00_0000usize & word) << 24) |
+ ((0x0000_0000_00FF_0000usize & word) << 16) |
+@@ -1115,22 +1394,24 @@ cfg_if! {
+ let third = ((0xFF00_0000_0000_0000usize & second_word) >> 8) |
+ ((0x00FF_0000_0000_0000usize & second_word) >> 16) |
+ ((0x0000_FF00_0000_0000usize & second_word) >> 24) |
+ ((0x0000_00FF_0000_0000usize & second_word) >> 32);
+ let fourth = ((0x0000_0000_FF00_0000usize & second_word) << 24) |
+ ((0x0000_0000_00FF_0000usize & second_word) << 16) |
+ ((0x0000_0000_0000_FF00usize & second_word) << 8) |
+ (0x0000_0000_0000_00FFusize & second_word);
++ // Safety: fn invariant used here
+ *dst = first;
+ *(dst.add(1)) = second;
+ *(dst.add(2)) = third;
+ *(dst.add(3)) = fourth;
+ }
+
++ /// Safety: dst must point to valid space for writing two `usize`s
+ #[inline(always)]
+ unsafe fn pack_alu(first: usize, second: usize, third: usize, fourth: usize, dst: *mut usize) {
+ let word = ((0x00FF0000_00000000usize & first) << 8) |
+ ((0x000000FF_00000000usize & first) << 16) |
+ ((0x00000000_00FF0000usize & first) << 24) |
+ ((0x00000000_000000FFusize & first) << 32) |
+ ((0x00FF0000_00000000usize & second) >> 24) |
+ ((0x000000FF_00000000usize & second) >> 16) |
+@@ -1139,67 +1420,80 @@ cfg_if! {
+ let second_word = ((0x00FF0000_00000000usize & third) << 8) |
+ ((0x000000FF_00000000usize & third) << 16) |
+ ((0x00000000_00FF0000usize & third) << 24) |
+ ((0x00000000_000000FFusize & third) << 32) |
+ ((0x00FF0000_00000000usize & fourth) >> 24) |
+ ((0x000000FF_00000000usize & fourth) >> 16) |
+ ((0x00000000_00FF0000usize & fourth) >> 8) |
+ (0x00000000_000000FFusize & fourth);
++ // Safety: fn invariant used here
+ *dst = word;
+ *(dst.add(1)) = second_word;
+ }
+ } else if #[cfg(all(target_endian = "big", target_pointer_width = "32"))] {
+ // Aligned ALU word, big-endian, 32-bit
+
++ /// Safety invariant: this is the amount of bytes consumed by
++ /// unpack_alu. This will be twice the pointer width, as it consumes two usizes.
++ /// This is also the number of bytes produced by pack_alu.
++ /// This is also the number of u16 code units produced/consumed by unpack_alu/pack_alu respectively.
+ pub const ALU_STRIDE_SIZE: usize = 8;
+
+ pub const MAX_STRIDE_SIZE: usize = 8;
+
++ // Safety invariant: this is the pointer width in bytes
+ pub const ALU_ALIGNMENT: usize = 4;
+
++ // Safety invariant: this is a mask for getting the bits of a pointer not aligned to ALU_ALIGNMENT
+ pub const ALU_ALIGNMENT_MASK: usize = 3;
+
++ /// Safety: dst must point to valid space for writing four `usize`s
+ #[inline(always)]
+ unsafe fn unpack_alu(word: usize, second_word: usize, dst: *mut usize) {
+ let first = ((0xFF00_0000usize & word) >> 8) |
+ ((0x00FF_0000usize & word) >> 16);
+ let second = ((0x0000_FF00usize & word) << 8) |
+ (0x0000_00FFusize & word);
+ let third = ((0xFF00_0000usize & second_word) >> 8) |
+ ((0x00FF_0000usize & second_word) >> 16);
+ let fourth = ((0x0000_FF00usize & second_word) << 8) |
+ (0x0000_00FFusize & second_word);
++ // Safety: fn invariant used here
+ *dst = first;
+ *(dst.add(1)) = second;
+ *(dst.add(2)) = third;
+ *(dst.add(3)) = fourth;
+ }
+
++ /// Safety: dst must point to valid space for writing two `usize`s
+ #[inline(always)]
+ unsafe fn pack_alu(first: usize, second: usize, third: usize, fourth: usize, dst: *mut usize) {
+ let word = ((0x00FF_0000usize & first) << 8) |
+ ((0x0000_00FFusize & first) << 16) |
+ ((0x00FF_0000usize & second) >> 8) |
+ (0x0000_00FFusize & second);
+ let second_word = ((0x00FF_0000usize & third) << 8) |
+ ((0x0000_00FFusize & third) << 16) |
+ ((0x00FF_0000usize & fourth) >> 8) |
+ (0x0000_00FFusize & fourth);
++ // Safety: fn invariant used here
+ *dst = word;
+ *(dst.add(1)) = second_word;
+ }
+ } else {
+ ascii_naive!(ascii_to_ascii, u8, u8);
+ ascii_naive!(ascii_to_basic_latin, u8, u16);
+ ascii_naive!(basic_latin_to_ascii, u16, u8);
+ }
+ }
+
+ cfg_if! {
++ // Safety-usable invariant: this counts the zeroes from the "first byte" of utf-8 data packed into a usize
++ // with the target endianness
+ if #[cfg(target_endian = "little")] {
+ #[allow(dead_code)]
+ #[inline(always)]
+ fn count_zeros(word: usize) -> u32 {
+ word.trailing_zeros()
+ }
+ } else {
+ #[allow(dead_code)]
+@@ -1207,208 +1501,272 @@ cfg_if! {
+ fn count_zeros(word: usize) -> u32 {
+ word.leading_zeros()
+ }
+ }
+ }
+
+ cfg_if! {
+ if #[cfg(all(feature = "simd-accel", target_endian = "little", target_arch = "disabled"))] {
++ /// Safety-usable invariant: Will return the value and position of the first non-ASCII byte in the slice in a Some if found.
++ /// In other words, the first element of the Some is always `> 127`
+ #[inline(always)]
+ pub fn validate_ascii(slice: &[u8]) -> Option<(u8, usize)> {
+ let src = slice.as_ptr();
+ let len = slice.len();
+ let mut offset = 0usize;
++ // Safety: if this check succeeds we're valid for reading/writing at least `stride` elements.
+ if SIMD_STRIDE_SIZE <= len {
+ let len_minus_stride = len - SIMD_STRIDE_SIZE;
+ loop {
++ // Safety: src at offset is valid for a `SIMD_STRIDE_SIZE` read
+ let simd = unsafe { load16_unaligned(src.add(offset)) };
+ if !simd_is_ascii(simd) {
+ break;
+ }
+ offset += SIMD_STRIDE_SIZE;
++ // This is `offset > len - SIMD_STRIDE_SIZE` which means we always have at least `SIMD_STRIDE_SIZE` elements to munch next time.
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ }
+ while offset < len {
+ let code_unit = slice[offset];
+ if code_unit > 127 {
++ // Safety: Safety-usable invariant upheld here
+ return Some((code_unit, offset));
+ }
+ offset += 1;
+ }
+ None
+ }
+ } else if #[cfg(all(feature = "simd-accel", target_feature = "sse2"))] {
++ /// Safety-usable invariant: will return Some() when it encounters non-ASCII, with the first element in the Some being
++ /// guaranteed to be non-ASCII (> 127), and the second being the offset where it is found
+ #[inline(always)]
+ pub fn validate_ascii(slice: &[u8]) -> Option<(u8, usize)> {
+ let src = slice.as_ptr();
+ let len = slice.len();
+ let mut offset = 0usize;
++ // Safety: if this check succeeds we're valid for reading at least `stride` elements.
+ if SIMD_STRIDE_SIZE <= len {
+ // First, process one unaligned vector
++ // Safety: src is valid for a `SIMD_STRIDE_SIZE` read
+ let simd = unsafe { load16_unaligned(src) };
+ let mask = mask_ascii(simd);
+ if mask != 0 {
+ offset = mask.trailing_zeros() as usize;
+ let non_ascii = unsafe { *src.add(offset) };
+ return Some((non_ascii, offset));
+ }
+ offset = SIMD_STRIDE_SIZE;
++ // Safety: Now that offset has changed we don't yet know how much it is valid for
+
+ // We have now seen 16 ASCII bytes. Let's guess that
+ // there will be enough more to justify more expense
+ // in the case of non-ASCII.
+ // Use aligned reads for the sake of old microachitectures.
++ // Safety: this correctly calculates the number of src_units that need to be read before the remaining list is aligned.
++ // This is by definition less than SIMD_ALIGNMENT, which is defined to be equal to SIMD_STRIDE_SIZE.
+ let until_alignment = unsafe { (SIMD_ALIGNMENT - ((src.add(offset) as usize) & SIMD_ALIGNMENT_MASK)) & SIMD_ALIGNMENT_MASK };
+ // This addition won't overflow, because even in the 32-bit PAE case the
+ // address space holds enough code that the slice length can't be that
+ // close to address space size.
+ // offset now equals SIMD_STRIDE_SIZE, hence times 3 below.
++ //
++ // Safety: if this check succeeds we're valid for reading at least `2 * SIMD_STRIDE_SIZE` elements plus `until_alignment`.
++ // The extra SIMD_STRIDE_SIZE in the condition is because `offset` is already `SIMD_STRIDE_SIZE`.
+ if until_alignment + (SIMD_STRIDE_SIZE * 3) <= len {
+ if until_alignment != 0 {
++ // Safety: this is safe to call since we're valid for this read (and more), and don't care about alignment
++ // This will copy over bytes that get decoded twice since it's not incrementing `offset` by SIMD_STRIDE_SIZE. This is fine.
+ let simd = unsafe { load16_unaligned(src.add(offset)) };
+ let mask = mask_ascii(simd);
+ if mask != 0 {
+ offset += mask.trailing_zeros() as usize;
+ let non_ascii = unsafe { *src.add(offset) };
+ return Some((non_ascii, offset));
+ }
+ offset += until_alignment;
+ }
++ // Safety: At this point we're valid for reading 2*SIMD_STRIDE_SIZE elements
++ // Safety: Now `offset` is aligned for `src`
+ let len_minus_stride_times_two = len - (SIMD_STRIDE_SIZE * 2);
+ loop {
++ // Safety: We were valid for this read, and were aligned.
+ let first = unsafe { load16_aligned(src.add(offset)) };
+ let second = unsafe { load16_aligned(src.add(offset + SIMD_STRIDE_SIZE)) };
+ if !simd_is_ascii(first | second) {
++ // Safety: mask_ascii produces a mask of all the high bits.
+ let mask_first = mask_ascii(first);
+ if mask_first != 0 {
++ // Safety: on little endian systems this will be the number of ascii bytes
++ // before the first non-ascii, i.e. valid for indexing src
++ // TODO SAFETY: What about big-endian systems?
+ offset += mask_first.trailing_zeros() as usize;
+ } else {
+ let mask_second = mask_ascii(second);
++ // Safety: on little endian systems this will be the number of ascii bytes
++ // before the first non-ascii, i.e. valid for indexing src
+ offset += SIMD_STRIDE_SIZE + mask_second.trailing_zeros() as usize;
+ }
++ // Safety: We know this is non-ASCII, and can uphold the safety-usable invariant here
+ let non_ascii = unsafe { *src.add(offset) };
++
+ return Some((non_ascii, offset));
+ }
+ offset += SIMD_STRIDE_SIZE * 2;
++ // Safety: This is `offset > len - 2 * SIMD_STRIDE_SIZE` which means we always have at least `2 * SIMD_STRIDE_SIZE` elements to munch next time.
+ if offset > len_minus_stride_times_two {
+ break;
+ }
+ }
++ // Safety: if this check succeeds we're valid for reading at least `SIMD_STRIDE_SIZE`
+ if offset + SIMD_STRIDE_SIZE <= len {
+- let simd = unsafe { load16_aligned(src.add(offset)) };
+- let mask = mask_ascii(simd);
++ // Safety: We were valid for this read, and were aligned.
++ let simd = unsafe { load16_aligned(src.add(offset)) };
++ // Safety: mask_ascii produces a mask of all the high bits.
++ let mask = mask_ascii(simd);
+ if mask != 0 {
++ // Safety: on little endian systems this will be the number of ascii bytes
++ // before the first non-ascii, i.e. valid for indexing src
+ offset += mask.trailing_zeros() as usize;
+ let non_ascii = unsafe { *src.add(offset) };
++ // Safety: We know this is non-ASCII, and can uphold the safety-usable invariant here
+ return Some((non_ascii, offset));
+ }
+ offset += SIMD_STRIDE_SIZE;
+ }
+ } else {
++ // Safety: this is the unaligned branch
+ // At most two iterations, so unroll
++ // Safety: if this check succeeds we're valid for reading at least `SIMD_STRIDE_SIZE`
+ if offset + SIMD_STRIDE_SIZE <= len {
++ // Safety: We're valid for this read but must use an unaligned read
+ let simd = unsafe { load16_unaligned(src.add(offset)) };
+ let mask = mask_ascii(simd);
+ if mask != 0 {
+ offset += mask.trailing_zeros() as usize;
+ let non_ascii = unsafe { *src.add(offset) };
++ // Safety-usable invariant upheld here (same as above)
+ return Some((non_ascii, offset));
+ }
+ offset += SIMD_STRIDE_SIZE;
++ // Safety: if this check succeeds we're valid for reading at least `SIMD_STRIDE_SIZE`
+ if offset + SIMD_STRIDE_SIZE <= len {
++ // Safety: We're valid for this read but must use an unaligned read
+ let simd = unsafe { load16_unaligned(src.add(offset)) };
+ let mask = mask_ascii(simd);
+ if mask != 0 {
+ offset += mask.trailing_zeros() as usize;
+ let non_ascii = unsafe { *src.add(offset) };
++ // Safety-usable invariant upheld here (same as above)
+ return Some((non_ascii, offset));
+ }
+ offset += SIMD_STRIDE_SIZE;
+ }
+ }
+ }
+ }
+ while offset < len {
++ // Safety: relies straightforwardly on the `len` invariant
+ let code_unit = unsafe { *(src.add(offset)) };
+ if code_unit > 127 {
++ // Safety-usable invariant upheld here
+ return Some((code_unit, offset));
+ }
+ offset += 1;
+ }
+ None
+ }
+ } else {
++ // Safety-usable invariant: returns byte index of first non-ascii byte
+ #[inline(always)]
+ fn find_non_ascii(word: usize, second_word: usize) -> Option<usize> {
+ let word_masked = word & ASCII_MASK;
+ let second_masked = second_word & ASCII_MASK;
+ if (word_masked | second_masked) == 0 {
++ // Both are ascii, invariant upheld
+ return None;
+ }
+ if word_masked != 0 {
+ let zeros = count_zeros(word_masked);
+- // `zeros` now contains 7 (for the seven bits of non-ASCII)
++ // `zeros` now contains 0 to 7 (for the seven bits of masked ASCII in little endian,
++ // or up to 7 bits of non-ASCII in big endian if the first byte is non-ASCII)
+ // plus 8 times the number of ASCII in text order before the
+ // non-ASCII byte in the little-endian case or 8 times the number of ASCII in
+ // text order before the non-ASCII byte in the big-endian case.
+ let num_ascii = (zeros >> 3) as usize;
++ // Safety-usable invariant upheld here
+ return Some(num_ascii);
+ }
+ let zeros = count_zeros(second_masked);
+- // `zeros` now contains 7 (for the seven bits of non-ASCII)
++ // `zeros` now contains 0 to 7 (for the seven bits of masked ASCII in little endian,
++ // or up to 7 bits of non-ASCII in big endian if the first byte is non-ASCII)
+ // plus 8 times the number of ASCII in text order before the
+ // non-ASCII byte in the little-endian case or 8 times the number of ASCII in
+ // text order before the non-ASCII byte in the big-endian case.
+ let num_ascii = (zeros >> 3) as usize;
++ // Safety-usable invariant upheld here
+ Some(ALU_ALIGNMENT + num_ascii)
+ }
+
++ /// Safety: `src` must be valid for the reads of two `usize`s
++ ///
++ /// Safety-usable invariant: will return byte index of first non-ascii byte
+ #[inline(always)]
+ unsafe fn validate_ascii_stride(src: *const usize) -> Option<usize> {
+ let word = *src;
+ let second_word = *(src.add(1));
+ find_non_ascii(word, second_word)
+ }
+
++ /// Safety-usable invariant: will return Some() when it encounters non-ASCII, with the first element in the Some being
++ /// guaranteed to be non-ASCII (> 127), and the second being the offset where it is found
+ #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
+ #[inline(always)]
+ pub fn validate_ascii(slice: &[u8]) -> Option<(u8, usize)> {
+ let src = slice.as_ptr();
+ let len = slice.len();
+ let mut offset = 0usize;
+ let mut until_alignment = (ALU_ALIGNMENT - ((src as usize) & ALU_ALIGNMENT_MASK)) & ALU_ALIGNMENT_MASK;
++ // Safety: If this check fails we're valid to read `until_alignment + ALU_STRIDE_SIZE` elements
+ if until_alignment + ALU_STRIDE_SIZE <= len {
+ while until_alignment != 0 {
+ let code_unit = slice[offset];
+ if code_unit > 127 {
++ // Safety-usable invairant upheld here
+ return Some((code_unit, offset));
+ }
+ offset += 1;
+ until_alignment -= 1;
+ }
++ // Safety: At this point we have read until_alignment elements and
++ // are valid for `ALU_STRIDE_SIZE` more.
+ let len_minus_stride = len - ALU_STRIDE_SIZE;
+ loop {
++ // Safety: we were valid for this read
+ let ptr = unsafe { src.add(offset) as *const usize };
+ if let Some(num_ascii) = unsafe { validate_ascii_stride(ptr) } {
+ offset += num_ascii;
++ // Safety-usable invairant upheld here using the invariant from validate_ascii_stride()
+ return Some((unsafe { *(src.add(offset)) }, offset));
+ }
+ offset += ALU_STRIDE_SIZE;
++ // Safety: This is `offset > ALU_STRIDE_SIZE` which means we always have at least `2 * ALU_STRIDE_SIZE` elements to munch next time.
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ }
+ while offset < len {
+ let code_unit = slice[offset];
+ if code_unit > 127 {
++ // Safety-usable invairant upheld here
+ return Some((code_unit, offset));
+ }
+ offset += 1;
+ }
+ None
+ }
+
+ }
+@@ -1423,70 +1781,88 @@ cfg_if! {
+ // vector reads without vector writes.
+
+ pub const ALU_STRIDE_SIZE: usize = 8;
+
+ pub const ALU_ALIGNMENT: usize = 4;
+
+ pub const ALU_ALIGNMENT_MASK: usize = 3;
+ } else {
++ // Safety: src points to two valid `usize`s, dst points to four valid `usize`s
+ #[inline(always)]
+ unsafe fn unpack_latin1_stride_alu(src: *const usize, dst: *mut usize) {
++ // Safety: src safety invariant used here
+ let word = *src;
+ let second_word = *(src.add(1));
++ // Safety: dst safety invariant passed down
+ unpack_alu(word, second_word, dst);
+ }
+
++ // Safety: src points to four valid `usize`s, dst points to two valid `usize`s
+ #[inline(always)]
+ unsafe fn pack_latin1_stride_alu(src: *const usize, dst: *mut usize) {
++ // Safety: src safety invariant used here
+ let first = *src;
+ let second = *(src.add(1));
+ let third = *(src.add(2));
+ let fourth = *(src.add(3));
++ // Safety: dst safety invariant passed down
+ pack_alu(first, second, third, fourth, dst);
+ }
+
++ // Safety: src points to two valid `usize`s, dst points to four valid `usize`s
+ #[inline(always)]
+ unsafe fn ascii_to_basic_latin_stride_alu(src: *const usize, dst: *mut usize) -> bool {
++ // Safety: src safety invariant used here
+ let word = *src;
+ let second_word = *(src.add(1));
+ // Check if the words contains non-ASCII
+ if (word & ASCII_MASK) | (second_word & ASCII_MASK) != 0 {
+ return false;
+ }
++ // Safety: dst safety invariant passed down
+ unpack_alu(word, second_word, dst);
+ true
+ }
+
++ // Safety: src points four valid `usize`s, dst points to two valid `usize`s
+ #[inline(always)]
+ unsafe fn basic_latin_to_ascii_stride_alu(src: *const usize, dst: *mut usize) -> bool {
++ // Safety: src safety invariant used here
+ let first = *src;
+ let second = *(src.add(1));
+ let third = *(src.add(2));
+ let fourth = *(src.add(3));
+ if (first & BASIC_LATIN_MASK) | (second & BASIC_LATIN_MASK) | (third & BASIC_LATIN_MASK) | (fourth & BASIC_LATIN_MASK) != 0 {
+ return false;
+ }
++ // Safety: dst safety invariant passed down
+ pack_alu(first, second, third, fourth, dst);
+ true
+ }
+
++ // Safety: src, dst both point to two valid `usize`s each
++ // Safety-usable invariant: Will return byte index of first non-ascii byte.
+ #[inline(always)]
+ unsafe fn ascii_to_ascii_stride(src: *const usize, dst: *mut usize) -> Option<usize> {
++ // Safety: src safety invariant used here
+ let word = *src;
+ let second_word = *(src.add(1));
++ // Safety: src safety invariant used here
+ *dst = word;
+ *(dst.add(1)) = second_word;
++ // Relies on safety-usable invariant here
+ find_non_ascii(word, second_word)
+ }
+
+ basic_latin_alu!(ascii_to_basic_latin, u8, u16, ascii_to_basic_latin_stride_alu);
+ basic_latin_alu!(basic_latin_to_ascii, u16, u8, basic_latin_to_ascii_stride_alu);
+ latin1_alu!(unpack_latin1, u8, u16, unpack_latin1_stride_alu);
+ latin1_alu!(pack_latin1, u16, u8, pack_latin1_stride_alu);
++ // Safety invariant upheld: ascii_to_ascii_stride will return byte index of first non-ascii if found
+ ascii_alu!(ascii_to_ascii, u8, u8, ascii_to_ascii_stride);
+ }
+ }
+
+ pub fn ascii_valid_up_to(bytes: &[u8]) -> usize {
+ match validate_ascii(bytes) {
+ None => bytes.len(),
+ Some((_, num_valid)) => num_valid,
+diff --git a/third_party/rust/encoding_rs/src/handles.rs b/third_party/rust/encoding_rs/src/handles.rs
+--- third_party/rust/encoding_rs/src/handles.rs
++++ third_party/rust/encoding_rs/src/handles.rs
+@@ -29,17 +29,17 @@ use crate::simd_funcs::*;
+ #[cfg(all(
+ feature = "simd-accel",
+ any(
+ target_feature = "sse2",
+ all(target_endian = "little", target_arch = "aarch64"),
+ all(target_endian = "little", target_feature = "neon")
+ )
+ ))]
+-use packed_simd::u16x8;
++use core::simd::u16x8;
+
+ use super::DecoderResult;
+ use super::EncoderResult;
+ use crate::ascii::*;
+ use crate::utf_8::convert_utf8_to_utf16_up_to_invalid;
+ use crate::utf_8::utf8_valid_up_to;
+
+ pub enum Space<T> {
+@@ -85,84 +85,100 @@ impl Endian for LittleEndian {
+ const OPPOSITE_ENDIAN: bool = false;
+
+ #[cfg(target_endian = "big")]
+ const OPPOSITE_ENDIAN: bool = true;
+ }
+
+ #[derive(Debug, Copy, Clone)]
+ struct UnalignedU16Slice {
++ // Safety invariant: ptr must be valid for reading 2*len bytes
+ ptr: *const u8,
+ len: usize,
+ }
+
+ impl UnalignedU16Slice {
++ /// Safety: ptr must be valid for reading 2*len bytes
+ #[inline(always)]
+ pub unsafe fn new(ptr: *const u8, len: usize) -> UnalignedU16Slice {
++ // Safety: field invariant passed up to caller here
+ UnalignedU16Slice { ptr, len }
+ }
+
+ #[inline(always)]
+ pub fn trim_last(&mut self) {
+ assert!(self.len > 0);
++ // Safety: invariant upheld here: a slice is still valid with a shorter len
+ self.len -= 1;
+ }
+
+ #[inline(always)]
+ pub fn at(&self, i: usize) -> u16 {
+ use core::mem::MaybeUninit;
+
+ assert!(i < self.len);
+ unsafe {
+ let mut u: MaybeUninit<u16> = MaybeUninit::uninit();
++ // Safety: i is at most len - 1, which works here
+ ::core::ptr::copy_nonoverlapping(self.ptr.add(i * 2), u.as_mut_ptr() as *mut u8, 2);
++ // Safety: valid read above lets us do this
+ u.assume_init()
+ }
+ }
+
+ #[cfg(feature = "simd-accel")]
+ #[inline(always)]
+ pub fn simd_at(&self, i: usize) -> u16x8 {
++ // Safety: i/len are on the scale of u16s, each one corresponds to 2 u8s
+ assert!(i + SIMD_STRIDE_SIZE / 2 <= self.len);
+ let byte_index = i * 2;
++ // Safety: load16_unaligned needs SIMD_STRIDE_SIZE=16 u8 elements to read,
++ // or 16/2 = 8 u16 elements to read.
++ // We have checked that we have at least that many above.
++
+ unsafe { to_u16_lanes(load16_unaligned(self.ptr.add(byte_index))) }
+ }
+
+ #[inline(always)]
+ pub fn len(&self) -> usize {
+ self.len
+ }
+
+ #[inline(always)]
+ pub fn tail(&self, from: usize) -> UnalignedU16Slice {
+ // XXX the return value should be restricted not to
+ // outlive self.
+ assert!(from <= self.len);
++ // Safety: This upholds the same invariant: `from` is in bounds and we're returning a shorter slice
+ unsafe { UnalignedU16Slice::new(self.ptr.add(from * 2), self.len - from) }
+ }
+
+ #[cfg(feature = "simd-accel")]
+ #[inline(always)]
+ pub fn copy_bmp_to<E: Endian>(&self, other: &mut [u16]) -> Option<(u16, usize)> {
+ assert!(self.len <= other.len());
+ let mut offset = 0;
++ // Safety: SIMD_STRIDE_SIZE is measured in bytes, whereas len is in u16s. We check we can
++ // munch SIMD_STRIDE_SIZE / 2 u16s which means we can write SIMD_STRIDE_SIZE u8s
+ if SIMD_STRIDE_SIZE / 2 <= self.len {
+ let len_minus_stride = self.len - SIMD_STRIDE_SIZE / 2;
+ loop {
+ let mut simd = self.simd_at(offset);
+ if E::OPPOSITE_ENDIAN {
+ simd = simd_byte_swap(simd);
+ }
++ // Safety: we have enough space on the other side to write this
+ unsafe {
+ store8_unaligned(other.as_mut_ptr().add(offset), simd);
+ }
+ if contains_surrogates(simd) {
+ break;
+ }
+ offset += SIMD_STRIDE_SIZE / 2;
++ // Safety: This ensures we still have space for writing SIMD_STRIDE_SIZE u8s
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ }
+ while offset < self.len {
+ let unit = swap_if_opposite_endian::<E>(self.at(offset));
+ other[offset] = unit;
+@@ -231,33 +247,37 @@ fn copy_unaligned_basic_latin_to_ascii<E
+ #[cfg(feature = "simd-accel")]
+ #[inline(always)]
+ fn copy_unaligned_basic_latin_to_ascii<E: Endian>(
+ src: UnalignedU16Slice,
+ dst: &mut [u8],
+ ) -> CopyAsciiResult<usize, (u16, usize)> {
+ let len = ::core::cmp::min(src.len(), dst.len());
+ let mut offset = 0;
++ // Safety: This check ensures we are able to read/write at least SIMD_STRIDE_SIZE elements
+ if SIMD_STRIDE_SIZE <= len {
+ let len_minus_stride = len - SIMD_STRIDE_SIZE;
+ loop {
+ let mut first = src.simd_at(offset);
+ let mut second = src.simd_at(offset + (SIMD_STRIDE_SIZE / 2));
+ if E::OPPOSITE_ENDIAN {
+ first = simd_byte_swap(first);
+ second = simd_byte_swap(second);
+ }
+ if !simd_is_basic_latin(first | second) {
+ break;
+ }
+ let packed = simd_pack(first, second);
++ // Safety: We are able to write SIMD_STRIDE_SIZE elements in this iteration
+ unsafe {
+ store16_unaligned(dst.as_mut_ptr().add(offset), packed);
+ }
+ offset += SIMD_STRIDE_SIZE;
++ // Safety: This is `offset > len - SIMD_STRIDE_SIZE`, which ensures that we can write at least SIMD_STRIDE_SIZE elements
++ // in the next iteration
+ if offset > len_minus_stride {
+ break;
+ }
+ }
+ }
+ copy_unaligned_basic_latin_to_ascii_alu::<E>(src.tail(offset), &mut dst[offset..], offset)
+ }
+
+@@ -632,94 +652,106 @@ impl<'a> Utf16Destination<'a> {
+ #[inline(always)]
+ fn write_astral(&mut self, astral: u32) {
+ debug_assert!(astral > 0xFFFF);
+ debug_assert!(astral <= 0x10_FFFF);
+ self.write_code_unit((0xD7C0 + (astral >> 10)) as u16);
+ self.write_code_unit((0xDC00 + (astral & 0x3FF)) as u16);
+ }
+ #[inline(always)]
+- pub fn write_surrogate_pair(&mut self, high: u16, low: u16) {
++ fn write_surrogate_pair(&mut self, high: u16, low: u16) {
+ self.write_code_unit(high);
+ self.write_code_unit(low);
+ }
+ #[inline(always)]
+ fn write_big5_combination(&mut self, combined: u16, combining: u16) {
+ self.write_bmp_excl_ascii(combined);
+ self.write_bmp_excl_ascii(combining);
+ }
++ // Safety-usable invariant: CopyAsciiResult::GoOn will only contain bytes >=0x80
+ #[inline(always)]
+ pub fn copy_ascii_from_check_space_bmp<'b>(
+ &'b mut self,
+ source: &mut ByteSource,
+ ) -> CopyAsciiResult<(DecoderResult, usize, usize), (u8, Utf16BmpHandle<'b, 'a>)> {
+ let non_ascii_ret = {
+ let src_remaining = &source.slice[source.pos..];
+ let dst_remaining = &mut self.slice[self.pos..];
+ let (pending, length) = if dst_remaining.len() < src_remaining.len() {
+ (DecoderResult::OutputFull, dst_remaining.len())
+ } else {
+ (DecoderResult::InputEmpty, src_remaining.len())
+ };
++ // Safety: This function is documented as needing valid pointers for src/dest and len, which
++ // is true since we've passed the minumum length of the two
+ match unsafe {
+ ascii_to_basic_latin(src_remaining.as_ptr(), dst_remaining.as_mut_ptr(), length)
+ } {
+ None => {
+ source.pos += length;
+ self.pos += length;
+ return CopyAsciiResult::Stop((pending, source.pos, self.pos));
+ }
++ // Safety: the function is documented as returning bytes >=0x80 in the Some
+ Some((non_ascii, consumed)) => {
+ source.pos += consumed;
+ self.pos += consumed;
+ source.pos += 1; // +1 for non_ascii
++ // Safety: non-ascii bubbled out here
+ non_ascii
+ }
+ }
+ };
++ // Safety: non-ascii returned here
+ CopyAsciiResult::GoOn((non_ascii_ret, Utf16BmpHandle::new(self)))
+ }
++ // Safety-usable invariant: CopyAsciiResult::GoOn will only contain bytes >=0x80
+ #[inline(always)]
+ pub fn copy_ascii_from_check_space_astral<'b>(
+ &'b mut self,
+ source: &mut ByteSource,
+ ) -> CopyAsciiResult<(DecoderResult, usize, usize), (u8, Utf16AstralHandle<'b, 'a>)> {
+ let non_ascii_ret = {
+ let dst_len = self.slice.len();
+ let src_remaining = &source.slice[source.pos..];
+ let dst_remaining = &mut self.slice[self.pos..];
+ let (pending, length) = if dst_remaining.len() < src_remaining.len() {
+ (DecoderResult::OutputFull, dst_remaining.len())
+ } else {
+ (DecoderResult::InputEmpty, src_remaining.len())
+ };
++ // Safety: This function is documented as needing valid pointers for src/dest and len, which
++ // is true since we've passed the minumum length of the two
+ match unsafe {
+ ascii_to_basic_latin(src_remaining.as_ptr(), dst_remaining.as_mut_ptr(), length)
+ } {
+ None => {
+ source.pos += length;
+ self.pos += length;
+ return CopyAsciiResult::Stop((pending, source.pos, self.pos));
+ }
++ // Safety: the function is documented as returning bytes >=0x80 in the Some
+ Some((non_ascii, consumed)) => {
+ source.pos += consumed;
+ self.pos += consumed;
+ if self.pos + 1 < dst_len {
+ source.pos += 1; // +1 for non_ascii
++ // Safety: non-ascii bubbled out here
+ non_ascii
+ } else {
+ return CopyAsciiResult::Stop((
+ DecoderResult::OutputFull,
+ source.pos,
+ self.pos,
+ ));
+ }
+ }
+ }
+ };
++ // Safety: non-ascii returned here
+ CopyAsciiResult::GoOn((non_ascii_ret, Utf16AstralHandle::new(self)))
+ }
+ #[inline(always)]
+ pub fn copy_utf8_up_to_invalid_from(&mut self, source: &mut ByteSource) {
+ let src_remaining = &source.slice[source.pos..];
+ let dst_remaining = &mut self.slice[self.pos..];
+ let (read, written) = convert_utf8_to_utf16_up_to_invalid(src_remaining, dst_remaining);
+ source.pos += read;
+diff --git a/third_party/rust/encoding_rs/src/lib.rs b/third_party/rust/encoding_rs/src/lib.rs
+--- third_party/rust/encoding_rs/src/lib.rs
++++ third_party/rust/encoding_rs/src/lib.rs
+@@ -684,37 +684,26 @@
+ //! <tr><td>TIS-620</td><td>windows-874</td></tr>
+ //! </tbody>
+ //! </table>
+ //!
+ //! See the section [_UTF-16LE, UTF-16BE and Unicode Encoding Schemes_](#utf-16le-utf-16be-and-unicode-encoding-schemes)
+ //! for discussion about the UTF-16 family.
+
+ #![no_std]
+-#![cfg_attr(feature = "simd-accel", feature(core_intrinsics))]
++#![cfg_attr(feature = "simd-accel", feature(core_intrinsics, portable_simd))]
+
+ #[cfg(feature = "alloc")]
+ #[cfg_attr(test, macro_use)]
+ extern crate alloc;
+
+ extern crate core;
+ #[macro_use]
+ extern crate cfg_if;
+
+-#[cfg(all(
+- feature = "simd-accel",
+- any(
+- target_feature = "sse2",
+- all(target_endian = "little", target_arch = "aarch64"),
+- all(target_endian = "little", target_feature = "neon")
+- )
+-))]
+-#[macro_use(shuffle)]
+-extern crate packed_simd;
+-
+ #[cfg(feature = "serde")]
+ extern crate serde;
+
+ #[cfg(all(test, feature = "serde"))]
+ extern crate bincode;
+ #[cfg(all(test, feature = "serde"))]
+ #[macro_use]
+ extern crate serde_derive;
+diff --git a/third_party/rust/encoding_rs/src/mem.rs b/third_party/rust/encoding_rs/src/mem.rs
+--- third_party/rust/encoding_rs/src/mem.rs
++++ third_party/rust/encoding_rs/src/mem.rs
+@@ -111,16 +111,21 @@ macro_rules! by_unit_check_alu {
+ until_alignment -= 1;
+ }
+ if accu >= $bound {
+ return false;
+ }
+ }
+ let len_minus_stride = len - ALU_ALIGNMENT / unit_size;
+ if offset + (4 * (ALU_ALIGNMENT / unit_size)) <= len {
++ // Safety: the above check lets us perform 4 consecutive reads of
++ // length ALU_ALIGNMENT / unit_size. ALU_ALIGNMENT is the size of usize, and unit_size
++ // is the size of the `src` pointer, so this is equal to performing four usize reads.
++ //
++ // This invariant is upheld on all loop iterations
+ let len_minus_unroll = len - (4 * (ALU_ALIGNMENT / unit_size));
+ loop {
+ let unroll_accu = unsafe { *(src.add(offset) as *const usize) }
+ | unsafe {
+ *(src.add(offset + (ALU_ALIGNMENT / unit_size)) as *const usize)
+ }
+ | unsafe {
+ *(src.add(offset + (2 * (ALU_ALIGNMENT / unit_size)))
+@@ -129,22 +134,24 @@ macro_rules! by_unit_check_alu {
+ | unsafe {
+ *(src.add(offset + (3 * (ALU_ALIGNMENT / unit_size)))
+ as *const usize)
+ };
+ if unroll_accu & $mask != 0 {
+ return false;
+ }
+ offset += 4 * (ALU_ALIGNMENT / unit_size);
++ // Safety: this check lets us continue to perform the 4 reads earlier
+ if offset > len_minus_unroll {
+ break;
+ }
+ }
+ }
+ while offset <= len_minus_stride {
++ // Safety: the above check lets us perform one usize read.
+ accu |= unsafe { *(src.add(offset) as *const usize) };
+ offset += ALU_ALIGNMENT / unit_size;
+ }
+ }
+ }
+ for &unit in &buffer[offset..] {
+ accu |= unit as usize;
+ }
+@@ -184,16 +191,21 @@ macro_rules! by_unit_check_simd {
+ until_alignment -= 1;
+ }
+ if accu >= $bound {
+ return false;
+ }
+ }
+ let len_minus_stride = len - SIMD_STRIDE_SIZE / unit_size;
+ if offset + (4 * (SIMD_STRIDE_SIZE / unit_size)) <= len {
++ // Safety: the above check lets us perform 4 consecutive reads of
++ // length SIMD_STRIDE_SIZE / unit_size. SIMD_STRIDE_SIZE is the size of $simd_ty, and unit_size
++ // is the size of the `src` pointer, so this is equal to performing four $simd_ty reads.
++ //
++ // This invariant is upheld on all loop iterations
+ let len_minus_unroll = len - (4 * (SIMD_STRIDE_SIZE / unit_size));
+ loop {
+ let unroll_accu = unsafe { *(src.add(offset) as *const $simd_ty) }
+ | unsafe {
+ *(src.add(offset + (SIMD_STRIDE_SIZE / unit_size))
+ as *const $simd_ty)
+ }
+ | unsafe {
+@@ -203,23 +215,25 @@ macro_rules! by_unit_check_simd {
+ | unsafe {
+ *(src.add(offset + (3 * (SIMD_STRIDE_SIZE / unit_size)))
+ as *const $simd_ty)
+ };
+ if !$func(unroll_accu) {
+ return false;
+ }
+ offset += 4 * (SIMD_STRIDE_SIZE / unit_size);
++ // Safety: this check lets us continue to perform the 4 reads earlier
+ if offset > len_minus_unroll {
+ break;
+ }
+ }
+ }
+ let mut simd_accu = $splat;
+ while offset <= len_minus_stride {
++ // Safety: the above check lets us perform one $simd_ty read.
+ simd_accu = simd_accu | unsafe { *(src.add(offset) as *const $simd_ty) };
+ offset += SIMD_STRIDE_SIZE / unit_size;
+ }
+ if !$func(simd_accu) {
+ return false;
+ }
+ }
+ }
+@@ -229,18 +243,18 @@ macro_rules! by_unit_check_simd {
+ accu < $bound
+ }
+ };
+ }
+
+ cfg_if! {
+ if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2", all(target_endian = "little", target_arch = "aarch64"), all(target_endian = "little", target_feature = "neon"))))] {
+ use crate::simd_funcs::*;
+- use packed_simd::u8x16;
+- use packed_simd::u16x8;
++ use core::simd::u8x16;
++ use core::simd::u16x8;
+
+ const SIMD_ALIGNMENT: usize = 16;
+
+ const SIMD_ALIGNMENT_MASK: usize = 15;
+
+ by_unit_check_simd!(is_ascii_impl, u8, u8x16::splat(0), u8x16, 0x80, simd_is_ascii);
+ by_unit_check_simd!(is_basic_latin_impl, u16, u16x8::splat(0), u16x8, 0x80, simd_is_basic_latin);
+ by_unit_check_simd!(is_utf16_latin1_impl, u16, u16x8::splat(0), u16x8, 0x100, simd_is_latin1);
+diff --git a/third_party/rust/encoding_rs/src/simd_funcs.rs b/third_party/rust/encoding_rs/src/simd_funcs.rs
+--- third_party/rust/encoding_rs/src/simd_funcs.rs
++++ third_party/rust/encoding_rs/src/simd_funcs.rs
+@@ -2,65 +2,84 @@
+ // file at the top-level directory of this distribution.
+ //
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+ // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+ // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+ // option. This file may not be copied, modified, or distributed
+ // except according to those terms.
+
+-use packed_simd::u16x8;
+-use packed_simd::u8x16;
+-use packed_simd::IntoBits;
++use any_all_workaround::all_mask16x8;
++use any_all_workaround::all_mask8x16;
++use any_all_workaround::any_mask16x8;
++use any_all_workaround::any_mask8x16;
++use core::simd::cmp::SimdPartialEq;
++use core::simd::cmp::SimdPartialOrd;
++use core::simd::mask16x8;
++use core::simd::mask8x16;
++use core::simd::simd_swizzle;
++use core::simd::u16x8;
++use core::simd::u8x16;
++use core::simd::ToBytes;
+
+ // TODO: Migrate unaligned access to stdlib code if/when the RFC
+ // https://github.com/rust-lang/rfcs/pull/1725 is implemented.
+
++/// Safety invariant: ptr must be valid for an unaligned read of 16 bytes
+ #[inline(always)]
+ pub unsafe fn load16_unaligned(ptr: *const u8) -> u8x16 {
+- let mut simd = ::core::mem::uninitialized();
+- ::core::ptr::copy_nonoverlapping(ptr, &mut simd as *mut u8x16 as *mut u8, 16);
+- simd
++ let mut simd = ::core::mem::MaybeUninit::<u8x16>::uninit();
++ ::core::ptr::copy_nonoverlapping(ptr, simd.as_mut_ptr() as *mut u8, 16);
++ // Safety: copied 16 bytes of initialized memory into this, it is now initialized
++ simd.assume_init()
+ }
+
++/// Safety invariant: ptr must be valid for an aligned-for-u8x16 read of 16 bytes
+ #[allow(dead_code)]
+ #[inline(always)]
+ pub unsafe fn load16_aligned(ptr: *const u8) -> u8x16 {
+ *(ptr as *const u8x16)
+ }
+
++/// Safety invariant: ptr must be valid for an unaligned store of 16 bytes
+ #[inline(always)]
+ pub unsafe fn store16_unaligned(ptr: *mut u8, s: u8x16) {
+ ::core::ptr::copy_nonoverlapping(&s as *const u8x16 as *const u8, ptr, 16);
+ }
+
++/// Safety invariant: ptr must be valid for an aligned-for-u8x16 store of 16 bytes
+ #[allow(dead_code)]
+ #[inline(always)]
+ pub unsafe fn store16_aligned(ptr: *mut u8, s: u8x16) {
+ *(ptr as *mut u8x16) = s;
+ }
+
++/// Safety invariant: ptr must be valid for an unaligned read of 16 bytes
+ #[inline(always)]
+ pub unsafe fn load8_unaligned(ptr: *const u16) -> u16x8 {
+- let mut simd = ::core::mem::uninitialized();
+- ::core::ptr::copy_nonoverlapping(ptr as *const u8, &mut simd as *mut u16x8 as *mut u8, 16);
+- simd
++ let mut simd = ::core::mem::MaybeUninit::<u16x8>::uninit();
++ ::core::ptr::copy_nonoverlapping(ptr as *const u8, simd.as_mut_ptr() as *mut u8, 16);
++ // Safety: copied 16 bytes of initialized memory into this, it is now initialized
++ simd.assume_init()
+ }
+
++/// Safety invariant: ptr must be valid for an aligned-for-u16x8 read of 16 bytes
+ #[allow(dead_code)]
+ #[inline(always)]
+ pub unsafe fn load8_aligned(ptr: *const u16) -> u16x8 {
+ *(ptr as *const u16x8)
+ }
+
++/// Safety invariant: ptr must be valid for an unaligned store of 16 bytes
+ #[inline(always)]
+ pub unsafe fn store8_unaligned(ptr: *mut u16, s: u16x8) {
+ ::core::ptr::copy_nonoverlapping(&s as *const u16x8 as *const u8, ptr as *mut u8, 16);
+ }
+
++/// Safety invariant: ptr must be valid for an aligned-for-u16x8 store of 16 bytes
+ #[allow(dead_code)]
+ #[inline(always)]
+ pub unsafe fn store8_aligned(ptr: *mut u16, s: u16x8) {
+ *(ptr as *mut u16x8) = s;
+ }
+
+ cfg_if! {
+ if #[cfg(all(target_feature = "sse2", target_arch = "x86_64"))] {
+@@ -95,234 +114,241 @@ cfg_if! {
+ pub fn simd_byte_swap(s: u16x8) -> u16x8 {
+ let left = s << 8;
+ let right = s >> 8;
+ left | right
+ }
+
+ #[inline(always)]
+ pub fn to_u16_lanes(s: u8x16) -> u16x8 {
+- s.into_bits()
++ u16x8::from_ne_bytes(s)
+ }
+
+ cfg_if! {
+ if #[cfg(target_feature = "sse2")] {
+
+ // Expose low-level mask instead of higher-level conclusion,
+ // because the non-ASCII case would perform less well otherwise.
++ // Safety-usable invariant: This returned value is whether each high bit is set
+ #[inline(always)]
+ pub fn mask_ascii(s: u8x16) -> i32 {
+ unsafe {
+- _mm_movemask_epi8(s.into_bits())
++ _mm_movemask_epi8(s.into())
+ }
+ }
+
+ } else {
+
+ }
+ }
+
+ cfg_if! {
+ if #[cfg(target_feature = "sse2")] {
+ #[inline(always)]
+ pub fn simd_is_ascii(s: u8x16) -> bool {
+ unsafe {
+- _mm_movemask_epi8(s.into_bits()) == 0
++ // Safety: We have cfg()d the correct platform
++ _mm_movemask_epi8(s.into()) == 0
+ }
+ }
+ } else if #[cfg(target_arch = "aarch64")]{
+ #[inline(always)]
+ pub fn simd_is_ascii(s: u8x16) -> bool {
+ unsafe {
+- vmaxvq_u8(s.into_bits()) < 0x80
++ // Safety: We have cfg()d the correct platform
++ vmaxvq_u8(s.into()) < 0x80
+ }
+ }
+ } else {
+ #[inline(always)]
+ pub fn simd_is_ascii(s: u8x16) -> bool {
+ // This optimizes better on ARM than
+ // the lt formulation.
+ let highest_ascii = u8x16::splat(0x7F);
+- !s.gt(highest_ascii).any()
++ !any_mask8x16(s.simd_gt(highest_ascii))
+ }
+ }
+ }
+
+ cfg_if! {
+ if #[cfg(target_feature = "sse2")] {
+ #[inline(always)]
+ pub fn simd_is_str_latin1(s: u8x16) -> bool {
+ if simd_is_ascii(s) {
+ return true;
+ }
+ let above_str_latin1 = u8x16::splat(0xC4);
+- s.lt(above_str_latin1).all()
++ s.simd_lt(above_str_latin1).all()
+ }
+ } else if #[cfg(target_arch = "aarch64")]{
+ #[inline(always)]
+ pub fn simd_is_str_latin1(s: u8x16) -> bool {
+ unsafe {
+- vmaxvq_u8(s.into_bits()) < 0xC4
++ // Safety: We have cfg()d the correct platform
++ vmaxvq_u8(s.into()) < 0xC4
+ }
+ }
+ } else {
+ #[inline(always)]
+ pub fn simd_is_str_latin1(s: u8x16) -> bool {
+ let above_str_latin1 = u8x16::splat(0xC4);
+- s.lt(above_str_latin1).all()
++ all_mask8x16(s.simd_lt(above_str_latin1))
+ }
+ }
+ }
+
+ cfg_if! {
+ if #[cfg(target_arch = "aarch64")]{
+ #[inline(always)]
+ pub fn simd_is_basic_latin(s: u16x8) -> bool {
+ unsafe {
+- vmaxvq_u16(s.into_bits()) < 0x80
++ // Safety: We have cfg()d the correct platform
++ vmaxvq_u16(s.into()) < 0x80
+ }
+ }
+
+ #[inline(always)]
+ pub fn simd_is_latin1(s: u16x8) -> bool {
+ unsafe {
+- vmaxvq_u16(s.into_bits()) < 0x100
++ // Safety: We have cfg()d the correct platform
++ vmaxvq_u16(s.into()) < 0x100
+ }
+ }
+ } else {
+ #[inline(always)]
+ pub fn simd_is_basic_latin(s: u16x8) -> bool {
+ let above_ascii = u16x8::splat(0x80);
+- s.lt(above_ascii).all()
++ all_mask16x8(s.simd_lt(above_ascii))
+ }
+
+ #[inline(always)]
+ pub fn simd_is_latin1(s: u16x8) -> bool {
+ // For some reason, on SSE2 this formulation
+ // seems faster in this case while the above
+ // function is better the other way round...
+ let highest_latin1 = u16x8::splat(0xFF);
+- !s.gt(highest_latin1).any()
++ !any_mask16x8(s.simd_gt(highest_latin1))
+ }
+ }
+ }
+
+ #[inline(always)]
+ pub fn contains_surrogates(s: u16x8) -> bool {
+ let mask = u16x8::splat(0xF800);
+ let surrogate_bits = u16x8::splat(0xD800);
+- (s & mask).eq(surrogate_bits).any()
++ any_mask16x8((s & mask).simd_eq(surrogate_bits))
+ }
+
+ cfg_if! {
+ if #[cfg(target_arch = "aarch64")]{
+ macro_rules! aarch64_return_false_if_below_hebrew {
+ ($s:ident) => ({
+ unsafe {
+- if vmaxvq_u16($s.into_bits()) < 0x0590 {
++ // Safety: We have cfg()d the correct platform
++ if vmaxvq_u16($s.into()) < 0x0590 {
+ return false;
+ }
+ }
+ })
+ }
+
+ macro_rules! non_aarch64_return_false_if_all {
+ ($s:ident) => ()
+ }
+ } else {
+ macro_rules! aarch64_return_false_if_below_hebrew {
+ ($s:ident) => ()
+ }
+
+ macro_rules! non_aarch64_return_false_if_all {
+ ($s:ident) => ({
+- if $s.all() {
++ if all_mask16x8($s) {
+ return false;
+ }
+ })
+ }
+ }
+ }
+
+ macro_rules! in_range16x8 {
+ ($s:ident, $start:expr, $end:expr) => {{
+ // SIMD sub is wrapping
+- ($s - u16x8::splat($start)).lt(u16x8::splat($end - $start))
++ ($s - u16x8::splat($start)).simd_lt(u16x8::splat($end - $start))
+ }};
+ }
+
+ #[inline(always)]
+ pub fn is_u16x8_bidi(s: u16x8) -> bool {
+ // We try to first quickly refute the RTLness of the vector. If that
+ // fails, we do the real RTL check, so in that case we end up wasting
+ // the work for the up-front quick checks. Even the quick-check is
+ // two-fold in order to return `false` ASAP if everything is below
+ // Hebrew.
+
+ aarch64_return_false_if_below_hebrew!(s);
+
+- let below_hebrew = s.lt(u16x8::splat(0x0590));
++ let below_hebrew = s.simd_lt(u16x8::splat(0x0590));
+
+ non_aarch64_return_false_if_all!(below_hebrew);
+
+- if (below_hebrew | in_range16x8!(s, 0x0900, 0x200F) | in_range16x8!(s, 0x2068, 0xD802)).all() {
++ if all_mask16x8(
++ below_hebrew | in_range16x8!(s, 0x0900, 0x200F) | in_range16x8!(s, 0x2068, 0xD802),
++ ) {
+ return false;
+ }
+
+ // Quick refutation failed. Let's do the full check.
+
+- (in_range16x8!(s, 0x0590, 0x0900)
+- | in_range16x8!(s, 0xFB1D, 0xFE00)
+- | in_range16x8!(s, 0xFE70, 0xFEFF)
+- | in_range16x8!(s, 0xD802, 0xD804)
+- | in_range16x8!(s, 0xD83A, 0xD83C)
+- | s.eq(u16x8::splat(0x200F))
+- | s.eq(u16x8::splat(0x202B))
+- | s.eq(u16x8::splat(0x202E))
+- | s.eq(u16x8::splat(0x2067)))
+- .any()
++ any_mask16x8(
++ (in_range16x8!(s, 0x0590, 0x0900)
++ | in_range16x8!(s, 0xFB1D, 0xFE00)
++ | in_range16x8!(s, 0xFE70, 0xFEFF)
++ | in_range16x8!(s, 0xD802, 0xD804)
++ | in_range16x8!(s, 0xD83A, 0xD83C)
++ | s.simd_eq(u16x8::splat(0x200F))
++ | s.simd_eq(u16x8::splat(0x202B))
++ | s.simd_eq(u16x8::splat(0x202E))
++ | s.simd_eq(u16x8::splat(0x2067))),
++ )
+ }
+
+ #[inline(always)]
+ pub fn simd_unpack(s: u8x16) -> (u16x8, u16x8) {
+- unsafe {
+- let first: u8x16 = shuffle!(
+- s,
+- u8x16::splat(0),
+- [0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23]
+- );
+- let second: u8x16 = shuffle!(
+- s,
+- u8x16::splat(0),
+- [8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31]
+- );
+- (first.into_bits(), second.into_bits())
+- }
++ let first: u8x16 = simd_swizzle!(
++ s,
++ u8x16::splat(0),
++ [0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23]
++ );
++ let second: u8x16 = simd_swizzle!(
++ s,
++ u8x16::splat(0),
++ [8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31]
++ );
++ (u16x8::from_ne_bytes(first), u16x8::from_ne_bytes(second))
+ }
+
+ cfg_if! {
+ if #[cfg(target_feature = "sse2")] {
+ #[inline(always)]
+ pub fn simd_pack(a: u16x8, b: u16x8) -> u8x16 {
+ unsafe {
+- _mm_packus_epi16(a.into_bits(), b.into_bits()).into_bits()
++ // Safety: We have cfg()d the correct platform
++ _mm_packus_epi16(a.into(), b.into()).into()
+ }
+ }
+ } else {
+ #[inline(always)]
+ pub fn simd_pack(a: u16x8, b: u16x8) -> u8x16 {
+- unsafe {
+- let first: u8x16 = a.into_bits();
+- let second: u8x16 = b.into_bits();
+- shuffle!(
+- first,
+- second,
+- [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]
+- )
+- }
++ let first: u8x16 = a.to_ne_bytes();
++ let second: u8x16 = b.to_ne_bytes();
++ simd_swizzle!(
++ first,
++ second,
++ [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]
++ )
+ }
+ }
+ }
+
+ #[cfg(test)]
+ mod tests {
+ use super::*;
+ use alloc::vec::Vec;
+diff --git a/third_party/rust/encoding_rs/src/single_byte.rs b/third_party/rust/encoding_rs/src/single_byte.rs
+--- third_party/rust/encoding_rs/src/single_byte.rs
++++ third_party/rust/encoding_rs/src/single_byte.rs
+@@ -48,16 +48,19 @@ impl SingleByteDecoder {
+ CopyAsciiResult::GoOn((mut non_ascii, mut handle)) => 'middle: loop {
+ // Start non-boilerplate
+ //
+ // Since the non-ASCIIness of `non_ascii` is hidden from
+ // the optimizer, it can't figure out that it's OK to
+ // statically omit the bound check when accessing
+ // `[u16; 128]` with an index
+ // `non_ascii as usize - 0x80usize`.
++ //
++ // Safety: `non_ascii` is a u8 byte >=0x80, from the invariants
++ // on Utf8Destination::copy_ascii_from_check_space_bmp()
+ let mapped =
+ unsafe { *(self.table.get_unchecked(non_ascii as usize - 0x80usize)) };
+ // let mapped = self.table[non_ascii as usize - 0x80usize];
+ if mapped == 0u16 {
+ return (
+ DecoderResult::Malformed(1, 0),
+ source.consumed(),
+ handle.written(),
+@@ -146,82 +149,103 @@ impl SingleByteDecoder {
+ dst: &mut [u16],
+ _last: bool,
+ ) -> (DecoderResult, usize, usize) {
+ let (pending, length) = if dst.len() < src.len() {
+ (DecoderResult::OutputFull, dst.len())
+ } else {
+ (DecoderResult::InputEmpty, src.len())
+ };
++ // Safety invariant: converted <= length. Quite often we have `converted < length`
++ // which will be separately marked.
+ let mut converted = 0usize;
+ 'outermost: loop {
+ match unsafe {
++ // Safety: length is the minimum length, `src/dst + x` will always be valid for reads/writes of `len - x`
+ ascii_to_basic_latin(
+ src.as_ptr().add(converted),
+ dst.as_mut_ptr().add(converted),
+ length - converted,
+ )
+ } {
+ None => {
+ return (pending, length, length);
+ }
+ Some((mut non_ascii, consumed)) => {
++ // Safety invariant: `converted <= length` upheld, since this can only consume
++ // up to `length - converted` bytes.
++ //
++ // Furthermore, in this context,
++ // we can assume `converted < length` since this branch is only ever hit when
++ // ascii_to_basic_latin fails to consume the entire slice
+ converted += consumed;
+ 'middle: loop {
+ // `converted` doesn't count the reading of `non_ascii` yet.
+ // Since the non-ASCIIness of `non_ascii` is hidden from
+ // the optimizer, it can't figure out that it's OK to
+ // statically omit the bound check when accessing
+ // `[u16; 128]` with an index
+ // `non_ascii as usize - 0x80usize`.
++ //
++ // Safety: We can rely on `non_ascii` being between `0x80` and `0xFF` due to
++ // the invariants of `ascii_to_basic_latin()`, and our table has enough space for that.
+ let mapped =
+ unsafe { *(self.table.get_unchecked(non_ascii as usize - 0x80usize)) };
+ // let mapped = self.table[non_ascii as usize - 0x80usize];
+ if mapped == 0u16 {
+ return (
+ DecoderResult::Malformed(1, 0),
+ converted + 1, // +1 `for non_ascii`
+ converted,
+ );
+ }
+ unsafe {
+- // The bound check has already been performed
++ // Safety: As mentioned above, `converted < length`
+ *(dst.get_unchecked_mut(converted)) = mapped;
+ }
++ // Safety: `converted <= length` upheld, since `converted < length` before this
+ converted += 1;
+ // Next, handle ASCII punctuation and non-ASCII without
+ // going back to ASCII acceleration. Non-ASCII scripts
+ // use ASCII punctuation, so this avoid going to
+ // acceleration just for punctuation/space and then
+ // failing. This is a significant boost to non-ASCII
+ // scripts.
+ // TODO: Split out Latin converters without this part
+ // this stuff makes Latin script-conversion slower.
+ if converted == length {
+ return (pending, length, length);
+ }
++ // Safety: We are back to `converted < length` because of the == above
++ // and can perform this check.
+ let mut b = unsafe { *(src.get_unchecked(converted)) };
++ // Safety: `converted < length` is upheld for this loop
+ 'innermost: loop {
+ if b > 127 {
+ non_ascii = b;
+ continue 'middle;
+ }
+ // Testing on Haswell says that we should write the
+ // byte unconditionally instead of trying to unread it
+ // to make it part of the next SIMD stride.
+ unsafe {
++ // Safety: `converted < length` is true for this loop
+ *(dst.get_unchecked_mut(converted)) = u16::from(b);
+ }
++ // Safety: We are now at `converted <= length`. We should *not* `continue`
++ // the loop without reverifying
+ converted += 1;
+ if b < 60 {
+ // We've got punctuation
+ if converted == length {
+ return (pending, length, length);
+ }
++ // Safety: we're back to `converted <= length` because of the == above
+ b = unsafe { *(src.get_unchecked(converted)) };
++ // Safety: The loop continues as `converted < length`
+ continue 'innermost;
+ }
+ // We've got markup or ASCII text
+ continue 'outermost;
+ }
+ }
+ }
+ }
+@@ -229,16 +253,18 @@ impl SingleByteDecoder {
+ }
+
+ pub fn latin1_byte_compatible_up_to(&self, buffer: &[u8]) -> usize {
+ let mut bytes = buffer;
+ let mut total = 0;
+ loop {
+ if let Some((non_ascii, offset)) = validate_ascii(bytes) {
+ total += offset;
++ // Safety: We can rely on `non_ascii` being between `0x80` and `0xFF` due to
++ // the invariants of `ascii_to_basic_latin()`, and our table has enough space for that.
+ let mapped = unsafe { *(self.table.get_unchecked(non_ascii as usize - 0x80usize)) };
+ if mapped != u16::from(non_ascii) {
+ return total;
+ }
+ total += 1;
+ bytes = &bytes[offset + 1..];
+ } else {
+ return total;
+@@ -379,64 +405,89 @@ impl SingleByteEncoder {
+ dst: &mut [u8],
+ _last: bool,
+ ) -> (EncoderResult, usize, usize) {
+ let (pending, length) = if dst.len() < src.len() {
+ (EncoderResult::OutputFull, dst.len())
+ } else {
+ (EncoderResult::InputEmpty, src.len())
+ };
++ // Safety invariant: converted <= length. Quite often we have `converted < length`
++ // which will be separately marked.
+ let mut converted = 0usize;
+ 'outermost: loop {
+ match unsafe {
++ // Safety: length is the minimum length, `src/dst + x` will always be valid for reads/writes of `len - x`
+ basic_latin_to_ascii(
+ src.as_ptr().add(converted),
+ dst.as_mut_ptr().add(converted),
+ length - converted,
+ )
+ } {
+ None => {
+ return (pending, length, length);
+ }
+ Some((mut non_ascii, consumed)) => {
++ // Safety invariant: `converted <= length` upheld, since this can only consume
++ // up to `length - converted` bytes.
++ //
++ // Furthermore, in this context,
++ // we can assume `converted < length` since this branch is only ever hit when
++ // ascii_to_basic_latin fails to consume the entire slice
+ converted += consumed;
+ 'middle: loop {
+ // `converted` doesn't count the reading of `non_ascii` yet.
+ match self.encode_u16(non_ascii) {
+ Some(byte) => {
+ unsafe {
++ // Safety: we're allowed this access since `converted < length`
+ *(dst.get_unchecked_mut(converted)) = byte;
+ }
+ converted += 1;
++ // `converted <= length` now
+ }
+ None => {
+ // At this point, we need to know if we
+ // have a surrogate.
+ let high_bits = non_ascii & 0xFC00u16;
+ if high_bits == 0xD800u16 {
+ // high surrogate
+ if converted + 1 == length {
+ // End of buffer. This surrogate is unpaired.
+ return (
+ EncoderResult::Unmappable('\u{FFFD}'),
+ converted + 1, // +1 `for non_ascii`
+ converted,
+ );
+ }
++ // Safety: convered < length from outside the match, and `converted + 1 != length`,
++ // So `converted + 1 < length` as well. We're in bounds
+ let second =
+ u32::from(unsafe { *src.get_unchecked(converted + 1) });
+ if second & 0xFC00u32 != 0xDC00u32 {
+ return (
+ EncoderResult::Unmappable('\u{FFFD}'),
+ converted + 1, // +1 `for non_ascii`
+ converted,
+ );
+ }
+ // The next code unit is a low surrogate.
+ let astral: char = unsafe {
++ // Safety: We can rely on non_ascii being 0xD800-0xDBFF since the high bits are 0xD800
++ // Then, (non_ascii << 10 - 0xD800 << 10) becomes between (0 to 0x3FF) << 10, which is between
++ // 0x400 to 0xffc00. Adding the 0x10000 gives a range of 0x10400 to 0x10fc00. Subtracting the 0xDC00
++ // gives 0x2800 to 0x102000
++ // The second term is between 0xDC00 and 0xDFFF from the check above. This gives a maximum
++ // possible range of (0x10400 + 0xDC00) to (0x102000 + 0xDFFF) which is 0x1E000 to 0x10ffff.
++ // This is in range.
++ //
++ // From a Unicode principles perspective this can also be verified as we have checked that `non_ascii` is a high surrogate
++ // (0xD800..=0xDBFF), and that `second` is a low surrogate (`0xDC00..=0xDFFF`), and we are applying reverse of the UTC16 transformation
++ // algorithm <https://en.wikipedia.org/wiki/UTF-16#Code_points_from_U+010000_to_U+10FFFF>, by applying the high surrogate - 0xD800 to the
++ // high ten bits, and the low surrogate - 0xDc00 to the low ten bits, and then adding 0x10000
+ ::core::char::from_u32_unchecked(
+ (u32::from(non_ascii) << 10) + second
+ - (((0xD800u32 << 10) - 0x1_0000u32) + 0xDC00u32),
+ )
+ };
+ return (
+ EncoderResult::Unmappable(astral),
+ converted + 2, // +2 `for non_ascii` and `second`
+@@ -451,52 +502,63 @@ impl SingleByteEncoder {
+ converted,
+ );
+ }
+ return (
+ EncoderResult::unmappable_from_bmp(non_ascii),
+ converted + 1, // +1 `for non_ascii`
+ converted,
+ );
++ // Safety: This branch diverges, so no need to uphold invariants on `converted`
+ }
+ }
+ // Next, handle ASCII punctuation and non-ASCII without
+ // going back to ASCII acceleration. Non-ASCII scripts
+ // use ASCII punctuation, so this avoid going to
+ // acceleration just for punctuation/space and then
+ // failing. This is a significant boost to non-ASCII
+ // scripts.
+ // TODO: Split out Latin converters without this part
+ // this stuff makes Latin script-conversion slower.
+ if converted == length {
+ return (pending, length, length);
+ }
++ // Safety: we're back to `converted < length` due to the == above and can perform
++ // the unchecked read
+ let mut unit = unsafe { *(src.get_unchecked(converted)) };
+ 'innermost: loop {
++ // Safety: This loop always begins with `converted < length`, see
++ // the invariant outside and the comment on the continue below
+ if unit > 127 {
+ non_ascii = unit;
+ continue 'middle;
+ }
+ // Testing on Haswell says that we should write the
+ // byte unconditionally instead of trying to unread it
+ // to make it part of the next SIMD stride.
+ unsafe {
++ // Safety: Can rely on converted < length
+ *(dst.get_unchecked_mut(converted)) = unit as u8;
+ }
+ converted += 1;
++ // `converted <= length` here
+ if unit < 60 {
+ // We've got punctuation
+ if converted == length {
+ return (pending, length, length);
+ }
++ // Safety: `converted < length` due to the == above. The read is safe.
+ unit = unsafe { *(src.get_unchecked(converted)) };
++ // Safety: This only happens if `converted < length`, maintaining it
+ continue 'innermost;
+ }
+ // We've got markup or ASCII text
+ continue 'outermost;
++ // Safety: All other routes to here diverge so the continue is the only
++ // way to run the innermost loop.
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+diff --git a/third_party/rust/encoding_rs/src/x_user_defined.rs b/third_party/rust/encoding_rs/src/x_user_defined.rs
+--- third_party/rust/encoding_rs/src/x_user_defined.rs
++++ third_party/rust/encoding_rs/src/x_user_defined.rs
+@@ -9,22 +9,23 @@
+
+ use super::*;
+ use crate::handles::*;
+ use crate::variant::*;
+
+ cfg_if! {
+ if #[cfg(feature = "simd-accel")] {
+ use simd_funcs::*;
+- use packed_simd::u16x8;
++ use core::simd::u16x8;
++ use core::simd::cmp::SimdPartialOrd;
+
+ #[inline(always)]
+ fn shift_upper(unpacked: u16x8) -> u16x8 {
+ let highest_ascii = u16x8::splat(0x7F);
+- unpacked + unpacked.gt(highest_ascii).select(u16x8::splat(0xF700), u16x8::splat(0)) }
++ unpacked + unpacked.simd_gt(highest_ascii).select(u16x8::splat(0xF700), u16x8::splat(0)) }
+ } else {
+ }
+ }
+
+ pub struct UserDefinedDecoder;
+
+ impl UserDefinedDecoder {
+ pub fn new() -> VariantDecoder {
+@@ -111,20 +112,25 @@ impl UserDefinedDecoder {
+ } else {
+ (DecoderResult::InputEmpty, src.len())
+ };
+ // Not bothering with alignment
+ let tail_start = length & !0xF;
+ let simd_iterations = length >> 4;
+ let src_ptr = src.as_ptr();
+ let dst_ptr = dst.as_mut_ptr();
++ // Safety: This is `for i in 0..length / 16`
+ for i in 0..simd_iterations {
++ // Safety: This is in bounds: length is the minumum valid length for both src/dst
++ // and i ranges to length/16, so multiplying by 16 will always be `< length` and can do
++ // a 16 byte read
+ let input = unsafe { load16_unaligned(src_ptr.add(i * 16)) };
+ let (first, second) = simd_unpack(input);
+ unsafe {
++ // Safety: same as above, but this is two consecutive 8-byte reads
+ store8_unaligned(dst_ptr.add(i * 16), shift_upper(first));
+ store8_unaligned(dst_ptr.add((i * 16) + 8), shift_upper(second));
+ }
+ }
+ let src_tail = &src[tail_start..length];
+ let dst_tail = &mut dst[tail_start..length];
+ src_tail
+ .iter()
+
+--- config/makefiles/rust.mk.orig 2024-08-01 18:27:37.000000000 +0000
++++ config/makefiles/rust.mk
+@@ -249,7 +252,7 @@ endif
+ ifndef RUSTC_BOOTSTRAP
+ RUSTC_BOOTSTRAP := mozglue_static,qcms
+ ifdef MOZ_RUST_SIMD
+-RUSTC_BOOTSTRAP := $(RUSTC_BOOTSTRAP),encoding_rs,packed_simd
++RUSTC_BOOTSTRAP := $(RUSTC_BOOTSTRAP),encoding_rs,any_all_workaround
+ endif
+ export RUSTC_BOOTSTRAP
+ endif
Index: pkgsrc/mail/thunderbird115/patches/patch-security_nss_lib_freebl_mpi_mpi.c
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-security_nss_lib_freebl_mpi_mpi.c:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-security_nss_lib_freebl_mpi_mpi.c Tue Oct 1 14:21:37 2024
@@ -0,0 +1,25 @@
+$NetBSD: patch-security_nss_lib_freebl_mpi_mpi.c,v 1.1 2024/10/01 14:21:37 ryoon Exp $
+
+--- security/nss/lib/freebl/mpi/mpi.c.orig 2020-08-28 21:33:15.000000000 +0000
++++ security/nss/lib/freebl/mpi/mpi.c
+@@ -4661,9 +4661,9 @@ s_mp_tovalue(char ch, int r)
+ int val, xch;
+
+ if (r > 36)
+- xch = ch;
++ xch = (unsigned char) ch;
+ else
+- xch = toupper(ch);
++ xch = toupper((unsigned char) ch);
+
+ if (isdigit(xch))
+ val = xch - '0';
+@@ -4709,7 +4709,7 @@ s_mp_todigit(mp_digit val, int r, int lo
+ ch = s_dmap_1[val];
+
+ if (r <= 36 && low)
+- ch = tolower(ch);
++ ch = tolower((unsigned char) ch);
+
+ return ch;
+
Index: pkgsrc/mail/thunderbird115/patches/patch-servo_components_style__traits_values.rs
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-servo_components_style__traits_values.rs:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-servo_components_style__traits_values.rs Tue Oct 1 14:21:38 2024
@@ -0,0 +1,47 @@
+$NetBSD: patch-servo_components_style__traits_values.rs,v 1.1 2024/10/01 14:21:38 ryoon Exp $
+
+Bug 1912663 - Fix some build issues with cbindgen 0.27. r=firefox-style-system-reviewers,zrhoffman
+
+It updates serde and syn and they are more strict. In particular, syn 2
+doesn't parse the rust 2015 syntax where try is not a keyword, and serde
+rejects duplicate keys.
+
+Differential Revision: https://phabricator.services.mozilla.com/D219025
+
+--- servo/components/style_traits/values.rs.orig 2024-08-19 19:21:51.000000000 +0000
++++ servo/components/style_traits/values.rs
+@@ -388,11 +388,11 @@ impl Separator for Space {
+ where
+ F: for<'tt> FnMut(&mut Parser<'i, 'tt>) -> Result<T, ParseError<'i, E>>,
+ {
+- input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less.
++ input.skip_whitespace(); // Unnecessary for correctness, but may help try_parse() rewind less.
+ let mut results = vec![parse_one(input)?];
+ loop {
+- input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less.
+- if let Ok(item) = input.try(&mut parse_one) {
++ input.skip_whitespace(); // Unnecessary for correctness, but may help try_parse() rewind less.
++ if let Ok(item) = input.try_parse(&mut parse_one) {
+ results.push(item);
+ } else {
+ return Ok(results);
+@@ -413,14 +413,14 @@ impl Separator for CommaWithSpace {
+ where
+ F: for<'tt> FnMut(&mut Parser<'i, 'tt>) -> Result<T, ParseError<'i, E>>,
+ {
+- input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less.
++ input.skip_whitespace(); // Unnecessary for correctness, but may help try_parse() rewind less.
+ let mut results = vec![parse_one(input)?];
+ loop {
+- input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less.
++ input.skip_whitespace(); // Unnecessary for correctness, but may help try_parse() rewind less.
+ let comma_location = input.current_source_location();
+- let comma = input.try(|i| i.expect_comma()).is_ok();
+- input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less.
+- if let Ok(item) = input.try(&mut parse_one) {
++ let comma = input.try_parse(|i| i.expect_comma()).is_ok();
++ input.skip_whitespace(); // Unnecessary for correctness, but may help try_parse() rewind less.
++ if let Ok(item) = input.try_parse(&mut parse_one) {
+ results.push(item);
+ } else if comma {
+ return Err(comma_location.new_unexpected_token_error(Token::Comma));
Index: pkgsrc/mail/thunderbird115/patches/patch-servo_ports_geckolib_cbindgen.toml
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-servo_ports_geckolib_cbindgen.toml:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-servo_ports_geckolib_cbindgen.toml Tue Oct 1 14:21:38 2024
@@ -0,0 +1,20 @@
+$NetBSD: patch-servo_ports_geckolib_cbindgen.toml,v 1.1 2024/10/01 14:21:38 ryoon Exp $
+
+Bug 1912663 - Fix some build issues with cbindgen 0.27. r=firefox-style-system-reviewers,zrhoffman
+
+It updates serde and syn and they are more strict. In particular, syn 2
+doesn't parse the rust 2015 syntax where try is not a keyword, and serde
+rejects duplicate keys.
+
+Differential Revision: https://phabricator.services.mozilla.com/D219025
+
+--- servo/ports/geckolib/cbindgen.toml.orig 2024-08-19 19:21:52.000000000 +0000
++++ servo/ports/geckolib/cbindgen.toml
+@@ -360,7 +360,6 @@ renaming_overrides_prefixing = true
+ "Keyframe" = "Keyframe"
+ "nsChangeHint" = "nsChangeHint"
+ "ServoElementSnapshotTable" = "ServoElementSnapshotTable"
+-"Keyframe" = "Keyframe"
+ "ComputedKeyframeValues" = "ComputedKeyframeValues"
+ "OriginFlags" = "OriginFlags"
+ "ServoTraversalFlags" = "ServoTraversalFlags"
Index: pkgsrc/mail/thunderbird115/patches/patch-third__party_libwebrtc_modules_video__capture_linux_device__info__v4l2.cc
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-third__party_libwebrtc_modules_video__capture_linux_device__info__v4l2.cc:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-third__party_libwebrtc_modules_video__capture_linux_device__info__v4l2.cc Tue Oct 1 14:21:38 2024
@@ -0,0 +1,67 @@
+$NetBSD: patch-third__party_libwebrtc_modules_video__capture_linux_device__info__v4l2.cc,v 1.1 2024/10/01 14:21:38 ryoon Exp $
+
+* Fix build under NetBSD 9 and older.
+ The older NetBSD's sys/videoio.h does not have v4l2_capability.device_caps.
+
+--- third_party/libwebrtc/modules/video_capture/linux/device_info_v4l2.cc.orig 2022-10-19 18:00:20.000000000 +0000
++++ third_party/libwebrtc/modules/video_capture/linux/device_info_v4l2.cc
+@@ -193,11 +193,13 @@ uint32_t DeviceInfoV4l2::NumberOfDevices
+ for (int n = 0; n < 64; n++) {
+ snprintf(device, sizeof(device), "/dev/video%d", n);
+ if ((fd = open(device, O_RDONLY)) != -1) {
++#if defined(VIDIOC_QUERYCAP)
+ // query device capabilities and make sure this is a video capture device
+ if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0 || !IsVideoCaptureDevice(&cap)) {
+ close(fd);
+ continue;
+ }
++#endif
+
+ close(fd);
+ count++;
+@@ -225,11 +227,13 @@ int32_t DeviceInfoV4l2::GetDeviceName(ui
+ for (device_index = 0; device_index < 64; device_index++) {
+ sprintf(device, "/dev/video%d", device_index);
+ if ((fd = open(device, O_RDONLY)) != -1) {
++#if defined(VIDIOC_QUERYCAP)
+ // query device capabilities and make sure this is a video capture device
+ if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0 || !IsVideoCaptureDevice(&cap)) {
+ close(fd);
+ continue;
+ }
++#endif
+ if (count == deviceNumber) {
+ // Found the device
+ found = true;
+@@ -307,6 +311,7 @@ int32_t DeviceInfoV4l2::CreateCapability
+ if (fd == -1)
+ continue;
+
++#if defined(VIDIOC_QUERYCAP)
+ // query device capabilities
+ struct v4l2_capability cap;
+ if (ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0) {
+@@ -331,6 +336,7 @@ int32_t DeviceInfoV4l2::CreateCapability
+ }
+ }
+ }
++#endif
+ close(fd); // close since this is not the matching device
+ }
+
+@@ -376,11 +382,15 @@ bool DeviceInfoV4l2::IsDeviceNameMatches
+
+ bool DeviceInfoV4l2::IsVideoCaptureDevice(struct v4l2_capability* cap)
+ {
++#if defined(V4L2_CAP_DEVICE_CAPS)
+ if (cap->capabilities & V4L2_CAP_DEVICE_CAPS) {
+ return cap->device_caps & V4L2_CAP_VIDEO_CAPTURE;
+ } else {
+ return cap->capabilities & V4L2_CAP_VIDEO_CAPTURE;
+ }
++#else
++ return cap->capabilities & V4L2_CAP_VIDEO_CAPTURE;
++#endif
+ }
+
+ int32_t DeviceInfoV4l2::FillCapabilities(int fd) {
Index: pkgsrc/mail/thunderbird115/patches/patch-third__party_rust_libc_src_unix_bsd_netbsdlike_netbsd_mod.rs
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-third__party_rust_libc_src_unix_bsd_netbsdlike_netbsd_mod.rs:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-third__party_rust_libc_src_unix_bsd_netbsdlike_netbsd_mod.rs Tue Oct 1 14:21:38 2024
@@ -0,0 +1,65 @@
+$NetBSD: patch-third__party_rust_libc_src_unix_bsd_netbsdlike_netbsd_mod.rs,v 1.1 2024/10/01 14:21:38 ryoon Exp $
+
+--- third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs.orig 2020-08-28 21:33:54.000000000 +0000
++++ third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs
+@@ -1,6 +1,7 @@
+ pub type clock_t = ::c_uint;
+ pub type suseconds_t = ::c_int;
+ pub type dev_t = u64;
++pub type key_t = c_long;
+ pub type blksize_t = i32;
+ pub type fsblkcnt_t = u64;
+ pub type fsfilcnt_t = u64;
+@@ -619,6 +620,17 @@ s_no_extra_traits! {
+ pub ar_op: u16,
+ }
+
++ #[repr(packed)]
++ pub struct ipc_perm {
++ pub cuid: ::uid_t,
++ pub cgid: ::gid_t,
++ pub uid: ::uid_t,
++ pub gid: ::gid_t,
++ pub mode: ::mode_t,
++ pub seq: ::c_ushort,
++ pub key: ::key_t,
++ }
++
+ pub struct in_addr {
+ pub s_addr: ::in_addr_t,
+ }
+@@ -1488,6 +1500,7 @@ pub const SCM_CREDS: ::c_int = 0x10;
+
+ pub const O_DSYNC: ::c_int = 0x10000;
+
++pub const MAP_ANONYMOUS: ::c_int =0x1000;
+ pub const MAP_RENAME: ::c_int = 0x20;
+ pub const MAP_NORESERVE: ::c_int = 0x40;
+ pub const MAP_HASSEMAPHORE: ::c_int = 0x200;
+@@ -1505,6 +1518,12 @@ pub const MAP_ALIGNMENT_64PB: ::c_int =
+ // mremap flag
+ pub const MAP_REMAPDUP: ::c_int = 0x004;
+
++pub const IPC_PRIVATE: ::key_t = 0;
++pub const IPC_CREAT: ::c_int = 0x1000;
++pub const IPC_EXCL: ::c_int = 0x2000;
++pub const IPC_NOWAIT: ::c_int = 0x4000;
++pub const IPC_RMID: ::c_int = 0;
++
+ pub const DCCP_TYPE_REQUEST: ::c_int = 0;
+ pub const DCCP_TYPE_RESPONSE: ::c_int = 1;
+ pub const DCCP_TYPE_DATA: ::c_int = 2;
+@@ -2412,6 +2431,13 @@ extern "C" {
+ pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: *mut ::c_void, data: ::c_int) -> ::c_int;
+ pub fn utrace(label: *const ::c_char, addr: *mut ::c_void, len: ::size_t) -> ::c_int;
+ pub fn pthread_getname_np(t: ::pthread_t, name: *mut ::c_char, len: ::size_t) -> ::c_int;
++ pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
++ pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void,
++ shmflg: ::c_int) -> *mut ::c_void;
++ pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int;
++ #[cfg_attr(target_os = "netbsd", link_name = "__shmctl50")]
++ pub fn shmctl(shmid: ::c_int, cmd: ::c_int,
++ buf: *mut ::shmid_ds) -> ::c_int;
+ pub fn pthread_setname_np(
+ t: ::pthread_t,
+ name: *const ::c_char,
Index: pkgsrc/mail/thunderbird115/patches/patch-third__party_sqlite3_src_moz.build
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-third__party_sqlite3_src_moz.build:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-third__party_sqlite3_src_moz.build Tue Oct 1 14:21:38 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-third__party_sqlite3_src_moz.build,v 1.1 2024/10/01 14:21:38 ryoon Exp $
+
+* Fix segfault under NetBSD/i386 9 and pkgsrc/lang/gcc8-8.5.0
+ For NetBSD/i386 9, @SQLITE3OPTFLAG@ will be replaced with "'-O0',".
+
+--- third_party/sqlite3/src/moz.build.orig 2023-06-22 21:19:22.000000000 +0000
++++ third_party/sqlite3/src/moz.build
+@@ -108,6 +108,7 @@ if CONFIG['CC_TYPE'] in ('clang', 'gcc')
+ CFLAGS += [
+ '-Wno-sign-compare',
+ '-Wno-type-limits',
++ @SQLITE3OPTFLAG@
+ ]
+
+ # Set a default journal size limit. Note an hot journal can grow over this
Index: pkgsrc/mail/thunderbird115/patches/patch-third__party_wasm2c_src_prebuilt_wasm2c__source__includes.cc
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-third__party_wasm2c_src_prebuilt_wasm2c__source__includes.cc:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-third__party_wasm2c_src_prebuilt_wasm2c__source__includes.cc Tue Oct 1 14:21:38 2024
@@ -0,0 +1,13 @@
+$NetBSD: patch-third__party_wasm2c_src_prebuilt_wasm2c__source__includes.cc,v 1.1 2024/10/01 14:21:38 ryoon Exp $
+
+--- third_party/wasm2c/src/prebuilt/wasm2c_source_includes.cc.orig 2023-05-25 21:19:41.000000000 +0000
++++ third_party/wasm2c/src/prebuilt/wasm2c_source_includes.cc
+@@ -20,7 +20,7 @@ R"w2c_template(#include <malloc.h>
+ )w2c_template"
+ R"w2c_template(#define alloca _alloca
+ )w2c_template"
+-R"w2c_template(#elif defined(__FreeBSD__) || defined(__OpenBSD__)
++R"w2c_template(#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+ )w2c_template"
+ R"w2c_template(#include <stdlib.h>
+ )w2c_template"
Index: pkgsrc/mail/thunderbird115/patches/patch-toolkit_components_terminator_nsTerminator.cpp
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-toolkit_components_terminator_nsTerminator.cpp:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-toolkit_components_terminator_nsTerminator.cpp Tue Oct 1 14:21:38 2024
@@ -0,0 +1,26 @@
+$NetBSD: patch-toolkit_components_terminator_nsTerminator.cpp,v 1.1 2024/10/01 14:21:38 ryoon Exp $
+
+--- toolkit/components/terminator/nsTerminator.cpp.orig 2020-08-28 21:33:46.000000000 +0000
++++ toolkit/components/terminator/nsTerminator.cpp
+@@ -34,7 +34,7 @@
+ #if defined(XP_WIN)
+ # include <windows.h>
+ #else
+-# include <unistd.h>
++# include <time.h>
+ #endif
+
+ #include "mozilla/AppShutdown.h"
+@@ -184,7 +184,11 @@ void RunWatchdog(void* arg) {
+ #if defined(XP_WIN)
+ Sleep(HEARTBEAT_INTERVAL_MS /* ms */);
+ #else
+- usleep(HEARTBEAT_INTERVAL_MS * 1000 /* usec */);
++ // usleep(HEARTBEAT_INTERVAL_MS * 1000 /* usec */);
++ struct timespec tickd;
++ tickd.tv_sec = 1;
++ tickd.tv_nsec = 0;
++ nanosleep(&tickd, NULL);
+ #endif
+
+ if (gHeartbeat++ < timeToLive) {
Index: pkgsrc/mail/thunderbird115/patches/patch-toolkit_modules_subprocess_subprocess__shared__unix.js
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-toolkit_modules_subprocess_subprocess__shared__unix.js:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-toolkit_modules_subprocess_subprocess__shared__unix.js Tue Oct 1 14:21:38 2024
@@ -0,0 +1,22 @@
+$NetBSD: patch-toolkit_modules_subprocess_subprocess__shared__unix.js,v 1.1 2024/10/01 14:21:38 ryoon Exp $
+
+--- toolkit/modules/subprocess/subprocess_shared_unix.js.orig 2020-08-28 21:34:00.000000000 +0000
++++ toolkit/modules/subprocess/subprocess_shared_unix.js
+@@ -13,7 +13,16 @@
+
+ var LIBC = OS.Constants.libc;
+
+-const LIBC_CHOICES = ["libc.so", "libSystem.B.dylib", "a.out"];
++// const LIBC_CHOICES = ["libc.so", "libSystem.B.dylib", "a.out"];
++/* libc.so isn't meant to be dlopen'ed. On Linux it's usually an ld
++ * script so one cannot dlopen it. On NetBSD (and possibly other
++ * BSDs too) dlopen'ing libc.so will succeed, but some global symbols,
++ * especially environ(7), are pointing to unused memory regions
++ * because they are meant to be overridden by the main executable.
++ * So the most portable way to access libc symbols is to do it through
++ * the NULL handle, i.e. the one which NSPR calls "a.out".
++ */
++const LIBC_CHOICES = ["a.out"];
+
+ const unix = {
+ pid_t: ctypes.int32_t,
Index: pkgsrc/mail/thunderbird115/patches/patch-toolkit_moz.configure
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-toolkit_moz.configure:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-toolkit_moz.configure Tue Oct 1 14:21:38 2024
@@ -0,0 +1,22 @@
+$NetBSD: patch-toolkit_moz.configure,v 1.1 2024/10/01 14:21:38 ryoon Exp $
+
+--- toolkit/moz.configure.orig 2023-08-14 18:20:04.000000000 +0000
++++ toolkit/moz.configure
+@@ -325,8 +325,6 @@ set_config("MOZ_OPENSL", imply_opensl, w
+
+ set_config("MOZ_OSS", imply_oss, when="--enable-audio-backends")
+
+-imply_option("--enable-pulseaudio", imply_pulseaudio, reason="--enable-audio-backends")
+-
+ imply_option("--enable-sndio", imply_sndio, reason="--enable-audio-backends")
+
+ set_config("MOZ_SUNAUDIO", imply_sunaudio, when="--enable-audio-backends")
+@@ -1167,7 +1165,7 @@ set_define("MOZ_WEBSPEECH_TEST_BACKEND",
+ # ==============================================================
+ @depends(target, milestone)
+ def skia_pdf_default(target, milestone):
+- return milestone.is_nightly and target.os != "WINNT"
++ return milestone.is_nightly and target.os != "WINNT" and target.endianness != 'big'
+
+
+ option("--enable-skia-pdf", default=skia_pdf_default, help="{Enable|Disable} Skia PDF")
Index: pkgsrc/mail/thunderbird115/patches/patch-toolkit_mozapps_installer_packager.mk
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-toolkit_mozapps_installer_packager.mk:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-toolkit_mozapps_installer_packager.mk Tue Oct 1 14:21:38 2024
@@ -0,0 +1,13 @@
+$NetBSD: patch-toolkit_mozapps_installer_packager.mk,v 1.1 2024/10/01 14:21:38 ryoon Exp $
+
+--- toolkit/mozapps/installer/packager.mk.orig 2020-08-28 21:33:59.000000000 +0000
++++ toolkit/mozapps/installer/packager.mk
+@@ -156,7 +156,7 @@ 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)
++ #ln -s $(installdir)/$(MOZ_APP_NAME) $(DESTDIR)$(bindir)
+
+ upload:
+ $(PYTHON3) -u $(MOZILLA_DIR)/build/upload.py --base-path $(DIST) $(UPLOAD_FILES)
Index: pkgsrc/mail/thunderbird115/patches/patch-widget_gtk_DMABufSurface.cpp
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-widget_gtk_DMABufSurface.cpp:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-widget_gtk_DMABufSurface.cpp Tue Oct 1 14:21:38 2024
@@ -0,0 +1,34 @@
+$NetBSD: patch-widget_gtk_DMABufSurface.cpp,v 1.1 2024/10/01 14:21:38 ryoon Exp $
+
+No eventfd on NetBSD 9 and older, fix build
+
+--- widget/gtk/DMABufSurface.cpp.orig 2023-08-14 18:20:04.000000000 +0000
++++ widget/gtk/DMABufSurface.cpp
+@@ -18,7 +18,9 @@
+ #include <sys/time.h>
+ #include <dlfcn.h>
+ #include <sys/mman.h>
++#ifndef __NetBSD__
+ #include <sys/eventfd.h>
++#endif
+ #include <poll.h>
+ #include <sys/ioctl.h>
+
+@@ -147,6 +149,9 @@ void DMABufSurface::GlobalRefAdd() {
+ }
+
+ void DMABufSurface::GlobalRefCountCreate() {
++#ifdef __NetBSD__
++ mGlobalRefCountFd = 0;
++#else
+ LOGDMABUFREF(("DMABufSurface::GlobalRefCountCreate UID %d", mUID));
+ MOZ_DIAGNOSTIC_ASSERT(!mGlobalRefCountFd);
+ // Create global ref count initialized to 0,
+@@ -159,6 +164,7 @@ void DMABufSurface::GlobalRefCountCreate
+ mGlobalRefCountFd = 0;
+ return;
+ }
++#endif
+ }
+
+ void DMABufSurface::GlobalRefCountImport(int aFd) {
Index: pkgsrc/mail/thunderbird115/patches/patch-xpcom_base_nscore.h
diff -u /dev/null pkgsrc/mail/thunderbird115/patches/patch-xpcom_base_nscore.h:1.1
--- /dev/null Tue Oct 1 14:21:38 2024
+++ pkgsrc/mail/thunderbird115/patches/patch-xpcom_base_nscore.h Tue Oct 1 14:21:38 2024
@@ -0,0 +1,13 @@
+$NetBSD: patch-xpcom_base_nscore.h,v 1.1 2024/10/01 14:21:38 ryoon Exp $
+
+--- xpcom/base/nscore.h.orig 2020-08-28 21:33:30.000000000 +0000
++++ xpcom/base/nscore.h
+@@ -77,7 +77,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)
Home |
Main Index |
Thread Index |
Old Index