You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by om...@apache.org on 2017/07/24 17:49:40 UTC
[38/51] [partial] orc git commit: ORC-204 Update and use CMake
External Project to build C++ compression libraries.
http://git-wip-us.apache.org/repos/asf/orc/blob/590245a0/c++/libs/snappy-1.1.2/m4/gtest.m4
----------------------------------------------------------------------
diff --git a/c++/libs/snappy-1.1.2/m4/gtest.m4 b/c++/libs/snappy-1.1.2/m4/gtest.m4
deleted file mode 100644
index 98e61f9..0000000
--- a/c++/libs/snappy-1.1.2/m4/gtest.m4
+++ /dev/null
@@ -1,74 +0,0 @@
-dnl GTEST_LIB_CHECK([minimum version [,
-dnl action if found [,action if not found]]])
-dnl
-dnl Check for the presence of the Google Test library, optionally at a minimum
-dnl version, and indicate a viable version with the HAVE_GTEST flag. It defines
-dnl standard variables for substitution including GTEST_CPPFLAGS,
-dnl GTEST_CXXFLAGS, GTEST_LDFLAGS, and GTEST_LIBS. It also defines
-dnl GTEST_VERSION as the version of Google Test found. Finally, it provides
-dnl optional custom action slots in the event GTEST is found or not.
-AC_DEFUN([GTEST_LIB_CHECK],
-[
-dnl Provide a flag to enable or disable Google Test usage.
-AC_ARG_ENABLE([gtest],
- [AS_HELP_STRING([--enable-gtest],
- [Enable tests using the Google C++ Testing Framework.
- (Default is enabled.)])],
- [],
- [enable_gtest=])
-AC_ARG_VAR([GTEST_CONFIG],
- [The exact path of Google Test's 'gtest-config' script.])
-AC_ARG_VAR([GTEST_CPPFLAGS],
- [C-like preprocessor flags for Google Test.])
-AC_ARG_VAR([GTEST_CXXFLAGS],
- [C++ compile flags for Google Test.])
-AC_ARG_VAR([GTEST_LDFLAGS],
- [Linker path and option flags for Google Test.])
-AC_ARG_VAR([GTEST_LIBS],
- [Library linking flags for Google Test.])
-AC_ARG_VAR([GTEST_VERSION],
- [The version of Google Test available.])
-HAVE_GTEST="no"
-AS_IF([test "x${enable_gtest}" != "xno"],
- [AC_MSG_CHECKING([for 'gtest-config'])
- AS_IF([test "x${enable_gtest}" = "xyes"],
- [AS_IF([test -x "${enable_gtest}/scripts/gtest-config"],
- [GTEST_CONFIG="${enable_gtest}/scripts/gtest-config"],
- [GTEST_CONFIG="${enable_gtest}/bin/gtest-config"])
- AS_IF([test -x "${GTEST_CONFIG}"], [],
- [AC_MSG_RESULT([no])
- AC_MSG_ERROR([dnl
-Unable to locate either a built or installed Google Test.
-The specific location '${enable_gtest}' was provided for a built or installed
-Google Test, but no 'gtest-config' script could be found at this location.])
- ])],
- [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])])
- AS_IF([test -x "${GTEST_CONFIG}"],
- [AC_MSG_RESULT([${GTEST_CONFIG}])
- m4_ifval([$1],
- [_gtest_min_version="--min-version=$1"
- AC_MSG_CHECKING([for Google Test at least version >= $1])],
- [_gtest_min_version="--min-version=0"
- AC_MSG_CHECKING([for Google Test])])
- AS_IF([${GTEST_CONFIG} ${_gtest_min_version}],
- [AC_MSG_RESULT([yes])
- HAVE_GTEST='yes'],
- [AC_MSG_RESULT([no])])],
- [AC_MSG_RESULT([no])])
- AS_IF([test "x${HAVE_GTEST}" = "xyes"],
- [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags`
- GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags`
- GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
- GTEST_LIBS=`${GTEST_CONFIG} --libs`
- GTEST_VERSION=`${GTEST_CONFIG} --version`
- AC_DEFINE([HAVE_GTEST],[1],[Defined when Google Test is available.])],
- [AS_IF([test "x${enable_gtest}" = "xyes"],
- [AC_MSG_ERROR([dnl
-Google Test was enabled, but no viable version could be found.])
- ])])])
-AC_SUBST([HAVE_GTEST])
-AM_CONDITIONAL([HAVE_GTEST],[test "x$HAVE_GTEST" = "xyes"])
-AS_IF([test "x$HAVE_GTEST" = "xyes"],
- [m4_ifval([$2], [$2])],
- [m4_ifval([$3], [$3])])
-])
http://git-wip-us.apache.org/repos/asf/orc/blob/590245a0/c++/libs/snappy-1.1.2/missing
----------------------------------------------------------------------
diff --git a/c++/libs/snappy-1.1.2/missing b/c++/libs/snappy-1.1.2/missing
deleted file mode 100644
index 86a8fc3..0000000
--- a/c++/libs/snappy-1.1.2/missing
+++ /dev/null
@@ -1,331 +0,0 @@
-#! /bin/sh
-# Common stub for a few missing GNU programs while installing.
-
-scriptversion=2012-01-06.13; # UTC
-
-# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
-# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
-# Originally by Fran,cois Pinard <pi...@iro.umontreal.ca>, 1996.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-if test $# -eq 0; then
- echo 1>&2 "Try \`$0 --help' for more information"
- exit 1
-fi
-
-run=:
-sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
-sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
-
-# In the cases where this matters, `missing' is being run in the
-# srcdir already.
-if test -f configure.ac; then
- configure_ac=configure.ac
-else
- configure_ac=configure.in
-fi
-
-msg="missing on your system"
-
-case $1 in
---run)
- # Try to run requested program, and just exit if it succeeds.
- run=
- shift
- "$@" && exit 0
- # Exit code 63 means version mismatch. This often happens
- # when the user try to use an ancient version of a tool on
- # a file that requires a minimum version. In this case we
- # we should proceed has if the program had been absent, or
- # if --run hadn't been passed.
- if test $? = 63; then
- run=:
- msg="probably too old"
- fi
- ;;
-
- -h|--h|--he|--hel|--help)
- echo "\
-$0 [OPTION]... PROGRAM [ARGUMENT]...
-
-Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
-error status if there is no known handling for PROGRAM.
-
-Options:
- -h, --help display this help and exit
- -v, --version output version information and exit
- --run try to run the given command, and emulate it if it fails
-
-Supported PROGRAM values:
- aclocal touch file \`aclocal.m4'
- autoconf touch file \`configure'
- autoheader touch file \`config.h.in'
- autom4te touch the output file, or create a stub one
- automake touch all \`Makefile.in' files
- bison create \`y.tab.[ch]', if possible, from existing .[ch]
- flex create \`lex.yy.c', if possible, from existing .c
- help2man touch the output file
- lex create \`lex.yy.c', if possible, from existing .c
- makeinfo touch the output file
- yacc create \`y.tab.[ch]', if possible, from existing .[ch]
-
-Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
-\`g' are ignored when checking the name.
-
-Send bug reports to <bu...@gnu.org>."
- exit $?
- ;;
-
- -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
- echo "missing $scriptversion (GNU Automake)"
- exit $?
- ;;
-
- -*)
- echo 1>&2 "$0: Unknown \`$1' option"
- echo 1>&2 "Try \`$0 --help' for more information"
- exit 1
- ;;
-
-esac
-
-# normalize program name to check for.
-program=`echo "$1" | sed '
- s/^gnu-//; t
- s/^gnu//; t
- s/^g//; t'`
-
-# Now exit if we have it, but it failed. Also exit now if we
-# don't have it and --version was passed (most likely to detect
-# the program). This is about non-GNU programs, so use $1 not
-# $program.
-case $1 in
- lex*|yacc*)
- # Not GNU programs, they don't have --version.
- ;;
-
- *)
- if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
- # We have it, but it failed.
- exit 1
- elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
- # Could not run --version or --help. This is probably someone
- # running `$TOOL --version' or `$TOOL --help' to check whether
- # $TOOL exists and not knowing $TOOL uses missing.
- exit 1
- fi
- ;;
-esac
-
-# If it does not exist, or fails to run (possibly an outdated version),
-# try to emulate it.
-case $program in
- aclocal*)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified \`acinclude.m4' or \`${configure_ac}'. You might want
- to install the \`Automake' and \`Perl' packages. Grab them from
- any GNU archive site."
- touch aclocal.m4
- ;;
-
- autoconf*)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified \`${configure_ac}'. You might want to install the
- \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
- archive site."
- touch configure
- ;;
-
- autoheader*)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified \`acconfig.h' or \`${configure_ac}'. You might want
- to install the \`Autoconf' and \`GNU m4' packages. Grab them
- from any GNU archive site."
- files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
- test -z "$files" && files="config.h"
- touch_files=
- for f in $files; do
- case $f in
- *:*) touch_files="$touch_files "`echo "$f" |
- sed -e 's/^[^:]*://' -e 's/:.*//'`;;
- *) touch_files="$touch_files $f.in";;
- esac
- done
- touch $touch_files
- ;;
-
- automake*)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
- You might want to install the \`Automake' and \`Perl' packages.
- Grab them from any GNU archive site."
- find . -type f -name Makefile.am -print |
- sed 's/\.am$/.in/' |
- while read f; do touch "$f"; done
- ;;
-
- autom4te*)
- echo 1>&2 "\
-WARNING: \`$1' is needed, but is $msg.
- You might have modified some files without having the
- proper tools for further handling them.
- You can get \`$1' as part of \`Autoconf' from any GNU
- archive site."
-
- file=`echo "$*" | sed -n "$sed_output"`
- test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
- if test -f "$file"; then
- touch $file
- else
- test -z "$file" || exec >$file
- echo "#! /bin/sh"
- echo "# Created by GNU Automake missing as a replacement of"
- echo "# $ $@"
- echo "exit 0"
- chmod +x $file
- exit 1
- fi
- ;;
-
- bison*|yacc*)
- echo 1>&2 "\
-WARNING: \`$1' $msg. You should only need it if
- you modified a \`.y' file. You may need the \`Bison' package
- in order for those modifications to take effect. You can get
- \`Bison' from any GNU archive site."
- rm -f y.tab.c y.tab.h
- if test $# -ne 1; then
- eval LASTARG=\${$#}
- case $LASTARG in
- *.y)
- SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
- if test -f "$SRCFILE"; then
- cp "$SRCFILE" y.tab.c
- fi
- SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
- if test -f "$SRCFILE"; then
- cp "$SRCFILE" y.tab.h
- fi
- ;;
- esac
- fi
- if test ! -f y.tab.h; then
- echo >y.tab.h
- fi
- if test ! -f y.tab.c; then
- echo 'main() { return 0; }' >y.tab.c
- fi
- ;;
-
- lex*|flex*)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified a \`.l' file. You may need the \`Flex' package
- in order for those modifications to take effect. You can get
- \`Flex' from any GNU archive site."
- rm -f lex.yy.c
- if test $# -ne 1; then
- eval LASTARG=\${$#}
- case $LASTARG in
- *.l)
- SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
- if test -f "$SRCFILE"; then
- cp "$SRCFILE" lex.yy.c
- fi
- ;;
- esac
- fi
- if test ! -f lex.yy.c; then
- echo 'main() { return 0; }' >lex.yy.c
- fi
- ;;
-
- help2man*)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified a dependency of a manual page. You may need the
- \`Help2man' package in order for those modifications to take
- effect. You can get \`Help2man' from any GNU archive site."
-
- file=`echo "$*" | sed -n "$sed_output"`
- test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
- if test -f "$file"; then
- touch $file
- else
- test -z "$file" || exec >$file
- echo ".ab help2man is required to generate this page"
- exit $?
- fi
- ;;
-
- makeinfo*)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified a \`.texi' or \`.texinfo' file, or any other file
- indirectly affecting the aspect of the manual. The spurious
- call might also be the consequence of using a buggy \`make' (AIX,
- DU, IRIX). You might want to install the \`Texinfo' package or
- the \`GNU make' package. Grab either from any GNU archive site."
- # The file to touch is that specified with -o ...
- file=`echo "$*" | sed -n "$sed_output"`
- test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
- if test -z "$file"; then
- # ... or it is the one specified with @setfilename ...
- infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
- file=`sed -n '
- /^@setfilename/{
- s/.* \([^ ]*\) *$/\1/
- p
- q
- }' $infile`
- # ... or it is derived from the source name (dir/f.texi becomes f.info)
- test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
- fi
- # If the file does not exist, the user really needs makeinfo;
- # let's fail without touching anything.
- test -f $file || exit 1
- touch $file
- ;;
-
- *)
- echo 1>&2 "\
-WARNING: \`$1' is needed, and is $msg.
- You might have modified some files without having the
- proper tools for further handling them. Check the \`README' file,
- it often tells you about the needed prerequisites for installing
- this package. You may also peek at any GNU archive site, in case
- some other package would contain this missing \`$1' program."
- exit 1
- ;;
-esac
-
-exit 0
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
-# time-stamp-end: "; # UTC"
-# End:
http://git-wip-us.apache.org/repos/asf/orc/blob/590245a0/c++/libs/snappy-1.1.2/snappy-c.cc
----------------------------------------------------------------------
diff --git a/c++/libs/snappy-1.1.2/snappy-c.cc b/c++/libs/snappy-1.1.2/snappy-c.cc
deleted file mode 100644
index 473a0b0..0000000
--- a/c++/libs/snappy-1.1.2/snappy-c.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2011 Martin Gieseking <ma...@uos.de>.
-//
-// 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 "snappy.h"
-#include "snappy-c.h"
-
-extern "C" {
-
-snappy_status snappy_compress(const char* input,
- size_t input_length,
- char* compressed,
- size_t *compressed_length) {
- if (*compressed_length < snappy_max_compressed_length(input_length)) {
- return SNAPPY_BUFFER_TOO_SMALL;
- }
- snappy::RawCompress(input, input_length, compressed, compressed_length);
- return SNAPPY_OK;
-}
-
-snappy_status snappy_uncompress(const char* compressed,
- size_t compressed_length,
- char* uncompressed,
- size_t* uncompressed_length) {
- size_t real_uncompressed_length;
- if (!snappy::GetUncompressedLength(compressed,
- compressed_length,
- &real_uncompressed_length)) {
- return SNAPPY_INVALID_INPUT;
- }
- if (*uncompressed_length < real_uncompressed_length) {
- return SNAPPY_BUFFER_TOO_SMALL;
- }
- if (!snappy::RawUncompress(compressed, compressed_length, uncompressed)) {
- return SNAPPY_INVALID_INPUT;
- }
- *uncompressed_length = real_uncompressed_length;
- return SNAPPY_OK;
-}
-
-size_t snappy_max_compressed_length(size_t source_length) {
- return snappy::MaxCompressedLength(source_length);
-}
-
-snappy_status snappy_uncompressed_length(const char *compressed,
- size_t compressed_length,
- size_t *result) {
- if (snappy::GetUncompressedLength(compressed,
- compressed_length,
- result)) {
- return SNAPPY_OK;
- } else {
- return SNAPPY_INVALID_INPUT;
- }
-}
-
-snappy_status snappy_validate_compressed_buffer(const char *compressed,
- size_t compressed_length) {
- if (snappy::IsValidCompressedBuffer(compressed, compressed_length)) {
- return SNAPPY_OK;
- } else {
- return SNAPPY_INVALID_INPUT;
- }
-}
-
-} // extern "C"
http://git-wip-us.apache.org/repos/asf/orc/blob/590245a0/c++/libs/snappy-1.1.2/snappy-c.h
----------------------------------------------------------------------
diff --git a/c++/libs/snappy-1.1.2/snappy-c.h b/c++/libs/snappy-1.1.2/snappy-c.h
deleted file mode 100644
index c6c2a86..0000000
--- a/c++/libs/snappy-1.1.2/snappy-c.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2011 Martin Gieseking <ma...@uos.de>.
- *
- * 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.
- *
- * Plain C interface (a wrapper around the C++ implementation).
- */
-
-#ifndef UTIL_SNAPPY_OPENSOURCE_SNAPPY_C_H_
-#define UTIL_SNAPPY_OPENSOURCE_SNAPPY_C_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stddef.h>
-
-/*
- * Return values; see the documentation for each function to know
- * what each can return.
- */
-typedef enum {
- SNAPPY_OK = 0,
- SNAPPY_INVALID_INPUT = 1,
- SNAPPY_BUFFER_TOO_SMALL = 2
-} snappy_status;
-
-/*
- * Takes the data stored in "input[0..input_length-1]" and stores
- * it in the array pointed to by "compressed".
- *
- * <compressed_length> signals the space available in "compressed".
- * If it is not at least equal to "snappy_max_compressed_length(input_length)",
- * SNAPPY_BUFFER_TOO_SMALL is returned. After successful compression,
- * <compressed_length> contains the true length of the compressed output,
- * and SNAPPY_OK is returned.
- *
- * Example:
- * size_t output_length = snappy_max_compressed_length(input_length);
- * char* output = (char*)malloc(output_length);
- * if (snappy_compress(input, input_length, output, &output_length)
- * == SNAPPY_OK) {
- * ... Process(output, output_length) ...
- * }
- * free(output);
- */
-snappy_status snappy_compress(const char* input,
- size_t input_length,
- char* compressed,
- size_t* compressed_length);
-
-/*
- * Given data in "compressed[0..compressed_length-1]" generated by
- * calling the snappy_compress routine, this routine stores
- * the uncompressed data to
- * uncompressed[0..uncompressed_length-1].
- * Returns failure (a value not equal to SNAPPY_OK) if the message
- * is corrupted and could not be decrypted.
- *
- * <uncompressed_length> signals the space available in "uncompressed".
- * If it is not at least equal to the value returned by
- * snappy_uncompressed_length for this stream, SNAPPY_BUFFER_TOO_SMALL
- * is returned. After successful decompression, <uncompressed_length>
- * contains the true length of the decompressed output.
- *
- * Example:
- * size_t output_length;
- * if (snappy_uncompressed_length(input, input_length, &output_length)
- * != SNAPPY_OK) {
- * ... fail ...
- * }
- * char* output = (char*)malloc(output_length);
- * if (snappy_uncompress(input, input_length, output, &output_length)
- * == SNAPPY_OK) {
- * ... Process(output, output_length) ...
- * }
- * free(output);
- */
-snappy_status snappy_uncompress(const char* compressed,
- size_t compressed_length,
- char* uncompressed,
- size_t* uncompressed_length);
-
-/*
- * Returns the maximal size of the compressed representation of
- * input data that is "source_length" bytes in length.
- */
-size_t snappy_max_compressed_length(size_t source_length);
-
-/*
- * REQUIRES: "compressed[]" was produced by snappy_compress()
- * Returns SNAPPY_OK and stores the length of the uncompressed data in
- * *result normally. Returns SNAPPY_INVALID_INPUT on parsing error.
- * This operation takes O(1) time.
- */
-snappy_status snappy_uncompressed_length(const char* compressed,
- size_t compressed_length,
- size_t* result);
-
-/*
- * Check if the contents of "compressed[]" can be uncompressed successfully.
- * Does not return the uncompressed data; if so, returns SNAPPY_OK,
- * or if not, returns SNAPPY_INVALID_INPUT.
- * Takes time proportional to compressed_length, but is usually at least a
- * factor of four faster than actual decompression.
- */
-snappy_status snappy_validate_compressed_buffer(const char* compressed,
- size_t compressed_length);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif /* UTIL_SNAPPY_OPENSOURCE_SNAPPY_C_H_ */
http://git-wip-us.apache.org/repos/asf/orc/blob/590245a0/c++/libs/snappy-1.1.2/snappy-internal.h
----------------------------------------------------------------------
diff --git a/c++/libs/snappy-1.1.2/snappy-internal.h b/c++/libs/snappy-1.1.2/snappy-internal.h
deleted file mode 100644
index c99d331..0000000
--- a/c++/libs/snappy-1.1.2/snappy-internal.h
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright 2008 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.
-//
-// Internals shared between the Snappy implementation and its unittest.
-
-#ifndef UTIL_SNAPPY_SNAPPY_INTERNAL_H_
-#define UTIL_SNAPPY_SNAPPY_INTERNAL_H_
-
-#include "snappy-stubs-internal.h"
-
-namespace snappy {
-namespace internal {
-
-class WorkingMemory {
- public:
- WorkingMemory() : large_table_(NULL) { }
- ~WorkingMemory() { delete[] large_table_; }
-
- // Allocates and clears a hash table using memory in "*this",
- // stores the number of buckets in "*table_size" and returns a pointer to
- // the base of the hash table.
- uint16* GetHashTable(size_t input_size, int* table_size);
-
- private:
- uint16 small_table_[1<<10]; // 2KB
- uint16* large_table_; // Allocated only when needed
-
- DISALLOW_COPY_AND_ASSIGN(WorkingMemory);
-};
-
-// Flat array compression that does not emit the "uncompressed length"
-// prefix. Compresses "input" string to the "*op" buffer.
-//
-// REQUIRES: "input_length <= kBlockSize"
-// REQUIRES: "op" points to an array of memory that is at least
-// "MaxCompressedLength(input_length)" in size.
-// REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero.
-// REQUIRES: "table_size" is a power of two
-//
-// Returns an "end" pointer into "op" buffer.
-// "end - op" is the compressed size of "input".
-char* CompressFragment(const char* input,
- size_t input_length,
- char* op,
- uint16* table,
- const int table_size);
-
-// Return the largest n such that
-//
-// s1[0,n-1] == s2[0,n-1]
-// and n <= (s2_limit - s2).
-//
-// Does not read *s2_limit or beyond.
-// Does not read *(s1 + (s2_limit - s2)) or beyond.
-// Requires that s2_limit >= s2.
-//
-// Separate implementation for x86_64, for speed. Uses the fact that
-// x86_64 is little endian.
-#if defined(ARCH_K8)
-static inline int FindMatchLength(const char* s1,
- const char* s2,
- const char* s2_limit) {
- assert(s2_limit >= s2);
- int matched = 0;
-
- // Find out how long the match is. We loop over the data 64 bits at a
- // time until we find a 64-bit block that doesn't match; then we find
- // the first non-matching bit and use that to calculate the total
- // length of the match.
- while (PREDICT_TRUE(s2 <= s2_limit - 8)) {
- if (PREDICT_FALSE(UNALIGNED_LOAD64(s2) == UNALIGNED_LOAD64(s1 + matched))) {
- s2 += 8;
- matched += 8;
- } else {
- // On current (mid-2008) Opteron models there is a 3% more
- // efficient code sequence to find the first non-matching byte.
- // However, what follows is ~10% better on Intel Core 2 and newer,
- // and we expect AMD's bsf instruction to improve.
- uint64 x = UNALIGNED_LOAD64(s2) ^ UNALIGNED_LOAD64(s1 + matched);
- int matching_bits = Bits::FindLSBSetNonZero64(x);
- matched += matching_bits >> 3;
- return matched;
- }
- }
- while (PREDICT_TRUE(s2 < s2_limit)) {
- if (PREDICT_TRUE(s1[matched] == *s2)) {
- ++s2;
- ++matched;
- } else {
- return matched;
- }
- }
- return matched;
-}
-#else
-static inline int FindMatchLength(const char* s1,
- const char* s2,
- const char* s2_limit) {
- // Implementation based on the x86-64 version, above.
- assert(s2_limit >= s2);
- int matched = 0;
-
- while (s2 <= s2_limit - 4 &&
- UNALIGNED_LOAD32(s2) == UNALIGNED_LOAD32(s1 + matched)) {
- s2 += 4;
- matched += 4;
- }
- if (LittleEndian::IsLittleEndian() && s2 <= s2_limit - 4) {
- uint32 x = UNALIGNED_LOAD32(s2) ^ UNALIGNED_LOAD32(s1 + matched);
- int matching_bits = Bits::FindLSBSetNonZero(x);
- matched += matching_bits >> 3;
- } else {
- while ((s2 < s2_limit) && (s1[matched] == *s2)) {
- ++s2;
- ++matched;
- }
- }
- return matched;
-}
-#endif
-
-} // end namespace internal
-} // end namespace snappy
-
-#endif // UTIL_SNAPPY_SNAPPY_INTERNAL_H_
http://git-wip-us.apache.org/repos/asf/orc/blob/590245a0/c++/libs/snappy-1.1.2/snappy-sinksource.cc
----------------------------------------------------------------------
diff --git a/c++/libs/snappy-1.1.2/snappy-sinksource.cc b/c++/libs/snappy-1.1.2/snappy-sinksource.cc
deleted file mode 100644
index 5844552..0000000
--- a/c++/libs/snappy-1.1.2/snappy-sinksource.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2011 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 <string.h>
-
-#include "snappy-sinksource.h"
-
-namespace snappy {
-
-Source::~Source() { }
-
-Sink::~Sink() { }
-
-char* Sink::GetAppendBuffer(size_t length, char* scratch) {
- return scratch;
-}
-
-ByteArraySource::~ByteArraySource() { }
-
-size_t ByteArraySource::Available() const { return left_; }
-
-const char* ByteArraySource::Peek(size_t* len) {
- *len = left_;
- return ptr_;
-}
-
-void ByteArraySource::Skip(size_t n) {
- left_ -= n;
- ptr_ += n;
-}
-
-UncheckedByteArraySink::~UncheckedByteArraySink() { }
-
-void UncheckedByteArraySink::Append(const char* data, size_t n) {
- // Do no copying if the caller filled in the result of GetAppendBuffer()
- if (data != dest_) {
- memcpy(dest_, data, n);
- }
- dest_ += n;
-}
-
-char* UncheckedByteArraySink::GetAppendBuffer(size_t len, char* scratch) {
- return dest_;
-}
-
-}
http://git-wip-us.apache.org/repos/asf/orc/blob/590245a0/c++/libs/snappy-1.1.2/snappy-sinksource.h
----------------------------------------------------------------------
diff --git a/c++/libs/snappy-1.1.2/snappy-sinksource.h b/c++/libs/snappy-1.1.2/snappy-sinksource.h
deleted file mode 100644
index faabfa1..0000000
--- a/c++/libs/snappy-1.1.2/snappy-sinksource.h
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright 2011 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.
-
-#ifndef UTIL_SNAPPY_SNAPPY_SINKSOURCE_H_
-#define UTIL_SNAPPY_SNAPPY_SINKSOURCE_H_
-
-#include <stddef.h>
-
-
-namespace snappy {
-
-// A Sink is an interface that consumes a sequence of bytes.
-class Sink {
- public:
- Sink() { }
- virtual ~Sink();
-
- // Append "bytes[0,n-1]" to this.
- virtual void Append(const char* bytes, size_t n) = 0;
-
- // Returns a writable buffer of the specified length for appending.
- // May return a pointer to the caller-owned scratch buffer which
- // must have at least the indicated length. The returned buffer is
- // only valid until the next operation on this Sink.
- //
- // After writing at most "length" bytes, call Append() with the
- // pointer returned from this function and the number of bytes
- // written. Many Append() implementations will avoid copying
- // bytes if this function returned an internal buffer.
- //
- // If a non-scratch buffer is returned, the caller may only pass a
- // prefix of it to Append(). That is, it is not correct to pass an
- // interior pointer of the returned array to Append().
- //
- // The default implementation always returns the scratch buffer.
- virtual char* GetAppendBuffer(size_t length, char* scratch);
-
-
- private:
- // No copying
- Sink(const Sink&);
- void operator=(const Sink&);
-};
-
-// A Source is an interface that yields a sequence of bytes
-class Source {
- public:
- Source() { }
- virtual ~Source();
-
- // Return the number of bytes left to read from the source
- virtual size_t Available() const = 0;
-
- // Peek at the next flat region of the source. Does not reposition
- // the source. The returned region is empty iff Available()==0.
- //
- // Returns a pointer to the beginning of the region and store its
- // length in *len.
- //
- // The returned region is valid until the next call to Skip() or
- // until this object is destroyed, whichever occurs first.
- //
- // The returned region may be larger than Available() (for example
- // if this ByteSource is a view on a substring of a larger source).
- // The caller is responsible for ensuring that it only reads the
- // Available() bytes.
- virtual const char* Peek(size_t* len) = 0;
-
- // Skip the next n bytes. Invalidates any buffer returned by
- // a previous call to Peek().
- // REQUIRES: Available() >= n
- virtual void Skip(size_t n) = 0;
-
- private:
- // No copying
- Source(const Source&);
- void operator=(const Source&);
-};
-
-// A Source implementation that yields the contents of a flat array
-class ByteArraySource : public Source {
- public:
- ByteArraySource(const char* p, size_t n) : ptr_(p), left_(n) { }
- virtual ~ByteArraySource();
- virtual size_t Available() const;
- virtual const char* Peek(size_t* len);
- virtual void Skip(size_t n);
- private:
- const char* ptr_;
- size_t left_;
-};
-
-// A Sink implementation that writes to a flat array without any bound checks.
-class UncheckedByteArraySink : public Sink {
- public:
- explicit UncheckedByteArraySink(char* dest) : dest_(dest) { }
- virtual ~UncheckedByteArraySink();
- virtual void Append(const char* data, size_t n);
- virtual char* GetAppendBuffer(size_t len, char* scratch);
-
- // Return the current output pointer so that a caller can see how
- // many bytes were produced.
- // Note: this is not a Sink method.
- char* CurrentDestination() const { return dest_; }
- private:
- char* dest_;
-};
-
-
-}
-
-#endif // UTIL_SNAPPY_SNAPPY_SINKSOURCE_H_
http://git-wip-us.apache.org/repos/asf/orc/blob/590245a0/c++/libs/snappy-1.1.2/snappy-stubs-internal.cc
----------------------------------------------------------------------
diff --git a/c++/libs/snappy-1.1.2/snappy-stubs-internal.cc b/c++/libs/snappy-1.1.2/snappy-stubs-internal.cc
deleted file mode 100644
index 6ed3343..0000000
--- a/c++/libs/snappy-1.1.2/snappy-stubs-internal.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2011 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 <algorithm>
-#include <string>
-
-#include "snappy-stubs-internal.h"
-
-namespace snappy {
-
-void Varint::Append32(string* s, uint32 value) {
- char buf[Varint::kMax32];
- const char* p = Varint::Encode32(buf, value);
- s->append(buf, p - buf);
-}
-
-} // namespace snappy
http://git-wip-us.apache.org/repos/asf/orc/blob/590245a0/c++/libs/snappy-1.1.2/snappy-stubs-internal.h
----------------------------------------------------------------------
diff --git a/c++/libs/snappy-1.1.2/snappy-stubs-internal.h b/c++/libs/snappy-1.1.2/snappy-stubs-internal.h
deleted file mode 100644
index 12393b6..0000000
--- a/c++/libs/snappy-1.1.2/snappy-stubs-internal.h
+++ /dev/null
@@ -1,491 +0,0 @@
-// Copyright 2011 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.
-//
-// Various stubs for the open-source version of Snappy.
-
-#ifndef UTIL_SNAPPY_OPENSOURCE_SNAPPY_STUBS_INTERNAL_H_
-#define UTIL_SNAPPY_OPENSOURCE_SNAPPY_STUBS_INTERNAL_H_
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string>
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-#endif
-
-#include "snappy-stubs-public.h"
-
-#if defined(__x86_64__)
-
-// Enable 64-bit optimized versions of some routines.
-#define ARCH_K8 1
-
-#endif
-
-// Needed by OS X, among others.
-#ifndef MAP_ANONYMOUS
-#define MAP_ANONYMOUS MAP_ANON
-#endif
-
-// Pull in std::min, std::ostream, and the likes. This is safe because this
-// header file is never used from any public header files.
-using namespace std;
-
-// The size of an array, if known at compile-time.
-// Will give unexpected results if used on a pointer.
-// We undefine it first, since some compilers already have a definition.
-#ifdef ARRAYSIZE
-#undef ARRAYSIZE
-#endif
-#define ARRAYSIZE(a) (sizeof(a) / sizeof(*(a)))
-
-// Static prediction hints.
-#ifdef HAVE_BUILTIN_EXPECT
-#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
-#define PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
-#else
-#define PREDICT_FALSE(x) x
-#define PREDICT_TRUE(x) x
-#endif
-
-// This is only used for recomputing the tag byte table used during
-// decompression; for simplicity we just remove it from the open-source
-// version (anyone who wants to regenerate it can just do the call
-// themselves within main()).
-#define DEFINE_bool(flag_name, default_value, description) \
- bool FLAGS_ ## flag_name = default_value
-#define DECLARE_bool(flag_name) \
- extern bool FLAGS_ ## flag_name
-
-namespace snappy {
-
-static const uint32 kuint32max = static_cast<uint32>(0xFFFFFFFF);
-static const int64 kint64max = static_cast<int64>(0x7FFFFFFFFFFFFFFFLL);
-
-// Potentially unaligned loads and stores.
-
-// x86 and PowerPC can simply do these loads and stores native.
-
-#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__)
-
-#define UNALIGNED_LOAD16(_p) (*reinterpret_cast<const uint16 *>(_p))
-#define UNALIGNED_LOAD32(_p) (*reinterpret_cast<const uint32 *>(_p))
-#define UNALIGNED_LOAD64(_p) (*reinterpret_cast<const uint64 *>(_p))
-
-#define UNALIGNED_STORE16(_p, _val) (*reinterpret_cast<uint16 *>(_p) = (_val))
-#define UNALIGNED_STORE32(_p, _val) (*reinterpret_cast<uint32 *>(_p) = (_val))
-#define UNALIGNED_STORE64(_p, _val) (*reinterpret_cast<uint64 *>(_p) = (_val))
-
-// ARMv7 and newer support native unaligned accesses, but only of 16-bit
-// and 32-bit values (not 64-bit); older versions either raise a fatal signal,
-// do an unaligned read and rotate the words around a bit, or do the reads very
-// slowly (trip through kernel mode). There's no simple #define that says just
-// “ARMv7 or higher”, so we have to filter away all ARMv5 and ARMv6
-// sub-architectures.
-//
-// This is a mess, but there's not much we can do about it.
-
-#elif defined(__arm__) && \
- !defined(__ARM_ARCH_4__) && \
- !defined(__ARM_ARCH_4T__) && \
- !defined(__ARM_ARCH_5__) && \
- !defined(__ARM_ARCH_5T__) && \
- !defined(__ARM_ARCH_5TE__) && \
- !defined(__ARM_ARCH_5TEJ__) && \
- !defined(__ARM_ARCH_6__) && \
- !defined(__ARM_ARCH_6J__) && \
- !defined(__ARM_ARCH_6K__) && \
- !defined(__ARM_ARCH_6Z__) && \
- !defined(__ARM_ARCH_6ZK__) && \
- !defined(__ARM_ARCH_6T2__)
-
-#define UNALIGNED_LOAD16(_p) (*reinterpret_cast<const uint16 *>(_p))
-#define UNALIGNED_LOAD32(_p) (*reinterpret_cast<const uint32 *>(_p))
-
-#define UNALIGNED_STORE16(_p, _val) (*reinterpret_cast<uint16 *>(_p) = (_val))
-#define UNALIGNED_STORE32(_p, _val) (*reinterpret_cast<uint32 *>(_p) = (_val))
-
-// TODO(user): NEON supports unaligned 64-bit loads and stores.
-// See if that would be more efficient on platforms supporting it,
-// at least for copies.
-
-inline uint64 UNALIGNED_LOAD64(const void *p) {
- uint64 t;
- memcpy(&t, p, sizeof t);
- return t;
-}
-
-inline void UNALIGNED_STORE64(void *p, uint64 v) {
- memcpy(p, &v, sizeof v);
-}
-
-#else
-
-// These functions are provided for architectures that don't support
-// unaligned loads and stores.
-
-inline uint16 UNALIGNED_LOAD16(const void *p) {
- uint16 t;
- memcpy(&t, p, sizeof t);
- return t;
-}
-
-inline uint32 UNALIGNED_LOAD32(const void *p) {
- uint32 t;
- memcpy(&t, p, sizeof t);
- return t;
-}
-
-inline uint64 UNALIGNED_LOAD64(const void *p) {
- uint64 t;
- memcpy(&t, p, sizeof t);
- return t;
-}
-
-inline void UNALIGNED_STORE16(void *p, uint16 v) {
- memcpy(p, &v, sizeof v);
-}
-
-inline void UNALIGNED_STORE32(void *p, uint32 v) {
- memcpy(p, &v, sizeof v);
-}
-
-inline void UNALIGNED_STORE64(void *p, uint64 v) {
- memcpy(p, &v, sizeof v);
-}
-
-#endif
-
-// This can be more efficient than UNALIGNED_LOAD64 + UNALIGNED_STORE64
-// on some platforms, in particular ARM.
-inline void UnalignedCopy64(const void *src, void *dst) {
- if (sizeof(void *) == 8) {
- UNALIGNED_STORE64(dst, UNALIGNED_LOAD64(src));
- } else {
- const char *src_char = reinterpret_cast<const char *>(src);
- char *dst_char = reinterpret_cast<char *>(dst);
-
- UNALIGNED_STORE32(dst_char, UNALIGNED_LOAD32(src_char));
- UNALIGNED_STORE32(dst_char + 4, UNALIGNED_LOAD32(src_char + 4));
- }
-}
-
-// The following guarantees declaration of the byte swap functions.
-#ifdef WORDS_BIGENDIAN
-
-#ifdef HAVE_SYS_BYTEORDER_H
-#include <sys/byteorder.h>
-#endif
-
-#ifdef HAVE_SYS_ENDIAN_H
-#include <sys/endian.h>
-#endif
-
-#ifdef _MSC_VER
-#include <stdlib.h>
-#define bswap_16(x) _byteswap_ushort(x)
-#define bswap_32(x) _byteswap_ulong(x)
-#define bswap_64(x) _byteswap_uint64(x)
-
-#elif defined(__APPLE__)
-// Mac OS X / Darwin features
-#include <libkern/OSByteOrder.h>
-#define bswap_16(x) OSSwapInt16(x)
-#define bswap_32(x) OSSwapInt32(x)
-#define bswap_64(x) OSSwapInt64(x)
-
-#elif defined(HAVE_BYTESWAP_H)
-#include <byteswap.h>
-
-#elif defined(bswap32)
-// FreeBSD defines bswap{16,32,64} in <sys/endian.h> (already #included).
-#define bswap_16(x) bswap16(x)
-#define bswap_32(x) bswap32(x)
-#define bswap_64(x) bswap64(x)
-
-#elif defined(BSWAP_64)
-// Solaris 10 defines BSWAP_{16,32,64} in <sys/byteorder.h> (already #included).
-#define bswap_16(x) BSWAP_16(x)
-#define bswap_32(x) BSWAP_32(x)
-#define bswap_64(x) BSWAP_64(x)
-
-#else
-
-inline uint16 bswap_16(uint16 x) {
- return (x << 8) | (x >> 8);
-}
-
-inline uint32 bswap_32(uint32 x) {
- x = ((x & 0xff00ff00UL) >> 8) | ((x & 0x00ff00ffUL) << 8);
- return (x >> 16) | (x << 16);
-}
-
-inline uint64 bswap_64(uint64 x) {
- x = ((x & 0xff00ff00ff00ff00ULL) >> 8) | ((x & 0x00ff00ff00ff00ffULL) << 8);
- x = ((x & 0xffff0000ffff0000ULL) >> 16) | ((x & 0x0000ffff0000ffffULL) << 16);
- return (x >> 32) | (x << 32);
-}
-
-#endif
-
-#endif // WORDS_BIGENDIAN
-
-// Convert to little-endian storage, opposite of network format.
-// Convert x from host to little endian: x = LittleEndian.FromHost(x);
-// convert x from little endian to host: x = LittleEndian.ToHost(x);
-//
-// Store values into unaligned memory converting to little endian order:
-// LittleEndian.Store16(p, x);
-//
-// Load unaligned values stored in little endian converting to host order:
-// x = LittleEndian.Load16(p);
-class LittleEndian {
- public:
- // Conversion functions.
-#ifdef WORDS_BIGENDIAN
-
- static uint16 FromHost16(uint16 x) { return bswap_16(x); }
- static uint16 ToHost16(uint16 x) { return bswap_16(x); }
-
- static uint32 FromHost32(uint32 x) { return bswap_32(x); }
- static uint32 ToHost32(uint32 x) { return bswap_32(x); }
-
- static bool IsLittleEndian() { return false; }
-
-#else // !defined(WORDS_BIGENDIAN)
-
- static uint16 FromHost16(uint16 x) { return x; }
- static uint16 ToHost16(uint16 x) { return x; }
-
- static uint32 FromHost32(uint32 x) { return x; }
- static uint32 ToHost32(uint32 x) { return x; }
-
- static bool IsLittleEndian() { return true; }
-
-#endif // !defined(WORDS_BIGENDIAN)
-
- // Functions to do unaligned loads and stores in little-endian order.
- static uint16 Load16(const void *p) {
- return ToHost16(UNALIGNED_LOAD16(p));
- }
-
- static void Store16(void *p, uint16 v) {
- UNALIGNED_STORE16(p, FromHost16(v));
- }
-
- static uint32 Load32(const void *p) {
- return ToHost32(UNALIGNED_LOAD32(p));
- }
-
- static void Store32(void *p, uint32 v) {
- UNALIGNED_STORE32(p, FromHost32(v));
- }
-};
-
-// Some bit-manipulation functions.
-class Bits {
- public:
- // Return floor(log2(n)) for positive integer n. Returns -1 iff n == 0.
- static int Log2Floor(uint32 n);
-
- // Return the first set least / most significant bit, 0-indexed. Returns an
- // undefined value if n == 0. FindLSBSetNonZero() is similar to ffs() except
- // that it's 0-indexed.
- static int FindLSBSetNonZero(uint32 n);
- static int FindLSBSetNonZero64(uint64 n);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Bits);
-};
-
-#ifdef HAVE_BUILTIN_CTZ
-
-inline int Bits::Log2Floor(uint32 n) {
- return n == 0 ? -1 : 31 ^ __builtin_clz(n);
-}
-
-inline int Bits::FindLSBSetNonZero(uint32 n) {
- return __builtin_ctz(n);
-}
-
-inline int Bits::FindLSBSetNonZero64(uint64 n) {
- return __builtin_ctzll(n);
-}
-
-#else // Portable versions.
-
-inline int Bits::Log2Floor(uint32 n) {
- if (n == 0)
- return -1;
- int log = 0;
- uint32 value = n;
- for (int i = 4; i >= 0; --i) {
- int shift = (1 << i);
- uint32 x = value >> shift;
- if (x != 0) {
- value = x;
- log += shift;
- }
- }
- assert(value == 1);
- return log;
-}
-
-inline int Bits::FindLSBSetNonZero(uint32 n) {
- int rc = 31;
- for (int i = 4, shift = 1 << 4; i >= 0; --i) {
- const uint32 x = n << shift;
- if (x != 0) {
- n = x;
- rc -= shift;
- }
- shift >>= 1;
- }
- return rc;
-}
-
-// FindLSBSetNonZero64() is defined in terms of FindLSBSetNonZero().
-inline int Bits::FindLSBSetNonZero64(uint64 n) {
- const uint32 bottombits = static_cast<uint32>(n);
- if (bottombits == 0) {
- // Bottom bits are zero, so scan in top bits
- return 32 + FindLSBSetNonZero(static_cast<uint32>(n >> 32));
- } else {
- return FindLSBSetNonZero(bottombits);
- }
-}
-
-#endif // End portable versions.
-
-// Variable-length integer encoding.
-class Varint {
- public:
- // Maximum lengths of varint encoding of uint32.
- static const int kMax32 = 5;
-
- // Attempts to parse a varint32 from a prefix of the bytes in [ptr,limit-1].
- // Never reads a character at or beyond limit. If a valid/terminated varint32
- // was found in the range, stores it in *OUTPUT and returns a pointer just
- // past the last byte of the varint32. Else returns NULL. On success,
- // "result <= limit".
- static const char* Parse32WithLimit(const char* ptr, const char* limit,
- uint32* OUTPUT);
-
- // REQUIRES "ptr" points to a buffer of length sufficient to hold "v".
- // EFFECTS Encodes "v" into "ptr" and returns a pointer to the
- // byte just past the last encoded byte.
- static char* Encode32(char* ptr, uint32 v);
-
- // EFFECTS Appends the varint representation of "value" to "*s".
- static void Append32(string* s, uint32 value);
-};
-
-inline const char* Varint::Parse32WithLimit(const char* p,
- const char* l,
- uint32* OUTPUT) {
- const unsigned char* ptr = reinterpret_cast<const unsigned char*>(p);
- const unsigned char* limit = reinterpret_cast<const unsigned char*>(l);
- uint32 b, result;
- if (ptr >= limit) return NULL;
- b = *(ptr++); result = b & 127; if (b < 128) goto done;
- if (ptr >= limit) return NULL;
- b = *(ptr++); result |= (b & 127) << 7; if (b < 128) goto done;
- if (ptr >= limit) return NULL;
- b = *(ptr++); result |= (b & 127) << 14; if (b < 128) goto done;
- if (ptr >= limit) return NULL;
- b = *(ptr++); result |= (b & 127) << 21; if (b < 128) goto done;
- if (ptr >= limit) return NULL;
- b = *(ptr++); result |= (b & 127) << 28; if (b < 16) goto done;
- return NULL; // Value is too long to be a varint32
- done:
- *OUTPUT = result;
- return reinterpret_cast<const char*>(ptr);
-}
-
-inline char* Varint::Encode32(char* sptr, uint32 v) {
- // Operate on characters as unsigneds
- unsigned char* ptr = reinterpret_cast<unsigned char*>(sptr);
- static const int B = 128;
- if (v < (1<<7)) {
- *(ptr++) = v;
- } else if (v < (1<<14)) {
- *(ptr++) = v | B;
- *(ptr++) = v>>7;
- } else if (v < (1<<21)) {
- *(ptr++) = v | B;
- *(ptr++) = (v>>7) | B;
- *(ptr++) = v>>14;
- } else if (v < (1<<28)) {
- *(ptr++) = v | B;
- *(ptr++) = (v>>7) | B;
- *(ptr++) = (v>>14) | B;
- *(ptr++) = v>>21;
- } else {
- *(ptr++) = v | B;
- *(ptr++) = (v>>7) | B;
- *(ptr++) = (v>>14) | B;
- *(ptr++) = (v>>21) | B;
- *(ptr++) = v>>28;
- }
- return reinterpret_cast<char*>(ptr);
-}
-
-// If you know the internal layout of the std::string in use, you can
-// replace this function with one that resizes the string without
-// filling the new space with zeros (if applicable) --
-// it will be non-portable but faster.
-inline void STLStringResizeUninitialized(string* s, size_t new_size) {
- s->resize(new_size);
-}
-
-// Return a mutable char* pointing to a string's internal buffer,
-// which may not be null-terminated. Writing through this pointer will
-// modify the string.
-//
-// string_as_array(&str)[i] is valid for 0 <= i < str.size() until the
-// next call to a string method that invalidates iterators.
-//
-// As of 2006-04, there is no standard-blessed way of getting a
-// mutable reference to a string's internal buffer. However, issue 530
-// (http://www.open-std.org/JTC1/SC22/WG21/docs/lwg-defects.html#530)
-// proposes this as the method. It will officially be part of the standard
-// for C++0x. This should already work on all current implementations.
-inline char* string_as_array(string* str) {
- return str->empty() ? NULL : &*str->begin();
-}
-
-} // namespace snappy
-
-#endif // UTIL_SNAPPY_OPENSOURCE_SNAPPY_STUBS_INTERNAL_H_
http://git-wip-us.apache.org/repos/asf/orc/blob/590245a0/c++/libs/snappy-1.1.2/snappy-stubs-public.h
----------------------------------------------------------------------
diff --git a/c++/libs/snappy-1.1.2/snappy-stubs-public.h b/c++/libs/snappy-1.1.2/snappy-stubs-public.h
deleted file mode 100644
index 6b41bbe..0000000
--- a/c++/libs/snappy-1.1.2/snappy-stubs-public.h
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-// Author: sesse@google.com (Steinar H. Gunderson)
-//
-// 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.
-//
-// Various type stubs for the open-source version of Snappy.
-//
-// This file cannot include config.h, as it is included from snappy.h,
-// which is a public header. Instead, snappy-stubs-public.h is generated by
-// from snappy-stubs-public.h.in at configure time.
-
-#ifndef UTIL_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
-#define UTIL_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
-
-#if 1
-#include <stdint.h>
-#endif
-
-#if 1
-#include <stddef.h>
-#endif
-
-#if 0
-#include <sys/uio.h>
-#endif
-
-#define SNAPPY_MAJOR 1
-#define SNAPPY_MINOR 1
-#define SNAPPY_PATCHLEVEL 2
-#define SNAPPY_VERSION \
- ((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL)
-
-#include <string>
-
-namespace snappy {
-
-#if 1
-typedef int8_t int8;
-typedef uint8_t uint8;
-typedef int16_t int16;
-typedef uint16_t uint16;
-typedef int32_t int32;
-typedef uint32_t uint32;
-typedef int64_t int64;
-typedef uint64_t uint64;
-#else
-typedef signed char int8;
-typedef unsigned char uint8;
-typedef short int16;
-typedef unsigned short uint16;
-typedef int int32;
-typedef unsigned int uint32;
-typedef long long int64;
-typedef unsigned long long uint64;
-#endif
-
-typedef std::string string;
-
-#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
- TypeName(const TypeName&); \
- void operator=(const TypeName&)
-
-#if !0
-// Windows does not have an iovec type, yet the concept is universally useful.
-// It is simple to define it ourselves, so we put it inside our own namespace.
-struct iovec {
- void* iov_base;
- size_t iov_len;
-};
-#endif
-
-} // namespace snappy
-
-#endif // UTIL_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
http://git-wip-us.apache.org/repos/asf/orc/blob/590245a0/c++/libs/snappy-1.1.2/snappy-stubs-public.h.in
----------------------------------------------------------------------
diff --git a/c++/libs/snappy-1.1.2/snappy-stubs-public.h.in b/c++/libs/snappy-1.1.2/snappy-stubs-public.h.in
deleted file mode 100644
index 6c181a1..0000000
--- a/c++/libs/snappy-1.1.2/snappy-stubs-public.h.in
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-// Author: sesse@google.com (Steinar H. Gunderson)
-//
-// 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.
-//
-// Various type stubs for the open-source version of Snappy.
-//
-// This file cannot include config.h, as it is included from snappy.h,
-// which is a public header. Instead, snappy-stubs-public.h is generated by
-// from snappy-stubs-public.h.in at configure time.
-
-#ifndef UTIL_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
-#define UTIL_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
-
-#if @ac_cv_have_stdint_h@
-#include <stdint.h>
-#endif
-
-#if @ac_cv_have_stddef_h@
-#include <stddef.h>
-#endif
-
-#if @ac_cv_have_sys_uio_h@
-#include <sys/uio.h>
-#endif
-
-#define SNAPPY_MAJOR @SNAPPY_MAJOR@
-#define SNAPPY_MINOR @SNAPPY_MINOR@
-#define SNAPPY_PATCHLEVEL @SNAPPY_PATCHLEVEL@
-#define SNAPPY_VERSION \
- ((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL)
-
-#include <string>
-
-namespace snappy {
-
-#if @ac_cv_have_stdint_h@
-typedef int8_t int8;
-typedef uint8_t uint8;
-typedef int16_t int16;
-typedef uint16_t uint16;
-typedef int32_t int32;
-typedef uint32_t uint32;
-typedef int64_t int64;
-typedef uint64_t uint64;
-#else
-typedef signed char int8;
-typedef unsigned char uint8;
-typedef short int16;
-typedef unsigned short uint16;
-typedef int int32;
-typedef unsigned int uint32;
-typedef long long int64;
-typedef unsigned long long uint64;
-#endif
-
-typedef std::string string;
-
-#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
- TypeName(const TypeName&); \
- void operator=(const TypeName&)
-
-#if !@ac_cv_have_sys_uio_h@
-// Windows does not have an iovec type, yet the concept is universally useful.
-// It is simple to define it ourselves, so we put it inside our own namespace.
-struct iovec {
- void* iov_base;
- size_t iov_len;
-};
-#endif
-
-} // namespace snappy
-
-#endif // UTIL_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
http://git-wip-us.apache.org/repos/asf/orc/blob/590245a0/c++/libs/snappy-1.1.2/snappy-test.cc
----------------------------------------------------------------------
diff --git a/c++/libs/snappy-1.1.2/snappy-test.cc b/c++/libs/snappy-1.1.2/snappy-test.cc
deleted file mode 100644
index 4619410..0000000
--- a/c++/libs/snappy-1.1.2/snappy-test.cc
+++ /dev/null
@@ -1,606 +0,0 @@
-// Copyright 2011 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.
-//
-// Various stubs for the unit tests for the open-source version of Snappy.
-
-#include "snappy-test.h"
-
-#ifdef HAVE_WINDOWS_H
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#endif
-
-#include <algorithm>
-
-DEFINE_bool(run_microbenchmarks, true,
- "Run microbenchmarks before doing anything else.");
-
-namespace snappy {
-
-string ReadTestDataFile(const string& base, size_t size_limit) {
- string contents;
- const char* srcdir = getenv("srcdir"); // This is set by Automake.
- string prefix;
- if (srcdir) {
- prefix = string(srcdir) + "/";
- }
- file::GetContents(prefix + "testdata/" + base, &contents, file::Defaults()
- ).CheckSuccess();
- if (size_limit > 0) {
- contents = contents.substr(0, size_limit);
- }
- return contents;
-}
-
-string ReadTestDataFile(const string& base) {
- return ReadTestDataFile(base, 0);
-}
-
-string StringPrintf(const char* format, ...) {
- char buf[4096];
- va_list ap;
- va_start(ap, format);
- vsnprintf(buf, sizeof(buf), format, ap);
- va_end(ap);
- return buf;
-}
-
-bool benchmark_running = false;
-int64 benchmark_real_time_us = 0;
-int64 benchmark_cpu_time_us = 0;
-string *benchmark_label = NULL;
-int64 benchmark_bytes_processed = 0;
-
-void ResetBenchmarkTiming() {
- benchmark_real_time_us = 0;
- benchmark_cpu_time_us = 0;
-}
-
-#ifdef WIN32
-LARGE_INTEGER benchmark_start_real;
-FILETIME benchmark_start_cpu;
-#else // WIN32
-struct timeval benchmark_start_real;
-struct rusage benchmark_start_cpu;
-#endif // WIN32
-
-void StartBenchmarkTiming() {
-#ifdef WIN32
- QueryPerformanceCounter(&benchmark_start_real);
- FILETIME dummy;
- CHECK(GetProcessTimes(
- GetCurrentProcess(), &dummy, &dummy, &dummy, &benchmark_start_cpu));
-#else
- gettimeofday(&benchmark_start_real, NULL);
- if (getrusage(RUSAGE_SELF, &benchmark_start_cpu) == -1) {
- perror("getrusage(RUSAGE_SELF)");
- exit(1);
- }
-#endif
- benchmark_running = true;
-}
-
-void StopBenchmarkTiming() {
- if (!benchmark_running) {
- return;
- }
-
-#ifdef WIN32
- LARGE_INTEGER benchmark_stop_real;
- LARGE_INTEGER benchmark_frequency;
- QueryPerformanceCounter(&benchmark_stop_real);
- QueryPerformanceFrequency(&benchmark_frequency);
-
- double elapsed_real = static_cast<double>(
- benchmark_stop_real.QuadPart - benchmark_start_real.QuadPart) /
- benchmark_frequency.QuadPart;
- benchmark_real_time_us += elapsed_real * 1e6 + 0.5;
-
- FILETIME benchmark_stop_cpu, dummy;
- CHECK(GetProcessTimes(
- GetCurrentProcess(), &dummy, &dummy, &dummy, &benchmark_stop_cpu));
-
- ULARGE_INTEGER start_ulargeint;
- start_ulargeint.LowPart = benchmark_start_cpu.dwLowDateTime;
- start_ulargeint.HighPart = benchmark_start_cpu.dwHighDateTime;
-
- ULARGE_INTEGER stop_ulargeint;
- stop_ulargeint.LowPart = benchmark_stop_cpu.dwLowDateTime;
- stop_ulargeint.HighPart = benchmark_stop_cpu.dwHighDateTime;
-
- benchmark_cpu_time_us +=
- (stop_ulargeint.QuadPart - start_ulargeint.QuadPart + 5) / 10;
-#else // WIN32
- struct timeval benchmark_stop_real;
- gettimeofday(&benchmark_stop_real, NULL);
- benchmark_real_time_us +=
- 1000000 * (benchmark_stop_real.tv_sec - benchmark_start_real.tv_sec);
- benchmark_real_time_us +=
- (benchmark_stop_real.tv_usec - benchmark_start_real.tv_usec);
-
- struct rusage benchmark_stop_cpu;
- if (getrusage(RUSAGE_SELF, &benchmark_stop_cpu) == -1) {
- perror("getrusage(RUSAGE_SELF)");
- exit(1);
- }
- benchmark_cpu_time_us += 1000000 * (benchmark_stop_cpu.ru_utime.tv_sec -
- benchmark_start_cpu.ru_utime.tv_sec);
- benchmark_cpu_time_us += (benchmark_stop_cpu.ru_utime.tv_usec -
- benchmark_start_cpu.ru_utime.tv_usec);
-#endif // WIN32
-
- benchmark_running = false;
-}
-
-void SetBenchmarkLabel(const string& str) {
- if (benchmark_label) {
- delete benchmark_label;
- }
- benchmark_label = new string(str);
-}
-
-void SetBenchmarkBytesProcessed(int64 bytes) {
- benchmark_bytes_processed = bytes;
-}
-
-struct BenchmarkRun {
- int64 real_time_us;
- int64 cpu_time_us;
-};
-
-struct BenchmarkCompareCPUTime {
- bool operator() (const BenchmarkRun& a, const BenchmarkRun& b) const {
- return a.cpu_time_us < b.cpu_time_us;
- }
-};
-
-void Benchmark::Run() {
- for (int test_case_num = start_; test_case_num <= stop_; ++test_case_num) {
- // Run a few iterations first to find out approximately how fast
- // the benchmark is.
- const int kCalibrateIterations = 100;
- ResetBenchmarkTiming();
- StartBenchmarkTiming();
- (*function_)(kCalibrateIterations, test_case_num);
- StopBenchmarkTiming();
-
- // Let each test case run for about 200ms, but at least as many
- // as we used to calibrate.
- // Run five times and pick the median.
- const int kNumRuns = 5;
- const int kMedianPos = kNumRuns / 2;
- int num_iterations = 0;
- if (benchmark_real_time_us > 0) {
- num_iterations = 200000 * kCalibrateIterations / benchmark_real_time_us;
- }
- num_iterations = max(num_iterations, kCalibrateIterations);
- BenchmarkRun benchmark_runs[kNumRuns];
-
- for (int run = 0; run < kNumRuns; ++run) {
- ResetBenchmarkTiming();
- StartBenchmarkTiming();
- (*function_)(num_iterations, test_case_num);
- StopBenchmarkTiming();
-
- benchmark_runs[run].real_time_us = benchmark_real_time_us;
- benchmark_runs[run].cpu_time_us = benchmark_cpu_time_us;
- }
-
- string heading = StringPrintf("%s/%d", name_.c_str(), test_case_num);
- string human_readable_speed;
-
- nth_element(benchmark_runs,
- benchmark_runs + kMedianPos,
- benchmark_runs + kNumRuns,
- BenchmarkCompareCPUTime());
- int64 real_time_us = benchmark_runs[kMedianPos].real_time_us;
- int64 cpu_time_us = benchmark_runs[kMedianPos].cpu_time_us;
- if (cpu_time_us <= 0) {
- human_readable_speed = "?";
- } else {
- int64 bytes_per_second =
- benchmark_bytes_processed * 1000000 / cpu_time_us;
- if (bytes_per_second < 1024) {
- human_readable_speed = StringPrintf("%dB/s", bytes_per_second);
- } else if (bytes_per_second < 1024 * 1024) {
- human_readable_speed = StringPrintf(
- "%.1fkB/s", bytes_per_second / 1024.0f);
- } else if (bytes_per_second < 1024 * 1024 * 1024) {
- human_readable_speed = StringPrintf(
- "%.1fMB/s", bytes_per_second / (1024.0f * 1024.0f));
- } else {
- human_readable_speed = StringPrintf(
- "%.1fGB/s", bytes_per_second / (1024.0f * 1024.0f * 1024.0f));
- }
- }
-
- fprintf(stderr,
-#ifdef WIN32
- "%-18s %10I64d %10I64d %10d %s %s\n",
-#else
- "%-18s %10lld %10lld %10d %s %s\n",
-#endif
- heading.c_str(),
- static_cast<long long>(real_time_us * 1000 / num_iterations),
- static_cast<long long>(cpu_time_us * 1000 / num_iterations),
- num_iterations,
- human_readable_speed.c_str(),
- benchmark_label->c_str());
- }
-}
-
-#ifdef HAVE_LIBZ
-
-ZLib::ZLib()
- : comp_init_(false),
- uncomp_init_(false) {
- Reinit();
-}
-
-ZLib::~ZLib() {
- if (comp_init_) { deflateEnd(&comp_stream_); }
- if (uncomp_init_) { inflateEnd(&uncomp_stream_); }
-}
-
-void ZLib::Reinit() {
- compression_level_ = Z_DEFAULT_COMPRESSION;
- window_bits_ = MAX_WBITS;
- mem_level_ = 8; // DEF_MEM_LEVEL
- if (comp_init_) {
- deflateEnd(&comp_stream_);
- comp_init_ = false;
- }
- if (uncomp_init_) {
- inflateEnd(&uncomp_stream_);
- uncomp_init_ = false;
- }
- first_chunk_ = true;
-}
-
-void ZLib::Reset() {
- first_chunk_ = true;
-}
-
-// --------- COMPRESS MODE
-
-// Initialization method to be called if we hit an error while
-// compressing. On hitting an error, call this method before returning
-// the error.
-void ZLib::CompressErrorInit() {
- deflateEnd(&comp_stream_);
- comp_init_ = false;
- Reset();
-}
-
-int ZLib::DeflateInit() {
- return deflateInit2(&comp_stream_,
- compression_level_,
- Z_DEFLATED,
- window_bits_,
- mem_level_,
- Z_DEFAULT_STRATEGY);
-}
-
-int ZLib::CompressInit(Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong *sourceLen) {
- int err;
-
- comp_stream_.next_in = (Bytef*)source;
- comp_stream_.avail_in = (uInt)*sourceLen;
- if ((uLong)comp_stream_.avail_in != *sourceLen) return Z_BUF_ERROR;
- comp_stream_.next_out = dest;
- comp_stream_.avail_out = (uInt)*destLen;
- if ((uLong)comp_stream_.avail_out != *destLen) return Z_BUF_ERROR;
-
- if ( !first_chunk_ ) // only need to set up stream the first time through
- return Z_OK;
-
- if (comp_init_) { // we've already initted it
- err = deflateReset(&comp_stream_);
- if (err != Z_OK) {
- LOG(WARNING) << "ERROR: Can't reset compress object; creating a new one";
- deflateEnd(&comp_stream_);
- comp_init_ = false;
- }
- }
- if (!comp_init_) { // first use
- comp_stream_.zalloc = (alloc_func)0;
- comp_stream_.zfree = (free_func)0;
- comp_stream_.opaque = (voidpf)0;
- err = DeflateInit();
- if (err != Z_OK) return err;
- comp_init_ = true;
- }
- return Z_OK;
-}
-
-// In a perfect world we'd always have the full buffer to compress
-// when the time came, and we could just call Compress(). Alas, we
-// want to do chunked compression on our webserver. In this
-// application, we compress the header, send it off, then compress the
-// results, send them off, then compress the footer. Thus we need to
-// use the chunked compression features of zlib.
-int ZLib::CompressAtMostOrAll(Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong *sourceLen,
- int flush_mode) { // Z_FULL_FLUSH or Z_FINISH
- int err;
-
- if ( (err=CompressInit(dest, destLen, source, sourceLen)) != Z_OK )
- return err;
-
- // This is used to figure out how many bytes we wrote *this chunk*
- int compressed_size = comp_stream_.total_out;
-
- // Some setup happens only for the first chunk we compress in a run
- if ( first_chunk_ ) {
- first_chunk_ = false;
- }
-
- // flush_mode is Z_FINISH for all mode, Z_SYNC_FLUSH for incremental
- // compression.
- err = deflate(&comp_stream_, flush_mode);
-
- *sourceLen = comp_stream_.avail_in;
-
- if ((err == Z_STREAM_END || err == Z_OK)
- && comp_stream_.avail_in == 0
- && comp_stream_.avail_out != 0 ) {
- // we processed everything ok and the output buffer was large enough.
- ;
- } else if (err == Z_STREAM_END && comp_stream_.avail_in > 0) {
- return Z_BUF_ERROR; // should never happen
- } else if (err != Z_OK && err != Z_STREAM_END && err != Z_BUF_ERROR) {
- // an error happened
- CompressErrorInit();
- return err;
- } else if (comp_stream_.avail_out == 0) { // not enough space
- err = Z_BUF_ERROR;
- }
-
- assert(err == Z_OK || err == Z_STREAM_END || err == Z_BUF_ERROR);
- if (err == Z_STREAM_END)
- err = Z_OK;
-
- // update the crc and other metadata
- compressed_size = comp_stream_.total_out - compressed_size; // delta
- *destLen = compressed_size;
-
- return err;
-}
-
-int ZLib::CompressChunkOrAll(Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen,
- int flush_mode) { // Z_FULL_FLUSH or Z_FINISH
- const int ret =
- CompressAtMostOrAll(dest, destLen, source, &sourceLen, flush_mode);
- if (ret == Z_BUF_ERROR)
- CompressErrorInit();
- return ret;
-}
-
-// This routine only initializes the compression stream once. Thereafter, it
-// just does a deflateReset on the stream, which should be faster.
-int ZLib::Compress(Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen) {
- int err;
- if ( (err=CompressChunkOrAll(dest, destLen, source, sourceLen,
- Z_FINISH)) != Z_OK )
- return err;
- Reset(); // reset for next call to Compress
-
- return Z_OK;
-}
-
-
-// --------- UNCOMPRESS MODE
-
-int ZLib::InflateInit() {
- return inflateInit2(&uncomp_stream_, MAX_WBITS);
-}
-
-// Initialization method to be called if we hit an error while
-// uncompressing. On hitting an error, call this method before
-// returning the error.
-void ZLib::UncompressErrorInit() {
- inflateEnd(&uncomp_stream_);
- uncomp_init_ = false;
- Reset();
-}
-
-int ZLib::UncompressInit(Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong *sourceLen) {
- int err;
-
- uncomp_stream_.next_in = (Bytef*)source;
- uncomp_stream_.avail_in = (uInt)*sourceLen;
- // Check for source > 64K on 16-bit machine:
- if ((uLong)uncomp_stream_.avail_in != *sourceLen) return Z_BUF_ERROR;
-
- uncomp_stream_.next_out = dest;
- uncomp_stream_.avail_out = (uInt)*destLen;
- if ((uLong)uncomp_stream_.avail_out != *destLen) return Z_BUF_ERROR;
-
- if ( !first_chunk_ ) // only need to set up stream the first time through
- return Z_OK;
-
- if (uncomp_init_) { // we've already initted it
- err = inflateReset(&uncomp_stream_);
- if (err != Z_OK) {
- LOG(WARNING)
- << "ERROR: Can't reset uncompress object; creating a new one";
- UncompressErrorInit();
- }
- }
- if (!uncomp_init_) {
- uncomp_stream_.zalloc = (alloc_func)0;
- uncomp_stream_.zfree = (free_func)0;
- uncomp_stream_.opaque = (voidpf)0;
- err = InflateInit();
- if (err != Z_OK) return err;
- uncomp_init_ = true;
- }
- return Z_OK;
-}
-
-// If you compressed your data a chunk at a time, with CompressChunk,
-// you can uncompress it a chunk at a time with UncompressChunk.
-// Only difference bewteen chunked and unchunked uncompression
-// is the flush mode we use: Z_SYNC_FLUSH (chunked) or Z_FINISH (unchunked).
-int ZLib::UncompressAtMostOrAll(Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong *sourceLen,
- int flush_mode) { // Z_SYNC_FLUSH or Z_FINISH
- int err = Z_OK;
-
- if ( (err=UncompressInit(dest, destLen, source, sourceLen)) != Z_OK ) {
- LOG(WARNING) << "UncompressInit: Error: " << err << " SourceLen: "
- << *sourceLen;
- return err;
- }
-
- // This is used to figure out how many output bytes we wrote *this chunk*:
- const uLong old_total_out = uncomp_stream_.total_out;
-
- // This is used to figure out how many input bytes we read *this chunk*:
- const uLong old_total_in = uncomp_stream_.total_in;
-
- // Some setup happens only for the first chunk we compress in a run
- if ( first_chunk_ ) {
- first_chunk_ = false; // so we don't do this again
-
- // For the first chunk *only* (to avoid infinite troubles), we let
- // there be no actual data to uncompress. This sometimes triggers
- // when the input is only the gzip header, say.
- if ( *sourceLen == 0 ) {
- *destLen = 0;
- return Z_OK;
- }
- }
-
- // We'll uncompress as much as we can. If we end OK great, otherwise
- // if we get an error that seems to be the gzip footer, we store the
- // gzip footer and return OK, otherwise we return the error.
-
- // flush_mode is Z_SYNC_FLUSH for chunked mode, Z_FINISH for all mode.
- err = inflate(&uncomp_stream_, flush_mode);
-
- // Figure out how many bytes of the input zlib slurped up:
- const uLong bytes_read = uncomp_stream_.total_in - old_total_in;
- CHECK_LE(source + bytes_read, source + *sourceLen);
- *sourceLen = uncomp_stream_.avail_in;
-
- if ((err == Z_STREAM_END || err == Z_OK) // everything went ok
- && uncomp_stream_.avail_in == 0) { // and we read it all
- ;
- } else if (err == Z_STREAM_END && uncomp_stream_.avail_in > 0) {
- LOG(WARNING)
- << "UncompressChunkOrAll: Received some extra data, bytes total: "
- << uncomp_stream_.avail_in << " bytes: "
- << string(reinterpret_cast<const char *>(uncomp_stream_.next_in),
- min(int(uncomp_stream_.avail_in), 20));
- UncompressErrorInit();
- return Z_DATA_ERROR; // what's the extra data for?
- } else if (err != Z_OK && err != Z_STREAM_END && err != Z_BUF_ERROR) {
- // an error happened
- LOG(WARNING) << "UncompressChunkOrAll: Error: " << err
- << " avail_out: " << uncomp_stream_.avail_out;
- UncompressErrorInit();
- return err;
- } else if (uncomp_stream_.avail_out == 0) {
- err = Z_BUF_ERROR;
- }
-
- assert(err == Z_OK || err == Z_BUF_ERROR || err == Z_STREAM_END);
- if (err == Z_STREAM_END)
- err = Z_OK;
-
- *destLen = uncomp_stream_.total_out - old_total_out; // size for this call
-
- return err;
-}
-
-int ZLib::UncompressChunkOrAll(Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen,
- int flush_mode) { // Z_SYNC_FLUSH or Z_FINISH
- const int ret =
- UncompressAtMostOrAll(dest, destLen, source, &sourceLen, flush_mode);
- if (ret == Z_BUF_ERROR)
- UncompressErrorInit();
- return ret;
-}
-
-int ZLib::UncompressAtMost(Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong *sourceLen) {
- return UncompressAtMostOrAll(dest, destLen, source, sourceLen, Z_SYNC_FLUSH);
-}
-
-// We make sure we've uncompressed everything, that is, the current
-// uncompress stream is at a compressed-buffer-EOF boundary. In gzip
-// mode, we also check the gzip footer to make sure we pass the gzip
-// consistency checks. We RETURN true iff both types of checks pass.
-bool ZLib::UncompressChunkDone() {
- assert(!first_chunk_ && uncomp_init_);
- // Make sure we're at the end-of-compressed-data point. This means
- // if we call inflate with Z_FINISH we won't consume any input or
- // write any output
- Bytef dummyin, dummyout;
- uLongf dummylen = 0;
- if ( UncompressChunkOrAll(&dummyout, &dummylen, &dummyin, 0, Z_FINISH)
- != Z_OK ) {
- return false;
- }
-
- // Make sure that when we exit, we can start a new round of chunks later
- Reset();
-
- return true;
-}
-
-// Uncompresses the source buffer into the destination buffer.
-// The destination buffer must be long enough to hold the entire
-// decompressed contents.
-//
-// We only initialize the uncomp_stream once. Thereafter, we use
-// inflateReset, which should be faster.
-//
-// Returns Z_OK on success, otherwise, it returns a zlib error code.
-int ZLib::Uncompress(Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen) {
- int err;
- if ( (err=UncompressChunkOrAll(dest, destLen, source, sourceLen,
- Z_FINISH)) != Z_OK ) {
- Reset(); // let us try to compress again
- return err;
- }
- if ( !UncompressChunkDone() ) // calls Reset()
- return Z_DATA_ERROR;
- return Z_OK; // stream_end is ok
-}
-
-#endif // HAVE_LIBZ
-
-} // namespace snappy