From ee03c949b85036b68c261dcc27dca064ee7e525d Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Tue, 23 Apr 2013 08:28:39 +0000 Subject: Add basic zlib support to LLVM. This would allow to use compression/uncompression in selected LLVM tools. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180083 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Config/config.h.cmake | 6 ++++ include/llvm/Config/config.h.in | 9 ++++++ include/llvm/Support/Compression.h | 58 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 include/llvm/Support/Compression.h (limited to 'include') diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index 0a26857397..408c590beb 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -498,6 +498,9 @@ /* Define if the xdot.py program is available */ #cmakedefine HAVE_XDOT_PY ${HAVE_XDOT_PY} +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ZLIB_H ${HAVE_ZLIB_H} + /* Have host's _alloca */ #cmakedefine HAVE__ALLOCA ${HAVE__ALLOCA} @@ -570,6 +573,9 @@ /* Define if threads enabled */ #cmakedefine01 LLVM_ENABLE_THREADS +/* Define if zlib compression is available */ +#cmakedefine01 LLVM_ENABLE_ZLIB + /* Installation directory for config files */ #cmakedefine LLVM_ETCDIR "${LLVM_ETCDIR}" diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in index 5a3d02c553..7f75f4df69 100644 --- a/include/llvm/Config/config.h.in +++ b/include/llvm/Config/config.h.in @@ -226,6 +226,9 @@ /* Define to 1 if you have the `udis86' library (-ludis86). */ #undef HAVE_LIBUDIS86 +/* Define to 1 if you have the `z' library (-lz). */ +#undef HAVE_LIBZ + /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H @@ -503,6 +506,9 @@ /* Define if the xdot.py program is available */ #undef HAVE_XDOT_PY +/* Define to 1 if you have the header file. */ +#undef HAVE_ZLIB_H + /* Have host's _alloca */ #undef HAVE__ALLOCA @@ -575,6 +581,9 @@ /* Define if threads enabled */ #undef LLVM_ENABLE_THREADS +/* Define if zlib is enabled */ +#undef LLVM_ENABLE_ZLIB + /* Installation directory for config files */ #undef LLVM_ETCDIR diff --git a/include/llvm/Support/Compression.h b/include/llvm/Support/Compression.h new file mode 100644 index 0000000000..9b1142d035 --- /dev/null +++ b/include/llvm/Support/Compression.h @@ -0,0 +1,58 @@ +//===-- llvm/Support/Compression.h ---Compression----------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains basic functions for compression/uncompression. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_COMPRESSION_H +#define LLVM_SUPPORT_COMPRESSION_H + +#include "llvm/Support/DataTypes.h" + +namespace llvm { + +class MemoryBuffer; +template class OwningPtr; +class StringRef; + +namespace zlib { + +enum CompressionLevel { + NoCompression, + DefaultCompression, + BestSpeedCompression, + BestSizeCompression +}; + +enum Status { + StatusOK, + StatusUnsupported, // zlib is unavaliable + StatusOutOfMemory, // there was not enough memory + StatusBufferTooShort, // there was not enough room in the output buffer + StatusInvalidArg, // invalid input parameter + StatusInvalidData // data was corrupted or incomplete +}; + +bool isAvailable(); + +Status compress(StringRef InputBuffer, + OwningPtr &CompressedBuffer, + CompressionLevel Level = DefaultCompression); + +Status uncompress(StringRef InputBuffer, + OwningPtr &UncompressedBuffer, + size_t UncompressedSize); + +} // End of namespace zlib + +} // End of namespace llvm + +#endif + -- cgit v1.2.3