POLIS Programmers' Guide
 

 

POLIS Programmers' Guide

The information in this text is derived from many messages exchanged between the members of the hardware-software codesign team. The author of this document is Ellen M. Sentovich currently at Ecole des Mines de Paris, Centre de Mathématiques Appliquées, B.P. 207, F, 06904 Sophia-Antipolis Cedex, FRANCE; ellen@cma.cma.fr.

Contents

1 Introduction

  This document is for the benefit of POLIS programmers. It summarizes information that has been disseminated within the group since its inception. Members of the group are encouraged to contribute updates and corrections as necessary.

2 Creating POLIS in a new location

 

2.1 Initial set up

  Edit your .cshrc file at UCB and the new location:

  1. Set the ARCH variable using the following sequence:
    		if ( -e /bin/arch ) then
    		    setenv ARCH `/bin/arch`
    		else if ( -e /bin/machine ) then
    		    setenv ARCH `/bin/machine`
    		else if (-e /bin/mach ) then
    		    setenv ARCH `/bin/mach`
    		endif
  2. Add the POLIS path to the path variable (e.g. add some_root_path/hwsw/$(ARCH)/bin).

For new POLIS programmers: have your login added to the hwsw group at UCB.

2.2 Creating a new distribution at UCB

  Let the name of the new location be nl. Execute the following:

    cd /projects/hwsw/hwsw/common/src
    mkdir for_nl
    chmod g+w for_nl
    cd polis
    co -l Makefile.src
    vi Makefile.src
Add the for_nl and for_nl_force rules (see examples in the Makefile).
    ci -u Makefile.src
    make Makefile
    cd ..
    tar cf - polis | gzip > for_nl/polis.tar.gz
    touch for_nl/bundle
    chmod g+w for_nl/bundle

2.3 Directory structure setup

  Let root_hwsw be the root directory at the new location (e.g. /projects/hwsw/hwsw).

    cd root_hwsw
    mkdir sun4
Create directories for each architecture.
    mkdir sun4/bin
    mkdir sun4/lib
    mkdir common
    mkdir common/src

2.4 FTPing the files

  From the new location:

    cd root_hwsw/common/src
    ftp 128.32.168.7
    binary
    cd /projects/hwsw/hwsw/common/src/for_nl
    get polis.tar.Z
    quit
At UCB, execute rm polis.tar.Z.

Note that you will need the mm libraries at the new location too. Instructions for getting and compiling those are not contained here. If you don't have them and can't get them, either compile POLIS without the -g options (make libpolis.a, make polis), or remove the references to libmm*.a from util/Makefile*.beg and/or from the root Makefile.

    gunzip polis.tar.Z
    tar xmf polis.tar
The m is important so that the modification times are consistent.
    rm polis.tar
    cd polis
%    make strip_depend

2.5 Initial script installation

  On any machine, set up the scripts by compiling them in the common area. These scripts are later used to create the shadow source trees, at which point the scripts for each architecture are built. Execute the following commands:

    cd root_hwsw/common/src/polis/util
    co -l makemakefile.sh
    vi makemakefile.sh
Change the POLIS variable.
    ci -u makemakefile.sh
    source makemakefile.sh
    make	
    rehash

2.6 Creating the Makefiles and Linking Header Files

 

    cd root_hwsw/common/src/polis/util
    co -l Make.sh Makefile.leaf.beg Makefile.non_leaf.beg Makefile.strl.beg Shell.sh
    vi Make.sh Makefile.leaf.beg Makefile.non_leaf.beg Makefile.strl.beg Shell.sh
Set the POLIS variable appropriately: POLIS = root_hwsw/$(ARCH). To make the Makefiles:
    cd root_hwsw/common/src/polis
    makemakefile_all

To link the header files:

    cd root_hwsw/common/src/polis
    mkdir include (in fact, all the include directories need to be created)
    make link_header

Remake the makefiles since now they will find the header files:

    cd root_hwsw/common/src/polis
    makemakefile_all

2.7 Creating the architecture-specific source links

  Create the shadow source trees for each architecture, linking the include and lib directories. For each architecture:

    cd root_hwsw/$ARCH
    ln -s ../common/src/polis/include
    ln -s ../common/src/polis/polis_lib
    mkdir src
    cd src
    rslink ../../common/src/polis polis
In the common directory:
    cd root_hwsw/common
    ln -s src/polis/polis_lib

2.8 Script installation for each architecture

  Execute the following commands for each architecture (you should be logged onto a machine of that architecture, so that everything is installed correctly):

    cd root_hwsw/$(ARCH)/src/polis/util
    make

2.9 Compiling

  For each architecture:

    cd root_hwsw/$ARCH/src/polis
    Make install
It may be necessary to do a ``make clean'' before each compile, since the source file linking may have linked some yacc and lex generated files to files in the common subdirectory.

2.10 Testing

 

    cd root_hwsw/$ARCH/src/polis/examples/test
    make clean
    make
    make clean

2.11 Results

  Main programs in $POLIS/bin:

polis :
The main program for synthesis of mixed HW/SW systems.
golden_gate :
The program for graphically creating SHIFT descriptions of reactive systems in a Tcl/Tk environment.
autoload, booleqn, booleqn_print, range, table :
The suite of programs used by golden_gate.
a2n, e2s, s2s :
The suite of programs for creating SHIFT from ESTEREL. e2s creates SIF intermediate files from each Esterel file; s2s creates a SHIFT file from a SIF file; a2n creates a single SHIFT file from a set of sub-SHIFT files and an auxiliary file which defines constants, etc.

Utility scripts in $POLIS/bin:
Make :
Program for making POLIS in the architecture source directory and locking the directory while doing the Make.
makemakefile :
Updates the Makefile in the current directory from Makefile.src and the leaf Makefiles.
makemakefile_all :
Runs makemakefile in the current directory and recursively through all subdirectories.
rslink :
Updates links in the shadow source trees for various architectures.

2.12 Updates

Updates to an installation procede similarly. At UCB:

    cd /projects/hwsw/hwsw/common/src/polis
    make for_nl
FTP for_nl/polis.tar.Z to the root_hwsw/common/src/polis directory and execute gunzip polis.tar.Z; tar xf polis.tar; rm polis.tar. If the extraction works properly, remove polis.tar.Z from the common area at UCB. After this, follow the instructions in Section 3.2 to completely update directory and recompile.

3 General procedure for installing POLIS code

 

3.1 Code Overview

  There are 3 places where code development and changes take place:

  1. The main code repository is /projects/hwsw/hwsw/common/src/polis at UCB. (This directory is often referred to here simply as polis.) Shadow directories exist for each architecture (e.g. /projects/hwsw/hwsw/mips). These contain links to the main code and this is where all the compiling is done.
  2. Code development is also done at remote locations, and the Makefiles provide rules for updating those sites as needed (see the for_site targets in polis/Makefile).
  3. Individual packages are usually duplicated by the owners in their home directories.
For installing POLIS at a new location, see Section 2. The information therein is also useful for setting up parts of POLIS in one's own directories for code development. The POLIS code itself can be divided into 3 groups:
Main programs:
polis, golden_gate, strl2shift.
POLIS code:
subdirectories (non-leaf packages with no code such as sw) which contain the leaf packages (such as sw/sg) where all the code resides. Code includes files: *.[ylch]; code directories include also *.doc, Makefile.src. Permanent files in all directories, as defined by the RCS_pattern variable in the Makefiles include *.[ylch], *.doc, Makefile.src, *.sh, *.pl, *.blif, *.txt, Makefile.*leaf*, *.1, *.strl, *.aux *.shift.
Auxiliary files:
polis_lib (help files, start-up scripts, other files used at run-time), examples, libraries (for creating the OS, etc.).

Makefiles for all directories and subdirectories are standardized and set up to be automatically created and updated. In general, it is best to look at a stable existing package to see how to set up the packages correctly. In brief, code development involves

  • writing, debugging, de-linting, and leak-freeing code in your own area
  • installing the code in the common area using RCS
  • re-compiling the libraries and binaries in the public, architecture-specific areas
  • testing the new compilation on standard examples.

General guidelines follow.

3.2 General instructions for code installation

  The following is a quick summary of commands to be executed after installing new code in the common area, or to update links in your own directories, or to update a remote distribution. Sections 2 and 3.5 contain more detailed information about some of these tasks.

Code installation:

  Install the new code in the common area:

  • *.c, *.h, *.doc files go in the proper directories and should be checked into RCS; new directories should have correct permissions and contain an RCS directory. See Sections 3.5 and 3.6.
  • Help files (*.1) are installed in polis/polis_lib/help and checked-in to RCS.
  • Update Makefile.src and run make makefile as necessary.
  • Update header file links as necessary, e.g. make link_header; cd /projects/hwsw/hwsw/common/src/polis; make link_header.

  • When larger or unknown changes are made (e.g., code is updated on a remote location) update all the Makefiles in the common area: cd /projects/hwsw/hwsw/common/src/polis/util; makemakefile; cd /projects/hwsw/hwsw/common/src/polis; make makefile. In extreme cases, force the update of all Makefiles: cd /projects/hwsw/hwsw/common/src/polis; make makefile_force.

Architecture updates:

  Update the code links, the Makefiles, and the header-file links: rsh $(ARCH)_machine; cd /projects/hwsw/hwsw/$(ARCH)/src/polis; make rslink; cd util; make; cd ..; make makefile; make link_header; make makefile. This second invokation is needed now that the header files are correctly linked. Again, for large or unknown changes, it is best to execute makemakefile_all or make makefile_force (only in the common directory). (For directories in your home directory that you are using for code development, note that you will also have to issue make depend if you want robust dependency-based compilation.)

Compilation:

  cd /projects/hwsw/hwsw/$(ARCH)/src/polis; Make. Do not interrupt compilation, or if you must, remove all object and library files afterward. Make locks the compilation. If it is already locked by someone else and you are sure they are finished, remove or move the file .make_lock and inform the owner.

Testing:

cd /projects/hwsw/hwsw/$(ARCH)/src/polis/examples/test; make

Dissemination:

Inform the polis group by e-mail of the changes.

3.3 Creating new leaf packages and subdirectories

  This section contains information about the POLIS code structure, i.e., the subdirectories and leaf packages (leaf subdirectories) contained in /projects/hwsw/hwsw/common/src/polis.

  • Each leaf package (e.g. sg, in general pkg) contains:
    RCS
    directory containing all files matching the RCS_pattern defined in polis/util/Makefile.non_leaf.beg.
    Makefile.src, OWNER
    (see existing packages for examples). The OWNER list indicates the main package developers.
    com_pkg.c
    file containing the com_commandname routines, the package daemon routines if there are any, the init_pkg routine which defines all commands and registers the daemons, and the end_pkg routine, which frees memory.
    pkg.c
    file containing memory management routines for the package and basic routines for filling and accessing the main data structures of the package.
    pkg.h
    file containing data structure definitions, access macros, and external function definitions.
    pkg_int.h
    fine containing internal data structure definitions, access macros, and function definitions. Internal means not to be used outside of this package.
    pkg.doc
    file containing programmer's documentation for external routines.
    *.cyl
    files containing the remainder of the code.

    In addition, a commandname.1 file should be created for each new command and installed in polis/polis_lib/help.

  • Each subdirectory (e.g. sw, in general subdir) contains
    RCS
    directory containing all files matching the RCS_pattern defined in polis/util/Makefile.non_leaf.beg. (This is probably only Makefile.src in this directory.)
    Makefile.src, OWNER
    (see existing packages for examples).
    subdir_main
    special directory containing the code for package interaction with POLIS. subdir_main contains:
    RCS, Makefile.src, OWNER
    see existing packages for examples.
    subdir_main.c
    file containing init_subdir() (calling init_pkg1(), init_pkg2(), etc.) and end_subdir() to be called by the POLIS initialization routines. This file also contains C-code relevant to the entire subdir package.
    subdir.h
    file containing includes for all the leaf packages contained, and any external declarations relevant to the entire package.
    *.c
    files containing other C-code relevant to the entire subdir package.

    dirs
    subdirectories or leaf-package directories. the package daemon routines if there are any, the init_pkg routine which defines all commands and registers the daemons, and the end_pkg routine, which frees memory.

  • Creating Makefile.src files
    • In general, model the Makefiles after existing ones, using the same defined variables, etc. Not all of the Makefiles use all the available defined variables (e.g. MYCFLAGS); see polis/util/Makefile* for the variables that are used for leaf Makefiles, non-leaf Makefiles, and Esterel example directory Makefiles.
    • Non-leaf packages should contain
      P: the package name
      DIRS: the subdirectories where compilation occurs
      AUXDIRS: all directories that must be cleaned, traversed when making Makefiles, etc. (e.g., test, documentation).
      INSTDIRS: all directories that in addition to cleaning, etc., must be traversed when making install

    • Leaf packages should contain
      P: the package name
      PSRC: the source files (all .c files)
      GLBHDR: header files that must be exported (used by other packages).
      LOCHDR: other (local) header files
      PHDR: usually the union of the above two
      MISC: other interesting files

    • They can contain some specific compilation rules, e.g. for yacc and lex. Look at existing packages (e.g. cfsm/s_io) and follow the models.
    • An individual Makefile can be updated with make makefile when the Makefile leafs are changed or Makefile.src is changed, or forced to be remade with with make makefile_force or equivalently makemakefile. This should only be done in the common subdirectory. The Makefiles are recursively updated (down the hierarchy from the current point) with makemakefile_all. This should only be done in the common directory.
  • Installing a new package or subdirectory
    • Follow the instructions in Section 3.2 for code installation.
    • Change the initialization routine in polis/main/init.c to call init_pkg() and end_pkg().
    • Include your header files in the main header file polis.h. This must be adjusted depending on where you are in the polis hierarchy. For example, init_sg() is part of the sw package, and so init_polis() calls init_sw() which calls init_sg().
    • Follow the instructions in Section 3.2 for architecture updates: re-do source linking, header linking, and create and update the Makefiles in the architecture-specific directories.
  • Compiling and testing
    • Follow the instructions in Section 3.2 for compilation.
    • In your own area, before installing code, issue make lint and/or compile with CC=gcc for more robust error checking.

3.4 Creating new programs

To create a new POLIS auxiliary program (e.g. golden_gate, strl2shift), follow the existing models. Note also

  • The program should be listed in the INSTDIRS variable of the parent package Makefile.src if it requires the installation of libraries or binaries in $POLIS.
  • If a library for the program needs to be installed in $POLIS/lib (e.g. libpolis.a or the strl2shift/strlutil library), the following rules should appear in Makefile.src:
    	install: install_lib
  • If an executable for a NON-LEAF package needs to be installed in $POLIS/bin (e.g autoload, a2n etc.), the following rules should appear in Makefile.src:
    	install: install_bin

3.5 Using RCS

  Each directory should have an RCS subdirectory. Directories and files are created and maintained according to the following rules.

Updating files
To update file.c in an existing directory, execute co -l file.c; vi file.c; ci -u file.c. This checks out the file with a lock (which prevents access by other programmers), and checks it back in unlocked. Supply a useful message about the updates when prompted by RCS.
New files
To add a new file file.c to an existing directory, execute ci -u file.c; rcs -A/projects/hwsw/hwsw/common/src/polis/main/polis.c file.c. The ci command will prompt you to supply a useful message about the purpose of the file.

New directories
To add a new directory called dir: mkdir dir; chgrp hwsw dir; chmod g+w dir; cd dir; cp my_files dir; mkdir RCS; chgrp hwsw RCS; chmod g+w RCS, where my_files contain the new C-code, header files, documentation files, and Makefile.src. Then check-in all the files that match the RCS_pattern defined in polis/util/Makefile.non_leaf.beg. Check them in following the instructions above for new files.

Some additional notes on the use of RCS:
  • After a long editing session, use make ci_rcs in the root directory. It checks back in all writable, RCS-maintained (see RCS_Pattern in the Makefiles) files. Similarly, if you want to check out everything (especially useful in your own copy of the tree), use make co_rcs.
  • To see the history of a file run rlog filename.
  • To see the differences between the current version and the last version, run rlog to find out the previous version number (e.g. 1), then rcsdiff -r1 filename.

3.6 File Permissions

  It is absolutely imperative that the file permissions are maintained correctly. Using RCS (see Section 3.5) permits organization of file revision and proper file permissions. For other files (examples, auxiliary files, etc.) and for directories, permissions must be explicitly maintained correctly. If the instructions in Section 3.5 are followed carefully, the permissions will be set up correctly. Nonetheless, it is often useful to execute the following in a new directory of files:

find . -type f -exec chmod g+w {} ';'
find . -type f -exec chgrp hwsw {} ';'
or execute
find . -type d -exec chmod g+w {} ';'
find . -type d -exec chgrp hwsw {} ';'
in an updated directory tree (both common and machine-dependent) on ic.

3.7 Automatic Documentation

  Programmers documentation in HTML format is automatically generated with the addition of some simple text in the source files. Makefiles are being set up so that documentation is automatically extracted from the files com_pkg.c, pkg_*.c, pkg.h, and pkg_int.h. To set up this documentation in your package:

  1. The beginning of each file should have the original RCS section at the top then the include files.
  2. Just after the includes, copy the file .../polis/util/extdoc_templates/template.c (or template.h as appropriate) into the source file. Fill in the blanks. (This also has a small RCS section - just leave it in.)
  3. For each function (macro) within that file that you want to be publicly documented, copy the file .../polis/util/extdoc_templates/function (macro) into your source file just above the beginning of the function. Fill in the blanks.
  4. Move one directory level up, and run extdoc -KR -html pkg, then chmod g+w *html, then mv *html /projects/hwsw/hwsw/common/mosaic/hsc/packages (verify your pages first in your own directory using Netscape and the "Open file" option in the File menu).
  5. View the final documentation from http://embedded.eecs.berkeley.edu/Respep/Research/hsc/abstract.html.

In addition, note that
  • External functions must adhere to the convention that they have names of the form pkg_name; the exceptions are init_pkg and end_pkg. Also, since there is no prefix for macros, there is no distinction between external or internal macros.
  • The hyperlink defined for "See also" only works for cross references within a same package.
  • To document internal functions, insert headers and change the function names to pkgname instead of pkg_name; otherwise the package header extraction mechanism will consider the function as exported. This of course will potentially affect every file in the same package so it is entirely optional.
  • Auxiliary documents written in Latex (e.g., a document describing the general principles of OS generation) can be converted to html format using latex2html. Some hints:
    • Use simple latex commands.
    • Avoid extra blank lines, as latex2html takes them literally.
    • The ~\ref latex command works beautifully.
    • Convert latex to html with latex2html -split 0 to generate only a single html file.
    • The resulting html file can be converted to plain text using lynx -dump file:file_path_name.html > file.txt.

3.8 Notes on using the shell scripts and make targets

 

rslink :
use this whenever you install new code in the common directory. Go to the src/polis directory of each specific architecture and run make rslink. The shadow trees will be updated.
make makefile :
use this whenever you update a Makefile.src in a leaf directory (to add new source directories, for example). Issue this command only from the common subtree.
makemakefile :
Shell :
This should be used while updating the common tree. Execute it by typing "Shell". This locks the tree and puts you in a C shell. Do whatever you need (quickly) to update the master tree. Type exit to leave the shell and unlock the tree.

3.9 On interacting with the POLIS group

  Information of interest to POLIS developers goes to polis@eecs.berkeley.edu. General information on hwsw codesign issues goes to hwsw@eecs.berkeley.edu. Questions and comments on individual packages go to the OWNERS of the package. Keep the bandwidth on e-mail down! Don't respond simply with "I agree". Only include the relevant parts of a previous message.

4 Notes on C-programming

  This section contains a number of helpful hints for C-programming in POLIS. It is no substitute for reading a good programming manual, but does contain information that has been needed in particular in POLIS in the past. See also John Ousterhout's programming style document in /vol/hyper/hyper14/vis/vis/common/doc/TclEngineering/engManual.ps.

Robust switch statements:

For robustness, an if-then-else test on a two-valued enumerated type should be done with a switch with a default failure. In this way, one can later add a third value to the enum and get a nice core dump rather than a nasty wrong result. For example:

            switch (net_trel_out_type (out)) {
            case CONST:
                val = net_trel_out_value (out);
                assert (val < nval);
                break;
            case VAR:
                val = net_var_nval (var) +
                    net_var_index (net_trel_out_var (out));
                break;
            default:
                fail ("invalid net_trel_out_type");
            }
This example also shows (1) judicious use of assertions and (2) how to use access functions rather than directly accessing data structures.

Naming data structures and routines:

Names of generally accessible data structures and procedures (that is, everything that is not static) should be prefaced with a short package indicator (e.g. net_). All such procedures should be externally declared in the header file (e.g. net.h). All static procedures and internal data structures should be declared in the appropriate internal header file (e.g. net_int.h).

On data structure duplication:

Avoid duplicating objects whenever possible. Example: the s-graph package has pointers to CFSM variables (ivar and ovar). Should we do a net_var_copy (i.e. duplicate the whole variable) or just assign the pointer? Don't duplicate if possible. Pointer copying is usually safe, this saves memory, and this way comparison for equality can be done just by pointer comparison, symbol tables can use just st_ptrhash and st_ptrcmp, and so on. Note that for strings this is slightly different - it is easy and often safer to copy them. There is more on this issue in the archives. Of course, remember that whoever allocates data should free it.

On allocating strings:

Use the util_strsav() function whenever possible. You will avoid mistakes such as under-allocating space.

On setting variables to NIL after freeing:

Don't set a call-by-value variable to NIL in ``free'' functions. This is useless and misleading for two reasons: the value is not passed back to the calling environment, and you are not setting to NIL all other references to that variable. It is also useless to set the FREED fields to an illegal value, because this is done automatically by libmm_p.a.

On testing for NIL values:

Avoid simply testing if a parameter is NIL and aborting. You get exactly the same result as you do when using the NIL pointer, but waste time and space. Note that testing for NIL and taking corrective action, on the other hand, is useful and should be done whenever appropriate.

On using data structure fields:

Don't use data structure fields directly in packages other than that where the data structure is defined. Use access functions instead.

On memory leaks:

A memory leak is any area of memory that is allocated but not freed. POLIS should have none, with a few exceptions due to system I/O buffer allocations. At Berkeley, we have been using mprof on DEC MIPS machines. Purify should be used at locations with SUN workstations and the proper software. To use mprof, compile POLIS, linking with luciano/util/mprof/libc_mp.a instead of whatever_dir/libmm.a. Run luciano/util/mprof/mprof executable_name (probably polis-g) with a few commands of your choice (if possible exercising all the options of your package), and quit. Then issue mprof -terse polis-g and have a look at the leak table. It gives a short stack backtrace of every leak.

On printing information programmatically:

Don't just arbitrarily choose stdout or stderr to send to printing routines. Every non-top-level (i.e., non-exported) routine that prints some output should get a FILE* parameter. Top-level calls, from comamnd line interface or from other routines, should use the polisout and poliserr file pointers ONLY. Polisout is for debugging and generic information, while poliserr is for error messages.

On using the basic data structures (hash tables, arrays, etc.):

The basic data structures that come with polis (arrays, lists, symbol tables AVL trees, sparse matrices, directed graphs, BDDs, MDDs) serve different purposes and should be used appropriately. For example, if you need to generate a list of unique elements (i.e., check if an object is already in the structure, and insert it otherwise), then you should use a symbol table (or an AVL tree, if you need to retrieve them sorted by insertion key).

Brief cross-reference - definitions and optimal use:

array:
Array package, which has efficient dynamic insertion and access. Inefficient deletion and search other than by index. Sorting primitives are available. These can be used to to produce arrays which contain only one instance of each element (usually a hash table is better for this, sometimes there are other reasons for arrays). Rather than doing a O(n2) search before every insertion, insert unconditionally, sort and then delete duplicated adjacent elements (there are primitives for both) with O(n log n) complexity.
list:
List package, with efficient dynamic insertion and deletion. Inefficient access and search other than sequentially. Larger overhead than arrays. Sorting primitives available.
st:
Symbol table package, with efficient dynamic insertion, deletion and search (both sequentially and by key). Larger overhead than arrays and lists. Excellent to emulate pointer-sized data structure fields when you are not yet sure whether or not you need them (or when they are used in a very specific section of the code).
avl:
AVL tree package, which is like symbol table, but allows sequential access sorted by key, while symbol table sequential access generates items in random order.
sparse:
Sparse matrix package, which is like list, but two-dimensional. Efficient column covering algorithms available.
graph:
General-purpose digraph pacakge, with slots for user data and efficient traversal and depth-first search.
bdd, mdd:
The BDD and MDD packages don't require any explanation (except for a recommendation not to use cofactoring for simulation).

