Thread: [Pntool-developers] SF.net SVN: pntool:[111]
Brought to you by:
compaqdrew,
miordache
From: <the...@us...> - 2009-06-27 16:10:18
|
Revision: 111 http://pntool.svn.sourceforge.net/pntool/?rev=111&view=rev Author: thecodeweasel Date: 2009-06-27 16:10:17 +0000 (Sat, 27 Jun 2009) Log Message: ----------- Fixing naming Added Paths: ----------- ANTLR3_LICENSE.txt Removed Paths: ------------- COPYING Copied: ANTLR3_LICENSE.txt (from rev 110, COPYING) =================================================================== --- ANTLR3_LICENSE.txt (rev 0) +++ ANTLR3_LICENSE.txt 2009-06-27 16:10:17 UTC (rev 111) @@ -0,0 +1,29 @@ +// [The "BSD licence"] +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC +// http://www.temporal-wave.com +// http://www.linkedin.com/in/jimidle +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. 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. +// 3. The name of the author may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + Deleted: COPYING =================================================================== --- COPYING 2009-06-27 16:08:23 UTC (rev 110) +++ COPYING 2009-06-27 16:10:17 UTC (rev 111) @@ -1,29 +0,0 @@ -// [The "BSD licence"] -// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC -// http://www.temporal-wave.com -// http://www.linkedin.com/in/jimidle -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. 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. -// 3. The name of the author may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2009-06-28 06:07:36
|
Revision: 114 http://pntool.svn.sourceforge.net/pntool/?rev=114&view=rev Author: compaqdrew Date: 2009-06-28 06:07:34 +0000 (Sun, 28 Jun 2009) Log Message: ----------- Better codegen main_function.c integration Modified Paths: -------------- Makefile codegen/src/codegen.c codegen/src/codegen.h pnheaders/main_function.c Modified: Makefile =================================================================== --- Makefile 2009-06-28 06:07:26 UTC (rev 113) +++ Makefile 2009-06-28 06:07:34 UTC (rev 114) @@ -36,8 +36,8 @@ # cd $(SPNBOX); make # cd $(TRANSLATOR); make -main_function.o: $(PNHEADERS)/main_function.c $(PNHEADERS)/pns.h $(SPNBOX)/spnbox.h - $(COMPILER) -c $(PNHEADERS)/main_function.c -Ispnbox +main_function.o: $(PNHEADERS)/main_function.c $(PNHEADERS)/pns.h $(SPNBOX)/spnbox.h $(CODEGEN)/src/codegen.h + $(COMPILER) -c $(PNHEADERS)/main_function.c -Ispnbox -Icodegen/src clean: rm -f main_function.o Modified: codegen/src/codegen.c =================================================================== --- codegen/src/codegen.c 2009-06-28 06:07:26 UTC (rev 113) +++ codegen/src/codegen.c 2009-06-28 06:07:34 UTC (rev 114) @@ -16,7 +16,7 @@ #include "petriNetSerializer.h" -int GenerateProgam(pns *supervisor, char* sname, process** prarray, int num) +int GenerateProgram(pns *supervisor, char* sname, process** prarray, int num) { //Temporary solution to make current code work with new version pns pnarray[num]; Modified: codegen/src/codegen.h =================================================================== --- codegen/src/codegen.h 2009-06-28 06:07:26 UTC (rev 113) +++ codegen/src/codegen.h 2009-06-28 06:07:34 UTC (rev 114) @@ -9,7 +9,7 @@ */ #include "../../pnheaders/pns.h" -int GenerateProgam(pns *supervisor, char* sname, process** prarray, int num); +int GenerateProgram(pns *supervisor, char* sname, process** prarray, int num); /* Generates the supervisor and the process source files. It also generates the makefile that should be used to build them. Note that sname is the name of the supervisor program. Further, num is the number of processes. */ Modified: pnheaders/main_function.c =================================================================== --- pnheaders/main_function.c 2009-06-28 06:07:26 UTC (rev 113) +++ pnheaders/main_function.c 2009-06-28 06:07:34 UTC (rev 114) @@ -1,5 +1,6 @@ #include "pns.h" #include "spnbox.h" +#include "codegen.h" //this is the real GenerateProgram call (as opposed to GenerateProgam) int verb; @@ -134,7 +135,7 @@ // Generate code - GenerateProgam(&pnsv, sp->name, sp->process_array, sp->process_num); + GenerateProgram(&pnsv, sp->name, sp->process_array, sp->process_num); dealloc(&pnsv); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-01 18:46:09
|
Revision: 134 http://pntool.svn.sourceforge.net/pntool/?rev=134&view=rev Author: thecodeweasel Date: 2009-07-01 18:46:00 +0000 (Wed, 01 Jul 2009) Log Message: ----------- Moving things to support the new directory structure The translator now builds from the main makefile Modified Paths: -------------- Makefile translator/Makefile translator/clibs.patch translator/pngenerator.c Added Paths: ----------- third-party/ANTLR3_ctarget_3_1_3/ third-party/ANTLR3_ctarget_3_1_3/.deps/ third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3baserecognizer.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3basetree.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3basetreeadaptor.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3bitset.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3collections.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontoken.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontree.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontreeadaptor.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontreenodestream.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3convertutf.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3cyclicdfa.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3debughandlers.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3encodings.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3exception.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3filestream.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3inputstream.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3intstream.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3lexer.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3parser.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3rewritestreams.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3string.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3stringstream.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3tokenstream.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3treeparser.Plo third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3ucs2inputstream.Plo third-party/ANTLR3_ctarget_3_1_3/.libs/ third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3baserecognizer.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3basetree.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3basetreeadaptor.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3bitset.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3collections.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3commontoken.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3commontree.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3commontreeadaptor.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3commontreenodestream.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3convertutf.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3cyclicdfa.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3debughandlers.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3encodings.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3exception.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3filestream.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3inputstream.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3intstream.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3lexer.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3parser.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3rewritestreams.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3string.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3stringstream.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3tokenstream.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3treeparser.o third-party/ANTLR3_ctarget_3_1_3/.libs/antlr3ucs2inputstream.o third-party/ANTLR3_ctarget_3_1_3/.libs/libantlr3c.a third-party/ANTLR3_ctarget_3_1_3/.libs/libantlr3c.dylib third-party/ANTLR3_ctarget_3_1_3/.libs/libantlr3c.dylib.dSYM/ third-party/ANTLR3_ctarget_3_1_3/.libs/libantlr3c.dylib.dSYM/Contents/ third-party/ANTLR3_ctarget_3_1_3/.libs/libantlr3c.dylib.dSYM/Contents/Info.plist third-party/ANTLR3_ctarget_3_1_3/.libs/libantlr3c.dylib.dSYM/Contents/Resources/ third-party/ANTLR3_ctarget_3_1_3/.libs/libantlr3c.dylib.dSYM/Contents/Resources/DWARF/ third-party/ANTLR3_ctarget_3_1_3/.libs/libantlr3c.dylib.dSYM/Contents/Resources/DWARF/libantlr3c.dylib third-party/ANTLR3_ctarget_3_1_3/.libs/libantlr3c.la third-party/ANTLR3_ctarget_3_1_3/.libs/libantlr3c.lai third-party/ANTLR3_ctarget_3_1_3/AUTHORS third-party/ANTLR3_ctarget_3_1_3/C.sln third-party/ANTLR3_ctarget_3_1_3/C.vcproj third-party/ANTLR3_ctarget_3_1_3/C.vcproj.vspscc third-party/ANTLR3_ctarget_3_1_3/C.vssscc third-party/ANTLR3_ctarget_3_1_3/COPYING third-party/ANTLR3_ctarget_3_1_3/ChangeLog third-party/ANTLR3_ctarget_3_1_3/INSTALL third-party/ANTLR3_ctarget_3_1_3/Makefile third-party/ANTLR3_ctarget_3_1_3/Makefile.am third-party/ANTLR3_ctarget_3_1_3/Makefile.in third-party/ANTLR3_ctarget_3_1_3/NEWS third-party/ANTLR3_ctarget_3_1_3/README third-party/ANTLR3_ctarget_3_1_3/aclocal.m4 third-party/ANTLR3_ctarget_3_1_3/antlr3baserecognizer.lo third-party/ANTLR3_ctarget_3_1_3/antlr3baserecognizer.o third-party/ANTLR3_ctarget_3_1_3/antlr3basetree.lo third-party/ANTLR3_ctarget_3_1_3/antlr3basetree.o third-party/ANTLR3_ctarget_3_1_3/antlr3basetreeadaptor.lo third-party/ANTLR3_ctarget_3_1_3/antlr3basetreeadaptor.o third-party/ANTLR3_ctarget_3_1_3/antlr3bitset.lo third-party/ANTLR3_ctarget_3_1_3/antlr3bitset.o third-party/ANTLR3_ctarget_3_1_3/antlr3collections.lo third-party/ANTLR3_ctarget_3_1_3/antlr3collections.o third-party/ANTLR3_ctarget_3_1_3/antlr3commontoken.lo third-party/ANTLR3_ctarget_3_1_3/antlr3commontoken.o third-party/ANTLR3_ctarget_3_1_3/antlr3commontree.lo third-party/ANTLR3_ctarget_3_1_3/antlr3commontree.o third-party/ANTLR3_ctarget_3_1_3/antlr3commontreeadaptor.lo third-party/ANTLR3_ctarget_3_1_3/antlr3commontreeadaptor.o third-party/ANTLR3_ctarget_3_1_3/antlr3commontreenodestream.lo third-party/ANTLR3_ctarget_3_1_3/antlr3commontreenodestream.o third-party/ANTLR3_ctarget_3_1_3/antlr3config.h third-party/ANTLR3_ctarget_3_1_3/antlr3config.h.in third-party/ANTLR3_ctarget_3_1_3/antlr3convertutf.lo third-party/ANTLR3_ctarget_3_1_3/antlr3convertutf.o third-party/ANTLR3_ctarget_3_1_3/antlr3cyclicdfa.lo third-party/ANTLR3_ctarget_3_1_3/antlr3cyclicdfa.o third-party/ANTLR3_ctarget_3_1_3/antlr3debughandlers.lo third-party/ANTLR3_ctarget_3_1_3/antlr3debughandlers.o third-party/ANTLR3_ctarget_3_1_3/antlr3encodings.lo third-party/ANTLR3_ctarget_3_1_3/antlr3encodings.o third-party/ANTLR3_ctarget_3_1_3/antlr3exception.lo third-party/ANTLR3_ctarget_3_1_3/antlr3exception.o third-party/ANTLR3_ctarget_3_1_3/antlr3filestream.lo third-party/ANTLR3_ctarget_3_1_3/antlr3filestream.o third-party/ANTLR3_ctarget_3_1_3/antlr3inputstream.lo third-party/ANTLR3_ctarget_3_1_3/antlr3inputstream.o third-party/ANTLR3_ctarget_3_1_3/antlr3intstream.lo third-party/ANTLR3_ctarget_3_1_3/antlr3intstream.o third-party/ANTLR3_ctarget_3_1_3/antlr3lexer.lo third-party/ANTLR3_ctarget_3_1_3/antlr3lexer.o third-party/ANTLR3_ctarget_3_1_3/antlr3parser.lo third-party/ANTLR3_ctarget_3_1_3/antlr3parser.o third-party/ANTLR3_ctarget_3_1_3/antlr3rewritestreams.lo third-party/ANTLR3_ctarget_3_1_3/antlr3rewritestreams.o third-party/ANTLR3_ctarget_3_1_3/antlr3string.lo third-party/ANTLR3_ctarget_3_1_3/antlr3string.o third-party/ANTLR3_ctarget_3_1_3/antlr3stringstream.lo third-party/ANTLR3_ctarget_3_1_3/antlr3stringstream.o third-party/ANTLR3_ctarget_3_1_3/antlr3tokenstream.lo third-party/ANTLR3_ctarget_3_1_3/antlr3tokenstream.o third-party/ANTLR3_ctarget_3_1_3/antlr3treeparser.lo third-party/ANTLR3_ctarget_3_1_3/antlr3treeparser.o third-party/ANTLR3_ctarget_3_1_3/antlr3ucs2inputstream.lo third-party/ANTLR3_ctarget_3_1_3/antlr3ucs2inputstream.o third-party/ANTLR3_ctarget_3_1_3/config.guess third-party/ANTLR3_ctarget_3_1_3/config.log third-party/ANTLR3_ctarget_3_1_3/config.status third-party/ANTLR3_ctarget_3_1_3/config.sub third-party/ANTLR3_ctarget_3_1_3/configure third-party/ANTLR3_ctarget_3_1_3/configure.ac third-party/ANTLR3_ctarget_3_1_3/depcomp third-party/ANTLR3_ctarget_3_1_3/include/ third-party/ANTLR3_ctarget_3_1_3/include/antlr3.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3baserecognizer.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3basetree.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3basetreeadaptor.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3bitset.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3collections.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3commontoken.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3commontree.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3commontreeadaptor.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3commontreeadaptor.h.rej third-party/ANTLR3_ctarget_3_1_3/include/antlr3commontreenodestream.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3convertutf.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3cyclicdfa.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3debugeventlistener.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3defs.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3encodings.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3errors.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3exception.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3filestream.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3input.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3interfaces.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3intstream.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3lexer.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3memory.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3parser.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3parsetree.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3recognizersharedstate.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3rewritestreams.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3string.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3stringstream.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3tokenstream.h third-party/ANTLR3_ctarget_3_1_3/include/antlr3treeparser.h third-party/ANTLR3_ctarget_3_1_3/install-sh third-party/ANTLR3_ctarget_3_1_3/libantlr3c.la third-party/ANTLR3_ctarget_3_1_3/libtool third-party/ANTLR3_ctarget_3_1_3/ltmain.sh third-party/ANTLR3_ctarget_3_1_3/missing third-party/ANTLR3_ctarget_3_1_3/src/ third-party/ANTLR3_ctarget_3_1_3/src/antlr3baserecognizer.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3basetree.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3basetree.c.rej third-party/ANTLR3_ctarget_3_1_3/src/antlr3basetreeadaptor.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3bitset.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3collections.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3commontoken.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3commontree.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3commontreeadaptor.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3commontreeadaptor.c.rej third-party/ANTLR3_ctarget_3_1_3/src/antlr3commontreenodestream.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3convertutf.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3cyclicdfa.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3debughandlers.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3encodings.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3exception.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3filestream.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3inputstream.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3intstream.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3lexer.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3parser.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3rewritestreams.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3string.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3stringstream.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3tokenstream.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3treeparser.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3ucs2inputstream.c third-party/ANTLR3_ctarget_3_1_3/stamp-h1 third-party/ANTLR3_ctarget_3_1_3/vsrulefiles/ third-party/ANTLR3_ctarget_3_1_3/vsrulefiles/antlr3lexer.rules third-party/ANTLR3_ctarget_3_1_3/vsrulefiles/antlr3lexerandparser.rules third-party/ANTLR3_ctarget_3_1_3/vsrulefiles/antlr3parser.rules third-party/ANTLR3_ctarget_3_1_3/vsrulefiles/antlr3treeparser.rules Modified: Makefile =================================================================== --- Makefile 2009-07-01 16:31:58 UTC (rev 133) +++ Makefile 2009-07-01 18:46:00 UTC (rev 134) @@ -34,7 +34,7 @@ cd $(PNHEADERS); make cd $(CODEGEN); make static # cd $(SPNBOX); make -# cd $(TRANSLATOR); make + cd $(TRANSLATOR); make main_function.o: $(PNHEADERS)/main_function.c $(PNHEADERS)/pns.h $(SPNBOX)/spnbox.h $(CODEGEN)/src/codegen.h $(COMPILER) -c $(PNHEADERS)/main_function.c -Ispnbox -I$(CODEGEN)/src -I$(PNHEADERS) @@ -42,7 +42,8 @@ clean: rm -f main_function.o cd codegen; make clean - + cd $(TRANSLATOR); make clean distclean: clean cd codegen; make distclean + cd $(TRANSLATOR); make distclean \ No newline at end of file Added: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3baserecognizer.Plo =================================================================== --- third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3baserecognizer.Plo (rev 0) +++ third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3baserecognizer.Plo 2009-07-01 18:46:00 UTC (rev 134) @@ -0,0 +1,210 @@ +antlr3baserecognizer.lo antlr3baserecognizer.o: \ + src/antlr3baserecognizer.c include/antlr3baserecognizer.h \ + include/antlr3defs.h include/antlr3errors.h antlr3config.h \ + /usr/include/stdio.h /usr/include/_types.h /usr/include/sys/_types.h \ + /usr/include/sys/cdefs.h /usr/include/machine/_types.h \ + /usr/include/i386/_types.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h \ + /usr/include/sys/types.h /usr/include/sys/appleapiopts.h \ + /usr/include/machine/types.h /usr/include/i386/types.h \ + /usr/include/machine/endian.h /usr/include/i386/endian.h \ + /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ + /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h \ + /usr/include/sys/stat.h /usr/include/stdlib.h /usr/include/available.h \ + /usr/include/sys/wait.h /usr/include/sys/signal.h \ + /usr/include/machine/signal.h /usr/include/i386/signal.h \ + /usr/include/i386/_structs.h /usr/include/machine/_structs.h \ + /usr/include/mach/i386/_structs.h /usr/include/sys/resource.h \ + /usr/include/alloca.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/inttypes.h \ + /usr/include/unistd.h /usr/include/sys/unistd.h \ + /usr/include/sys/select.h /usr/include/sys/_select.h \ + /usr/include/netinet/in.h /usr/include/sys/socket.h \ + /usr/include/machine/_param.h /usr/include/i386/_param.h \ + /usr/include/netinet6/in6.h /usr/include/netinet/tcp.h \ + /usr/include/arpa/nameser.h /usr/include/sys/param.h \ + /usr/include/sys/syslimits.h /usr/include/machine/param.h \ + /usr/include/i386/param.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h \ + /usr/include/limits.h /usr/include/machine/limits.h \ + /usr/include/i386/limits.h /usr/include/i386/_limits.h \ + /usr/include/netdb.h /usr/include/sys/malloc.h /usr/include/ctype.h \ + /usr/include/runetype.h include/antlr3interfaces.h \ + include/antlr3convertutf.h include/antlr3exception.h \ + include/antlr3input.h include/antlr3string.h \ + include/antlr3collections.h include/antlr3commontoken.h \ + include/antlr3intstream.h include/antlr3tokenstream.h \ + include/antlr3bitset.h include/antlr3debugeventlistener.h \ + include/antlr3basetree.h include/antlr3commontreenodestream.h \ + include/antlr3commontreeadaptor.h include/antlr3basetreeadaptor.h \ + include/antlr3commontree.h include/antlr3recognizersharedstate.h \ + include/antlr3lexer.h include/antlr3parser.h include/antlr3treeparser.h + +include/antlr3baserecognizer.h: + +include/antlr3defs.h: + +include/antlr3errors.h: + +antlr3config.h: + +/usr/include/stdio.h: + +/usr/include/_types.h: + +/usr/include/sys/_types.h: + +/usr/include/sys/cdefs.h: + +/usr/include/machine/_types.h: + +/usr/include/i386/_types.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: + +/usr/include/sys/types.h: + +/usr/include/sys/appleapiopts.h: + +/usr/include/machine/types.h: + +/usr/include/i386/types.h: + +/usr/include/machine/endian.h: + +/usr/include/i386/endian.h: + +/usr/include/sys/_endian.h: + +/usr/include/libkern/_OSByteOrder.h: + +/usr/include/libkern/i386/_OSByteOrder.h: + +/usr/include/sys/_structs.h: + +/usr/include/sys/stat.h: + +/usr/include/stdlib.h: + +/usr/include/available.h: + +/usr/include/sys/wait.h: + +/usr/include/sys/signal.h: + +/usr/include/machine/signal.h: + +/usr/include/i386/signal.h: + +/usr/include/i386/_structs.h: + +/usr/include/machine/_structs.h: + +/usr/include/mach/i386/_structs.h: + +/usr/include/sys/resource.h: + +/usr/include/alloca.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h: + +/usr/include/string.h: + +/usr/include/strings.h: + +/usr/include/inttypes.h: + +/usr/include/unistd.h: + +/usr/include/sys/unistd.h: + +/usr/include/sys/select.h: + +/usr/include/sys/_select.h: + +/usr/include/netinet/in.h: + +/usr/include/sys/socket.h: + +/usr/include/machine/_param.h: + +/usr/include/i386/_param.h: + +/usr/include/netinet6/in6.h: + +/usr/include/netinet/tcp.h: + +/usr/include/arpa/nameser.h: + +/usr/include/sys/param.h: + +/usr/include/sys/syslimits.h: + +/usr/include/machine/param.h: + +/usr/include/i386/param.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/machine/limits.h: + +/usr/include/i386/limits.h: + +/usr/include/i386/_limits.h: + +/usr/include/netdb.h: + +/usr/include/sys/malloc.h: + +/usr/include/ctype.h: + +/usr/include/runetype.h: + +include/antlr3interfaces.h: + +include/antlr3convertutf.h: + +include/antlr3exception.h: + +include/antlr3input.h: + +include/antlr3string.h: + +include/antlr3collections.h: + +include/antlr3commontoken.h: + +include/antlr3intstream.h: + +include/antlr3tokenstream.h: + +include/antlr3bitset.h: + +include/antlr3debugeventlistener.h: + +include/antlr3basetree.h: + +include/antlr3commontreenodestream.h: + +include/antlr3commontreeadaptor.h: + +include/antlr3basetreeadaptor.h: + +include/antlr3commontree.h: + +include/antlr3recognizersharedstate.h: + +include/antlr3lexer.h: + +include/antlr3parser.h: + +include/antlr3treeparser.h: Property changes on: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3baserecognizer.Plo ___________________________________________________________________ Added: svn:eol-style + native Added: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3basetree.Plo =================================================================== --- third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3basetree.Plo (rev 0) +++ third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3basetree.Plo 2009-07-01 18:46:00 UTC (rev 134) @@ -0,0 +1,170 @@ +antlr3basetree.lo antlr3basetree.o: src/antlr3basetree.c \ + include/antlr3basetree.h include/antlr3defs.h include/antlr3errors.h \ + antlr3config.h /usr/include/stdio.h /usr/include/_types.h \ + /usr/include/sys/_types.h /usr/include/sys/cdefs.h \ + /usr/include/machine/_types.h /usr/include/i386/_types.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h \ + /usr/include/sys/types.h /usr/include/sys/appleapiopts.h \ + /usr/include/machine/types.h /usr/include/i386/types.h \ + /usr/include/machine/endian.h /usr/include/i386/endian.h \ + /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ + /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h \ + /usr/include/sys/stat.h /usr/include/stdlib.h /usr/include/available.h \ + /usr/include/sys/wait.h /usr/include/sys/signal.h \ + /usr/include/machine/signal.h /usr/include/i386/signal.h \ + /usr/include/i386/_structs.h /usr/include/machine/_structs.h \ + /usr/include/mach/i386/_structs.h /usr/include/sys/resource.h \ + /usr/include/alloca.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/inttypes.h \ + /usr/include/unistd.h /usr/include/sys/unistd.h \ + /usr/include/sys/select.h /usr/include/sys/_select.h \ + /usr/include/netinet/in.h /usr/include/sys/socket.h \ + /usr/include/machine/_param.h /usr/include/i386/_param.h \ + /usr/include/netinet6/in6.h /usr/include/netinet/tcp.h \ + /usr/include/arpa/nameser.h /usr/include/sys/param.h \ + /usr/include/sys/syslimits.h /usr/include/machine/param.h \ + /usr/include/i386/param.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h \ + /usr/include/limits.h /usr/include/machine/limits.h \ + /usr/include/i386/limits.h /usr/include/i386/_limits.h \ + /usr/include/netdb.h /usr/include/sys/malloc.h /usr/include/ctype.h \ + /usr/include/runetype.h include/antlr3interfaces.h \ + include/antlr3convertutf.h include/antlr3collections.h \ + include/antlr3string.h + +include/antlr3basetree.h: + +include/antlr3defs.h: + +include/antlr3errors.h: + +antlr3config.h: + +/usr/include/stdio.h: + +/usr/include/_types.h: + +/usr/include/sys/_types.h: + +/usr/include/sys/cdefs.h: + +/usr/include/machine/_types.h: + +/usr/include/i386/_types.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: + +/usr/include/sys/types.h: + +/usr/include/sys/appleapiopts.h: + +/usr/include/machine/types.h: + +/usr/include/i386/types.h: + +/usr/include/machine/endian.h: + +/usr/include/i386/endian.h: + +/usr/include/sys/_endian.h: + +/usr/include/libkern/_OSByteOrder.h: + +/usr/include/libkern/i386/_OSByteOrder.h: + +/usr/include/sys/_structs.h: + +/usr/include/sys/stat.h: + +/usr/include/stdlib.h: + +/usr/include/available.h: + +/usr/include/sys/wait.h: + +/usr/include/sys/signal.h: + +/usr/include/machine/signal.h: + +/usr/include/i386/signal.h: + +/usr/include/i386/_structs.h: + +/usr/include/machine/_structs.h: + +/usr/include/mach/i386/_structs.h: + +/usr/include/sys/resource.h: + +/usr/include/alloca.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h: + +/usr/include/string.h: + +/usr/include/strings.h: + +/usr/include/inttypes.h: + +/usr/include/unistd.h: + +/usr/include/sys/unistd.h: + +/usr/include/sys/select.h: + +/usr/include/sys/_select.h: + +/usr/include/netinet/in.h: + +/usr/include/sys/socket.h: + +/usr/include/machine/_param.h: + +/usr/include/i386/_param.h: + +/usr/include/netinet6/in6.h: + +/usr/include/netinet/tcp.h: + +/usr/include/arpa/nameser.h: + +/usr/include/sys/param.h: + +/usr/include/sys/syslimits.h: + +/usr/include/machine/param.h: + +/usr/include/i386/param.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/machine/limits.h: + +/usr/include/i386/limits.h: + +/usr/include/i386/_limits.h: + +/usr/include/netdb.h: + +/usr/include/sys/malloc.h: + +/usr/include/ctype.h: + +/usr/include/runetype.h: + +include/antlr3interfaces.h: + +include/antlr3convertutf.h: + +include/antlr3collections.h: + +include/antlr3string.h: Property changes on: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3basetree.Plo ___________________________________________________________________ Added: svn:eol-style + native Added: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3basetreeadaptor.Plo =================================================================== --- third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3basetreeadaptor.Plo (rev 0) +++ third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3basetreeadaptor.Plo 2009-07-01 18:46:00 UTC (rev 134) @@ -0,0 +1,178 @@ +antlr3basetreeadaptor.lo antlr3basetreeadaptor.o: \ + src/antlr3basetreeadaptor.c include/antlr3basetreeadaptor.h \ + include/antlr3defs.h include/antlr3errors.h antlr3config.h \ + /usr/include/stdio.h /usr/include/_types.h /usr/include/sys/_types.h \ + /usr/include/sys/cdefs.h /usr/include/machine/_types.h \ + /usr/include/i386/_types.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h \ + /usr/include/sys/types.h /usr/include/sys/appleapiopts.h \ + /usr/include/machine/types.h /usr/include/i386/types.h \ + /usr/include/machine/endian.h /usr/include/i386/endian.h \ + /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ + /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h \ + /usr/include/sys/stat.h /usr/include/stdlib.h /usr/include/available.h \ + /usr/include/sys/wait.h /usr/include/sys/signal.h \ + /usr/include/machine/signal.h /usr/include/i386/signal.h \ + /usr/include/i386/_structs.h /usr/include/machine/_structs.h \ + /usr/include/mach/i386/_structs.h /usr/include/sys/resource.h \ + /usr/include/alloca.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/inttypes.h \ + /usr/include/unistd.h /usr/include/sys/unistd.h \ + /usr/include/sys/select.h /usr/include/sys/_select.h \ + /usr/include/netinet/in.h /usr/include/sys/socket.h \ + /usr/include/machine/_param.h /usr/include/i386/_param.h \ + /usr/include/netinet6/in6.h /usr/include/netinet/tcp.h \ + /usr/include/arpa/nameser.h /usr/include/sys/param.h \ + /usr/include/sys/syslimits.h /usr/include/machine/param.h \ + /usr/include/i386/param.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h \ + /usr/include/limits.h /usr/include/machine/limits.h \ + /usr/include/i386/limits.h /usr/include/i386/_limits.h \ + /usr/include/netdb.h /usr/include/sys/malloc.h /usr/include/ctype.h \ + /usr/include/runetype.h include/antlr3interfaces.h \ + include/antlr3convertutf.h include/antlr3collections.h \ + include/antlr3string.h include/antlr3basetree.h \ + include/antlr3commontoken.h include/antlr3debugeventlistener.h + +include/antlr3basetreeadaptor.h: + +include/antlr3defs.h: + +include/antlr3errors.h: + +antlr3config.h: + +/usr/include/stdio.h: + +/usr/include/_types.h: + +/usr/include/sys/_types.h: + +/usr/include/sys/cdefs.h: + +/usr/include/machine/_types.h: + +/usr/include/i386/_types.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: + +/usr/include/sys/types.h: + +/usr/include/sys/appleapiopts.h: + +/usr/include/machine/types.h: + +/usr/include/i386/types.h: + +/usr/include/machine/endian.h: + +/usr/include/i386/endian.h: + +/usr/include/sys/_endian.h: + +/usr/include/libkern/_OSByteOrder.h: + +/usr/include/libkern/i386/_OSByteOrder.h: + +/usr/include/sys/_structs.h: + +/usr/include/sys/stat.h: + +/usr/include/stdlib.h: + +/usr/include/available.h: + +/usr/include/sys/wait.h: + +/usr/include/sys/signal.h: + +/usr/include/machine/signal.h: + +/usr/include/i386/signal.h: + +/usr/include/i386/_structs.h: + +/usr/include/machine/_structs.h: + +/usr/include/mach/i386/_structs.h: + +/usr/include/sys/resource.h: + +/usr/include/alloca.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h: + +/usr/include/string.h: + +/usr/include/strings.h: + +/usr/include/inttypes.h: + +/usr/include/unistd.h: + +/usr/include/sys/unistd.h: + +/usr/include/sys/select.h: + +/usr/include/sys/_select.h: + +/usr/include/netinet/in.h: + +/usr/include/sys/socket.h: + +/usr/include/machine/_param.h: + +/usr/include/i386/_param.h: + +/usr/include/netinet6/in6.h: + +/usr/include/netinet/tcp.h: + +/usr/include/arpa/nameser.h: + +/usr/include/sys/param.h: + +/usr/include/sys/syslimits.h: + +/usr/include/machine/param.h: + +/usr/include/i386/param.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/machine/limits.h: + +/usr/include/i386/limits.h: + +/usr/include/i386/_limits.h: + +/usr/include/netdb.h: + +/usr/include/sys/malloc.h: + +/usr/include/ctype.h: + +/usr/include/runetype.h: + +include/antlr3interfaces.h: + +include/antlr3convertutf.h: + +include/antlr3collections.h: + +include/antlr3string.h: + +include/antlr3basetree.h: + +include/antlr3commontoken.h: + +include/antlr3debugeventlistener.h: Property changes on: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3basetreeadaptor.Plo ___________________________________________________________________ Added: svn:eol-style + native Added: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3bitset.Plo =================================================================== --- third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3bitset.Plo (rev 0) +++ third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3bitset.Plo 2009-07-01 18:46:00 UTC (rev 134) @@ -0,0 +1,167 @@ +antlr3bitset.lo antlr3bitset.o: src/antlr3bitset.c include/antlr3bitset.h \ + include/antlr3defs.h include/antlr3errors.h antlr3config.h \ + /usr/include/stdio.h /usr/include/_types.h /usr/include/sys/_types.h \ + /usr/include/sys/cdefs.h /usr/include/machine/_types.h \ + /usr/include/i386/_types.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h \ + /usr/include/sys/types.h /usr/include/sys/appleapiopts.h \ + /usr/include/machine/types.h /usr/include/i386/types.h \ + /usr/include/machine/endian.h /usr/include/i386/endian.h \ + /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ + /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h \ + /usr/include/sys/stat.h /usr/include/stdlib.h /usr/include/available.h \ + /usr/include/sys/wait.h /usr/include/sys/signal.h \ + /usr/include/machine/signal.h /usr/include/i386/signal.h \ + /usr/include/i386/_structs.h /usr/include/machine/_structs.h \ + /usr/include/mach/i386/_structs.h /usr/include/sys/resource.h \ + /usr/include/alloca.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/inttypes.h \ + /usr/include/unistd.h /usr/include/sys/unistd.h \ + /usr/include/sys/select.h /usr/include/sys/_select.h \ + /usr/include/netinet/in.h /usr/include/sys/socket.h \ + /usr/include/machine/_param.h /usr/include/i386/_param.h \ + /usr/include/netinet6/in6.h /usr/include/netinet/tcp.h \ + /usr/include/arpa/nameser.h /usr/include/sys/param.h \ + /usr/include/sys/syslimits.h /usr/include/machine/param.h \ + /usr/include/i386/param.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h \ + /usr/include/limits.h /usr/include/machine/limits.h \ + /usr/include/i386/limits.h /usr/include/i386/_limits.h \ + /usr/include/netdb.h /usr/include/sys/malloc.h /usr/include/ctype.h \ + /usr/include/runetype.h include/antlr3interfaces.h \ + include/antlr3convertutf.h include/antlr3collections.h + +include/antlr3bitset.h: + +include/antlr3defs.h: + +include/antlr3errors.h: + +antlr3config.h: + +/usr/include/stdio.h: + +/usr/include/_types.h: + +/usr/include/sys/_types.h: + +/usr/include/sys/cdefs.h: + +/usr/include/machine/_types.h: + +/usr/include/i386/_types.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: + +/usr/include/sys/types.h: + +/usr/include/sys/appleapiopts.h: + +/usr/include/machine/types.h: + +/usr/include/i386/types.h: + +/usr/include/machine/endian.h: + +/usr/include/i386/endian.h: + +/usr/include/sys/_endian.h: + +/usr/include/libkern/_OSByteOrder.h: + +/usr/include/libkern/i386/_OSByteOrder.h: + +/usr/include/sys/_structs.h: + +/usr/include/sys/stat.h: + +/usr/include/stdlib.h: + +/usr/include/available.h: + +/usr/include/sys/wait.h: + +/usr/include/sys/signal.h: + +/usr/include/machine/signal.h: + +/usr/include/i386/signal.h: + +/usr/include/i386/_structs.h: + +/usr/include/machine/_structs.h: + +/usr/include/mach/i386/_structs.h: + +/usr/include/sys/resource.h: + +/usr/include/alloca.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h: + +/usr/include/string.h: + +/usr/include/strings.h: + +/usr/include/inttypes.h: + +/usr/include/unistd.h: + +/usr/include/sys/unistd.h: + +/usr/include/sys/select.h: + +/usr/include/sys/_select.h: + +/usr/include/netinet/in.h: + +/usr/include/sys/socket.h: + +/usr/include/machine/_param.h: + +/usr/include/i386/_param.h: + +/usr/include/netinet6/in6.h: + +/usr/include/netinet/tcp.h: + +/usr/include/arpa/nameser.h: + +/usr/include/sys/param.h: + +/usr/include/sys/syslimits.h: + +/usr/include/machine/param.h: + +/usr/include/i386/param.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/machine/limits.h: + +/usr/include/i386/limits.h: + +/usr/include/i386/_limits.h: + +/usr/include/netdb.h: + +/usr/include/sys/malloc.h: + +/usr/include/ctype.h: + +/usr/include/runetype.h: + +include/antlr3interfaces.h: + +include/antlr3convertutf.h: + +include/antlr3collections.h: Property changes on: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3bitset.Plo ___________________________________________________________________ Added: svn:eol-style + native Added: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3collections.Plo =================================================================== --- third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3collections.Plo (rev 0) +++ third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3collections.Plo 2009-07-01 18:46:00 UTC (rev 134) @@ -0,0 +1,222 @@ +antlr3collections.lo antlr3collections.o: src/antlr3collections.c \ + include/antlr3.h include/antlr3defs.h include/antlr3errors.h \ + antlr3config.h /usr/include/stdio.h /usr/include/_types.h \ + /usr/include/sys/_types.h /usr/include/sys/cdefs.h \ + /usr/include/machine/_types.h /usr/include/i386/_types.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h \ + /usr/include/sys/types.h /usr/include/sys/appleapiopts.h \ + /usr/include/machine/types.h /usr/include/i386/types.h \ + /usr/include/machine/endian.h /usr/include/i386/endian.h \ + /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ + /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h \ + /usr/include/sys/stat.h /usr/include/stdlib.h /usr/include/available.h \ + /usr/include/sys/wait.h /usr/include/sys/signal.h \ + /usr/include/machine/signal.h /usr/include/i386/signal.h \ + /usr/include/i386/_structs.h /usr/include/machine/_structs.h \ + /usr/include/mach/i386/_structs.h /usr/include/sys/resource.h \ + /usr/include/alloca.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/inttypes.h \ + /usr/include/unistd.h /usr/include/sys/unistd.h \ + /usr/include/sys/select.h /usr/include/sys/_select.h \ + /usr/include/netinet/in.h /usr/include/sys/socket.h \ + /usr/include/machine/_param.h /usr/include/i386/_param.h \ + /usr/include/netinet6/in6.h /usr/include/netinet/tcp.h \ + /usr/include/arpa/nameser.h /usr/include/sys/param.h \ + /usr/include/sys/syslimits.h /usr/include/machine/param.h \ + /usr/include/i386/param.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h \ + /usr/include/limits.h /usr/include/machine/limits.h \ + /usr/include/i386/limits.h /usr/include/i386/_limits.h \ + /usr/include/netdb.h /usr/include/sys/malloc.h /usr/include/ctype.h \ + /usr/include/runetype.h include/antlr3interfaces.h \ + include/antlr3convertutf.h include/antlr3exception.h \ + include/antlr3encodings.h include/antlr3string.h \ + include/antlr3collections.h include/antlr3input.h \ + include/antlr3commontoken.h include/antlr3intstream.h \ + include/antlr3cyclicdfa.h include/antlr3baserecognizer.h \ + include/antlr3tokenstream.h include/antlr3bitset.h \ + include/antlr3debugeventlistener.h include/antlr3basetree.h \ + include/antlr3commontreenodestream.h include/antlr3commontreeadaptor.h \ + include/antlr3basetreeadaptor.h include/antlr3commontree.h \ + include/antlr3recognizersharedstate.h include/antlr3lexer.h \ + include/antlr3parser.h include/antlr3treeparser.h \ + include/antlr3filestream.h include/antlr3rewritestreams.h + +include/antlr3.h: + +include/antlr3defs.h: + +include/antlr3errors.h: + +antlr3config.h: + +/usr/include/stdio.h: + +/usr/include/_types.h: + +/usr/include/sys/_types.h: + +/usr/include/sys/cdefs.h: + +/usr/include/machine/_types.h: + +/usr/include/i386/_types.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: + +/usr/include/sys/types.h: + +/usr/include/sys/appleapiopts.h: + +/usr/include/machine/types.h: + +/usr/include/i386/types.h: + +/usr/include/machine/endian.h: + +/usr/include/i386/endian.h: + +/usr/include/sys/_endian.h: + +/usr/include/libkern/_OSByteOrder.h: + +/usr/include/libkern/i386/_OSByteOrder.h: + +/usr/include/sys/_structs.h: + +/usr/include/sys/stat.h: + +/usr/include/stdlib.h: + +/usr/include/available.h: + +/usr/include/sys/wait.h: + +/usr/include/sys/signal.h: + +/usr/include/machine/signal.h: + +/usr/include/i386/signal.h: + +/usr/include/i386/_structs.h: + +/usr/include/machine/_structs.h: + +/usr/include/mach/i386/_structs.h: + +/usr/include/sys/resource.h: + +/usr/include/alloca.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h: + +/usr/include/string.h: + +/usr/include/strings.h: + +/usr/include/inttypes.h: + +/usr/include/unistd.h: + +/usr/include/sys/unistd.h: + +/usr/include/sys/select.h: + +/usr/include/sys/_select.h: + +/usr/include/netinet/in.h: + +/usr/include/sys/socket.h: + +/usr/include/machine/_param.h: + +/usr/include/i386/_param.h: + +/usr/include/netinet6/in6.h: + +/usr/include/netinet/tcp.h: + +/usr/include/arpa/nameser.h: + +/usr/include/sys/param.h: + +/usr/include/sys/syslimits.h: + +/usr/include/machine/param.h: + +/usr/include/i386/param.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/machine/limits.h: + +/usr/include/i386/limits.h: + +/usr/include/i386/_limits.h: + +/usr/include/netdb.h: + +/usr/include/sys/malloc.h: + +/usr/include/ctype.h: + +/usr/include/runetype.h: + +include/antlr3interfaces.h: + +include/antlr3convertutf.h: + +include/antlr3exception.h: + +include/antlr3encodings.h: + +include/antlr3string.h: + +include/antlr3collections.h: + +include/antlr3input.h: + +include/antlr3commontoken.h: + +include/antlr3intstream.h: + +include/antlr3cyclicdfa.h: + +include/antlr3baserecognizer.h: + +include/antlr3tokenstream.h: + +include/antlr3bitset.h: + +include/antlr3debugeventlistener.h: + +include/antlr3basetree.h: + +include/antlr3commontreenodestream.h: + +include/antlr3commontreeadaptor.h: + +include/antlr3basetreeadaptor.h: + +include/antlr3commontree.h: + +include/antlr3recognizersharedstate.h: + +include/antlr3lexer.h: + +include/antlr3parser.h: + +include/antlr3treeparser.h: + +include/antlr3filestream.h: + +include/antlr3rewritestreams.h: Property changes on: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3collections.Plo ___________________________________________________________________ Added: svn:eol-style + native Added: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontoken.Plo =================================================================== --- third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontoken.Plo (rev 0) +++ third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontoken.Plo 2009-07-01 18:46:00 UTC (rev 134) @@ -0,0 +1,222 @@ +antlr3commontoken.lo antlr3commontoken.o: src/antlr3commontoken.c \ + include/antlr3.h include/antlr3defs.h include/antlr3errors.h \ + antlr3config.h /usr/include/stdio.h /usr/include/_types.h \ + /usr/include/sys/_types.h /usr/include/sys/cdefs.h \ + /usr/include/machine/_types.h /usr/include/i386/_types.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h \ + /usr/include/sys/types.h /usr/include/sys/appleapiopts.h \ + /usr/include/machine/types.h /usr/include/i386/types.h \ + /usr/include/machine/endian.h /usr/include/i386/endian.h \ + /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ + /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h \ + /usr/include/sys/stat.h /usr/include/stdlib.h /usr/include/available.h \ + /usr/include/sys/wait.h /usr/include/sys/signal.h \ + /usr/include/machine/signal.h /usr/include/i386/signal.h \ + /usr/include/i386/_structs.h /usr/include/machine/_structs.h \ + /usr/include/mach/i386/_structs.h /usr/include/sys/resource.h \ + /usr/include/alloca.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/inttypes.h \ + /usr/include/unistd.h /usr/include/sys/unistd.h \ + /usr/include/sys/select.h /usr/include/sys/_select.h \ + /usr/include/netinet/in.h /usr/include/sys/socket.h \ + /usr/include/machine/_param.h /usr/include/i386/_param.h \ + /usr/include/netinet6/in6.h /usr/include/netinet/tcp.h \ + /usr/include/arpa/nameser.h /usr/include/sys/param.h \ + /usr/include/sys/syslimits.h /usr/include/machine/param.h \ + /usr/include/i386/param.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h \ + /usr/include/limits.h /usr/include/machine/limits.h \ + /usr/include/i386/limits.h /usr/include/i386/_limits.h \ + /usr/include/netdb.h /usr/include/sys/malloc.h /usr/include/ctype.h \ + /usr/include/runetype.h include/antlr3interfaces.h \ + include/antlr3convertutf.h include/antlr3exception.h \ + include/antlr3encodings.h include/antlr3string.h \ + include/antlr3collections.h include/antlr3input.h \ + include/antlr3commontoken.h include/antlr3intstream.h \ + include/antlr3cyclicdfa.h include/antlr3baserecognizer.h \ + include/antlr3tokenstream.h include/antlr3bitset.h \ + include/antlr3debugeventlistener.h include/antlr3basetree.h \ + include/antlr3commontreenodestream.h include/antlr3commontreeadaptor.h \ + include/antlr3basetreeadaptor.h include/antlr3commontree.h \ + include/antlr3recognizersharedstate.h include/antlr3lexer.h \ + include/antlr3parser.h include/antlr3treeparser.h \ + include/antlr3filestream.h include/antlr3rewritestreams.h + +include/antlr3.h: + +include/antlr3defs.h: + +include/antlr3errors.h: + +antlr3config.h: + +/usr/include/stdio.h: + +/usr/include/_types.h: + +/usr/include/sys/_types.h: + +/usr/include/sys/cdefs.h: + +/usr/include/machine/_types.h: + +/usr/include/i386/_types.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: + +/usr/include/sys/types.h: + +/usr/include/sys/appleapiopts.h: + +/usr/include/machine/types.h: + +/usr/include/i386/types.h: + +/usr/include/machine/endian.h: + +/usr/include/i386/endian.h: + +/usr/include/sys/_endian.h: + +/usr/include/libkern/_OSByteOrder.h: + +/usr/include/libkern/i386/_OSByteOrder.h: + +/usr/include/sys/_structs.h: + +/usr/include/sys/stat.h: + +/usr/include/stdlib.h: + +/usr/include/available.h: + +/usr/include/sys/wait.h: + +/usr/include/sys/signal.h: + +/usr/include/machine/signal.h: + +/usr/include/i386/signal.h: + +/usr/include/i386/_structs.h: + +/usr/include/machine/_structs.h: + +/usr/include/mach/i386/_structs.h: + +/usr/include/sys/resource.h: + +/usr/include/alloca.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h: + +/usr/include/string.h: + +/usr/include/strings.h: + +/usr/include/inttypes.h: + +/usr/include/unistd.h: + +/usr/include/sys/unistd.h: + +/usr/include/sys/select.h: + +/usr/include/sys/_select.h: + +/usr/include/netinet/in.h: + +/usr/include/sys/socket.h: + +/usr/include/machine/_param.h: + +/usr/include/i386/_param.h: + +/usr/include/netinet6/in6.h: + +/usr/include/netinet/tcp.h: + +/usr/include/arpa/nameser.h: + +/usr/include/sys/param.h: + +/usr/include/sys/syslimits.h: + +/usr/include/machine/param.h: + +/usr/include/i386/param.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/machine/limits.h: + +/usr/include/i386/limits.h: + +/usr/include/i386/_limits.h: + +/usr/include/netdb.h: + +/usr/include/sys/malloc.h: + +/usr/include/ctype.h: + +/usr/include/runetype.h: + +include/antlr3interfaces.h: + +include/antlr3convertutf.h: + +include/antlr3exception.h: + +include/antlr3encodings.h: + +include/antlr3string.h: + +include/antlr3collections.h: + +include/antlr3input.h: + +include/antlr3commontoken.h: + +include/antlr3intstream.h: + +include/antlr3cyclicdfa.h: + +include/antlr3baserecognizer.h: + +include/antlr3tokenstream.h: + +include/antlr3bitset.h: + +include/antlr3debugeventlistener.h: + +include/antlr3basetree.h: + +include/antlr3commontreenodestream.h: + +include/antlr3commontreeadaptor.h: + +include/antlr3basetreeadaptor.h: + +include/antlr3commontree.h: + +include/antlr3recognizersharedstate.h: + +include/antlr3lexer.h: + +include/antlr3parser.h: + +include/antlr3treeparser.h: + +include/antlr3filestream.h: + +include/antlr3rewritestreams.h: Property changes on: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontoken.Plo ___________________________________________________________________ Added: svn:eol-style + native Added: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontree.Plo =================================================================== --- third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontree.Plo (rev 0) +++ third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontree.Plo 2009-07-01 18:46:00 UTC (rev 134) @@ -0,0 +1,175 @@ +antlr3commontree.lo antlr3commontree.o: src/antlr3commontree.c \ + include/antlr3commontree.h include/antlr3defs.h include/antlr3errors.h \ + antlr3config.h /usr/include/stdio.h /usr/include/_types.h \ + /usr/include/sys/_types.h /usr/include/sys/cdefs.h \ + /usr/include/machine/_types.h /usr/include/i386/_types.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h \ + /usr/include/sys/types.h /usr/include/sys/appleapiopts.h \ + /usr/include/machine/types.h /usr/include/i386/types.h \ + /usr/include/machine/endian.h /usr/include/i386/endian.h \ + /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ + /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h \ + /usr/include/sys/stat.h /usr/include/stdlib.h /usr/include/available.h \ + /usr/include/sys/wait.h /usr/include/sys/signal.h \ + /usr/include/machine/signal.h /usr/include/i386/signal.h \ + /usr/include/i386/_structs.h /usr/include/machine/_structs.h \ + /usr/include/mach/i386/_structs.h /usr/include/sys/resource.h \ + /usr/include/alloca.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/inttypes.h \ + /usr/include/unistd.h /usr/include/sys/unistd.h \ + /usr/include/sys/select.h /usr/include/sys/_select.h \ + /usr/include/netinet/in.h /usr/include/sys/socket.h \ + /usr/include/machine/_param.h /usr/include/i386/_param.h \ + /usr/include/netinet6/in6.h /usr/include/netinet/tcp.h \ + /usr/include/arpa/nameser.h /usr/include/sys/param.h \ + /usr/include/sys/syslimits.h /usr/include/machine/param.h \ + /usr/include/i386/param.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h \ + /usr/include/limits.h /usr/include/machine/limits.h \ + /usr/include/i386/limits.h /usr/include/i386/_limits.h \ + /usr/include/netdb.h /usr/include/sys/malloc.h /usr/include/ctype.h \ + /usr/include/runetype.h include/antlr3interfaces.h \ + include/antlr3convertutf.h include/antlr3basetree.h \ + include/antlr3collections.h include/antlr3string.h \ + include/antlr3commontoken.h + +include/antlr3commontree.h: + +include/antlr3defs.h: + +include/antlr3errors.h: + +antlr3config.h: + +/usr/include/stdio.h: + +/usr/include/_types.h: + +/usr/include/sys/_types.h: + +/usr/include/sys/cdefs.h: + +/usr/include/machine/_types.h: + +/usr/include/i386/_types.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: + +/usr/include/sys/types.h: + +/usr/include/sys/appleapiopts.h: + +/usr/include/machine/types.h: + +/usr/include/i386/types.h: + +/usr/include/machine/endian.h: + +/usr/include/i386/endian.h: + +/usr/include/sys/_endian.h: + +/usr/include/libkern/_OSByteOrder.h: + +/usr/include/libkern/i386/_OSByteOrder.h: + +/usr/include/sys/_structs.h: + +/usr/include/sys/stat.h: + +/usr/include/stdlib.h: + +/usr/include/available.h: + +/usr/include/sys/wait.h: + +/usr/include/sys/signal.h: + +/usr/include/machine/signal.h: + +/usr/include/i386/signal.h: + +/usr/include/i386/_structs.h: + +/usr/include/machine/_structs.h: + +/usr/include/mach/i386/_structs.h: + +/usr/include/sys/resource.h: + +/usr/include/alloca.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h: + +/usr/include/string.h: + +/usr/include/strings.h: + +/usr/include/inttypes.h: + +/usr/include/unistd.h: + +/usr/include/sys/unistd.h: + +/usr/include/sys/select.h: + +/usr/include/sys/_select.h: + +/usr/include/netinet/in.h: + +/usr/include/sys/socket.h: + +/usr/include/machine/_param.h: + +/usr/include/i386/_param.h: + +/usr/include/netinet6/in6.h: + +/usr/include/netinet/tcp.h: + +/usr/include/arpa/nameser.h: + +/usr/include/sys/param.h: + +/usr/include/sys/syslimits.h: + +/usr/include/machine/param.h: + +/usr/include/i386/param.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/machine/limits.h: + +/usr/include/i386/limits.h: + +/usr/include/i386/_limits.h: + +/usr/include/netdb.h: + +/usr/include/sys/malloc.h: + +/usr/include/ctype.h: + +/usr/include/runetype.h: + +include/antlr3interfaces.h: + +include/antlr3convertutf.h: + +include/antlr3basetree.h: + +include/antlr3collections.h: + +include/antlr3string.h: + +include/antlr3commontoken.h: Property changes on: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontree.Plo ___________________________________________________________________ Added: svn:eol-style + native Added: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontreeadaptor.Plo =================================================================== --- third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontreeadaptor.Plo (rev 0) +++ third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontreeadaptor.Plo 2009-07-01 18:46:00 UTC (rev 134) @@ -0,0 +1,183 @@ +antlr3commontreeadaptor.lo antlr3commontreeadaptor.o: \ + src/antlr3commontreeadaptor.c include/antlr3commontreeadaptor.h \ + include/antlr3defs.h include/antlr3errors.h antlr3config.h \ + /usr/include/stdio.h /usr/include/_types.h /usr/include/sys/_types.h \ + /usr/include/sys/cdefs.h /usr/include/machine/_types.h \ + /usr/include/i386/_types.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h \ + /usr/include/sys/types.h /usr/include/sys/appleapiopts.h \ + /usr/include/machine/types.h /usr/include/i386/types.h \ + /usr/include/machine/endian.h /usr/include/i386/endian.h \ + /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ + /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h \ + /usr/include/sys/stat.h /usr/include/stdlib.h /usr/include/available.h \ + /usr/include/sys/wait.h /usr/include/sys/signal.h \ + /usr/include/machine/signal.h /usr/include/i386/signal.h \ + /usr/include/i386/_structs.h /usr/include/machine/_structs.h \ + /usr/include/mach/i386/_structs.h /usr/include/sys/resource.h \ + /usr/include/alloca.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/inttypes.h \ + /usr/include/unistd.h /usr/include/sys/unistd.h \ + /usr/include/sys/select.h /usr/include/sys/_select.h \ + /usr/include/netinet/in.h /usr/include/sys/socket.h \ + /usr/include/machine/_param.h /usr/include/i386/_param.h \ + /usr/include/netinet6/in6.h /usr/include/netinet/tcp.h \ + /usr/include/arpa/nameser.h /usr/include/sys/param.h \ + /usr/include/sys/syslimits.h /usr/include/machine/param.h \ + /usr/include/i386/param.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h \ + /usr/include/limits.h /usr/include/machine/limits.h \ + /usr/include/i386/limits.h /usr/include/i386/_limits.h \ + /usr/include/netdb.h /usr/include/sys/malloc.h /usr/include/ctype.h \ + /usr/include/runetype.h include/antlr3interfaces.h \ + include/antlr3convertutf.h include/antlr3collections.h \ + include/antlr3string.h include/antlr3basetreeadaptor.h \ + include/antlr3basetree.h include/antlr3commontoken.h \ + include/antlr3debugeventlistener.h include/antlr3commontree.h + +include/antlr3commontreeadaptor.h: + +include/antlr3defs.h: + +include/antlr3errors.h: + +antlr3config.h: + +/usr/include/stdio.h: + +/usr/include/_types.h: + +/usr/include/sys/_types.h: + +/usr/include/sys/cdefs.h: + +/usr/include/machine/_types.h: + +/usr/include/i386/_types.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: + +/usr/include/sys/types.h: + +/usr/include/sys/appleapiopts.h: + +/usr/include/machine/types.h: + +/usr/include/i386/types.h: + +/usr/include/machine/endian.h: + +/usr/include/i386/endian.h: + +/usr/include/sys/_endian.h: + +/usr/include/libkern/_OSByteOrder.h: + +/usr/include/libkern/i386/_OSByteOrder.h: + +/usr/include/sys/_structs.h: + +/usr/include/sys/stat.h: + +/usr/include/stdlib.h: + +/usr/include/available.h: + +/usr/include/sys/wait.h: + +/usr/include/sys/signal.h: + +/usr/include/machine/signal.h: + +/usr/include/i386/signal.h: + +/usr/include/i386/_structs.h: + +/usr/include/machine/_structs.h: + +/usr/include/mach/i386/_structs.h: + +/usr/include/sys/resource.h: + +/usr/include/alloca.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h: + +/usr/include/string.h: + +/usr/include/strings.h: + +/usr/include/inttypes.h: + +/usr/include/unistd.h: + +/usr/include/sys/unistd.h: + +/usr/include/sys/select.h: + +/usr/include/sys/_select.h: + +/usr/include/netinet/in.h: + +/usr/include/sys/socket.h: + +/usr/include/machine/_param.h: + +/usr/include/i386/_param.h: + +/usr/include/netinet6/in6.h: + +/usr/include/netinet/tcp.h: + +/usr/include/arpa/nameser.h: + +/usr/include/sys/param.h: + +/usr/include/sys/syslimits.h: + +/usr/include/machine/param.h: + +/usr/include/i386/param.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/machine/limits.h: + +/usr/include/i386/limits.h: + +/usr/include/i386/_limits.h: + +/usr/include/netdb.h: + +/usr/include/sys/malloc.h: + +/usr/include/ctype.h: + +/usr/include/runetype.h: + +include/antlr3interfaces.h: + +include/antlr3convertutf.h: + +include/antlr3collections.h: + +include/antlr3string.h: + +include/antlr3basetreeadaptor.h: + +include/antlr3basetree.h: + +include/antlr3commontoken.h: + +include/antlr3debugeventlistener.h: + +include/antlr3commontree.h: Property changes on: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontreeadaptor.Plo ___________________________________________________________________ Added: svn:eol-style + native Added: third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontreenodestream.Plo =================================================================== --- third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontreenodestream.Plo (rev 0) +++ third-party/ANTLR3_ctarget_3_1_3/.deps/antlr3commontreenodestream.Plo 2009-07-01 18:46:00 UTC (rev 134) @@ -0,0 +1,188 @@ +antlr3commontreenodestream.lo antlr3commontreenodestream.o: \ + src/antlr3commontreenodestream.c include/antlr3commontreenodestream.h \ + include/antlr3defs.h include/antlr3errors.h antlr3config.h \ + /usr/include/stdio.h /usr/include/_types.h /usr/include/sys/_types.h \ + /usr/include/sys/cdefs.h /usr/include/machine/_types.h \ + /usr/include/i386/_types.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h \ + /usr/include/sys/types.h /usr/include/sys/appleapiopts.h \ + /usr/include/machine/types.h /usr/include/i386/types.h \ + /usr/include/machine/endian.h /usr/include/i386/endian.h \ + /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ + /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h \ + /usr/include/sys/stat.h /usr/include/stdlib.h /usr/include/available.h \ + /usr/include/sys/wait.h /usr/include/sys/signal.h \ + /usr/include/machine/signal.h /usr/include/i386/signal.h \ + /usr/include/i386/_structs.h /usr/include/machine/_structs.h \ + /usr/include/mach/i386/_structs.h /usr/include/sys/resource.h \ + /usr/include/alloca.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdarg.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/inttypes.h \ + /usr/include/unistd.h /usr/include/sys/unistd.h \ + /usr/include/sys/select.h /usr/include/sys/_select.h \ + /usr/include/netinet/in.h /usr/include/sys/socket.h \ + /usr/include/machine/_param.h /usr/include/i386/_param.h \ + /usr/include/netinet6/in6.h /usr/include/netinet/tcp.h \ + /usr/include/arpa/nameser.h /usr/include/sys/param.h \ + /usr/include/sys/syslimits.h /usr/include/machine/param.h \ + /usr/include/i386/param.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h \ + /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h \ + /usr/include/limits.h /usr/include/machine/limits.h \ + /usr/include/i386/limits.h /usr/include/i386/_limits.h \ + /usr/include/netdb.h /usr/include/sys/malloc.h /usr/include/ctype.h \ + /usr/include/runetype.h include/antlr3interfaces.h \ + include/antlr3convertutf.h include/antlr3commontreeadaptor.h \ + include/antlr3collections.h include/antlr3string.h \ + include/antlr3basetreeadaptor.h include/antlr3basetree.h \ + include/antlr3commontoken.h include/antlr3debugeventlistener.h \ + include/antlr3commontree.h include/antlr3intstream.h + +include/antlr3commontreenodestream.h: + +include/antlr3defs.h: + +include/antlr3errors.h: + +antlr3config.h: + +/usr/include/stdio.h: + +/usr/include/_types.h: + +/usr/include/sys/_types.h: + +/usr/include/sys/cdefs.h: + +/usr/include/machine/_types.h: + +/usr/include/i386/_types.h: + +/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: + +/usr/include/sys/types.h: + +/usr/include/sys/appleapiopts.h: + +/usr/include/machine/types.h: + +/usr/include/i386/types.h: + +/usr/include/machine/endian.h: + +/usr/include/i386/endian.h: + +/usr/include/sys/_endian.h: + +/usr/include/libkern/_OSByteOrder.h: + +/usr/include/libkern/i386/_OSByteOrder.h: + +/usr/include/sys/_structs.h: + +/usr/include/sys/stat.h: + +/usr/include/stdlib.h: + +/usr/include/available.h: + +/usr/include/sys/wait.h: + +/usr/include/sys/signal.h: + +/usr/include/machine/signal.h: + +/usr/include/i386/signal.h: + +/usr/include/i386/_structs.h: + +/usr/include/machine/_structs.h: + +/usr/include/mach/i386/_structs.h: + +/usr/include/sys/resource.h: + +/usr/include/alloca... [truncated message content] |
From: <the...@us...> - 2009-07-01 23:15:39
|
Revision: 145 http://pntool.svn.sourceforge.net/pntool/?rev=145&view=rev Author: thecodeweasel Date: 2009-07-01 23:15:18 +0000 (Wed, 01 Jul 2009) Log Message: ----------- makefile now cleans the pns libraries cleaned up translator includes Fixed pnheader clean to not crash Modified Paths: -------------- Makefile pnheaders/Makefile translator/Makefile Modified: Makefile =================================================================== --- Makefile 2009-07-01 23:06:03 UTC (rev 144) +++ Makefile 2009-07-01 23:15:18 UTC (rev 145) @@ -30,7 +30,7 @@ ct: objectfiles main_function.o $(COMPILER) -o ct $(PNHEADERS)/*.o $(CODEGENOBJS)/*.o $(SPNBOX)/*.o \ - $(TRANSLATOR)/*.o main_function.o $(SPNBOX)/*.a $(TRANSLATOR)/libtranslator.a + main_function.o $(SPNBOX)/*.a $(TRANSLATOR)/libtranslator.a objectfiles: cd $(PNHEADERS); make cd $(CODEGEN); make static @@ -42,14 +42,10 @@ clean: rm -f main_function.o + cd $(PNHEADERS); make clean cd codegen; make clean cd $(TRANSLATOR); make clean - cd $(SPNBOX); make clean - #my personal feeling is that these next lines should be in some other makefile - cd third-party/lp_solve_5.5; make -f Makefile.Linux clean distclean: clean cd codegen; make distclean - #this line must be last, because occasionally it errors. - #bion: consider using a test (like in codegen's distclean) to see if you run antlr's distclean cd $(TRANSLATOR); make distclean \ No newline at end of file Modified: pnheaders/Makefile =================================================================== --- pnheaders/Makefile 2009-07-01 23:06:03 UTC (rev 144) +++ pnheaders/Makefile 2009-07-01 23:15:18 UTC (rev 145) @@ -12,4 +12,4 @@ $(COMPILER) -c pns.c clean: - rm *.o \ No newline at end of file + rm *.o || true \ No newline at end of file Modified: translator/Makefile =================================================================== --- translator/Makefile 2009-07-01 23:06:03 UTC (rev 144) +++ translator/Makefile 2009-07-01 23:15:18 UTC (rev 145) @@ -42,6 +42,6 @@ rm *.o *.orig *.rej || true distclean : clean - if ! test -e ../third-party/ANTLR3_ctarget_3_1_3/Makefile; then cd ../third-party/ANTLR3_ctarget_3_1_3/; make distclean; fi + if test -e ../third-party/ANTLR3_ctarget_3_1_3/Makefile; then cd ../third-party/ANTLR3_ctarget_3_1_3/; make distclean; fi test : ; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2009-07-02 20:55:39
|
Revision: 150 http://pntool.svn.sourceforge.net/pntool/?rev=150&view=rev Author: compaqdrew Date: 2009-07-02 19:04:13 +0000 (Thu, 02 Jul 2009) Log Message: ----------- I am an idiot. Modified Paths: -------------- Makefile third-party/lp_solve_5.5/Makefile.Linux translator/Makefile Modified: Makefile =================================================================== --- Makefile 2009-07-02 00:11:54 UTC (rev 149) +++ Makefile 2009-07-02 19:04:13 UTC (rev 150) @@ -41,9 +41,13 @@ clean: rm -f main_function.o + rm -f ct cd $(PNHEADERS); make clean cd codegen; make clean cd $(TRANSLATOR); make clean + cd $(SPNBOX); make clean + #My personal opinion is that this should be in spnbox's makefile + cd third-party/lp_solve_5.5; make -f Makefile.Linux clean distclean: clean cd codegen; make distclean Modified: third-party/lp_solve_5.5/Makefile.Linux =================================================================== --- third-party/lp_solve_5.5/Makefile.Linux 2009-07-02 00:11:54 UTC (rev 149) +++ third-party/lp_solve_5.5/Makefile.Linux 2009-07-02 19:04:13 UTC (rev 150) @@ -53,7 +53,7 @@ ifeq ("$(UNAME)", "Darwin") #there's no concept of an ".so" on a mac. We use dylib for this. LIBRARIES := liblpsolve55.a else - ADDL_ARGS := liblpsolve55.a liblpsolve55.so + LIBRARIES := liblpsolve55.a liblpsolve55.so endif BINARIES = lp_solve demo @@ -87,7 +87,7 @@ ranlib lpsolve55/$@ liblpsolve55.so: $(OBJECTS) - $(CC) -fpic -shared -Wl,$(ADDL_ARGS)$@ -o lpsolve55/$@ `echo $(SRC)|sed 's/[.]c/.o/g'` $(LDFLAGS) + $(CC) -fpic -shared -Wl,-Bsymbolic -Wl,-soname,$@ -o lpsolve55/$@ `echo $(SRC)|sed 's/[.]c/.o/g'` $(LDFLAGS) clean: Modified: translator/Makefile =================================================================== --- translator/Makefile 2009-07-02 00:11:54 UTC (rev 149) +++ translator/Makefile 2009-07-02 19:04:13 UTC (rev 150) @@ -40,6 +40,8 @@ rm *.java || true clean : cleanup rm *.o *.orig *.rej || true + #this was left behind on OSX + rm -f libtranslator.a distclean : clean if test -e ../third-party/ANTLR3_ctarget_3_1_3/Makefile; then cd ../third-party/ANTLR3_ctarget_3_1_3/; make distclean; fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-04 04:08:19
|
Revision: 157 http://pntool.svn.sourceforge.net/pntool/?rev=157&view=rev Author: thecodeweasel Date: 2009-07-04 04:08:18 +0000 (Sat, 04 Jul 2009) Log Message: ----------- Improved error handling Modified Paths: -------------- third-party/ANTLR3_ctarget_3_1_3/src/antlr3baserecognizer.c third-party/ANTLR3_ctarget_3_1_3/src/antlr3lexer.c translator/Makefile translator/clibs.patch Modified: third-party/ANTLR3_ctarget_3_1_3/src/antlr3baserecognizer.c =================================================================== --- third-party/ANTLR3_ctarget_3_1_3/src/antlr3baserecognizer.c 2009-07-03 22:55:00 UTC (rev 156) +++ third-party/ANTLR3_ctarget_3_1_3/src/antlr3baserecognizer.c 2009-07-04 04:08:18 UTC (rev 157) @@ -1021,23 +1021,23 @@ { if (((pANTLR3_COMMON_TOKEN)(ex->token))->type == ANTLR3_TOKEN_EOF) { - ANTLR3_FPRINTF(stderr, "-end of input-("); + ANTLR3_FPRINTF(stderr, "-end of input-"); } else { - ANTLR3_FPRINTF(stderr, "-unknown source-("); + ANTLR3_FPRINTF(stderr, "-unknown source-"); } } else { ftext = ex->streamName->to8(ex->streamName); - ANTLR3_FPRINTF(stderr, "%s(", ftext->chars); + ANTLR3_FPRINTF(stderr, "%s - ", ftext->chars); } // Next comes the line number // - ANTLR3_FPRINTF(stderr, "%d) ", recognizer->state->exception->line); + ANTLR3_FPRINTF(stderr, "line %d ", recognizer->state->exception->line); ANTLR3_FPRINTF(stderr, " : error %d : %s", recognizer->state->exception->type, (pANTLR3_UINT8) (recognizer->state->exception->message)); Modified: third-party/ANTLR3_ctarget_3_1_3/src/antlr3lexer.c =================================================================== --- third-party/ANTLR3_ctarget_3_1_3/src/antlr3lexer.c 2009-07-03 22:55:00 UTC (rev 156) +++ third-party/ANTLR3_ctarget_3_1_3/src/antlr3lexer.c 2009-07-04 04:08:18 UTC (rev 157) @@ -413,15 +413,15 @@ // if (ex->name == NULL) { - ANTLR3_FPRINTF(stderr, "-unknown source-("); + ANTLR3_FPRINTF(stderr, "-unknown source-"); } else { ftext = ex->streamName->to8(ex->streamName); - ANTLR3_FPRINTF(stderr, "%s(", ftext->chars); + ANTLR3_FPRINTF(stderr, "%s - ", ftext->chars); } - ANTLR3_FPRINTF(stderr, "%d) ", recognizer->state->exception->line); + ANTLR3_FPRINTF(stderr, "line %d ", recognizer->state->exception->line); ANTLR3_FPRINTF(stderr, ": lexer error %d :\n\t%s at offset %d, ", ex->type, (pANTLR3_UINT8) (ex->message), @@ -436,7 +436,7 @@ { if (isprint(ex->c)) { - ANTLR3_FPRINTF(stderr, "near '%c' :\n", ex->c); + ANTLR3_FPRINTF(stderr, "expected \"%s\" near:\n", (char*) ex->custom); } else { @@ -446,7 +446,7 @@ } else { - ANTLR3_FPRINTF(stderr, "(end of input).\n\t This indicates a poorly specified lexer RULE\n\t or unterminated input element such as: \"STRING[\"]\n"); + ANTLR3_FPRINTF(stderr, "(end of input).\n\t You probably forgot to close a bracket.\n"); ANTLR3_FPRINTF(stderr, "\t The lexer was matching from line %d, offset %d, which\n\t ", (ANTLR3_UINT32)(lexer->rec->state->tokenStartLine), (ANTLR3_UINT32)(lexer->rec->state->tokenStartCharPositionInLine) @@ -702,6 +702,14 @@ static ANTLR3_BOOLEAN matchs(pANTLR3_LEXER lexer, ANTLR3_UCHAR * string) { + char* debugStr; + int i=0; + int j; + for(i=0;string[i] != ANTLR3_STRING_TERMINATOR;i++); + debugStr = calloc(i, sizeof(char)); + for(j = 0; j < i; j++) { + debugStr[j] = (char)string[j]; + } while (*string != ANTLR3_STRING_TERMINATOR) { if (lexer->input->istream->_LA(lexer->input->istream, 1) != (*string)) @@ -713,6 +721,7 @@ } lexer->rec->exConstruct(lexer->rec); + lexer->rec->state->exception->custom = debugStr; lexer->rec->state->failed = ANTLR3_TRUE; /* TODO: Implement exception creation more fully perhaps Modified: translator/Makefile =================================================================== --- translator/Makefile 2009-07-03 22:55:00 UTC (rev 156) +++ translator/Makefile 2009-07-04 04:08:18 UTC (rev 157) @@ -1,4 +1,4 @@ -COMPILER=gcc -g -O0 +COMPILER=gcc -g -std=gnu89 -O0 INCLUDES=-iquote../pnheaders -I../third-party/ANTLR3_ctarget_3_1_3 -I../third-party/ANTLR3_ctarget_3_1_3/include pnscript : dataStructures.o main.o pnscriptParser.o pnscriptLexer.o pncompactor.o pngenerator.o Modified: translator/clibs.patch =================================================================== --- translator/clibs.patch 2009-07-03 22:55:00 UTC (rev 156) +++ translator/clibs.patch 2009-07-04 04:08:18 UTC (rev 157) @@ -60,3 +60,99 @@ } return newToken; } +Index: third-party/ANTLR3_ctarget_3_1_3/src/antlr3lexer.c +=================================================================== +--- third-party/ANTLR3_ctarget_3_1_3/src/antlr3lexer.c (revision 151) ++++ ../third-party/ANTLR3_ctarget_3_1_3/src/antlr3lexer.c (working copy) +@@ -413,15 +413,15 @@ + // + if (ex->name == NULL) + { +- ANTLR3_FPRINTF(stderr, "-unknown source-("); ++ ANTLR3_FPRINTF(stderr, "-unknown source-"); + } + else + { + ftext = ex->streamName->to8(ex->streamName); +- ANTLR3_FPRINTF(stderr, "%s(", ftext->chars); ++ ANTLR3_FPRINTF(stderr, "%s - ", ftext->chars); + } + +- ANTLR3_FPRINTF(stderr, "%d) ", recognizer->state->exception->line); ++ ANTLR3_FPRINTF(stderr, "line %d ", recognizer->state->exception->line); + ANTLR3_FPRINTF(stderr, ": lexer error %d :\n\t%s at offset %d, ", + ex->type, + (pANTLR3_UINT8) (ex->message), +@@ -436,7 +436,7 @@ + { + if (isprint(ex->c)) + { +- ANTLR3_FPRINTF(stderr, "near '%c' :\n", ex->c); ++ ANTLR3_FPRINTF(stderr, "expected \"%s\" near:\n", (char*) ex->custom); + } + else + { +@@ -446,7 +446,7 @@ + } + else + { +- ANTLR3_FPRINTF(stderr, "(end of input).\n\t This indicates a poorly specified lexer RULE\n\t or unterminated input element such as: \"STRING[\"]\n"); ++ ANTLR3_FPRINTF(stderr, "(end of input).\n\t You probably forgot to close a bracket.\n"); + ANTLR3_FPRINTF(stderr, "\t The lexer was matching from line %d, offset %d, which\n\t ", + (ANTLR3_UINT32)(lexer->rec->state->tokenStartLine), + (ANTLR3_UINT32)(lexer->rec->state->tokenStartCharPositionInLine) +@@ -702,6 +702,14 @@ + static ANTLR3_BOOLEAN + matchs(pANTLR3_LEXER lexer, ANTLR3_UCHAR * string) + { ++ char* debugStr; ++ int i=0; ++ int j; ++ for(i=0;string[i] != ANTLR3_STRING_TERMINATOR;i++); ++ debugStr = calloc(i, sizeof(char)); ++ for(j = 0; j < i; j++) { ++ debugStr[j] = (char)string[j]; ++ } + while (*string != ANTLR3_STRING_TERMINATOR) + { + if (lexer->input->istream->_LA(lexer->input->istream, 1) != (*string)) +@@ -713,6 +721,7 @@ + } + + lexer->rec->exConstruct(lexer->rec); ++ lexer->rec->state->exception->custom = debugStr; + lexer->rec->state->failed = ANTLR3_TRUE; + + /* TODO: Implement exception creation more fully perhaps +Index: third-party/ANTLR3_ctarget_3_1_3/src/antlr3baserecognizer.c +=================================================================== +--- third-party/ANTLR3_ctarget_3_1_3/src/antlr3baserecognizer.c (revision 151) ++++ ../third-party/ANTLR3_ctarget_3_1_3/src/antlr3baserecognizer.c (working copy) +@@ -1021,23 +1021,23 @@ + { + if (((pANTLR3_COMMON_TOKEN)(ex->token))->type == ANTLR3_TOKEN_EOF) + { +- ANTLR3_FPRINTF(stderr, "-end of input-("); ++ ANTLR3_FPRINTF(stderr, "-end of input-"); + } + else + { +- ANTLR3_FPRINTF(stderr, "-unknown source-("); ++ ANTLR3_FPRINTF(stderr, "-unknown source-"); + } + } + else + { + ftext = ex->streamName->to8(ex->streamName); +- ANTLR3_FPRINTF(stderr, "%s(", ftext->chars); ++ ANTLR3_FPRINTF(stderr, "%s - ", ftext->chars); + } + + // Next comes the line number + // + +- ANTLR3_FPRINTF(stderr, "%d) ", recognizer->state->exception->line); ++ ANTLR3_FPRINTF(stderr, "line %d ", recognizer->state->exception->line); + ANTLR3_FPRINTF(stderr, " : error %d : %s", + recognizer->state->exception->type, + (pANTLR3_UINT8) (recognizer->state->exception->message)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ste...@us...> - 2009-07-10 04:46:48
|
Revision: 194 http://pntool.svn.sourceforge.net/pntool/?rev=194&view=rev Author: StephenCamp Date: 2009-07-10 04:46:45 +0000 (Fri, 10 Jul 2009) Log Message: ----------- Added row and column add and remove functions to matrixmath. These employ optimizations when possible based on the internals of the matrix structure - if the structure is ever changed these functions will have to be changed. Actually adding the readme file this time. Found two apparent bugs in matrix.c: GetMatrixEl and SetMatrixEl for type-1 matrices that have been transposed appear to have been swapping row and column count. Modified Paths: -------------- pnheaders/matrix.c spnbox/Makefile spnbox/matrixmath.c spnbox/matrixmath.h Added Paths: ----------- spnbox/README.txt Modified: pnheaders/matrix.c =================================================================== --- pnheaders/matrix.c 2009-07-08 20:55:01 UTC (rev 193) +++ pnheaders/matrix.c 2009-07-10 04:46:45 UTC (rev 194) @@ -80,7 +80,7 @@ mtype GetMatrixEl(const matrix* m, int i, int j) { switch(m->type) { case 1: - return m->trans?m->elem[j*m->nr+i]:m->elem[i*m->nc+j]; + return m->trans?m->elem[j*m->nc+i]:m->elem[i*m->nc+j]; case 2: return m->trans?m->ar[j][i]:m->ar[i][j]; case 3: @@ -179,7 +179,7 @@ switch(m->type) { case 1: if(m->trans) - m->elem[j*m->nr+i] = x; + m->elem[j*m->nc+i] = x; else m->elem[i*m->nc+j] = x; break; Modified: spnbox/Makefile =================================================================== --- spnbox/Makefile 2009-07-08 20:55:01 UTC (rev 193) +++ spnbox/Makefile 2009-07-10 04:46:45 UTC (rev 194) @@ -3,7 +3,7 @@ COMPILER=gcc -g -all: actn.o chkcons.o ilpadm.o ipslv.o ipsolve.o isadm.o linenf.o matrixmath.o MemoryManager.o msplit.o nltrans.o pn2acpn.o pn2eacpn.o supervis.o liblpsolve55.a +all: actn.o chkcons.o ilpadm.o ipslv.o ipsolve.o isadm.o issiph.o linenf.o matrixmath.o MemoryManager.o msplit.o nltrans.o pn2acpn.o pn2eacpn.o supervis.o liblpsolve55.a actn.o: actn.c spnbox.h MemoryManager.h matrixmath.h ../pnheaders/general.h ../pnheaders/matrix.h $(COMPILER) -c actn.c @@ -16,13 +16,16 @@ ipslv.o: ipslv.c spnbox.h ../third-party/lp_solve_5.5/lp_lib.h $(COMPILER) -c ipslv.c - + ipsolve.o: ipsolve.c spnbox.h matrixmath.h ../pnheaders/general.h ../pnheaders/matrix.h $(COMPILER) -c ipsolve.c isadm.o: isadm.c spnbox.h MemoryManager.h matrixmath.h ../pnheaders/general.h ../pnheaders/matrix.h $(COMPILER) -c isadm.c +issiph.o: ../issiph.c ../spnbox.h ../../pnheaders/general.h ../../pnheaders/matrix.h + $(COMPILER) -c ../issiph.c + linenf.o: linenf.c spnbox.h MemoryManager.h matrixmath.h ../pnheaders/general.h ../pnheaders/matrix.h $(COMPILER) -c linenf.c Added: spnbox/README.txt =================================================================== --- spnbox/README.txt (rev 0) +++ spnbox/README.txt 2009-07-10 04:46:45 UTC (rev 194) @@ -0,0 +1,62 @@ +#ABOUT +SPNBOX implements the Petri net supervisory control functions originally developed by Dr. Iordache for Matlab. + +#COMPILING +To generate object files for the entire SPNBOX toolset, run "make" from the pntool/spnbox directory. + +Note that SPNBOX makes use of the LPSOLVE MILP solver API found in the pntool/third-party directory. The makefile will attempt to copy the compiled library liblpsolve55.a from the LPSOLVE directories into the pntool/spnbox directory if it is not already present. If the LPSOLVE library is not present in its own directory, the SPNBOX makefile will invoke LPSOLVE's linux-targeted makefile to build the lpsolve library. + +#TESTING +The subdirectory "tests" contains test files for the SPNBOX functions. There are source files for a test program for each function except chkcons, which is used as a subroutine of other functions and so tested implicitly. +The makefile within the directory will make any of the test programs. To generate the test program for a particular function, use a command of the form: +make <functionname> +This will generate an executable called <functionname>.exe. +make all will generate test executables for all spnbox functions. + +For all with such test programs except that ipslv, the test program is implemented as a program that will read from an input stream containing text in a human-readable format, interpret the text as parameters to the function, make a function call, and display the results. For format specifications, see the comments in StructuredIO.c/h. + +The programs may be invoked with a single command line argument, which will be taken as the name of a text file from which to read the input. If no command line argument is used the test programs will take input from the console. + +Pre-formatted test scripts with problems to test each part of a function have been provided. These are named in the form test-<functionname>.txt. + +Thus, to test ipsolve with the default test script the following command sequence might be issued: + +cd ~/pntool/spnbox/tests +make ipsolve +./ipsolve test-ipsolve.txt + +#FILES +Main directory: +- spnbox.h: This is the header file containing the definitions for all the SPNBOX + functions, as well as various constant definitions. +- matrixmath.h & matrixmath.c: These implement various matrix operations used by + other SPNBOX functions. +- deallocation.c: This implements functions to deallocate the structures returned + by SPNBOX functions. +- Makefile: This is the main makefile. When used without a target it builds + object files that implement all SPNBOX functionality. It can take as a target + the command "clean", upon reciept of which it removes all object files, all + library (*.a) files, moves to the third-party/lp_solve_5.5/ directory, and + executes the linux-targeted makefile to clean the lpsolve libraries and + intermediate files. +- Each of the other files corresponds to a single SPNBOX function. + +tests subdirectory: +- test.c & test.h: These define and implement a few subroutines used by many of + the test programs as well as implemented the pntool "is_verbose" function to + ensure maximum verbosity during testing. The header file also includes header + files common to all the test programs. +- StructuredIO.c & StructuredIO.h: These define and implement a pair of functions, + ParseStructure and DisplayStructure. ParseStructure is used used to parse human- + readable text from a stream as described in a format string and with it fill + an arbitrary number of variables. It is an analogue of sprintf with support + for more complex data structures such as arrays and matrices. + DisplayStructure is used to display such data structures in a human-readable + format as described by a similar format string. For usage and format string + information see the comments in the files. These functions are used by nearly + all the test programs to make the collection of input easier. +- Makefile: This is the test makefile. It is responsible for building various + test routines and takes targets as described above in #TESTING. +- All other files are the source files for the test executables for various + functions. + Modified: spnbox/matrixmath.c =================================================================== --- spnbox/matrixmath.c 2009-07-08 20:55:01 UTC (rev 193) +++ spnbox/matrixmath.c 2009-07-10 04:46:45 UTC (rev 194) @@ -459,3 +459,280 @@ return 1; } +/*This function is called by AddRows and AddColumns when they detect that the +matrix is properly formatted for optimized row/column add. It assumes that +basic parameter checking has been done by AddRow and AddCol. It is a private +function internal to this file.*/ +static void AddRowsFast(matrix* m, int start, int rowsToAdd) +{ + int i; + mtype** NewAr; + m->nr += rowsToAdd; + NewAr = tcalloc(m->nr, sizeof(mtype*)); + for (i = 0; i < m->nr; i++) + { + /*If we have not yet reached the insertion point, copy addresses directly.*/ + if (i < start) + { + NewAr[i] = m->ar[i]; + } + /*At the insertion point, allocate space for a new row.*/ + else if (i < start + rowsToAdd) + { + NewAr[i] = tcalloc(m->nc, sizeof(mtype)); + } + /*After the insertion point, each new array element should get the value + of the previous element in the original array.*/ + else + { + NewAr[i] = m->ar[i - rowsToAdd]; + } + } + /*Free and reassign memory.*/ + free(m->ar); + m->ar = NewAr; +} + +/*This function is called by AddRows and AddColumns when they detect that a +matrix is not properly formatted for fast row add. It is a private function +internal to this file.*/ +static void AddRowsSlow(matrix* m, int start, int rowsToAdd) +{ + int i; + matrix NewM; + + /*Preserve the transpose state of the matrix.*/ + if (m->trans) + { + AllocateMatrixType(m->type, &NewM, NumberOfColumns(*m), NumberOfRows(*m) + rowsToAdd); + TransposeMatrix(&NewM); + } + else + { + AllocateMatrixType(m->type, &NewM, NumberOfRows(*m) + rowsToAdd, NumberOfColumns(*m)); + } + + for (i = 0; i < NumberOfRows(NewM); i++) + { + if (i < start) + { + CopyBlock(1, NumberOfColumns(NewM), m, i, 0, &NewM, i, 0); + } + else if (i >= start + rowsToAdd) + { + CopyBlock(1, NumberOfColumns(NewM), m, i - rowsToAdd, 0, &NewM, i, 0); + } + } + DeallocateMatrix(m); + (*m) = NewM; +} + +/*This function is called by RemoveRow and RemoveCol when they detect that the +matrix is properly formatted for an optimized row/column removal. It assumes +that basic parameter checking has been done by AddRow and AddCol. It is a +private function internal to this file.*/ +static void RemoveRowsFast(matrix* m, int start, int rowsToAdd) +{ + int i; + mtype** NewAr; + NewAr = tcalloc(m->nr, sizeof(mtype*)); + for (i = 0; i < m->nr; i++) + { + if (i < start) + { + NewAr[i] = m->ar[i]; + } + else if (i < start + rowsToAdd) + { + free(m->ar[i]); + } + else + { + NewAr[i - rowsToAdd] = m->ar[i]; + } + } + free(m->ar); + m->ar = NewAr; + m->nr -= rowsToAdd; +} + +/*This function is called by RemoveRows and RemoveColumns when they detect that +a matrix is not properly formatted for fast row removal. It is a private +function internal to this file.*/ +static int RemoveRowsSlow(matrix *m, int start, int rowsToRemove) +{ + int i; + matrix NewM; + /*Preserve the transpose state of the matrix.*/ + if (m->trans) + { + AllocateMatrixType(m->type, &NewM, NumberOfColumns(*m), NumberOfRows(*m) - rowsToRemove); + TransposeMatrix(&NewM); + } + else + { + AllocateMatrixType(m->type, &NewM, NumberOfRows(*m) - rowsToRemove, NumberOfColumns(*m)); + } + for (i = 0; i < NumberOfRows(NewM); i++) + { + if (i < start) + { + CopyBlock(1, NumberOfColumns(NewM), m, i, 0, &NewM, i, 0); + } + else + { + CopyBlock(1, NumberOfColumns(NewM), m, i + rowsToRemove, 0, &NewM, i, 0); + } + } + DeallocateMatrix(m); + *m = NewM; +} + +int AddRows(matrix* m, int start, int rowsToAdd) +{ + int i; + matrix NewM; + if (! m) + { + merror(0, "ADDROWS: Null matrix pointer"); + return 0; + } + /*Make sure the starting point is valid. Start will be the index of the first + of the new rows added. If index < 0, default to adding at the end of the + matrix.*/ + if (start < 0) start = NumberOfRows(*m); + if (start > NumberOfRows(*m)) + { + merror(0, "ADDROWS: First new row index is out of range"); + return 0; + } + /*Make sure the rowsToAdd is valid. Cannot be less than 1.*/ + if (rowsToAdd < 1) + { + merror(0, "ADDROWS: Rows to add is negative or zero"); + return 0; + } + + if (m->type == 2 && (! m->trans)) + { + /*If matrix is an untransposed type 2, the row add can be heavily + optimized.*/ + AddRowsFast(m, start, rowsToAdd); + } + else + { + AddRowsSlow(m, start, rowsToAdd); + return 1; + } +} + +int AddColumns(matrix* m, int start, int colsToAdd) +{ + if (! m) + { + merror(0, "ADDCOLUMNS: Null matrix pointer"); + return 0; + } + /*Make sure the starting point is valid. Start will be the index of the first + of the new columns added. If index < 0, default to adding at the end of the + matrix.*/ + if (start < 0) start = NumberOfColumns(*m); + if (start > NumberOfColumns(*m)) + { + merror(0, "ADDCOLUMNS: First new row index is out of range"); + return 0; + } + /*Make sure the colsToAdd is valid. Cannot be less than 1.*/ + if (colsToAdd < 1) + { + merror(0, "ADDCOLUMNS: cols to add is negative or zero"); + return 0; + } + + if (m->type == 2 && m->trans) + { + /*If matrix is a transposed type 2, the column add can be heavily + optimized.*/ + AddRowsFast(m, start, colsToAdd); + } + else + { + /*AddRowsSlow just adds rows. Transpose the matrix to do the add, then + untranspose when we're done.*/ + TransposeMatrix(m); + AddRowsSlow(m, start, colsToAdd); + TransposeMatrix(m); + } + return 1; +} + +int RemoveRows(matrix* m, int start, int rowsToRemove) +{ + /*Matrix pointer cannot be null.*/ + if (! m) + { + merror(0, "REMOVEROWS: Null matrix pointer"); + return 0; + } + /*Start has to be the index of the first row to remove.*/ + if (start < 0 || start >= NumberOfRows(*m)) + { + merror(0, "REMOVEROWS: Index of first row to remove is out of range"); + return 0; + } + /*The row count cannot be less than 1, nor can it be so great that it + requires the removal of rows that do not exist.*/ + if (rowsToRemove < 1 || start + rowsToRemove > NumberOfRows(*m)) + { + merror(0, "REMOVEROWS: Number of rows to remove is out of range"); + return 0; + } + /*See if we can optimize the removal.*/ + if (m->type == 2 && ! m->trans) + { + RemoveRowsFast(m, start, rowsToRemove); + } + else + { + RemoveRowsSlow(m, start, rowsToRemove); + } + return 1; +} + +int RemoveColumns(matrix* m, int start, int colsToRemove) +{ + /*Matrix pointer cannot be null.*/ + if (! m) + { + merror(0, "REMOVECOLUMNS: Null matrix pointer"); + return 0; + } + /*Start has to be the index of the first column to remove.*/ + if (start < 0 || start >= NumberOfColumns(*m)) + { + merror(0, "REMOVECOLUMNS: Index of first column to remove is out of range"); + return 0; + } + /*The column count cannot be less than 1, nor can it be so great that it + requires the removal of columns that do not exist.*/ + if (colsToRemove < 1 || start + colsToRemove > NumberOfColumns(*m)) + { + merror(0, "REMOVECOLUMNS: Number of columns to remove is out of range"); + return 0; + } + /*See if we can optimize the removal.*/ + if (m->type == 2 && m->trans) + { + RemoveRowsFast(m, start, colsToRemove); + } + else + { + /*If not, transpose the matrix so we can use the row removal function. + Untranspose when done.*/ + TransposeMatrix(m); + RemoveRowsSlow(m, start, colsToRemove); + TransposeMatrix(m); + } + return 1; +} + Modified: spnbox/matrixmath.h =================================================================== --- spnbox/matrixmath.h 2009-07-08 20:55:01 UTC (rev 193) +++ spnbox/matrixmath.h 2009-07-10 04:46:45 UTC (rev 194) @@ -68,6 +68,49 @@ int MatrixEqualMatrix(matrix* A, matrix* B); /*MatrixEqualMatrix tests the equality of matrices A and B. It returns nonzero if the matrices are equal and zero if they are different.*/ + +int AddRows(matrix* m, int start, int rowsToAdd); +/*AddRows adds one or more contiguous rows to the given matrix. +start The index of the first of the new rows. If it is set to a negative + number, AddRows adds the block of rows to the bottom of the matrix. + If it is too high the function will show an error message and + terminate execution. +rowsToAdd The number of rows to add to the matrix. Rows will be added in a + contiguous block. +Return value is nonzero on success and zero on failure. +Note that if the matrix is a type-2 un-transposed, AddRows is able to invoke +a special highly-optimized algorithm that reduces the computational complexity +of the operation by at least a factor corresponding to the number of columns in +the matrix.*/ + +int AddColumns(matrix* m, int start, int colsToAdd); +/*AddColumns adds one or more contiguous columns to the given matrix. See +AddRows; the parameters of AddColumns are the column analogues of AddRows' +parameters. The return value is nonzero on success and zero on failure. +AddColumns is able to employ the same type of optimization as AddRows (decreasing +computational complexity by a factor at least equal to the number of rows in the +matrix) if and only if the matrix is a type-2 transposed.*/ + +int RemoveRows(matrix* m, int start, int rowsToRemove); +/*RemoveRows removes one or more contiguous rows from the given matrix. +start The index of the first row to remove. If it is out of range the + function will fail with an error message. +rowsToRemove The number of rows to remove. If the number is less than 1 or + large enough that it would attempt to remove nonexistant rows, + the function fails with an error message and terminates execution. +The return value is nonzero on success and zero on failure. +If RemoveRows is passed a type-2 untransposed matrix, it employs optimization +that reduces the computational complexity of the operation by at least a +factor corresponding to the number of columns in the matrix.*/ + +int RemoveColumns(matrix* m, int start, int colsToRemove); +/*RemoveColumns removes one or more contiguous columns from the given matrix. +See RemoveRows; the parameters of RemoveColumns are the column analogues of +RemoveRows. The return value is nonzero on success and zero on failure. +RemoveColumns is able to employ the same type of optimization as RemoveRows +(reducing computational copmlexity by a factor at least equal to the number of +rows in the matrix) if and only if the matrix is a type-2 transposed.*/ + #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mio...@us...> - 2011-04-02 00:08:41
|
Revision: 244 http://pntool.svn.sourceforge.net/pntool/?rev=244&view=rev Author: miordache Date: 2011-04-02 00:08:32 +0000 (Sat, 02 Apr 2011) Log Message: ----------- 2011 update--first part Modified Paths: -------------- Makefile spnbox/spnbox.h spnbox/tests/Makefile spnbox/tests/StructuredIO.c translator/pngenerator.c translator/pngenerator.g Added Paths: ----------- Makefile09 newcodegen/ newcodegen/Makefile newcodegen/ProcessTemplate.c newcodegen/SupervisorTemplate.c newcodegen/codegen.h newcodegen/compexample.c newcodegen/filltmpl.lex newcodegen/plantCompiler.c newcodegen/plantCompiler.h newcodegen/spcommon.h newcodegen/supervisorCompiler.c pnheaders09/ spnbox/disj2normal.c spnbox/disj2pn.c spnbox/disq2disj.c spnbox/tests/test-lindisj.c spnbox/tests/test-lindisj.txt spnbox/tests/test-lindisq.c spnbox/tests/test-lindisq.txt spnbox/tests/test-lintree.c spnbox/tests/test-lintree.txt spnbox/tests/test-superdis.c spnbox/tree2spec.c Removed Paths: ------------- README.txt pnheaders/ Modified: Makefile =================================================================== --- Makefile 2009-08-23 07:45:43 UTC (rev 243) +++ Makefile 2011-04-02 00:08:32 UTC (rev 244) @@ -7,7 +7,6 @@ # the object code. # # 2) Place all relevant object files and libraries in the same directory. -# Codegen note: makefile is in codegen/, however .o files are codegen/src/*.o # 3) Place no other object files in that directory (or else please make # appropriate changes below). # @@ -23,30 +22,33 @@ PNHEADERS=pnheaders SPNBOX=spnbox -CODEGEN=codegen -CODEGENOBJS = codegen/src +CODEGEN=newcodegen +CODEGENOBJS = $(CODEGEN)/obj TRANSLATOR=translator ct: objectfiles main_function.o $(COMPILER) -o ct $(PNHEADERS)/*.o $(CODEGENOBJS)/*.o $(SPNBOX)/*.o \ main_function.o $(SPNBOX)/*.a $(TRANSLATOR)/libtranslator.a + cp ct.exe .. + objectfiles: cd $(PNHEADERS); make cd $(CODEGEN); make static cd $(SPNBOX); make cd $(TRANSLATOR); make -main_function.o: $(PNHEADERS)/main_function.c $(PNHEADERS)/pns.h $(SPNBOX)/spnbox.h $(CODEGEN)/src/codegen.h +main_function.o: $(PNHEADERS)/main_function.c $(PNHEADERS)/pns.h $(SPNBOX)/spnbox.h $(CODEGEN)/codegen.h $(COMPILER) -c $(PNHEADERS)/main_function.c -Ispnbox -I$(CODEGEN)/src -I$(PNHEADERS) clean: rm -f main_function.o rm -f ct cd $(PNHEADERS); make clean - cd codegen; make clean + cd $(CODEGEN); make clean cd $(TRANSLATOR); make clean cd $(SPNBOX); make clean distclean: clean - cd codegen; make distclean - cd $(TRANSLATOR); make distclean \ No newline at end of file + cd $(CODEGEN); make distclean + cd $(TRANSLATOR); make distclean + Added: Makefile09 =================================================================== --- Makefile09 (rev 0) +++ Makefile09 2011-04-02 00:08:32 UTC (rev 244) @@ -0,0 +1,54 @@ +# This is the make file of the 2009 version of the program. +# +# Modify it so that the files you contribute are properly included. +# I propose the following format (but you may change it if necessary). +# +# 1) Create a local make file in your directory. It should generate +# the object code. +# +# 2) Place all relevant object files and libraries in the same directory. +# Codegen note: makefile is in codegen/, however .o files are codegen/src/*.o +# 3) Place no other object files in that directory (or else please make +# appropriate changes below). +# +# Please make sure all commands can be run in Linux! +# +# Changelog: +# 6/26/09 SC: Changed ct instruction to include static library files +#(.a) from the spnbox directories. This is necessary to link the lpsolve library. +# +# If you make changes to this format, please document them above. + +COMPILER=gcc -g + +PNHEADERS=pnheaders09 +SPNBOX=spnbox +CODEGEN=codegen +CODEGENOBJS = codegen/src +TRANSLATOR=translator + +ct: objectfiles main_function.o + $(COMPILER) -o ct $(PNHEADERS)/*.o $(CODEGENOBJS)/*.o $(SPNBOX)/*.o \ + main_function.o $(SPNBOX)/*.a $(TRANSLATOR)/libtranslator.a + cp ct.exe .. + +objectfiles: + cd $(PNHEADERS); make + cd $(CODEGEN); make static + cd $(SPNBOX); make + cd $(TRANSLATOR); make + +main_function.o: $(PNHEADERS)/main_function.c $(PNHEADERS)/pns.h $(SPNBOX)/spnbox.h $(CODEGEN)/src/codegen.h + $(COMPILER) -c $(PNHEADERS)/main_function.c -Ispnbox -I$(CODEGEN)/src -I$(PNHEADERS) + +clean: + rm -f main_function.o + rm -f ct + cd $(PNHEADERS); make clean + cd codegen; make clean + cd $(TRANSLATOR); make clean + cd $(SPNBOX); make clean + +distclean: clean + cd codegen; make distclean + cd $(TRANSLATOR); make distclean Deleted: README.txt =================================================================== --- README.txt 2009-08-23 07:45:43 UTC (rev 243) +++ README.txt 2011-04-02 00:08:32 UTC (rev 244) @@ -1,20 +0,0 @@ -You're looking at the SOURCE CODE REPOSITORY for pntool - -Drew Crawford administrates this repo. If you need help, send me an e-mail: dr...@se... - -Here's the directory structure: - -codegen - these files are maintained by Drew Crawford and Kris Eggert. - This will become the code generating portion of the petri net. - -pnheaders - these files are maintained by Dr. Iordache. They provide functions - for the manipulation of PN objects. - -spnbox - this code performs the supervisory control. Maintained by - Stephen Camp. Uses LPSOLVE as the MILP solver. LPSOLVE is - distributed under the LGPL licence. - -translator - this code takes a high-level-language spec and turns it into a pns datastructure. Maintained by Bion Oren. Uses ANTLR - (third-party/ANTLR3_ctarget_x_x_x/). ANTLR is distributed under the BSD license. - -Feel free to add more directories! Track your code in here! Added: newcodegen/Makefile =================================================================== --- newcodegen/Makefile (rev 0) +++ newcodegen/Makefile 2011-04-02 00:08:32 UTC (rev 244) @@ -0,0 +1,25 @@ +COMPILER=gcc -g +PNDIR=../pnheaders/ + +comp: plantCompiler.o compexample.o filltmpl.fl.o supervisorCompiler.o + make -f pnexample.mak -C$(PNDIR) + $(COMPILER) -o compexample plantCompiler.o compexample.o filltmpl.fl.o $(PNDIR)matrix.o $(PNDIR)general.o $(PNDIR)pns.o $(PNDIR)insert.o supervisorCompiler.o + +static: plantCompiler.o filltmpl.fl.o supervisorCompiler.o + cp plantCompiler.o filltmpl.fl.o supervisorCompiler.o obj/ + +compexample.o: compexample.c *.h $(PNDIR)*.h + $(COMPILER) -c -I$(PNDIR) compexample.c + +plantCompiler.o: plantCompiler.c *.h $(PNDIR)*.h + $(COMPILER) -c -I$(PNDIR) plantCompiler.c + +supervisorCompiler.o: supervisorCompiler.c *.h $(PNDIR)*.h + $(COMPILER) -c -I$(PNDIR) supervisorCompiler.c + +filltmpl.fl.o: filltmpl.lex + flex -Pfl -ofilltmpl.fl.c filltmpl.lex + $(COMPILER) -c filltmpl.fl.c + +clean: + rm *.o obj/*.o || true \ No newline at end of file Added: newcodegen/ProcessTemplate.c =================================================================== --- newcodegen/ProcessTemplate.c (rev 0) +++ newcodegen/ProcessTemplate.c 2011-04-02 00:08:32 UTC (rev 244) @@ -0,0 +1,212 @@ + +#include<stdarg.h> +#include<stdio.h> +#include<stdlib.h> +#include<time.h> +#include<string.h> +#include<pthread.h> +#include<limits.h> +#include<sys/types.h> + +#ifdef ___PROCESS +int ___debug = 0; // value determined by parameters of main function +#else +extern int ___debug; // corresponds to variable of supervisor +#endif + +#include"spcommon.h" + +static void* ___main_function(void* ___v); + +// +++++++ OTHER DECLARATIONS (GENERATED CODE HERE) + + +#ifndef ___NTR + +// Here are some default definitions allowing to compile the file without +// automatically generated code. This is for debugging purposes. + +#define ___NTR 1 // ___NTR defined in the automatically generated code +// TR represents a list of transitions and NTR its max size. +static const char ___TRinfo[10]; + +#endif + +static void* ___main_function(void* ___v) { + int ___i, ___j, ___flag, ___ntran; + time_t ___ctime; + char* ___str; + struct ___thread_data *___pthr = ___v; + struct ___trans ___TR[___NTR]; + + void *p___ = 0; // Reserved for user code. Useful when there are + // several thread copies running in parallel. + // Each thread can allocate memory and associate p___ to the + // address, if needed. + // At the end of the program p___ should be deallocated if nonzero!!! + + int ___place; // denotes the value of the current place + int ___finish; // the program terminates when its value is nonzero + + ___finish = 0; + ___flag = 0; + ___place = ___pthr->state; + + // !!! To define communication parameters ... + + time(&___ctime);//___ctime used to initialize the random number generator + // Next, ___ctime is modified so that different processes started at the + // same time do not have the same ___ctime. + // The random number generator of the threads is initialized by supervisor. +#ifndef ___THREAD + ___ctime += (int) getpid(); +#else + ___ctime += (int) getpid() + (int)___pthr->id; +#endif + srand(___ctime%64000); + + while(!___finish) { + switch(___place) { + + // +++++++ case list (GENERATED CODE HERE) + + default: + // display error message for undefined place + debugInfo("Internal ERROR: the place %d is undefined", ___place); + ___finish = 1; + } // ends main switch block + + if(___finish) + break; // exit main while loop + + //debugInfo("Calling ___NextState"); + ___place = ___NextState(___TR, ___TRinfo, ___place, ___i, &___finish, ___pthr, debugInfo); + // at this point ___i = no of elements of ___TR + //debugInfo("Going to place %d", ___place); // place = -1 when terminating + + } // ends main while loop + + ___send_exit_notification(___pthr); + + debugInfo("The end of the main function was reached"); + + return 0; +} + + +#ifndef ___THREAD + + +void ___print_args(int argc, char* argv[], struct ___thread_data *___pthr, struct ___thread_comm *___pc) { + int ___i, ___j; + char *___str, *___s1 = 0, *___s2 = 0, *___s3 = 0, *___s4 = 0; + + if(___debug) { + if(argc <= 1) + asprintf(&___s1, "The main function was entered. The main function has no parameters."); // This line should not be reached! + else { + for(___i = 0, ___j = 0; ___i < argc; ___i++) + ___j += strlen(argv[___i]); + ___j += argc + 1; + ___str = malloc(___j*sizeof(char)); + for(___i = 0, ___j = 0; ___i < argc - 1; ___i++) { + sprintf(___str + ___j, "%s ", argv[___i]); + ___j += strlen(argv[___i]) + 1; + } + sprintf(___str + ___j, "%s", argv[___i]); + asprintf(&___s1, "The process was started with the following command line\n\t%s", ___str); + free(___str); + } + if(___pthr || ___pc) { + asprintf(&___s2, "\nThe following parameters were received:\n"); + if(___pthr) + asprintf(&___s3, "id = %d debug = %d initial state = %d", (int)___pthr->id, (int)___pthr->debug, (int)___pthr->state); + if(___pc) + asprintf(&___s4, " write end = %d", (int)___pc->pwrite); + } + if(!___s2) asprintf(&___s2, " "); + if(!___s3) asprintf(&___s3, " "); + if(!___s4) asprintf(&___s4, " "); + } + debugInfo("%s%s%s%s", ___s1, ___s2, ___s3, ___s4); + free(___s1); free(___s2); free(___s3); free(___s4); +} + + +#define ___RETURN_IF_ERROR_1(___f, ___string) \ + if(!___f) { \ + ___print_args(argc, argv, ___pthr, ___pc);\ + debugInfo(___string); \ + free(___pthr); free(___pc); \ + return 1; \ + } + +#define ___RETURN_IF_ERROR_2(___f, ___string) \ + if(!___f) { \ + ___print_args(argc, argv, ___pthr, ___pc);\ + debugInfo(___string); \ + close(___pc->pread); close(___pc->pwrite); \ + ___send_exit_notification(___pthr); \ + free(___pthr); free(___pc); \ + return 1; \ + } + + +int main(int argc, char* argv[]) { + + // Update to read from pipe parameters! See ___upd_comm_param + + int ___i, ___j, ___flag = 0, ___vplace; + char* ___str; + struct ___thread_data *___pthr = 0; + struct ___thread_comm *___pc = 0; + + ___debug = 1; // allow messages if errors occur at the beginning + + ___pthr = calloc(1, sizeof(*___pthr)); + if(!___pthr) { + debugInfo("Could not allocate 'struct ___thread_data' object"); + return 1; + } + ___pc = calloc(1, sizeof(*___pc)); + if(!___pc) { + free(___pthr); + debugInfo("Could not allocate 'struct ___thread_comm' object"); + return 1; + } + + ___flag = (argc > 1); + if(___flag) + ___pc->pread = atoi(argv[1]); + // Command line parameter from get_process_comm_data in SupervisorTemplate + + ___RETURN_IF_ERROR_1(___flag, "The process exits since no command line parameter is given.\n"); + + // READ PARAMETERS FROM PIPE + + ___j = ___get_msg(___pc->pread, &___pc->pwrite, sizeof(___pc->pwrite), debugInfo); + ___RETURN_IF_ERROR_1(___j, "The process exits since 'pwrite' cannot be read from pipe.\n"); + ___j = ___get_msg(___pc->pread, &___pthr->id, sizeof(___pthr->id), debugInfo); + ___RETURN_IF_ERROR_1(___j, "The process exits since process id cannot be read from pipe.\n"); + ___j = ___get_msg(___pc->pread, &___pthr->debug, sizeof(___pthr->debug), debugInfo); + ___RETURN_IF_ERROR_2(___j, "The process exits since 'debug' cannot be read from pipe.\n"); + ___j = ___get_msg(___pc->pread, &___pthr->state, sizeof(___pthr->state), debugInfo); + ___RETURN_IF_ERROR_2(___j, "The process exits since the initial state cannot be read from pipe.\n"); + + ___pthr->comm = ___pc; + ___debug = ___pthr->debug; + + + ___print_args(argc, argv, ___pthr, ___pc); + + ___main_function(___pthr); + + debugInfo("The process is terminating.\n"); + + free(___pthr); + free(___pc); + + return 0; +} + +#endif Added: newcodegen/SupervisorTemplate.c =================================================================== --- newcodegen/SupervisorTemplate.c (rev 0) +++ newcodegen/SupervisorTemplate.c 2011-04-02 00:08:32 UTC (rev 244) @@ -0,0 +1,1096 @@ +// TO DO: check pipe size and adjust it if necessary or terminate if impossible +// enable SIGPIPE for sread pipe of supervisor. +// use fcntl for both +// The plant must use fcntl so that its write is not blocked! +// Plant: Blocking read, nonblocking write! +// +// Note: read() from pipe with O_NOBLOCK set returns 0 if the sender has closed +// its end of the pipe or -1 and errno = EAGAIN if the pipe is empty. +// +// check_for_msg()/get_msg() accounts for the possibility that read() may return less bytes +// than expected. However, some testing might be needed to ensure that the way +// check_for_msg()/get_msg() deals with this error is adequate. +// If this is not the case, some functions could be created to read and write +// bytes one by one. Then, struct proc would have two additional items: one buffer +// to hold the bytes of a message that is being received, which is filled with bytes +// of data as they arrive, and one integer indicating how many bytes are in the +// buffer. +// +// The plant should send a notification message to the supervisor when terminating. +// +// The debugInfo of the supervisor should use a lock. + +#define ___SUPERVISOR + +#include<stdarg.h> +#include<stdio.h> +#include<stdlib.h> +#include<time.h> +#include<string.h> +#include<pthread.h> +#include<unistd.h> +#include<fcntl.h> +#include<signal.h> + +#define MSG_READ_LIMIT 10 +// max number of messages read from a single process during an iteration + +char ___debug; // value determined by parameters of main function +int ___finish; // the program terminates when its value is nonzero +pid_t ___pid; +pthread_t ___tid; +FILE* ___f; +char* ___name; + +#include"spcommon.h" + +// The following is used for unnamed pipe communication between plant +// and supervisor. + +struct ___comm { + int sread, swrite; + int pread, pwrite; + char pclosed; // nonzero if pread and pwrite pipes have been closed +}; + +// The following is used in the command line when a process is started. +// The size should be updated if the communication approach is changed. +// A size of (4*sizeof(int)+1) is sufficient to represent one signed +// int-type number in text form. + +char ___com[4*sizeof(int)+1]; + +// The following is used to store transition lists in "struct proc" + +struct trlist { + int t; // transition number + int a; // action label of plant transition + //char type; // 0: if input transition, 1: if output transition +}; + +// When a plant process is created, an object of type "struct proc" +// is created. The address of this object is transmitted to the process and +// this address is included in all messages from the process to the supervisor. +// These objects are placed in three lists, as follows: +// - prlist is the list of all processes started by the supervisor. +// - wtlist[i] is a list of processes of the type i that wait for the supervisor. +// - queue is a queue list of all processes that wait for the supervisor. + +struct proc { + int type; // identifies the type of the process + int request; // id of last request (not notification!) made by the proc to the supervisor + int solved; // id of last resolved request (so solved == request when all + // requests of the process have been answered). + char atype; // the action type (permission request or firing notification) + // bit 0: 0 -- permission, 1 -- notification + // bit 1: 1 -- if part of qelist (QueueEntryList of IsPermissible) + int fireable; // the plant transition selected by the supervisor algorithms + int ntlist; // number of elements of the list below + struct trlist *tlist; // list of firable plant transitions + // All entries below must be ZERO when not used + struct proc *next_in_queue; // next element of lower priority + struct proc *prev_in_queue; // next element of higher priority + struct proc *next_in_prlist; // next element in the list of processes + struct proc *prev_in_prlist; // previous element + struct proc *next_in_wtlist; // next element in the list of processes of the + // same type that wait for a supervisor action + struct proc *prev_in_wtlist; + struct proc *next_in_qelist; + + pthread_t thread_id; // id of thread + pid_t pid; // id of forked process + + void* comm; // pointer to an unspecified communication structure, such as + // struct ___comm. +}; + +struct proc *___prlist; // pointer to the first element of the list +// wtlist is defined automatically as "struct proc *___wtlist[n];" +// wtlistLast[n] (pointer to last element of wtlist[n]) is defined the same way. + +struct proc *___first, *___last; // Queue pointers + +// When a process sends a message requesting action i, the supervisor +// examines the data associated with the action i. This data consists of +// process types that are involved in firing the transition and of supervisor +// transitions that are involved. This data is stored in 'struct ___action' +// objects (the structure is defined below). Note that a transition is fired +// if all process type requirements are met and one of the supervisor +// transitions in the list is enabled. + +// Conditions are expressed by process type lists and transition lists. +// There are npr process types: type[i] denotes the type of process i and +// weight[i] denotes the weight of the transition of process i that is part +// of the synchronization. +// There are ntr supevisor transitions having the same label as the plant +// transitions participating in the synchronization. Their indices are +// in the array t. + +// The structure allows expressing constraints in which a synchronization may +// involve either t (non-source) or t' (source tran), where t and t' belong to +// the same process. This situation may arise when t and t' have the same label. +// This is done by means of the 'disj' field. If disj[i] != 0, then one of +// the transitions itr[i] should be chosen OR one of the transitions corresp to +// oplace[disj[i]-1]. + +struct ___action { + const int ni; + const int *itype; // input proc. type, array of size ni + const int *nit; // array of size ni + const int *disj; // array of size ni; see the disj field of struct sync_element + const int **itr; // array of size ni x nit[i] for transitions + const int **iweight; // array of size ni x nit[i] + + const int no; + const int *otype; // output proc. type, array of size no + const int *not; // array of size no + const int **oweight; // array of size no x not[i] + const int **oplace; // array of size no x not[i] + // (place in which proc is started) + const int ntr; + const int *t; // array of size ntr +}; + + +// The PN structure of the supervisor is represented using the following +// structure. Each transition 0, 1, ..., n has an object of this type. + +struct ___PN { + const int nipl; // number of input places + const int *iplace; // vector of nipl elements + const int *iweight; // vector of nipl elements + + const int nopl; // number of output places + const int *oplace; // vector of nopl elements + const int *oweight; // vector of nopl elements +}; + + +// +++++++ OTHER DECLARATIONS (GENERATED CODE HERE) + +// default values included below for debugging puroposes +#ifndef n___prtypes +#define n___prtypes 1 +#endif + +struct proc *___prtype[n___prtypes]; + +int ___marking[___pnum]; // supervisor marking + + + +inline int ___is_enabled(int ___t) { // checks whether ___t is enabled + int ___i, ___nipl; + const int *___iplace, *___iweight; + const struct ___PN *___p; + + ___p = ___trans + ___t; + ___nipl = ___p->nipl; + ___iplace = ___p->iplace; + ___iweight = ___p->iweight; + + for(___i = 0; ___i < ___nipl; ___i++) + if(___marking[___iplace[___i]] < ___iweight[___i]) + break; + return (___i == ___nipl); +} + + +inline void ___fire(int ___t) { + // Fires __t without checking if it is enabled + + int ___i; + struct ___PN ___d = ___trans[___t]; + + for(___i = 0; ___i < ___d.nipl; ___i++) + ___marking[___d.iplace[___i]] -= ___d.iweight[___i]; + for(___i = 0; ___i < ___d.nopl; ___i++) + ___marking[___d.oplace[___i]] += ___d.oweight[___i]; +} + + +inline void ___fire_zltrans() { + // check 0 label transitions and fire them if enabled + + #ifdef ZERO_LABEL_TRANS + + for(___flag = 1; ___flag; ) { + ___flag = 0; + for(___i = 0; ___i < ZERO_LABEL_TRANS; ___i++) { + ___tr = ___zltrans[___i]; + if(___is_enabled(___tr)) { + ___fire(___tr); + ___flag = 1; + } + } + } + #endif +} + + +inline void ___fire_all(int ___t) { + // Fires __t without checking if it is enabled; fires also all zero label + // transitions that are enabled until none remains enabled. + + int ___i, ___flag, ___tr; + + ___fire(___t); + ___fire_zltrans(); +} + + +void ___UpdateSupervisorMarking(int ___a) { // ___a is the action number + + #ifdef ___ACTIONS + + const int *___ip = ___act[___a].t, ___n = ___act[___a].ntr; + int ___i; + + for(___i = 0; ___i < ___n; ___i++) + if(___is_enabled(___ip[___i])) { + ___fire_all(___ip[___i]); + break; + } + #endif +} + + +/* + +int find_weight(int ___prtype, int ___a, int ___t) { + // Returns zero if ___t has no input place. Otherwise, it + // returns the weight of the input arc of ___t. + + int ___i, ___j, ___w = 0; + struct ___action ___at = ___act[___a]; + + if(___at.ni) { + for(___i = 0; ___i < ___at.ni; ___i++) + if(___at.itype[___i] == ___prtype) + break; + if(___i < ___at.ni) { // that is, if ___prtype was found + for(___j = 0; ___j < ___at.nit[___i]; ___j++) + if(___t == ___at.itr[___i][___j]) { + ___w = ___at.iweight[___i][___j]; + break; + } + } + } + return ___w; +} + +*/ + + +void inline clear_qel_entries(struct proc* ___qel_last) { + // Clears from QueueEntryList all elements that follow ___qel_last + struct proc* ___pr, *___pr2; + for(___pr = ___qel_last->next_in_qelist; ___pr; ___pr = ___pr2) { + ___pr->atype -= (___pr->atype & 2); // clear bit 1 + ___pr2 = ___pr->next_in_qelist; + ___pr->next_in_qelist = 0; + } + ___qel_last->next_in_qelist = 0; +} + +struct proc* SearchQueue(int ___prtype, int ___t, int ___w, int ___cnt,\ + struct proc* ___qel_last) { + // The search is done for transitions 't' with *t!=0 corresponding to + // an action 'a' and to processes of type 'prtype'. 'w' is the weight + // of 't'. 'qel_last' denotes the last element of QueueEntryList. The + // function returns zero if nothing is found. Otherwise, it adds the + // appropriate processes to the QueueEntryList and returns the new + // last element of QueueEntryList. + + struct proc *___pr, *___qlast; + struct trlist* ___ptl; + int ___i, ___c = ___cnt; + + ___qlast = ___qel_last; + for(___pr = ___wtlist[___prtype]; ___pr; ___pr = ___pr->next_in_wtlist) { + if(___pr->atype & 2) // if entry in QueueEntryList + continue; + // Check if t is in the transition list + for(___ptl = ___pr->tlist, ___i = 0; ___i < ___pr->ntlist; ___i++) + if(___t == ___ptl[___i].t) + break; + if(___ptl) { // That is, if the transition was found + ___pr->fireable = ___t; + ___pr->atype |= 2; // set the bit 1 + ___qlast->next_in_qelist = ___pr; + ___qlast = ___pr; + ___c++; + if(___c >= ___w) + return ___qlast; + } + } + clear_qel_entries(___qel_last); // clear qel entries added by SearchQueue + return 0; +} + + +#ifdef ___MASK +inline void ___reset_mask(int ___n) { + int ___i; + for(___i = 0; ___i < ___n; ___i++) + ___mask[___i] = 0; +} +#endif + + +#ifdef ___ACTIONS // The following function called in the context of actions + +int IsPermissible(struct proc* ___q) { + // Checks whether the entry ___q of the queue has some transition that + // may be fired. It returns a nonzero number (action number + 1) if this + // is the case. + + int ___i, ___j, ___k, ___a, ___t, ___w; + int ___count, ___permissible, ___ptype, ___type; + char ___first; + struct ___action *___pa; + struct proc *___qel_last, *___q2; + + ___q->atype |= 2; // the instruction places {q} in QueueEntryList + ___ptype = ___q->type; + for(___i = 0; ___i < ___q->ntlist; ___i++) { + ___a = ___q->tlist[___i].a; + ___pa = ___act + ___a; // pa: pointer to the action element + + // Check whether any of the supervisor transitions associated with the + // action ___a is enabled. To execute ___a, at least one should be enabled. + + if(___pa->ntr) { // if there are sup. trans. associated with ___a + for(___j = 0; ___j < ___pa->ntr; ___j++) + if(___is_enabled(___pa->t[___j])) + break; // found one enabled supervisor transition + if(___j >= ___pa->ntr) + continue; // line reached if there are supervisor transitions + // associated with the action and none is enabled. + } + + // Note: For any correct supervisor, if the supervisor enables t + // it enables also all transitions with the same label as t. Thus, + // it is not necessary to check whether any other transition synchronized + // with t is supervisor enabled, since they have the same label. + + ___t = ___q->tlist[___i].t; + ___q->fireable = ___t; + ___qel_last = ___q; + ___permissible = 1; + #ifdef ___MASK + ___reset_mask(___pa->no); + #endif + for(___j = 0, ___first = 1; ___j < ___pa->ni; ___j++) { + // Note: pa->ni cannot be zero, because ___t cannot be a source + // transition (a plant will not request permission to fire one of its + // source transitions). Thus, ___t must be part of the input transition + // list of *___pa, so ni >= 1. + + ___type = ___pa->itype[___j]; + + // (a) Check first whether entry j of pa corresponds to t + // If yes, it is necessary to check the weight of t and whether enough + // many processes enable t. + + if(___first && ___ptype == ___type) { + for(___k = 0; ___k < ___pa->nit[___j]; ___k++) + if(___t == ___pa->itr[___j][___k]) + break; + if(___k < ___pa->nit[___j]) { // if the transition t was found + ___first = 0; + // If a non-source transition is chosen and source transitions are an + // alternative, an alternative source transition should not be fired + #ifdef ___MASK + ___w = ___pa->disj[___j]; + if(___w) // if source tran alternatives are present + ___mask[___w-1] = 1; // then mask (inhibit) them + #endif + ___w = ___pa->iweight[___j][___k]; + if(___w == 1) + continue; // continues with the next ___j + ___q2 = SearchQueue(___type, ___t, ___w, 1, ___qel_last); + if(___q2) { + ___qel_last = ___q2; + continue; // continues with the next ___j + } + ___permissible = 0; // line reached if t is unfirable + clear_qel_entries(___q); // clear QueueEntryList + break; // Go to next i, since t is unfirable + } // endif ___k < ... + } // endif ___first && ... + + // (b) Check whether some transition of entry j of pa is firable + + for(___k = 0; ___k < ___pa->nit[___j]; ___k++) { + ___w = ___pa->iweight[___j][___k]; + ___q2 = SearchQueue(___type, ___pa->itr[___j][___k], ___w, 0, ___qel_last); + if(___q2) { // if a firable entry was found + ___qel_last = ___q2; + // If a non-source transition is chosen and source transitions are an + // alternative, an alternative source transition should not be fired + #ifdef ___MASK + ___w = ___pa->disj[___j]; + if(___w) // if source tran alternatives are present + ___mask[___w-1] = 1; // then mask (inhibit) them + #endif + break; // Go to the next ___j + } + } // end for(___k ... + if(___k >= ___pa->nit[___j]) { // if no firable transition was found + if(___pa->disj[___j]) // if there are alternative source transitions + continue; // continue with the next ___j + clear_qel_entries(___q); //clear QueueEntryList; line reached if no sol found + ___permissible = 0; + break; // Go to next i, since t is unfirable + } + + } // end for(___j ... + if(___permissible) + return ___a + 1; // the transition may be fired! + } // end for(___i ... + ___q->atype -= ___q->atype & 2; // reset bit 1 of atype + return 0; // no transition of ___q may be fired! +} // ends IsPermissible + +#endif // ends ifdef ACTIONS + + +struct ___comm* ___new_comm_struct() { + int ___ip[2]; + struct ___comm* ___p; + + ___p = malloc(sizeof(*___p)); + if(! ___p) { + debugInfo("Could not allocate memory for 'struct ___comm' object"); + return 0; + } + + if (pipe(___ip) == -1) { + debugInfo("Could not open unnamed pipes"); + free(___p); + return 0; + } + + ___p->sread = ___ip[0]; + ___p->pwrite = ___ip[1]; + + if (pipe(___ip) == -1) { + debugInfo("Could not open unnamed pipes"); + close(___p->sread); + close(___p->pwrite); + free(___p); + return 0; + } + + ___p->swrite = ___ip[1]; + ___p->pread = ___ip[0]; + + fcntl( ___p->sread, F_SETFL, O_NONBLOCK); + fcntl( ___p->swrite, F_SETFL, O_NONBLOCK); + fcntl( ___p->pwrite, F_SETFL, O_NONBLOCK); + + return ___p; +} + + +struct proc* ___NewProcess(int ___type) { + // Creates new process structure. Places it at the beginning in prlist. + + struct proc *___p; + + ___p = calloc(1, sizeof(*___p)); // initializes everything to zero + if(!___p) { + debugInfo("Could not allocate memory for 'struct proc' object"); + return 0; + } + + ___p->comm = ___new_comm_struct(); + if(!___p->comm) { + free(___p); + return 0; + } + + ___p->tlist = calloc(___maxOutpTranNum[___type], sizeof(*(___p->tlist))); + if( ! ___p->tlist) { + debugInfo("Could not allocate memory for 'tlist' field of 'struct proc'"); + free(___p->comm); + free(___p); + return 0; + } + + ___p->ntlist = ___maxOutpTranNum[___type]; + ___p->type = ___type; + + // insert element in ___prlist + + if( ! ___prlist) + ___prlist = ___p; + else { + ___prlist->prev_in_prlist = ___p; + ___p->next_in_prlist = ___prlist; + ___prlist = ___p; + } + + return ___p; +} + + +void ___free_comm(struct ___comm *___pc) { + if(___pc) { + close(___pc->sread); close(___pc->swrite); + if( ! ___pc->pclosed ) { + close(___pc->pread); close(___pc->pwrite); + } + free(___pc); + } +} + + +void inline ___remove_from_prlist(struct proc *___p) { + if(___prlist == ___p) // is ___p first element of ___prlist? + ___prlist = ___p->next_in_prlist; + if(___p->prev_in_prlist) + ___p->prev_in_prlist->next_in_prlist = ___p->next_in_prlist; + if(___p->next_in_prlist) + ___p->next_in_prlist->prev_in_prlist = ___p->prev_in_prlist; + ___p->next_in_prlist = 0; // these two lines unnecessary if ___p is freed next + ___p->prev_in_prlist = 0; +} + +void inline ___remove_from_queue(struct proc *___p) { + if(___first == ___p) + ___first = ___p->next_in_queue; + if(___last == ___p) + ___last = ___p->prev_in_queue; + if(___p->prev_in_queue) + ___p->prev_in_queue->next_in_queue = ___p->next_in_queue; + if(___p->next_in_queue) + ___p->next_in_queue->prev_in_queue = ___p->prev_in_queue; + ___p->prev_in_queue = 0; + ___p->next_in_queue = 0; +} + +void inline ___remove_from_wtlist(struct proc *___p) { + struct proc **___ap = ___wtlist + ___p->type, **___apL = ___wtlistLast + ___p->type; + + if(*___ap == ___p) + *___ap = ___p->next_in_wtlist; + if(*___apL == ___p) + *___apL = ___p->prev_in_wtlist; + if(___p->prev_in_wtlist) + ___p->prev_in_wtlist->next_in_wtlist = ___p->next_in_wtlist; + if(___p->next_in_wtlist) + ___p->next_in_wtlist->prev_in_wtlist = ___p->prev_in_wtlist; + ___p->prev_in_wtlist = 0; + ___p->next_in_wtlist = 0; +} + + + +void ___free_proc(struct proc* ___p) { + if(___p) { + + if(___p->tlist) free(___p->tlist); + + ___free_comm(___p->comm); // Close communication channels and free memory + + // Remove ___p from process lists + + ___remove_from_prlist(___p); + ___remove_from_queue(___p); + ___remove_from_wtlist(___p); + + free(___p); + } +} + + +struct ___thread_data* get_thread_data(struct proc* ___p, int ___where) { + struct ___thread_data *___pthr; + struct ___thread_comm *___pc; + + ___pthr = calloc(1, sizeof(*___pthr)); + if(!___pthr) { + debugInfo("Could not allocate 'struct ___thread_data' object"); + return 0; + } + ___pc = calloc(1, sizeof(*___pc)); + if(!___pc) { + free(___pthr); + debugInfo("Could not allocate 'struct ___thread_comm' object"); + return 0; + } + + ___pc->pread = ((struct ___comm*) ___p->comm)->pread; + ___pc->pwrite = ((struct ___comm*) ___p->comm)->pwrite; + ___pthr->comm = ___pc; + ___pthr->debug = ___debug; + ___pthr->state = ___where; + ___pthr->id = (void*) ___p; + + return ___pthr; +} + + +void get_process_comm_data(struct proc* ___p) { + sprintf(___com, "%d", ((struct ___comm*)___p->comm)->pread); +} + + +int ___upd_comm_param(int ___sup, struct proc* ___p, int ___where) { + // This function is used for processes created via "fork" instructions. + // Since "fork" creates duplicate file descriptors in the child process, + // unnecessary descriptors are closed in this function. + + struct proc *___pa; + void *___v = ___p; + + if(!___sup) { // if this is the child process, close 'sread' and 'swrite' + close(((struct ___comm*)___p->comm)->sread); + close(((struct ___comm*)___p->comm)->swrite); + for(___pa = ___prlist; ___pa; ___pa = ___pa->next_in_prlist) { + if(___pa == ___p) + continue; + close(((struct ___comm*)___pa->comm)->sread); + close(((struct ___comm*)___pa->comm)->swrite); + } + return 1; + } + else { // if this is the supervisor process + close(((struct ___comm*)___p->comm)->pread); + close(((struct ___comm*)___p->comm)->pwrite); + ((struct ___comm*)___p->comm)->pclosed = 1; + + // send parameters to child process + + if(write(((struct ___comm*)___p->comm)->swrite, \ + &((struct ___comm*)___p->comm)->pwrite, \ + sizeof(((struct ___comm*)___p->comm)->pwrite)) == -1) + return 0; + if(write(((struct ___comm*)___p->comm)->swrite, & ___v, \ + sizeof(void*)) == -1) + return 0; + if(write(((struct ___comm*)___p->comm)->swrite, & ___debug, \ + sizeof(___debug)) == -1) + return 0; + if(write(((struct ___comm*)___p->comm)->swrite, & ___where, \ + sizeof(___where)) == -1) + return 0; + } + return 1; +} + + +inline int ___send_to_supervisor(const void* ___pdata, int ___n, \ + struct proc* ___p) { + // Sends ___n bytes of data located at address ___pdata. Here, ___p is the + // address of the 'struct proc' object of the sender process. + // This function is called only from error conditions. It returns 0 if the + // message could not be sent. + + return ___send_msg(___pdata, ___n, ((struct ___comm*)___p->comm)->pwrite, debugInfo); +} + + +void ___terminate_process(struct proc* ___p) { + if(___p->pid) // then this is a forked process + kill(___p->pid, SIGINT); + else // then this is a thread + pthread_kill(___p->thread_id, SIGINT); + ___free_proc(___p); +} + + +struct proc* ___StartProcess(int ___type, int ___where) { + struct proc *___pr; + int ___i; + struct ___thread_data *___pthr; + pid_t ___cpid; + struct ___msg ___ms; + + ___pr = ___NewProcess(___type); + if( ! ___pr) { + debugInfo("Unable to create new process!\n"); + return 0; + } + + #ifdef ___THREADS + + if(___start_fn[___type]) { + ___pthr = get_thread_data(___pr, ___where); + if(!___pthr) { + debugInfo("Cannot start thread with empty ___thread_data object"); + return 0; + } + ___i = pthread_create(&___pr->thread_id, 0, ___start_fn[___type],\ + (void*) ___pthr); + if(___i) { + debugInfo("pthread_create has returned the error code %d", ___i); + free(___pthr); + ___free_proc(___pr); + return 0; + } + return ___pr; + } + + #endif + + #ifdef ___PROCESSES + + if(___pname[___type]) { + get_process_comm_data(___pr); // updates the ___com variable + ___cpid = fork(); + if(___cpid == -1) { + debugInfo("fork() was not able to create a new process"); + ___free_proc(___pr); + return 0; + } + if( ! ___cpid) { // code execuded by child process + ___upd_comm_param(0, ___pr, ___where); + execlp(___pname[___type], ___pname[___type], ___com, 0); + debugInfo("exclp was unable to start \"%s %s\"", ___pname[___type], ___com); + ___ms.type = ___EXIT_NOTIFICATION; + ___ms.id = ___pr; + ___send_to_supervisor(&___ms, sizeof(___ms), ___pr); + exit(EXIT_FAILURE); // this line should not be reached + } + else { // code executed by supervisor + // upd_comm_param below updates the communication settings of the + // supervisor and sends input parameters to the child process + ___pr->pid = ___cpid; + if( ! ___upd_comm_param(1, ___pr, ___where)) { + debugInfo("Unable to initiate communication with child process"); + ___terminate_process(___pr); // also calls ___free_proc(___pr) + return 0; + } + return ___pr; + } + } + + #endif + + debugInfo("___StartProcess indicates a problem with the supervisor template or\ + the supervisor compiler"); // this line should not be reached + + return 0; +} + + + +void ___finish_sig_handler(int ___sig) { + struct proc* ___p; + + if(getpid() != ___pid) + exit(EXIT_FAILURE); + else if(pthread_self() != ___tid) + pthread_exit(0); + else { + debugInfo("A signal has been received and the program will be terminated"); + for(___p = ___prlist; ___p; ___p = ___p->next_in_prlist) + ___terminate_process(___p); // also calls___free_proc(___p); + exit(EXIT_SUCCESS); + } +} + + +inline int ___check_for_msg(struct proc *___p, struct ___msg *p___ms) { + // The function returns 0 if there are no messages + + return ___get_msg(((struct ___comm*)___p->comm)->sread, p___ms, \ + sizeof(*p___ms), debugInfo); +} + + +void inline ___PerformAction(int ___a, char* ___msk) { + +#ifdef ___ACTIONS + + int ___i, ___j, ___n, ___w; + struct ___action* ___ac = ___act + ___a; + + // Start new processes (if applicable) + + ___n = ___ac->no; + for(___i = 0; ___i < ___n; ___i++) { + if(___msk) + if(___msk[___i]) // ignore masked entries + continue; + ___j = 0; + if(___ac->not[___i] > 1) + ___j = rand() % ___ac->not[___i]; // select one of the source transitions + ___w = ___ac->oweight[___i][___j]; + for( ; ___w; ___w--) + ___StartProcess(___ac->otype[___i], ___ac->oplace[___i][___j]); + } + +#endif + +} + + +void ___execute_action(int ___a) { + int ___i = 1; + +#ifdef ___ACTIONS + + ___i = (___a < 0) || (___a >= ___ACTIONS); + +#endif + + if(___i) { + debugInfo("Action %d is undefined", ___a); + return; + } + + ___UpdateSupervisorMarking(___a); + ___PerformAction(___a, 0); // start new processes, if applicable +} + + +int ___process_msg(struct ___msg *p___ms) { + // Returns zero if the process of p___ms has terminated + struct proc **___ap, **___apL, *___p, *___pa = p___ms->id; + int ___i; + + switch(p___ms->type) { + + case ___EXIT_NOTIFICATION: // then deallocate process + + for(___p = ___prlist; ___p; ___p = ___p->next_in_prlist) { + if(___pa == ___p) { + ___free_proc(___p); + break; + } + } + return 0; + + case ___FIRING_REQUEST: + + + // Is this message about the last answered request? + if(___pa->solved == p___ms->req_id) // req_id may not be zero + return 1; // nothing to do, the request is already answered + + // Is this firing request already in the queue? + + if(___pa->request == p___ms->req_id) { + ___i = ___pa->ntlist; + if(___i >= ___maxOutpTranNum[___pa->type]) + debugInfo("Transition list of (%d:%d) exceeds maximum size", (int) ___pa->pid, (int) ___pa->thread_id); + else { + ___pa->tlist[___i].t = p___ms->t; + ___pa->tlist[___i].a = p___ms->a; + ___pa->ntlist++; + } + debugInfo("Proc. type %d (%d:%d): t%d (a%d) alternative tran. to fir. req. %d", (int)___pa->type, (int) ___pa->pid, (int) ___pa->thread_id, (int)p___ms->t, (int)p___ms->a, (int)___pa->request); + return 1; + } + + // If not in queue, add to queue and wtlist + + ___pa->request = p___ms->req_id; + + ___pa->tlist[0].t = p___ms->t; + ___pa->tlist[0].a = p___ms->a; + ___pa->ntlist = 1; + + if(!___last) { // update queue + ___last = ___pa; + ___first = ___pa; + } + else { + ___last->next_in_queue = ___pa; + ___pa->prev_in_queue = ___last; + ___last = ___pa; + } + + ___ap = ___wtlist + ___pa->type; // update wtlist + ___apL = ___wtlistLast + ___pa->type; + if(!*___apL) { + *___apL = ___pa; + *___ap = ___pa; + } + else { + (*___apL)->next_in_wtlist = ___pa; + ___pa->prev_in_wtlist = *___apL; + *___apL = ___pa; + } + + debugInfo("Firing req. [id:%d] (%d:%d): proc. type %d requests t%d (a%d)", (int)___pa->request, (int) ___pa->pid, (int) ___pa->thread_id, (int) ___pa->type, (int)p___ms->t, (int)p___ms->a); + + return 1; + + case ___FIRING_NOTIFICATION: + + ___execute_action(p___ms->a); + return 1; + + default: + debugInfo("Type %d of (%d:%d) is an undefined message type", (int)p___ms->type, (int) ___pa->pid, (int) ___pa->thread_id); + } + + return 1; +} + + + +inline void ___send_permission_msg(struct proc *___p) { + + ___send_msg(&___p->fireable, sizeof(int), ((struct ___comm*)___p->comm)->swrite, debugInfo); + +} + + +int main(int argc, char* argv[]) { + int ___i, ___j, ___a; + char* ___str, ___no_msg, ___start_flag; + struct proc *___p, *___pa, *___pn; + struct sigaction ___act; + struct ___msg ___ms; + time_t ___ctime; + char ___help_msg[] = "\nOptions: \n\ + -e: suppress error and status messages\n\ + -s: start the program right away without displaying introductory message\n\n\ + Ctrl-C (SIGINT) can be used to stop the program. This will terminate all\n\ + its processes.\n"; + + ___pid = getpid(); + ___tid = pthread_self(); + + ___debug = 0; + ___finish = 0; + ___f = stderr; + ___name = 0; + ___prlist = 0; + ___first = 0; ___last = 0; + + // install signal handlers + + sigaction(SIGINT, 0, &___act); // initialize act + ___act.sa_flags = 0; + //sigemptyset(&act.sa_mask); // no signals blocked + ___act.sa_handler = ___finish_sig_handler; + sigaction(SIGINT, &___act, 0); // initialize act + + time(&___ctime); + srand(___ctime%64000); + + ___debug = 1; + ___start_flag = (argc <= 1); + for(___i = 1; ___i < argc; ___i++) { + if(!strcmp(argv[___i], "-e")) + ___debug = 0; + else if(!strcmp(argv[___i], "-h") || !strcmp(argv[___i], "--help")) { + fprintf(stdout, ___help_msg); + return 0; + } + else if(!strcmp(argv[___i], "-s")) { + ___start_flag = 0; // "-s" is for future use; unnecessary right now + } + } + + if(___start_flag) { + fprintf(stdout, "%s\nThe program will start in five seconds.\n", ___help_msg); + sleep(5); + } + + if(___debug) { + if(argc <= 1) + debugInfo("The main function was entered. The main functions has no parameters."); + else { + for(___i = 0, ___j = 0; ___i < argc; ___i++) + ___j += strlen(argv[___i]); + ___j += argc + 1; + ___str = malloc(___j*sizeof(char)); + for(___i = 0, ___j = 0; ___i < argc - 1; ___i++) { + sprintf(___str + ___j, "%s ", argv[___i]); + ___j += strlen(argv[___i]) + 1; + } + sprintf(___str + ___j, "%s", argv[___i]); + debugInfo("The process was started with the following command line\n\t%s", ___str); + free(___str); + } + } + + // initialize supervisor ___marking + memset(___marking, 0, sizeof(*___marking)*___pnum); + for(___i = 0; ___i < n___m0; ___i++) + ___marking[___m0[___i][0]] = ___m0[___i][1]; + ___fire_zltrans(); // fire zero label transitions of supervisor if enabled + + // start processes + for(___i = 0; ___i < n___pm0; ___i++) + for(___j = 0; ___j < ___pm0[___i][2]; ___j++) // ___pm0[___i][2]: # of tokens + ___StartProcess(___pm0[___i][0], ___pm0[___i][1]); // arguments: type, place + + + while( ! ___finish) { + + if(!___prlist) + break; // all processes have terminated, so the supervisor terminates + + // Check all processes for new messages + + for(___p = ___prlist, ___no_msg = 1; ___p; ___p = ___pn) { + ___pn = ___p->next_in_prlist; // process_msg below may deallocate ___p + for(___i = 0; ___i < MSG_READ_LIMIT; ___i++) { + ___j = ___check_for_msg(___p, &___ms); + if( ! ___j ) + break; // exit loop, since there are no messages + ___no_msg = 0; + if( ! ___process_msg(&___ms) ) // processes the message + break; // exit loop since the process of ___p has terminated + } + } + + if(___no_msg) { + sleep(2); // any interrupt will awake the process + continue; + } + + // Check for queued requests that can be resolved + +#ifdef ___ACTIONS // There may be queued requests only if actions are defined, + // as can be seen in the definition of ___process_msg(). + + for(___p = ___first; ___p; ___p = ___pn) { // search queued requests + ___pn = ___p->next_in_queue; // the loop will not deallocate ___p but + // it may remove ___p from the queue + ___a = IsPermissible(___p); // creates EntryList (qelist) + if(___a > 0) { // then the request of ___p can be resolved + + // Grant permission to fire to the processes in EntryList + // Remove also from queue and wait list processes in EntryList + + for(___pa = ___p; ___pa; ___pa = ___pa->next_in_qelist) { + // This loop does not affect 'qelist' (EntryList). + // However, it does affect 'queue' and 'wtlist'. + if(___pn == ___pa) // if ___pn will be removed from queued requests + ___pn = ___pn->next_in_queue; // select next queued request + ___send_permission_msg(___pa); + ___remove_from_queue(___pa); // remove ___pa from queued requests + ___remove_from_wtlist(___pa); + } + + clear_qel_entries(___p); // delete EntryList except for first element + ___p->atype -= (___p->atype & 2); // remove first el of EntryList + ___a--; // since IsPermissible adds 1 to the return value + ___UpdateSupervisorMarking(___a); // update supervisor marking +#ifdef ___MASK + ___PerformAction(___a, ___mask); // start new processes, if applicable +#else + ___PerformAction(___a, 0); // start new processes, if applicable +#endif + + } + } +#endif // end of ifdef ___ACTIONS + + } // end of while( ! ___finish) (the main loop) + + debugInfo("The end of the main function was reached.\n"); + + return 1; +} + Added: newcodegen/codegen.h =================================================================== --- newcodegen/codegen.h (rev 0) +++ newcodegen/codegen.h 2011-04-02 00:08:32 UTC (rev 244) @@ -0,0 +1,51 @@ +/* codegen.h + + This header file was created for the 2010 version of the code generation tools. +*/ + +/* The code generation module expects processes satisfying the following + + - Nondeterministic places: If a place is nondeterministic and one of its + output transitions is controlled by the supervisor or participates in a + process synchronization, then permission to fire is always requested + from the supervisor. (NOT YET IMPLEMENTED.) + + - The supervisor format: It is assumed that each transition has a + unique label. Process transitions that are synchronized are assumed to + have the same label. The supervisor is connected to the plant using the + conventional parallel composition of PNs. + + - The select function: If defined, it should return the number of + transitions selected. Let n be that number. The select function writes the + list of enabled transitions by writing their data to the first n elements + of the array ___TR of ProcessTemplate.c. + + It is assumed that for a pn structure, the select[i] item contains a + string indicating how the select function should be called. Example: + select[0] = "myselect(1, x, y);", where x and y should be defined in + the context of the segment[i] code. Note that select[0] does not specify + any assignment of the return value. The code generation module is + responsible for writing the assignment of the return value. + +*/ + + + +#define INDENT 2 // indentation increment used in generated C code + +#define DBG3 is_verbose()>=3 + + +int FillTemplate(FILE* template, FILE* outp, ...); // in filltmpl.lex + +FILE* searchTemplate(char* s); // in plantCompiler.c + +char* GetFileName(const char* s, const char *ext); +// Similar to "asprintf(&x, "%s.%s", s, ext); return x;" + +void compileSupervisor(pns *supervisor, char* sname, process **procTypes, \ + int nbrTypes, TrData** TrInfo, struct synclist* sl, \ + const char* buildparam); + +void compileProcessArray(process **procArray, int nbrElements, TrData** TrInfo, \ + int** actlabels); Added: newcodegen/compexample.c =================================================================== --- newcodegen/compexample.c (rev 0) +++ newcodegen/compexample.c 2011-04-02 00:08:32 UTC (rev 244) @@ -0,0 +1,278 @@ +#include"pns.h" +#include"codegen.h" + + +int verb = 3; + +int inline is_verbose() { return verb; } + +int main() { + int i; + + /* Declaring pn objects */ + + pns pn_p, pn_s, pn_s2, pn, pn2, pn3; + process pr1, pr2, pr3, *apr[2]; + + + /* Petri nets can be initialized using the incidence matrix */ + + /* This will be used for the incidence matrix of one pn */ + + int Dp[] = { 1, 1, -1, 1, 0, 0,\ + 0, 0, 1, 0, -1, 0,\ + 0, -1, 1, 0, 0, -1,\ + -1, 0, 0, 0, 1, 0,\ + 0, 0, 0, -1, 0, 1}; + + int mp[] = { 1, 1, 1, 1, 1}; /* The initial marking */ + + /* These will be used for the input and output matrices of another pn */ + + int Is[] = { 0, 1, 0, 0,\ + 0, 0, 1, 0,\ + 0, 0, 0, 1,\ + 1, 0, 0, 0}; + + int Os[] = { 0, 0, 1, 0,\ + 0, 0, 0, 1,\ + 1, 0, 0, 0,\ + 0, 1, 0, 0}; + + int ms[] = {0, 0, 1, 1}; /* The initial marking */ + + struct placelist *plist; + arcs* alist; + char *str; + + /* Here is how the pn objects are created */ + + /* The following creates a pn of 5 places, 6 transitions, incidence + matrix Dp, and initial marking mp */ + pn_p = createpn("pnum tnum D m0", 5, 6, Dp, mp); + + /* Here the input and output matrices are used to initialize the pn */ + pn_s = createpn("pnum tnum I O m0", 4, 4, Is, Os, ms); + + /* This creates a pn object without transition arcs */ + pn = createpn("pnum tnum", 3, 5); + + int m0pn[] = {1, 0, 0}; + updatepn(&pn, "m0", m0pn); + + // Let's create the following PN: + // + // t2 + // -------|<---- + // | p0 p1 |p2 + // ->O->|->O->|->O<-- + // | t0 | t1 | + // | | | + // | V | + // | --- t3 | + // | | + // ------>|------- + // t4 + + /* GetMatrixEl and SetMatrixEl can be used to read or write the elements + of a matrix. */ + + /* For instance, arcs could be added by changing the value of the input + and output matrices of the pn */ + + SetMatrixEl(&pn.out, 0, 0, 1); /* add arc from p0 to t0 of weight 1 */ + SetMatrixEl(&pn.out, 0, 4, 1); /* add arc from p0 to t4 of weight 1 */ + SetMatrixEl(&pn.in, 0, 2, 1); + + SetMatrixEl(&pn.out, 1, 1, 1); + SetMatrixEl(&pn.out, 1, 3, 1); + SetMatrixEl(&pn.in, 1, 0, 1); + + SetMatrixEl(&pn.out, 2, 2, 1); + SetMatrixEl(&pn.in, 2, 1, 1); + SetMatrixEl(&pn.in, 2, 4, 1); + + int labls[] = {-1, -2, -3, -4, -5}; + updatepn(&pn, "labels", labls); + + // Let's create one more PN: + // + // p0 p1 + // |->O->|->O->| + // t2 t0 t1 + // + + pn3= createpn("pnum tnum", 2, 3); + int labl2[] = {-1, -7, -5}; + + SetMatrixEl(&pn3.out, 0, 0, 1); /* add arc from p0 to t0 of weight 1 */ + SetMatrixEl(&pn3.in, 0, 2, 1); + + SetMatrixEl(&pn3.out, 1, 1, 1); + SetMatrixEl(&pn3.in, 1, 0, 1); + + updatepn(&pn3, "labels", labl2); + + /* For instance, to check whether there is an arc from t1 to p2: */ + i = GetMatrixEl(&pn.in, 2, 1); + if(i) + fprintf(stderr, "\nThe arc (t1, p2) has the weight %d.\n", i); + else + fprintf(stderr, "\nThere is no arc from t1 to p2.\n"); + + /* To display in text format a Petri net object use displaypn */ + + fprintf(stderr, "\n** PN_P *************************************\n"); + displaypn(pn_p, stderr); /* displays pn_p */ + fprintf(stderr, "\n** PN_S *************************************\n"); + displaypn(pn_s, stderr); /* displays pn_s */ + fprintf(stderr, "\n** PN *************************************\n"); + displaypn(pn, stderr); /* displays pn */ + + /* Properties of the pn objects can be set or changed with updatepn */ + + updatepn(&pn, "place_name", 0, "start_p"); + /* The line above associates the name "start_p" with the place 0 */ + + updatepn(&pn, "trans_name", 0, "tr0"); + /* The line above associates the name "tr0" with the transition 0 */ + + updatepn(&pn, "select", 1, "f1(u)"); /*select function 'f1' for place 1*/ + + updatepn(&pn, "segment", 0, "u++; printf(\"\\nPN: State 0 u = %d\", u);\ndelay(1);"); + updatepn(&pn, "segment", 1, "printf(\"\\nPN: State 1\");\ndelay(1);"); + updatepn(&pn, "segment", 2, "printf(\"\\nPN: State 2\");\ndelay(1);"); + + updatepn(&pn3, "segment", 0, "u++; printf(\"\\nPN3: State 0 u = %d\", u);\ndelay(2);"); + updatepn(&pn3, "segment", 1, "printf(\"\\nPN3: State 1\");\ndelay(2);"); + + /* Text transmitted by means of createpn/updatepn is copied to the + corresponding items of the pns object; thus it should be + deallocated, when applicable. For instance: */ + + //str = tcalloc(strlen("f1(i, j);")+1, sizeof(char)); + //strcpy(str, "f1(i, j);"); + //updatepn(&pn, "segment", 1, str); + ///* Now, str may be freed, since its content has been copied */ + // free(str); + + /* Flags are set as follows. */ + + updatepn(&pn, "unobservable nondeterministic", 0, 1); + /* marks transition 0 unobservable and place 1 as nondeterministic */ + + updatepn(&pn, "live uncontrollable uncontrollable", 0, 0, 2); + /* The line above sets the "live" and "uncontrollable" flags of + transition 0 and the uncontrollable flag of transition 2 */ + + /* To create a copy */ + + pn2 = copypn(&pn); + + + + /* Arcs are added similarly (using createpn or updatepn). Here is + an example. */ + + plist = tmalloc(sizeof(struct placelist)); + plist->place = 1; + plist->next = tmalloc(sizeof(*plist)); + plist->next->place = 2; + plist->next->next = 0; + + alist = tmalloc(sizeof(arcs)); + alist->in_place = 0; + alist->out_places = plist; + alist->condition = tcalloc(strlen("j == i || z == 0.1")+1, sizeof(char)); + strcpy(alist->condition, "j == i || z == 0.1"); + alist->next = 0; + + updatepn(&pn, "arcs", 0, alist); /* arc list associated with transition 0 */ + + /* The line above updates the arc_list item of the pns object as well as the + input & output matrices. */ + + /* Note the absence of the lines of code deallocating alist. The object alist is + placed in the pns object, it is not copied. Thus, alist is deallocated when + the pns object is deallocated with the function deallocpn. */ + + + TrData **TInf; + + // Let's create also some processes + + asprintf(&(pr1.name), "type_one"); asprintf(&(pr2.name), "PN3"); + pr1.instance = "pr1"; pr2.instance = "pr2"; + pr1.thread = 0; pr2.thread = 1; + pr1.pn = &pn2; pr2.pn = &pn3; + asprintf(&(pr1.build), "gcc -g -o $$$.exe $$$.c"); + pr2.build = 0; + // pr2.build = "make -f pn3.mak"; + pr1.include = "#include<stdio.h>\nint pr1_state = 0, i, j, u = 0;\n\n\ +void delay(int n) {\n time_t a, b;\n\ + for(time(&a), time(&b); a + n > b; time(&b));\n}\n\nint f1(int z) {\n\ + if(u > 5) {\n\ + ___TR[0].no_output = 1;\n\ + ___TR[0].label = -4;\n\ + ___TR[0].trans = 3;\n\ + }\n\ + else {\n\ + ___TR[0].no_output = 0;\n\ + ___TR[0].label = -2;\n\ + ___TR[0].trans = 1;\n\ + ___TR[0].place = 2;\n\ + }\n\ + return 1;\n\ +}\n"; + pr2.include = "#include<stdio.h>\nint pr1_state = 0, i, j, u = 0;\n\n\ +void delay(int n) {\n time_t a, b;\n\ + for(time(&a), time(&b); a + n > b; time(&b));\n}\n\n"; + + pr1.type = 0; pr1.start = 1; pr2.type = 1; pr2.start = 0; + apr[0] = &pr1; + apr[1] = &pr2; + + TInf = calloc(sizeof(TrData*), 2); + TInf[0] = calloc(sizeof(TrData), pn2.tnum); + TInf[1] = calloc(sizeof(TrData), pn3.tnum); + + // int labls[] = {-1, -2, -3, -4, -5}; + // int labl2[] = {-1, -7, -5}; + + struct synclist *sn1; + struct sync_element *se; + + sn1 = calloc(2, sizeof(*sn1)); + se = calloc(10, sizeof(*se)); + + sn1[0].next = sn1+1; sn1->s = &se[0]; + se[0].prtype = 0; se[0].n = 1; + int t1[] = {0}, w1[] = {1}; + se[0].t = t1; se[0].w = w1; se[0].next = &se[1]; + se[1].prtype = 1; se[1].t = t1; se[1].w = w1; se[1].n = 1; + sn1[1].s = &se[2]; + int t2[] = {4}; + se[2].prtype = 0; se[2].t = t2; se[2].w = w1; se[2].n = 1; + sn1[1].o = &se[3]; se[3].n = 1; + int t3[] = {2}, p1[] = {0}; + se[3].prtype = 1; se[3].t = t3; se[3].w = w1; se[3].p = p1; + + //compileProcessArray(apr, 2, TInf); + //fprintf(stderr, "\nNow generating the supervisor ..."); + //compileSupervisor(&pn2, "spr", apr, 2, TInf, sn1, 0); + + CodeGenerator(&pn2, "spr", apr, 2, sn1, TInf, 0); + + for(i = 0; i < 2; i++) + free(TInf[i]); + free(TInf); + free(se); free(sn1); free(pr1.name); free(pr2.name); + /* To deallocate a pn object use deallocpn */ + + deallocpn(&pn_p); + deallocpn(&pn_s); + deallocpn(&pn); + deallocpn(&pn2); + + return 0; +} Added: newcodegen/filltmpl.lex =================================================================== --- newcodegen/filltmpl.lex (rev 0) +++ newcodegen/filltmpl.lex 2011-04-02 00:08:32 UTC (rev 244) @@ -0,0 +1,92 @@ + +LABEL ([ \t]*\/\/[ \t]*[+]{3,}[[:print:]]*) +IDENTIFIER ("(GENERATED CODE HERE)") + +%{ + #include<stdio.h> + #include<stdarg.h> + + int flag, skip, i, j; + va_list param; + FILE *out; + char *stmp, cc; + +%} + + +%% + +{LABEL}/{IDENTIFIER} { + flag = 0; skip = 1; + fprintf(out, "%s (BEGINNING OF CODE)\n", yytext); + for(i = 0; yytext[i] == ' ' || yytext[i] == '\t'; i++); + cc = yytext[i]; + yytext[i] = 0; // g... [truncated message content] |
From: <mio...@us...> - 2011-04-08 22:36:53
|
Revision: 246 http://pntool.svn.sourceforge.net/pntool/?rev=246&view=rev Author: miordache Date: 2011-04-08 22:36:44 +0000 (Fri, 08 Apr 2011) Log Message: ----------- update Modified Paths: -------------- 2009_version/codegen/Makefile Makefile newcodegen/Makefile pnheaders/insert.c Added Paths: ----------- 2009_version/ 2009_version/Makefile09 2009_version/codegen/ 2009_version/pnheaders/ 2009_version/spnbox09/ 2009_version/spnbox09/Makefile 2009_version/spnbox09/MemoryManager.c 2009_version/spnbox09/MemoryManager.h 2009_version/spnbox09/actn.c 2009_version/spnbox09/admcon.c 2009_version/spnbox09/asiph.c 2009_version/spnbox09/avpr.c 2009_version/spnbox09/chkcons.c 2009_version/spnbox09/deallocation.c 2009_version/spnbox09/dp.c 2009_version/spnbox09/dp4.c 2009_version/spnbox09/extendedmatrix.c 2009_version/spnbox09/extendedmatrix.h 2009_version/spnbox09/fvpr.c 2009_version/spnbox09/gcdv.c 2009_version/spnbox09/ilpadm.c 2009_version/spnbox09/invar.c 2009_version/spnbox09/ipslv.c 2009_version/spnbox09/ipsolve.c 2009_version/spnbox09/isadm.c 2009_version/spnbox09/issiph.c 2009_version/spnbox09/linenf.c 2009_version/spnbox09/matrixmath.c 2009_version/spnbox09/matrixmath.h 2009_version/spnbox09/mroadm.c 2009_version/spnbox09/msplit.c 2009_version/spnbox09/nltrans.c 2009_version/spnbox09/pn2acpn.c 2009_version/spnbox09/pn2eacpn.c 2009_version/spnbox09/reduce.c 2009_version/spnbox09/spnbox.h 2009_version/spnbox09/supervis.c 2009_version/spnbox09/tactn.c 2009_version/spnbox09/tests/ 2009_version/spnbox09/tests/Makefile 2009_version/spnbox09/tests/StructuredIO.c 2009_version/spnbox09/tests/StructuredIO.h 2009_version/spnbox09/tests/pnexample.c 2009_version/spnbox09/tests/test-actn.c 2009_version/spnbox09/tests/test-actn.txt 2009_version/spnbox09/tests/test-admcon.c 2009_version/spnbox09/tests/test-asiph.c 2009_version/spnbox09/tests/test-asiph.txt 2009_version/spnbox09/tests/test-avpr.c 2009_version/spnbox09/tests/test-avpr.txt 2009_version/spnbox09/tests/test-dp.c 2009_version/spnbox09/tests/test-dp.txt 2009_version/spnbox09/tests/test-extendedmatrix.c 2009_version/spnbox09/tests/test-extendedmatrix.txt 2009_version/spnbox09/tests/test-fvpr.c 2009_version/spnbox09/tests/test-fvpr.txt 2009_version/spnbox09/tests/test-gcdv.c 2009_version/spnbox09/tests/test-gcdv.txt 2009_version/spnbox09/tests/test-ilpadm.c 2009_version/spnbox09/tests/test-ilpadm.txt 2009_version/spnbox09/tests/test-invar.c 2009_version/spnbox09/tests/test-invar.txt 2009_version/spnbox09/tests/test-ipslv.c 2009_version/spnbox09/tests/test-ipsolve.c 2009_version/spnbox09/tests/test-ipsolve.txt 2009_version/spnbox09/tests/test-isadm.c 2009_version/spnbox09/tests/test-isadm.txt 2009_version/spnbox09/tests/test-issiph.c 2009_version/spnbox09/tests/test-issiph.txt 2009_version/spnbox09/tests/test-linenf.c 2009_version/spnbox09/tests/test-linenf.txt 2009_version/spnbox09/tests/test-matrixmath.c 2009_version/spnbox09/tests/test-matrixmath.txt 2009_version/spnbox09/tests/test-mroadm.c 2009_version/spnbox09/tests/test-mroadm.txt 2009_version/spnbox09/tests/test-msplit.c 2009_version/spnbox09/tests/test-msplit.txt 2009_version/spnbox09/tests/test-nltrans.c 2009_version/spnbox09/tests/test-nltrans.txt 2009_version/spnbox09/tests/test-pn2acpn.c 2009_version/spnbox09/tests/test-pn2acpn.txt 2009_version/spnbox09/tests/test-pn2eacpn.c 2009_version/spnbox09/tests/test-pn2eacpn.txt 2009_version/spnbox09/tests/test-reduce.c 2009_version/spnbox09/tests/test-reduce.txt 2009_version/spnbox09/tests/test-supervis.c 2009_version/spnbox09/tests/test-supervis.txt 2009_version/spnbox09/tests/test-tactn.c 2009_version/spnbox09/tests/test-tactn.txt 2009_version/spnbox09/tests/test.c 2009_version/spnbox09/tests/test.h LICENSE/ LICENSE/ANTLR3_LICENSE.txt LICENSE/LICENSE.txt LICENSE/README.txt README.txt pnheaders/Makefile Removed Paths: ------------- ANTLR3_LICENSE.txt LICENSE.txt Makefile09 codegen/ pnheaders09/ Copied: 2009_version/Makefile09 (from rev 245, Makefile09) =================================================================== --- 2009_version/Makefile09 (rev 0) +++ 2009_version/Makefile09 2011-04-08 22:36:44 UTC (rev 246) @@ -0,0 +1,34 @@ +# This is the make file of the 2009 version of the program. + +COMPILER=gcc -g + +PNHEADERS=pnheaders +SPNBOX=spnbox09 +CODEGEN=codegen +CODEGENOBJS = codegen/src +TRANSLATOR=../translator + +ct09: objectfiles main_function.o + $(COMPILER) -o ct09 $(PNHEADERS)/*.o $(CODEGENOBJS)/*.o $(SPNBOX)/*.o \ + main_function.o $(SPNBOX)/*.a $(TRANSLATOR)/libtranslator.a + +objectfiles: + cd $(PNHEADERS); make + cd $(CODEGEN); make static + cd $(SPNBOX); make + cd $(TRANSLATOR); make + +main_function.o: $(PNHEADERS)/main_function.c $(PNHEADERS)/pns.h $(SPNBOX)/spnbox.h $(CODEGEN)/src/codegen.h + $(COMPILER) -c $(PNHEADERS)/main_function.c -Ispnbox09 -I$(CODEGEN)/src -I$(PNHEADERS) + +clean: + rm -f main_function.o + cd $(PNHEADERS); make clean + cd codegen; make clean + cd $(TRANSLATOR); make clean + cd $(SPNBOX); make clean + +distclean: clean + cd codegen; make distclean + cd $(TRANSLATOR); make distclean + Modified: 2009_version/codegen/Makefile =================================================================== --- codegen/Makefile 2011-04-02 00:10:24 UTC (rev 245) +++ 2009_version/codegen/Makefile 2011-04-08 22:36:44 UTC (rev 246) @@ -2,7 +2,8 @@ COMPILER=gcc -g -PNHEADERS = ../pnheaders/general.o ../pnheaders/matrix.o ../pnheaders/pns.o +PNHEADERS = ../pnheaders/general.c ../pnheaders/matrix.c ../pnheaders/pns.c +PNOBJS = ../pnheaders/general.o ../pnheaders/matrix.o ../pnheaders/pns.o STANDALONE = src/main.o OBJS = src/codegen.o src/plantCompiler.o src/supervisorCompiler.o src/petriNetSerializer.o src/text.o src/MakeGen.o B = \033[32m @@ -10,21 +11,21 @@ -standalone: pnslib static $(STANDALONE) +standalone: pnslib static $(STANDALONE) $(PNOBJS) echo "$(B)Making standalone files...$(E)" $(COMPILER) -c $(STANDALONE) echo "$(B)Linking it all up...$(E)" - $(COMPILER) -o codegen $(OBJS) $(PNHEADERS) $(STANDALONE) + $(COMPILER) -o codegen $(OBJS) $(PNOBJS) $(STANDALONE) echo "$(B)Done$(E)" -pnslib: $(PNHEADERS) +pnslib: $(PNHEADERS) echo "$(B) Precompiling pnheaders...$(E)" $(COMPILER) -c $(PNHEADERS) echo "$(B)Done$(E)" static: $(OBJS) pnslib echo "$(B) Making pure codegen...$(E)" - $(COMPILER) -c $(OBJS) $(PNHEADERS) -I../pnheaders + #$(COMPILER) -c $(OBJS) -I../pnheaders echo "$(B)Done$(E)" src/%.o : src/%.c $(COMPILER) -I../pnheaders -o src/$*.o -c src/$*.c @@ -41,6 +42,6 @@ echo "$(B)Done$(E)" distclean: clean echo "$(B)Making distclean...$(E)" - rm -f $(PNHEADERS) + rm -f $(PNOBJS) echo "$(B)Done$(E)" Added: 2009_version/spnbox09/Makefile =================================================================== --- 2009_version/spnbox09/Makefile (rev 0) +++ 2009_version/spnbox09/Makefile 2011-04-08 22:36:44 UTC (rev 246) @@ -0,0 +1,108 @@ +#This is the makefile for all spnbox functions. +#It is called by the pntool makefile to create object code for all the functions. + +COMPILER=gcc -g +PNHEADERS=../pnheaders + +all: actn.o admcon.o asiph.o avpr.o chkcons.o deallocation.o dp.o\ + extendedmatrix.o fvpr.o gcdv.o invar.o ilpadm.o ipslv.o ipsolve.o isadm.o\ + issiph.o linenf.o matrixmath.o MemoryManager.o mroadm.o msplit.o nltrans.o\ + pn2acpn.o pn2eacpn.o reduce.o supervis.o tactn.o liblpsolve55.a + +actn.o: actn.c spnbox.h MemoryManager.h matrixmath.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c actn.c + +admcon.o: admcon.c spnbox.h matrixmath.h extendedmatrix.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c admcon.c + +asiph.o: asiph.c spnbox.h extendedmatrix.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c asiph.c + +avpr.o: avpr.c $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c avpr.c + +chkcons.o: chkcons.c spnbox.h MemoryManager.h matrixmath.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h $(PNHEADERS)/pns.h + $(COMPILER) -c chkcons.c + +deallocation.o: deallocation.c spnbox.h $(PNHEADERS)/matrix.h + $(COMPILER) -c deallocation.c + +dp.o: dp.c spnbox.h matrixmath.h extendedmatrix.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h $(PNHEADERS)/pns.h + $(COMPILER) -c dp.c + +dp4.o: dp4.c spnbox.h matrixmath.h extendedmatrix.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h $(PNHEADERS)/pns.h + $(COMPILER) -c dp4.c + +extendedmatrix.o: extendedmatrix.c extendedmatrix.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c extendedmatrix.c + +fvpr.o: fvpr.c $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c fvpr.c + +gcdv.o: gcdv.c $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c gcdv.c + +invar.o: invar.c spnbox.h matrixmath.h MemoryManager.h extendedmatrix.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c invar.c + +ilpadm.o: ilpadm.c spnbox.h MemoryManager.h matrixmath.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h $(PNHEADERS)/pns.h + $(COMPILER) -c ilpadm.c + +ipslv.o: ipslv.c spnbox.h ../../third-party/lp_solve_5.5/lp_lib.h + $(COMPILER) -c ipslv.c + +ipsolve.o: ipsolve.c spnbox.h matrixmath.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c ipsolve.c + +isadm.o: isadm.c spnbox.h MemoryManager.h matrixmath.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c isadm.c + +issiph.o: issiph.c spnbox.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c issiph.c + +linenf.o: linenf.c spnbox.h MemoryManager.h matrixmath.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c linenf.c + +matrixmath.o: matrixmath.c matrixmath.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c matrixmath.c + +MemoryManager.o: MemoryManager.c MemoryManager.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c MemoryManager.c + +mroadm.o: mroadm.c spnbox.h $(PNHEADERS)/matrix.h $(PNHEADERS)/general.h matrixmath.h + $(COMPILER) -c mroadm.c + +msplit.o: msplit.c spnbox.h MemoryManager.h matrixmath.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c msplit.c + +nltrans.o: nltrans.c spnbox.h MemoryManager.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c nltrans.c + +pn2acpn.o: pn2acpn.c spnbox.h MemoryManager.h matrixmath.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c pn2acpn.c + +pn2eacpn.o: pn2eacpn.c spnbox.h MemoryManager.h matrixmath.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h + $(COMPILER) -c pn2eacpn.c + +reduce.o: reduce.c spnbox.h $(PNHEADERS)/general.h $(PNHEADERS)/matrix.h $(PNHEADERS)/pns.h + $(COMPILER) -c reduce.c + +supervis.o: supervis.c spnbox.h matrixmath.h $(PNHEADERS)/matrix.h + $(COMPILER) -c supervis.c + +tactn.o: tactn.c spnbox.h $(PNHEADERS)/matrix.h $(PNHEADERS)/pns.h matrixmath.h MemoryManager.h + $(COMPILER) -c tactn.c + +liblpsolve55.a: ../../third-party/lp_solve_5.5/lpsolve55/liblpsolve55.a + cp ../../third-party/lp_solve_5.5/lpsolve55/liblpsolve55.a liblpsolve55.a + +../../third-party/lp_solve_5.5/lpsolve55/liblpsolve55.a: + cd ../../third-party/lp_solve_5.5; make -f Makefile.Linux lib + +clean: + rm -fv *.o *.a + cd ../../third-party/lp_solve_5.5; make -f Makefile.Linux clean + +clean-partial: + rm -fv *.o + Added: 2009_version/spnbox09/MemoryManager.c =================================================================== --- 2009_version/spnbox09/MemoryManager.c (rev 0) +++ 2009_version/spnbox09/MemoryManager.c 2011-04-08 22:36:44 UTC (rev 246) @@ -0,0 +1,201 @@ +#include "MemoryManager.h" + +inline void ManageMatrix(MemoryManager* mgr, matrix* m) +{ + matrix **matrices; + if(mgr->nextm == mgr->lengthm) + { + if (! (matrices = realloc(mgr->matrices, sizeof(matrix*) * (mgr->lengthm + mgr->addressblockm)))) + { + merror(0, "Out of memory"); + return; + } + mgr->matrices = matrices; + mgr->lengthm += mgr->addressblockm; + } + mgr->matrices[mgr->nextm++] = m; +} + +inline void ManageMemory(MemoryManager* mgr, void* mem) +{ + void** memory; + if (mgr->next == mgr->length) + { + if (! (memory = realloc(mgr->memory, sizeof(void*) * (mgr->length + mgr->addressblock)))) + { + merror(0, "Out of memory"); + return; + } + mgr->memory = memory; + mgr->length += mgr->addressblock; + } + mgr->memory[mgr->next++] = mem; +} + +inline void* mmalloc(MemoryManager* mgr, size_t nbytes) +{ + void **memory; + if(mgr->next == mgr->length) + { + if (! (memory = realloc(mgr->memory, sizeof(void*) * (mgr->length + mgr->addressblock)))) + { + merror(0, "Out of memory"); + return; + } + mgr->memory = memory; + mgr->length += mgr->addressblock; + } + return mgr->memory[mgr->next++] = tmalloc(nbytes); +} + +inline void* mcalloc(MemoryManager* mgr, size_t n, size_t nbytes) +{ + void **memory; + if(mgr->next == mgr->length) + { + if (! (memory = realloc(mgr->memory, sizeof(void*) * (mgr->length + mgr->addressblock)))) + { + merror(0, "Out of memory"); + return; + } + mgr->memory = memory; + mgr->length += mgr->addressblock; + } + return mgr->memory[mgr->next++] = tcalloc(n, nbytes); +} + +inline void MAllocateMatrixType(MemoryManager* mgr, int type, matrix* m, int rows, int cols) +{ + AllocateMatrixType(type, m, rows, cols); + if (rows || cols) + { + ManageMatrix(mgr, m); + } +} + +void FreeMemory(MemoryManager* mgr) +{ + int i; + for (i = 0; i < mgr->nextm; i++) + { + if (mgr->matrices[i]->type) DeallocateMatrix(mgr->matrices[i]); + } + free(mgr->matrices); + mgr->matrices = 0; + for (i = 0; i < mgr->next; i++) + { + free(mgr->memory[i]); + } + free(mgr->memory); + mgr->memory = 0; +} + +MemoryManager CreateMemoryManager(int InitialLength, int InitialMatrices, int AddressBlockSize, int MatrixAddressBlockSize) +{ + MemoryManager mgr; + mgr.next = 0; + mgr.nextm = 0; + if (InitialLength <= 0) InitialLength = 1; + if (InitialMatrices <= 0) InitialMatrices = 1; + if (AddressBlockSize <= 5) AddressBlockSize = 5; + if (MatrixAddressBlockSize <= 5) MatrixAddressBlockSize = 5; + mgr.length = InitialLength; + mgr.lengthm = InitialMatrices; + mgr.memory = tcalloc(InitialLength, sizeof(void*)); + mgr.matrices = tcalloc(InitialMatrices, sizeof(void*)); + mgr.addressblock = AddressBlockSize; + mgr.addressblockm = MatrixAddressBlockSize; + return mgr; +} + +/*CreateMemoryGrower initializes a memory grower structure.*/ +MemoryGrower CreateMemoryGrower(int pointers, int blocksize) +{ + MemoryGrower g; + if (pointers < 1 || blocksize < 1) + { + merror(0, "CREATEMEMORYGROWER: Parameters are non-positive"); + memset(&g, 0, sizeof(MemoryGrower)); + return g; + } + + g.blocksize = blocksize; + g.memories = pointers; + g.memory = tcalloc(pointers, sizeof(void*)); + g.capacity = tcalloc(pointers, sizeof(int)); + g.next = 0; + return g; +} + +void* growMalloc(MemoryGrower* g, void* memory, int size) +{ + /*If the pointer is null, allocate some new memory.*/ + if (! g) + { + merror(0, "MEMORYGROWER: The pointer to the grower is null"); + return 0; + } + if (! memory) + { + if (g->next == g->memories) + { + merror(0, "MEMORYGROWER: Too many pointers registered with the grower"); + return 0; + } + if (size < g->blocksize) size = g->blocksize; + g->memory[g->next] = tmalloc(size); + g->capacity[g->next] = size; + return g->memory[g->next++]; + } + else + { + /*Otherwise, find the index of the memory record.*/ + int i; + for (i = 0; i < g->next; i++) + { + if (memory == g->memory[i]) break; + } + if (i == g->next) + { + merror(0, "MEMORYGROWER: The memory did not originate with the grower"); + return 0; + } + /*If the request size is smaller than the current capacity return without + reallocating.*/ + if (size < g->capacity[i]) + { + return memory; + } + /*Otherwise, allocate as necessary.*/ + { + if (size < g->capacity[i] + g->blocksize) size = g->capacity[i] + g->blocksize; + void* newMem = tmalloc(size); + memcpy(newMem, memory, g->capacity[i]); + g->capacity[i] = size; + g->memory[i] = newMem; + free(memory); + return newMem; + } + } +} + +void* growCalloc(MemoryGrower* g, void* memory, int elementSize, int elements) +{ + return growMalloc(g, memory, elementSize * elements); +} + + +/*FreeMemoryGrower deallocates all the memories pointed to by a memory +grower.*/ +void FreeMemoryGrower(MemoryGrower* g) +{ + if (! g) return; + int i; + for (i = 0; i < g->next; i++) + { + free(g->memory[i]); + } + free(g->memory); + free(g->capacity); + memset(g, 0, sizeof(MemoryGrower)); +} Added: 2009_version/spnbox09/MemoryManager.h =================================================================== --- 2009_version/spnbox09/MemoryManager.h (rev 0) +++ 2009_version/spnbox09/MemoryManager.h 2011-04-08 22:36:44 UTC (rev 246) @@ -0,0 +1,75 @@ +#ifndef MEMORYMANAGER_H +#define MEMORYMANAGER_H + +#include "../pnheaders/general.h" +#include "../pnheaders/matrix.h" + +/*The MemoryManager structure is used to store information about dynamically +allocated memory so that it can be freed when appropriate. It stores lists +of pointers to ordinary memory blocks and pointers to matrices.*/ +typedef struct MemoryManager +{ + void** memory; + int length; + int next; + int addressblock; + + matrix** matrices; + int lengthm; + int nextm; + int addressblockm; +} MemoryManager; + +/*ManageMatrix adds a matrix to the list of matrices to free later.*/ +inline void ManageMatrix(MemoryManager* mgr, matrix* m); + +/*ManageMemory adds a block of memory to the list of blocks to be freed later.*/ +inline void ManageMemory(MemoryManager* mgr, void* mem); + +/*mmalloc allocates a block of memory and adds it to the lists.*/ +inline void* mmalloc(MemoryManager* mgr, size_t nbytes); + +/*mcalloc allocates a block of memory for an array and adds to the lists.*/ +inline void* mcalloc(MemoryManager* mgr, size_t n, size_t nbytes); + +/*MAllocateMatrixType is exactly like AllocateMatrixType except that it adds +the newly-allocated matrix to the list of matrices to be freed later.*/ +inline void MAllocateMatrixType(MemoryManager* mgr, int type, matrix* m, int rows, int cols); + +/*FreeMemory frees the memory blocks and matrices listed by a memory manager.*/ +void FreeMemory(MemoryManager* mgr); + +/*CreateMemoryManager initializes a memory manager structure. InitialLength +and InitialMatrices are the initial sizes of the lists that hold memory block +and matrix addresses, respectively. Both these parameters must be at least 1 and +will be set to 1 automatically if passed as less than that. +AddressBlockSize and MatrixAddressBlockSize are the number of additional +addresses that memory will be allocated for each time the list of memory block +addresses or matrix addresses respectively become full. These must be at least +five and will be set to five automatically if passed as less than that.*/ +MemoryManager CreateMemoryManager(int InitialLength, int InitialMatrices, int AddressBlockSize, int MatrixAddressBlockSize); + +/*The MemoryGrower structure maintains the information needed to have a region +of memory that can be increased in size several times before a time-consuming +reallocation is necessary.*/ +typedef struct MemoryGrower +{ + void** memory; + int * capacity; + int blocksize, memories, next; +} MemoryGrower; + +/*CreateMemoryGrower initializes a memory grower structure.*/ +MemoryGrower CreateMemoryGrower(int pointers, int blocksize); + +/*growMalloc and growCalloc grow the specified piece of memory to the given +capacity. If the pointer to the memory is null, new memory is allocated. If the +pointer points to a piece of memory the memorygrower is not responsible for the +function fails.*/ +void* growMalloc(MemoryGrower* g, void* memory, int size); +void* growCalloc(MemoryGrower* g, void* memory, int elementSize, int elements); + +/*FreeMemoryGrower deallocates all the memories pointed to by a memory +grower.*/ +void FreeMemoryGrower(MemoryGrower* g); +#endif Added: 2009_version/spnbox09/actn.c =================================================================== --- 2009_version/spnbox09/actn.c (rev 0) +++ 2009_version/spnbox09/actn.c 2011-04-08 22:36:44 UTC (rev 246) @@ -0,0 +1,459 @@ +#include <stdlib.h> +#include "../pnheaders/matrix.h" +#include "matrixmath.h" +#include "extendedmatrix.h" +#include "MemoryManager.h" +#include "spnbox.h" + +static int CheckParams(matrix* Dm, matrix* Dp, int** X, int* XCount, matrix *Dcm, matrix *Dcp, int update); + +static int isUnique(matrix* D, int* X, int XCount); + +static actn_r BuildResult(matrix* Dm, matrix* Dp, int* cullPlace, int* cullTrans); + +static int* cullPlaces(matrix* Dp, int* cullTransition); + +static int* updateURT(matrix* Dm, matrix* Dp, matrix* Dcm, matrix* Dcp); + +static int CheckParams(matrix* Dm, matrix* Dp, int** X, int* XCount, matrix *Dcm, matrix *Dcp, int update); + +actn_r actn(matrix* Dm, matrix* Dp, int* X, int XCount, matrix *Dcm, matrix *Dcp, int update, int checkUnique) +{ + actn_r result; + nltrans_r nltransResult; + MemoryManager memory; + matrix D; /*The incidence matrix*/ + int *cullTransition; /*An array of flags, one for each transition, set if it + should be culled (is unraisable)*/ + int *cullPlace; /*An array of flags, one for each place, set if the place + should be culled.*/ + + /*Initialize the error return value*/ + memset(&result, 0, sizeof(actn_r)); + + /*Initialize the memory manager*/ + memory = CreateMemoryManager(5, 5, 0, 0); + + /*Check the parameters.*/ + if (! CheckParams(Dm, Dp, &X, &XCount, Dcm, Dcp, update)) return result; + + /*Get the incidence matrix - we'll need it later.*/ + D = SubtractMatrix(Dp, Dm, (matrix*) 2); + ManageMatrix(&memory, &D); + + if (update) + { + /*If we are in update mode, use the updateURT function to get the + unraisable transitions.*/ + cullTransition = updateURT(Dm, Dp, Dcm, Dcp); + } + else + { + /*Otherwise, use nltrans to get the list of unraisable transitions.*/ + nltransResult = nltrans(&D, X, XCount); + if (! (nltransResult.dtrCount)) + { + /*If the call failed, fail.*/ + FreeMemory(&memory); + merror(0, "ACTN: nltrans call failed"); + return result; + } + else + { + cullTransition = nltransResult.dtr; + } + } + ManageMemory(&memory, cullTransition); + + /*Build the cullPlace flags, which will be cleared only for places that + have nonzero input arcs from transitions that are not being culled.*/ + cullPlace = cullPlaces(Dp, cullTransition); + ManageMemory(&memory, cullPlace); + + /*Build the final output.*/ + result = BuildResult(Dm, Dp, cullPlace, cullTransition); + + /*Do an isUnique test only if the checkUnique flag is set, since the test + does several linear programming problems and is thus rather slow.*/ + if (checkUnique) + { + result.unique = isUnique(&D, X, XCount); + } + + /*Clean up.*/ + FreeMemory(&memory); + + return result; +} + +/******************************************************************************* +isUnique examines the petri net and the given set of unraisable transitions to +determine if the live subnet that will be returned is unique. It is only called +when the actn caller requests it.*/ +int isUnique(matrix* D, int* X, int XCount) +{ + /*We will be doing a linear programming problem for each raisable transition. + The constraint matrix will be the subset of D having only the columns + corresponding to transitions not in X, with a row of 1s concatenated onto the + bottom, and the column corresponding to whichever transition is currently + being tested removed (or in this case, zeroed).*/ + matrix Dx, dx; + int i, j, Transitions = 0; + int* UnraisableT; + double* B; + short int *IntList; + ipsolve_r result; + + //If no transitions are being evaluated, return true. + if ((Transitions = NumberOfColumns(*D) - XCount) <= 0) return 1; + /*Build a flag array of the columns whose indices are in X.*/ + UnraisableT = tcalloc(NumberOfColumns(*D), sizeof(int)); + for (i = 0; i < XCount; i++) + { + UnraisableT[X[i]] = 1; + } + /*Build Dx. It should include only columns of D whose indices are not in X. + It should be optimized for column ops.*/ + AllocateMatrixType(2, &Dx, Transitions, NumberOfRows(*D) + 1); + TransposeMatrix(&Dx); + j = 0; + for (i = 0; i < NumberOfColumns(*D); i++) + { + if (! UnraisableT[i]) + { + /*Fill in the last row.*/ + SetMatrixEl(&Dx, NumberOfRows(*D), j, 1); + /*Fill in the other rows*/ + CopyBlock(NumberOfRows(*D), 1, D, 0, i, &Dx, 0, j++); + } + } + //We are done with the flag array. Free memory. + free(UnraisableT); + + /*Allocate space to record the values of the current column while it is + zeroed. Make it a type-2 transpose to optimize the column-swap operation.*/ + AllocateMatrixType(1, &dx, 1, NumberOfRows(*D) + 1); + TransposeMatrix(&dx); + + /*Build B. It is all zeroes except for a 1 in the last element.*/ + B = tcalloc(NumberOfRows(*D) + 1, sizeof(double)); + B[NumberOfRows(*D)] = 1; + + /*IntList needs to be all zeroes to override the default of all 1s.*/ + IntList = tcalloc(Transitions, sizeof(short int)); + + /*Iterate through each transition*/ + for (i = 0; i < Transitions; i++) + { + /*If there is a previous transition to restore, restore it.*/ + if (i) SwapColumns(&Dx, &dx, i - 1, 0); + /*Swap out the current transition. Because dx is a column of zeros this + will effectively zero the current transition and save a copy in dx for later + restoration.*/ + SwapColumns(&Dx, &dx, i, 0); + + //ipsolve_r ipsolve(matrix* L, double* B, double* f, short int *IntList, double *ub, double *lb, short int *ctype); + result = ipsolve(&Dx, B, 0, IntList, 0, 0, 0); + if (result.res) free(result.res); + + /*If we get a valid solution, then free memory and return false.*/ + if (! strcmp(result.mhow, HOW_OK)) + { + free(IntList); + free(B); + DeallocateMatrix(&Dx); + DeallocateMatrix(&dx); + return 0; + } + } + //If we get through all transition without returning false, return true. + free(IntList); + free(B); + DeallocateMatrix(&Dx); + DeallocateMatrix(&dx); + return 1; +} + +/******************************************************************************* +BuildResult takes the list of places and transitions to cull from the total net +and builds the active subnet. It returns the result structure that will be +returned by actn. +*/ +actn_r BuildResult(matrix* Dm, matrix* Dp, int* cullPlace, int* cullTrans) +{ + int Places = 0, Transitions = 0, i, j, k, l; + actn_r result; + + /*All matrices are zeroed initially.*/ + memset(&result, 0, sizeof(actn_r)); + + /*Count the number of places and transitions that are going to be left after + culling.*/ + for (i = 0; i < NumberOfRows(*Dm); i++) + { + if (! cullPlace[i]) Places++; + } + for (i = 0; i < NumberOfColumns(*Dm); i++) + { + if (! cullTrans[i]) Transitions++; + } + + /*Allocate space. Dma/Dmp are the same size as the original matrices but + contain only elements in non-culled rows and columns. Dmra/Dpra contain only + non-culled rows and columns. TA holds the indices of kept transitions.*/ + if (Places && Transitions) + { + AllocateMatrixType(2, &result.Dmra, Places, Transitions); + AllocateMatrixType(2, &result.Dpra, Places, Transitions); + } + AllocateMatrixType(2, &result.Dma, NumberOfRows(*Dm), NumberOfColumns(*Dm)); + AllocateMatrixType(2, &result.Dpa, NumberOfRows(*Dm), NumberOfColumns(*Dm)); + result.TA = tcalloc(Transitions, sizeof(int)); + result.TACount = Transitions; + /*Do the copy. k and l indicate the row and column numbers in the Dmra/Dpra + matrices. Fill in TA while we're at it.*/ + l = 0; + for (j = 0; j < NumberOfColumns(*Dm); j++) + { + if (cullTrans[j]) continue; + k = 0; + for (i = 0; i < NumberOfRows(*Dm); i++) + { + if (cullPlace[i]) continue; + SetMatrixEl(&result.Dma, i, j, GetMatrixEl(Dm, i, j)); + SetMatrixEl(&result.Dpa, i, j, GetMatrixEl(Dp, i, j)); + SetMatrixEl(&result.Dmra, k, l, GetMatrixEl(Dm, i, j)); + SetMatrixEl(&result.Dpra, k, l, GetMatrixEl(Dp, i, j)); + k++; + } + result.TA[l] = j; + l++; + } + return result; +} +/******************************************************************************* +cullPlaces examines the Petri net and the list of transitions to cull and +returns an array of integer flags, one for each place, indicating whether that +place should be culled. +*/ +int* cullPlaces(matrix* Dp, int* cullTransition) +{ + int i, j; + int *cull; + /*Allocate and initialize the return value cull. It will be clear only for + places that have nonzero output arcs to transitions that are not being + culled.*/ + cull = tcalloc(NumberOfRows(*Dp), sizeof(int)); + for (i = 0; i < NumberOfRows(*Dp); i++) + { + /*Look to see if the current place has any nonzero output arcs to + transitions not being culled.*/ + for (j = 0; j < NumberOfColumns(*Dp); j++) + { + if (GetMatrixEl(Dp, i, j) && (! cullTransition[j])) + { + break; + } + } + /*If there were no nonzero output arcs set the place flag.*/ + if (j == NumberOfColumns(*Dp)) + { + cull[i] = 1; + } + } + return cull; +} + +/******************************************************************************* +updateURT examines the Petri net and the predefined active subnet if given and +returns an array of transitions that are unraisable given the active subnet. +This is used to determine transitions to cull if in update mode. +*/ +int* updateURT(matrix* Dm, matrix* Dp, matrix* Dcm, matrix* Dcp) +{ + /*This function builds a list of unraisable transitions in Dm/Dp by examining + Dcm/Dcp.*/ + int Places, Transitions, SubPlaces, SubTransitions, i, j, keepGoing; + /*These are each flag arrays set to indicate live places or transitions at + various times throughout the algorithm.*/ + int *URT, *Trans = 0, *Place = 0; + + Places = NumberOfRows(*Dm); + Transitions = NumberOfColumns(*Dm); + SubPlaces = NumberOfRows(*Dcm); + SubTransitions = NumberOfColumns(*Dcm); + + /*URT is the return value. It has a flag for each transition.*/ + URT = tcalloc(Transitions, sizeof(int)); + /*Trans and Place both have flags only for each of the possible new + transitions or places that can be added.*/ + if (Places - SubPlaces) + { + Place = tcalloc(Places - SubPlaces, sizeof(int)); + } + if (Transitions - SubTransitions) + { + Trans = tcalloc(Transitions - SubTransitions, sizeof(int)); + } + + /*URT is a flag vector with an element for each transition. It is initially + cleared only for non-null columns of Dcm/Dcp, where column numbers in Dcm/Dcp + map to the same column numbers in Dm/Dp.*/ + for (i = 0; i < SubTransitions; i++) + { + /*See if the current column of Dcm/Dcp is non-null.*/ + for (j = 0; j < SubPlaces; j++) + { + if (GetMatrixEl(Dcm, j, i) || GetMatrixEl(Dcp, j, i)) + { + break; + } + } + /*If it was null, set the URT flag.*/ + if (j == SubPlaces) + { + URT[i] = 1; + } + } + /*Fill the additional elements of URT, the ones not taken care of above.*/ + for (i = SubTransitions; i < Transitions; i++) + { + URT[i] = 1; + } + + /*Now, we loop. For the first iteration we have to do something special. Use + keepGoing = -1 to indicate first loop iteration.*/ + keepGoing = -1; + do + { + /*The place flag should be set for any place (in Dm/Dp beyond those mapped + to by Dcm/Dcp) such that the place has at least one nonzero output arc to + a transition that is flagged in the current transition list. It should + be cleared for every other place. On the first loop iteration, rather + than using the current transition list (which maps to the columns in the + right of Dm/Dp that have no corresponding columns in Dcm/Dcp), we use logic + inverse of URT, which maps to all columns in Dm/Dp. The keepGoing flag will + be set to -1 on the first iteration.*/ + memset(Place, 0, sizeof(int) * (Places - SubPlaces)); + if (keepGoing > 0) + { + for (i = SubPlaces; i < Places; i++) + { + /*Check to see if the current place has at least one nonzero output arc + to a transition flagged in the current transition list.*/ + for (j = SubTransitions; j < Transitions; j++) + { + if (Trans[j - SubTransitions] && GetMatrixEl(Dm, i, j)) + { + /*If it does, set the flag and break out of the test loop.*/ + Place[i - SubPlaces] = 1; + break; + } + } + } + } + else + { + for (i = SubPlaces; i < Places; i++) + { + /*Check to see if the current place has at least one nonzero output arc + to a transition not flagged in URT.*/ + for (j = 0; j < SubTransitions; j++) + { + if ((! URT[j]) && GetMatrixEl(Dm, i, j)) + { + /*If it does, set the flag and break out of the test loop.*/ + Place[i - SubPlaces] = 1; + break; + } + } + } + } + /*Similarly, the transition flag should be set for any transition in Dm/Dp + beyond those mapped to by Dcm/Dcp such that the transition has at least one + nonzero input arc to a place that is flagged in the current place list. + Additionally, we clear every flag of URT that corresponds to a + transition whose flag is set in Trans. Finally, the overall loop will + continue only until Trans is entirely empty. Set the keepGoing flag + if any element of Trans is set.*/ + keepGoing = 0; + memset(Trans, 0, sizeof(int) * (Transitions - SubTransitions)); + for (j = SubTransitions; j < Transitions; j++) + { + for (i = SubPlaces; i < Places; i++) + { + if (Place[i - SubPlaces] && GetMatrixEl(Dp, i, j)) + { + Trans[j - SubTransitions] = 1; + /*Clear the appropriate URT flag.*/ + URT[j] = 0; + /*Set the keepGoing flag.*/ + keepGoing = 1; + break; + } + } + } + } while (keepGoing); + /*Free memory*/ + if (Place) free(Place); + if (Trans) free(Trans); + /*Return*/ + return URT; +} + +/******************************************************************************* +CheckParams checks the parameters to make sure required parameters are present, +checks some basic validity, and makes sure that all array pointers are null if +their counts are zero and vice-versa.*/ +int CheckParams(matrix* Dm, matrix* Dp, int** X, int* XCount, matrix *Dcm, matrix *Dcp, int update) +{ + int Rows0, Cols0, Rows1, Cols1; + /*Dm and Dp are required and must be the same size.*/ + if (! (Dm && Dp)) + { + merror(0, "ACTN: Dm or Dp was not given"); + return 0; + } + Rows0 = NumberOfRows(*Dm); + Cols0 = NumberOfColumns(*Dm); + if (Rows0 != NumberOfRows(*Dp) || Cols0 != NumberOfColumns(*Dp)) + { + merror(0, "ACTN: The dimensions of Dm and Dp do not match"); + return 0; + } + + /*X is not required. Make sure that XCount is zero if X is null and vice- + versa.*/ + if (! *X) + { + *XCount = 0; + } + else if (! *XCount) + { + *X = 0; + } + + /*If update is nonzero, Dcm and Dcp are required. They cannot be larger than + Dm/Dp in either dimension and they must be the same size.*/ + if (update) + { + if (! (Dcm && Dcp)) + { + merror(0, "ACTN: Dcm or Dcp was not given while update was nonzero"); + return 0; + } + Rows1 = NumberOfRows(*Dcm); + Cols1 = NumberOfColumns(*Dcm); + if (NumberOfRows(*Dcp) != Rows1 || NumberOfColumns(*Dcp) != Cols1) + { + merror(0, "ACTN: Dcm and Dcp are not the same size"); + return 0; + } + if (Rows1 > Rows0 || Cols1 > Cols0) + { + merror(0, "ACTN: Dcm and Dcp are larger than Dm and Dp"); + return 0; + } + } + return 1; +} Added: 2009_version/spnbox09/admcon.c =================================================================== --- 2009_version/spnbox09/admcon.c (rev 0) +++ 2009_version/spnbox09/admcon.c 2011-04-08 22:36:44 UTC (rev 246) @@ -0,0 +1,613 @@ +#include <stdlib.h> +#include "../pnheaders/general.h" +#include "../pnheaders/matrix.h" +#include "MemoryManager.h" +#include "matrixmath.h" +#include "extendedmatrix.h" +#include "spnbox.h" + +static int CheckParams(admcon_p *params); +static int GetRowCount(admcon_p *params); +static matrix BuildZ(admcon_p *params); +static matrix BuildDX(admcon_p *p, matrix *Z); +static int *nlplace(admcon_p *p, matrix *DX, int *pCount); +static ipsolve_r RawSolution(admcon_p *param, matrix *DX, int* p, int pCount); +static admcon_r BuildResult(ipsolve_r *lpresult, int *p, int pCount, int rowCount); + +admcon_r admcon(admcon_p *params) +{ + /*Initialize to an error value.*/ + admcon_r result; + memset(&result, 0, sizeof(result)); + + /*Check parameters.*/ + if (! CheckParams(params)) + { + return result; + } + + /*Initialize the result to a default value.*/ + result.how = 1; + + /*Get the row count and the intermediate matrix Z.*/ + int rowCount = GetRowCount(params); + matrix Z = BuildZ(params); + /*Get the intermediate linear programming matrix DX. Z will be deallocated + by the function call. If DX returns an empty matrix, it means that the + default solution, a copy of the siphon, is feasible. Return immediately.*/ + matrix DX = BuildDX(params, &Z); + if (! DX.type) + { + /*Build the result and return. l should be a copy of the siphon vector.*/ + result.l = tcalloc(NumberOfRows(params->Dm), sizeof(int)); + result.lCount = NumberOfRows(params->Dm); + memcpy(result.l, params->siphon, sizeof(int) * NumberOfRows(params->Dm)); + return result; + } + + /*Get p, a list of places. This function is an aggregate of the nlplace function + present in the Matlab version of this function, and several lines of code + immediately after it. If nlplace returns a null pointer, it means that no + feasible solution exists.*/ + int pCount; + int *p; + if (! (p = nlplace(params, &DX, &pCount))) + { + result.how = 0; + DeallocateMatrix(&DX); + return result; + } + + /*Otherwise, proceed to build and solve another linear programming problem + using p. This problem deallocates DX.*/ + ipsolve_r lpresult = RawSolution(params, &DX, p, pCount); + + /*Get the new solution.*/ + return BuildResult(&lpresult, p, pCount, rowCount); +} + +/******************************************************************************* +This function processes the solution returned by RawSolution to build the new +solution. It also deallocates everything that still needs to be deallocated.*/ +admcon_r BuildResult(ipsolve_r *lpresult, int *p, int pCount, int rowCount) +{ + int i; + admcon_r result; + + /*If the lp solution is valid, copy the appropriate values to the result. + Otherwise leave it blank.*/ + if (! strcmp(lpresult->mhow, HOW_OK)) + { + result.l = tcalloc(rowCount, sizeof(int)); + result.lCount = rowCount; + for (i = 0; i < pCount; i++) + { + result.l[p[i]] = (int) lpresult->res[p[i]]; + } + result.how = 1; + } + else + { + memset(&result, 0, sizeof(admcon_r)); + } + + /*Deallocate p and the lpresult.*/ + free(p); + DeallocateIpsolve(lpresult); + return result; +} + +/******************************************************************************* +This function builds and solves a linear programming problem to get the modified +solution vector l. It returns the raw ipsolve results - not the processed +version that is the final solution. It also deallocates DX, which is not used +after this point.*/ +ipsolve_r RawSolution(admcon_p *param, matrix *DX, int* p, int pCount) +{ + MemoryManager mem; + mem = CreateMemoryManager(3, 1, 0, 0); + /*The constraint matrix is an identity followed below by those columns + of DX which have indices present in p. We will do this by adding rows directly + to DX (it has been optimized for row ops), nulling out the columns we are not + interested in, and putting in 1s for the identity where we are interested.*/ + InsertNullRows(DX, 0, pCount, -1); + ManageMatrix(&mem, DX); + + /*Insert the 1s we are interested in. While doing it, build a flag array that + is set at each index present in p.*/ + int *pFlag = mcalloc(&mem, NumberOfColumns(*DX), sizeof(int)); + int i, j; + for (i = 0; i < pCount; i++) + { + pFlag[p[i]] = 1; + SetMatrixEl(DX, i, p[i], 1); + } + /*Now go back and zero all the columns not flagged in pFlag.*/ + for (i = 0; i < NumberOfColumns(*DX); i++) + { + if (! pFlag[i]) MakeZeroColumn(DX, i); + } + + /*The constraint vector should be 1s for each row that was added by the + identity and zeros for all elements thereafter except the last.*/ + double *B = mcalloc(&mem, NumberOfRows(*DX), sizeof(double)); + for (i = 0; i < pCount; i++) + { + B[i] = 1; + } + B[NumberOfRows(*DX) - 1] = 1; + + /*Cost should have, for each place indexed in p, an element that is the sum + of all elements of Dm for that place that correspond to elements of the + incidence matrix D that are negative.*/ + double *F = mcalloc(&mem, NumberOfColumns(*DX), sizeof(double)); + for (i = 0; i < pCount; i++) + { + for (j = 0; j < NumberOfColumns(param->Dm); j++) + { + int dm = GetMatrixEl(¶m->Dm, p[i], j); + int dp = GetMatrixEl(¶m->Dp, p[i], j); + if (dp - dm < 0) F[p[i]] += (double) dm; + } + } + + /*Solve the problem.*/ + ipsolve_r result = ipsolve(DX, B, F, 0, 0, 0, 0); + + /*Free memory and return the solution.*/ + FreeMemory(&mem); + return result; +} + +/******************************************************************************* +Get the list of places p that are live. Return the list length in the integer +pointed to by parameter pCount.*/ +int *nlplace(admcon_p *p, matrix *DX, int *pCount) +{ + MemoryManager mem; + mem = CreateMemoryManager(4, 1, 0, 0); + + /*We need to build a linear programming problem. We will iterate through each + column, adjust the problem slightly, and resolve it.*/ + + /*We need to know how many places are flagged in the siphon flag array.*/ + int placeCount = 0, i, j, k; + for (i = 0; i < NumberOfRows(p->Dm); i++) + { + if (p->siphon[i]) placeCount++; + } + + /*The constraint matrix is the columns (?) of DX for which flags are set in the + siphon listing, followed to the right by a negative identity, then below by a + vector which will change from iteration to iteration.*/ + matrix L; + MAllocateMatrixType(&mem, 2, &L, NumberOfRows(*DX) + 1, placeCount + NumberOfRows(*DX)); + j = 0; + /*Copy the appropriate columns of DX.*/ + for (i = 0; i < NumberOfRows(p->Dm); i++) + { + if (p->siphon[i]) + { + CopyBlock(NumberOfRows(*DX), 1, DX, 0, i, &L, 0, j++); + } + } + /*Fill in the negative identity.*/ + for (i = 0; i < NumberOfRows(*DX); i++) + { + SetMatrixEl(&L, i, i + placeCount, -1); + } + + /*The constraint vector should be all zeros except the last element, which + should be 1.*/ + double *B = mcalloc(&mem, NumberOfRows(L), sizeof(double)); + B[NumberOfRows(L) - 1] = 1; + + /*Cost vector should be all ones.*/ + double *F = mcalloc(&mem, NumberOfColumns(L), sizeof(double)); + for (i = 0; i < NumberOfColumns(L); i++) + { + F[i] = 1; + } + + /*Constraint type should be all equalities (0) except that of the last column, + which should be a greater-than (1).*/ + short *ctype = mcalloc(&mem, NumberOfRows(L), sizeof(short)); + ctype[NumberOfRows(L) - 1] = 1; + + /*IntList should be all zeroes.*/ + short *intList = mcalloc(&mem, NumberOfColumns(L), sizeof(short)); + + /*During our iterations we will modify a flag array, cov, with an element for + each of the columns that came from DX. Allocate space.*/ + int *cov = mcalloc(&mem, placeCount, sizeof(int)); + + /*Start the iterations. Store in j the index of the last column of L such that + its element in the last row was set to 1 within the loop. -1 means no column + set yet.*/ + j = -1; + for (i = 0; i < placeCount; i++) + { + /*Process only columns which are not flagged yet in cov.*/ + if (cov[i]) continue; + + /*The last row of the constraint matrix should be all zeros except for the + element corresponding to the current column, which should be 1.*/ + if (j >= 0) SetMatrixEl(&L, NumberOfRows(L) - 1, j, 0); + j = i; + SetMatrixEl(&L, NumberOfRows(L) - 1, i, 1); + + /*Solve the linear programming problem. Let the bounds default to 0 and inf.*/ + ipsolve_r lpresult = ipsolve(&L, B, F, intList, 0, 0, ctype); + + /*If the solution is valid, set any elements of cov for which there is a + nonzero (and not very small) value in the solution vector.*/ + if (! strcmp(lpresult.mhow, HOW_OK)) + { + for (k = 0; k < placeCount; k++) + { + if (lpresult.res[k] > HOW_MAX_ERROR || lpresult.res[k] < -HOW_MAX_ERROR) + { + cov[k] = 1; + } + } + } + /*Deallocate any memory used by the solution.*/ + DeallocateIpsolve(&lpresult); + } + + /*Build the result. It is a list of the indices of elements of the siphon list + (places) that correspond to nonzero elements in cov. Start by counting them.*/ + *pCount = 0; + for (i = 0; i < placeCount; i++) + { + if (cov[i]) (*pCount)++; + } + /*Allocate space and do the building. Each index should be not the index + within cov, but, for the ith element of cov, the index of the ith nonzero + element in siphon. Use j to count indices in siphon.*/ + int *result = tcalloc(*pCount, sizeof(int)); + j = -1; + k = 0; + for (i = 0; i < placeCount; i++) + { + /*Find the ith nonzero place in siphon.*/ + j++; + while (! p->siphon[j]) j++; + /*If the current nonzero place is flagged in cov, copy the index.*/ + if (cov[i]) result[k++] = j; + } + /*Free up memory.*/ + FreeMemory(&mem); + + /*Make sure that there are at least two places with indices in p that are + also present in the active place list. Count places like that in k.*/ + k = 0; + for (i = 0; i < *pCount; i++) + { + for (j = 0; j < p->apCount; j++) + { + if (result[i] == p->apl[j]) + { + if (++k == 2) break; + } + } + } + /*If not, no feasible solution to the admcon problem exists. Return a null + pointer to indicate this.*/ + if (k < 2) + { + free(result); + *pCount = 0; + return 0; + } + return result; +} + +/******************************************************************************* +This function builds the intermediate linear programming description matrix DX. +It runs a test on DX, and if the value of l (the solution vector) is already +correct it returns an empty matrix to signify that admcon should return +immediately. This function also deallocates the Z matrix, which, is not used +again.*/ +matrix BuildDX(admcon_p *p, matrix *Z) +{ + /*DX is a matrix composed of a right-to-left concatentation of submatrices, all transposed: + DX = [Auc, Auo, -Auo, -Ds, d]' + For: + Auc = Z * DI(:,Tuc) + Auo = Z * DI(:,Tuo) + Ds = (Dp - Dm)(:,ntr) %that is, the part of the incidence matrix corresponding + %to transitions that came from transition split. + d = a flag array, one for each place, set to 1 for active places. + */ + /*Allocate DX.*/ + matrix DX; + AllocateMatrixType(2, &DX, p->TucCount + p->TuoCount + p->TuoCount + p->ntCount + 1, NumberOfRows(*Z)); + + int i, j, k; + for (i = 0; i < NumberOfColumns(DX); i++) + { + /*Fill in Auc.*/ + for (j = 0; j < p->TucCount; j++) + { + SetMatrixEl(&DX, j, i, MultiplyVector(Z, &p->DI, i, p->Tuc[j], 0)); + } + /*Fill in Auo and -Auo.*/ + for (j = 0; j < p->TuoCount; j++) + { + k = MultiplyVector(Z, &p->DI, i, p->Tuo[j], 0); + SetMatrixEl(&DX, j + p->TucCount, i, k); + SetMatrixEl(&DX, j + p->TucCount + p->TuoCount, i, -k); + } + /*Fill in -Ds.*/ + for (j = 0; j < p->ntCount; j++) + { + k = GetMatrixEl(&p->Dm, i, p->ntr[j]) - GetMatrixEl(&p->Dp, i, p->ntr[j]); + SetMatrixEl(&DX, j + p->TucCount + (2 * p->TuoCount), i, k); + } + } + /*Fill in d.*/ + for (i = 0; i < p->apCount; i++) + { + SetMatrixEl(&DX, NumberOfRows(DX) - 1, p->apl[i], 1); + } + /*Deallocate Z. It will not be needed anymore.*/ + DeallocateMatrix(Z); + + /*Run a test. If DX * siphon (the default solution vector is simply the siphon) + >= b, the default solution vector is good. b should be a vector of all zeros + except for the last element, which should be 1. We can skip the building of b + and simply put the test in a loop.*/ + if (p->siphon) + { + for (i = 0; i < NumberOfRows(DX); i++) + { + k = MultiplyVector(&DX, (matrix*) p->siphon, i, MULTIPLYVECTOR_ARRAY, 0); + if (k < (i < NumberOfRows(DX) - 1 ? 0 : 1)) + { + break; + } + } + /*If we made it through the loop without breaking out early, it means that the + default solution vector is valid. Deallocate and zero DX and return to + indicate this. Otherwise just return DX as-is for the next stage in + processing.*/ + if (i == NumberOfRows(DX)) + { + DeallocateMatrix(&DX); + } + } + return DX; +} + +/******************************************************************************* +This function builds the matrix Z, an intermediate matrix of the admcon +algorithm.*/ +matrix BuildZ(admcon_p *p) +{ + /*Build the independent place flag array. This is an array of flags, one for + each element of the independent place list. The flag should be set of the + place indexed by the corresponding ind. place list element is also present in + the original place list.*/ + int *ipFlag = 0; + int ipFlagged = 0, i, j, k; + if (p->ipl) + { + ipFlag = tcalloc(p->ipCount, sizeof(int)); + for (i = 0; i < p->ipCount; i++) + { + for (j = 0; j < p->opCount; j++) + { + if (p->ipl[i] == p->opl[j]) + { + ipFlag[i] = 1; + ipFlagged++; + break; + } + } + } + } + + /*Initialize the result to an empty matrix.*/ + matrix result; + memset(&result, 0, sizeof(matrix)); + + if (ipFlagged) + { + /*Allocate space for Z.*/ + AllocateMatrixType(2, &result, p->ipCount + p->dpCount, ipFlagged); + j = 0; + /*Build Z. We'll need to examine each independent place.*/ + for (i = 0; i < p->ipCount; i++) + { + if (ipFlag[i]) + { + /*Build the part of Z based on independent places. We are inserting an + identity, except that some columns (those not flagged in ipFlagged) must + be removed premptively. Thus, on the ith independent place, count how + many places up to that point have been flagged. Use j. Set the jth + column of Z (at the appropriate row) to a 1.*/ + SetMatrixEl(&result, p->ipl[i], j, 1); + + /*Build the part of Z based on dependent places. We are copying rows + from M to their corresponding rows in Z (dep. place rows) except that + the columns not flagged in ipFlag will not be copied.*/ + if (p->M.type) + { + for (k = 0; k < p->dpCount; k++) + { + SetMatrixEl(&result, p->dpl[k], j, GetMatrixEl(&p->M, k, i)); + } + } + + j++; + } + } + } + /*Free the flag array.*/ + if (ipFlag) free(ipFlag); + return result; +} + +/******************************************************************************* +This function gets the row count.*/ +int GetRowCount(admcon_p *params) +{ + int max = 0, i; + for (i = 0; i < params->ipCount; i++) + { + if (params->ipl[i] > max) max = params->ipl[i]; + } + for (i = 0; i < params->dpCount; i++) + { + if (params->dpl[i] > max) max = params->dpl[i]; + } + for (i = 0; i < params->opCount; i++) + { + if (params->opl[i] > max) max = params->opl[i]; + } + return max + 1; +} + +/******************************************************************************* +This function checks the parameters to make sure they are valid.*/ +int CheckParams(admcon_p *params) +{ + /*If the skipParamCheck flag is set, skip the checks. Return 1 immediately.*/ + if (params->skipParamCheck) return 1; + + int i, j; + if (! params) + { + merror(0, "ADMCON: No parameters provided"); + return 0; + } + /*Dm and Dp must be present.*/ + if (! (params->Dm.type && params->Dp.type)) + { + merror(0, "ADMCON: Dm and Dp were not initialized"); + return 0; + } + /*Dm and Dp must be the same size.*/ + if (NumberOfRows(params->Dm) != NumberOfRows(params->Dp) || NumberOfColumns(params->Dm) != NumberOfColumns(params->Dp)) + { + merror(0, "ADMCON: Dm and Dp are not the same size"); + return 0; + } + /*DI must be present.*/ + if (! params->DI.type) + { + merror(0, "ADMCON: DI has not been initialized"); + return 0; + } + /*Make sure that array pointers are null if their counts are null.*/ + if (! params->ipCount) params->ipl = 0; + else if (! params->ipl) params->ipCount = 0; + if (! params->dpCount) params->dpl = 0; + else if (! params->dpl) params->dpCount = 0; + if (! params->opCount) params->opl = 0; + else if (! params->opl) params->opCount = 0; + if (! params->apCount) params->apl = 0; + else if (! params->apl) params->apCount = 0; + if (! params->ntCount) params->ntr = 0; + else if (! params->ntr) params->ntCount = 0; + if (! params->TucCount) params->Tuc = 0; + else if (! params->Tuc) params->TucCount = 0; + if (! params->TuoCount) params->Tuo = 0; + else if (! params->Tuo) params->TuoCount = 0; + + /*If the dependent/independent place lists are provided, run some tests.*/ + if (params->ipl || params->dpl) + { + /*Their total count must be that of the total number of places.*/ + if (params->ipCount + params->dpCount != NumberOfRows(params->Dm)) + { + merror(0, "ADMCON: The number of dependent and independent places does not match the total number of places"); + return 0; + } + /*They cannot include any of the same places or include any out-of-range + indices.*/ + for (i = 0; i < params->ipCount; i++) + { + if (params->ipl[i] < 0 || params->ipl[i] > NumberOfRows(params->Dm)) + { + merror(0, "ADMCON: The independent place list has an out-of-range index"); + return 0; + } + } + for (i = 0; i < params->dpCount; i++) + { + if (params->dpl[i] < 0 || params->dpl[i] > NumberOfRows(params->Dm)) + { + merror(0, "ADMCON: The dependent place list has an out-of-range index"); + return 0; + } + } + for (i = 0; i < params->ipCount; i++) + { + for (j = 0; j < params->dpCount; j++) + { + if (params->ipl[i] == params->dpl[j]) + { + merror(0, "ADMCON: The independent and dependent place lists contain common elements"); + return 0; + } + } + } + } + /*If the list of transitions that resulted from the transition split is present, + make sure there are no duplicate or out-of-range elements.*/ + if (params->ntr) + { + for (i = 0; i < params->ntCount; i++) + { + if (params->ntr[i] < 0 || params->ntr[i] > NumberOfColumns(params->Dm)) + { + merror(0, "ADMCON: The new transition list contains an out-of-range index"); + return 0; + } + for (j = i + 1; j < params->ntCount; j++) + { + if (params->ntr[i] == params->ntr[j]) + { + merror(0, "ADMCON: The new transition list containts duplicate entries"); + } + } + } + } + /*If M is present (nonzero) it must have the same number of columns as there + are independent places and the same number of rows as there are independent + places.*/ + if (params->M.type && (params->ipl && params->dpl)) + { + if (NumberOfColumns(params->M) != params->ipCount || NumberOfRows(params->M) != params->dpCount) + { + merror(0, "The dependent-to-independent marking transformation matrix is not the right size"); + return 0; + } + } + /*At least one of Tuc or Tuo must be provided.*/ + if (! (params->Tuc || params->Tuo)) + { + merror(0, "ADMCON: No unobservable or uncontrollable transitions were given"); + return 0; + } + /*Neither Tuc nor Tuo should contain duplicate or out-of-range indices.*/ + for (i = 0; i < params->TucCount; i++) + { + if (params->Tuc[i] < 0 || params->Tuc[i] >= NumberOfColumns(params->DI)) + { + merror(0, "ADMCON: Tuc contains an out-of-range index"); + return 0; + } + } + for (i = 0; i < params->TuoCount; i++) + { + if (params->Tuo[i] < 0 || params->Tuo[i] >= NumberOfColumns(params->DI)) + { + merror(0, "ADMCON: Tuo contains an out-of-range index"); + return 0; + } + } + return 1; +} Added: 2009_version/spnbox09/asiph.c =================================================================== --- 2009_version/spnbox09/asiph.c (rev 0) +++ 2009_version/spnbox09/asiph.c 2011-04-08 22:36:44 UTC (rev 246) @@ -0,0 +1,901 @@ +#include <stdio.h> +#include "../pnheaders/general.h" +#include "../pnheaders/matrix.h" +#include "spnbox.h" +#include "MemoryManager.h" +#include "extendedmatrix.h" + +typedef struct asiph_data +{ + int *numInputPlaces; + int *curTrans; + int *counters; + matrix M; + matrix N; + matrix MT; + matrix NT; + matrix newRow; + matrix newPlace; + matrix MNS; + matrix NS; +} asiph_data; + +static int CheckParams(matrix *Dm, matrix *Dp, int **list, int *listCount, matrix *PS, matrix **Dma, matrix **Dpa, MemoryManager *mem); +static matrix SXInit(matrix *Dm, matrix *Dp, matrix *Dma, matrix* Dpa, matrix *PS, int **list, int* listCount, asiph_data* data); +static int* insert(asiph_data* data, matrix* vector, int* index); +static int *DataInit(matrix *Dm, matrix *Dp, matrix *PS, matrix *sx, asiph_data* data); +static int GetNewTrans(matrix *Dm, matrix *Dp, matrix *Places, int *Flags); +static void OuterLoopInit(asiph_data* data, matrix *Dm, matrix *Dp, MemoryManager *mem); +static void MiddleLoopInit(asiph_data* data, asiph_r* result, int siphon); +static void InnerLoopInit(asiph_data* data, matrix *Dm, matrix *Dp); +static int Check1(matrix *MNS, matrix *newRow); +static int Check2(matrix* M, matrix* newRow); +static int* DoInnerLoop(asiph_data* data, matrix* Dm, matrix *Dp, int* index); +static void PrintPercent(int num, int denom); +static asiph_r BuildResult(matrix *Dm, matrix *Dp, asiph_data* data, int *index); + +asiph_r asiph(matrix *Dm, matrix *Dp, int* list, int listCount, matrix *PS, matrix *Dma, matrix *Dpa) +{ + MemoryManager mem; + mem = CreateMemoryManager(10, 10, 0, 0); + asiph_r result; + memset(&result, 0, sizeof(asiph_r)); + /*Check parameters.*/ + if (! CheckParams(Dm, Dp, &list, &listCount, PS, &Dma, &Dpa, &mem)) + { + return result; + } + asiph_data data; + memset(&data, 0, sizeof(asiph_data)); + + /*Initialize sx (and a few other things)*/ + matrix sx = SXInit(Dm, Dp, Dma, Dpa, PS, &list, &listCount, &data); + ManageMatrix(&mem, &sx); + /*Initialize some other parts of the loop data. Build the newIndex array.*/ + int *newIndex = DataInit(Dm, Dp, PS, &sx, &data); + + /*Allocate and initialize various quantities that do not change or the space + for which does not change over the iterations of the outer loop.*/ + OuterLoopInit(&data, Dm, Dp, &mem); + + /*Iterate through each of the rows of NS. Each row corresponds to a siphon + that needs to be processed. If verbosity is high enough we'll be printing a + progress report as we go. Prepare.*/ + int siphon, originalSiphons; + originalSiphons = NumberOfRows(data.NS); + if (is_verbose() >= VRB_ASIPH) + { + printf("ASIPH: Primary Processing Loop Progress: "); + PrintPercent(0, 1); + } + for (siphon = 0; siphon < originalSiphons; siphon++) + { + /*Initialize the stuff that doesn't change within the middle loop.*/ + MiddleLoopInit(&data, &result, siphon); + /*The middle loop runs until we have removed all rows from M/N*/ + while (NumberOfRows(data.M)) + { + /*Initialize the stuff for the innermost loop run.*/ + InnerLoopInit(&data, Dm, Dp); + /*Run the inner loop. This has been moved to its own function.*/ + newIndex = DoInnerLoop(&data, Dm, Dp, newIndex); + /*Now concatenate MT onto M and NT onto N.*/ + if (NumberOfRows(data.MT)) InsertRows(&data.M, &data.MT, -1, -1); + if (NumberOfRows(data.NT)) InsertRows(&data.N, &data.NT, -1, -1); + /*Remove the first row of M and N.*/ + RemoveRows(&data.M, 0, 1, -1); + RemoveRows(&data.N, 0, 1, -1); + } + /*Deallocate whatever still needs to be deallocated - M and N.*/ + DeallocateMatrix(&data.M); + DeallocateMatrix(&data.N); + /*If verbosity is high enough, print a progress percentage.*/ + if (is_verbose() >= VRB_ASIPH) + { + PrintPercent(siphon + 1, originalSiphons); + } + } + if (is_verbose() >= VRB_ASIPH) + { + PrintPercent(1, 1); + printf("\n"); + } + /*If MNS is empty, build it based on if there are any source transitions.*/ + result = BuildResult(Dm, Dp, &data, newIndex); + FreeMemory(&mem); + return result; +} + +/******************************************************************************* +This function builds the result structure.*/ +asiph_r BuildResult(matrix *Dm, matrix *Dp, asiph_data* data, int *index) +{ + int i, j, oFlag, iFlag, flag = 0; + int *sourceF; + sourceF = tcalloc(NumberOfColumns(*Dm), sizeof(int)); + + /*Build a set of source transition flags.*/ + + /*If MNS is empty, build a new MNS algo... [truncated message content] |
From: <mio...@us...> - 2011-05-13 22:48:26
|
Revision: 248 http://pntool.svn.sourceforge.net/pntool/?rev=248&view=rev Author: miordache Date: 2011-05-13 22:48:19 +0000 (Fri, 13 May 2011) Log Message: ----------- added some examples Added Paths: ----------- doc/ doc/GettingStarted.htm doc/input2.sp examples/ examples/+README+ examples/reader.sp examples/test.sp examples/test2.sp examples/test2a.sp examples/test2b.sp examples/test2c.sp examples/test2d.sp examples/test2e.sp examples/test2f.sp examples/test2g.sp examples/test3a.sp examples/test3b.sp examples/test3c.sp examples/test3d.sp Added: doc/GettingStarted.htm =================================================================== --- doc/GettingStarted.htm (rev 0) +++ doc/GettingStarted.htm 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,41 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> + <head> + <title></title> + </head> + + <body> + <h1></h1> + +<p><b>A Concurrency Tool Suite--Getting Started</b> + +<p>The software is intended for Unix operating systems. If you use a Windows computer, you may download cygwin from <a href="http://www.cygwin.com">http://www.cygwin.com</a>. The cygwin program runs in Windows and emulates Linux. Thus, you may run the software in Windows by means of cygwin. + +<p>To build the software, type the command "make" in the main directory of the source code. This will execute the commands of the file called "Makefile" and build an executable file called "ct.exe". In spite of its extension, this is not a Windows executable file. It can only be executed within cygwin or in Unix. + +<p>If you run ct.exe you can see a description of its options. + +<p>In order to run the program on a specification file: +<ul> +<li> Copy the files SupervisorTemplate.c ProcessTemplate.c and spcommon.h from the newcodegen directory to your working directory. +<li> Run ct.exe on your specification file. For instance, if spec.sp is the specification file, you could type "./ct.exe -d4 spec.sp". The d4 option can be used in order to have ct.exe display messages describing what it is doing. +<li>If the specification file is correct, ct.exe will exit normally and create a number of sources files allowing you to build your program. +<li> You can build your program using "make" and the makefile generated by ct.exe. For instance, to build the program from the source code generated for spec.sp, type "make -f spec.mak". +<li> The previous step will generate an executable file. When you run it, you can force it to terminate with Ctrl-c. This should terminate also all other processes (if any) started by the executable file. +</ul> + +<p>To create your own specification files: +<ul> +<li>See the example directory of the source code. +<li>Check also input2.sp. However, note that the features of input2.sp are not fully implemented in the translator module (which is unfinished at this time) and input2.sp is not a complete description of the low level specification language. Some syntax details (such as semicolon separators and braces) are not described in this version of input2.sp. +</ul> + + + + <hr> +<!-- Created: Fri May 13 17:16:03 CDT 2011 --> +<!-- hhmts start --> +Last modified: Fri May 13 17:43:01 CDT 2011 +<!-- hhmts end --> + </body> +</html> Added: doc/input2.sp =================================================================== --- doc/input2.sp (rev 0) +++ doc/input2.sp 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,342 @@ +// This is a preliminary description of the low level specification language. + +// FOR REFERENCE ONLY. ON ONE HAND, NOT ALL FEATURES HAVE BEEN IMPLEMENTED +// IN THE TRANSLATOR. ON THE OTHER HAND, SOME IMPLEMENTED FEATURES ARE NOT +// DESCRIBED HERE. THIS FILE MAY NOT DESCRIBE THE ENTIRE SYNTAX. SEE THE +// EXAMPLES FOR INFORMATION ON THE SYNTAX. + +// Version 2.1.1 - 04/21/2011 +// The keyword "init" was added for initialization code. +// Version 2.1 - 05/19/2009 +// Compared to version 2, the following keywords were added: +// "nondeterministic", "select", "uncontrollable", and "unobservable". +// The low level (PN level) specification language is illustrated on a +// specification of independent reader and writer processes with shared memory. +// The high level language has not been developed yet. + +// The concurrent programming tool operates as follows. +// +// Given a specification file (say input.sp), the tool generates +// - input.c containing the code of the supervisor; +// - input.mak a makefile; +// - additional c files, one for each process defined below. +// +// After the application is built, the user can start it by +// running the supervisor program (say input.exe). The supervisor program +// will start all other processes and ensure that they operate +// correctly. Terminating the supervisor program will also +// terminate children processes. + + +// The specification file consists of three parts containing +// - process-type declarations +// - definitions +// - process declarations and dependencies +// - instructions on supervisor design + +// 1. PROCESS-TYPE DECLARATIONS + +// Format: +// +// process type // Write here the name of the process type. + // Note that all processes of the same type have the same + // executable file. +// build command: // Write here the line(s) used to build the executable. + // For instance: 'make -f process_name.mak' or + // 'gcc -o process_name process_name.sp.c functions.c ...' + // Note that process_name.sp.c is the c file generated + // by the concurrent programing tool for the process_name + // type. +// include: // Write here what should be included at the beginning of + // process_name.sp.c, such as #include directives. +// extern process type // Declares a process type for which the tool should + // not generate code. Such a process type may describe + // hardware or software functions already implemented. + // If such external processes impose relevant + // constraints, the specification should + // describe them. This may help: + // - simplify some supervisory control methods + // - reveal potential deadlock situations + // A process may not be external unless all transitions + // unique to the process are uncontrollable and + // unobservable. + +process type READER + +build command: make -f reader.mak + +include: { + #include<stdio.h> + #include<string.h> + + int state = 0; /* variables can be declared here as well */ +} + + +init: { + // include here declarations and initialization code +} + +process type WRITER + +build command: make -f writer.mak + +include: #include "writer.h" + + +extern process type ARBITER // Note that no build or include commands follow + // the declaration of an external process type. + + +// 2. DEFINITIONS + +// This version of the specification format describes only a low level PN +// definition of the processes. + +// Format: + +// process_name.PN: +// places: list of place names +// transitions: list of transition names +// place.code: gives the C code associated with a place. The C code +// is not parsed here! Rather the "text" structure associated +// to the PN place is initialized with the position of the C code. +// *place: list of input transitions +// place*: list of the output transition of place +// ([place], transition, [place, ...])[.{c code}] where items between +// square brackets are optional. +// Note that the c code is not parsed but its position is copied to a "text" +// structure associated with the arc. + + + +ARBITER.PN: + +places: p1 p2 // place names do not have to start with a 'p' + +transitions: t1 t2 // transition names do not have to start with a 't' + +// Note the absence of place.code lines for an external process. + +*p1: t1 +p1*: t2 +*p2: t2 +p2*: t1 + + +// The format *place: input transition(s), place*: output transition(s) +// is ideal for representing a PN structure and this is what we need for an +// external process. However, the format it is ambiguous for the processes for +// which code should be generated. For instance, assume a transition t such +// that *t: p1 p2 and t*: p3 p4. Recall that each process of type X is a +// token in the underlying PN. Thus, assuming two processes, one in the stage +// p1 and one in the stage p2, it is not clear what action should be taken +// when t is fired. The following format will be used to describe the outcome +// of firing t. +// 1. The process in p1 goes to p3 and the one in p2 to p4 +// (p1, t, p3) (p2, t, p4) +// 2. The process in p1 goes to p3 and forks one child process in p4. The +// process in p2 terminates. +// (p1, t, p3, p4) (p2, t) +// 3. Both processes in p1 and p2 terminate and two new processes are created +// in p3 and p4. +// (p1, t) (p2, t) (t, p3) (t, p4) +// 4. ... +// ... + +READER.PN: + +places: p1 p1b p2 p3 + +transitions: t1 t2 t3 t4 ti t_end + +p1.code: initialize_r(); + +p1b.code: initialize_r_b(); + +p2.code: { + str = read_data(); +} + +p3.code: process_data(str); + +// The following lines describe the structure of the PN + +(p1b, ti, p1) +(p1, t1, p2).{i != 0} // the transition will be taken only if the condition + // between braces is TRUE. +// The expression between braces should only be copied; it does not have to +// be parsed. + +(p2, t2, p3) +(p3, t3, p1) +(p1, t_end).{exit_v == TRUE} +(p1, t4, p3) + +// Note that a process in p1 has three choices. +// if(i != 0) then fire t1 +// else if(exit_v == TRUE) then fire t_end +// else fire t4 + +// Instead of using the conditions above to determine which transitions to +// fire, a function to select them could be specified. + +select function p1.{select_t} // select_t is the name of the function + +// Thus, when there is a token in p1, the function select_f is invoked to +// to determine which transition should be fired. + +nondeterministic places: p1 + +// By default a place p is deterministic. For a deterministic place, one of the +// enabled output transition is selected and then the process waits until the +// supervisor permits its firing. However, if the place p is nondeterministic, +// a protocol such as the one below is used. +// +// 1. The select function is invoked to produce the list of enabled transitions +// in the order of firing preference (first in list is the transition the +// process is most interested to fire). +// 1.b. Optionally, the supervisor is inquired about the transitions it +// enables. However, note that the set of transitions enabled by the +// supervisor can change before the process asks the supervisor for +// permission to fire. +// 2. The list of transitions is sent to the supervisor. Then, the process +// sleeps until the supervisor replies. +// 4. The supervisor gives permission to fire one of the transitions on the +// list. +// +// The main difference between a deterministic and a nondetermistic place is +// as follows. For a deterministic place a transition is selected and then the +// process sleeps until it can continue by firing that transition. For a +// nondeterministic place the choice of the next transition depends on the +// transitions enabled by the supervisor. + + + +WRITER.PN: + +places: p pwr_1 pwr2 + +transitions: t1 t2 t3 t4 + +p.code: process_wrdata(); + +pwr_1.code: write_dest1(); + +pwr_2.code: write_dest2(); + +(p, t1, pwr_1).{dest == 1} +(p, t2, pwr_2) +(pwr_1, t3, p) +(pwr_2, t4, p) + + + +// 3. PROCESS DECLARATIONS + +READER r_group(p1:2, p3:1) // This declares a group of 2+1= 3 READER + // processes. Two processes begin in the state + // p1 and one in the state p3. + // The name of this group of processes is 'r_group'. + // They will be implemented by the READER.PN with + // initial marking m(p1) = 2 and m(p3) = 1. + +READER reader1(p1b) // This declares a single READER process that begins in + // the state p1b. The name of the process is reader1. + +WRITER writer1(p) + +WRITER w_group(p:2) + +ARBITER arbiter(p1) + + +// DEPENDENCIES (transitions that processes synchronize on their own) + +sync reader1.t1 arbiter.t1 + // mentions that the two transitions are synchronized + // (they take place simultaneously). + +sync writer1.t2 arbiter.t2 + +// Remark: all transitions of the external processes are considered to be +// uncontrollable and unobservable, excepting the transitions synchronized +// with transitions of internal processes. Such transitions have the type +// specified by the internal process. + + +// 4. INSTRUCTIONS ON THE DESIGN OF THE SUPERVISOR + +// These describe what the objectives of the supervisor. +// - 'start' commands describe what processes the supervisor should start +// - 'constraints' commands describe what constraints should be enforced +// Constraints have the form +// weighted sum <= free term +// Since we deal with integers, <, >, and >= are all equivalent to this +// form. For instance, a < b is the same as a <= b - 1. +// Disjunctive constraints are also allowed +// (weighted sum <= free term) || (weighted sum 2 <= free term 2) +// The keyword 'live' is used to introduce a list of transitions that +// should always be eventually firable. +// Similarly, the keywords "uncontrollable" and "unobservable" introduce +// lists of transitions that the supervisor should not attempt to control +// and observe, respectively. + +start r_group w_group reader1 writer1 // Unimplemented as of May 2011. + + +// CONSTRAINTS + +r_group.constraints: // these are constraints on the PN of r_group + +live: t2 t4 // requests that the transitions t2 and t4 of r_group be live + // (i.e. they never deadlock). + +uncontrollable: t1 t_end t4 + +unobservable: t1 t_end t4 + + +w_group.constraints: // these are constraints on the PN of w_group + +// Here are some constraints that two writers may not be at the same time +// in the same critical section. + +pwr_1 <= 1 // requests that the marking of pwr_1 does not exceed 1 +pwr_2 <= 1 // requests that the marking of pwr_2 does not exceed 1 + +live: all // requests all transitions of w_group to be live. + + +// NOTE: Some constraint features are not implemented as of May 2011. + +global.constraints: // these are constraints on all PNs + +(r_group.p2 <= 0) || (w_group.pwr_1 <= 0) + +// The line above requests that at all times either the place p2 of r_group +// has no tokens or the place pwr_1 of w_group has no tokens. That is, any +// number of readers may be at the same time in the critical section, but +// a reader and a writer may not be there at the same time. + +q.reader1.t1 - writer1.p <= 0 //'q.' denotes the firing vector. The constraint + // requires that t1 of reader1 may be fired only + // if there is one token in the place p of + // writer1. + +2*reader1.t1 - 2*reader1.t2 + w_group.pwr_2 <= 2 +// reader1.t1 denotes the number of firings of t1. This constraint is +// another way of requesting 2*reader1.p2 + w_group.pwr_2 <= 2 + + + +// More general constraints, such as requiring a certain language to be +// generated, will be implemented when the need will arise. + + + +// 5. OTHER COMMANDS + +print supervisor to debug.log // 'print supervisor to file_name' requests the + // PN produced by the supervisory control + // algorithms to be written to file_name. Added: examples/+README+ =================================================================== --- examples/+README+ (rev 0) +++ examples/+README+ 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,36 @@ + +Here is the list of test examples: + +test2.sp: When running this example a single process (not thread) is started. The process prints messages indicating its state until it terminates. + +Variants: + +test2a.sp: a single processes (not thread) is started. + +test2b.sp: several identical processes (not threads) are started. + +test2c.sp: only one thread (not forked process) will run this time. + +test2d.sp: multiple threads (not forked processes) will run this time. + +test2e.sp: synchronization by means of transitions between single threads. + +test2f.sp: synchronization by means of transitions between multiple threads. + +test2g.sp: same as test2f.sp except for using forked processes (not threads). + + + +test3: A dining philosopher example. + +test3a.sp: Tests that the deadlock prevention function works fine when no deadlock is possible. Only one philosopher with two resources. + +test3b.sp: A test involving two philosophers. + +test3c.sp: A test involving 5 philosophers. + +test3d.sp: A test involving 5 philosophers. Here, the resources (chopsticks) are defined as supervisor components, not as threads. + + + +reader.sp: A reader, inserter, deleter problem. Added: examples/reader.sp =================================================================== --- examples/reader.sp (rev 0) +++ examples/reader.sp 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,124 @@ +// This is a reader/writer/inserter example + +process READER; +build: {<thread>}; + +process DELETER; +build: {<thread>}; + +process INSERTER; +build: {<thread>}; + +READER.PN: + +places: pv pc pd; + +transitions: tv tc td; + +// The main function for a thread/process defines a void* type pointer p___ initialized to zero. +// This is useful when several copies of a thread run in parallel, so that each thread copy +// has a known variable to allocate so that it can save its own data. Further, an initialization +// function can be called if p___ = 0. + +pv.code: { +//evaluate_data(&p___); + debugInfo("READER: Entering the evaluation block"); + sleep(1); +}; + +pc.code: { +//read_data(&p___); + debugInfo("READER: Entering the read block"); + sleep(1); + debugInfo("READER: Exiting the read block"); +}; + +pd.code: { +//process_data(&p___); + debugInfo("READER: Entering the processing block"); + sleep(1); +}; + +(pv, tv, pc); +(pc, tc, pd); +(pd, td, pv); + + +DELETER.PN: + +places: pv pc pd; + +transitions: tv tc td; + +pv.code: { +//d_evaluate_data(&p___); + debugInfo("DELETER: Entering the evaluation block"); + sleep(1); + +}; + +pc.code: { +//delete_data(&p___); + debugInfo("DELETER: Entering the read block"); + sleep(1); + debugInfo("DELETER: Exiting the read block"); + +}; + +pd.code: { +//d_process_data(&p___); + debugInfo("DELETER: Entering the processing block"); + sleep(1); + +}; + +(pv, tv, pc); +(pc, tc, pd); +(pd, td, pv); + + +INSERTER.PN: + +places: pv pc pd; + +transitions: tv tc td; + +pv.code: { +//i_evaluate_data(&p___); + debugInfo("INSERTER: Entering the evaluation block"); + sleep(1); +}; + +pc.code: { +//insert_data(&p___); + debugInfo("INSERTER: Entering the read block"); + sleep(1); + debugInfo("INSERTER: Exiting the read block"); +}; + +pd.code: { +//i_process_data(&p___); + debugInfo("INSERTER: Entering the processing block"); + sleep(1); +}; + +(pv, tv, pc); +(pc, tc, pd); +(pd, td, pv); + + +READER read(pv:5); // defines five reader processes starting in state pv +INSERTER insert(pv:3); +DELETER delete(pv:3); + + +global.constraints: + +insert.pc <= 1; + +// delete.pc <= 1; // not necessary: see constraint below + +// The following should be read.pc + insert.pc + 6*delete.pc <= 6 +// However, the translator has a bug preventing it from recognizing multipliers + +read.pc + insert.pc + delete.pc + delete.pc + delete.pc + delete.pc + delete.pc + delete.pc<= 6; // 6 is max(reader.pc + inserter.pc) Added: examples/test.sp =================================================================== --- examples/test.sp (rev 0) +++ examples/test.sp 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,19 @@ +// This is a test file created in order to check the functionality of the +// pn translator. + +process TST; + +TST.PN: + +places: p0 p1 p2; + +transitions: t0 t1 t2; + +(p0, t0); +(t2, p0); +(p1, t1, p2, p0); +(p1, t1, p2, p0); +(p2, t2, p1).{i == 3}; + +TST testpn(p0:2,p1:1); + Added: examples/test2.sp =================================================================== --- examples/test2.sp (rev 0) +++ examples/test2.sp 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,126 @@ +// This is a test file intended to check the code generation module +// The example of this file was adapted from compexample.c + +process TYPE1; + +build: {gcc -g -o $$$.exe $$$.c}; + +include: { + #include<stdio.h> + int pr1_state = 0, i, j, u = 0; + + void delay(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } + + int f1(int z) { + struct ___trans ___TR[1]; + if(u > 5) { + ___TR[0].no_output = 1; + ___TR[0].label = -4; + ___TR[0].trans = 3; + } + else { + ___TR[0].no_output = 0; + ___TR[0].label = -2; + ___TR[0].trans = 1; + ___TR[0].place = 2; + } + return 1; + } +}; + + +process PN3; + +build: {<thread>}; + +include: { + #include<stdio.h> + int pr1_state = 0, i, j, u = 0; + + void delay(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } +}; + + +TYPE1.PN: + +places: p0 p1 p2; + +transitions: t0 t1 t2 t3 t4; + +p0.code: { + u++; + fprintf(stderr, "\nPN: State 0 u = %d", u); + delay(1); +}; + +p1.code: { + fprintf(stderr, "\nPN: State 1"); + delay(1); +}; + +p2.code: { + fprintf(stderr, "\nPN: State 2"); + delay(1); +}; + + + // Let's create the following PN: + // + // t2 + // -------|<---- + // | p0 p1 |p2 + // ->O->|->O->|->O<-- + // | t0 | t1 | + // | | | + // | V | + // | --- t3 | + // | | + // ------>|------- + // t4 + +(p0, t4, p2); +(p1, t3); +(p2, t2, p0); +(p1, t1, p2); +(p0, t0, p1); + +PN3.PN: + +places: p0 p1; + +transitions: t0 t1 t2; + +p0.code: { + u++; + printf("\nPN3: State 0 u = %d", u); + delay(2); +}; + +p1.code: { + printf("\nPN3: State 1"); + delay(2); +}; + + // Let's create this PN: + // + // p0 p1 + // |->O->|->O->| + // t2 t0 t1 + // + +(t2, p0); +(p0, t0, p1); +(p1, t1); + + + +TYPE1 pr1(p0:1); + +PN3 pr2; + Added: examples/test2a.sp =================================================================== --- examples/test2a.sp (rev 0) +++ examples/test2a.sp 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,126 @@ +// This is a test file intended to check the code generation module +// The example of this file was adapted from compexample.c + +process TYPE1; + +build: {gcc -g -o $$$.exe $$$.c}; + +include: { + #include<stdio.h> + int pr1_state = 0, i, j, u = 0; + + void delay(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } + + int f1(int z) { + struct ___trans ___TR[1]; + if(u > 5) { + ___TR[0].no_output = 1; + ___TR[0].label = -4; + ___TR[0].trans = 3; + } + else { + ___TR[0].no_output = 0; + ___TR[0].label = -2; + ___TR[0].trans = 1; + ___TR[0].place = 2; + } + return 1; + } +}; + + +process PN3; + +build: {<thread>}; + +include: { + #include<stdio.h> + int pr1_state = 0, i, j, u = 0; + + void delay(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } +}; + + +TYPE1.PN: + +places: p0 p1 p2; + +transitions: t0 t1 t2 t3 t4; + +p0.code: { + u++; + fprintf(stderr, "\nPN: State 0 u = %d", u); + delay(1); +}; + +p1.code: { + fprintf(stderr, "\nPN: State 1"); + delay(1); +}; + +p2.code: { + fprintf(stderr, "\nPN: State 2"); + delay(1); +}; + + + // Let's create the following PN: + // + // t2 + // -------|<---- + // | p0 p1 |p2 + // ->O->|->O->|->O<-- + // | t0 | t1 | + // | | | + // | V | + // | --- t3 | + // | | + // ------>|------- + // t4 + +(p0, t4, p2); +(p1, t3); +(p2, t2, p0); +(p1, t1, p2); +(p0, t0, p1); + +PN3.PN: + +places: p0 p1; + +transitions: t0 t1 t2; + +p0.code: { + u++; + printf("\nPN3: State 0 u = %d", u); + delay(2); +}; + +p1.code: { + printf("\nPN3: State 1"); + delay(2); +}; + + // Let's create this PN: + // + // p0 p1 + // |->O->|->O->| + // t2 t0 t1 + // + +(t2, p0); +(p0, t0, p1); +(p1, t1); + + + +TYPE1 pr1(p0:1); + +PN3 pr2; + Added: examples/test2b.sp =================================================================== --- examples/test2b.sp (rev 0) +++ examples/test2b.sp 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,126 @@ +// This is a test file intended to check the code generation module +// The example of this file was adapted from compexample.c + +process TYPE1; + +build: {gcc -g -o $$$.exe $$$.c}; + +include: { + #include<stdio.h> + int pr1_state = 0, i, j, u = 0; + + void delay(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } + + int f1(int z) { + struct ___trans ___TR[1]; + if(u > 5) { + ___TR[0].no_output = 1; + ___TR[0].label = -4; + ___TR[0].trans = 3; + } + else { + ___TR[0].no_output = 0; + ___TR[0].label = -2; + ___TR[0].trans = 1; + ___TR[0].place = 2; + } + return 1; + } +}; + + +process PN3; + +build: {<thread>}; + +include: { + #include<stdio.h> + int pr1_state = 0, i, j, u = 0; + + void delay(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } +}; + + +TYPE1.PN: + +places: p0 p1 p2; + +transitions: t0 t1 t2 t3 t4; + +p0.code: { + u++; + fprintf(stderr, "\nPN: State 0 u = %d", u); + delay(1); +}; + +p1.code: { + fprintf(stderr, "\nPN: State 1"); + delay(1); +}; + +p2.code: { + fprintf(stderr, "\nPN: State 2"); + delay(1); +}; + + + // Let's create the following PN: + // + // t2 + // -------|<---- + // | p0 p1 |p2 + // ->O->|->O->|->O<-- + // | t0 | t1 | + // | | | + // | V | + // | --- t3 | + // | | + // ------>|------- + // t4 + +(p0, t4, p2); +(p1, t3); +(p2, t2, p0); +(p1, t1, p2); +(p0, t0, p1); + +PN3.PN: + +places: p0 p1; + +transitions: t0 t1 t2; + +p0.code: { + u++; + printf("\nPN3: State 0 u = %d", u); + delay(2); +}; + +p1.code: { + printf("\nPN3: State 1"); + delay(2); +}; + + // Let's create this PN: + // + // p0 p1 + // |->O->|->O->| + // t2 t0 t1 + // + +(t2, p0); +(p0, t0, p1); +(p1, t1); + + + +TYPE1 pr1(p0:3,p1:0,p2:0); + +PN3 pr2; + Added: examples/test2c.sp =================================================================== --- examples/test2c.sp (rev 0) +++ examples/test2c.sp 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,126 @@ +// This is a test file intended to check the code generation module +// The example of this file was adapted from compexample.c + +process TYPE1; + +build: {<thread>}; + +include: { + #include<stdio.h> + int pr1_state = 0, i, j, u = 0; + + void delay(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } + + int f1(int z) { + struct ___trans ___TR[1]; + if(u > 5) { + ___TR[0].no_output = 1; + ___TR[0].label = -4; + ___TR[0].trans = 3; + } + else { + ___TR[0].no_output = 0; + ___TR[0].label = -2; + ___TR[0].trans = 1; + ___TR[0].place = 2; + } + return 1; + } +}; + + +process PN3; + +build: {<thread>}; + +include: { + #include<stdio.h> + int v = 0; + + void delay2(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } +}; + + +TYPE1.PN: + +places: p0 p1 p2; + +transitions: t0 t1 t2 t3 t4; + +p0.code: { + u++; + fprintf(stderr, "\nPN: State 0 u = %d", u); + delay(1); +}; + +p1.code: { + fprintf(stderr, "\nPN: State 1"); + delay(1); +}; + +p2.code: { + fprintf(stderr, "\nPN: State 2"); + delay(1); +}; + + + // Let's create the following PN: + // + // t2 + // -------|<---- + // | p0 p1 |p2 + // ->O->|->O->|->O<-- + // | t0 | t1 | + // | | | + // | V | + // | --- t3 | + // | | + // ------>|------- + // t4 + +(p0, t4, p2); +(p1, t3); +(p2, t2, p0); +(p1, t1, p2); +(p0, t0, p1); + +PN3.PN: + +places: p0 p1; + +transitions: t0 t1 t2; + +p0.code: { + v--; + printf("\nPN3: State 0 v = %d", v); + delay2(2); +}; + +p1.code: { + printf("\nPN3: State 1"); + delay2(2); +}; + + // Let's create this PN: + // + // p0 p1 + // |->O->|->O->| + // t2 t0 t1 + // + +(t2, p0); +(p0, t0, p1); +(p1, t1); + + + +TYPE1 pr1(p0:1); + +PN3 pr2; + Added: examples/test2d.sp =================================================================== --- examples/test2d.sp (rev 0) +++ examples/test2d.sp 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,126 @@ +// This is a test file intended to check the code generation module +// The example of this file was adapted from compexample.c + +process TYPE1; + +build: {<thread>}; + +include: { + #include<stdio.h> + int pr1_state = 0, i, j, u = 0; + + void delay(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } + + int f1(int z) { + struct ___trans ___TR[1]; + if(u > 5) { + ___TR[0].no_output = 1; + ___TR[0].label = -4; + ___TR[0].trans = 3; + } + else { + ___TR[0].no_output = 0; + ___TR[0].label = -2; + ___TR[0].trans = 1; + ___TR[0].place = 2; + } + return 1; + } +}; + + +process PN3; + +build: {<thread>}; + +include: { + #include<stdio.h> + int v = 0; + + void delay2(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } +}; + + +TYPE1.PN: + +places: p0 p1 p2; + +transitions: t0 t1 t2 t3 t4; + +p0.code: { + u++; + fprintf(stderr, "\nPN: State 0 u = %d", u); + delay(1); +}; + +p1.code: { + fprintf(stderr, "\nPN: State 1"); + delay(1); +}; + +p2.code: { + fprintf(stderr, "\nPN: State 2"); + delay(1); +}; + + + // Let's create the following PN: + // + // t2 + // -------|<---- + // | p0 p1 |p2 + // ->O->|->O->|->O<-- + // | t0 | t1 | + // | | | + // | V | + // | --- t3 | + // | | + // ------>|------- + // t4 + +(p0, t4, p2); +(p1, t3); +(p2, t2, p0); +(p1, t1, p2); +(p0, t0, p1); + +PN3.PN: + +places: p0 p1; + +transitions: t0 t1 t2; + +p0.code: { + v--; + printf("\nPN3: State 0 v = %d", v); + delay2(2); +}; + +p1.code: { + printf("\nPN3: State 1"); + delay2(2); +}; + + // Let's create this PN: + // + // p0 p1 + // |->O->|->O->| + // t2 t0 t1 + // + +(t2, p0); +(p0, t0, p1); +(p1, t1); + + + +TYPE1 pr1(p0:4); + +PN3 pr2; + Added: examples/test2e.sp =================================================================== --- examples/test2e.sp (rev 0) +++ examples/test2e.sp 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,134 @@ +// This is a test file intended to check the code generation module +// The example of this file was adapted from compexample.c + +process TYPE1; + +build: {<thread>}; + +include: { + #include<stdio.h> + int pr1_state = 0, i, j, u = 0; + + void delay(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } + + int f1(int z) { + struct ___trans ___TR[1]; + if(u > 5) { + ___TR[0].no_output = 1; + ___TR[0].label = -4; + ___TR[0].trans = 3; + } + else { + ___TR[0].no_output = 0; + ___TR[0].label = -2; + ___TR[0].trans = 1; + ___TR[0].place = 2; + } + return 1; + } +}; + + +process PN3; + +build: {<thread>}; + +include: { + #include<stdio.h> + int v = 0; + + void delay2(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } +}; + + +TYPE1.PN: + +places: p0 p1 p2; + +transitions: t0 t1 t2 t3 t4; + +p0.code: { + u++; + fprintf(stderr, "\nPN: State 0 u = %d", u); + fflush(0); + delay(1); +}; + +p1.code: { + fprintf(stderr, "\nPN: State 1"); + fflush(0); + delay(1); +}; + +p2.code: { + fprintf(stderr, "\nPN: State 2"); + fflush(0); + delay(1); +}; + + + // Let's create the following PN: + // + // t2 + // -------|<---- + // | p0 p1 |p2 + // ->O->|->O->|->O<-- + // | t0 | t1 | + // | | | + // | V | + // | --- t3 | + // | | + // ------>|------- + // t4 + +(p0, t4, p2); +(p1, t3); +(p2, t2, p0); +(p1, t1, p2); +(p0, t0, p1); + +PN3.PN: + +places: p0 p1; + +transitions: t0 t1 t2; + +p0.code: { + v--; + printf("\nPN3: State 0 v = %d", v); + fflush(0); + delay2(2); +}; + +p1.code: { + printf("\nPN3: State 1"); + fflush(0); + delay2(2); +}; + + // Let's create this PN: + // + // p0 p1 + // |->O->|->O->| + // t2 t0 t1 + // + +(t2, p0); +(p0, t0, p1); +(p1, t1); + + + +TYPE1 pr1(p0:1); + +PN3 pr2; + +sync pr1.t1 pr2.t2; +sync pr1.t4 pr2.t2; +sync pr1.t2 pr2.t1; Added: examples/test2f.sp =================================================================== --- examples/test2f.sp (rev 0) +++ examples/test2f.sp 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,134 @@ +// This is a test file intended to check the code generation module +// The example of this file was adapted from compexample.c + +process TYPE1; + +build: {<thread>}; + +include: { + #include<stdio.h> + int pr1_state = 0, i, j, u = 0; + + void delay(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } + + int f1(int z) { + struct ___trans ___TR[1]; + if(u > 5) { + ___TR[0].no_output = 1; + ___TR[0].label = -4; + ___TR[0].trans = 3; + } + else { + ___TR[0].no_output = 0; + ___TR[0].label = -2; + ___TR[0].trans = 1; + ___TR[0].place = 2; + } + return 1; + } +}; + + +process PN3; + +build: {<thread>}; + +include: { + #include<stdio.h> + int v = 0; + + void delay2(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } +}; + + +TYPE1.PN: + +places: p0 p1 p2; + +transitions: t0 t1 t2 t3 t4; + +p0.code: { + u++; + fprintf(stderr, "\nPN: State 0 u = %d", u); + fflush(0); + delay(1); +}; + +p1.code: { + fprintf(stderr, "\nPN: State 1"); + fflush(0); + delay(1); +}; + +p2.code: { + fprintf(stderr, "\nPN: State 2"); + fflush(0); + delay(1); +}; + + + // Let's create the following PN: + // + // t2 + // -------|<---- + // | p0 p1 |p2 + // ->O->|->O->|->O<-- + // | t0 | t1 | + // | | | + // | V | + // | --- t3 | + // | | + // ------>|------- + // t4 + +(p0, t4, p2); +(p1, t3); +(p2, t2, p0); +(p1, t1, p2); +(p0, t0, p1); + +PN3.PN: + +places: p0 p1; + +transitions: t0 t1 t2; + +p0.code: { + v--; + printf("\nPN3: State 0 v = %d", v); + fflush(0); + delay2(2); +}; + +p1.code: { + printf("\nPN3: State 1"); + fflush(0); + delay2(2); +}; + + // Let's create this PN: + // + // p0 p1 + // |->O->|->O->| + // t2 t0 t1 + // + +(t2, p0); +(p0, t0, p1); +(p1, t1); + + + +TYPE1 pr1(p0:4); + +PN3 pr2; + +sync pr1.t1 pr2.t2; +sync pr1.t4 pr2.t2; +sync pr1.t2 pr2.t1; Added: examples/test2g.sp =================================================================== --- examples/test2g.sp (rev 0) +++ examples/test2g.sp 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,134 @@ +// This is a test file intended to check the code generation module +// The example of this file was adapted from compexample.c + +process TYPE1; + +build: {gcc -g -o $$$.exe $$$.c}; + +include: { + #include<stdio.h> + int pr1_state = 0, i, j, u = 0; + + void delay(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } + + int f1(int z) { + struct ___trans ___TR[1]; + if(u > 5) { + ___TR[0].no_output = 1; + ___TR[0].label = -4; + ___TR[0].trans = 3; + } + else { + ___TR[0].no_output = 0; + ___TR[0].label = -2; + ___TR[0].trans = 1; + ___TR[0].place = 2; + } + return 1; + } +}; + + +process PN3; + +build: {gcc -g -o $$$.exe $$$.c}; + +include: { + #include<stdio.h> + int v = 0; + + void delay2(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } +}; + + +TYPE1.PN: + +places: p0 p1 p2; + +transitions: t0 t1 t2 t3 t4; + +p0.code: { + u++; + fprintf(stderr, "\nPN (%d): State 0 u = %d", (int) getpid(), u); + //fflush(0); + delay(1); +}; + +p1.code: { + fprintf(stderr, "\nPN (%d): State 1", (int) getpid()); + //fflush(0); + delay(1); +}; + +p2.code: { + fprintf(stderr, "\nPN (%d): State 2", (int) getpid()); + //fflush(0); + delay(1); +}; + + + // Let's create the following PN: + // + // t2 + // -------|<---- + // | p0 p1 |p2 + // ->O->|->O->|->O<-- + // | t0 | t1 | + // | | | + // | V | + // | --- t3 | + // | | + // ------>|------- + // t4 + +(p0, t4, p2); +(p1, t3); +(p2, t2, p0); +(p1, t1, p2); +(p0, t0, p1); + +PN3.PN: + +places: p0 p1; + +transitions: t0 t1 t2; + +p0.code: { + v--; + printf("\nPN3: State 0 v = %d", v); + //fflush(0); + delay2(2); +}; + +p1.code: { + printf("\nPN3: State 1"); + //fflush(0); + delay2(2); +}; + + // Let's create this PN: + // + // p0 p1 + // |->O->|->O->| + // t2 t0 t1 + // + +(t2, p0); +(p0, t0, p1); +(p1, t1); + + + +TYPE1 pr1(p0:4); + +PN3 pr2; + +sync pr1.t1 pr2.t2; +sync pr1.t4 pr2.t2; +sync pr1.t2 pr2.t1; Added: examples/test3a.sp =================================================================== --- examples/test3a.sp (rev 0) +++ examples/test3a.sp 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,105 @@ +// This is a test file intended to check the code generation module + +process PHIL; + +build: {<thread>}; + +include: { + #include<stdio.h> + int pr1_state = 0, i, j, u = 0; + + void delay(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } +}; + + + +process RESOURCE; + +build: {<thread>}; + +include: { + #include<stdio.h> + static int v = 0; + + static void delay2(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } +}; + + +PHIL.PN: + +places: p0 p1 p2 p3; // think, request right fork, request left fork, eat + +transitions: t0 t1 t2 t3 t4; + +p0.code: { + u++; + fprintf(stderr, "\nPhil. State 0 (think) u = %d", u); + fflush(0); + delay(1); +}; + +p1.code: { + fprintf(stderr, "\nPN: State 1 (requesting right fork)"); + fflush(0); + delay(1); +}; + +p2.code: { + fprintf(stderr, "\nPN: State 2 (requesting left fork)"); + fflush(0); + delay(1); +}; + +p3.code: { + fprintf(stderr, "\nPN: State 3 (eat)"); + fflush(0); + delay(1); +}; + +(p0, t0, p1); (p1, t1, p2); (p2, t2, p3); (p3, t3, p0); + +// t3 +// ------------|<--------------- +// | | +// ->O-->|-->O-->|-->O-->|-->O-- +// p0 t0 p1 t1 p2 t2 p3 + + +RESOURCE.PN: + +places: p; + +transitions: t0 t2; + +// --->| t2 +// p | +// t0 |--->O +// + + +(p, t2); (t0, p); + +p.code: { + fprintf(stderr, "\nResource %s is available", ___NAME); + fflush(0); +}; + +RESOURCE left(p:1); +RESOURCE right(p:1); + +PHIL ph1(p0:1); + +sync ph1.t1 left.t2; +sync ph1.t2 right.t2; +sync ph1.t3 left.t0; +sync ph1.t3 right.t0; + +ph1.constraints: + +live: t1; Added: examples/test3b.sp =================================================================== --- examples/test3b.sp (rev 0) +++ examples/test3b.sp 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,113 @@ +// This is a test file intended to check the code generation module + +process PHIL; + +build: {<thread>}; + +include: { + #include<stdio.h> + static int pr1_state = 0, i, j, u = 0; + + static void delay(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } +}; + + + +process RESOURCE; + +build: {<thread>}; + +include: { + #include<stdio.h> + static int v = 0; + + static void delay2(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } +}; + + +PHIL.PN: + +places: p0 p1 p2 p3; // think, request right fork, request left fork, eat + +transitions: t0 t1 t2 t3 t4; + +p0.code: { + u++; + fprintf(stderr, "\nPhil. State 0 (think) u = %d", u); + fflush(0); + delay(1); +}; + +p1.code: { + fprintf(stderr, "\nPN: State 1 (requesting right fork)"); + fflush(0); + delay(1); +}; + +p2.code: { + fprintf(stderr, "\nPN: State 2 (requesting left fork)"); + fflush(0); + delay(1); +}; + +p3.code: { + fprintf(stderr, "\nPN: State 3 (eat)"); + fflush(0); + delay(1); +}; + +(p0, t0, p1); (p1, t1, p2); (p2, t2, p3); (p3, t3, p0); + +// t3 +// ------------|<--------------- +// | | +// ->O-->|-->O-->|-->O-->|-->O-- +// p0 t0 p1 t1 p2 t2 p3 + + +RESOURCE.PN: + +places: p; + +transitions: t0 t1 t2 t3; + +// --->| t2 +// p | +// t0 |--->O<---| t1 +// | +// --->| t3 + + +(p, t2); (p, t3); (t0, p); (t1, p); + +p.code: { + fprintf(stderr, "\nResource %s is available", ___NAME); + fflush(0); +}; + +RESOURCE left(p:1); +RESOURCE right(p:1); + +PHIL ph1(p0:1); +PHIL ph2(p0:1); + +sync ph1.t1 left.t2; +sync ph2.t1 right.t2; +sync ph1.t2 right.t3; +sync ph2.t2 left.t3; +sync ph1.t3 left.t0; +sync ph1.t3 right.t0; +sync ph2.t3 left.t1; +sync ph2.t3 right.t1; + +ph1.constraints: +live: t1; + +ph2.constraints: +live: t1; \ No newline at end of file Added: examples/test3c.sp =================================================================== --- examples/test3c.sp (rev 0) +++ examples/test3c.sp 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,113 @@ +// This is a test file intended to check the code generation module + +process PHIL; + +build: {<thread>}; + +include: { + #include<stdio.h> + static int pr1_state = 0, i, j, u = 0; + + static void delay(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } +}; + + + +process RESOURCE; + +build: {<thread>}; + +include: { + #include<stdio.h> + static int v = 0; + + static void delay2(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } +}; + + +PHIL.PN: + +places: p0 p1 p2 p3; // think, request right fork, request left fork, eat + +transitions: t0 t1 t2 t3 t4; + +p0.code: { + u++; + fprintf(stderr, "\n%s (%s): State 0 (think) u = %d",___INSTANCE,___NAME, u); + fflush(0); + delay(1); +}; + +p1.code: { + fprintf(stderr, "\n%s (%s): State 1 (requesting right fork)",___INSTANCE,___NAME); + fflush(0); + delay(1); +}; + +p2.code: { + fprintf(stderr, "\n%s (%s): State 2 (requesting left fork)",___INSTANCE,___NAME); + fflush(0); + delay(1); +}; + +p3.code: { + fprintf(stderr, "\n%s (%s): State 3 (eat)",___INSTANCE,___NAME); + fflush(0); + delay(1); +}; + +(p0, t0, p1); (p1, t1, p2); (p2, t2, p3); (p3, t3, p0); + +// t3 +// ------------|<--------------- +// | | +// ->O-->|-->O-->|-->O-->|-->O-- +// p0 t0 p1 t1 p2 t2 p3 + + +RESOURCE.PN: + +places: p; + +transitions: t0 t1 t2 t3; + +// --->| t2 +// p | +// t0 |--->O<---| t1 +// | +// --->| t3 + + +(p, t2); (p, t3); (t0, p); (t1, p); + +p.code: { + fprintf(stderr, "\nResource %s is available", ___NAME); + fflush(0); +}; + +RESOURCE r1(p:1); RESOURCE r2(p:1); RESOURCE r3(p:1); RESOURCE r4(p:1); RESOURCE r5(p:1); + +PHIL ph1(p0:1); PHIL ph2(p0:1); PHIL ph3(p0:1); PHIL ph4(p0:1); PHIL ph5(p0:1); + +sync ph1.t1 r1.t2; sync ph2.t1 r2.t2; sync ph3.t1 r3.t2; sync ph4.t1 r4.t2; sync ph5.t1 r5.t2; + +sync ph1.t2 r5.t3; sync ph2.t2 r1.t3; sync ph3.t2 r2.t3; sync ph4.t2 r3.t3; sync ph5.t2 r4.t3; + +sync ph1.t3 r1.t0 r5.t1; sync ph2.t3 r2.t0 r1.t1; sync ph3.t3 r3.t0 r2.t1; sync ph4.t3 r4.t0 r3.t1; sync ph5.t3 r5.t0 r4.t1; + +ph1.constraints: +live: t1; +ph2.constraints: +live: t1; +ph3.constraints: +live: t1; +ph4.constraints: +live: t1; +ph5.constraints: +live: t1; Added: examples/test3d.sp =================================================================== --- examples/test3d.sp (rev 0) +++ examples/test3d.sp 2011-05-13 22:48:19 UTC (rev 248) @@ -0,0 +1,113 @@ +// This is a test file intended to check the code generation module + +process PHIL; + +build: {<thread>}; + +include: { + #include<stdio.h> + static int pr1_state = 0, i, j, u = 0; + + static void delay(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } +}; + + + +process RESOURCE; + +build: {<supervisor>}; // code is ignored for supervisor components + +include: { + #include<stdio.h> + static int v = 0; + + static void delay2(int n) { + time_t a, b; + for(time(&a), time(&b); a + n > b; time(&b)); + } +}; + + +PHIL.PN: + +places: p0 p1 p2 p3; // think, request right fork, request left fork, eat + +transitions: t0 t1 t2 t3 t4; + +p0.code: { + u++; + fprintf(stderr, "\n%s (%s): State 0 (think) u = %d",___INSTANCE,___NAME, u); + fflush(0); + delay(1); +}; + +p1.code: { + fprintf(stderr, "\n%s (%s): State 1 (requesting right fork)",___INSTANCE,___NAME); + fflush(0); + delay(1); +}; + +p2.code: { + fprintf(stderr, "\n%s (%s): State 2 (requesting left fork)",___INSTANCE,___NAME); + fflush(0); + delay(1); +}; + +p3.code: { + fprintf(stderr, "\n%s (%s): State 3 (eat)",___INSTANCE,___NAME); + fflush(0); + delay(1); +}; + +(p0, t0, p1); (p1, t1, p2); (p2, t2, p3); (p3, t3, p0); + +// t3 +// ------------|<--------------- +// | | +// ->O-->|-->O-->|-->O-->|-->O-- +// p0 t0 p1 t1 p2 t2 p3 + + +RESOURCE.PN: + +places: p; + +transitions: t0 t1 t2 t3; + +// --->| t2 +// p | +// t0 |--->O<---| t1 +// | +// --->| t3 + + +(p, t2); (p, t3); (t0, p); (t1, p); + +p.code: { + fprintf(stderr, "\nResource %s is available", ___NAME); + fflush(0); +}; + +RESOURCE r1(p:1); RESOURCE r2(p:1); RESOURCE r3(p:1); RESOURCE r4(p:1); RESOURCE r5(p:1); + +PHIL ph1(p0:1); PHIL ph2(p0:1); PHIL ph3(p0:1); PHIL ph4(p0:1); PHIL ph5(p0:1); + +sync ph1.t1 r1.t2; sync ph2.t1 r2.t2; sync ph3.t1 r3.t2; sync ph4.t1 r4.t2; sync ph5.t1 r5.t2; + +sync ph1.t2 r5.t3; sync ph2.t2 r1.t3; sync ph3.t2 r2.t3; sync ph4.t2 r3.t3; sync ph5.t2 r4.t3; + +sync ph1.t3 r1.t0 r5.t1; sync ph2.t3 r2.t0 r1.t1; sync ph3.t3 r3.t0 r2.t1; sync ph4.t3 r4.t0 r3.t1; sync ph5.t3 r5.t0 r4.t1; + +ph1.constraints: +live: t1; +ph2.constraints: +live: t1; +ph3.constraints: +live: t1; +ph4.constraints: +live: t1; +ph5.constraints: +live: t1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mio...@us...> - 2011-05-17 13:45:21
|
Revision: 249 http://pntool.svn.sourceforge.net/pntool/?rev=249&view=rev Author: miordache Date: 2011-05-17 13:45:15 +0000 (Tue, 17 May 2011) Log Message: ----------- corrections Modified Paths: -------------- examples/test.sp newcodegen/plantCompiler.c newcodegen/supervisorCompiler.c pnheaders/pns.c translator/main.c Modified: examples/test.sp =================================================================== --- examples/test.sp 2011-05-13 22:48:19 UTC (rev 248) +++ examples/test.sp 2011-05-17 13:45:15 UTC (rev 249) @@ -1,8 +1,12 @@ // This is a test file created in order to check the functionality of the -// pn translator. +// pn translator. -process TST; +process TST +include: { + int i; +}; + TST.PN: places: p0 p1 p2; @@ -11,8 +15,8 @@ (p0, t0); (t2, p0); -(p1, t1, p2, p0); -(p1, t1, p2, p0); +(p1, t1, p2, p0); // this is not a state machine; +(p1, t1, p2, p0); // the code generator assumes state machines. (p2, t2, p1).{i == 3}; TST testpn(p0:2,p1:1); Modified: newcodegen/plantCompiler.c =================================================================== --- newcodegen/plantCompiler.c 2011-05-13 22:48:19 UTC (rev 248) +++ newcodegen/plantCompiler.c 2011-05-17 13:45:15 UTC (rev 249) @@ -95,7 +95,8 @@ for(i = 0; i < pn->pnum; i++) { ins = FSInsert(ins, "\ncase %d:\n", i); - ins = SInsert(pn->segment[i], ins); + if(pn->segment) + ins = SInsert(pn->segment[i], ins); // Inserting/creating select functions // The output of the select function is the ___TR list. Modified: newcodegen/supervisorCompiler.c =================================================================== --- newcodegen/supervisorCompiler.c 2011-05-13 22:48:19 UTC (rev 248) +++ newcodegen/supervisorCompiler.c 2011-05-17 13:45:15 UTC (rev 249) @@ -718,15 +718,21 @@ ins = SInsert(";\n", ins); ins = FSInsert(ins, "#define n___in %d // Number of rows of ___in\n", j); */ - if(!sup->marking) { // initialize it to zero - ip = calloc(sup->pnum, sizeof(*ip)); - updatepn(sup, "m0", ip); - free(ip); + if(sup->pnum) { + if(!sup->marking) { // initialize it to zero + ip = calloc(sup->pnum, sizeof(*ip)); + updatepn(sup, "m0", ip); + free(ip); + } + ins = SInsert("const int ___m0[][2] = ", ins); + ins = cinsert1D(sup->marking, sup->pnum, &j, ins); + ins = SInsert(";\n", ins); + ins = FSInsert(ins,"#define n___m0 %d // Number of rows of ___m0\n\n",j); } - ins = SInsert("const int ___m0[][2] = ", ins); - ins = cinsert1D(sup->marking, sup->pnum, &j, ins); - ins = SInsert(";\n", ins); - ins = FSInsert(ins, "#define n___m0 %d // Number of rows of ___m0\n\n", j); + else { + ins = SInsert("const int ___m0[][2] = {};\n", ins); + ins = FSInsert(ins, "#define n___m0 0 // Number of rows of ___m0\n\n"); + } } // end of if(sup) else { ins = SInsert("#define ___pnum 0\n", ins); Modified: pnheaders/pns.c =================================================================== --- pnheaders/pns.c 2011-05-13 22:48:19 UTC (rev 248) +++ pnheaders/pns.c 2011-05-17 13:45:15 UTC (rev 249) @@ -764,6 +764,13 @@ int *lcount, np, np1, np2, nt, nt1, nt2, i, j, k, z, label; + if(!pn1 && !pn2) { + memset(&pn, 0, sizeof(pn)); + return pn; + } + if(!pn1) return copypn(pn2); + if(!pn2) return copypn(pn1); + nt1 = pn1->tnum; /* determine the number of transitions */ nt2 = pn2->tnum; Modified: translator/main.c =================================================================== --- translator/main.c 2011-05-13 22:48:19 UTC (rev 248) +++ translator/main.c 2011-05-17 13:45:15 UTC (rev 249) @@ -264,7 +264,8 @@ if(is_verbose() >= 10) { printf("Threads dealloced\n"); } - nodes ->free (nodes); nodes = NULL; + if(errors != true) // line added by MVI + nodes ->free (nodes); nodes = NULL; if(is_verbose() >= 10) { printf("Nodes freed\n"); } @@ -454,4 +455,4 @@ var = var->next; } printf(" <= \%i\n", ineq->free_term); -} \ No newline at end of file +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mio...@us...> - 2011-06-20 23:01:47
|
Revision: 250 http://pntool.svn.sourceforge.net/pntool/?rev=250&view=rev Author: miordache Date: 2011-06-20 23:01:38 +0000 (Mon, 20 Jun 2011) Log Message: ----------- enhancements Modified Paths: -------------- examples/+README+ examples/test.sp newcodegen/ProcessTemplate.c newcodegen/SupervisorTemplate.c newcodegen/codegen.h newcodegen/filltmpl.lex newcodegen/plantCompiler.c newcodegen/spcommon.h newcodegen/supervisorCompiler.c pnheaders/general.c pnheaders/general.h pnheaders/main_function.c pnheaders/pns.c pnheaders/pns.h translator/Makefile translator/dataStructures.h translator/main.c Added Paths: ----------- examples/catandmouse.sp examples/loop.sp examples/loop3.sp Modified: examples/+README+ =================================================================== --- examples/+README+ 2011-05-17 13:45:15 UTC (rev 249) +++ examples/+README+ 2011-06-20 23:01:38 UTC (rev 250) @@ -1,6 +1,11 @@ Here is the list of test examples: +loop.sp: illustrates how to create loops + +loop3.sp: illustrates how to create loops and how to specify code for the main function of the generated program. + + test2.sp: When running this example a single process (not thread) is started. The process prints messages indicating its state until it terminates. Variants: @@ -34,3 +39,6 @@ reader.sp: A reader, inserter, deleter problem. + + +catandmouse.sp: This is the cat and mouse maze example. Implemented by Micah Martin. Added: examples/catandmouse.sp =================================================================== --- examples/catandmouse.sp (rev 0) +++ examples/catandmouse.sp 2011-06-20 23:01:38 UTC (rev 250) @@ -0,0 +1,116 @@ +// This is a cat and mouse room example + +process CAT; +build: {<thread>}; + +process MOUSE; +build: {<thread>}; + +CAT.PN: + +places: p1 p2 p3 p4 p5; + +transitions: c1 c2 c3 c4 c5 c6 c7 c8; + +// This function defines the places a cat can go. + +p1.code: { +// Room 1 + fprintf(stderr, "\n\nCat is in Room 1"); + sleep(1); +}; + +p2.code: { +// Room 2 + fprintf(stderr, "\n\nCat is in Room 2"); + sleep(1); +}; + +p3.code: { +// Room 3 + fprintf(stderr, "\n\nCat is in Room 3"); + sleep(1); +}; + +p4.code: { +// Room 4 + fprintf(stderr, "\n\nCat is in Room 4"); + sleep(1); +}; + +p5.code: { +// Room 5 + fprintf(stderr, "\n\nCat is in Room 5"); + sleep(1); +}; + +(p1, c1, p2); +(p2, c2, p3); +(p3, c3, p1); +(p1, c4, p4); +(p4, c5, p5); +(p5, c6, p1); +(p2, c7, p4); +(p4, c8, p2); + + +MOUSE.PN: + +places: p6 p7 p8 p9 p10; + +transitions: m1 m2 m3 m4 m5 m6; + +// This function defines the places a mouse can go. + +p6.code: { +// Room 1 + fprintf(stderr, "\n\nMouse is in Room 1"); + sleep(1); +}; + +p7.code: { +// Room 2 + fprintf(stderr, "\n\nMouse is in Room 2"); + sleep(1); +}; + +p8.code: { +// Room 3 + fprintf(stderr, "\n\nMouse is in Room 3"); + sleep(1); +}; + +p9.code: { +// Room 4 + fprintf(stderr, "\n\nMouse is in Room 4"); + sleep(1); +}; + +p10.code: { +// Room 5 + fprintf(stderr, "\n\nMouse is in Room 5"); + sleep(1); +}; + +(p6, m1, p8); +(p8, m2, p7); +(p7, m3, p6); +(p6, m4, p10); +(p10, m5, p9); +(p9, m6, p6); + + +CAT cat(p3:1); // defines one cat initialized in Room 3 +MOUSE mouse(p10:1); // defines one mouse initialized in Room 5 + + + +global.constraints: + +// No room can contain a cat and mouse simultaneously + +cat.p1 + mouse.p6 <= 1; +cat.p2 + mouse.p7 <= 1; +cat.p3 + mouse.p8 <= 1; +cat.p4 + mouse.p9 <= 1; +cat.p5 + mouse.p10 <= 1; \ No newline at end of file Added: examples/loop.sp =================================================================== --- examples/loop.sp (rev 0) +++ examples/loop.sp 2011-06-20 23:01:38 UTC (rev 250) @@ -0,0 +1,38 @@ +// This is an example illustrating conditional transitions and loops. + + + +process MLOOP; + +build: {<thread>}; + +include: { + #include<stdio.h> + static int i = 0; // 'i' shared by threads in the same group; the 'static' + // keyword ensures that it is not visible to other threads +}; + +MLOOP.PN: + +places: p0 p1; + +transitions: t0 t1 t2; + +(p0, t0, p1); +(p1, t1, p0).{i < 4}; // Transition takes place only if i < 4. +(p1, t2).{i >= 4}; // exit via t2 if i is greater than 4. + +p0.code: { + fprintf(stderr, "\nState 0, i = %d", i); + fflush(0); + sleep(1); + i++; +}; + +p1.code: { + fprintf(stderr, "\nState 1, i = %d", i); + fflush(0); + sleep(1); +}; + +MLOOP pr1(p0:1); Added: examples/loop3.sp =================================================================== --- examples/loop3.sp (rev 0) +++ examples/loop3.sp 2011-06-20 23:01:38 UTC (rev 250) @@ -0,0 +1,159 @@ + +process SPR; + +build: {<supervisor>}; + +include: { + #include<stdio.h> + int result, N; // these will be used as shared variable + int a[10]; // declares a shared array of 10 integers + +<main> + + // <main> indicates that what follows is part of the main function of the + // supervisor. + + N = 5; + result = 0; + + /* The following function call will execute the code of the supervisor, + which in turn will start and execute the code of the specified processes + and/or threads. */ + + ___run_supervisor(); + + // The result of the program is verified: + + printf("\nThe result is %d. The expected result was %d.\n", result, 3*N); + + // A return instruction is ESSENTIAL when the code calls + // ___run_supervisor(). Otherwise, this function will be called again by + // the default instructions of the generated code. + + return 0; +}; + + +process LOOP_1; + +build: {<thread>}; + +include: { + #include<stdio.h> + extern int result; + extern int N; + extern int a[]; + static int i; + static int j; + + // 'extern' indicates a variable defined in another C file of the project + // 'static' defines a variable invisible to the other C files of the project + +<main> // This indicates code for the main function of the thread + + fprintf(stderr, "\nA LOOP_1 thread was started."); + fflush(0); + i = 0; + +}; + + +process LOOP_2; + +build: {<thread>}; + +include: { + #include<stdio.h> + extern int result; + extern int N; + static int i; + static int j; + + // 'extern' indicates a variable defined in another C file of the project + // 'static' defines a variable invisible to the other C files of the project + +<main> // This indicates code for the main function of the thread + + fprintf(stderr, "\nA LOOP_2 thread was started."); + fflush(0); + i = 0; + +}; + + + +SPR.PN: + +places: p0; + +transitions: t0; + +(p0, t0); + + + + +LOOP_1.PN: + +places: p0 p1; + +transitions: t0 t1 t2; + +(p0, t0, p1); +(p1, t1, p0).{i < N}; // Transition takes place only if i < N. +(p1, t2).{i >= N}; // exit via t2 if i is greater than N. + +p0.code: { + fprintf(stderr, "\nLOOP_1: State 0, i = %d", i); + fflush(0); + sleep(1); + i++; +}; + +p1.code: { + j = result + 1; + fprintf(stderr, "\nLOOP_1: State 1, i = %d", i); + fflush(0); + sleep(1); + result = j; +}; + + + +LOOP_2.PN: + +places: p0 p1; + +transitions: t0 t1 t2; + +(p0, t0, p1); +(p1, t1, p0).{i < N}; // Transition takes place only if i < N. +(p1, t2).{i >= N}; // exit via t2 if i is greater than N. + +p0.code: { + fprintf(stderr, "\nLOOP_2: State 0, i = %d", i); + fflush(0); + sleep(1); + i++; +}; + +p1.code: { + j = result + 2; + fprintf(stderr, "\nLOOP_2: State 1, i = %d", i); + fflush(0); + sleep(1); + result = j; +}; + + + + + +LOOP_1 a(p0:1); +LOOP_2 b(p0:1); +SPR sp; + + +global.constraints: + +a.p1 + b.p1 <= 1; // implement mutual exclusion Modified: examples/test.sp =================================================================== --- examples/test.sp 2011-05-17 13:45:15 UTC (rev 249) +++ examples/test.sp 2011-06-20 23:01:38 UTC (rev 250) @@ -1,7 +1,7 @@ // This is a test file created in order to check the functionality of the // pn translator. -process TST +process TST; include: { int i; Modified: newcodegen/ProcessTemplate.c =================================================================== --- newcodegen/ProcessTemplate.c 2011-05-17 13:45:15 UTC (rev 249) +++ newcodegen/ProcessTemplate.c 2011-06-20 23:01:38 UTC (rev 250) @@ -7,6 +7,7 @@ #include<pthread.h> #include<limits.h> #include<sys/types.h> +#include<signal.h> #ifdef ___PROCESS int ___debug = 0; // value determined by parameters of main function @@ -18,6 +19,16 @@ static void* ___main_function(void* ___v); +#ifdef ___PROCESS +inline void ___pr_send_signal() { +#ifndef SINGLE_READ_CHANNEL +#ifdef ___SIGNALS + kill(getppid(), SIGUSR1); +#endif +#endif +} +#endif + // +++++++ OTHER DECLARATIONS (GENERATED CODE HERE) @@ -32,6 +43,10 @@ #endif + +// ++++++++++++++++++++++++++ USER CODE--DECLARATIONS (GENERATED CODE HERE) + + static void* ___main_function(void* ___v) { int ___i, ___j, ___flag, ___ntran; time_t ___ctime; @@ -47,12 +62,12 @@ int ___place; // denotes the value of the current place int ___finish; // the program terminates when its value is nonzero + sigset_t ___set; // set of signals that should be blocked ___finish = 0; ___flag = 0; ___place = ___pthr->state; - // !!! To define communication parameters ... time(&___ctime);//___ctime used to initialize the random number generator // Next, ___ctime is modified so that different processes started at the @@ -62,9 +77,19 @@ ___ctime += (int) getpid(); #else ___ctime += (int) getpid() + (int)___pthr->id; + #ifndef SINGLE_READ_CHANNEL + // block SIGUSR1 which may be used to notify main program of new messages + sigemptyset(&___set); + sigaddset(&___set, SIGUSR1); + pthread_sigmask(SIG_BLOCK, &___set, 0); + #endif #endif srand(___ctime%64000); + + // +++++++++++++++++++ USER CODE--MAIN FUNCTION (GENERATED CODE HERE) + + while(!___finish) { switch(___place) { @@ -156,8 +181,6 @@ int main(int argc, char* argv[]) { - // Update to read from pipe parameters! See ___upd_comm_param - int ___i, ___j, ___flag = 0, ___vplace; char* ___str; struct ___thread_data *___pthr = 0; Modified: newcodegen/SupervisorTemplate.c =================================================================== --- newcodegen/SupervisorTemplate.c 2011-05-17 13:45:15 UTC (rev 249) +++ newcodegen/SupervisorTemplate.c 2011-06-20 23:01:38 UTC (rev 250) @@ -1,8 +1,6 @@ // TO DO: check pipe size and adjust it if necessary or terminate if impossible -// enable SIGPIPE for sread pipe of supervisor. +// Enable SIGIO for sread pipe of supervisor. O_ASYNC would be used. // use fcntl for both -// The plant must use fcntl so that its write is not blocked! -// Plant: Blocking read, nonblocking write! // // Note: read() from pipe with O_NOBLOCK set returns 0 if the sender has closed // its end of the pipe or -1 and errno = EAGAIN if the pipe is empty. @@ -16,8 +14,6 @@ // of data as they arrive, and one integer indicating how many bytes are in the // buffer. // -// The plant should send a notification message to the supervisor when terminating. -// // The debugInfo of the supervisor should use a lock. #define ___SUPERVISOR @@ -32,21 +28,26 @@ #include<fcntl.h> #include<signal.h> + #define MSG_READ_LIMIT 10 // max number of messages read from a single process during an iteration char ___debug; // value determined by parameters of main function int ___finish; // the program terminates when its value is nonzero pid_t ___pid; -pthread_t ___tid; +pthread_t ___tid; // thread id of the main program FILE* ___f; char* ___name; + #include"spcommon.h" // The following is used for unnamed pipe communication between plant // and supervisor. +int ___read_ch, ___write_ch; // the read and write ends of the pipe to which +// plant components write. + struct ___comm { int sread, swrite; int pread, pwrite; @@ -165,20 +166,33 @@ const int *oweight; // vector of nopl elements }; +static char ___no_msg; // indicates absence of plant messages in main function +static sigset_t ___set; // set of signals that may be blocked by main thread +static unsigned char ___start_flag; // used in the main function + +int ___run_supervisor(); // this is the main function of the sup. program + + // +++++++ OTHER DECLARATIONS (GENERATED CODE HERE) -// default values included below for debugging puroposes -#ifndef n___prtypes -#define n___prtypes 1 -#endif -struct proc *___prtype[n___prtypes]; +struct proc *___prtype[n___prtypes]; // n___prtypes defined in generated code -int ___marking[___pnum]; // supervisor marking +int ___marking[___pnum]; // supervisor marking; ___pnum defined in gen. code +inline void ___th_send_signal() { +#ifndef SINGLE_READ_CHANNEL +#ifdef ___SIGNALS + if(pthread_self() != ___tid) + pthread_kill(___tid, SIGUSR1); +// it may be that all threads receive the signal, though handler executed only by ___tid +#endif +#endif +} + inline int ___is_enabled(int ___t) { // checks whether ___t is enabled int ___i, ___nipl; const int *___iplace, *___iweight; @@ -472,6 +486,14 @@ return 0; } + +#ifdef SINGLE_READ_CHANNEL + + ___p->sread = ___read_ch; + ___p->pwrite = ___write_ch; + +#else + ___p->sread = ___ip[0]; ___p->pwrite = ___ip[1]; @@ -483,12 +505,15 @@ return 0; } + fcntl( ___p->sread, F_SETFL, O_NONBLOCK); // supervisor has nonblocking read + fcntl( ___p->pwrite, F_SETFL, O_NONBLOCK); // plant has nonblocking write + +#endif + ___p->swrite = ___ip[1]; ___p->pread = ___ip[0]; - fcntl( ___p->sread, F_SETFL, O_NONBLOCK); - fcntl( ___p->swrite, F_SETFL, O_NONBLOCK); - fcntl( ___p->pwrite, F_SETFL, O_NONBLOCK); + fcntl( ___p->swrite, F_SETFL, O_NONBLOCK); // sup. has nonblocking write return ___p; } @@ -538,10 +563,18 @@ void ___free_comm(struct ___comm *___pc) { if(___pc) { + +#ifdef SINGLE_READ_CHANNEL + close(___pc->swrite); + if( ! ___pc->pclosed ) // plant end of pipes already closed for processes + close(___pc->pread); // line reached in the case of threads +#else close(___pc->sread); close(___pc->swrite); - if( ! ___pc->pclosed ) { + if( ! ___pc->pclosed ) {// plant end of pipes already closed for processes close(___pc->pread); close(___pc->pwrite); } +#endif + free(___pc); } } @@ -652,14 +685,19 @@ for(___pa = ___prlist; ___pa; ___pa = ___pa->next_in_prlist) { if(___pa == ___p) continue; + +#ifndef SINGLE_READ_CHANNEL close(((struct ___comm*)___pa->comm)->sread); +#endif close(((struct ___comm*)___pa->comm)->swrite); } return 1; } else { // if this is the supervisor process close(((struct ___comm*)___p->comm)->pread); +#ifndef SINGLE_READ_CHANNEL close(((struct ___comm*)___p->comm)->pwrite); +#endif ((struct ___comm*)___p->comm)->pclosed = 1; // send parameters to child process @@ -702,7 +740,7 @@ } -struct proc* ___StartProcess(int ___type, int ___where) { +inline struct proc* ___StartProcess_sub(int ___type, int ___where) { struct proc *___pr; int ___i; struct ___thread_data *___pthr; @@ -778,8 +816,30 @@ +struct proc* ___StartProcess(int ___type, int ___where) { + struct proc* ___p; + +#ifndef SINGLE_READ_CHANNEL +#ifdef ___SIGNALS + pthread_sigmask(SIG_BLOCK, &___set, 0); +#endif +#endif + + ___p = ___StartProcess_sub(___type, ___where); + +#ifndef SINGLE_READ_CHANNEL +#ifdef ___SIGNALS + pthread_sigmask(SIG_UNBLOCK, &___set, 0); +#endif +#endif + + return ___p; +} + + void ___finish_sig_handler(int ___sig) { struct proc* ___p; + void* ___v; if(getpid() != ___pid) exit(EXIT_FAILURE); @@ -787,18 +847,59 @@ pthread_exit(0); else { debugInfo("A signal has been received and the program will be terminated"); - for(___p = ___prlist; ___p; ___p = ___p->next_in_prlist) - ___terminate_process(___p); // also calls___free_proc(___p); - exit(EXIT_SUCCESS); + for(___p = ___prlist; ___p; ___p = ___p->next_in_prlist) { + //___terminate_process(___p); // also calls ___free_proc(___p); + if(___p->pid) // then this is a forked process + kill(___p->pid, SIGTERM); + /*else { // then this is a thread + pthread_kill(___p->thread_id, SIGINT); + pthread_join(___p->thread_id, &___v); // wait for it to terminate + }*/ + ___free_proc(___p); + } + debugInfo("The program is terminating ... "); + //sleep(1); + raise(SIGTERM); + //exit(EXIT_SUCCESS); } } +#ifndef SINGLE_READ_CHANNEL +#ifdef ___SIGNALS + +void ___newmsg_sig_handler(int ___sig) { + + debugInfo("SIGUSR1 received"); + if(getpid() == ___pid) + if(pthread_self() == ___tid) + ___no_msg = 0; + return; +} + +#endif +#endif + + inline int ___check_for_msg(struct proc *___p, struct ___msg *p___ms) { // The function returns 0 if there are no messages + int ___i; - return ___get_msg(((struct ___comm*)___p->comm)->sread, p___ms, \ - sizeof(*p___ms), debugInfo); + // Block signals while receiving data + +#ifndef SINGLE_READ_CHANNEL +#ifdef ___SIGNALS + pthread_sigmask(SIG_BLOCK, &___set, 0); +#endif +#endif + ___i = ___get_msg(((struct ___comm*)___p->comm)->sread, p___ms, \ + sizeof(*p___ms), debugInfo); +#ifndef SINGLE_READ_CHANNEL +#ifdef ___SIGNALS + pthread_sigmask(SIG_UNBLOCK, &___set, 0); +#endif +#endif + return ___i; } @@ -937,28 +1038,39 @@ inline void ___send_permission_msg(struct proc *___p) { +#ifndef SINGLE_READ_CHANNEL +#ifdef ___SIGNALS + pthread_sigmask(SIG_BLOCK, &___set, 0); +#endif +#endif + ___send_msg(&___p->fireable, sizeof(int), ((struct ___comm*)___p->comm)->swrite, debugInfo); +#ifndef SINGLE_READ_CHANNEL +#ifdef ___SIGNALS + pthread_sigmask(SIG_UNBLOCK, &___set, 0); +#endif +#endif + } -int main(int argc, char* argv[]) { - int ___i, ___j, ___a; - char* ___str, ___no_msg, ___start_flag; + +// Define the main function of the supervisor program + +int ___run_supervisor() { + int ___i, ___j, ___a, ___ip[2]; + long ___def_flags; struct proc *___p, *___pa, *___pn; struct sigaction ___act; struct ___msg ___ms; time_t ___ctime; - char ___help_msg[] = "\nOptions: \n\ - -e: suppress error and status messages\n\ - -s: start the program right away without displaying introductory message\n\n\ - Ctrl-C (SIGINT) can be used to stop the program. This will terminate all\n\ - its processes.\n"; + ___pid = getpid(); ___tid = pthread_self(); - ___debug = 0; + //___debug = 0; ___finish = 0; ___f = stderr; ___name = 0; @@ -973,46 +1085,31 @@ ___act.sa_handler = ___finish_sig_handler; sigaction(SIGINT, &___act, 0); // initialize act +#ifdef SINGLE_READ_CHANNEL + + if (pipe(___ip) == -1) { + debugInfo("Could not open unnamed pipes"); + return 1; + } + ___read_ch = ___ip[0]; // read end of supervisor + ___write_ch = ___ip[1]; // write end of plant components + ___def_flags = fcntl(___read_ch, F_GETFL); +#else +#ifdef ___SIGNALS + sigaction(SIGUSR1, 0, &___act); // initialize act + ___act.sa_flags = SA_RESTART; + ___act.sa_handler = ___newmsg_sig_handler; + sigaction(SIGUSR1, &___act, 0); // initialize act + sigemptyset(&___set); + sigaddset(&___set, SIGUSR1); +#endif +#endif + time(&___ctime); srand(___ctime%64000); - ___debug = 1; - ___start_flag = (argc <= 1); - for(___i = 1; ___i < argc; ___i++) { - if(!strcmp(argv[___i], "-e")) - ___debug = 0; - else if(!strcmp(argv[___i], "-h") || !strcmp(argv[___i], "--help")) { - fprintf(stdout, ___help_msg); - return 0; - } - else if(!strcmp(argv[___i], "-s")) { - ___start_flag = 0; // "-s" is for future use; unnecessary right now - } - } - if(___start_flag) { - fprintf(stdout, "%s\nThe program will start in five seconds.\n", ___help_msg); - sleep(5); - } - if(___debug) { - if(argc <= 1) - debugInfo("The main function was entered. The main functions has no parameters."); - else { - for(___i = 0, ___j = 0; ___i < argc; ___i++) - ___j += strlen(argv[___i]); - ___j += argc + 1; - ___str = malloc(___j*sizeof(char)); - for(___i = 0, ___j = 0; ___i < argc - 1; ___i++) { - sprintf(___str + ___j, "%s ", argv[___i]); - ___j += strlen(argv[___i]) + 1; - } - sprintf(___str + ___j, "%s", argv[___i]); - debugInfo("The process was started with the following command line\n\t%s", ___str); - free(___str); - } - } - // initialize supervisor ___marking memset(___marking, 0, sizeof(*___marking)*___pnum); for(___i = 0; ___i < n___m0; ___i++) @@ -1032,10 +1129,21 @@ // Check all processes for new messages +#ifdef SINGLE_READ_CHANNEL + fcntl(___read_ch, F_SETFL, ___def_flags); // next read will be blocking + for(___i = 0; ___i < MSG_READ_LIMIT; ___i++) { + ___j = ___get_msg(___read_ch, &___ms, sizeof(___ms), debugInfo); + if(!___j) + break; // exit loop since there are no more messages + ___process_msg(&___ms); + if(!___i) + fcntl(___read_ch, F_SETFL, O_NONBLOCK); // next reads nonblocking + } +#else for(___p = ___prlist, ___no_msg = 1; ___p; ___p = ___pn) { ___pn = ___p->next_in_prlist; // process_msg below may deallocate ___p for(___i = 0; ___i < MSG_READ_LIMIT; ___i++) { - ___j = ___check_for_msg(___p, &___ms); + ___j = ___check_for_msg(___p, &___ms); if( ! ___j ) break; // exit loop, since there are no messages ___no_msg = 0; @@ -1044,10 +1152,13 @@ } } - if(___no_msg) { - sleep(2); // any interrupt will awake the process + if(___no_msg) { // if SIGUSR1 occurs between if and sleep --> ignored! + #ifdef ___SLEEP + sleep(___SLEEP); // any signal will awake the process + #endif continue; } +#endif // Check for queued requests that can be resolved @@ -1096,8 +1207,81 @@ } // end of while( ! ___finish) (the main loop) - debugInfo("The end of the main function was reached.\n"); +#ifdef SINGLE_READ_CHANNEL + close(___read_ch); + close(___write_ch); +#endif + + debugInfo("The end of the supervisor function was reached.\n"); - return 1; + return 0; } + + + +// ++++++++++++++++++++++++++ USER CODE--DECLARATIONS (GENERATED CODE HERE) + + + +int ___smain_fn() { + + + // +++++++++++++++++++ USER CODE--MAIN FUNCTION (GENERATED CODE HERE) + + + return ___run_supervisor(); +} + + +#ifdef ___MAIN_FUNCTION + +int main(int argc, char* argv[]) { + int ___i, ___j; + char *___str, ___help_msg[] = "\nOptions: \n\ + -e: suppress error and status messages\n\ + -s: start the program right away without displaying introductory message\n\n\ + Ctrl-C (SIGINT) can be used to stop the program. This will terminate all\n\ + its processes.\n"; + + ___debug = 1; + ___start_flag = (argc <= 1); + for(___i = 1; ___i < argc; ___i++) { + if(!strcmp(argv[___i], "-e")) + ___debug = 0; + else if(!strcmp(argv[___i], "-h") || !strcmp(argv[___i], "--help")) { + fprintf(stdout, ___help_msg); + return 0; + } + else if(!strcmp(argv[___i], "-s")) { + ___start_flag = 0; + } + } + + if(___start_flag) { + fprintf(stdout, "%s\nThe program will start in five seconds.\n", ___help_msg); + sleep(5); + } + + if(___debug) { + if(argc <= 1) + debugInfo("The main function was entered. The main functions has no parameters."); + else { + for(___i = 0, ___j = 0; ___i < argc; ___i++) + ___j += strlen(argv[___i]); + ___j += argc + 1; + ___str = malloc(___j*sizeof(char)); + for(___i = 0, ___j = 0; ___i < argc - 1; ___i++) { + sprintf(___str + ___j, "%s ", argv[___i]); + ___j += strlen(argv[___i]) + 1; + } + sprintf(___str + ___j, "%s", argv[___i]); + debugInfo("The program was started with the following command line\n\t%s", ___str); + free(___str); + } + } + + return ___smain_fn(); +} + +#endif Modified: newcodegen/codegen.h =================================================================== --- newcodegen/codegen.h 2011-05-17 13:45:15 UTC (rev 249) +++ newcodegen/codegen.h 2011-06-20 23:01:38 UTC (rev 250) @@ -43,9 +43,8 @@ char* GetFileName(const char* s, const char *ext); // Similar to "asprintf(&x, "%s.%s", s, ext); return x;" -void compileSupervisor(pns *supervisor, char* sname, process **procTypes, \ - int nbrTypes, TrData** TrInfo, struct synclist* sl, \ - const char* buildparam); +void compileSupervisor(specs *sp, pns *supervisor, process **procTypes, \ + int nbrTypes, TrData** TrInfo, struct synclist* sl); -void compileProcessArray(process **procArray, int nbrElements, TrData** TrInfo, \ - int** actlabels); +void compileProcessArray(specs *sp, process **procArray, int nbrElements, \ + TrData** TrInfo, int** actlabels); Modified: newcodegen/filltmpl.lex =================================================================== --- newcodegen/filltmpl.lex 2011-05-17 13:45:15 UTC (rev 249) +++ newcodegen/filltmpl.lex 2011-06-20 23:01:38 UTC (rev 250) @@ -23,10 +23,12 @@ cc = yytext[i]; yytext[i] = 0; // get indentation string stmp = va_arg(param, char*); // get string to insert - for(j = 0; stmp[j]; j++) { - fwrite(stmp+j, sizeof(stmp[j]), 1, out); - if(stmp[j] == '\r' || stmp[j] == '\n') - fprintf(out, "%s", yytext); + if(stmp) { + for(j = 0; stmp[j]; j++) { + fwrite(stmp+j, sizeof(stmp[j]), 1, out); + if(stmp[j] == '\r' || stmp[j] == '\n') + fprintf(out, "%s", yytext); + } } yytext[i] = cc; // restore yytext fprintf(out, "\n%s (END OF CODE)\n", yytext); Modified: newcodegen/plantCompiler.c =================================================================== --- newcodegen/plantCompiler.c 2011-05-17 13:45:15 UTC (rev 249) +++ newcodegen/plantCompiler.c 2011-06-20 23:01:38 UTC (rev 250) @@ -31,7 +31,7 @@ } -struct myinsert genDefineBlock(process* pr, TrData* TrInfo) { +struct myinsert genDefineBlock(specs *sp, process* pr, TrData* TrInfo) { struct myinsert ins; int i, j, k, ntr; pns *pn; @@ -71,9 +71,14 @@ }\n", pr->name); } - ins = SInsert("\n\n//----- BEGINNING OF USER DEFINITIONS -----\n\n", ins); - ins = SInsert(pr->include, ins); // get include data of process - ins = SInsert("\n\n//----- END OF USER DEFINITIONS -----\n\n", ins); + if(sp->signals) + ins = SInsert("#define ___SIGNALS\n", ins); + if(sp->singlechannel) + ins = SInsert("#define SINGLE_READ_CHANNEL\n", ins); + + //ins = SInsert("\n\n//----- BEGINNING OF USER DEFINITIONS -----\n\n", ins); + //ins = SInsert(pr->include, ins); // get include data of process + //ins = SInsert("\n\n//----- END OF USER DEFINITIONS -----\n\n", ins); //if(DBG3) // if yes, then generated executables should also be in debug mode // incl = SInsert("\n#define ___DEBUG\n", incl); @@ -169,8 +174,8 @@ } -void compileProcessArray(process **procArray, int nbrElements, TrData** TrInfo, \ - int** actlabels) { +void compileProcessArray(specs *sp, process **procArray, int nbrElements, \ + TrData** TrInfo, int** actlabels) { // Note that TrInfo[i][j] indicates whether transition j of process i is // controlled and/or observed by the supervisor. @@ -203,7 +208,7 @@ fprintf(plantFile,"#define ___INSTANCE \"%s\"\n", procArray[i]->instance); // generate declarations/definitions - incl = genDefineBlock(procArray[i], TrInfo[i]); + incl = genDefineBlock(sp, procArray[i], TrInfo[i]); // generate block for main() mblock = genMainBlock(procArray[i], actlabels[i]); @@ -211,7 +216,8 @@ // Write output file rewind(f); - FillTemplate(f, plantFile, GetInsertBuf(&incl), GetInsertBuf(&mblock)); + FillTemplate(f, plantFile, GetInsertBuf(&incl), procArray[i]->include, \ + procArray[i]->main, GetInsertBuf(&mblock)); free(fileName); free(GetInsertBuf(&incl)); Modified: newcodegen/spcommon.h =================================================================== --- newcodegen/spcommon.h 2011-05-17 13:45:15 UTC (rev 249) +++ newcodegen/spcommon.h 2011-06-20 23:01:38 UTC (rev 250) @@ -6,7 +6,6 @@ #define SPCOMMON #include<errno.h> - // The following type describes data transmitted to a thread when it is created struct ___thread_data { @@ -58,6 +57,8 @@ int trans; // transition number }; +inline void ___pr_send_signal(); +inline void ___th_send_signal(); void ___debugInfoSub(int ___type, int ___id, char* ___vname, char* ___str, va_list ___param); @@ -132,6 +133,14 @@ } } + // Notify supervisor that a message has been sent + +#ifdef ___PROCESS + ___pr_send_signal(); +#else + ___th_send_signal(); +#endif + //if(write(pwrite, ___pdata, ___n) == -1) // return 0; @@ -153,11 +162,15 @@ //dbgfn("Inside get_msg"); ___ret = read(___read_end, p___ms, ___n); - if(___ret == -1 || ___ret == 0) // -1 indicates error + //if(___ret == -1 || ___ret == 0) // -1 indicates error + // return 0; + if(___ret <= 0) { + // ignore a common condition: nonblocking read from empty pipe + if(___ret == -1 && errno == EAGAIN) + return 0; + // report other conditions + dbgfn("read() has returned %d in ___get_msg(); errno = %d", ___ret, (int)errno); return 0; - if(___ret < 0) { - dbgfn("read() has returned %d in ___get_msg()", ___ret); - return 0; } if(___ret < ___n) { // Try to recover the remaining bytes dbgfn("read() has returned %d out of %d bytes in ___get_msg()",\ Modified: newcodegen/supervisorCompiler.c =================================================================== --- newcodegen/supervisorCompiler.c 2011-05-17 13:45:15 UTC (rev 249) +++ newcodegen/supervisorCompiler.c 2011-06-20 23:01:38 UTC (rev 250) @@ -691,7 +691,7 @@ */ -struct myinsert supDefineBlock(pns *sup, process **prs, int nprs, \ +struct myinsert supDefineBlock(pns *sup, process **prs, int nprs, specs* sp, \ TrData** TrInfo, struct synclist *sl) { struct myinsert ins; int i, j, n, p, t, *mk, *ip, first; @@ -884,6 +884,19 @@ ins = FSInsert(ins,"#define ___MASK %d\n", MaxNo); ins = SInsert("char ___mask[___MASK]; // Masked transitions are not fired\n\n",ins); } + + // Implement the settings of sp + + if(!(sp->nomain)) + ins = SInsert("#define ___MAIN_FUNCTION\n", ins); + if(sp->signals) + ins = SInsert("#define ___SIGNALS\n", ins); + if(sp->singlechannel) + ins = SInsert("#define SINGLE_READ_CHANNEL\n", ins); + if(sp->sleep) + ins = SInsert("#define ___SLEEP 2\n", ins); + ins = SInsert("\n", ins); + return ins; } @@ -973,15 +986,17 @@ free(thr); } -void compileSupervisor(pns *supervisor, char* sname, process **procTypes, \ - int nbrTypes, TrData** TrInfo, struct synclist* sl, \ - const char* buildparam) { +void compileSupervisor(specs* sp, pns *supervisor, process **procTypes, \ + int nbrTypes, TrData** TrInfo, struct synclist* sl) { FILE* f, *supFile; - char *fileName; + char *fileName, *sname, *buildparam; struct myinsert incl; time_t currentTime; + sname = sp->name; + buildparam = sp->sbuildparam; + f = searchTemplate(TEMPL); fileName = GetFileName(sname, "c"); supFile = fopen(fileName, "w"); @@ -999,12 +1014,12 @@ fprintf(supFile,"#define ___NAME \"%s\"\n", sname); - incl = supDefineBlock(supervisor, procTypes, nbrTypes, TrInfo, sl); + incl = supDefineBlock(supervisor, procTypes, nbrTypes, sp, TrInfo, sl); // Write output file rewind(f); - FillTemplate(f, supFile, GetInsertBuf(&incl)); + FillTemplate(f, supFile, GetInsertBuf(&incl), sp->include, sp->main); free(fileName); free(GetInsertBuf(&incl)); fclose(f); fclose(supFile); @@ -1112,14 +1127,19 @@ } -int CodeGenerator(pns *supervisor, char* sname, process** prarray, int num,\ - struct synclist* sl, TrData** TInf, const char* sbuildparam) { +int CodeGenerator(pns *supervisor, specs* sp, process** prarray, int num,\ + struct synclist* sl, TrData** TInf) { process* pr; int i, j, k, m; char *s; struct myinsert ins; + if(!sp) { + merror(0,"NEWCODEGEN: Empty specification object!"); + return 1; + } + // 2. Preprocess the array of prarray // 2.1. Update 'name' to correspond to the file name that will be @@ -1171,8 +1191,8 @@ // 3. Generate the code. - compileSupervisor(supervisor, sname, prarray, num, TInf, sl, sbuildparam); - compileProcessArray(prarray, num, TInf, plabels); + compileSupervisor(sp, supervisor, prarray, num, TInf, sl); + compileProcessArray(sp, prarray, num, TInf, plabels); // plabels is generated by compileSupervisor // Free data Modified: pnheaders/general.c =================================================================== --- pnheaders/general.c 2011-05-17 13:45:15 UTC (rev 249) +++ pnheaders/general.c 2011-06-20 23:01:38 UTC (rev 250) @@ -62,9 +62,10 @@ as intended approximately N bytes. */ if(!x->N) merror(0, "Uninitialized allocation structure!"); - x->i -= nbytes; - if(x->i >= 0) + if(x->i >= nbytes) { + x->i -= nbytes; return (x->mem) + (x->i); + } x->pos->next = tcalloc(1, sizeof(*(x->data))); x->pos = x->pos->next; x->mem = tmalloc(x->N + nbytes); x->pos->mem = x->mem; x->i = x->N; @@ -72,6 +73,14 @@ } +inline void* szalloc(struct alloc* x, size_t nbytes) { + void *ret; + ret = smalloc(x, nbytes); + memset(ret, 0, nbytes); + return ret; +} + + void sfree(struct alloc *x) { struct _alist *p, *q; for(p = x->data; p; ) { Modified: pnheaders/general.h =================================================================== --- pnheaders/general.h 2011-05-17 13:45:15 UTC (rev 249) +++ pnheaders/general.h 2011-06-20 23:01:38 UTC (rev 250) @@ -37,7 +37,9 @@ void initalloc(struct alloc* x, size_t N); /* Must be called before using the allocation object! - N determines the number of bytes of the memory blocks that are allocated. + N determines the number of bytes of the memory blocks that are allocated. + N does not limit the maximum size but the minimum size of the allocated + blocks. */ inline void* smalloc(struct alloc* x, size_t nbytes); @@ -46,6 +48,11 @@ allocated memory is in the worst case (max(nbytes)-1)/(x->N + 1), where max(nbytes) is the maximum value given by the program to nbytes. */ + +inline void* szalloc(struct alloc* x, size_t nbytes); +/* Same as smalloc except it initializes to zero the allocated memory */ + + void sfree(struct alloc *x); /* Deallocates the memory blocks addressed by the object. */ @@ -61,10 +68,10 @@ /* The structures is organized in blocks of memory called here pages. Each page can store N bytes. A page stores elements of size sz bytes. */ struct qalloc { - size_t N, sz; /* N: bytes per page, sz: bytes per element */ - size_t front, rear; /* front: position of last element; + long N, sz; /* N: bytes per page, sz: bytes per element */ + long front, rear; /* front: position of last element; rear: position of first element; */ - size_t nitems; /* number of items in the queue */ + long nitems; /* number of items in the queue */ struct _qlist *frpage, *rrpage; /*the pages of front and rear, respectively*/ struct _qlist *last; /* pointer to the last element of the chain of pages */ Modified: pnheaders/main_function.c =================================================================== --- pnheaders/main_function.c 2011-05-17 13:45:15 UTC (rev 249) +++ pnheaders/main_function.c 2011-06-20 23:01:38 UTC (rev 250) @@ -55,9 +55,54 @@ } +void main_filter(char **inc, char **newinc, char **main, char *pattern) { + // Copy/append to newinc everything in *inc up to 'pattern'. + // Copy/append to *main everything in *inc following 'pattern'. + // If newinc is zero, keep in inc everything up to 'pattern'. + // If newinc is nonzero, dealloc *inc and set it to zero. + + int i, n; + char *p, *p2; + + if(!inc) return; + p = *inc; + if(!p || !pattern) return; + n = strlen(pattern); + for(i = 0; p[i]; i++) { + if(p[i] == ' ' || p[i] == '\t') + continue; + if(!strncmp(p+i, pattern, n)) // then 'pattern' has been found + break; + } + + if(main && p[i]) { // p[i] is nonzero if 'pattern' was found + if(*main) { // append to text in *main + asprintf(&p2, "%s\n\n%s", *main, p+i+n); + free(*main); + *main = p2; + } + else // write text to *main + asprintf(main, "%s", p+i+n); + } + + p[i] = 0; // keep in inc everything up to 'pattern' + if(newinc) { + if(!*newinc) + *newinc = *inc; + else { // append to text in newinc + asprintf(&p2, "%s\n\n%s", *newinc, *inc); + free(*newinc); + *newinc = p2; + free(*inc); + } + *inc = 0; + } +} + + void sp_filter(specs *sp) { - // Removes beginning and end braces. - // Processes <thread> instructions. + // Removes beginning and end braces. Processes embedded instructions. + // Sets default values for fields not processed by the translator. int i, j; pns *pn; arcs *pa; @@ -65,13 +110,20 @@ return; if(!sp->process_array) return; + + // Default values + + sp->main = 0; + sp->include = 0; + for(i = 0; i < sp->process_num; i++) { if(!sp->process_array[i]) continue; + + sp->process_array[i]->main = 0; // not processed by the translator + br_filter(sp->process_array[i]->build); br_filter(sp->process_array[i]->include); - //if(th_filter(&(sp->process_array[i]->build))) - //sp->process_array[i]->thread = 1; // Is this a thread? sp->process_array[i]->thread = th_filter(&(sp->process_array[i]->build),\ @@ -79,6 +131,13 @@ // Is this a supervisor component? sp->process_array[i]->supervisor=th_filter(&(sp->process_array[i]->build),\ "<supervisor>"); + // Process the <main> instructions if any + if(sp->process_array[i]->supervisor) + main_filter(&(sp->process_array[i]->include), &(sp->include), \ + &(sp->main), "<main>"); + else + main_filter(&(sp->process_array[i]->include), 0, \ + &(sp->process_array[i]->main), "<main>"); pn = sp->process_array[i]->pn; if(pn) { if(pn->segment) @@ -117,33 +176,74 @@ struct label_lst* lls; TrData** TInf; + // These are flags + unsigned char no_main = 0, signals = 0, sleep = 1, single_ch = 0; +char help[] = "\ +The program generates concurrency control code based on a specification file.\ +\n\ +\nUsage: ct [options] [specification file] [-b list]\ +\n\ +\n'list' stands for a list of files and compiler options that should be\ +\ncopied to the command line used to build the executable file.\ +\n\ +\nOptions:\ +\n -d<number> Comment on execution progress. More information displayed for\ +\n higher values of <number>, where <number> = 1 ... 20.\ +\n -m Do not generate a main function.\ +\n -s<number> Depending on the value of <number> the supervisor can be built\ +\n as follows:\ +\n 0: The supervisor waits actively for events. \ +\n 1: The supervisor is built as in option 0 except it enters a \ +\n sleep state (for a finite amount of time) when no events\ +\n are detected. \ +\n 2: The supervisor blocks when no events occur. This option is \ +\n best when the number of concurrent processes or threads is \ +\n small. The supervisor has the least computational overhead \ +\n under this option. \ +\n\ +\nExamples: ct manf.sp\ +\n ct -d3 input.sp\n"; + +// About single channe (option 2) all plant components write to the same pipe. +// Use this option if it is unlikely that the pipe would keep getting full +// (i.e. if there are not many processes). Otherwise, fairness depends on +// whether the OS is fair in deciding which requests to serve when the pipe +// keeps getting full and there are competing requests to write to the pipe. + + // 1. INITIALIZATION ins = InitInsert(512); // used to store command line parameters verb = 0; input = 0; - if(na <= 1 || na > 3) { - printf("\nACTS--A Concurrency Tool Suite for concurrent programming and concurrent \nsystem design. This software is part of ongoing research to apply supervisory\ncontrol and related approaches to concurrency problems. While various \nsupervisory control tools should be implemented in the future, currently only\nmethods of the supervision based on place invariants are implemented. For \nmore information please refer to the documentation.\n\ -\nUsage: ct [-dnum] file [-b ...]\ -\nOptions:\ -\n -b ... List of files and compiler options that should be copied to\ -\n the command line that builds the main program.\ -\n -d<num> Comment on execution progress. More information displayed for\ -\n high values of <num>.\ -\n\ -\nExamples: ct manf.sp\ -\n ct -d3 input.sp\n"); - + if(na <= 1) { + puts(help); finish = 1; } for(i = 1; i < na && !finish; i++) { + if(!strcmp(argv[i], "--help")) { + finish = 1; + puts(help); + break; + } if(argv[i][0] == '-') { switch(argv[i][1]) { case 'd': verb = atoi(argv[i]+2); break; + case 'm': no_main = 1; + break; + case 's': j = atoi(argv[i]+2); + switch(j) { + case 0: sleep = 0; break; + case 1: sleep = 1; break; + case 2: single_ch = 1; break; + case 3: signals = 1; break; + default: fprintf(stderr,"Unexpected parameter %s.\n", argv[i]); + } + break; case 'b': if(argv[i][2]) ins = FSInsert(ins, " %s", argv[i]+2); for(i = i + 1; i < na; i++) @@ -200,6 +300,13 @@ return 0; } + // Set settings not detected by translator + + sp->signals = signals; + sp->sleep = sleep; + sp->singlechannel = single_ch; + sp->nomain = no_main; + sp_filter(sp); // detect settings and remove extra braces if(is_verbose() >= 3) { // For debugging @@ -247,6 +354,7 @@ // 2.3 Obtain SC specification. Currently: // extract the L, C, H, and b matrices (more complex specs to be done later) + // the function calculates also the composed PN extractLHCB(sp, &pn, &L, &H, &C, &B); @@ -418,10 +526,10 @@ /*CodeGenerator(apnsv, sp->name, sp->process_array, sp->process_num, \ syncl, TInf, build); */ + sp->sbuildparam = build; + CodeGenerator(apnsv, sp, plant_array, plcnum, syncl, TInf); - CodeGenerator(apnsv, sp->name, plant_array, plcnum, syncl, TInf, build); - // 5. TERMINATE if(apnsv) { @@ -431,7 +539,6 @@ free(plant_array); free(spv_array); dealloc_specs(sp); - if(build) free(build); free_label_list(lls); free_synclist(syncl); free_TrData(TInf, plcnum); Modified: pnheaders/pns.c =================================================================== --- pnheaders/pns.c 2011-05-17 13:45:15 UTC (rev 249) +++ pnheaders/pns.c 2011-06-20 23:01:38 UTC (rev 250) @@ -1,6 +1,6 @@ /**************************************************************************** PNS.C -Written in 2008-2010 by M. V. Iordache. +Written in 2008-2011 by M. V. Iordache. ****************************************************************************/ #include"pns.h" @@ -680,6 +680,12 @@ dealloc_process(sp->process_array[i]); free(sp->process_array); } + if(sp->include) + free(sp->include); + if(sp->main) + free(sp->main); + if(sp->sbuildparam) + free(sp->sbuildparam); } @@ -702,6 +708,12 @@ free(p->build); if(p->include) free(p->include); + if(p->main) + free(p->main); + if(p->pn) { + deallocpn(p->pn); + free(p->pn); + } } @@ -746,14 +758,144 @@ } +inline void dealloc_tarray(struct tarray* p) { + if(p) { + sfree(&(p->mem)); + if(p->T) + free(p->T); + free(p); + } +} + /*************************************************************************** COMPOSEPN ****************************************************************************/ -pns composepn(pns* pn1, pns* pn2) { - pns pn; - /* Algorithm: +void inline insert_tranlist_sub(struct tranlist where, pns* pn, int t, \ + struct alloc* mem) { + // subroutine of ComposePN; inserts a tranlist element in the chain such that + // the pn fields in the chain are sorted in increasing order. + + struct tranlist *p, *q; + + if(!where.pn) { // this indicates an empty chain + where.pn = pn; + where.t = t; + return; + } + + p = smalloc(mem, sizeof(*p)); + + if(pn < where.pn) { // if this must be the first chain element + p->pn = where.pn; + p->t = where.t; + p->next = where.next; + where.next = p; + where.pn = pn; + where.t = t; + return; + } + p->pn = pn; + p->t = t; + for(q = &where; q->next; q = q->next) { + if(q->next->pn >= p->pn) { // insert p in chain + p->next = q->next; + q->next = p; + return; + } + } + q->next = p; // line reached if p must be at the end of the chain + p->next = 0; // smalloc does not initialize memory to 0 when it allocates p +} + + +void inline insert_tranlist(struct tranlist where, struct tranlist* what, \ + struct alloc* mem) { + // subroutine of ComposePN; inserts a tranlist element in the chain such that + // the pn fields in the chain are sorted in increasing order. + + insert_tranlist_sub(where, what->pn, what->t, mem); +} + + +void update_TR(int i, int i1, int i2, struct tarray *T1, struct tarray *T2, \ + struct tarray *TR) { + // This is a subroutine of ComposePN. Copies T1[i1] and T2[i2] to TR[i]. + // + // Relies on TR->T having its elements initialized to zero (satisfied when + // TR->T is allocated with (t)calloc. + + struct tranlist *p; + + if(T1) + if(T1->T) + for(p = (T1->T)+i1; p; p = p->next) + insert_tranlist((TR->T)[i], p, &(TR->mem)); + + if(T2) + if(T2->T) + for(p = (T2->T)+i2; p; p = p->next) + insert_tranlist((TR->T)[i], p, &(TR->mem)); +} + + +void set_TR(pns* pn, struct tarray* T, struct tarray **TR) { + // This is a subroutine of ComposePN and PNComposition. + // It is used to initialize TR based on pn and T. + int nt, i; + struct tranlist* TL, *p; + + if(!TR) + return; + + *TR = tcalloc(1, sizeof(**TR)); + initalloc(&((*TR)->mem), 50*sizeof(*(*TR)->T)); + if(!T) { + nt = pn->tnum; + (*TR)->n = nt; + TL = tcalloc(nt, sizeof(*(*TR)->T)); + for(i = 0; i < nt; i++) { + TL[i].pn = pn; + TL[i].t = i; + } + (*TR)->T = TL; + return; + } + + // This is the case T != 0 + nt = T->n; + TL = tcalloc(nt, sizeof(*(*TR)->T)); + for(i = 0; i < nt; i++) { + TL[i].pn = T->T[i].pn; + TL[i].t = T->T[i].t; + for(p = T->T[i].next; p; p = p->next) + insert_tranlist(TL[i], p, &((*TR)->mem)); + } + (*TR)->T = TL; +} + + + +pns ComposePN(pns* pn1, pns* pn2, struct tarray* T1, struct tarray* T2,\ + struct tarray **TR) { + +/* Returns the parallel composition of pn1 and pn2. + + The remaining parameters are ignored when TR = 0. + + The role of T1, T2, and TR is as follows. If TR != 0, then *TR is + initialized to an array of N elements, where N is the number of transitions + of the parallel composition of the two PNs. Thus, (*TR)[i] is the element + associated with the transition i of the PN result. Note that i = 0 ... N-1. + The element i of *TR lists all transitions (and the pns to which they + belong) that form the transition i of the PN result. T1 and T2 should be + zero if pn1 and pn2 are not the result of previous PN compositions. + Otherwise, T1 and T2 may be set to the *TR of the previous PN + compositions. */ + + + /* Algorithm of pn composition: - Create the vector "lcount". For all t of pn1 lcount(t) indicates how many times the label of t appears in pn2. For all t of pn2 lcount(t) is 1 if the label of t appears in pn1. Otherwise it is 0. @@ -763,13 +905,15 @@ */ int *lcount, np, np1, np2, nt, nt1, nt2, i, j, k, z, label; + pns pn; if(!pn1 && !pn2) { memset(&pn, 0, sizeof(pn)); + if(TR) *TR = 0; return pn; } - if(!pn1) return copypn(pn2); - if(!pn2) return copypn(pn1); + if(!pn1) { set_TR(pn2, T2, TR); return copypn(pn2);} + if(!pn2) { set_TR(pn1, T1, TR); return copypn(pn1);} nt1 = pn1->tnum; /* determine the number of transitions */ nt2 = pn2->tnum; @@ -810,6 +954,17 @@ /* Create the composed pn */ pn = createpn("pnum tnum", np, nt); + if(TR) // { // if TR is to be used, then allocate *TR + alloc_tarray(*TR, nt); + /* if(!nt) + *TR = 0; + else { + *TR = tcalloc(1, sizeof(**TR)); + (*TR)->n = nt; + (*TR)->T = tcalloc(nt, sizeof(*(*TR)->T)); + initalloc(&((*TR)->mem), 50*sizeof(*(*TR)->T)); + } + }*/ /* Initialize the capacity and marking entries */ @@ -843,6 +998,10 @@ Copy2ZeroColumn(&(pn2->in),j,&(pn.in),j,np1); Copy2ZeroColumn(&(pn2->out),j,&(pn.out),j,np1); } + if(TR) { + if(nt1) set_TR(pn1, T1, TR); + if(nt2) set_TR(pn2, T2, TR); + } return pn; } @@ -861,7 +1020,7 @@ /* Next the transitions of pn1 are considered */ - for(i = 0, z = 0; i < nt1; i++) { + for(i = 0, z = 0; i < nt1; i++) { // lcount[i] != 0 only if both pns labeled if(lcount[i]) { /* pn2 has lcount[i] transitions with the same label */ label = pn1->t[i].l; for(j = 0, k = 0; k < lcount[i]; j++) { @@ -887,7 +1046,7 @@ pn2->t[j].uncontrollable; pn.t[z].unobservable=pn1->t[i].unobservable | pn2->t[j].unobservable; pn.t[z].live = pn1->t[i].live | pn2->t[j].live; - + if(TR) update_TR(z, i, j, T1, T2, *TR); z++; /* z: number of next empty column in the matrices of pn */ k++; } @@ -903,6 +1062,7 @@ pn.t = tcalloc(pn.tnum,sizeof(pn.t[0]));/*elements initialized to 0*/ memcpy((pn.t)+z, (pn1->t)+i, sizeof(pn.t[0])); } + if(TR) update_TR(z, i, 0, T1, 0, *TR); z++; } } @@ -921,6 +1081,7 @@ pn.t = tcalloc(pn.tnum,sizeof(pn.t[0]));/*elements initialized to 0*/ memcpy((pn.t)+z, (pn2->t)+j, sizeof(pn.t[0])); } + if(TR) update_TR(z, 0, j, 0, T2, *TR); z++; } @@ -931,26 +1092,36 @@ -pns pn_composition(process** process_array, int num) { +pns PNComposition(process** process_array, int num, struct tarray **TR) { /* Composes the PNs in the process array and returns the result. */ pns pn, pn1, *apn; int i; + struct tarray *T; - if(num <= 0 || !process_array) + if(num <= 0 || !process_array) { memset(&pn, 0, sizeof(pn)); // return null pn - else if(num == 1) + if(TR) *TR = 0; + return pn; + } + else if(num == 1) { pn = copypn(process_array[0]->pn); - else { - apn = process_array[0]->pn; - for(i = 1; i < num; i++) { - if(i > 1) { - pn1 = pn; // save intermediary result for subsequent deallocation - apn = &pn1; - } - pn = composepn(apn, process_array[i]->pn); - if(i > 1) - deallocpn(&pn1); // free intermediary result + if(TR) set_TR(process_array[0]->pn, 0, TR); + return pn; + } + + apn = process_array[0]->pn; + for(i = 1, T = 0; i < num; i++) { + if(i > 1) { + pn1 = pn; // save intermediary result for subsequent deallocation + apn = &pn1; + if(TR) + T = *TR; } + pn = ComposePN(apn, process_array[i]->pn, T, 0, TR); + if(i > 1) + deallocpn(&pn1); // free intermediary result + if(T) + dealloc_tarray(T); } return pn; @@ -1220,22 +1391,27 @@ EXTRACTLHCB ****************************************************************************/ -/* This is a temporary implementation; future work should take in account that - sp can contain more general specifications */ - /* The implementation assumes that no disjunctive constraints are present. */ +struct _extractLCHB { + int i; + struct tarray* p; +}; -int find_var_index(variable* var, pns* pn, specs* sp) { + +struct _extractLCHB find_var_index(variable* var, pns* pn, specs* sp) { int i, k; int lab; + struct _extractLCHB u; if(var->type == MARKINGV) { if(var->index >= var->pn->pnum) merror(0, "EXTRACTLHCB: index %d >= place number (%d)", var->index, var->pn->pnum); for(i = 0, k = 0; i < sp->process_num; i++) { - if(var->pn == sp->process_array[i]->pn) - return var->index + k; + if(var->pn == sp->process_array[i]->pn) { + u.i = var->index + k; + return u; + } k += sp->process_array[i]->pn->pnum; } merror(0, "EXTRACTLHCB: Marking variable does not match specified PNs"); @@ -1245,12 +1421,15 @@ merror(0, "EXTRACTLHCB expects labeled Petri nets"); if(var->index >= var->pn->tnum) merror(0, "EXTRACTLHCB: index %d >= tran. number (%d)", var->index, var->pn->tnum); - lab = var->pn->t[var->index].l; - for(i = 0; i < pn->tnum; i++) - if(pn->t[i].l == lab) // Assumes free-labeled PN - return i; - merror(0, "EXTRACTLHCB: Variable does not match specified PNs"); + u.p = var->pn->data; + u.i = var->index; + /* lab = var->pn->t[var->index].l; + for(i = 0; i < pn->tnum; i++) + if(pn->t[i].l == lab) // Assumes free-labeled PN + return i; + merror(0, "EXTRACTLHCB: Variable does not match specified PNs"); */ } + return u; } void extractLHCB(specs* sp, pns* pn, matrix* L, matrix* H, matrix* C, int** B) { @@ -1260,11 +1439,33 @@ int cnum; /* constraint number */ variable* var; inequality* in; + struct tarray *TR; + struct tranlist *p; + void **data; + struct _extractLCHB u; /* Find the composed PN */ - *pn = pn_composition(sp->process_array, sp->process_num); + *pn = PNComposition(sp->process_array, sp->process_num, &TR); + if(!TR) + merror(0, "EXTRACTLHCB: PN composition failed to extract required data"); + + /* Extract from TR transition information */ + data = tcalloc(sp->process_num, sizeof(*data)); + for(i = 0; i < sp->process_num; i++) { /* save 'data' content of each pn */ + data[i] = sp->process_array[i]->pn->data; + alloc_tarray(sp->process_array[i]->pn->data, sp->process_array[i]->pn->tnum); + } + for(i = 0; i < TR->n; i++) { + for(p = (TR->T)+i; p; p = p->next) + if(p->pn) + insert_tranlist_sub(((struct tarray*) p->pn->data)->T[p->t], \ + pn, i, &((struct tarray*) p->pn->data)->mem); + /* 2nd par of insert_... must be nonzero; value not essential */ + } + + /* May be deleted after testing pn_composition above if(sp->process_num == 1) *pn = copypn(sp->process_array[0]->pn); @@ -1308,15 +1509,31 @@ merror(0, "EXTRACTLCHB: Unexpected expression format"); (*B)[i] = in->free_term; for(var = in->variable_list; var; var = var->next) { - j = find_var_index(var, pn, sp); - if(var->type == MARKINGV) - SetMatrixEl(L, i, j, var->coefficient + GetMatrixEl(L, i, j)); - if(var->type == FIRINGV) - SetMatrixEl(H, i, j, var->coefficient + GetMatrixEl(H, i, j)); - if(var->type == PARIKHV) - SetMatrixEl(C, i, j, var->coefficient + GetMatrixEl(C, i, j)); + u = find_var_index(var, pn, sp); + if(var->type == MARKINGV) /* L(i, u.i) = L(i, u.i) + var->coefficient */ + SetMatrixEl(L, i, u.i, var->coefficient + GetMatrixEl(L, i, u.i)); + else { + /* A loop is needed in order to account for ALL transitions of the + composed pn corresponding to var->index */ + for(p = (u.p)->T+(u.i); p; p++) { + if(!(p->pn)) break; + j = p->t; + if(var->type == FIRINGV) + SetMatrixEl(H, i, j, var->coefficient + GetMatrixEl(H, i, j)); + if(var->type == PARIKHV) + SetMatrixEl(C, i, j, var->coefficient + GetMatrixEl(C, i, j)); + } + } } } + + for(i = 0; i < sp->process_num; i++) {/* restore data content of each pn */ + dealloc_tarray(sp->process_array[i]->pn->data); + sp->process_array[i]->pn->data = data[i]; + } + free(data); + dealloc_tarray(TR); + } Modified: pnheaders/pns.h =================================================================== --- pnheaders/pns.h 2011-05-17 13:45:15 UTC (rev 249) +++ pnheaders/pns.h 2011-06-20 23:01:38 UTC (rev 250) @@ -121,6 +121,9 @@ in software. Note that arc_list[i] is the list of arcs corresponding to the transition i. Currently used for plant PNs, not supervisor PNs. */ + + void* data; /* provides a way to associate arbitrary data with a PN */ + } pns; @@ -218,9 +221,6 @@ void deallocpn(pns *pn); /* frees the space used by the arrays inside the pns structure */ -pns composepn(pns* p1, pns* p2); -/* Performs the parallel composition of two pns */ - void displaypn(pns pn, FILE *f); /* Write pn information into a file. */ @@ -232,7 +232,56 @@ /* Returns nonzero when t is a source transition of pn */ +/* The following structures are used in ComposePN in order to associate to + each transition of the composed PN the list of transitions from which it + is obtained. */ +struct tranlist { + pns* pn; + int t; /* the transition of pn */ + struct tranlist *next; +}; + +struct tarray { + struct tranlist *T; /* array of n elements */ + int n; /* the number of elements in the array T */ + struct alloc mem; // struct alloc defined in general.h for memory management +}; + +#define alloc_tarray(p,m) \ + if(!m) p = 0; \ + else { \ + p = tcalloc(1, sizeof(struct tarray)); \ + ((struct tarray*) (p))->n = m; \ + ((struct tarray*) (p))->T = tcalloc(m, sizeof(struct tranlist)); \ + initalloc(&(((struct tarray*) (p))->mem), 50*sizeof(struct tranlist)); \ + } + +inline void dealloc_tarray(struct tarray* p); /* in pns.c */ +/* deallocates everything, including p itself */ + + +pns ComposePN(pns* pn1, pns* pn2, struct tarray* T1, struct tarray* T2,\ + struct tarray **TR); +/* Returns the parallel composition of pn1 and pn2. + + The remaining parameters are ignored when TR = 0. + + The role of T1, T2, and TR is as follows. If TR != 0, then *TR is + initialized to an array of N elements, where N is the number of transitions + of the parallel composition of the two PNs. Thus, (*TR)[i] is the element + associated with the transition i of the PN result. Note that i = 0 ... N-1. + The element i of *TR lists all transitions (and the pns to which they + belong) that form the transition i of the PN result. T1 and T2 should be + zero if pn1 and pn2 are not the result of previous PN compositions. + Otherwise, T1 and T2 may be set to the *TR of the previous PN + compositions. */ + + +#define composepn(x,y) ComposePN(x,y,0,0,0); + + + #define MARKINGV 0 /* marking */ #define FIRINGV 1 /* firing vector */ #define PARIKHV 2 /* Parikh vector (firing count vector) */ @@ -354,12 +403,18 @@ char* instance; /* name of process instance */ pns* pn; /* underlying PN structure.*/ char* build; /* the command that should be used to build the process */ - char* include; /* What should be included at the beginning of the source + char* include; /* text to be included at the beginning of the source file of the process. */ + char* main; /* text to be included in the main function of the process */ + + char thread:1; /* set to 1 if process should be implemented as a thread */ + char supervisor:1; /* set to 1 if the process is a supervisor component */ + + /* The following are not used */ + int type:1; /* type = 1 indicates an external process */ int start:1; /* start = 1 if the supervisor should start this process */ - char thread:1; /* set to 1 if process should be implemented as a thread */ - char supervisor:1; /* set to 1 if the process is a supervisor component */ + } process; @@ -373,6 +428,20 @@ process **process_array; /* each array element contains the address of one process object */ int process_num; /* the number of elements of the process array */ + + char* include; /* text to be included at the beginning of the + supervisor file */ + char* main; /* text to be included in the main function of the supervisor */ + + char* sbuildparam; /* Indicates additional parameters that should be included + in the command line building main executable file. + Used in WriteMakefile of supervisorCompiler.c */ + unsigned char signals:1; /* if implementation should use signals */ + unsigned char sleep:1; /* if false, the supervisor does not enter a "sleep" + state when there are no events */ + unsig... [truncated message content] |
From: <mio...@us...> - 2011-07-28 19:40:20
|
Revision: 259 http://pntool.svn.sourceforge.net/pntool/?rev=259&view=rev Author: miordache Date: 2011-07-28 19:40:14 +0000 (Thu, 28 Jul 2011) Log Message: ----------- Modified Paths: -------------- old_versions/2011/newcodegen/SupervisorTemplate.c old_versions/2011/newcodegen/supervisorCompiler.c present_version/newcodegen/SupervisorTemplate.c present_version/newcodegen/supervisorCompiler.c Modified: old_versions/2011/newcodegen/SupervisorTemplate.c =================================================================== --- old_versions/2011/newcodegen/SupervisorTemplate.c 2011-07-28 16:39:24 UTC (rev 258) +++ old_versions/2011/newcodegen/SupervisorTemplate.c 2011-07-28 19:40:14 UTC (rev 259) @@ -786,8 +786,8 @@ } if( ! ___cpid) { // code execuded by child process ___upd_comm_param(0, ___pr, ___where); - execlp(___pname[___type], ___pname[___type], ___com, 0); - debugInfo("exclp was unable to start \"%s %s\"", ___pname[___type], ___com); + execl(___pname[___type], ___pname[___type], ___com, (char*)0); + debugInfo("excl was unable to start \"%s %s\"", ___pname[___type], ___com); ___ms.type = ___EXIT_NOTIFICATION; ___ms.id = ___pr; ___send_to_supervisor(&___ms, sizeof(___ms), ___pr); Modified: old_versions/2011/newcodegen/supervisorCompiler.c =================================================================== --- old_versions/2011/newcodegen/supervisorCompiler.c 2011-07-28 16:39:24 UTC (rev 258) +++ old_versions/2011/newcodegen/supervisorCompiler.c 2011-07-28 19:40:14 UTC (rev 259) @@ -840,7 +840,7 @@ if(prs[i]->name) if(strlen(prs[i]->name)) { if( ! prs[i]->thread ) - ins = FSInsert(ins, " \"%s.exe\"", prs[i]->name); + ins = FSInsert(ins, " \"./%s.exe\"", prs[i]->name); else ins = SInsert(" 0", ins); if(i == nprs - 1) @@ -949,7 +949,7 @@ #ifndef ___USE_PTHREAD_LIB fprintf(f, "\n\t$(COMPILER) -o %s.exe %s.c", sn, sn); #else - fprintf(f, "\n\t$(COMPILER) -lpthreads -o %s.exe %s.c", sn, sn); + fprintf(f, "\n\t$(COMPILER) -lpthread -o %s.exe %s.c", sn, sn); #endif for(i = 0; i < n; i++) if(thr[i]) @@ -985,7 +985,7 @@ #ifndef ___USE_PTHREAD_LIB fprintf(f, "\n\t$(COMPILER) -o %s.exe %s.c", prs[i]->name, prs[i]->name); #else - fprintf(f, "\n\t$(COMPILER) -lpthreads -o %s.exe %s.c", prs[i]->name, prs[i]->name); + fprintf(f, "\n\t$(COMPILER) -lpthread -o %s.exe %s.c", prs[i]->name, prs[i]->name); #endif } } Modified: present_version/newcodegen/SupervisorTemplate.c =================================================================== --- present_version/newcodegen/SupervisorTemplate.c 2011-07-28 16:39:24 UTC (rev 258) +++ present_version/newcodegen/SupervisorTemplate.c 2011-07-28 19:40:14 UTC (rev 259) @@ -786,8 +786,8 @@ } if( ! ___cpid) { // code execuded by child process ___upd_comm_param(0, ___pr, ___where); - execlp(___pname[___type], ___pname[___type], ___com, 0); - debugInfo("exclp was unable to start \"%s %s\"", ___pname[___type], ___com); + execl(___pname[___type], ___pname[___type], ___com, (char*)0); + debugInfo("excl was unable to start \"%s %s\"", ___pname[___type], ___com); ___ms.type = ___EXIT_NOTIFICATION; ___ms.id = ___pr; ___send_to_supervisor(&___ms, sizeof(___ms), ___pr); Modified: present_version/newcodegen/supervisorCompiler.c =================================================================== --- present_version/newcodegen/supervisorCompiler.c 2011-07-28 16:39:24 UTC (rev 258) +++ present_version/newcodegen/supervisorCompiler.c 2011-07-28 19:40:14 UTC (rev 259) @@ -840,7 +840,7 @@ if(prs[i]->name) if(strlen(prs[i]->name)) { if( ! prs[i]->thread ) - ins = FSInsert(ins, " \"%s.exe\"", prs[i]->name); + ins = FSInsert(ins, " \"./%s.exe\"", prs[i]->name); else ins = SInsert(" 0", ins); if(i == nprs - 1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mio...@us...> - 2011-09-05 12:28:11
|
Revision: 263 http://pntool.svn.sourceforge.net/pntool/?rev=263&view=rev Author: miordache Date: 2011-09-05 12:28:05 +0000 (Mon, 05 Sep 2011) Log Message: ----------- Modified Paths: -------------- old_versions/2011/pnheaders/pns.c present_version/pnheaders/pns.c Modified: old_versions/2011/pnheaders/pns.c =================================================================== --- old_versions/2011/pnheaders/pns.c 2011-08-27 01:53:21 UTC (rev 262) +++ old_versions/2011/pnheaders/pns.c 2011-09-05 12:28:05 UTC (rev 263) @@ -1662,9 +1662,6 @@ int i, a, n; char zL, zC; - if(n <= 0) - return 1; - zL = !L || !m; zC = !C || !v; @@ -1679,6 +1676,9 @@ else n = NumberOfRows(*C); + if(n <= 0) + return 1; + for(i = 0; i < n; i++) { a = 0; if(!zL) Modified: present_version/pnheaders/pns.c =================================================================== --- present_version/pnheaders/pns.c 2011-08-27 01:53:21 UTC (rev 262) +++ present_version/pnheaders/pns.c 2011-09-05 12:28:05 UTC (rev 263) @@ -1662,9 +1662,6 @@ int i, a, n; char zL, zC; - if(n <= 0) - return 1; - zL = !L || !m; zC = !C || !v; @@ -1679,6 +1676,9 @@ else n = NumberOfRows(*C); + if(n <= 0) + return 1; + for(i = 0; i < n; i++) { a = 0; if(!zL) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mio...@us...> - 2012-08-15 20:59:35
|
Revision: 264 http://pntool.svn.sourceforge.net/pntool/?rev=264&view=rev Author: miordache Date: 2012-08-15 20:59:28 +0000 (Wed, 15 Aug 2012) Log Message: ----------- update of old_versions folder Modified Paths: -------------- present_version/README.txt Added Paths: ----------- old_versions/version_1/ old_versions/version_1/LICENSE/ old_versions/version_1/Makefile old_versions/version_1/Makefile-cygwin.mak old_versions/version_1/Makefile-linux.mak old_versions/version_1/README.txt old_versions/version_1/doc/ old_versions/version_1/examples/ old_versions/version_1/newcodegen/ old_versions/version_1/parser/ old_versions/version_1/pnheaders/ old_versions/version_1/spnbox/ Copied: old_versions/version_1/Makefile (from rev 263, present_version/Makefile) =================================================================== --- old_versions/version_1/Makefile (rev 0) +++ old_versions/version_1/Makefile 2012-08-15 20:59:28 UTC (rev 264) @@ -0,0 +1,33 @@ +# This is the make file of the entire program. + + +COMPILER=gcc -g +LDFLAGS=-lm -ldl + +PNHEADERS=pnheaders +SPNBOX=spnbox +CODEGEN=newcodegen +CODEGENOBJS = $(CODEGEN) +TRANSLATOR=parser + +ct: objectfiles main_function2.o + $(COMPILER) -o ct $(PNHEADERS)/*.o $(CODEGENOBJS)/*.o $(SPNBOX)/*.o \ + main_function2.o $(SPNBOX)/*.a $(TRANSLATOR)/*.o $(LDFLAGS) + +objectfiles: + cd $(PNHEADERS); make + cd $(CODEGEN); make -f Makefile-linux.mak static + cd $(SPNBOX); make + cd $(TRANSLATOR); make + +main_function2.o: $(PNHEADERS)/main_function2.c $(PNHEADERS)/pns.h $(SPNBOX)/spnbox.h $(CODEGEN)/codegen.h + $(COMPILER) -c $(PNHEADERS)/main_function2.c -Ispnbox -I$(CODEGEN) -I$(PNHEADERS) + +clean: + rm -f main_function2.o + rm -f ct + cd $(PNHEADERS); make clean + cd $(CODEGEN); make -f Makefile-linux.mak clean + cd $(TRANSLATOR); make clean + cd $(SPNBOX); make clean + Copied: old_versions/version_1/Makefile-cygwin.mak (from rev 263, present_version/Makefile-cygwin.mak) =================================================================== --- old_versions/version_1/Makefile-cygwin.mak (rev 0) +++ old_versions/version_1/Makefile-cygwin.mak 2012-08-15 20:59:28 UTC (rev 264) @@ -0,0 +1,33 @@ +# This is the make file of the entire program. + + +COMPILER=gcc -g +LDFLAGS=-lm -ldl + +PNHEADERS=pnheaders +SPNBOX=spnbox +CODEGEN=newcodegen +CODEGENOBJS = $(CODEGEN) +TRANSLATOR=parser + +ct: objectfiles main_function2.o + $(COMPILER) -o ct $(PNHEADERS)/*.o $(CODEGENOBJS)/*.o $(SPNBOX)/*.o \ + main_function2.o $(SPNBOX)/*.a $(TRANSLATOR)/*.o $(LDFLAGS) + +objectfiles: + cd $(PNHEADERS); make + cd $(CODEGEN); make -f Makefile-cygwin.mak static + cd $(SPNBOX); make + cd $(TRANSLATOR); make + +main_function2.o: $(PNHEADERS)/main_function2.c $(PNHEADERS)/pns.h $(SPNBOX)/spnbox.h $(CODEGEN)/codegen.h + $(COMPILER) -c $(PNHEADERS)/main_function2.c -Ispnbox -I$(CODEGEN) -I$(PNHEADERS) + +clean: + rm -f main_function2.o + rm -f ct + cd $(PNHEADERS); make clean + cd $(CODEGEN); make -f Makefile-cygwin.mak clean + cd $(TRANSLATOR); make clean + cd $(SPNBOX); make clean + Copied: old_versions/version_1/Makefile-linux.mak (from rev 263, present_version/Makefile-linux.mak) =================================================================== --- old_versions/version_1/Makefile-linux.mak (rev 0) +++ old_versions/version_1/Makefile-linux.mak 2012-08-15 20:59:28 UTC (rev 264) @@ -0,0 +1,33 @@ +# This is the make file of the entire program. + + +COMPILER=gcc -g +LDFLAGS=-lm -ldl + +PNHEADERS=pnheaders +SPNBOX=spnbox +CODEGEN=newcodegen +CODEGENOBJS = $(CODEGEN) +TRANSLATOR=parser + +ct: objectfiles main_function2.o + $(COMPILER) -o ct $(PNHEADERS)/*.o $(CODEGENOBJS)/*.o $(SPNBOX)/*.o \ + main_function2.o $(SPNBOX)/*.a $(TRANSLATOR)/*.o $(LDFLAGS) + +objectfiles: + cd $(PNHEADERS); make + cd $(CODEGEN); make -f Makefile-linux.mak static + cd $(SPNBOX); make + cd $(TRANSLATOR); make + +main_function2.o: $(PNHEADERS)/main_function2.c $(PNHEADERS)/pns.h $(SPNBOX)/spnbox.h $(CODEGEN)/codegen.h + $(COMPILER) -c $(PNHEADERS)/main_function2.c -Ispnbox -I$(CODEGEN) -I$(PNHEADERS) + +clean: + rm -f main_function2.o + rm -f ct + cd $(PNHEADERS); make clean + cd $(CODEGEN); make -f Makefile-linux.mak clean + cd $(TRANSLATOR); make clean + cd $(SPNBOX); make clean + Copied: old_versions/version_1/README.txt (from rev 263, present_version/README.txt) =================================================================== --- old_versions/version_1/README.txt (rev 0) +++ old_versions/version_1/README.txt 2012-08-15 20:59:28 UTC (rev 264) @@ -0,0 +1,17 @@ +To build the software, copy first the directory third-party from the directory +of the current version to this directory. + +Use the command "make" to build the program. + + +After building the software you may use it as follows: + +1) Write the specification file. + +2) Copy ProcessTemplate.c, SupervisorTemplate.c, and spcommon.h from newcodegen to the working directory. These are skeleton files for the concurrency code. + +3) Run the concurrency software. This will build the source code files specified in the specification file. + +4) Build your application with the generated makefile. + + Modified: present_version/README.txt =================================================================== --- present_version/README.txt 2011-09-05 12:28:05 UTC (rev 263) +++ present_version/README.txt 2012-08-15 20:59:28 UTC (rev 264) @@ -8,4 +8,3 @@ 4) Build your application with the generated makefile. - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |