[Pkg-electronics-commits] [gtkwave] 01/03: Imported Upstream version 3.3.65
أحمد المحمودي (Ahmed El-Mahmoudy)
aelmahmoudy at sabily.org
Fri Apr 24 17:24:26 UTC 2015
This is an automated email from the git hooks/post-receive script.
aelmahmoudy-guest pushed a commit to branch experimental
in repository gtkwave.
commit 473f5e5ce4521bfdffc1f53439bedc8d24546de7
Author: أحمد المحمودي (Ahmed El-Mahmoudy) <aelmahmoudy at users.sourceforge.net>
Date: Fri Apr 24 09:16:07 2015 +0200
Imported Upstream version 3.3.65
---
AUTHORS | 22 +-
ChangeLog | 11 +
LICENSE.TXT | 20 +-
configure | 20 +-
configure.ac | 2 +-
contrib/bundle_for_osx/Info-gtkwave.plist | 8 +-
doc/gtkwave.odt | Bin 1395012 -> 1395035 bytes
src/Makefile.am | 2 +-
src/fst.c | 129 +++++-
src/ghw.c | 102 ++++-
src/globals.c | 9 +
src/globals.h | 3 +
src/helpers/fst/fstapi.c | 8 +-
src/helpers/fst/fstapi.h | 10 +-
src/helpers/fst/lz4.c | 645 +++++++++++++++++-------------
src/helpers/fst/lz4.h | 50 +--
src/helpers/vzt_read.c | 6 +-
src/strace.c | 35 +-
src/treesearch_gtk2.c | 30 +-
src/vcd.c | 3 +-
src/vcd_partial.c | 3 +-
src/vcd_recoder.c | 3 +-
src/version.h | 4 +-
23 files changed, 713 insertions(+), 412 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index 3986058..f7910f6 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,14 +1,14 @@
-GTKWave Wave Viewer is Copyright (C) 1999-2014 Tony Bybell.
-Windows compatibility and PS/MIF routines are Copyright (C) 1999-2014 Udi Finkelstein.
-Context support is Copyright (C) 2007-2014 Kermin Elliott Fleming.
-Trace group support is Copyright (C) 2009-2014 Donald Baltus.
-GHW and additional GUI support is Copyright (C) 2005-2014 Tristan Gingold.
-Analog support is Copyright (C) 2005-2014 Thomas Sailer.
-External DnD support is Copyright (C) 2008-2014 Concept Engineering GmbH.
-FastLZ is Copyright (C) 2005-2014 Ariya Hidayat.
-PCCTS 1.33MR is Copyright (C) 1989-2014 Terence Parr, Russell Quong, Will Cohen, Hank Dietz, and Thomas Moog.
+GTKWave Wave Viewer is Copyright (C) 1999-2015 Tony Bybell.
+Windows compatibility and PS/MIF routines are Copyright (C) 1999-2015 Udi Finkelstein.
+Context support is Copyright (C) 2007-2015 Kermin Elliott Fleming.
+Trace group support is Copyright (C) 2009-2015 Donald Baltus.
+GHW and additional GUI support is Copyright (C) 2005-2015 Tristan Gingold.
+Analog support is Copyright (C) 2005-2015 Thomas Sailer.
+External DnD support is Copyright (C) 2008-2015 Concept Engineering GmbH.
+FastLZ is Copyright (C) 2005-2015 Ariya Hidayat.
+PCCTS 1.33MR is Copyright (C) 1989-2015 Terence Parr, Russell Quong, Will Cohen, Hank Dietz, and Thomas Moog.
Some public domain clip art by contributors at http://www.sxc.hu/ website.
Hierarchy marker icons from the Silk icons set by Mark James found at the http://www.famfamfam.com/lab/icons/silk/ website.
Portions of the TCL implementation, tcl_np.c and tcl_np.h are copyrighted by the Regents of the University of California, Sun Microsystems, Inc., Scriptics Corporation, ActiveState Corporation, and other parties.
-NSAlert is Copyright (C) 2011-2014 Philipp Mayerhofer.
-LZ4 is Copyright (C) 2011-2014 Yann Collet.
+NSAlert is Copyright (C) 2011-2015 Philipp Mayerhofer.
+LZ4 is Copyright (C) 2011-2015 Yann Collet.
diff --git a/ChangeLog b/ChangeLog
index 044e4b9..9f85fcb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1494,3 +1494,14 @@
absolute/relative pathname.
Updated LZ4 for version r124.
Fix for x-windows OSX compiles.
+3.3.65 01apr15 Added --, -I-, etc. option to port filtering in SST. Using
+ -- for example filters all non-ports from search results.
+ Updated LZ4 for version r126.
+ Minor warnings fixes.
+ Moved TCL_LDADD/TK_LDADD before FSDB_LDADD to avoid stale
+ Tcl library version conflicts.
+ Removed appending [31:0] to vcd loaded integer names.
+ Reduced recursion depth in GHW signal loader to prevent
+ stack overflow crashes.
+ Added support for synthetic clocks in FST file.
+ Update timetrace marking so it runs quicker for large traces.
diff --git a/LICENSE.TXT b/LICENSE.TXT
index 0f97fdd..7bdb0c2 100644
--- a/LICENSE.TXT
+++ b/LICENSE.TXT
@@ -1,14 +1,14 @@
##########################################################################
-GTKWave 3.3.64 Wave Viewer is Copyright (C) 1999-2014 Tony Bybell.
-Portions of GTKWave are Copyright (C) 1999-2014 Udi Finkelstein.
-Context support is Copyright (C) 2007-2014 Kermin Elliott Fleming.
-Trace group support is Copyright (C) 2009-2014 Donald Baltus.
-GHW and additional GUI support is Copyright (C) 2005-2014 Tristan Gingold.
-Analog support is Copyright (C) 2005-2014 Thomas Sailer.
-External DnD support is Copyright (C) 2008-2014 Concept Engineering GmbH.
-FastLZ is Copyright (C) 2005-2014 Ariya Hidayat.
-LZ4 is Copyright (C) 2011-2014 Yann Collet.
+GTKWave 3.3.65 Wave Viewer is Copyright (C) 1999-2015 Tony Bybell.
+Portions of GTKWave are Copyright (C) 1999-2015 Udi Finkelstein.
+Context support is Copyright (C) 2007-2015 Kermin Elliott Fleming.
+Trace group support is Copyright (C) 2009-2015 Donald Baltus.
+GHW and additional GUI support is Copyright (C) 2005-2015 Tristan Gingold.
+Analog support is Copyright (C) 2005-2015 Thomas Sailer.
+External DnD support is Copyright (C) 2008-2015 Concept Engineering GmbH.
+FastLZ is Copyright (C) 2005-2015 Ariya Hidayat.
+LZ4 is Copyright (C) 2011-2015 Yann Collet.
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
@@ -26,7 +26,7 @@ Franklin Street - Suite 500, Boston, MA 02110-1335, USA.
##########################################################################
-PCCTS 1.33MR is Copyright (C) 1989-2014 Terence Parr, Russell Quong,
+PCCTS 1.33MR is Copyright (C) 1989-2015 Terence Parr, Russell Quong,
Will Cohen, Hank Dietz, and Thomas Moog. It is in the public
domain. Please read contrib/pccts/RIGHTS for more information.
diff --git a/configure b/configure
index 6e973eb..2d56039 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for gtkwave 3.3.64.
+# Generated by GNU Autoconf 2.69 for gtkwave 3.3.65.
#
# Report bugs to <bybell at rocketmail.com>.
#
@@ -580,8 +580,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='gtkwave'
PACKAGE_TARNAME='gtkwave'
-PACKAGE_VERSION='3.3.64'
-PACKAGE_STRING='gtkwave 3.3.64'
+PACKAGE_VERSION='3.3.65'
+PACKAGE_STRING='gtkwave 3.3.65'
PACKAGE_BUGREPORT='bybell at rocketmail.com'
PACKAGE_URL=''
@@ -1383,7 +1383,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures gtkwave 3.3.64 to adapt to many kinds of systems.
+\`configure' configures gtkwave 3.3.65 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1449,7 +1449,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of gtkwave 3.3.64:";;
+ short | recursive ) echo "Configuration of gtkwave 3.3.65:";;
esac
cat <<\_ACEOF
@@ -1595,7 +1595,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-gtkwave configure 3.3.64
+gtkwave configure 3.3.65
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2239,7 +2239,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by gtkwave $as_me 3.3.64, which was
+It was created by gtkwave $as_me 3.3.65, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -3106,7 +3106,7 @@ fi
# Define the identity of the package.
PACKAGE='gtkwave'
- VERSION='3.3.64'
+ VERSION='3.3.65'
cat >>confdefs.h <<_ACEOF
@@ -10992,7 +10992,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by gtkwave $as_me 3.3.64, which was
+This file was extended by gtkwave $as_me 3.3.65, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -11058,7 +11058,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-gtkwave config.status 3.3.64
+gtkwave config.status 3.3.65
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/configure.ac b/configure.ac
index acee0af..2079b43 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT(gtkwave, 3.3.64, bybell at rocketmail.com)
+AC_INIT(gtkwave, 3.3.65, bybell at rocketmail.com)
AC_CONFIG_SRCDIR([src/vcd.c])
AM_INIT_AUTOMAKE
AC_CONFIG_HEADER([config.h])
diff --git a/contrib/bundle_for_osx/Info-gtkwave.plist b/contrib/bundle_for_osx/Info-gtkwave.plist
index 1627806..e56930c 100644
--- a/contrib/bundle_for_osx/Info-gtkwave.plist
+++ b/contrib/bundle_for_osx/Info-gtkwave.plist
@@ -8,7 +8,7 @@
<key>CFBundleExecutable</key>
<string>gtkwave</string>
<key>CFBundleGetInfoString</key>
- <string>3.3.64, (C) 1999-2014 Tony Bybell http://gtkwave.sourceforge.net</string>
+ <string>3.3.65, (C) 1999-2015 Tony Bybell http://gtkwave.sourceforge.net</string>
<key>CFBundleIconFile</key>
<string>gtkwave.icns</string>
<key>CFBundleIdentifier</key>
@@ -18,13 +18,13 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
- <string>3.3.64</string>
+ <string>3.3.65</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>3.3.64</string>
+ <string>3.3.65</string>
<key>NSHumanReadableCopyright</key>
- <string>Copyright 1999 - 2014 Tony Bybell, GNU General Public License.</string>
+ <string>Copyright 1999 - 2015 Tony Bybell, GNU General Public License.</string>
<key>LSMinimumSystemVersion</key>
<string>10.6</string>
diff --git a/doc/gtkwave.odt b/doc/gtkwave.odt
index 41525b5..8505a9a 100644
Binary files a/doc/gtkwave.odt and b/doc/gtkwave.odt differ
diff --git a/src/Makefile.am b/src/Makefile.am
index 9b4d391..dc133f4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -52,7 +52,7 @@ gtkwave_SOURCES= \
vcd_partial.c vcd_recoder.c vcd_saver.c vcd_saver.h version.h vlist.c vlist.h vzt.c vzt.h wavealloca.h \
wavewindow.c zoombuttons.c
-gtkwave_LDADD= $(LIBCOCOA_LDADD) $(GTK_LIBS) $(LIBLZMA_LDADD) $(LIBZ_LDADD) $(LIBBZ2_LDADD) $(LIBFST_LDADD) $(AET2_LDADD) $(FSDB_LDADD) $(TCL_LDADD) $(TK_LDADD) $(LIBJUDY_LDADD) $(GTK_MAC_LIBS) $(GCONF_LIBS) $(GTK_UNIX_PRINT_LIBS) $(MINGW_LDADD)
+gtkwave_LDADD= $(LIBCOCOA_LDADD) $(GTK_LIBS) $(LIBLZMA_LDADD) $(LIBZ_LDADD) $(LIBBZ2_LDADD) $(LIBFST_LDADD) $(AET2_LDADD) $(TCL_LDADD) $(TK_LDADD) $(FSDB_LDADD) $(LIBJUDY_LDADD) $(GTK_MAC_LIBS) $(GCONF_LIBS) $(GTK_UNIX_PRINT_LIBS) $(MINGW_LDADD)
gtkwave_LDFLAGS = $(COCOA_GTK_LDFLAGS)
twinwave_SOURCES= twinwave.c
diff --git a/src/fst.c b/src/fst.c
index 7e70b07..9dcedae 100644
--- a/src/fst.c
+++ b/src/fst.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) Tony Bybell 2009-2013.
+ * Copyright (c) Tony Bybell 2009-2015.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -440,6 +440,19 @@ while((h = fstReaderIterateHier(xc)))
GLOBALS->stem_path_string_table_siz++;
}
}
+ else
+ if(h->u.attr.subtype == FST_MT_VALUELIST)
+ {
+ if(h->u.attr.name)
+ {
+ /* format is concatenations of [m b xs xe valstring] */
+ if(GLOBALS->fst_synclock_str)
+ {
+ free_2(GLOBALS->fst_synclock_str);
+ }
+ GLOBALS->fst_synclock_str = strdup_2(h->u.attr.name);
+ }
+ }
}
break;
@@ -526,7 +539,7 @@ if(GLOBALS->fst_filetype == FST_FT_VHDL)
}
GLOBALS->subvar_jrb = make_jrb(); /* only used for attributes such as generated in VHDL, etc. */
-
+GLOBALS->synclock_jrb = make_jrb(); /* only used for synthetic clocks */
GLOBALS->numfacs=fstReaderGetVarCount(GLOBALS->fst_fst_c_1);
GLOBALS->mvlfacs_fst_c_3=(struct fac *)calloc_2(GLOBALS->numfacs,sizeof(struct fac));
@@ -625,6 +638,7 @@ for(i=0;i<GLOBALS->numfacs;i++)
fstReaderIterateHierRewind(GLOBALS->fst_fst_c_1);
h = extractNextVar(GLOBALS->fst_fst_c_1, &msb, &lsb, &nnam, &name_len, &nnam_max);
}
+
npar = GLOBALS->mod_tree_parent;
hier_len = GLOBALS->fst_scope_name ? GLOBALS->fst_scope_name_len : 0;
if(hier_len)
@@ -763,6 +777,24 @@ for(i=0;i<GLOBALS->numfacs;i++)
GLOBALS->mvlfacs_fst_c_3[i].len = 2;
}
+ if(GLOBALS->fst_synclock_str)
+ {
+ if(GLOBALS->mvlfacs_fst_c_3[i].len == 1) /* currently only for single bit signals */
+ {
+ Jval syn_jv;
+
+ GLOBALS->mvlfacs_fst_c_3[i].flags |= VZT_RD_SYM_F_SYNVEC; /* special meaning for this in FST loader--means synthetic signal! */
+ syn_jv.s = GLOBALS->fst_synclock_str;
+ jrb_insert_int(GLOBALS->synclock_jrb, i, syn_jv);
+ }
+ else
+ {
+ free_2(GLOBALS->fst_synclock_str);
+ }
+
+ GLOBALS->fst_synclock_str = NULL; /* under malloc_2() control for true if() branch, so not lost */
+ }
+
if(h->u.var.is_alias)
{
GLOBALS->mvlfacs_fst_c_3[i].node_alias = h->u.var.handle - 1; /* subtract 1 to scale it with gtkwave-style numbering */
@@ -1473,17 +1505,20 @@ if(np->mv.mvlfac->flags&VZT_RD_SYM_F_ALIAS)
}
-{
-int flagged = HIER_DEPACK_STATIC;
-char *str = hier_decompress_flagged(np->nname, &flagged);
-fprintf(stderr, "Import: %s\n", str);
-}
+if(!(f->flags&VZT_RD_SYM_F_SYNVEC)) /* block debug message for synclk */
+ {
+ int flagged = HIER_DEPACK_STATIC;
+ char *str = hier_decompress_flagged(np->nname, &flagged);
+ fprintf(stderr, "Import: %s\n", str); /* normally this never happens */
+ }
/* new stuff */
len = np->mv.mvlfac->len;
/* check here for array height in future */
+
+if(!(f->flags&VZT_RD_SYM_F_SYNVEC))
{
fstReaderSetFacProcessMask(GLOBALS->fst_fst_c_1, GLOBALS->mvlfacs_fst_c_3[txidx].node_alias+1);
fstReaderIterBlocks2(GLOBALS->fst_fst_c_1, fst_callback, fst_callback2, NULL, NULL);
@@ -1599,6 +1634,74 @@ if(nold!=np)
/*
+ * decompress [m b xs xe valstring]... format string into trace
+ */
+static void expand_synvec(int txidx, const char *s)
+{
+char *scopy = NULL;
+char *pnt, *pnt2;
+double m, b;
+uint64_t xs, xe, xi;
+char *vs;
+uint64_t tim;
+uint64_t tim_max;
+int vslen;
+int vspnt;
+unsigned char value[2] = {0, 0};
+unsigned char pval = 0;
+
+scopy = strdup_2(s);
+vs = calloc_2(1, strlen(s) + 1); /* will never be as big as original string */
+pnt = scopy;
+
+while(*pnt)
+ {
+ if(*pnt != '[') { pnt++; continue; }
+ pnt++;
+
+ pnt2 = strchr(pnt, ']');
+ if(!pnt2) break;
+ *pnt2 = 0;
+
+ /* printf("PNT: %s\n", pnt); */
+ int rc = sscanf(pnt, "%lg %lg %"SCNu64" %"SCNu64" %s", &m, &b, &xs, &xe, vs);
+ if(rc == 5)
+ {
+ vslen = strlen(vs);
+ vspnt = 0;
+
+ tim_max = 0;
+ for(xi = xs; xi <= xe; xi++)
+ {
+ tim = (xi * m) + b;
+ /* fprintf(stderr, "#%"PRIu64" '%c'\n", tim, vs[vspnt]); */
+ value[0] = vs[vspnt];
+ if(value[0] != pval) /* collapse new == old value transitions so new is ignored */
+ {
+ if((tim >= tim_max) || (xi == xs))
+ {
+ fst_callback2(NULL, tim, txidx, value, 0);
+ tim_max = tim;
+ }
+ pval = value[0];
+ }
+ vspnt++; vspnt = (vspnt == vslen) ? 0 : vspnt; /* modulus on repeating clock */
+ }
+ }
+ else
+ {
+ break;
+ }
+
+ pnt = pnt2 + 1;
+ }
+
+free_2(vs);
+free_2(scopy);
+}
+
+
+/*
* pre-import many traces at once so function above doesn't have to iterate...
*/
void fst_set_fac_process_mask(nptr np)
@@ -1609,6 +1712,7 @@ int txidx;
if(!(f=np->mv.mvlfac)) return; /* already imported */
txidx = f-GLOBALS->mvlfacs_fst_c_3;
+
if(np->mv.mvlfac->flags&VZT_RD_SYM_F_ALIAS)
{
txidx = GLOBALS->mvlfacs_fst_c_3[txidx].node_alias;
@@ -1618,6 +1722,17 @@ if(np->mv.mvlfac->flags&VZT_RD_SYM_F_ALIAS)
if(!(np->mv.mvlfac)) return; /* already imported */
}
+if(np->mv.mvlfac->flags&VZT_RD_SYM_F_SYNVEC)
+ {
+ JRB fi = jrb_find_int(GLOBALS->synclock_jrb, txidx);
+ if(fi)
+ {
+ expand_synvec(txidx+1, fi->val.s);
+ import_fst_trace(np);
+ return; /* import_fst_trace() will construct the trailer */
+ }
+ }
+
/* check here for array height in future */
{
fstReaderSetFacProcessMask(GLOBALS->fst_fst_c_1, GLOBALS->mvlfacs_fst_c_3[txidx].node_alias+1);
diff --git a/src/ghw.c b/src/ghw.c
index 2df415a..a8b9ec5 100644
--- a/src/ghw.c
+++ b/src/ghw.c
@@ -221,14 +221,40 @@ for(i=0;i<GLOBALS->numfacs;i++)
* preserve tree->t_which ordering so hierarchy children index pointers don't get corrupted
*/
+#if 1
+
+/* limited recursive version */
+
static void recurse_tree_build_whichcache(struct tree *t)
{
if(t)
{
- if(t->child) { recurse_tree_build_whichcache(t->child); }
- if(t->next) { recurse_tree_build_whichcache(t->next); }
-
- if(t->t_which >= 0) GLOBALS->gwt_ghw_c_1 = ghw_insert(t, GLOBALS->gwt_ghw_c_1, t->t_which, GLOBALS->facs[t->t_which]);
+ struct tree *t2 = t;
+ int i;
+ int cnt = 1;
+ struct tree **ar;
+
+ while((t2 = t2->next)) { cnt++; }
+
+ ar = malloc_2(cnt * sizeof(struct tree *));
+ t2 = t;
+ for(i=0;i<cnt;i++)
+ {
+ ar[i] = t2;
+ if(t2->child) { recurse_tree_build_whichcache(t2->child); }
+ t2 = t2->next;
+ }
+
+ for(i=cnt-1;i>=0;i--)
+ {
+ t = ar[i];
+ if(t->t_which >= 0)
+ {
+ GLOBALS->gwt_ghw_c_1 = ghw_insert(t, GLOBALS->gwt_ghw_c_1, t->t_which, GLOBALS->facs[t->t_which]);
+ }
+ }
+
+ free_2(ar);
}
}
@@ -236,19 +262,71 @@ static void recurse_tree_fix_from_whichcache(struct tree *t)
{
if(t)
{
- if(t->child) { recurse_tree_fix_from_whichcache(t->child); }
- if(t->next) { recurse_tree_fix_from_whichcache(t->next); }
-
- if(t->t_which >= 0)
+ struct tree *t2 = t;
+ int i;
+ int cnt = 1;
+ struct tree **ar;
+
+ while((t2 = t2->next)) { cnt++; }
+
+ ar = malloc_2(cnt * sizeof(struct tree *));
+ t2 = t;
+ for(i=0;i<cnt;i++)
{
- GLOBALS->gwt_ghw_c_1 = ghw_splay(t, GLOBALS->gwt_ghw_c_1);
- GLOBALS->gwt_corr_ghw_c_1 = ghw_splay(GLOBALS->gwt_ghw_c_1->sym, GLOBALS->gwt_corr_ghw_c_1); /* all facs are in this tree so this is OK */
-
- t->t_which = GLOBALS->gwt_corr_ghw_c_1->val_old;
+ ar[i] = t2;
+ if(t2->child) { recurse_tree_fix_from_whichcache(t2->child); }
+ t2 = t2->next;
+ }
+
+ for(i=cnt-1;i>=0;i--)
+ {
+ t = ar[i];
+ if(t->t_which >= 0)
+ {
+ GLOBALS->gwt_ghw_c_1 = ghw_splay(t, GLOBALS->gwt_ghw_c_1);
+ GLOBALS->gwt_corr_ghw_c_1 = ghw_splay(GLOBALS->gwt_ghw_c_1->sym, GLOBALS->gwt_corr_ghw_c_1); /* all facs are in this tree so this is OK */
+
+ t->t_which = GLOBALS->gwt_corr_ghw_c_1->val_old;
+ }
}
+
+ free_2(ar);
}
}
+#else
+
+/* original fully-recursive version */
+
+static void recurse_tree_build_whichcache(struct tree *t)
+{
+if(t)
+ {
+ if(t->child) { recurse_tree_build_whichcache(t->child); }
+ if(t->next) { recurse_tree_build_whichcache(t->next); }
+
+ if(t->t_which >= 0) GLOBALS->gwt_ghw_c_1 = ghw_insert(t, GLOBALS->gwt_ghw_c_1, t->t_which, GLOBALS->facs[t->t_which]);
+ }
+}
+
+static void recurse_tree_fix_from_whichcache(struct tree *t)
+{
+if(t)
+ {
+ if(t->child) { recurse_tree_fix_from_whichcache(t->child); }
+ if(t->next) { recurse_tree_fix_from_whichcache(t->next); }
+
+ if(t->t_which >= 0)
+ {
+ GLOBALS->gwt_ghw_c_1 = ghw_splay(t, GLOBALS->gwt_ghw_c_1);
+ GLOBALS->gwt_corr_ghw_c_1 = ghw_splay(GLOBALS->gwt_ghw_c_1->sym, GLOBALS->gwt_corr_ghw_c_1); /* all facs are in this tree so this is OK */
+
+ t->t_which = GLOBALS->gwt_corr_ghw_c_1->val_old;
+ }
+ }
+}
+
+#endif
static void incinerate_whichcache_tree(ghw_Tree *t)
{
diff --git a/src/globals.c b/src/globals.c
index 55db441..1514534 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -335,6 +335,8 @@ NULL, /* istem_struct_base */
0, /* istem_struct_base_siz_alloc */
0, /* stem_valid */
0, /* istem_valid */
+NULL, /* fst_synclock_str */
+NULL, /* synclock_jrb */
/*
@@ -1067,6 +1069,7 @@ NULL, /* sig_root_treesearch_gtk2_c_1 458 */
NULL, /* sst_sig_root_treesearch_gtk2_c_1 */
NULL, /* filter_str_treesearch_gtk2_c_1 459 */
ND_DIR_UNSPECIFIED, /* filter_typ_treesearch_gtk2_c_1 */
+0, /* filter_typ_polarity_treesearch_gtk2_c_1 */
0, /* filter_matlen_treesearch_gtk2_c_1 */
0, /* filter_noregex_treesearch_gtk2_c_1 */
#if defined(WAVE_USE_GTK2)
@@ -2024,6 +2027,12 @@ void reload_into_new_context_2(void)
GLOBALS->subvar_jrb_count = 0;
}
+ if(GLOBALS->synclock_jrb)
+ {
+ jrb_free_tree(GLOBALS->synclock_jrb);
+ GLOBALS->synclock_jrb = NULL;
+ }
+
/* deallocate any loader-related stuff */
switch(GLOBALS->loaded_file_type) {
diff --git a/src/globals.h b/src/globals.h
index 0886f93..92531f7 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -334,6 +334,8 @@ uint32_t istem_struct_base_siz;
uint32_t istem_struct_base_siz_alloc;
unsigned stem_valid : 1;
unsigned istem_valid : 1;
+char *fst_synclock_str;
+JRB synclock_jrb;
/*
@@ -1049,6 +1051,7 @@ struct tree *sig_root_treesearch_gtk2_c_1; /* from treesearch_gtk2.c 488 */
struct tree *sst_sig_root_treesearch_gtk2_c_1; /* from treesearch_gtk2.c */
char *filter_str_treesearch_gtk2_c_1; /* from treesearch_gtk2.c 489 */
int filter_typ_treesearch_gtk2_c_1;
+int filter_typ_polarity_treesearch_gtk2_c_1;
int filter_matlen_treesearch_gtk2_c_1;
unsigned char filter_noregex_treesearch_gtk2_c_1;
#if defined(WAVE_USE_GTK2)
diff --git a/src/helpers/fst/fstapi.c b/src/helpers/fst/fstapi.c
index b0d7dfc..5ec842d 100644
--- a/src/helpers/fst/fstapi.c
+++ b/src/helpers/fst/fstapi.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2014 Tony Bybell.
+ * Copyright (c) 2009-2015 Tony Bybell.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -2360,6 +2360,12 @@ fstWriterSetAttrGeneric(ctx, comm, FST_MT_COMMENT, 0);
}
+void fstWriterSetValueList(void *ctx, const char *vl)
+{
+fstWriterSetAttrGeneric(ctx, vl, FST_MT_VALUELIST, 0);
+}
+
+
void fstWriterSetEnvVar(void *ctx, const char *envvar)
{
fstWriterSetAttrGeneric(ctx, envvar, FST_MT_ENVVAR, 0);
diff --git a/src/helpers/fst/fstapi.h b/src/helpers/fst/fstapi.h
index 83daac4..df86ef0 100644
--- a/src/helpers/fst/fstapi.h
+++ b/src/helpers/fst/fstapi.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2014 Tony Bybell.
+ * Copyright (c) 2009-2015 Tony Bybell.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -191,9 +191,10 @@ enum fstMiscType {
FST_MT_PATHNAME = 3, /* reserved for fstWriterSetSourceStem() string -> number management */
FST_MT_SOURCESTEM = 4, /* use fstWriterSetSourceStem() to emit */
FST_MT_SOURCEISTEM = 5, /* use fstWriterSetSourceInstantiationStem() to emit */
- FST_MT_UNKNOWN = 6,
+ FST_MT_VALUELIST = 6, /* use fstWriterSetValueList() to emit, followed by fstWriterCreateVar*() */
+ FST_MT_UNKNOWN = 7,
- FST_MT_MAX = 6
+ FST_MT_MAX = 7
};
enum fstArrayType {
@@ -246,7 +247,7 @@ enum fstSupplementalVarType {
FST_SVT_VHDL_FILE = 4,
FST_SVT_VHDL_MEMORY = 5,
- FST_SVT_MAX = 5,
+ FST_SVT_MAX = 5
};
enum fstSupplementalDataType {
@@ -358,6 +359,7 @@ void fstWriterSetTimescale(void *ctx, int ts);
void fstWriterSetTimescaleFromString(void *ctx, const char *s);
void fstWriterSetTimezero(void *ctx, int64_t tim);
void fstWriterSetUpscope(void *ctx);
+void fstWriterSetValueList(void *ctx, const char *vl);
void fstWriterSetVersion(void *ctx, const char *vers);
diff --git a/src/helpers/fst/lz4.c b/src/helpers/fst/lz4.c
index 198b581..ed928ce 100644
--- a/src/helpers/fst/lz4.c
+++ b/src/helpers/fst/lz4.c
@@ -1,6 +1,6 @@
/*
LZ4 - Fast LZ compression algorithm
- Copyright (C) 2011-2014, Yann Collet.
+ 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
@@ -27,86 +27,78 @@
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 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
*/
+
/**************************************
Tuning parameters
**************************************/
/*
* HEAPMODE :
* Select how default compression functions will allocate memory for their hash table,
- * in memory stack (0:default, fastest), or in memory heap (1:requires memory allocation (malloc)).
+ * in memory stack (0:default, fastest), or in memory heap (1:requires malloc()).
*/
#define HEAPMODE 0
+/*
+ * CPU_HAS_EFFICIENT_UNALIGNED_MEMORY_ACCESS :
+ * By default, the source code expects the compiler to correctly optimize
+ * 4-bytes and 8-bytes read on architectures able to handle it efficiently.
+ * This is not always the case. In some circumstances (ARM notably),
+ * the compiler will issue cautious code even when target is able to correctly handle unaligned memory accesses.
+ *
+ * You can force the compiler to use unaligned memory access by uncommenting the line below.
+ * One of the below scenarios will happen :
+ * 1 - Your target CPU correctly handle unaligned access, and was not well optimized by compiler (good case).
+ * You will witness large performance improvements (+50% and up).
+ * Keep the line uncommented and send a word to upstream (https://groups.google.com/forum/#!forum/lz4c)
+ * The goal is to automatically detect such situations by adding your target CPU within an exception list.
+ * 2 - Your target CPU correctly handle unaligned access, and was already already optimized by compiler
+ * No change will be experienced.
+ * 3 - Your target CPU inefficiently handle unaligned access.
+ * You will experience a performance loss. Comment back the line.
+ * 4 - Your target CPU does not handle unaligned access.
+ * Program will crash.
+ * If uncommenting results in better performance (case 1)
+ * please report your configuration to upstream (https://groups.google.com/forum/#!forum/lz4c)
+ * An automatic detection macro will be added to match your case within future versions of the library.
+ */
+/* #define CPU_HAS_EFFICIENT_UNALIGNED_MEMORY_ACCESS 1 */
+
/**************************************
CPU Feature Detection
**************************************/
-/* 32 or 64 bits ? */
-#if (defined(__x86_64__) || defined(_M_X64) || defined(_WIN64) \
- || defined(__64BIT__) || defined(__mips64) \
- || defined(__powerpc64__) || defined(__powerpc64le__) \
- || defined(__ppc64__) || defined(__ppc64le__) \
- || defined(__PPC64__) || defined(__PPC64LE__) \
- || defined(__ia64) || defined(__itanium__) || defined(_M_IA64) \
- || defined(__s390x__) ) /* Detects 64 bits mode */
-# define LZ4_ARCH64 1
-#else
-# define LZ4_ARCH64 0
-#endif
-#define LZ4_32BITS (sizeof(void*)==4)
-#define LZ4_64BITS (sizeof(void*)==8)
-
/*
- * Little Endian or Big Endian ?
- * Overwrite the #define below if you know your architecture endianess
+ * Automated efficient unaligned memory access detection
+ * Based on known hardware architectures
+ * This list will be updated thanks to feedbacks
*/
-#include <stdlib.h> /* Apparently required to detect endianess */
-#if defined (__GLIBC__)
-# include <endian.h>
-# if (__BYTE_ORDER == __BIG_ENDIAN)
-# define LZ4_BIG_ENDIAN 1
-# endif
-#elif (defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN) || defined(_BIG_ENDIAN)) && !(defined(__LITTLE_ENDIAN__) || defined(__LITTLE_ENDIAN) || defined(_LITTLE_ENDIAN))
-# define LZ4_BIG_ENDIAN 1
-#elif defined(__sparc) || defined(__sparc__) \
- || defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) \
- || defined(__hpux) || defined(__hppa) \
- || defined(_MIPSEB) || defined(__s390__)
-# define LZ4_BIG_ENDIAN 1
+#if defined(CPU_HAS_EFFICIENT_UNALIGNED_MEMORY_ACCESS) \
+ || defined(__ARM_FEATURE_UNALIGNED) \
+ || defined(__i386__) || defined(__x86_64__) \
+ || defined(_M_IX86) || defined(_M_X64) \
+ || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_8__) \
+ || (defined(_M_ARM) && (_M_ARM >= 7))
+# define LZ4_UNALIGNED_ACCESS 1
#else
-/* Little Endian assumed. PDP Endian and other very rare endian format are unsupported. */
+# define LZ4_UNALIGNED_ACCESS 0
#endif
/*
- * Unaligned memory access is automatically enabled for "common" CPU, such as x86.
- * For others CPU, such as ARM, the compiler may be more cautious, inserting unnecessary extra code to ensure aligned access property
- * If you know your target CPU supports unaligned memory access, you want to force this option manually to improve performance
+ * LZ4_FORCE_SW_BITCOUNT
+ * Define this parameter if your target system or compiler does not support hardware bit count
*/
-#if defined(__ARM_FEATURE_UNALIGNED)
-# define LZ4_FORCE_UNALIGNED_ACCESS 1
-#endif
-
-/* Define this parameter if your target system or compiler does not support hardware bit count */
#if defined(_MSC_VER) && defined(_WIN32_WCE) /* Visual Studio for Windows CE does not support Hardware bit count */
# define LZ4_FORCE_SW_BITCOUNT
#endif
-/*
- * BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE :
- * This option may provide a small boost to performance for some big endian cpu, although probably modest.
- * You may set this option to 1 if data will remain within closed environment.
- * This option is useless on Little_Endian CPU (such as x86)
- */
-
-/* #define BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE 1 */
-
/**************************************
- Compiler Options
+ Compiler Options
**************************************/
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */
/* "restrict" is a known keyword */
@@ -116,28 +108,20 @@
#ifdef _MSC_VER /* Visual Studio */
# define FORCE_INLINE static __forceinline
-# include <intrin.h> /* For Visual 2005 */
-# if LZ4_ARCH64 /* 64-bits */
-# pragma intrinsic(_BitScanForward64) /* For Visual 2005 */
-# pragma intrinsic(_BitScanReverse64) /* For Visual 2005 */
-# else /* 32-bits */
-# pragma intrinsic(_BitScanForward) /* For Visual 2005 */
-# pragma intrinsic(_BitScanReverse) /* For Visual 2005 */
-# endif
+# include <intrin.h>
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
+# pragma warning(disable : 4293) /* disable: C4293: too large shift (32-bits) */
#else
-# ifdef __GNUC__
-# define FORCE_INLINE static inline __attribute__((always_inline))
+# if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */
+# ifdef __GNUC__
+# define FORCE_INLINE static inline __attribute__((always_inline))
+# else
+# define FORCE_INLINE static inline
+# endif
# else
-# define FORCE_INLINE static inline
-# endif
-#endif
-
-#ifdef _MSC_VER /* Visual Studio */
-# define lz4_bswap16(x) _byteswap_ushort(x)
-#else
-# define lz4_bswap16(x) ((unsigned short int) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)))
-#endif
+# define FORCE_INLINE static
+# endif /* __STDC_VERSION__ */
+#endif /* _MSC_VER */
#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
@@ -185,46 +169,132 @@
typedef unsigned long long U64;
#endif
-#if defined(__GNUC__) && !defined(LZ4_FORCE_UNALIGNED_ACCESS)
-# define _PACKED __attribute__ ((packed))
-#else
-# define _PACKED
-#endif
-#if !defined(LZ4_FORCE_UNALIGNED_ACCESS) && !defined(__GNUC__)
-# if defined(__IBMC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-# pragma pack(1)
-# else
-# pragma pack(push, 1)
-# endif
-#endif
+/**************************************
+ Reading and writing into memory
+**************************************/
+#define STEPSIZE sizeof(size_t)
-typedef struct { U16 v; } _PACKED U16_S;
-typedef struct { U32 v; } _PACKED U32_S;
-typedef struct { U64 v; } _PACKED U64_S;
-typedef struct {size_t v;} _PACKED size_t_S;
+static unsigned LZ4_64bits(void) { return sizeof(void*)==8; }
-#if !defined(LZ4_FORCE_UNALIGNED_ACCESS) && !defined(__GNUC__)
-# if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-# pragma pack(0)
-# else
-# pragma pack(pop)
-# endif
+static unsigned LZ4_isLittleEndian(void)
+{
+ const union { U32 i; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */
+ return one.c[0];
+}
+
+
+static U16 LZ4_readLE16(const void* memPtr)
+{
+ if ((LZ4_UNALIGNED_ACCESS) && (LZ4_isLittleEndian()))
+ return *(U16*)memPtr;
+ else
+ {
+ const BYTE* p = memPtr;
+ return (U16)((U16)p[0] + (p[1]<<8));
+ }
+}
+
+static void LZ4_writeLE16(void* memPtr, U16 value)
+{
+ if ((LZ4_UNALIGNED_ACCESS) && (LZ4_isLittleEndian()))
+ {
+ *(U16*)memPtr = value;
+ return;
+ }
+ else
+ {
+ BYTE* p = memPtr;
+ p[0] = (BYTE) value;
+ p[1] = (BYTE)(value>>8);
+ }
+}
+
+
+static U16 LZ4_read16(const void* memPtr)
+{
+ if (LZ4_UNALIGNED_ACCESS)
+ return *(U16*)memPtr;
+ else
+ {
+ U16 val16;
+ memcpy(&val16, memPtr, 2);
+ return val16;
+ }
+}
+
+static U32 LZ4_read32(const void* memPtr)
+{
+ if (LZ4_UNALIGNED_ACCESS)
+ return *(U32*)memPtr;
+ else
+ {
+ U32 val32;
+ memcpy(&val32, memPtr, 4);
+ return val32;
+ }
+}
+
+static U64 LZ4_read64(const void* memPtr)
+{
+ if (LZ4_UNALIGNED_ACCESS)
+ return *(U64*)memPtr;
+ else
+ {
+ U64 val64;
+ memcpy(&val64, memPtr, 8);
+ return val64;
+ }
+}
+
+static size_t LZ4_read_ARCH(const void* p)
+{
+ if (LZ4_64bits())
+ return (size_t)LZ4_read64(p);
+ else
+ return (size_t)LZ4_read32(p);
+}
+
+
+static void LZ4_copy4(void* dstPtr, const void* srcPtr)
+{
+ if (LZ4_UNALIGNED_ACCESS)
+ {
+ *(U32*)dstPtr = *(U32*)srcPtr;
+ return;
+ }
+ memcpy(dstPtr, srcPtr, 4);
+}
+
+static void LZ4_copy8(void* dstPtr, const void* srcPtr)
+{
+#if GCC_VERSION!=409 /* disabled on GCC 4.9, as it generates invalid opcode (crash) */
+ if (LZ4_UNALIGNED_ACCESS)
+ {
+ if (LZ4_64bits())
+ *(U64*)dstPtr = *(U64*)srcPtr;
+ else
+ ((U32*)dstPtr)[0] = ((U32*)srcPtr)[0],
+ ((U32*)dstPtr)[1] = ((U32*)srcPtr)[1];
+ return;
+ }
#endif
+ memcpy(dstPtr, srcPtr, 8);
+}
-#define A16(x) (((U16_S *)(x))->v)
-#define A32(x) (((U32_S *)(x))->v)
-#define A64(x) (((U64_S *)(x))->v)
-#define AARCH(x) (((size_t_S *)(x))->v)
+/* customized version of memcpy, which may overwrite up to 7 bytes beyond dstEnd */
+static void LZ4_wildCopy(void* dstPtr, const void* srcPtr, void* dstEnd)
+{
+ BYTE* d = dstPtr;
+ const BYTE* s = srcPtr;
+ BYTE* e = dstEnd;
+ do { LZ4_copy8(d,s); d+=8; s+=8; } while (d<e);
+}
/**************************************
- Constants
+ Common Constants
**************************************/
-#define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2)
-#define HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
-#define HASH_SIZE_U32 (1 << LZ4_HASHLOG)
-
#define MINMATCH 4
#define COPYLENGTH 8
@@ -232,13 +302,10 @@ typedef struct {size_t v;} _PACKED size_t_S;
#define MFLIMIT (COPYLENGTH+MINMATCH)
static const int LZ4_minLength = (MFLIMIT+1);
-#define KB *(1U<<10)
-#define MB *(1U<<20)
+#define KB *(1 <<10)
+#define MB *(1 <<20)
#define GB *(1U<<30)
-#define LZ4_64KLIMIT ((64 KB) + (MFLIMIT-1))
-#define SKIPSTRENGTH 6 /* Increasing this value will make the compression run slower on incompressible data */
-
#define MAXD_LOG 16
#define MAX_DISTANCE ((1 << MAXD_LOG) - 1)
@@ -249,130 +316,147 @@ static const int LZ4_minLength = (MFLIMIT+1);
/**************************************
- Structures and local types
+ Common Utils
**************************************/
-typedef struct {
- U32 hashTable[HASH_SIZE_U32];
- U32 currentOffset;
- U32 initCheck;
- const BYTE* dictionary;
- const BYTE* bufferStart;
- U32 dictSize;
-} LZ4_stream_t_internal;
+#define LZ4_STATIC_ASSERT(c) { enum { LZ4_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */
-typedef enum { notLimited = 0, limitedOutput = 1 } limitedOutput_directive;
-typedef enum { byPtr, byU32, byU16 } tableType_t;
-typedef enum { noDict = 0, withPrefix64k, usingExtDict } dict_directive;
-typedef enum { noDictIssue = 0, dictSmall } dictIssue_directive;
+/********************************
+ Common functions
+********************************/
+static unsigned LZ4_NbCommonBytes (register size_t val)
+{
+ if (LZ4_isLittleEndian())
+ {
+ if (LZ4_64bits())
+ {
+# if defined(_MSC_VER) && defined(_WIN64) && !defined(LZ4_FORCE_SW_BITCOUNT)
+ unsigned long r = 0;
+ _BitScanForward64( &r, (U64)val );
+ return (int)(r>>3);
+# elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
+ return (__builtin_ctzll((U64)val) >> 3);
+# else
+ static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2, 0, 3, 1, 3, 1, 4, 2, 7, 0, 2, 3, 6, 1, 5, 3, 5, 1, 3, 4, 4, 2, 5, 6, 7, 7, 0, 1, 2, 3, 3, 4, 6, 2, 6, 5, 5, 3, 4, 5, 6, 7, 1, 2, 4, 6, 4, 4, 5, 7, 2, 6, 5, 7, 6, 7, 7 };
+ return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
+# endif
+ }
+ else /* 32 bits */
+ {
+# if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
+ unsigned long r;
+ _BitScanForward( &r, (U32)val );
+ return (int)(r>>3);
+# elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
+ return (__builtin_ctz((U32)val) >> 3);
+# else
+ static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 };
+ return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27];
+# endif
+ }
+ }
+ else /* Big Endian CPU */
+ {
+ if (LZ4_64bits())
+ {
+# if defined(_MSC_VER) && defined(_WIN64) && !defined(LZ4_FORCE_SW_BITCOUNT)
+ unsigned long r = 0;
+ _BitScanReverse64( &r, val );
+ return (unsigned)(r>>3);
+# elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
+ return (__builtin_clzll(val) >> 3);
+# else
+ unsigned r;
+ if (!(val>>32)) { r=4; } else { r=0; val>>=32; }
+ if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
+ r += (!val);
+ return r;
+# endif
+ }
+ else /* 32 bits */
+ {
+# if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
+ unsigned long r = 0;
+ _BitScanReverse( &r, (unsigned long)val );
+ return (unsigned)(r>>3);
+# elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
+ return (__builtin_clz(val) >> 3);
+# else
+ unsigned r;
+ if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; }
+ r += (!val);
+ return r;
+# endif
+ }
+ }
+}
-typedef enum { endOnOutputSize = 0, endOnInputSize = 1 } endCondition_directive;
-typedef enum { full = 0, partial = 1 } earlyEnd_directive;
+static unsigned LZ4_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* pInLimit)
+{
+ const BYTE* const pStart = pIn;
+
+ while (likely(pIn<pInLimit-(STEPSIZE-1)))
+ {
+ size_t diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
+ if (!diff) { pIn+=STEPSIZE; pMatch+=STEPSIZE; continue; }
+ pIn += LZ4_NbCommonBytes(diff);
+ return (unsigned)(pIn - pStart);
+ }
+
+ if (LZ4_64bits()) if ((pIn<(pInLimit-3)) && (LZ4_read32(pMatch) == LZ4_read32(pIn))) { pIn+=4; pMatch+=4; }
+ if ((pIn<(pInLimit-1)) && (LZ4_read16(pMatch) == LZ4_read16(pIn))) { pIn+=2; pMatch+=2; }
+ if ((pIn<pInLimit) && (*pMatch == *pIn)) pIn++;
+ return (unsigned)(pIn - pStart);
+}
+#ifndef LZ4_COMMONDEFS_ONLY
/**************************************
- Architecture-specific macros
+ Local Constants
**************************************/
-#define STEPSIZE sizeof(size_t)
-#define LZ4_COPYSTEP(d,s) { AARCH(d) = AARCH(s); d+=STEPSIZE; s+=STEPSIZE; }
-#define LZ4_COPY8(d,s) { LZ4_COPYSTEP(d,s); if (STEPSIZE<8) LZ4_COPYSTEP(d,s); }
-
-#if (defined(LZ4_BIG_ENDIAN) && !defined(BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE))
-# define LZ4_READ_LITTLEENDIAN_16(d,s,p) { U16 v = A16(p); v = lz4_bswap16(v); d = (s) - v; }
-# define LZ4_WRITE_LITTLEENDIAN_16(p,i) { U16 v = (U16)(i); v = lz4_bswap16(v); A16(p) = v; p+=2; }
-#else /* Little Endian */
-# define LZ4_READ_LITTLEENDIAN_16(d,s,p) { d = (s) - A16(p); }
-# define LZ4_WRITE_LITTLEENDIAN_16(p,v) { A16(p) = v; p+=2; }
-#endif
+#define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2)
+#define HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
+#define HASH_SIZE_U32 (1 << LZ4_HASHLOG) /* required as macro for static allocation */
+
+static const int LZ4_64Klimit = ((64 KB) + (MFLIMIT-1));
+static const U32 LZ4_skipTrigger = 6; /* Increase this value ==> compression run slower on incompressible data */
/**************************************
- Macros
+ Local Utils
**************************************/
-#define LZ4_STATIC_ASSERT(c) { enum { LZ4_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */
-#if LZ4_ARCH64 || !defined(__GNUC__)
-# define LZ4_WILDCOPY(d,s,e) { do { LZ4_COPY8(d,s) } while (d<e); } /* at the end, d>=e; */
-#else
-# define LZ4_WILDCOPY(d,s,e) { if (likely(e-d <= 8)) LZ4_COPY8(d,s) else do { LZ4_COPY8(d,s) } while (d<e); }
-#endif
+int LZ4_versionNumber (void) { return LZ4_VERSION_NUMBER; }
+int LZ4_compressBound(int isize) { return LZ4_COMPRESSBOUND(isize); }
-/****************************
- Private local functions
-****************************/
-#if LZ4_ARCH64
+/**************************************
+ Local Structures and types
+**************************************/
+typedef struct {
+ U32 hashTable[HASH_SIZE_U32];
+ U32 currentOffset;
+ U32 initCheck;
+ const BYTE* dictionary;
+ const BYTE* bufferStart;
+ U32 dictSize;
+} LZ4_stream_t_internal;
-static int LZ4_NbCommonBytes (register U64 val)
-{
-# if defined(LZ4_BIG_ENDIAN)
-# if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
- unsigned long r = 0;
- _BitScanReverse64( &r, val );
- return (int)(r>>3);
-# elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
- return (__builtin_clzll(val) >> 3);
-# else
- int r;
- if (!(val>>32)) { r=4; } else { r=0; val>>=32; }
- if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
- r += (!val);
- return r;
-# endif
-# else
-# if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
- unsigned long r = 0;
- _BitScanForward64( &r, val );
- return (int)(r>>3);
-# elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
- return (__builtin_ctzll(val) >> 3);
-# else
- static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2, 0, 3, 1, 3, 1, 4, 2, 7, 0, 2, 3, 6, 1, 5, 3, 5, 1, 3, 4, 4, 2, 5, 6, 7, 7, 0, 1, 2, 3, 3, 4, 6, 2, 6, 5, 5, 3, 4, 5, 6, 7, 1, 2, 4, 6, 4, 4, 5, 7, 2, 6, 5, 7, 6, 7, 7 };
- return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
-# endif
-# endif
-}
+typedef enum { notLimited = 0, limitedOutput = 1 } limitedOutput_directive;
+typedef enum { byPtr, byU32, byU16 } tableType_t;
-#else
+typedef enum { noDict = 0, withPrefix64k, usingExtDict } dict_directive;
+typedef enum { noDictIssue = 0, dictSmall } dictIssue_directive;
-static int LZ4_NbCommonBytes (register U32 val)
-{
-# if defined(LZ4_BIG_ENDIAN)
-# if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
- unsigned long r = 0;
- _BitScanReverse( &r, val );
- return (int)(r>>3);
-# elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
- return (__builtin_clz(val) >> 3);
-# else
- int r;
- if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; }
- r += (!val);
- return r;
-# endif
-# else
-# if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
- unsigned long r;
- _BitScanForward( &r, val );
- return (int)(r>>3);
-# elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
- return (__builtin_ctz(val) >> 3);
-# else
- static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 };
- return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27];
-# endif
-# endif
-}
+typedef enum { endOnOutputSize = 0, endOnInputSize = 1 } endCondition_directive;
+typedef enum { full = 0, partial = 1 } earlyEnd_directive;
-#endif
/********************************
Compression functions
********************************/
-int LZ4_versionNumber (void) { return LZ4_VERSION_NUMBER; }
-int LZ4_compressBound(int isize) { return LZ4_COMPRESSBOUND(isize); }
-static int LZ4_hashSequence(U32 sequence, tableType_t tableType)
+static U32 LZ4_hashSequence(U32 sequence, tableType_t tableType)
{
if (tableType == byU16)
return (((sequence) * 2654435761U) >> ((MINMATCH*8)-(LZ4_HASHLOG+1)));
@@ -380,15 +464,15 @@ static int LZ4_hashSequence(U32 sequence, tableType_t tableType)
return (((sequence) * 2654435761U) >> ((MINMATCH*8)-LZ4_HASHLOG));
}
-static int LZ4_hashPosition(const BYTE* p, tableType_t tableType) { return LZ4_hashSequence(A32(p), tableType); }
+static U32 LZ4_hashPosition(const BYTE* p, tableType_t tableType) { return LZ4_hashSequence(LZ4_read32(p), tableType); }
static void LZ4_putPositionOnHash(const BYTE* p, U32 h, void* tableBase, tableType_t tableType, const BYTE* srcBase)
{
switch (tableType)
{
- case byPtr: { const BYTE** hashTable = (const BYTE**) tableBase; hashTable[h] = p; break; }
- case byU32: { U32* hashTable = (U32*) tableBase; hashTable[h] = (U32)(p-srcBase); break; }
- case byU16: { U16* hashTable = (U16*) tableBase; hashTable[h] = (U16)(p-srcBase); break; }
+ case byPtr: { const BYTE** hashTable = (const BYTE**)tableBase; hashTable[h] = p; return; }
+ case byU32: { U32* hashTable = (U32*) tableBase; hashTable[h] = (U32)(p-srcBase); return; }
+ case byU16: { U16* hashTable = (U16*) tableBase; hashTable[h] = (U16)(p-srcBase); return; }
}
}
@@ -411,32 +495,12 @@ static const BYTE* LZ4_getPosition(const BYTE* p, void* tableBase, tableType_t t
return LZ4_getPositionOnHash(h, tableBase, tableType, srcBase);
}
-static unsigned LZ4_count(const BYTE* pIn, const BYTE* pRef, const BYTE* pInLimit)
-{
- const BYTE* const pStart = pIn;
-
- while (likely(pIn<pInLimit-(STEPSIZE-1)))
- {
- size_t diff = AARCH(pRef) ^ AARCH(pIn);
- if (!diff) { pIn+=STEPSIZE; pRef+=STEPSIZE; continue; }
- pIn += LZ4_NbCommonBytes(diff);
- return (unsigned)(pIn - pStart);
- }
- if (LZ4_64BITS) if ((pIn<(pInLimit-3)) && (A32(pRef) == A32(pIn))) { pIn+=4; pRef+=4; }
- if ((pIn<(pInLimit-1)) && (A16(pRef) == A16(pIn))) { pIn+=2; pRef+=2; }
- if ((pIn<pInLimit) && (*pRef == *pIn)) pIn++;
-
- return (unsigned)(pIn - pStart);
-}
-
-
static int LZ4_compress_generic(
void* ctx,
const char* source,
char* dest,
int inputSize,
int maxOutputSize,
-
limitedOutput_directive outputLimited,
tableType_t tableType,
dict_directive dict,
@@ -459,7 +523,6 @@ static int LZ4_compress_generic(
BYTE* op = (BYTE*) dest;
BYTE* const olimit = op + maxOutputSize;
- const int skipStrength = SKIPSTRENGTH;
U32 forwardH;
size_t refDelta=0;
@@ -481,8 +544,8 @@ static int LZ4_compress_generic(
lowLimit = (const BYTE*)source;
break;
}
- if ((tableType == byU16) && (inputSize>=(int)LZ4_64KLIMIT)) return 0; /* Size too large (not within 64K limit) */
- if (inputSize<LZ4_minLength) goto _last_literals; /* Input too small, no compression (all literals) */
+ if ((tableType == byU16) && (inputSize>=LZ4_64Klimit)) return 0; /* Size too large (not within 64K limit) */
+ if (inputSize<LZ4_minLength) goto _last_literals; /* Input too small, no compression (all literals) */
/* First Byte */
LZ4_putPosition(ip, ctx, tableType, base);
@@ -491,26 +554,26 @@ static int LZ4_compress_generic(
/* Main Loop */
for ( ; ; )
{
- const BYTE* ref;
+ const BYTE* match;
BYTE* token;
{
const BYTE* forwardIp = ip;
unsigned step=1;
- unsigned searchMatchNb = (1U << skipStrength);
+ unsigned searchMatchNb = (1U << LZ4_skipTrigger);
/* Find a match */
do {
U32 h = forwardH;
ip = forwardIp;
forwardIp += step;
- step = searchMatchNb++ >> skipStrength;
+ step = searchMatchNb++ >> LZ4_skipTrigger;
if (unlikely(forwardIp > mflimit)) goto _last_literals;
- ref = LZ4_getPositionOnHash(h, ctx, tableType, base);
+ match = LZ4_getPositionOnHash(h, ctx, tableType, base);
if (dict==usingExtDict)
{
- if (ref<(const BYTE*)source)
+ if (match<(const BYTE*)source)
{
refDelta = dictDelta;
lowLimit = dictionary;
@@ -524,13 +587,13 @@ static int LZ4_compress_generic(
forwardH = LZ4_hashPosition(forwardIp, tableType);
LZ4_putPositionOnHash(ip, h, ctx, tableType, base);
- } while ( ((dictIssue==dictSmall) ? (ref < lowRefLimit) : 0)
- || ((tableType==byU16) ? 0 : (ref + MAX_DISTANCE < ip))
- || (A32(ref+refDelta) != A32(ip)) );
+ } while ( ((dictIssue==dictSmall) ? (match < lowRefLimit) : 0)
+ || ((tableType==byU16) ? 0 : (match + MAX_DISTANCE < ip))
+ || (LZ4_read32(match+refDelta) != LZ4_read32(ip)) );
}
/* Catch up */
- while ((ip>anchor) && (ref+refDelta > lowLimit) && (unlikely(ip[-1]==ref[refDelta-1]))) { ip--; ref--; }
+ while ((ip>anchor) && (match+refDelta > lowLimit) && (unlikely(ip[-1]==match[refDelta-1]))) { ip--; match--; }
{
/* Encode Literal length */
@@ -548,12 +611,13 @@ static int LZ4_compress_generic(
else *token = (BYTE)(litLength<<ML_BITS);
/* Copy Literals */
- { BYTE* end = op+litLength; LZ4_WILDCOPY(op,anchor,end); op=end; }
+ LZ4_wildCopy(op, anchor, op+litLength);
+ op+=litLength;
}
_next_match:
/* Encode Offset */
- LZ4_WRITE_LITTLEENDIAN_16(op, (U16)(ip-ref));
+ LZ4_writeLE16(op, (U16)(ip-match)); op+=2;
/* Encode MatchLength */
{
@@ -562,10 +626,10 @@ _next_match:
if ((dict==usingExtDict) && (lowLimit==dictionary))
{
const BYTE* limit;
- ref += refDelta;
- limit = ip + (dictEnd-ref);
+ match += refDelta;
+ limit = ip + (dictEnd-match);
if (limit > matchlimit) limit = matchlimit;
- matchLength = LZ4_count(ip+MINMATCH, ref+MINMATCH, limit);
+ matchLength = LZ4_count(ip+MINMATCH, match+MINMATCH, limit);
ip += MINMATCH + matchLength;
if (ip==limit)
{
@@ -576,14 +640,14 @@ _next_match:
}
else
{
- matchLength = LZ4_count(ip+MINMATCH, ref+MINMATCH, matchlimit);
+ matchLength = LZ4_count(ip+MINMATCH, match+MINMATCH, matchlimit);
ip += MINMATCH + matchLength;
}
+ if ((outputLimited) && (unlikely(op + (1 + LASTLITERALS) + (matchLength>>8) > olimit)))
+ return 0; /* Check output limit */
if (matchLength>=ML_MASK)
{
- if ((outputLimited) && (unlikely(op + (1 + LASTLITERALS) + (matchLength>>8) > olimit)))
- return 0; /* Check output limit */
*token += ML_MASK;
matchLength -= ML_MASK;
for (; matchLength >= 510 ; matchLength-=510) { *op++ = 255; *op++ = 255; }
@@ -602,10 +666,10 @@ _next_match:
LZ4_putPosition(ip-2, ctx, tableType, base);
/* Test next position */
- ref = LZ4_getPosition(ip, ctx, tableType, base);
+ match = LZ4_getPosition(ip, ctx, tableType, base);
if (dict==usingExtDict)
{
- if (ref<(const BYTE*)source)
+ if (match<(const BYTE*)source)
{
refDelta = dictDelta;
lowLimit = dictionary;
@@ -617,9 +681,9 @@ _next_match:
}
}
LZ4_putPosition(ip, ctx, tableType, base);
- if ( ((dictIssue==dictSmall) ? (ref>=lowRefLimit) : 1)
- && (ref+MAX_DISTANCE>=ip)
- && (A32(ref+refDelta)==A32(ip)) )
+ if ( ((dictIssue==dictSmall) ? (match>=lowRefLimit) : 1)
+ && (match+MAX_DISTANCE>=ip)
+ && (LZ4_read32(match+refDelta)==LZ4_read32(ip)) )
{ token=op++; *token=0; goto _next_match; }
/* Prepare next loop */
@@ -646,16 +710,16 @@ _last_literals:
int LZ4_compress(const char* source, char* dest, int inputSize)
{
#if (HEAPMODE)
- void* ctx = ALLOCATOR(LZ4_STREAMSIZE_U32, 4); /* Aligned on 4-bytes boundaries */
+ void* ctx = ALLOCATOR(LZ4_STREAMSIZE_U64, 8); /* Aligned on 8-bytes boundaries */
#else
- U32 ctx[LZ4_STREAMSIZE_U32] = {0}; /* Ensure data is aligned on 4-bytes boundaries */
+ U64 ctx[LZ4_STREAMSIZE_U64] = {0}; /* Ensure data is aligned on 8-bytes boundaries */
#endif
int result;
- if (inputSize < (int)LZ4_64KLIMIT)
+ if (inputSize < LZ4_64Klimit)
result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, 0, notLimited, byU16, noDict, noDictIssue);
else
- result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, 0, notLimited, LZ4_64BITS ? byU32 : byPtr, noDict, noDictIssue);
+ result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, 0, notLimited, LZ4_64bits() ? byU32 : byPtr, noDict, noDictIssue);
#if (HEAPMODE)
FREEMEM(ctx);
@@ -666,16 +730,16 @@ int LZ4_compress(const char* source, char* dest, int inputSize)
int LZ4_compress_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize)
{
#if (HEAPMODE)
- void* ctx = ALLOCATOR(LZ4_STREAMSIZE_U32, 4); /* Aligned on 4-bytes boundaries */
+ void* ctx = ALLOCATOR(LZ4_STREAMSIZE_U64, 8); /* Aligned on 8-bytes boundaries */
#else
- U32 ctx[LZ4_STREAMSIZE_U32] = {0}; /* Ensure data is aligned on 4-bytes boundaries */
+ U64 ctx[LZ4_STREAMSIZE_U64] = {0}; /* Ensure data is aligned on 8-bytes boundaries */
#endif
int result;
- if (inputSize < (int)LZ4_64KLIMIT)
+ if (inputSize < LZ4_64Klimit)
result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, maxOutputSize, limitedOutput, byU16, noDict, noDictIssue);
else
- result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, maxOutputSize, limitedOutput, LZ4_64BITS ? byU32 : byPtr, noDict, noDictIssue);
+ result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, maxOutputSize, limitedOutput, LZ4_64bits() ? byU32 : byPtr, noDict, noDictIssue);
#if (HEAPMODE)
FREEMEM(ctx);
@@ -700,7 +764,7 @@ void LZ4_resetStream (LZ4_stream_t* LZ4_stream)
LZ4_stream_t* LZ4_createStream(void)
{
- LZ4_stream_t* lz4s = (LZ4_stream_t*)ALLOCATOR(4, LZ4_STREAMSIZE_U32);
+ LZ4_stream_t* lz4s = (LZ4_stream_t*)ALLOCATOR(8, LZ4_STREAMSIZE_U64);
LZ4_STATIC_ASSERT(LZ4_STREAMSIZE >= sizeof(LZ4_stream_t_internal)); /* A compilation error here means LZ4_STREAMSIZE is not large enough */
LZ4_resetStream(lz4s);
return lz4s;
@@ -956,14 +1020,16 @@ FORCE_INLINE int LZ4_decompress_generic(
op += length;
break; /* Necessarily EOF, due to parsing restrictions */
}
- LZ4_WILDCOPY(op, ip, cpy); ip -= (op-cpy); op = cpy;
+ LZ4_wildCopy(op, ip, cpy);
+ ip += length; op = cpy;
/* get offset */
- LZ4_READ_LITTLEENDIAN_16(match,cpy,ip); ip+=2;
+ match = cpy - LZ4_readLE16(ip); ip+=2;
if ((checkOffset) && (unlikely(match < lowLimit))) goto _output_error; /* Error : offset outside destination buffer */
/* get matchlength */
- if ((length=(token&ML_MASK)) == ML_MASK)
+ length = token & ML_MASK;
+ if (length == ML_MASK)
{
unsigned s;
do
@@ -1012,7 +1078,7 @@ FORCE_INLINE int LZ4_decompress_generic(
/* copy repeated sequence */
cpy = op + length;
- if (unlikely((op-match)<(int)STEPSIZE))
+ if (unlikely((op-match)<8))
{
const size_t dec64 = dec64table[op-match];
op[0] = match[0];
@@ -1020,17 +1086,23 @@ FORCE_INLINE int LZ4_decompress_generic(
op[2] = match[2];
op[3] = match[3];
match += dec32table[op-match];
- A32(op+4) = A32(match);
+ LZ4_copy4(op+4, match);
op += 8; match -= dec64;
- } else { LZ4_COPY8(op,match); }
+ } else { LZ4_copy8(op, match); op+=8; match+=8; }
if (unlikely(cpy>oend-12))
{
- if (cpy > oend-LASTLITERALS) goto _output_error; /* Error : last 5 bytes must be literals */
- if (op<oend-COPYLENGTH) LZ4_WILDCOPY(op, match, (oend-COPYLENGTH));
- while(op<cpy) *op++=*match++;
+ if (cpy > oend-LASTLITERALS) goto _output_error; /* Error : last LASTLITERALS bytes must be literals */
+ if (op < oend-8)
+ {
+ LZ4_wildCopy(op, match, oend-8);
+ match += (oend-8) - op;
+ op = oend-8;
+ }
+ while (op<cpy) *op++ = *match++;
}
- else LZ4_WILDCOPY(op, match, cpy);
+ else
+ LZ4_wildCopy(op, match, cpy);
op=cpy; /* correction */
}
@@ -1079,7 +1151,7 @@ typedef struct
*/
LZ4_streamDecode_t* LZ4_createStreamDecode(void)
{
- LZ4_streamDecode_t* lz4s = (LZ4_streamDecode_t*) ALLOCATOR(sizeof(U32), LZ4_STREAMDECODESIZE_U32);
+ LZ4_streamDecode_t* lz4s = (LZ4_streamDecode_t*) ALLOCATOR(sizeof(U64), LZ4_STREAMDECODESIZE_U64);
return lz4s;
}
@@ -1241,18 +1313,16 @@ int LZ4_resetStreamState(void* state, const char* inputBuffer)
void* LZ4_create (const char* inputBuffer)
{
- void* lz4ds = ALLOCATOR(4, LZ4_STREAMSIZE_U32);
+ void* lz4ds = ALLOCATOR(8, LZ4_STREAMSIZE_U64);
LZ4_init ((LZ4_stream_t_internal*)lz4ds, (const BYTE*)inputBuffer);
return lz4ds;
}
char* LZ4_slideInputBuffer (void* LZ4_Data)
{
- LZ4_stream_t_internal* lz4ds = (LZ4_stream_t_internal*)LZ4_Data;
-
- LZ4_saveDict((LZ4_stream_t*)LZ4_Data, (char*)lz4ds->bufferStart, 64 KB);
-
- return (char*)(lz4ds->bufferStart + 64 KB);
+ LZ4_stream_t_internal* ctx = (LZ4_stream_t_internal*)LZ4_Data;
+ int dictSize = LZ4_saveDict((LZ4_stream_t*)ctx, (char*)ctx->bufferStart, 64 KB);
+ return (char*)(ctx->bufferStart + dictSize);
}
/* Obsolete compresson functions using User-allocated state */
@@ -1264,10 +1334,10 @@ int LZ4_compress_withState (void* state, const char* source, char* dest, int inp
if (((size_t)(state)&3) != 0) return 0; /* Error : state is not aligned on 4-bytes boundary */
MEM_INIT(state, 0, LZ4_STREAMSIZE);
- if (inputSize < (int)LZ4_64KLIMIT)
+ if (inputSize < LZ4_64Klimit)
return LZ4_compress_generic(state, source, dest, inputSize, 0, notLimited, byU16, noDict, noDictIssue);
else
- return LZ4_compress_generic(state, source, dest, inputSize, 0, notLimited, LZ4_64BITS ? byU32 : byPtr, noDict, noDictIssue);
+ return LZ4_compress_generic(state, source, dest, inputSize, 0, notLimited, LZ4_64bits() ? byU32 : byPtr, noDict, noDictIssue);
}
int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize)
@@ -1275,10 +1345,10 @@ int LZ4_compress_limitedOutput_withState (void* state, const char* source, char*
if (((size_t)(state)&3) != 0) return 0; /* Error : state is not aligned on 4-bytes boundary */
MEM_INIT(state, 0, LZ4_STREAMSIZE);
- if (inputSize < (int)LZ4_64KLIMIT)
+ if (inputSize < LZ4_64Klimit)
return LZ4_compress_generic(state, source, dest, inputSize, maxOutputSize, limitedOutput, byU16, noDict, noDictIssue);
else
- return LZ4_compress_generic(state, source, dest, inputSize, maxOutputSize, limitedOutput, LZ4_64BITS ? byU32 : byPtr, noDict, noDictIssue);
+ return LZ4_compress_generic(state, source, dest, inputSize, maxOutputSize, limitedOutput, LZ4_64bits() ? byU32 : byPtr, noDict, noDictIssue);
}
/* Obsolete streaming decompression functions */
@@ -1292,3 +1362,6 @@ int LZ4_decompress_fast_withPrefix64k(const char* source, char* dest, int origin
{
return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, withPrefix64k, (BYTE*)dest - 64 KB, NULL, 64 KB);
}
+
+#endif /* LZ4_COMMONDEFS_ONLY */
+
diff --git a/src/helpers/fst/lz4.h b/src/helpers/fst/lz4.h
index 0350f6a..7778caa 100644
--- a/src/helpers/fst/lz4.h
+++ b/src/helpers/fst/lz4.h
@@ -46,8 +46,8 @@ 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_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);
@@ -169,17 +169,19 @@ int LZ4_decompress_safe_partial (const char* source, char* dest, int compressedS
/***********************************************
- Experimental Streaming Compression Functions
+ Streaming Compression Functions
***********************************************/
-#define LZ4_STREAMSIZE_U32 ((1 << (LZ4_MEMORY_USAGE-2)) + 8)
-#define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U32 * sizeof(unsigned int))
+#define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4)
+#define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(long long))
/*
* LZ4_stream_t
* information structure to track an LZ4 stream.
* important : init this structure content before first use !
+ * note : only allocated directly the structure if you are statically linking LZ4
+ * If you are using liblz4 as a DLL, please use below construction methods instead.
*/
-typedef struct { unsigned int table[LZ4_STREAMSIZE_U32]; } LZ4_stream_t;
+typedef struct { long long table[LZ4_STREAMSIZE_U64]; } LZ4_stream_t;
/*
* LZ4_resetStream
@@ -188,9 +190,10 @@ typedef struct { unsigned int table[LZ4_STREAMSIZE_U32]; } LZ4_stream_t;
void LZ4_resetStream (LZ4_stream_t* LZ4_streamPtr);
/*
- * If you prefer dynamic allocation methods,
* LZ4_createStream will allocate and initialize an LZ4_stream_t structure
* LZ4_freeStream releases its memory.
+ * In the context of a DLL (liblz4), please use these methods rather than the static struct.
+ * They are more future proof, in case of a change of LZ4_stream_t size.
*/
LZ4_stream_t* LZ4_createStream(void);
int LZ4_freeStream (LZ4_stream_t* LZ4_streamPtr);
@@ -231,20 +234,19 @@ int LZ4_saveDict (LZ4_stream_t* LZ4_streamPtr, char* safeBuffer, int dictSize);
/************************************************
- Experimental Streaming Decompression Functions
+ Streaming Decompression Functions
************************************************/
-#define LZ4_STREAMDECODESIZE_U32 8
-#define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U32 * sizeof(unsigned int))
+#define LZ4_STREAMDECODESIZE_U64 4
+#define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long))
+typedef struct { unsigned long long table[LZ4_STREAMDECODESIZE_U64]; } LZ4_streamDecode_t;
/*
* LZ4_streamDecode_t
* information structure to track an LZ4 stream.
- * important : init this structure content using LZ4_setStreamDecode or memset() before first use !
- */
-typedef struct { unsigned int table[LZ4_STREAMDECODESIZE_U32]; } LZ4_streamDecode_t;
-
-/*
- * If you prefer dynamic allocation methods,
+ * init this structure content using LZ4_setStreamDecode or memset() before first use !
+ *
+ * In the context of a DLL (liblz4) please prefer usage of construction methods below.
+ * They are more future proof, in case of a change of LZ4_streamDecode_t size in the future.
* LZ4_createStreamDecode will allocate and initialize an LZ4_streamDecode_t structure
* LZ4_freeStreamDecode releases its memory.
*/
@@ -254,9 +256,7 @@ int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream);
/*
* LZ4_setStreamDecode
* Use this function to instruct where to find the dictionary.
- * This function can be used to specify a static dictionary,
- * or to instruct where to find some previously decoded data saved into a different memory space.
- * Setting a size of 0 is allowed (same effect as no dictionary, same effect as reset).
+ * Setting a size of 0 is allowed (same effect as reset).
* Return : 1 if OK, 0 if error
*/
int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize);
@@ -277,7 +277,7 @@ Advanced decoding functions :
*_usingDict() :
These decoding functions work the same as
a combination of LZ4_setDictDecode() followed by LZ4_decompress_x_continue()
- They don't use nor update an LZ4_streamDecode_t structure.
+ They are stand-alone and don't use nor update an LZ4_streamDecode_t structure.
*/
int LZ4_decompress_safe_usingDict (const char* source, char* dest, int compressedSize, int maxDecompressedSize, const char* dictStart, int dictSize);
int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalSize, const char* dictStart, int dictSize);
@@ -294,18 +294,10 @@ They are only provided here for compatibility with older user programs.
- LZ4_uncompress is the same as LZ4_decompress_fast
- LZ4_uncompress_unknownOutputSize is the same as LZ4_decompress_safe
These function prototypes are now disabled; uncomment them if you really need them.
-It is highly recommended to stop using these functions and migrated to newer ones */
+It is highly recommended to stop using these functions and migrate to newer ones */
/* int LZ4_uncompress (const char* source, char* dest, int outputSize); */
/* int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize); */
-/*
- * If you prefer dynamic allocation methods,
- * LZ4_createStreamDecode()
- * provides a pointer (void*) towards an initialized LZ4_streamDecode_t structure.
- * LZ4_free just frees it.
- */
-/* void* LZ4_createStreamDecode(void); */
-/*int LZ4_free (void* LZ4_stream); yes, it's the same one as for compression */
/* Obsolete streaming functions; use new streaming interface whenever possible */
void* LZ4_create (const char* inputBuffer);
diff --git a/src/helpers/vzt_read.c b/src/helpers/vzt_read.c
index 8446bb5..570ff32 100644
--- a/src/helpers/vzt_read.c
+++ b/src/helpers/vzt_read.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2014 Tony Bybell.
+ * Copyright (c) 2003-2015 Tony Bybell.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -273,7 +273,7 @@ return((x * 0x01010101) >> 24);
* "return the bitposition of the least significant 1 in vztint32_t"
* (use x &= ~(x&-x) to clear out that bit quickly)
*/
-_VZT_RD_INLINE vztint32_t
+_VZT_RD_INLINE static vztint32_t
vzt_rd_tzc(vztint32_t x)
{
return (vzt_rd_ones_cnt((x & -x) - 1));
@@ -1290,7 +1290,7 @@ return(rc);
}
-_VZT_RD_INLINE vztint64_t vzt_rd_get_block_mem_usage(struct vzt_rd_trace *lt)
+vztint64_t vzt_rd_get_block_mem_usage(struct vzt_rd_trace *lt)
{
vztint64_t mem;
diff --git a/src/strace.c b/src/strace.c
index 125c164..d8e766e 100644
--- a/src/strace.c
+++ b/src/strace.c
@@ -1408,8 +1408,8 @@ void strace_maketimetrace(int mode)
TimeType basetime=GLOBALS->tims.first;
TimeType endtime =MAX_HISTENT_TIME;
int i, notfirst=0;
-struct timechain *tchead=NULL, *tc=NULL, *tcnext;
TimeType *t;
+int t_allocated;
if(GLOBALS->strace_ctx->timearray)
{
@@ -1457,6 +1457,9 @@ if(basetime>endtime)
endtime =tmp;
}
+t_allocated = 1;
+t = malloc_2(sizeof(TimeType) * t_allocated);
+
while(1)
{
basetime=strace_timetrace(basetime, notfirst);
@@ -1471,40 +1474,22 @@ while(1)
if(basetime>endtime) break; /* formerly was >= which didn't mark the endpoint if true which is incorrect */
} /* i.e., if start is markable, end should be also */
+ t[GLOBALS->strace_ctx->timearray_size] = basetime;
GLOBALS->strace_ctx->timearray_size++;
-
- if(!tc)
- {
- tchead=tc=malloc_2(sizeof(struct timechain)); /* formerly wave_alloca but that dies > 4MB on linux x86! */
- }
- else
+ if(GLOBALS->strace_ctx->timearray_size == t_allocated)
{
- tc->next=malloc_2(sizeof(struct timechain)); /* formerly wave_alloca but that dies > 4MB on linux x86! */
- tc=tc->next;
+ t_allocated *= 2;
+ t = realloc_2(t, sizeof(TimeType) * t_allocated);
}
-
- tc->t=basetime;
- tc->next=NULL;
}
if(GLOBALS->strace_ctx->timearray_size)
{
- GLOBALS->strace_ctx->timearray=t=malloc_2(sizeof(TimeType)*GLOBALS->strace_ctx->timearray_size);
- for(i=0;i<GLOBALS->strace_ctx->timearray_size;i++)
- {
- if(!tchead) /* should never happen */
- {
- free_2(GLOBALS->strace_ctx->timearray); GLOBALS->strace_ctx->timearray = NULL;
- break;
- }
- *(t++)=tchead->t; /* scan-build null pointer deref found here */
- tcnext=tchead->next;
- free_2(tchead); /* need to explicitly free this up now */
- tchead=tcnext;
- }
+ GLOBALS->strace_ctx->timearray = realloc_2(t, sizeof(TimeType) * GLOBALS->strace_ctx->timearray_size);
}
else
{
+ free_2(t);
GLOBALS->strace_ctx->timearray = NULL;
}
diff --git a/src/treesearch_gtk2.c b/src/treesearch_gtk2.c
index a07618d..b9b06ba 100644
--- a/src/treesearch_gtk2.c
+++ b/src/treesearch_gtk2.c
@@ -218,7 +218,7 @@ fill_sig_store (void)
if (
(GLOBALS->filter_str_treesearch_gtk2_c_1 == NULL) ||
((!GLOBALS->filter_noregex_treesearch_gtk2_c_1) && (wrexm = wave_regex_match(t->name, WAVE_REGEX_TREE)) && (!GLOBALS->filter_matlen_treesearch_gtk2_c_1)) ||
- (GLOBALS->filter_matlen_treesearch_gtk2_c_1 && (GLOBALS->filter_typ_treesearch_gtk2_c_1 == vardir) &&
+ (GLOBALS->filter_matlen_treesearch_gtk2_c_1 && ((GLOBALS->filter_typ_treesearch_gtk2_c_1 == vardir) ^ GLOBALS->filter_typ_polarity_treesearch_gtk2_c_1) &&
(wrexm || (wrexm = wave_regex_match(t->name, WAVE_REGEX_TREE))) )
)
{
@@ -709,6 +709,7 @@ gboolean filter_edit_cb (GtkWidget *widget, GdkEventKey *ev, gpointer *data)
strcpy(GLOBALS->filter_str_treesearch_gtk2_c_1, t);
GLOBALS->filter_typ_treesearch_gtk2_c_1 = ND_DIR_UNSPECIFIED;
+ GLOBALS->filter_typ_polarity_treesearch_gtk2_c_1 = 0;
GLOBALS->filter_matlen_treesearch_gtk2_c_1 = 0;
GLOBALS->filter_noregex_treesearch_gtk2_c_1 = 0;
@@ -731,6 +732,27 @@ gboolean filter_edit_cb (GtkWidget *widget, GdkEventKey *ev, gpointer *data)
}
}
}
+ else
+ if(GLOBALS->filter_str_treesearch_gtk2_c_1[0] == '-')
+ {
+ for(i=0;i<=ND_DIR_MAX;i++)
+ {
+ int tlen = strlen(vardir_strings[i]);
+ if(!strncasecmp(vardir_strings[i], GLOBALS->filter_str_treesearch_gtk2_c_1 + 1, tlen))
+ {
+ if(GLOBALS->filter_str_treesearch_gtk2_c_1[tlen + 1] == '-')
+ {
+ GLOBALS->filter_matlen_treesearch_gtk2_c_1 = tlen + 2;
+ GLOBALS->filter_typ_treesearch_gtk2_c_1 = i;
+ GLOBALS->filter_typ_polarity_treesearch_gtk2_c_1 = 1; /* invert via XOR with 1 */
+ if(GLOBALS->filter_str_treesearch_gtk2_c_1[tlen + 2] == 0)
+ {
+ GLOBALS->filter_noregex_treesearch_gtk2_c_1 = 1;
+ }
+ }
+ }
+ }
+ }
wave_regex_compile(GLOBALS->filter_str_treesearch_gtk2_c_1 + GLOBALS->filter_matlen_treesearch_gtk2_c_1, WAVE_REGEX_TREE);
}
@@ -1627,7 +1649,8 @@ do_tooltips:
"Add a POSIX filter. "
"'.*' matches any number of characters,"
" '.' matches any character. Hit Return to apply."
- " The filter may be preceded with the port direction if it exists such as +I+, +O+, +IO+, etc.",
+ " The filter may be preceded with the port direction if it exists such as ++ (show only non-port), +I+, +O+, +IO+, etc."
+ " Use -- to exclude all non-ports (i.e., show only all ports), -I- to exclude all input ports, etc.",
NULL);
gtk_box_pack_start (GTK_BOX (filter_hbox), GLOBALS->filter_entry, FALSE, FALSE, 1);
@@ -1906,7 +1929,8 @@ GtkWidget* treeboxframe(char *title, GtkSignalFunc func)
"Add a POSIX filter. "
"'.*' matches any number of characters,"
" '.' matches any character. Hit Return to apply."
- " The filter may be preceded with the port direction if it exists such as +I+, +O+, +IO+, etc.",
+ " The filter may be preceded with the port direction if it exists such as ++ (show only non-port), +I+, +O+, +IO+, etc."
+ " Use -- to exclude all non-ports (i.e., show only all ports), -I- to exclude all input ports, etc.",
NULL);
gtk_box_pack_start (GTK_BOX (filter_hbox), GLOBALS->filter_entry, FALSE, FALSE, 1);
diff --git a/src/vcd.c b/src/vcd.c
index f7114cd..30e605b 100644
--- a/src/vcd.c
+++ b/src/vcd.c
@@ -2302,7 +2302,8 @@ while(v)
}
else /* atomic vector */
{
- if((v->vartype!=V_REAL)&&(v->vartype!=V_STRINGTYPE))
+ if((v->vartype!=V_REAL)&&(v->vartype!=V_STRINGTYPE)&&(v->vartype!=V_INTEGER)&&(v->vartype!=V_PARAMETER))
+ /* if((v->vartype!=V_REAL)&&(v->vartype!=V_STRINGTYPE)) */
{
sprintf(str+slen-1,"[%d:%d]",v->msi,v->lsi);
}
diff --git a/src/vcd_partial.c b/src/vcd_partial.c
index 1255f75..142cfb9 100644
--- a/src/vcd_partial.c
+++ b/src/vcd_partial.c
@@ -2153,7 +2153,8 @@ while(v)
}
else /* atomic vector */
{
- if((v->vartype!=V_REAL)&&(v->vartype!=V_STRINGTYPE))
+ if((v->vartype!=V_REAL)&&(v->vartype!=V_STRINGTYPE)&&(v->vartype!=V_INTEGER)&&(v->vartype!=V_PARAMETER))
+ /* if((v->vartype!=V_REAL)&&(v->vartype!=V_STRINGTYPE)) */
{
sprintf(str+slen-1,"[%d:%d]",v->msi,v->lsi);
}
diff --git a/src/vcd_recoder.c b/src/vcd_recoder.c
index ce1a9aa..8a66f19 100644
--- a/src/vcd_recoder.c
+++ b/src/vcd_recoder.c
@@ -2532,7 +2532,8 @@ while(v)
}
else /* atomic vector */
{
- if((v->vartype!=V_REAL)&&(v->vartype!=V_STRINGTYPE))
+ if((v->vartype!=V_REAL)&&(v->vartype!=V_STRINGTYPE)&&(v->vartype!=V_INTEGER)&&(v->vartype!=V_PARAMETER))
+ /* if((v->vartype!=V_REAL)&&(v->vartype!=V_STRINGTYPE)) */
{
sprintf(str+slen-1,"[%d:%d]",v->msi,v->lsi);
}
diff --git a/src/version.h b/src/version.h
index b10bb69..613ce77 100644
--- a/src/version.h
+++ b/src/version.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) Tony Bybell 2010-2014.
+ * Copyright (c) Tony Bybell 2010-2015.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -10,6 +10,6 @@
#ifndef WAVE_VERSION_H
#define WAVE_VERSION_H
-#define WAVE_VERSION_INFO "GTKWave Analyzer v" PACKAGE_VERSION " (w)1999-2014 BSI"
+#define WAVE_VERSION_INFO "GTKWave Analyzer v" PACKAGE_VERSION " (w)1999-2015 BSI"
#endif
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-electronics/gtkwave.git
More information about the Pkg-electronics-commits
mailing list