From daa320f3f7bd9cc121462ef7a201fad87f540bd6 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Sat, 13 Dec 2014 15:05:46 +0100 Subject: New : lz4frame integrated into liblz4 (v1.5.0) --- Makefile | 26 +++++++-------- NEWS | 3 ++ cmake_unofficial/CMakeLists.txt | 4 +-- lib/Makefile | 13 ++++---- lib/lz4.h | 6 ++-- lib/lz4frame.c | 4 +-- lib/lz4frame.h | 18 ++--------- lib/lz4frame_static.h | 72 +++++++++++++++++++++++++++++++++++++++++ programs/Makefile | 6 ++-- programs/frametest.c | 6 ++-- programs/lz4cli.c | 16 ++++----- 11 files changed, 117 insertions(+), 57 deletions(-) create mode 100644 lib/lz4frame_static.h diff --git a/Makefile b/Makefile index 3b1e51f..1d190fd 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # ################################################################ -# LZ4 library - Makefile -# Copyright (C) Yann Collet 2011-2014 +# LZ4 - Makefile +# Copyright (C) Yann Collet 2011-2015 # All rights reserved. # # BSD license @@ -30,24 +30,22 @@ # - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c # ################################################################ -# Version numbers -export VERSION=125 +# Version number +export VERSION=126 export RELEASE=r$(VERSION) DESTDIR?= PREFIX ?= /usr -CC := $(CC) -CFLAGS ?= -O3 -CFLAGS += -I. -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -DLZ4_VERSION=\"$(RELEASE)\" -LIBDIR?= $(PREFIX)/lib +LIBDIR ?= $(PREFIX)/lib INCLUDEDIR=$(PREFIX)/include -PRGDIR = programs -LZ4DIR = lib +PRGDIR = programs +LZ4DIR = lib DISTRIBNAME=lz4-$(RELEASE).tar.gz TEXT = $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4.h $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4hc.h \ - $(LZ4DIR)/lz4frame.c $(LZ4DIR)/lz4frame.h $(LZ4DIR)/xxhash.c $(LZ4DIR)/xxhash.h \ + $(LZ4DIR)/lz4frame.c $(LZ4DIR)/lz4frame.h $(LZ4DIR)/lz4frame_static.h \ + $(LZ4DIR)/xxhash.c $(LZ4DIR)/xxhash.h \ $(LZ4DIR)/liblz4.pc.in $(LZ4DIR)/Makefile $(LZ4DIR)/LICENSE \ Makefile lz4_block_format.txt LZ4_Frame_Format.html NEWS README.md \ cmake_unofficial/CMakeLists.txt \ @@ -93,8 +91,8 @@ clean: ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU)) install: - @cd $(LZ4DIR); sudo $(MAKE) -e install - @cd $(PRGDIR); sudo $(MAKE) -e install + @cd $(LZ4DIR); $(MAKE) -e install + @cd $(PRGDIR); $(MAKE) -e install uninstall: @cd $(LZ4DIR); $(MAKE) uninstall @@ -119,7 +117,7 @@ dist: clean @echo Distribution $(DISTRIBNAME) built test: - @cd $(PRGDIR); $(MAKE) -e $@ + @cd $(PRGDIR); $(MAKE) -e test test-travis: $(TRAVIS_TARGET) diff --git a/NEWS b/NEWS index 5259573..36fde86 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +r126: +New : lz4frame API is now integrated into liblz4 + r125: Changed : endian and alignment code Changed : directory structure : new "lib" directory diff --git a/cmake_unofficial/CMakeLists.txt b/cmake_unofficial/CMakeLists.txt index cacaca1..bb7ab5f 100644 --- a/cmake_unofficial/CMakeLists.txt +++ b/cmake_unofficial/CMakeLists.txt @@ -1,8 +1,8 @@ PROJECT(LZ4 C) set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LZ4 compression library") set(CPACK_PACKAGE_VERSION_MAJOR 1) -set(CPACK_PACKAGE_VERSION_MINOR 4) -set(CPACK_PACKAGE_VERSION_PATCH r125) +set(CPACK_PACKAGE_VERSION_MINOR 5) +set(CPACK_PACKAGE_VERSION_PATCH r126) set(VERSION_STRING " \"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}\" ") include(CPack) diff --git a/lib/Makefile b/lib/Makefile index c59cc82..2c85ed8 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,6 +1,6 @@ # ################################################################ # LZ4 library - Makefile -# Copyright (C) Yann Collet 2011-2014 +# Copyright (C) Yann Collet 2011-2015 # All rights reserved. # # BSD license @@ -32,8 +32,7 @@ # ################################################################ # Version numbers -VERSION=125 -RELEASE=r$(VERSION) +VERSION ?= 126 LIBVER_MAJOR=`sed -n '/define LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lz4.h` LIBVER_MINOR=`sed -n '/define LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lz4.h` LIBVER_PATCH=`sed -n '/define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lz4.h` @@ -41,9 +40,8 @@ LIBVER=$(LIBVER_MAJOR).$(LIBVER_MINOR).$(LIBVER_PATCH) DESTDIR?= PREFIX ?= /usr -CC := $(CC) CFLAGS ?= -O3 -CFLAGS += -I. -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -DLZ4_VERSION=\"$(RELEASE)\" +CFLAGS += -I. -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes LIBDIR?= $(PREFIX)/lib INCLUDEDIR=$(PREFIX)/include @@ -67,10 +65,10 @@ default: liblz4 all: liblz4 -liblz4: lz4.c lz4hc.c +liblz4: lz4.c lz4hc.c lz4frame.c xxhash.c @echo compiling static library @$(CC) $(CPPFLAGS) $(CFLAGS) -c $^ - @$(AR) rcs liblz4.a lz4.o lz4hc.o + @$(AR) rcs liblz4.a lz4.o lz4hc.o lz4frame.o xxhash.o @echo compiling dynamic library $(LIBVER) @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared $^ -fPIC $(SONAME_FLAGS) -o $@.$(SHARED_EXT_VER) @echo creating versioned links @@ -103,6 +101,7 @@ install: liblz4 liblz4.pc @install -m 644 liblz4.a $(DESTDIR)$(LIBDIR)/liblz4.a @install -m 644 lz4.h $(DESTDIR)$(INCLUDEDIR)/lz4.h @install -m 644 lz4hc.h $(DESTDIR)$(INCLUDEDIR)/lz4hc.h + @install -m 644 lz4frame.h $(DESTDIR)$(INCLUDEDIR)/lz4frame.h @echo lz4 static and shared library installed uninstall: diff --git a/lib/lz4.h b/lib/lz4.h index 7392320..7778caa 100644 --- a/lib/lz4.h +++ b/lib/lz4.h @@ -46,9 +46,9 @@ extern "C" { /************************************** Version **************************************/ -#define LZ4_VERSION_MAJOR 1 /* for major interface/format changes */ -#define LZ4_VERSION_MINOR 4 /* for minor interface/format changes */ -#define LZ4_VERSION_RELEASE 1 /* for tweaks, bug-fixes, or development */ +#define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */ +#define LZ4_VERSION_MINOR 5 /* for new (non-breaking) interface capabilities */ +#define LZ4_VERSION_RELEASE 0 /* for tweaks, bug-fixes, or development */ #define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE) int LZ4_versionNumber (void); diff --git a/lib/lz4frame.c b/lib/lz4frame.c index aa46152..5183f22 100644 --- a/lib/lz4frame.c +++ b/lib/lz4frame.c @@ -64,7 +64,7 @@ Memory routines /************************************** Includes **************************************/ -#include "lz4frame.h" +#include "lz4frame_static.h" #include "lz4.h" #include "lz4hc.h" #include "xxhash.h" @@ -161,7 +161,7 @@ Error management static const char* LZ4F_errorStrings[] = { LZ4F_LIST_ERRORS(LZ4F_GENERATE_STRING) }; -int LZ4F_isError(LZ4F_errorCode_t code) +U32 LZ4F_isError(LZ4F_errorCode_t code) { return (code > (LZ4F_errorCode_t)(-ERROR_maxCode)); } diff --git a/lib/lz4frame.h b/lib/lz4frame.h index 48fbf80..b2a7f40 100644 --- a/lib/lz4frame.h +++ b/lib/lz4frame.h @@ -60,20 +60,8 @@ extern "C" { * Error management * ************************************/ typedef size_t LZ4F_errorCode_t; -#define LZ4F_LIST_ERRORS(ITEM) \ - ITEM(OK_NoError) ITEM(ERROR_GENERIC) \ - ITEM(ERROR_maxBlockSize_invalid) ITEM(ERROR_blockMode_invalid) ITEM(ERROR_contentChecksumFlag_invalid) \ - ITEM(ERROR_compressionLevel_invalid) \ - ITEM(ERROR_allocation_failed) \ - ITEM(ERROR_srcSize_tooLarge) ITEM(ERROR_dstMaxSize_tooSmall) \ - ITEM(ERROR_decompressionFailed) \ - ITEM(ERROR_checksum_invalid) \ - ITEM(ERROR_maxCode) - -#define LZ4F_GENERATE_ENUM(ENUM) ENUM, -typedef enum { LZ4F_LIST_ERRORS(LZ4F_GENERATE_ENUM) } LZ4F_errorCodes; /* enum is exposed, to detect & handle specific errors; compare function result to -enum value */ - -int LZ4F_isError(LZ4F_errorCode_t code); /* Basically : code > -ERROR_maxCode */ + +unsigned LZ4F_isError(LZ4F_errorCode_t code); const char* LZ4F_getErrorName(LZ4F_errorCode_t code); /* return error code string; useful for debugging */ @@ -108,7 +96,7 @@ size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t* prefere size_t LZ4F_compressFrame(void* dstBuffer, size_t dstMaxSize, const void* srcBuffer, size_t srcSize, const LZ4F_preferences_t* preferencesPtr); /* LZ4F_compressFrame() - * Compress an entire srcBuffer into a valid LZ4 frame, as defined by specification v1.4.1, in a single step. + * Compress an entire srcBuffer into a valid LZ4 frame, as defined by specification v1.4.1. * The most important rule is that dstBuffer MUST be large enough (dstMaxSize) to ensure compression completion even in worst case. * You can get the minimum value of dstMaxSize by using LZ4F_compressFrameBound() * If this condition is not respected, LZ4F_compressFrame() will fail (result is an errorCode) diff --git a/lib/lz4frame_static.h b/lib/lz4frame_static.h new file mode 100644 index 0000000..cde8186 --- /dev/null +++ b/lib/lz4frame_static.h @@ -0,0 +1,72 @@ +/* + LZ4 auto-framing library + Header File for static linking only + Copyright (C) 2011-2015, Yann Collet. + + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + 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. + + 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. + + You can contact the author at : + - LZ4 source repository : http://code.google.com/p/lz4/ + - LZ4 source mirror : https://github.com/Cyan4973/lz4 + - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c +*/ + +#pragma once + +#if defined (__cplusplus) +extern "C" { +#endif + +/* lz4frame_static.h should be used solely in the context of static linking. + * */ + + +/************************************** + * Error management + * ************************************/ +#define LZ4F_LIST_ERRORS(ITEM) \ + ITEM(OK_NoError) ITEM(ERROR_GENERIC) \ + ITEM(ERROR_maxBlockSize_invalid) ITEM(ERROR_blockMode_invalid) ITEM(ERROR_contentChecksumFlag_invalid) \ + ITEM(ERROR_compressionLevel_invalid) \ + ITEM(ERROR_allocation_failed) \ + ITEM(ERROR_srcSize_tooLarge) ITEM(ERROR_dstMaxSize_tooSmall) \ + ITEM(ERROR_decompressionFailed) \ + ITEM(ERROR_checksum_invalid) \ + ITEM(ERROR_maxCode) + +#define LZ4F_GENERATE_ENUM(ENUM) ENUM, +typedef enum { LZ4F_LIST_ERRORS(LZ4F_GENERATE_ENUM) } LZ4F_errorCodes; /* enum is exposed, to handle specific errors; compare function result to -enum value */ + + +/************************************** + Includes +**************************************/ +#include "lz4frame.h" + + +#if defined (__cplusplus) +} +#endif diff --git a/programs/Makefile b/programs/Makefile index aaaa00e..f097d06 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -1,6 +1,7 @@ # ########################################################################## # LZ4 programs - Makefile -# Copyright (C) Yann Collet 2011-2014 +# Copyright (C) Yann Collet 2011-2015 +# # GPL v2 License # # This program is free software; you can redistribute it and/or modify @@ -30,11 +31,10 @@ # fullbench32: Same as fullbench, but forced to compile in 32-bits mode # ########################################################################## -RELEASE=r125 +RELEASE?= r126 DESTDIR?= PREFIX ?= /usr -CC := $(CC) CFLAGS ?= -O3 CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -DLZ4_VERSION=\"$(RELEASE)\" FLAGS = -I../lib $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) diff --git a/programs/frametest.c b/programs/frametest.c index 2a0c603..71490a6 100644 --- a/programs/frametest.c +++ b/programs/frametest.c @@ -38,13 +38,13 @@ /************************************** - Includes + Includes **************************************/ -#include +#include // free #include // fgets, sscanf #include // timeb #include // strcmp -#include "lz4frame.h" +#include "lz4frame_static.h" #include "xxhash.h" // XXH64 diff --git a/programs/lz4cli.c b/programs/lz4cli.c index 6f62095..b755ab8 100644 --- a/programs/lz4cli.c +++ b/programs/lz4cli.c @@ -55,7 +55,7 @@ //**************************** // Includes //**************************** -#include // fprintf, fopen, fread, _fileno, stdin, stdout +#include // fprintf, getchar #include // exit, calloc, free #include // strcmp, strlen #include "bench.h" // BMK_benchFile, BMK_SetNbIterations, BMK_SetBlocksize, BMK_SetPause @@ -85,7 +85,7 @@ //**************************** #define COMPRESSOR_NAME "LZ4 command line interface" #ifndef LZ4_VERSION -# define LZ4_VERSION "r125" +# define LZ4_VERSION "r126" #endif #define AUTHOR "Yann Collet" #define WELCOME_MESSAGE "*** %s %i-bits %s, by %s (%s) ***\n", COMPRESSOR_NAME, (int)(sizeof(void*)*8), LZ4_VERSION, AUTHOR, __DATE__ @@ -136,13 +136,13 @@ static char* programName; #define EXTENDED_FORMAT #define DEFAULT_COMPRESSOR LZ4IO_compressFilename #define DEFAULT_DECOMPRESSOR LZ4IO_decompressFilename -int LZ4IO_compressFilename_Legacy(char* input_filename, char* output_filename, int compressionlevel); +int LZ4IO_compressFilename_Legacy(char* input_filename, char* output_filename, int compressionlevel); // hidden function //**************************** // Functions //**************************** -int usage(void) +static int usage(void) { DISPLAY( "Usage :\n"); DISPLAY( " %s [arg] [input] [output]\n", programName); @@ -159,7 +159,7 @@ int usage(void) return 0; } -int usage_advanced(void) +static int usage_advanced(void) { DISPLAY(WELCOME_MESSAGE); usage(); @@ -190,7 +190,7 @@ int usage_advanced(void) return 0; } -int usage_longhelp(void) +static int usage_longhelp(void) { DISPLAY( "\n"); DISPLAY( "Which values can get [output] ? \n"); @@ -240,7 +240,7 @@ int usage_longhelp(void) return 0; } -int badusage(void) +static int badusage(void) { DISPLAYLEVEL(1, "Incorrect parameters\n"); if (displayLevel >= 1) usage(); @@ -248,7 +248,7 @@ int badusage(void) } -void waitEnter(void) +static void waitEnter(void) { DISPLAY("Press enter to continue...\n"); getchar(); -- cgit v0.12