Macros:

Remember that macro arguments must be put in parentheses in the macro body. For example:

#define foreach_net_node_attribute(node,name,value) \
{ st_generator  *gen;\
    st_foreach_item(node->attributes,gen,&name,&value) }
must become
#define foreach_net_node_attribute(node,name,value) \
{ st_generator  *gen;\
    st_foreach_item((node)->attributes,gen,&(name),&(value)) }

On gcc:

gcc should be used for development. The advantage of using an ANSI compiler is that we can check parameter type compatibility during each compilation. gcc will tell you if you call a function with a parameter that is inconsistent with its declaration (or whose declaration is missing from the scope where you use it). It will also tell you if the definition of a function in a .c file matches its extern declaration in a .h file. Ideally, each package should compile without warnings.

On lint:

The use of lint should get rid of programming errors such as uninitialized variables. Luciano wrote a (heuristic) lint filter that will remove spurious errors deriving from any use of the FREE macro and of the array package. Anything else should be considered a problem (except in files produced by yacc/lex, which are notoriously full of lint problems). Do a make lint from time to time in your directory to make sure that your code is ``lint free''.

On using cc, gcc, and lint together:

cc is used to produce object files (so that dbx and ups can work). gcc and lint are used to check for programming errors, by doing make lint. They produce an output (filtered, to remove junk errors) both to the terminal and to a file called lint.out. There is also a utility that is automatically called when you are making lint in the source tree. It e-mails lint warnings to the OWNER of each package and subpackage.

Bug finding and fixing:

When a bug is found:

  1. Assign it a probable culprit package/command/file and a number.
  2. Create a directory in /projects/hwsw/hwsw/common/src/polis/BUGS/your_name with the bug name and number, e.g., BUGS/jurecska/net_to_blif.1.
  3. Copy into that directory a SCRIPT (that can be run in a shell or from polis - NOT a log file) and a set of DATA FILES (e.g., shift, esterel files) that are minimally sufficient to re-create the bug. Conciseness here is essential because
    1. it speeds up the debugging work
    2. it will speed up regression testing
    In particular, do not include Makefiles or source files used indirectly to re-create the data files. This is because the more programs (strl2shift, make, etc.) that are involved, the more difficult it can be to re-create and pinpoint the problem.
  4. chmod g+w all files so that when the bug is fixed it can be moved to OLDBUGS.
  5. Send e-mail to the OWNER of the package and Luciano. You may also send e-mail to polis if the bug seems to be fatal and may hinder someone else's work. The e-mail should contain a session log describing where you were when the problem occurred (machine, architecture, executables) and what happened.

Whenever a bug is fixed, put the list of fixed bugs in an e-mail that announces the update to the source tree. Now the bug-finder can test the updated code, and if it works, move the bug information to, e.g., polis/OLDBUGS/luciano.

5 Examples

  Compiling the resulting C-files: compile os.c and z_*.c generated by polis with -I<lib site>. In practice, <lib site> is usually polis_lib/os.

6 References

 

About this document ...

POLIS Programmers' Guide

This document was generated using the LaTeX2HTML translator Version 0.6.4 (Tues Aug 30 1994) Copyright © 1993, 1994, Nikos Drakos, Computer Based Learning Unit, University of Leeds.

The command line arguments were:
latex2html -split 0 -show_section_numbers polis_prog.tex.

The translation was initiated by Luciano Lavagno on Fri Aug 2 15:15:30 PDT 1996


Luciano Lavagno
Fri Aug 2 15:15:30 PDT 1996
Contact 
©2002-2018 U.C. Regents