diff --git a/.clang-format-ignore b/.clang-format-ignore index 76ab26b11f24..f37c01fe2edc 100644 --- a/.clang-format-ignore +++ b/.clang-format-ignore @@ -168,7 +168,6 @@ media/openmax_il/.* media/webrtc/signaling/src/sdp/sipcc/.* media/webrtc/trunk/.* mfbt/double-conversion/double-conversion/.* -mfbt/lz4/.* mobile/android/geckoview/src/thirdparty/.* modules/brotli/.* modules/fdlibm/.* @@ -180,6 +179,7 @@ modules/woff2/src/.* modules/xz-embedded/.* modules/zlib/.* mozglue/misc/decimal/.* +mozglue/static/lz4/.* mozglue/tests/glibc_printf_tests/.* netwerk/dns/nsIDNKitInterface.h netwerk/sctp/src/.* diff --git a/.prettierignore b/.prettierignore index 3563bbb0132b..d5a03cdfef3b 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1389,7 +1389,6 @@ media/mp4parse-rust/ media/openmax_il/ media/webrtc/signaling/gtest/MockCall.h mfbt/double-conversion/double-conversion/ -mfbt/lz4/.* mobile/android/android-components/components/feature/readerview/src/main/assets/extensions/readerview/readability/JSDOMParser-0.4.2.js mobile/android/android-components/components/feature/readerview/src/main/assets/extensions/readerview/readability/readability-0.4.2.js mobile/android/android-components/components/feature/readerview/src/main/assets/extensions/readerview/readability/readability-readerable-0.4.2.js @@ -1401,6 +1400,7 @@ modules/woff2/ modules/xz-embedded/ modules/zlib/ mozglue/misc/decimal/ +mozglue/static/lz4/.* mozglue/tests/glibc_printf_tests/ netwerk/dns/nsIDNKitInterface.h netwerk/sctp/src/ diff --git a/build/sanitizers/ubsan_pointer_overflow_blacklist.txt b/build/sanitizers/ubsan_pointer_overflow_blacklist.txt index 43b07ddae982..3989df20cd36 100644 --- a/build/sanitizers/ubsan_pointer_overflow_blacklist.txt +++ b/build/sanitizers/ubsan_pointer_overflow_blacklist.txt @@ -18,7 +18,7 @@ src:*/media/libvpx/libvpx/vp8/encoder/encodeframe.c src:*/third_party/aom/av1/common/quant_common.c # crashtest src:*/parser/expat/lib/xmlparse.c -src:*/mfbt/lz4/lz4.c +src:*/mozglue/static/lz4/lz4.c src:*/media/libogg/src/ogg_framing.c # mochitest gl2c dom/canvas/test/webgl-conf/generated/test_2_conformance2__reading__read-pixels-pack-parameters.html src:*/dom/canvas/WebGLContextGL.cpp diff --git a/build/sanitizers/ubsan_signed_overflow_blacklist.txt b/build/sanitizers/ubsan_signed_overflow_blacklist.txt index 06c6502887b4..d72a8b04a2fa 100644 --- a/build/sanitizers/ubsan_signed_overflow_blacklist.txt +++ b/build/sanitizers/ubsan_signed_overflow_blacklist.txt @@ -112,7 +112,7 @@ src:*/modules/zlib/src/* # Our LZ4 implementation uses overflows. By listing it here we might # miss some unintended overflows in that implementation, but we can't # check for it right now. -src:*/mfbt/lz4.c +src:*/mozglue/static/lz4/lz4.c # Apparently this overflows a lot, because it contains some allocators # that keep overflowing, not sure why. Disabling by function didn't seem diff --git a/build/sanitizers/ubsan_unsigned_overflow_blacklist.txt b/build/sanitizers/ubsan_unsigned_overflow_blacklist.txt index ba7e59569fb3..c7d9e2b3f09f 100644 --- a/build/sanitizers/ubsan_unsigned_overflow_blacklist.txt +++ b/build/sanitizers/ubsan_unsigned_overflow_blacklist.txt @@ -119,7 +119,7 @@ src:*/modules/zlib/src/* # Our LZ4 implementation uses overflows. By listing it here we might # miss some unintended overflows in that implementation, but we can't # check for it right now. -src:*/mfbt/lz4/* +src:*/mozglue/static/lz4/* # Apparently this overflows a lot, because it contains some allocators # that keep overflowing, not sure why. Disabling by function didn't seem diff --git a/mfbt/moz.build b/mfbt/moz.build index be3482a8162b..35891b9bbc68 100644 --- a/mfbt/moz.build +++ b/mfbt/moz.build @@ -35,7 +35,6 @@ EXPORTS.mozilla = [ "CheckedInt.h", "CompactPair.h", "Compiler.h", - "Compression.h", "DbgMacro.h", "DebugOnly.h", "DefineEnum.h", @@ -163,7 +162,6 @@ if CONFIG["MOZ_TSAN"]: UNIFIED_SOURCES += [ "Assertions.cpp", "ChaosMode.cpp", - "Compression.cpp", "double-conversion/double-conversion/bignum-dtoa.cc", "double-conversion/double-conversion/bignum.cc", "double-conversion/double-conversion/cached-powers.cc", @@ -194,22 +192,10 @@ if CONFIG["MOZ_BUILD_APP"] not in ( DEFINES["IMPL_MFBT"] = True -SOURCES += [ - "lz4/lz4.c", - "lz4/lz4file.c", - "lz4/lz4frame.c", - "lz4/lz4hc.c", - "lz4/xxhash.c", -] - -SOURCES["lz4/xxhash.c"].flags += ["-Wno-unused-function"] - DisableStlWrapping() OS_LIBS += CONFIG["LIBATOMIC_LIBS"] -DEFINES["LZ4LIB_VISIBILITY"] = "" - # For RefCounted.cpp DEFINES["MOZ_SUPPORT_LEAKCHECKING"] = True diff --git a/mozglue/moz.build b/mozglue/moz.build index b94a86279345..1198aa69c1ff 100644 --- a/mozglue/moz.build +++ b/mozglue/moz.build @@ -20,6 +20,7 @@ DIRS += [ "baseprofiler", "build", "misc", + "static", ] if CONFIG["MOZ_WIDGET_TOOLKIT"]: diff --git a/mfbt/Compression.cpp b/mozglue/static/Compression.cpp similarity index 100% rename from mfbt/Compression.cpp rename to mozglue/static/Compression.cpp diff --git a/mfbt/Compression.h b/mozglue/static/Compression.h similarity index 79% rename from mfbt/Compression.h rename to mozglue/static/Compression.h index d9f787c0b46a..60b783afa1db 100644 --- a/mfbt/Compression.h +++ b/mozglue/static/Compression.h @@ -42,8 +42,7 @@ class LZ4 { * @param aInputSize is the input size. Max supported value is ~1.9GB * @return the number of bytes written in buffer |aDest| */ - static MFBT_API size_t compress(const char* aSource, size_t aInputSize, - char* aDest); + static size_t compress(const char* aSource, size_t aInputSize, char* aDest); /** * Compress |aInputSize| bytes from |aSource| into an output buffer @@ -60,9 +59,8 @@ class LZ4 { * @return the number of bytes written in buffer |aDest| or 0 if the * compression fails */ - static MFBT_API size_t compressLimitedOutput(const char* aSource, - size_t aInputSize, char* aDest, - size_t aMaxOutputSize); + static size_t compressLimitedOutput(const char* aSource, size_t aInputSize, + char* aDest, size_t aMaxOutputSize); /** * If the source stream is malformed, the function will stop decoding @@ -81,10 +79,9 @@ class LZ4 { * buffer (necessarily <= aMaxOutputSize) * @return true on success, false on failure */ - [[nodiscard]] static MFBT_API bool decompress(const char* aSource, - size_t aInputSize, char* aDest, - size_t aMaxOutputSize, - size_t* aOutputSize); + [[nodiscard]] static bool decompress(const char* aSource, size_t aInputSize, + char* aDest, size_t aMaxOutputSize, + size_t* aOutputSize); /** * If the source stream is malformed, the function will stop decoding @@ -105,11 +102,10 @@ class LZ4 { * buffer (necessarily <= aMaxOutputSize) * @return true on success, false on failure */ - [[nodiscard]] static MFBT_API bool decompressPartial(const char* aSource, - size_t aInputSize, - char* aDest, - size_t aMaxOutputSize, - size_t* aOutputSize); + [[nodiscard]] static bool decompressPartial(const char* aSource, + size_t aInputSize, char* aDest, + size_t aMaxOutputSize, + size_t* aOutputSize); /* * Provides the maximum size that LZ4 may output in a "worst case" @@ -134,10 +130,10 @@ class LZ4 { */ class LZ4FrameCompressionContext final { public: - MFBT_API LZ4FrameCompressionContext(int aCompressionLevel, size_t aMaxSrcSize, - bool aChecksum, bool aStableSrc = false); + LZ4FrameCompressionContext(int aCompressionLevel, size_t aMaxSrcSize, + bool aChecksum, bool aStableSrc = false); - MFBT_API ~LZ4FrameCompressionContext(); + ~LZ4FrameCompressionContext(); size_t GetRequiredWriteBufferLength() { return mWriteBufLen; } @@ -147,8 +143,7 @@ class LZ4FrameCompressionContext final { * @return a Result with a Span containing the frame header, or an lz4 error * code (size_t). */ - MFBT_API Result, size_t> BeginCompressing( - Span aWriteBuffer); + Result, size_t> BeginCompressing(Span aWriteBuffer); /** * Continue streaming frame-based compression with the provided input. @@ -157,8 +152,7 @@ class LZ4FrameCompressionContext final { * @return a Result with a Span containing compressed output, or an lz4 error * code (size_t). */ - MFBT_API Result, size_t> ContinueCompressing( - Span aInput); + Result, size_t> ContinueCompressing(Span aInput); /** * Finalize streaming frame-based compression with the provided input. @@ -166,7 +160,7 @@ class LZ4FrameCompressionContext final { * @return a Result with a Span containing compressed output and the frame * footer, or an lz4 error code (size_t). */ - MFBT_API Result, size_t> EndCompressing(); + Result, size_t> EndCompressing(); private: LZ4F_cctx_s* mContext; @@ -191,8 +185,8 @@ struct LZ4FrameDecompressionResult { */ class LZ4FrameDecompressionContext final { public: - explicit MFBT_API LZ4FrameDecompressionContext(bool aStableDest = false); - MFBT_API ~LZ4FrameDecompressionContext(); + explicit LZ4FrameDecompressionContext(bool aStableDest = false); + ~LZ4FrameDecompressionContext(); /** * Decompress a buffer/part of a buffer compressed with @@ -204,7 +198,7 @@ class LZ4FrameDecompressionContext final { * completely decompressed the input into the output, or an lz4 error code * (size_t). */ - MFBT_API Result Decompress( + Result Decompress( Span aOutput, Span aInput); private: diff --git a/mfbt/lz4/LICENSE b/mozglue/static/lz4/LICENSE similarity index 100% rename from mfbt/lz4/LICENSE rename to mozglue/static/lz4/LICENSE diff --git a/mfbt/lz4/README.md b/mozglue/static/lz4/README.md similarity index 100% rename from mfbt/lz4/README.md rename to mozglue/static/lz4/README.md diff --git a/mfbt/lz4/README.mozilla b/mozglue/static/lz4/README.mozilla similarity index 100% rename from mfbt/lz4/README.mozilla rename to mozglue/static/lz4/README.mozilla diff --git a/mfbt/lz4/lz4.c b/mozglue/static/lz4/lz4.c similarity index 100% rename from mfbt/lz4/lz4.c rename to mozglue/static/lz4/lz4.c diff --git a/mfbt/lz4/lz4.h b/mozglue/static/lz4/lz4.h similarity index 100% rename from mfbt/lz4/lz4.h rename to mozglue/static/lz4/lz4.h diff --git a/mfbt/lz4/lz4file.c b/mozglue/static/lz4/lz4file.c similarity index 100% rename from mfbt/lz4/lz4file.c rename to mozglue/static/lz4/lz4file.c diff --git a/mfbt/lz4/lz4file.h b/mozglue/static/lz4/lz4file.h similarity index 100% rename from mfbt/lz4/lz4file.h rename to mozglue/static/lz4/lz4file.h diff --git a/mfbt/lz4/lz4frame.c b/mozglue/static/lz4/lz4frame.c similarity index 100% rename from mfbt/lz4/lz4frame.c rename to mozglue/static/lz4/lz4frame.c diff --git a/mfbt/lz4/lz4frame.h b/mozglue/static/lz4/lz4frame.h similarity index 100% rename from mfbt/lz4/lz4frame.h rename to mozglue/static/lz4/lz4frame.h diff --git a/mfbt/lz4/lz4frame_static.h b/mozglue/static/lz4/lz4frame_static.h similarity index 100% rename from mfbt/lz4/lz4frame_static.h rename to mozglue/static/lz4/lz4frame_static.h diff --git a/mfbt/lz4/lz4hc.c b/mozglue/static/lz4/lz4hc.c similarity index 100% rename from mfbt/lz4/lz4hc.c rename to mozglue/static/lz4/lz4hc.c diff --git a/mfbt/lz4/lz4hc.h b/mozglue/static/lz4/lz4hc.h similarity index 100% rename from mfbt/lz4/lz4hc.h rename to mozglue/static/lz4/lz4hc.h diff --git a/mfbt/lz4/xxhash.c b/mozglue/static/lz4/xxhash.c similarity index 100% rename from mfbt/lz4/xxhash.c rename to mozglue/static/lz4/xxhash.c diff --git a/mfbt/lz4/xxhash.h b/mozglue/static/lz4/xxhash.h similarity index 100% rename from mfbt/lz4/xxhash.h rename to mozglue/static/lz4/xxhash.h diff --git a/mozglue/static/moz.build b/mozglue/static/moz.build new file mode 100644 index 000000000000..ba194f23a38c --- /dev/null +++ b/mozglue/static/moz.build @@ -0,0 +1,26 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +EXPORTS.mozilla = ["Compression.h"] + +UNIFIED_SOURCES += [ + "Compression.cpp", +] + +SOURCES += [ + "lz4/lz4.c", + "lz4/lz4file.c", + "lz4/lz4frame.c", + "lz4/lz4hc.c", + "lz4/xxhash.c", +] + +SOURCES["lz4/xxhash.c"].flags += ["-Wno-unused-function"] + +DEFINES["LZ4LIB_VISIBILITY"] = "" + +# By putting it in js, it ends up in libxul too. +FINAL_LIBRARY = "js" diff --git a/tools/rewriting/ThirdPartyPaths.txt b/tools/rewriting/ThirdPartyPaths.txt index b6cb487283e1..4551cb9b71e4 100644 --- a/tools/rewriting/ThirdPartyPaths.txt +++ b/tools/rewriting/ThirdPartyPaths.txt @@ -133,7 +133,6 @@ media/openmax_dl/ media/openmax_il/ media/webrtc/signaling/gtest/MockCall.h mfbt/double-conversion/double-conversion/ -mfbt/lz4/.* mobile/android/android-components/components/feature/readerview/src/main/assets/extensions/readerview/readability/JSDOMParser-0.4.2.js mobile/android/android-components/components/feature/readerview/src/main/assets/extensions/readerview/readability/readability-0.4.2.js mobile/android/android-components/components/feature/readerview/src/main/assets/extensions/readerview/readability/readability-readerable-0.4.2.js @@ -145,6 +144,7 @@ modules/woff2/ modules/xz-embedded/ modules/zlib/ mozglue/misc/decimal/ +mozglue/static/lz4/.* mozglue/tests/glibc_printf_tests/ netwerk/dns/nsIDNKitInterface.h netwerk/sctp/src/