From 4bef7cebe6ebd5e5585ac5079bbd0ec6eb44a954 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 2 Feb 2016 08:38:43 -0800 Subject: [PATCH 1/5] Use old memcpy for wrappers --- BUILD | 2 + Makefile | 7 ++-- binding.gyp | 6 +++ build.yaml | 2 + gRPC.podspec | 1 + grpc.gemspec | 1 + package.json | 1 + setup.py | 11 ++++- src/core/support/wrap_memcpy.c | 46 +++++++++++++++++++++ src/python/grpcio/grpc_core_dependencies.py | 1 + src/ruby/ext/grpc/extconf.rb | 2 + templates/Makefile.template | 10 +++-- templates/binding.gyp.template | 5 +++ tools/doxygen/Doxyfile.core.internal | 3 +- tools/run_tests/sources_and_headers.json | 3 +- vsprojects/vcxproj/gpr/gpr.vcxproj | 2 + vsprojects/vcxproj/gpr/gpr.vcxproj.filters | 3 ++ 17 files changed, 97 insertions(+), 9 deletions(-) create mode 100644 src/core/support/wrap_memcpy.c diff --git a/BUILD b/BUILD index c40ee518bba..92d0e699785 100644 --- a/BUILD +++ b/BUILD @@ -96,6 +96,7 @@ cc_library( "src/core/support/time_precise.c", "src/core/support/time_win32.c", "src/core/support/tls_pthread.c", + "src/core/support/wrap_memcpy.c", ], hdrs = [ "include/grpc/support/alloc.h", @@ -1171,6 +1172,7 @@ objc_library( "src/core/support/time_precise.c", "src/core/support/time_win32.c", "src/core/support/tls_pthread.c", + "src/core/support/wrap_memcpy.c", ], hdrs = [ "include/grpc/support/alloc.h", diff --git a/Makefile b/Makefile index 794778dae48..53974d1ef00 100644 --- a/Makefile +++ b/Makefile @@ -2247,6 +2247,7 @@ LIBGPR_SRC = \ src/core/support/time_precise.c \ src/core/support/time_win32.c \ src/core/support/tls_pthread.c \ + src/core/support/wrap_memcpy.c \ PUBLIC_HEADERS_C += \ include/grpc/support/alloc.h \ @@ -3884,15 +3885,15 @@ ifeq ($(SYSTEM),MINGW32) $(LIBDIR)/$(CONFIG)/grpc_csharp_ext.$(SHARED_EXT): $(LIBGRPC_CSHARP_EXT_OBJS) $(ZLIB_DEP) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_csharp_ext.def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext-imp.a -o $(LIBDIR)/$(CONFIG)/grpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) + $(Q) $(LD) $(LDFLAGS) -Wl,-wrap,memcpy -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_csharp_ext.def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext-imp.a -o $(LIBDIR)/$(CONFIG)/grpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) else $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT): $(LIBGRPC_CSHARP_EXT_OBJS) $(ZLIB_DEP) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name libgrpc_csharp_ext.$(SHARED_EXT) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) + $(Q) $(LD) $(LDFLAGS) -Wl,-wrap,memcpy -L$(LIBDIR)/$(CONFIG) -install_name libgrpc_csharp_ext.$(SHARED_EXT) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.0 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) + $(Q) $(LD) $(LDFLAGS) -Wl,-wrap,memcpy -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.0 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(Q) ln -sf libgrpc_csharp_ext.$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.so.0 $(Q) ln -sf libgrpc_csharp_ext.$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.so endif diff --git a/binding.gyp b/binding.gyp index 133f8f48624..0e4181cc06b 100644 --- a/binding.gyp +++ b/binding.gyp @@ -528,6 +528,7 @@ 'src/core/support/time_precise.c', 'src/core/support/time_win32.c', 'src/core/support/tls_pthread.c', + 'src/core/support/wrap_memcpy.c', ], "conditions": [ ['OS == "mac"', { @@ -743,6 +744,11 @@ "boringssl", "z", ] + }], + ['OS=="linux"', { + 'ldflags': [ + '-Wl,-wrap,memcpy' + ] }] ], "target_name": "grpc_node", diff --git a/build.yaml b/build.yaml index f8d18fbb9a6..41b09aa19e0 100644 --- a/build.yaml +++ b/build.yaml @@ -511,6 +511,7 @@ libs: - src/core/support/time_precise.c - src/core/support/time_win32.c - src/core/support/tls_pthread.c + - src/core/support/wrap_memcpy.c filegroups: - grpc_codegen secure: false @@ -872,6 +873,7 @@ libs: deps: - grpc - gpr + LDFLAGS: -Wl,-wrap,memcpy deps_linkage: static dll: only vs_config_type: DynamicLibrary diff --git a/gRPC.podspec b/gRPC.podspec index 30b278798a1..70e33edfc9d 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -163,6 +163,7 @@ Pod::Spec.new do |s| 'src/core/support/time_precise.c', 'src/core/support/time_win32.c', 'src/core/support/tls_pthread.c', + 'src/core/support/wrap_memcpy.c', 'src/core/security/auth_filters.h', 'src/core/security/base64.h', 'src/core/security/credentials.h', diff --git a/grpc.gemspec b/grpc.gemspec index 585d3ec9090..13e79d5005a 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -146,6 +146,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/support/time_precise.c ) s.files += %w( src/core/support/time_win32.c ) s.files += %w( src/core/support/tls_pthread.c ) + s.files += %w( src/core/support/wrap_memcpy.c ) s.files += %w( include/grpc/grpc_security.h ) s.files += %w( include/grpc/byte_buffer.h ) s.files += %w( include/grpc/byte_buffer_reader.h ) diff --git a/package.json b/package.json index 0a3440e6e4c..f47a3631408 100644 --- a/package.json +++ b/package.json @@ -503,6 +503,7 @@ "src/core/support/time_precise.c", "src/core/support/time_win32.c", "src/core/support/tls_pthread.c", + "src/core/support/wrap_memcpy.c", "third_party/boringssl/crypto/aes/internal.h", "third_party/boringssl/crypto/asn1/asn1_locl.h", "third_party/boringssl/crypto/bio/internal.h", diff --git a/setup.py b/setup.py index 01e91808543..6699263ab11 100644 --- a/setup.py +++ b/setup.py @@ -80,10 +80,19 @@ EXTENSION_INCLUDE_DIRECTORIES = ( EXTENSION_LIBRARIES = ('m',) if not "darwin" in sys.platform: - EXTENSION_LIBRARIES += ('rt',) + EXTENSION_LIBRARIES += ('rt',) DEFINE_MACROS = (('OPENSSL_NO_ASM', 1),) +CFLAGS = (,) +LDFLAGS = (,) +if "linux" in sys.platform: + LDFLAGS += ('-Wl,-wrap,memcpy',) +if "linux" in sys.platform or "darwin" in sys.platform: + CFLAGS += ('-fvisibility=hidden',) + DEFINE_MACROS += (('PyMODINIT_FUNC', '__attribute__((visibility ("default"))) void'),) + + def cython_extensions(package_names, module_names, include_dirs, libraries, define_macros, build_with_cython=False): if ENABLE_CYTHON_TRACING: diff --git a/src/core/support/wrap_memcpy.c b/src/core/support/wrap_memcpy.c new file mode 100644 index 00000000000..b191d0396be --- /dev/null +++ b/src/core/support/wrap_memcpy.c @@ -0,0 +1,46 @@ +/* +* +* Copyright 2016, Google Inc. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are +* met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following disclaimer +* in the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Google Inc. nor the names of its +* contributors may be used to endorse or promote products derived from +* this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include + +/* Provide a wrapped memcpy for targets that need to be backwards + * compatible with older libc's. + * + * Enable by setting LDFLAGS=-Wl,-wrap,memcpy when linking. + */ + +__asm__(".symver memcpy,memcpy@GLIBC_2.2.5"); + +void *__wrap_memcpy(void *destination, const void *source, size_t num) { + return memcpy(destination, source, num); +} diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 708091df9f1..ad4714da217 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -72,6 +72,7 @@ CORE_SOURCE_FILES = [ 'src/core/support/time_precise.c', 'src/core/support/time_win32.c', 'src/core/support/tls_pthread.c', + 'src/core/support/wrap_memcpy.c', 'src/core/httpcli/httpcli_security_connector.c', 'src/core/security/base64.c', 'src/core/security/client_auth_filter.c', diff --git a/src/ruby/ext/grpc/extconf.rb b/src/ruby/ext/grpc/extconf.rb index 018353ce5d8..3d809856cc0 100644 --- a/src/ruby/ext/grpc/extconf.rb +++ b/src/ruby/ext/grpc/extconf.rb @@ -80,6 +80,8 @@ if grpc_config == 'gcov' $LDFLAGS << ' -fprofile-arcs -ftest-coverage -rdynamic' end +$LDFLAGS << ' -Wl,-wrap,memcpy' + $CFLAGS << ' -std=c99 ' $CFLAGS << ' -Wall ' $CFLAGS << ' -Wextra ' diff --git a/templates/Makefile.template b/templates/Makefile.template index 1770d0f3663..a3d37804492 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -1598,6 +1598,10 @@ if lib.language == 'c++': common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)' + + ldflags = '$(LDFLAGS)' + if lib.get('LDFLAGS', None): + ldflags += ' ' + lib['LDFLAGS'] %> % if lib.build == "all": @@ -1605,15 +1609,15 @@ ${out_base}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps} $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=${out_base}.def -Wl,--out-implib=${out_libbase}-imp.a -o ${out_base}.$(SHARED_EXT) ${common}${mingw_libs} + $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=${out_base}.def -Wl,--out-implib=${out_libbase}-imp.a -o ${out_base}.$(SHARED_EXT) ${common}${mingw_libs} else ${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps} $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) - $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name lib${lib.name}.$(SHARED_EXT) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs} + $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -install_name lib${lib.name}.$(SHARED_EXT) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs} else - $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs} + $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs} $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so.${settings.version.major} $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so endif diff --git a/templates/binding.gyp.template b/templates/binding.gyp.template index a913585240d..31c9f8c96cf 100644 --- a/templates/binding.gyp.template +++ b/templates/binding.gyp.template @@ -230,6 +230,11 @@ % endif % endfor ] + }], + ['OS=="linux"', { + 'ldflags': [ + '-Wl,-wrap,memcpy' + ] }] ], "target_name": "${module.name}", diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index cd49a1980dc..17603802e07 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1150,7 +1150,8 @@ src/core/support/time.c \ src/core/support/time_posix.c \ src/core/support/time_precise.c \ src/core/support/time_win32.c \ -src/core/support/tls_pthread.c +src/core/support/tls_pthread.c \ +src/core/support/wrap_memcpy.c # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index aef0023a3e5..505385591de 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -2929,7 +2929,8 @@ "src/core/support/time_precise.c", "src/core/support/time_precise.h", "src/core/support/time_win32.c", - "src/core/support/tls_pthread.c" + "src/core/support/tls_pthread.c", + "src/core/support/wrap_memcpy.c" ] }, { diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj b/vsprojects/vcxproj/gpr/gpr.vcxproj index b20d6ff77f5..2d081240f90 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj @@ -293,6 +293,8 @@ + + diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters index 85d8ec86729..1480f339d7d 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters @@ -127,6 +127,9 @@ src\core\support + + src\core\support + From 00572a9dec89bb93e458c9c1a68cf8de9cd7b5bd Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 2 Feb 2016 08:45:46 -0800 Subject: [PATCH 2/5] Experimentally fix syntax --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 6699263ab11..2f73e94c458 100644 --- a/setup.py +++ b/setup.py @@ -84,8 +84,8 @@ if not "darwin" in sys.platform: DEFINE_MACROS = (('OPENSSL_NO_ASM', 1),) -CFLAGS = (,) -LDFLAGS = (,) +CFLAGS = () +LDFLAGS = () if "linux" in sys.platform: LDFLAGS += ('-Wl,-wrap,memcpy',) if "linux" in sys.platform or "darwin" in sys.platform: From 2cf2389ef8243307298c2a6290af6eebaf71fcc8 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 2 Feb 2016 08:50:34 -0800 Subject: [PATCH 3/5] Refine platform detection --- src/core/support/wrap_memcpy.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/support/wrap_memcpy.c b/src/core/support/wrap_memcpy.c index b191d0396be..6cedcaf1660 100644 --- a/src/core/support/wrap_memcpy.c +++ b/src/core/support/wrap_memcpy.c @@ -39,8 +39,11 @@ * Enable by setting LDFLAGS=-Wl,-wrap,memcpy when linking. */ +#ifdef __linux__ __asm__(".symver memcpy,memcpy@GLIBC_2.2.5"); void *__wrap_memcpy(void *destination, const void *source, size_t num) { return memcpy(destination, source, num); } +#endif + From 72c920f1484bb6ba3c21d8bafe012b845858ffa5 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 2 Feb 2016 08:58:57 -0800 Subject: [PATCH 4/5] Copyright, clang-format --- src/core/support/wrap_memcpy.c | 1 - src/ruby/ext/grpc/extconf.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/support/wrap_memcpy.c b/src/core/support/wrap_memcpy.c index 6cedcaf1660..36b474575fe 100644 --- a/src/core/support/wrap_memcpy.c +++ b/src/core/support/wrap_memcpy.c @@ -46,4 +46,3 @@ void *__wrap_memcpy(void *destination, const void *source, size_t num) { return memcpy(destination, source, num); } #endif - diff --git a/src/ruby/ext/grpc/extconf.rb b/src/ruby/ext/grpc/extconf.rb index 3d809856cc0..b13dd6c76d2 100644 --- a/src/ruby/ext/grpc/extconf.rb +++ b/src/ruby/ext/grpc/extconf.rb @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without From c01f240618be62acb7e612bf2866eb88ac4c14e3 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 2 Feb 2016 09:02:54 -0800 Subject: [PATCH 5/5] Clean up formatting --- src/core/support/wrap_memcpy.c | 62 +++++++++++++++++----------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/core/support/wrap_memcpy.c b/src/core/support/wrap_memcpy.c index 36b474575fe..cb59cc7e50e 100644 --- a/src/core/support/wrap_memcpy.c +++ b/src/core/support/wrap_memcpy.c @@ -1,35 +1,35 @@ /* -* -* Copyright 2016, Google Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are -* met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following disclaimer -* in the documentation and/or other materials provided with the -* distribution. -* * Neither the name of Google Inc. nor the names of its -* contributors may be used to endorse or promote products derived from -* this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ #include