Commit graph

91 commits

Author SHA1 Message Date
Maximilien Colange
878649c823 [buddy] Add an option to enable C++14.
* configure.ac: add an option --enable-c++14.
2016-12-13 17:42:22 +01:00
Alexandre Duret-Lutz
38c4fc8812 [buddy] fix bdd_noderesize
* src/kernel.c: Fix error introduced by 5a862295.
Report from Tomáš Babiak.
2016-11-19 16:46:10 +01:00
Alexandre Duret-Lutz
0ac14e9ca2 [buddy] avoid costly calls to setjmp() when BDD_REORDER_NONE
* src/reorder.c, src/kernel.h: Expose bddreordermethod.
* src/bddop.c: Test bddreordermethod before ever calling setjmp().
2016-11-09 14:52:04 +01:00
Alexandre Duret-Lutz
84b16aa6bd [buddy] consolidate shortcuts for binary operation
* src/bddop.c (apply_rec, appquant_rec): Define missing shortcuts
for bddop_less, bddop_diff, bddop_revimpl and define them once.
2016-11-09 10:29:00 +01:00
Alexandre Duret-Lutz
5a862295d3 [buddy] improve initialization of bddnode
* src/kernel.c, src/kernel.h: Here.
2016-11-08 19:03:08 +01:00
Alexandre Duret-Lutz
63818a3e69 [buddy] Fix several PVS-Studio warnings
For #192.

* src/bddio.c, src/cppext.cxx, src/kernel.c: Fix printf formats, calls
to new, and simplify one check in bdd_delref_nc().
2016-10-28 17:12:21 +02:00
Alexandre Duret-Lutz
a32ccd649d [buddy] slight optimization of bdd_implies
* src/bddop.c: Avoid the first recursion when it is obvious that the
second will fail.
2016-10-20 20:59:28 +02:00
Alexandre Duret-Lutz
57a055b656 [buddy] typo in comment
* src/bddop.c (bdd_implies): Fix documentation.
2016-10-20 09:37:24 +02:00
Alexandre Duret-Lutz
4c1147e497 [buddy] speedup bdd_init and bdd_noderesize
* src/kernel.c: The initialization code of the BDD cache was
awfully slow due to multiple references to global variables.
2016-10-19 10:51:38 +02:00
Alexandre Duret-Lutz
8e69530023 [buddy] fix an undefined behavior
* src/prime.c (BitIsSet): Do not shift signed
int by 31 places; shift unsigned int instead.
2016-07-27 19:47:30 +02:00
Alexandre Duret-Lutz
86abd6c1c0 Use -Bsymbolic-functions and -Bsymbolic
This avoids dynamic lookups to resolve symbols inside the library, but
disallows symbol interposition.

* m4/symbolic.m4: New file.
* buddy/m4/symbolic.m4: New link.
* configure.ac, buddy/configure.ac: Add AX_SYMBOLIC.
* buddy/src/Makefile.am, iface/ltsmin/Makefile.am, src/Makefile.am,
wrap/python/Makefile.am: Link with $(SYMBOLIC_LDFLAGS).
2015-11-10 15:10:11 +01:00
Etienne Renault
5f4b7e1f3f Remove all cvsignore files.
* .cvsignore, bench/.cvsignore,
bench/emptchk/.cvsignore, bench/emptchk/models/.cvsignore,
bench/ltl2tgba/.cvsignore, buddy/.cvsignore,
buddy/doc/.cvsignore, buddy/examples/.cvsignore,
buddy/examples/adder/.cvsignore,
buddy/examples/bddcalc/.cvsignore,
buddy/examples/bddtest/.cvsignore,
buddy/examples/calculator/.cvsignore,
buddy/examples/cmilner/.cvsignore,
buddy/examples/fdd/.cvsignore,
buddy/examples/internal/.cvsignore,
buddy/examples/milner/.cvsignore,
buddy/examples/money/.cvsignore,
buddy/examples/queen/.cvsignore,
buddy/examples/solitare/.cvsignore,
buddy/src/.cvsignore, buddy/tools/.cvsignore,
doc/.cvsignore, iface/.cvsignore,
src/.cvsignore, src/ltlast/.cvsignore,
src/ltlenv/.cvsignore, src/ltlparse/.cvsignore,
src/ltlvisit/.cvsignore, src/misc/.cvsignore,
src/sanity/.cvsignore, src/tests/.cvsignore,
src/twa/.cvsignore, tools/.cvsignore,
wrap/.cvsignore, wrap/python/.cvsignore,
wrap/python/tests/.cvsignore: here.
2015-04-24 13:57:56 +02:00
Alexandre Duret-Lutz
1ffdd57383 [buddy] backport some fixes from upstream
* src/fdd.c, src/imatrix.c, src/kernel.c, src/reorder.c: Here.
2015-03-11 23:45:00 +01:00
Alexandre Duret-Lutz
787e3f9315 [buddy] fix undefined behavior
The bug was found while running Spot's src/tgbatest/randpsl.test
on Debian i386 with gcc-4.9.2.  The following call would crash:

