diff --git a/mfbt/Compression.cpp b/mfbt/Compression.cpp index c675aa90af62..830e0b01b43b 100644 --- a/mfbt/Compression.cpp +++ b/mfbt/Compression.cpp @@ -12,27 +12,10 @@ // corecrt_memory.h. #include -// Because we wrap lz4.c in an anonymous namespace, all of its #includes -// go in the anonymous namespace too. This would create conflicting -// declarations for intrinsic functions that are internally defined -// at top-level. Including intrin.h here prevents it from being included -// later within the anonymous namespace. -#ifdef _MSC_VER -#include -#endif +#include "lz4.h" using namespace mozilla::Compression; -namespace { - -extern "C" { - -#include "lz4.c" - -} - -}/* anonymous namespace */ - /* Our wrappers */ size_t diff --git a/mfbt/lz4.h b/mfbt/lz4.h index 020a09d5bd50..5a5de84c31ef 100644 --- a/mfbt/lz4.h +++ b/mfbt/lz4.h @@ -72,19 +72,23 @@ extern "C" { /* * LZ4_DLL_EXPORT : * Enable exporting of functions when building a Windows DLL -* LZ4LIB_API : +* LZ4LIB_VISIBILITY : * Control library symbols visibility. */ -#if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1) -# define LZ4LIB_API __declspec(dllexport) -#elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1) -# define LZ4LIB_API __declspec(dllimport) /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ -#elif defined(__GNUC__) && (__GNUC__ >= 4) -# define LZ4LIB_API __attribute__ ((__visibility__ ("default"))) -#else -# define LZ4LIB_API +#ifndef LZ4LIB_VISIBILITY +# if defined(__GNUC__) && (__GNUC__ >= 4) +# define LZ4LIB_VISIBILITY __attribute__ ((visibility ("default"))) +# else +# define LZ4LIB_VISIBILITY +# endif +#endif +#if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1) +# define LZ4LIB_API __declspec(dllexport) LZ4LIB_VISIBILITY +#elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1) +# define LZ4LIB_API __declspec(dllimport) LZ4LIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ +#else +# define LZ4LIB_API LZ4LIB_VISIBILITY #endif - /*------ Version ------*/ #define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */ diff --git a/mfbt/moz.build b/mfbt/moz.build index 6c90106384bf..4e1aee1d87ea 100644 --- a/mfbt/moz.build +++ b/mfbt/moz.build @@ -147,24 +147,16 @@ DEFINES['IMPL_MFBT'] = True SOURCES += [ 'Compression.cpp', 'decimal/Decimal.cpp', + 'lz4.c', ] DisableStlWrapping() -# Suppress warnings in third-party LZ4 code. -# TODO: Remove these suppressions after bug 993267 is fixed. - -if CONFIG['GNU_CXX']: - SOURCES['Compression.cpp'].flags += ['-Wno-unused-function'] - CXXFLAGS += ['-Wno-error=shadow'] - if CONFIG['CLANG_CXX']: # Suppress warnings from third-party V8 Decimal code. SOURCES['decimal/Decimal.cpp'].flags += ['-Wno-implicit-fallthrough'] -if CONFIG['_MSC_VER']: - # Error 4804 is "'>' : unsafe use of type 'bool' in operation" - SOURCES['Compression.cpp'].flags += ['-wd4804'] - if CONFIG['MOZ_NEEDS_LIBATOMIC']: OS_LIBS += ['atomic'] + +DEFINES['LZ4LIB_VISIBILITY'] = ''