./ltl2tgba -R3 -t '(!(F(({{{(p0) |
{[*0]}}:{{{(p1)}[*2]}[:*]}[*]:[*2]}[:*0..3]}[]-> (G(F(p1)))) &
(G((!(p1)) | ((!(p2)) W (G(!(p0)))))))))'

On amd64 the call does not crash, but valgrind nonetheless
report that uninitialized memory is being read by bdd_gbc()
during the second garbage collect.

* src/kernel.h (PUSHREF): Define as a function rather than a macro
to avoid undefined behavior.  See comments for details.
2015-03-10 15:44:08 +01:00
Alexandre Duret-Lutz
e55bcd95aa hoa: preliminary implementation of a parser
* src/hoaparse/Makefile.am, src/hoaparse/fmterror.cc,
src/hoaparse/hoaparse.yy, src/hoaparse/hoascan.ll,
src/hoaparse/parsedecl.hh, src/hoaparse/public.hh: New files.
* src/Makefile.am, configure.ac, README: Adjust.
* src/tgbatest/ltl2tgba.cc: Add a -XH option.
* src/tgbatest/hoaparse.test: New file.
* src/tgbatest/Makefile.am: Adjust.
* buddy/src/bddx.h: Add a bdd_from_int() function.
2014-11-19 19:29:29 +01:00
Alexandre Duret-Lutz
ad8d24222a buddy: rename libbdd to libbddx
* buddy/src/bdd.h, buddy/src/bvec.h, buddy/src/fdd.h: Rename as...
* buddy/src/bddx.h, buddy/src/bvecx.h, buddy/src/fddx.h: ... these.
* buddy/src/Makefile.am: Build libbddx.la instead of libbdd.la.
* buddy/examples/Makefile.def: Use it.
* Makefile.am, buddy/src/bddtest.cxx, buddy/src/bvec.c,
buddy/src/cppext.cxx, buddy/src/fdd.c, buddy/src/imatrix.h,
buddy/src/kernel.h, buddy/examples/adder/adder.cxx,
buddy/examples/bddcalc/parser_.h, buddy/examples/bddtest/bddtest.cxx,
buddy/examples/cmilner/cmilner.c, buddy/examples/fdd/fdd.cxx,
buddy/examples/milner/milner.cxx, buddy/examples/money/money.cxx,
buddy/examples/queen/queen.cxx, buddy/examples/solitare/solitare.cxx,
m4/buddy.m4, src/ltlvisit/apcollect.hh, src/ltlvisit/simplify.hh,
src/misc/bddlt.hh, src/misc/bddop.hh, src/misc/minato.hh,
src/priv/acccompl.hh, src/priv/accconv.hh, src/priv/accmap.hh,
src/priv/bddalloc.cc, src/tgba/bdddict.hh, src/tgba/bddprint.hh,
src/tgba/tgbamask.hh, src/tgba/tgbasafracomplement.cc,
src/tgbaalgos/emptiness.hh, src/tgbaalgos/gtec/sccstack.hh,
src/tgbaalgos/neverclaim.cc, src/tgbaalgos/powerset.cc,
src/tgbaalgos/sccfilter.hh, src/tgbaalgos/sccinfo.hh,
src/tgbaalgos/weight.hh, wrap/python/buddy.i: Adjust.
* NEWS, README: Document it.
2014-10-30 20:58:10 +01:00
Alexandre Duret-Lutz
971788fdbe [buddy] pack cache entry on 16 bytes, not 20.
The double result is never used with a triple keys,
so we can pack the cache entry more tightly.

* src/cache.h: Reorganize the cache entry the structure.
* src/cache.c: Cleanup the code while we are at it.
* src/bddop.c: Adjust to accesses to cache entries.
2014-10-28 13:13:05 +01:00
Alexandre Duret-Lutz
1244b61710 [buddy] Fix a harmless uninitialized read.
This can only cause failure when running under valgrind (i.e., in the
test suite), but is not a problem in practice as the test is certain
to fail the entry->c check whenever entry->b is uninitialized.

* src/bddop.c (bdd_implies): Here.
2014-08-11 00:21:42 +02:00
Alexandre Duret-Lutz
7d70229f5b [buddy] Improve handling of bddtrue and bddfalse.
* src/bdd.h, src/cppext.cxx: Handle bddtrue and bddfalse using
special types.
2014-06-20 18:38:58 +02:00
Alexandre Duret-Lutz
bd6d88db96 [buddy] Enable C++11 and add a move constructor/assignment operator.
* configure.ac: Enable C++11 mode.
* src/bdd.h: Use noexport, and add a move constructor and
move assignment operator.  The move version of these method
do not have to increment the reference counter, saving time.
On a small test run, this change saved 24% of the calls to
bdd_addref_nc().
2014-02-12 14:08:46 +01:00
Alexandre Duret-Lutz
cee552689a [buddy] Probe for -fvisibility and -fvisibility-inlines-hidden.
* configure.ac: Check gcc and g++ for -fvisibility and
-fvisibility-inlines-hidden.  Add these options to
CFLAGS and CXXFLAGS.
* m4/ax_check_compile_flag.m4: New file.
* src/Makefile.am: Build BuDDy as a single library, reverting part of
the changes introduced in my previous patch to this file.  Since
the options are set in CFLAGS/CXXFLAGS, there is no possibility
for -fvisibility-inlines-hidden to be passed to the C compiler.
2013-07-29 01:14:36 +02:00
Alexandre Duret-Lutz
b5710663f4 [buddy] Restrict the number of exported symbols.
* src/bdd.h, src/bvec.h, src/fdd.h: Declare all exported
symbols using BUDDY_API, a new macro that sets visibility=default.
* src/Makefile.am: Compile with -fvisibility=hidden by default,
and compile the C++ part with -fvisibility-inlines-hidden as well.
2013-07-29 01:12:12 +02:00
Alexandre Duret-Lutz
15c9b72f13 [buddy]
* src/bdd.h: Make all inplace operators return a reference.
2012-12-24 13:14:23 +01:00
Alexandre Duret-Lutz
af639e58c7 more files to ignore 2012-11-28 16:45:04 +01:00
Alexandre Duret-Lutz
8cb68d76b5 * NEWS, buddy/src/bddop.c, m4/valgrind.m4: s/wether/whether/. 2012-08-22 13:53:59 +02:00
Alexandre Duret-Lutz
bc5a4ba416 [buddy] Fix the recent Automake workaround for VPATH builds.
* examples/bddcalc/Makefile.am (ACLOCAL_AMFLAGS): Add -I. for
parse.c.  Reported by Pierre Parutto.
2012-06-20 20:56:03 +02:00
Alexandre Duret-Lutz
a814b97543 [buddy] Add a function bdd_implies to decide implications between BDDs.
* src/bdd.h (bdd_implies): New function.
* src/bddop.c (bdd_implies): Implement it.
(CACHEID_IMPLIES, IMPLIES_HASH): New helper macros.
2012-06-19 21:52:03 +02:00
Alexandre Duret-Lutz
e7a46e10e2 [buddy] Reduce the size of bddNode to improve cache efficiency.
The unicity table was mixed with the bddNode table for now
apparent reason.  After the hash of some node is computed,
bddnodes[hash] did only contain some random node (not the one
looked for) whose .hash member would point to the actual node with
this hash.  So that's a two step lookup.  With this patch, we sill
have a two step lookup, but the .hash member have been moved to a
separate array.  A consequence is that bddNode is now 16-byte long
(instead of 20) so it will never span across two cache lines.

* src/kernel.h (bddNode): Remove the hash member, and move it...
(bddhash): ... as this new separate table.
* src/kernel.c, src/reorder.c: Adjust all code.
2012-06-19 21:52:03 +02:00
Alexandre Duret-Lutz
b98c47246c [buddy] Adjust parser construction to support Automake 1.11 and 1.12.
* examples/bddcalc/parser.yxx: Rename as ...
* examples/bddcalc/parser.y: ... this.
* examples/bddcalc/parser_.cxx: New file that includes parser.c.
* examples/bddcalc/Makefile.am: Adjust.
* examples/bddcalc/parser.hxx: Delete this unused file.
2012-06-19 17:03:34 +02:00
Alexandre Duret-Lutz
b6702fc23a [buddy] Speedup hash functions.
* src/kernel.h (PAIR, TRIPLE): Redefine these hash functions
using something that is simpler to compute.
2012-04-28 09:34:43 +02:00
Alexandre Duret-Lutz
92ef9d6e07 * examples/adder/adder.cxx (test_vector): Add parentheses to
remove a clang++-2.9 warning.
2011-08-28 10:37:42 +02:00
Alexandre Duret-Lutz
24be6076f6 * src/bddop.c (bdd_support): Speedup using a cache. 2011-08-28 10:37:42 +02:00
Alexandre Duret-Lutz
fb3edb47e0 [buddy] * src/bddop.c (apply_rec, appquant_rec): Improve caching by
reordering operands of commutative operators.
2011-06-14 09:51:32 +02:00
Alexandre Duret-Lutz
d3ccaa7cb9 [buddy] Remove some valgrind warnings about uninitialized memory when
BddCache_lookup return an entry from a Not operation.

* src/bddop.c (apply_rec, simplify_rec): When checking the cache
entry, always check entry->a and entry->c before checking
entry->b, because the "not_rec()" function does not initialize
the latter.
2011-06-09 11:56:02 +02:00
Alexandre Duret-Lutz
b535741a90 [buddy] * examples/cmilner/cmilner.c (A, transitions, initial_state)
(reachable_states, has_deadlocks): Declare as static functions,
to suppress a GCC warning.
2011-06-07 14:52:35 +02:00
Alexandre Duret-Lutz
1d1872ab90 [buddy] Inline the "is bdd constant" check performed in copies/constructors.
This avoids a library call to bdd_addref or bdd_delref.

* src/kernel.c (bdd_delref_nc, bdd_addref_nc): New function,
that work only on BDD that are not constant.
* src/cpext.cxx (bdd::operator=): Move...
* src/bdd.hh (bdd::operator=): ... here.
(bdd::bdd, bdd::~bdd, bdd::operator=): Inline the "is bdd constant"
check and call bdd_delref_nc/bdd_addref_nc only otherwise.
2011-04-30 13:37:53 +02:00
Alexandre Duret-Lutz
2b58fb90c4 [buddy] Hint gcc about likely/unlikely branches.
* src/bdd.h (__likely, __unlikely): Introduce these two macros.
* src/bddop.c, src/kerner.c: Use them in many situations.
2011-04-30 13:30:13 +02:00
Alexandre Duret-Lutz
24054605da [buddy] * src/pairs.c (bdd_pairalloc): Fix prototype. 2011-04-30 13:22:27 +02:00
Alexandre Duret-Lutz
e5f35dea48 [buddy]
Fix some warnings reported by gcc.

* buddy/src/kernel.c (errorstrings): Mark these as const.
* buddy/src/reorder.c (reorder_gbc): Fix prototype.
(siftTestCmp): Add missing const in cast.
(bdd_reorder_auto): Actually call bdd_reorder_ready().
2011-04-10 22:12:25 +02:00
Alexandre Duret-Lutz
35de7e9008 [buddy]
Add support for --enable-devel and similar macros.

* m4/debug.m4: Rename to ...
* m4/bdebug.m4: ... this.
* m4/debug.m4, m4/devel.m4, m4/gccoptim.m4, m4/ndebug.m4: New file.
* m4/gccwarns.m4: Fix usage of cache variable.  Fix shell
syntax.  Do not check for -Waggregate-return.  Update CFLAGS.
* configure.ac: Adjust to handle --enable-devel and similar macros
in the same way as Spot.
2011-04-10 22:12:25 +02:00
Alexandre Duret-Lutz
5fdfe28689 [buddy]
Tag functions with attributes pure, const, or noreturn.

* src/bdd.h (__purefn, __constfn, __noreturnfn): Define
new macros.
* src/bdd.h, src/bddio.c, src/bvec.h, src/imatrix.h: Use them
to tag many functions as suggested by -Wsuggest-attribute=pure,
-Wsuggest-attribute=const, -Wsuggest-attribute=noreturn.
2011-04-05 09:29:03 +02:00
Alexandre Duret-Lutz
61d9e721a0 [buddy]
Remove more sanity checks when NDEBUG is set.

* src/kernel.h (CHECKnc): New macro.
* src/kernel.c (bdd_var, bdd_low, bdd_high, bdd_ithvar,
bdd_nithvar): Use it.
2011-04-04 19:10:06 +02:00
Alexandre Duret-Lutz
30f00584d4 [buddy]
* src/kernel.h (CHECK, CHECKa, CHECKn): Disable if NDEBUG is set.
2011-04-03 14:28:45 +02:00
Alexandre Duret-Lutz
44aed5cda6 [buddy]
Fix declaration of bddproduced.

* src/reorder.c (bddproduced): Declare a longint, to match
the definition in kerner.c.
2011-04-03 13:54:01 +02:00
Alexandre Duret-Lutz
197019ea62 [buddy]
* buddy/src/kernel.c (bdd_addref, bdd_delref): Disable sanity
checks when compiled with NDEBUG.
2011-04-03 10:49:35 +02:00
Alexandre Duret-Lutz
8f5ecc14bf [buddy]
* examples/cmilner/Makefile.am (cmilner_LDADD): Link with -lm, to
find the pow() function.
2011-02-27 15:24:22 +01:00
Alexandre Duret-Lutz
4034b7f87f [buddy]
* src/bddop.c (bdd_setxor): New function.
* src/bdd.h (bdd_setxor): New function.
2010-11-07 11:15:45 +01:00
Alexandre Duret-Lutz
0fe5403956 Revert inlining of bdd_addref() and bdd_delref().
This reverts commit d462f50b59.

Conflicts:

	buddy/ChangeLog
2010-01-22 15:55:08 +01:00
Alexandre Duret-Lutz
e828783f47 [buddy]
Get rid of some "deprecated conversion from string constant to
`char*'" warnings.

* examples/bddcalc/parser_.h (yyerror): Declare the format
as a "const char*".
* examples/bddcalc/parser.yxx (yyerror): Likewise.
2010-01-22 11:14:10 +01:00
Alexandre Duret-Lutz
e20ba143bb [buddy]
* src/bddio.c (bdd_load): Check the return value of fscanf() to
kill a warning.
2010-01-21 15:51:23 +01:00