MULTICS TECHNICAL BULLETIN                             MTB-738-03

To:       MTB Distribution

From:     Doug Howe

Date:     November 13, 1986

Subject:  Changes Required to List Init

               -----------------------------------

1.  Abstract

This MTB  describes the changes  required to list_init_  to allow
external pointers to be initialized to nonconstant values.

Revision 1:
The changes  made concern the  comments made toward  MCR 7395 and
MCR 7396.  The changes also  include changes to the documentation
and changes to linkage_errors.gi.info and manual CH026.

Revision 2:
The changes made clean up the documentation changes.

Revision 3:                                                       |
The changes made reflect MCR 7420 and MCR 7421.                   |

               -----------------------------------


MTB-738-03                     Changes Required to List Init by C

Comments should be sent to the authors:

     via Multics mail to:

        DGHowe.Multics

     via posted mail to:

        Douglas G.  Howe
        Advanced Computing Technology Centre
        Foothills Professional Building
        1620 29th St., N.W.
        Calgary Alberta Canada   T2N-4L7

     via telephone to:

        (403)-284-6400
        (403)-284-6437 (Howe)

     via forum on System-M to:

        >udd>m>DGHowe>mtgs_dir>c>c_imp (c)


Changes Required to List Init by C                     MTB-738-03

                        TABLE OF CONTENTS

Section    Page  Subject
=======    ====  =======

1          i     Abstract
2          1     Preface
3          2     Introduction
3.1        3     . . References For This Document
4          4     Background
5          5     General
6          5     Proposal
7          5     Structure Definition
8          8     Changes to list_init_
9          9     Other Required Changes
10         9     Routine Change List
11         11    Error Handling in list_init_
12         13    Include File Changes
13         13    Documentation Changes
14         13    Summary
15         14    Appendix A
16         17    Appendix B
17         24    Appendix C
18         25    Appendix D
19         31    Appendix E
20         35    Appendix F
21         39    Appendix G
22         43    Appendix H


Changes Required to List Init by C                     MTB-738-03

2.  Preface

This MTB  along with MTBs 691,  647, 732 and 733  are intended to
give a full explanation of how C will execute under Multics.


MTB-738-03                     Changes Required to List Init by C

3.  Introduction

There are various possibilities for implementing external pointer
initialization.   These  possibilities  are,  introducing  a  new
initialization   type  or   redeveloping  one   of  the  existing
initialization types.

Developing a new initialization type similar to the list template
structure  seemed  to  be  the  only  viable  alternative.  This,
however  would result  in a  large amount  of duplication  of the
functionality  already  performed  by  list_init_  and its caller
set_ext_variable_.

It was  therefore decided that the  existing list_init_ structure
should be used.  list_init_ was chosen because of its ability for
data  compression and the  ease that the  change fitted into  the
existing structure.  This MTB will  define the changes to be made
to the list_init_ structure.


Changes Required to List Init by C                     MTB-738-03

3.1.  References For This Document

1) MTB-647 created by Greg Baryza.

2) The C Programming Language
   Kernighan, Brian W.  & Ritchie, Dennis M.
   Prentice-Hall (1978)
   Englewood Cliffs, New Jersey

3) Multics Programmers Reference Manual (10.2 AG91-03A)
   (hereafter referred to as MPRM)


MTB-738-03                     Changes Required to List Init by C

4.  Background

The current  initialization structure for external  pointers does
not allow  for pointers to be initialized  to nonconstant values.
In C, external pointers can be  initialized to the address of any
C  data  type.   For  this  reason  a  new  method  of performing
initialization will be defined.  The new method of initialization
will  use  the  existing   list_init_  structure  to  define  its
initialization.   The  types  of  initializations  that  will  be
handled are as follows in C:

/* initialize a pointer to an external variable */
int a = 5;
int *b = &a;

/* initialize a pointer to an external function */
int q();
int *c = q();

/* initialize a pointer to a static variable */
static int d = 20;
int *e = &d;

/* initialize a pointer to an external entrypoint */
int f$g();
int *h = &f$g();

/* initialize a pointer to an external structure */
struct { int x;
         float z; } t;
float *y = &t.z;

/* initialize a static pointer to an external int */
int z = 10;
static int *p = &z;

main()
{
}


Changes Required to List Init by C                     MTB-738-03

5.  General

The  current  method  of  performing  initialization for external
structures  or  arrays  is  called  list_init_.   This  method of
initialization  allows for repetitive  initialization information
to be  encoded in such a  way that large amounts  of space can be
saved.   The information  currently is  copied out  to the target
variable  directly.  Any  pointers contained  in these structures
can only be initialized to constant values.

C  requires  that  external  pointers  have  the  ability  to  be
initialized to various nonconstant  values.  These values include
pointers to text references,  external variable references and to
static variable  references.  The new initialization  method will
have to ensure that all possible target areas can be referenced.

C static  variables are different than  Multics static variables.
C  static variables  are known  only in  the scope  that they are
declared  in.  ie.   per function   or per  file.  While  Multics
static variables are available via external references.  C static
variables will  be defined as  heap variables with  a unique name
only  known within  their scope.   References to  these variables
will be made via heap links.

6.  Proposal

The solution  being proposed here  allows an external  pointer to
have encoded information associated with it so that references to
specific sections  can be available at  runtime.  The information
required is a section specifier and offset.  list_init_ will take
this  information and  form a  reference to  the desired  target.
This  also requires  that the  segment be  known in  some way  to
list_init_ so that references to sections that it contains can be
found.  In  order for this to  happen list_init_ will now  take a
segment pointer  and a stack  header pointer as  parameters.  The
stack header pointer  makes it easier for list_init_  to find the
linkage and  static references via  the LOT and  ISOT pointers in
the stack header.

7.  Structure Definition

A new  structure will be defined and  list_template_entry will be
altered   within  system_link_init_info.incl.pl1  to   allow  for
pointer initialization to take place.  For a complete description
of the changes to  the include file system_link_init_info.inl.pl1
see Appendix A.  For a complete description of the changes to the
include file definitions_dcl.incl.pl1 see Appendix B.


MTB-738-03                     Changes Required to List Init by C

The redefinition  of a pad field  to a mbz and  an initialization
type will force the recompilation of any program that generates a
list_init_ structure.  The list_init_ structures generated by the
current  implementation  of  Fortran  need  not  be recompiled as
Fortran  zeros out  the  field  being altered.   The declarations
follow:

dcl       1 list_template_entry    aligned based,
           2 n_bits                fixed bin (35) aligned,
           2 mbz                   bit (3) unaligned,             |
           2 init_type             fixed bin (3)                  |
                                   unsigned unaligned,            |
           2 repeat                fixed bin (30)
                                   unsigned unaligned,
           2 datum                 bit (init_n_bits_in_datum
                                   refer
                                 (list_template_entry.n_bits));

dcl       1 pointer_init_template        based,
           2 ptr_type              fixed bin (18) unsigned unaligned,
           2 section_offset        fixed bin (18) unsigned unaligned,
           2 word_offset           fixed bin (18) unsigned unaligned,
           2 mbz                   bit (12) unaligned,
           2 bit_offset            fixed bin (6) unsigned unaligned;

Where:

  n_bits
          specifies  the length  of the  datum in  bits.  For all
          pointer initializations  this will have a  value of 72.
          It  can also  specify the   number of  bits to  skip if
          skipping  is specified  by the  repeat field.   In this
          case the  value of n_bits specifies the  number of bits
          to  skip.  If  positive this  implies skipping  forward
          while  if  negative  it  implies  skipping the absolute
          value backwards.

  init_type (new)
          specifies  what   type  of  initialization  is   to  be
          performed.  The following named  constants can be found
          in link_init_info.incl.pl1
             NORMAL_INIT (= 0)
             ITS_PTR_INIT (= 1)
             PACKED_PTR_INIT (= 2)

  repeat
          specifies the number of times the datum is to be copied
          to the target area.  It  can specify that a skipping of
          n_bits bits is to be performed if zero.


Changes Required to List Init by C                     MTB-738-03

  datum
          specifies the data to be copied out to the target area.
          For an  ITS pointer or a  packed pointer initialization
          this specifies the pointer_init_template.

  ptr_type (new)
          specifies  where  the  target  area  is  located.   The
          following    named    constants    are    declared   in
          link_init_info.incl.pl1
             PTR_INIT_TEXT (= 0)
             PTR_INIT_LOT (= 1)
             PTR_INIT_ISOT (= 2)

  section_offset (new)
          the  word offset  of  the  target within  the specified
          section.

  word_offset (new)
          is  the offset  in words  from the  address within  the
          section to  the target.  If the  the location specified
          by the  section_offset and the ptr_type is  a link this
          value will be applied to the target address obtained by
          referencing through the link.

  bit_offset (new)
          is  the offset  in bits  from the  address specified by
          word_offset above  to the target.  If  the the location
          specified by  the section_offset and the  ptr_type is a
          link this  value will be applied to  the target address
          obtained by referencing through the link.

The  ptr_type and  section_offset fields  specify a  pointer to a
word within the object segment.  In  the case of a pointer to the
linkage  section this  location may  be a  link.  If  this is the
case, then the reference, references indirectly through the link,
snapping   it  via   hcs_$link_force  if   necessary.   Then  the
word_offset and bit_offset values are applied.  Thus an arbitrary
word and bit  offset may be specified to be  added to any pointer
for which a standard link may be created.

In the case  of nonlink references, if either  the word_offset or
the section_offset  are nonzero then the offsets  will be applied
as word offsets to the section pointer identified by the ptr_type
field.  If the bit_offset is nonzero  it will be applied as a bit
offset  from  the  resulting  address  generated  by applying the
section_offset and  word_offset.  If this  reference is not  to a
constant  structure  the  results  are  undefined.   This  allows
pointers to be  created to any arbitrary point  within the object
segment.


MTB-738-03                     Changes Required to List Init by C

The  effective  address  of  the  target  can  be  found  by  the
following:

     effective_target = section_pointer | section_offset;

     If this is a reference in the linkage section the link found
     at the effective address is snapped.

     target_address    =     effective_target    |    word_offset
     (bit_offset);

Recursive   references  to    external  variables   with  pointer
initialization  will be  handled due   to the  allocation of  the
variable  taking  place  prior   to  the  initialization  of  the
variable.    This  implies   that  a   recursive  reference  will
eventually find the allocated variable  in the external name list
and its value will be the address of the allocated variable.

8.  Changes to list_init_

list_init_  will  have  to  be  altered  to  check  for  a  typed
initialization, and  then initialize the variable  to the desired
target.  If  a pointer typed  initialization does not  exist then
list_init_ will operate in its normal fashion.

To  initialize the  variable to  the desired  sections list_init_
will have be altered to accept a stack base pointer and a pointer
to the segment where the link is defined.

The following lists the possible targets for each section:

     text section:
          can point to an entry point or a constant.  The address
          of  the  entry  point  or  constant  is  copied  to the
          variable.

     linkage section:
          can point to an unsnapped  link or a snapped link.  The
          address of the link target is stored in the variable.

     static section:
          can  point to  a static  constant.  The  address of the
          constant is copied to the  variable.  If the static and
          linkage  sections  are  combined  this  can  point to a
          constant in the combined area.


Changes Required to List Init by C                     MTB-738-03

9.  Other Required Changes

In order for  the segment defining the link to  be known in cases
where the information is currently not available, entry points in
set_ext_variable_ will  be altered to  save a segment  pointer in
the  variable node.   This implies  passing a  segment pointer to
set_ext_variable_$for_linker.

10.  Routine Change List

The following routines  will be altered due to the  change in the
parameter  list  for  list_init_  and  set_ext_variable_.   For a
complete  description  of  the  changes  to  list_init_  and  the
set_ext_variable_ entry points see Section 13.

list_init_
     change  the parameter  list and  add a  new subroutine named
     initialize_ptr.  Change the following entry points

     declare list_init_ entry
          (pointer, pointer, fixed bin (35) pointer, pointer,
          fixed bin(35));

     call list_init_
          (variable_pointer,   init_info_pointer,  variable_size,
          stack_base_pointer, segment_pointer, error_code);

     declare list_init_$variable_already_zero entry
          (pointer, pointer, fixed bin (35), pointer, pointer,
          fixed bin(35));

     call list_init_$variable_already_zero
          (variable_pointer,   init_info_pointer,  variable_size,
          stack_base_pointer, segment_pointer, error_code);

set_ext_variable_
     change         the        calling         sequence        of
     list_init_$variable_already_zero.  Save  the segment pointer
     passed  to  the  entry  points  in  set_ext_variable_ in the
     variable  node  structure.   For  a  description  of the new
     variable  node   structure  see  Appendix  C.    Change  the
     following undocumented entry points in set_ext_variable_:

     declare set_ext_variable_$for_linker entry
          (char(*), pointer,  pointer, pointer, bit  (1) aligned,
          pointer,  fixed bin   (35), pointer,  pointer, pointer,
          pointer);


MTB-738-03                     Changes Required to List Init by C

     call set_ext_variable_$for_linker
          (ext_name,    init_info_pointer,    stack_base_pointer,
          segment_pointer,   found_sw,    node_ptr,   error_code,
          mc_pointer, def_pointer, type_pointer, link_pointer);   *

     (new)
     declare set_ext_variable_$star_heap entry
          (char(*), pointer,  pointer, pointer, bit  (1) aligned,
          pointer, fixed bin(35));

     call set_ext_variable_$star_heap
          (ext_name,    init_info_pointer,    stack_base_pointer,
          segment_pointer, found_sw, error_code);

     (new)
     declare set_ext_variable_$pointer entry
          (char(*), pointer,  pointer, pointer, bit  (1) aligned,
          pointer, fixed bin (35));

     call set_ext_variable_$pointer
          (ext_name,    init_info_pointer,    stack_base_pointer,
          segment_pointer, found_sw, node_ptr, error_code);

reset_external_variables
     change   the    passed   parameters   to    list_init_   and
     list_init_$variable_already_zero.    The   segment   pointer
     passed  to list_init_  will  be  obtained from  the variable
     node.

set_fortran_common
     change     the    calling     sequence    of     list_init_.
     set_fortran_common creates its  own initialization structure
     when   more  than    one  segment   contains  initialization
     information.   When this  happens the  segment that contains
     the  initialization is  no  longer  known.  For  this reason
     set_fortran_common will always pass a null segment pointer.

fortran_storage_
     change  the calling  sequences of  list_init_.  The  segment
     pointer passed  to list_init_ will be obtained  via the text
     pointer passed to fortran_storage_.

get_external_variable_
     Recompile this routine with the new include files.

cross_ring_io_
     Recompile this routine with the new include files.

set_severity_indicator
     Recompile this routine with the new include files.


Changes Required to List Init by C                     MTB-738-03

term_
     change  the  subroutine  free_linkage  to  set  the  segment
     pointer saved in the variable node to null.

run_
     change  the subroutine  cleanup_old_linkage_section to  null
     the segment pointer saved in the variable_node.

list_external_variables
     Recompile this routine with the new include files.

link_snap
     change the calling sequences of set_ext_variable_$for_linker
     and set_ext_variable_$star_heap  to pass a  segment pointer.
     The segment pointer will be obtained from the address of the
     initialization  information which  will be  contained in the
     segment that snapped the link.

binder / linkage_editor
     The Binder and the Linkage Editor will have to be altered to
     understand  the  new  pointer  initialization  type and heap
     links.

11.  Error Handling in list_init_

The current  method of error handling in  list_init_ involves the
signalling of the condition malformed_list_template_entry_.  When
this condition is  signalled the user has the  ability to restart
the  initialization.   The   restarting  of  this  initialization
continues at the next object  to be initialized.  This ability is
only     available     from     the     system     commands    of
reset_external_variable  and set_fortran_common.   These commands
take a list of objects that  the user wishes to have initialized.
If any  one of the objects  fails the user currently  can restart
the command to initialize the rest  of the objects which can lead
to confusing errors in the users programs.

The commands that use list_init_ to initialize external variables
will  be altered to  check for the  returned error codes.   These
commands will  print out an  informative message and  then abort.
This will allow the user to fix the error and recompile.

In  the case  where list_init_  is called  from set_ext_variable_
after a  link fault has  occurred the condition  is signalled and
then trapped  in set_ext_variable_.  set_ext_variable_  traps the
condition       and       returns       the       error      code
error_table_$malformed_list_template_entry.  If list_init_ was to
return the error code directly there would be no need to set up a
condition handler for malformed_list_template_entry_.  The normal
operation  of snapping a  link would be  the same from  the users
point of view.


MTB-738-03                     Changes Required to List Init by C

When  an  error  occurs  in  the  initialization  of  an external
pointers  target, list_init_ will  return an error  code defining
the  type  of  error  that  occurred  If  the  error occurs while
snapping  a targets  link the   error returned  will concern  the
current external pointer and will  not reference the target.  The
message  returned to  the user   will specify  that an  error has
occurred   while   initializing   the   target   of   a   pointer
initialization.

As  the  only  conditions  that  force  list_init_  to signal the
condition  malformed_list_template_entry_ are   an out  of bounds
error or a negative reference in the n_bits field the user should
repair the error and recompile.   To continue execution after the
above errors occur can lead  to results that may appear confusing
to the user.

For  this reason list_init_  will be altered  to accept an  error
code      as     a       parameter     and      the     condition
malformed_list_template_entry_  will be removed  from list_init_.
The error codes returned from list_init_ will be as follows:

error_table_$malformed_list_template_entry
     This  will be  returned when  there is  a possibility  of an
     error  in  the  list  template  structure.   This can happen
     either by  the segment being damaged  or by an error  in the
     compiler that generated the structure.

(new)
error_table_$invalid_ptr_target
     This will be returned when an error occurrs while snapping a
     link to  the specified target for  a pointer initialization.
     It  can be  caused by  the segment  being damaged  or by the
     compiler generating an invalid structure.

error_table_$null_info_ptr
     This will be returned when a  null segment pointer or a null
     stack  base pointer  is passed  to list_init_  and a pointer
     initialization is  taking place.  This  can be caused  by an
     error  in the structure  or by misuse  of the defined  entry
     points into list_init_.

error_table_$seg_unknown
     This will be returned when an  error is found in the LOT for
     the segment containing the initialization information.  This
     should never occur  if the segment is initiated  prior to or
     during execution.

12.  Include File Changes

The following is a list of the changed include files:


Changes Required to List Init by C                     MTB-738-03

1) For changes to the include file system_link_init_info.incl.pl1
   see Appendix A.
2) For changes  to the include file  definition_dcls.incl.pl1 see
   Appendix B.
3) For changes to the include file system_link_names.incl.pl1 see
   Appendix C.

13.  Documentation Changes

The   following   lists   the   required   changes   to   Multics
documentation.

1) Documentation for set_ext_variable_$for_linker should be moved
   from AG93 to the  new Privileged Subroutines Manual.  Appendix
   E contains modified documentation for this entry point.
2) AG93 and  info seg documentation for  set_ext_variable_ can be
   found in Appendix D.
3) The   Privileged   Subroutines    Manual   documentation   for
   set_ext_variable_ can be found in Appendix E.
4) list_init_ documentation for the Privileged Subroutines Manual
   can be found in Appendix F.
5) The  documentation changes  for linkage_errors.gi.info  can be
   found in appendix G.
6) The additions for  CH26-00 section 4 can be  found in Appendix
   H.

14.  Summary

With  the  changes  to  list_init_  and  the  saving of a segment
pointer in the variable node it will be possible to initialize an
external pointer to certain nonconstant values.


MTB-738-03                     Changes Required to List Init by C

15.  Appendix A

/* Begin include file ...  system_link_init_info.incl.pl1 ...
   5/6/80 MRJ */

/* Modified: 82-11-17 by T. Oke to add list_init_info and
                      LIST_TEMPLATE_INIT.
*/

/* format: style3,idind25 */

/* NOTE --------------------------------------------------        |
the following structures defining initialization information can  |
also be found in fortran_storage.incl.pl1                         |
definition_dcls.incl.pl1 and should be kept equivalent            |
------------------------------------------------------- */        |

dcl       init_info_ptr            ptr;
dcl       init_size                fixed bin (35);

dcl       1 init_info              aligned based
                                   (init_info_ptr),
            2 size                 fixed bin (35),
            2 type                 fixed bin,
            2 init_template        (init_size refer
                                   (init_info.size))
                                   fixed bin (35);

dcl       1 init_info_single_word  aligned based
                                   (init_info_ptr),
            2 size                 fixed bin (19),
            2 type                 fixed bin,
            2 init_template        (1) fixed bin (35);

dcl       1 list_init_info         aligned based,
            2 size                 fixed bin (35),
            2 type                 fixed bin,
            2 pad                  bit (18) unaligned,
            2 list_size            fixed bin (18)
                                   unsigned unaligned,
            2 template             (0 refer
                                   (list_init_info.list_size))
                                   bit (36);

/* A list template consists of a series of entries with the
following description, concatenated together.  n_bits and datum
are bit items, to permit a wide range of inputs.


Changes Required to List Init by C                     MTB-738-03

   1.  A 'repeat' of '0' signifies skipping of 'n_bits' bits.
       can specify either a forward or reverse skip if n_bits is
       positive or negative.
   2.  A 'n_bits' of '0' signifies the last item of the list.

   COMMON, VLA's, and LA's are presumed to start at the base
pointer of their particular storage section.  */

dcl       1 list_template_entry    aligned based,
            2 n_bits               fixed bin (35) aligned,
            2 mbz                  bit (3) unaligned,             |
            2 init_type            fixed bin (3)                  |
                                   unsigned unaligned,            |
            2 repeat               fixed bin (30)
                                   unsigned unaligned,
            2 datum                bit
                                   (init_n_bits_in_datum
                                   refer
                                   (list_template_entry.n_bits));

/* list_template_entry_ptr is defined such that it can be used    |
as an automatic definition overlay with a fixed size datum.  it   |
has a declared size of 72 to allow for the its pointer size of    |
72 bits.  */                                                      |

dcl       1 list_template_entry_ptr     aligned based,            |
            2 n_bits               fixed bin (35) aligned,        |
            2 mbz                  bit(3) unaligned,              |
            2 init_type            fixed bin (3)                  |
                                   unsigned unaligned,            |
            2 repeat               fixed bin (30)                 |
                                   unsigned unaligned,            |
            2 datum                bit(72);                       |

/* the pointer_init_template represents the initialization        |
information for ITS and packed pointers.  Both pointer types      |
require the entire 72 bit structure.  */                          |

dcl       1 pointer_init_template  based,                         |
            2 ptr_type             fixed bin (18)                 |
                                   unsigned unaligned,            |
            2 section_offset       fixed bin (18)                 |
                                   unsigned unaligned,            |
            2 word_offset          fixed bin (18)                 |
                                   unsigned unaligned,            |
            2 mbz                  bit (12) unaligned,            |
            2 bit_offset           fixed bin (6)                  |
                                   unsigned unaligned;            |

dcl       init_n_bits_in_datum     fixed bin (35);


MTB-738-03                     Changes Required to List Init by C

dcl       NO_INIT                  fixed bin
                                   static options (constant)
                                   init (0);
dcl       TEMPLATE_INIT            fixed bin
                                   static options (constant)
                                   init (3);
dcl       EMPTY_AREA_INIT          fixed bin
                                   static options (constant)
                                   init (4);
dcl       LIST_TEMPLATE_INIT       fixed bin
                                   static options (constant)
                                   init (5);
dcl       INIT_DEFERRED            fixed bin
                                   static options (constant)
                                   init (6);
dcl       NORMAL_INIT              fixed bin (3)                  |
                                   unsigned static                |
                                   options (constant) init(0);    |
dcl       ITS_PTR_INIT             fixed bin (3)                  |
                                   unsigned static                |
                                   options (constant) init(1);    |
dcl       PACKED_PTR_INIT          fixed bin (3) unsigned static  |
                                   options (constant) init(2);    |
dcl       PTR_INIT_TEXT            fixed bin (17)                 |
                                   static options (constant)      |
                                   init(0);                       |
dcl       PTR_INIT_LOT             fixed bin (17)                 |
                                   static options (constant)      |
                                   init(1);                       |
dcl       PTR_INIT_ISOT            fixed bin (17)                 |
                                   static options (constant)      |
                                   init(2);                       |

/* End include file ... system_link_init_info.incl.pl1 */


Changes Required to List Init by C                     MTB-738-03

16.  Appendix B

/* Begin include file definition_dcls.incl.pl1 BIM 1981 */
/* Modified:
   13 Dec 1982 by Lee A. Newcomb to put
          definition_header.hash_table_relp after unused
          half-word instead of before it.
   1 March 1983 by M. Weaver to add list template init type
*/

/* format: style3,idind25 */
/* everything for the definition section */

declare   (
          CLASS_TEXT               init (0),
          CLASS_LINKAGE            init (1),
          CLASS_SYMBOL             init (2),
          CLASS_SEGNAME            init (3),
          CLASS_STATIC             init (4),
          CLASS_SYSTEM             init (5),
          CLASS_HEAP               init (6)
          )                        fixed bin (3) unsigned internal
                                   static options (constant);

declare   CLASS_NAMES              (0:6) character (12) internal static
                                   options (constant) init ("text",
                                   "linkage", "symbol", "segname",
                                   "static", "system", "heap");

declare   SYMBOLIC_SECTION_NAMES   (0:6) character (8)
                                   init ("*text", "*link", "*symbol",
                                   *, "*static", "*system", "*heap")
                                   internal static options (constant);

declare   1 definition_flags       unaligned based,
            2 new                  bit (1),
            2 ignore               bit (1),
            2 entry                bit (1),
            2 retain               bit (1),
            2 argcount             bit (1),
            2 descriptors          bit (1),
            2 indirect             bit (1),
            2 unused               bit (8);

/* Header of the definition section */


MTB-738-03                     Changes Required to List Init by C

declare   def_header_ptr           pointer;
declare   1 definition_header      aligned based (def_header_ptr),
            2 def_list_relp        fixed bin (18) unsigned unaligned,
            2 msf_map_relp         fixed bin (18) unsigned unaligned,
            2 hash_table_relp      fixed bin (18) unsigned unaligned,
            2 flags                unaligned like definition_flags;

/* A non class=3 definition. See segname_definition below for class=3 */

declare   def_ptr                  pointer;
declare   1 definition             aligned based (def_ptr),
            2 forward_relp         unal fixed bin (18) unsigned,
            2 backward_relp        unal fixed bin (18) unsigned,
            2 thing_relp           unal fixed bin (18) unsigned,
            2 flags                unaligned like definition_flags,
            2 class                unal fixed bin (3) unsigned,
            2 name_relp            unal fixed bin (18) unsigned,
            2 segname_relp         unal fixed bin (18) unsigned;

/* Class=3, segname definition */

declare   segname_ptr              pointer;
declare   1 segname_definition     aligned based (segname_ptr),
            2 forward_relp         unal fixed bin (18) unsigned,
            2 backward_relp        unal fixed bin (18) unsigned,
            2 next_segname_relp    unal fixed bin (18) unsigned,
            2 flags                unaligned like definition_flags,
            2 class                unal fixed bin (3) unsigned,
            2 name_relp            unal fixed bin (18) unsigned,
            2 first_relp           unal fixed bin (18) unsigned;

/* Definition blocks are chained off of segname definitions.
   segname_definition.first_relp is one of three things:
    (1) the def section offset of the first ordinary (class^=3) definition
      belonging to this segname block. In the case where there are more
      than one segname's on a block, all their first_relp will point
      to the same place.

    (2) if there are no ordinary definitions associated with this segname,
      then it is the def section offset of the next segname.

    (3) if there are no ordinary definitions in the block, and it
      is the last block, then it points to a word containing 0.

 Thus the end of a list of synonym segnames can be detected by
forward_relp pointing to a class=3 definition whose first_relp is not
the same as the current definitions first_relp.  */


Changes Required to List Init by C                     MTB-738-03

/* All the definitions are linked through the forward and
   backward thread variables. The end of the chain can is indicated
   by forward pointing to a zero word. */

declare   exp_ptr                  pointer;
declare   1 exp_word               based (exp_ptr) aligned,
            2 type_relp            fixed bin (18) unsigned unal,
            2 expression           fixed bin (17) unal;

declare   (
          LINK_SELF_BASE           init (1),
          LINK_OBSOLETE_2          init (2),
          LINK_REFNAME_BASE        init (3),
          LINK_REFNAME_OFFSETNAME  init (4),
          LINK_SELF_OFFSETNAME     init (5),
          LINK_CREATE_IF_NOT_FOUND init (6),
          SECTION_TEXT             init (0),
          SECTION_LINK             init (1),
          SECTION_SYMBOL           init (2),
          SECTION_UNUSED           init (3),
          SECTION_STATIC           init (4),
          SECTION_SYSTEM           init (5),
          SECTION_HEAP             init (6)
          )                        fixed bin (18) unsigned unaligned
                                   internal static options (constant);

/* use CLASS_NAMES for section names */

declare   LINK_TYPE_NAMES          (1:6)
                                   init ("absolute in section", "unused",
                                   "absolute off of refname",
                                   "symbolic off of refname",
                                   "symbolic in section",
                                   "symbolic off of refname; create")
                                   character (32) varying
                                   internal static options (constant);

declare   type_ptr                 pointer;
declare   1 type_pair              based (type_ptr) aligned,
            2 type                 fixed bin (18) unsigned unal,
            2 trap_relp            fixed bin (18) unsigned unal,
            2 segname_relp         fixed bin (18) unsigned unal,
            2 offsetname_relp      fixed bin (18) unsigned unal;

/* Link Trap Pair */


MTB-738-03                     Changes Required to List Init by C

declare   link_trap_ptr            pointer;
declare   1 link_trap_pair         aligned based (link_trap_ptr),
            2 call_relp            fixed bin (18) unsigned unaligned,
            2 info_relp            fixed bin (18) unsigned unaligned;

/* initialization info for *system or *heap link */               |

/* NOTE --------------------------------------------------        |
the following structures defining initialization information are  |
also defined in fortran_storage.incl.pl1 and                      |
system_link_init_info.incl.pl1 and should be kept equivalent      |
------------------------------------------------------- */        |

declare   (
          INIT_NO_INIT             init (0),
          INIT_COPY_INFO           init (3),
          INIT_DEFINE_AREA         init (4),
          INIT_LIST_TEMPLATE       init (5),
          INIT_DEFERRED            init (6)
          )                        fixed bin internal static
                                   options (constant);

/* for type = 0 or 4 */

declare   link_init_ptr            pointer;
declare   1 link_init              aligned based (link_init_ptr),
            2 n_words              fixed bin (35),
            2 type                 fixed bin;

/* for type=3, there is data to copy */

declare   1 link_init_copy_info    aligned based (link_init_ptr),
            2 header               aligned like link_init,
            2 initial_data         (link_init_n_words refer
                                   (link_init_copy_info.header.n_words))
                                   bit (36) aligned;

declare   link_init_n_words        fixed bin;

/* for type = 5, there is a list template to copy */

declare   1 link_init_list_template
                                   aligned based (link_init_ptr),
            2 header               aligned like link_init,
            2 pad                  bit (18) unaligned,
            2 n_words_in_list      fixed bin (18) unsigned unaligned,
            2 template             (link_init_n_words_in_list refer
                               (link_init_list_template.n_words_in_list));

declare   link_init_n_words_in_list
                                   fixed bin;


Changes Required to List Init by C                     MTB-738-03

/* A list template consists of a series of entries with the following
   description, concatenated together.  n_bits and datum are bit items,
   to permit a wide range of inputs.

   1.  A 'repeat' of '0' signifies skipping of 'n_bits' bits.
   2.  A 'n_bits' of '0' signifies the last item of the list.

   COMMON, VLA's, and LA's are presumed to start at the base pointer
   of their particular storage section. */

declare   1 list_template_entry    aligned based,
            2 n_bits               fixed bin (35) aligned,
            2 mbz                  bit (3) unaligned,             |
            2 init_type            fixed bin (3)                  |
                                   unsigned unaligned,            |
            2 repeat               fixed bin (30)
                                   unsigned unaligned,
            2 datum                bit (link_init_n_bits_in_datum
                                   refer
                                   (list_template_entry.n_bits));

/* the pointer_init_template represents the initialization        |
information for ITS and packed pointers.  Both pointer types      |
require the entire 72 bit structure.  */                          |

dcl       1 pointer_init_template  based,                         |
            2 ptr_type             fixed bin (18)                 |
                                   unsigned unaligned,            |
            2 section_offset       fixed bin (18)                 |
                                   unsigned unaligned,            |
            2 word_offset          fixed bin (18)                 |
                                   unsigned unaligned,            |
            2 mbz                  bit (12) unaligned,            |
            2 bit_offset           fixed bin (6)                  |
                                   unsigned unaligned;            |

declare   link_init_n_bits_in_datum
                                   fixed bin (35);

/* for type = 6, the init_info resides in another MSF component */
/* target_relp is a linkage section offset to a partial link to */
/* the base of the linkage section of the component containing  */
/* the actual init_info. link_relp is the offset of the actual  */
/* link within that linkage section.                            */

declare   1 link_init_deferred     aligned based (link_init_ptr),
            2 header               aligned like link_init,
            2 target_relp          fixed bin (18) unsigned unaligned,
            2 link_relp            fixed bin (18) unsigned unaligned;

/* Definition section hash table */


MTB-738-03                     Changes Required to List Init by C

declare   def_ht_ptr               pointer;
declare   1 definition_ht          aligned based (def_ht_ptr),
            2 n_entries            fixed bin,
            2 table                (def_ht_n_entries refer
                                   (definition_ht.n_entries)) aligned,
              3 def_relp           fixed bin (18) unsigned unaligned,
              3 unused             bit (18) unaligned;

declare   def_ht_n_entries         fixed bin;

/* Component name ht */
declare   comp_ht_ptr              pointer;
declare   1 component_ht           aligned based (comp_ht_ptr),
            2 n_entries            fixed bin,
            2 table                (comp_ht_n_entries refer
                                   (component_ht.n_entries)) aligned,
              3 def_relp           fixed bin (18) unsigned unaligned,
              3 block_hdr_relp     fixed bin (18) unsigned unaligned;

declare   comp_ht_n_entries        fixed bin;

/* Duplicate name table */

declare   dup_table_ptr            pointer;
declare   1 duplicate_table        aligned based (dup_table_ptr),
            2 mbz                  bit (18) unaligned,
            2 n_names              fixed bin (18) unsigned unaligned,
            2 table                (dup_table_n_names refer
                                   (duplicate_table.n_names)) aligned,
              3 def_relp           fixed bin (18) unsigned unaligned,
              3 block_hdr_relp     fixed bin (18) unsigned unaligned;

declare   dup_table_n_names        fixed bin;

/* The msf_map is found in the definition section of an     */
/* object MSF component.  It is used by the linker to       */
/* determine whether a segment is a component of an object  */
/* MSF or a standard single-segment object.                 */

  dcl msf_map_ptr             ptr;
  dcl 01 msf_map              aligned based (msf_map_ptr),
       02 version             char (8),
       02 component_count     fixed bin (15) unsigned,
       02 my_component        fixed bin (15) unsigned;

  dcl msf_map_version_1       char (8) static options (constant)
                                   init ("msfmp1.0");


Changes Required to List Init by C                     MTB-738-03

declare   acc_string_ptr           pointer;
declare   1 acc_string             aligned based (acc_string_ptr),
            2 count                fixed bin (9) unsigned unaligned,
            2 string               character (max (3, acc_string_length)
                                   refer (acc_string.count)) unaligned,
            2 mbz                  bit (0) aligned;

declare   acc_string_length        fixed bin (21);

/* end include file definitions_dcls.incl.pl1 */


MTB-738-03                     Changes Required to List Init by C

17.  Appendix C

/* BEGIN INCLUDE FILE ... system_link_names.incl.pl1 */
/* created by M. Weaver 7/28/76 */
/* Modified: 82-11-19 by T. Oke to add LIST_TEMPLATE_INIT. */
/* Modified 02/11/83 by M. Weaver to add have_vla_variables flag */

dcl 1 variable_table_header aligned based,
     2 hash_table (0:63) ptr unaligned,
     2 total_search_time fixed bin (71),
     2 total_allocation_time fixed bin (71),
     2 number_of_searches fixed bin,
     2 number_of_variables fixed bin (35),
     2 flags unaligned,
        3 have_vla_variables bit (1) unaligned,
        3 pad bit (11) unaligned,
     2 cur_num_of_variables fixed bin (24) unal,
     2 number_of_steps fixed bin,
     2 total_allocated_size fixed bin (35);

dcl 1 variable_node aligned based,
     2 forward_thread ptr unaligned,
     2 vbl_size fixed bin (24) unsigned unaligned,
     2 init_type fixed bin (11) unaligned,
     2 time_allocated fixed bin (71),
     2 vbl_ptr ptr,
     2 init_ptr ptr,
     2 name_size fixed bin(21) aligned,
     2 name char (nchars refer (variable_node.name_size)),
     2 seg_ptr  pointer;                                          |

dcl 1 heap_header based,
     2 version            char(8),
     2 heap_name_list_ptr pointer,
     2 previous_heap_ptr  pointer,
     2 area_ptr           pointer,
     2 execution_level    fixed bin (17);

dcl heap_header_version_1  char (8) static options (constant)
                           init ("Heap_v01");

/* END INCLUDE FILE ... system_link_names.incl.pl1 */


Changes Required to List Init by C                     MTB-738-03

18.  Appendix D

 04/15/86  set_ext_variable_

Entry points in set_ext_variable_:
   (List is generated by the help command)

:Entry:  set_ext_variable_:  04/15/86  set_ext_variable_

Function: allows the caller to look up an external variable by name.
If the name is not found, the variable is created.

Syntax:
declare set_ext_variable_ entry (char(*), ptr, ptr, bit(1) aligned,
     ptr, fixed bin(35));
call set_ext_variable_ (ext_name, init_info_ptr, sb_ptr, found_sw,
     node_ptr, code);

Arguments:
ext_name
   is the name of the external variable.  (Input)
init_info_ptr
   is a pointer to the initialization info (see "Notes on
   init_info Structure").
   (Input)
sb_ptr
   is a pointer to the base of the stack of the caller.  (Input)
found_sw
   is set to indicate whether the variable was found or not.
   (Output)
node_ptr
   is a pointer to the external variable node.  (see "Notes on
   variable_node Structure")
   (Output)
code
   is an error code.  (Output)

:Entry:  locate:  04/15/86 set_ext_variable_$locate

Function: This entry point locates the specified external variable
and returns a pointer to the structure describing the variable.


MTB-738-03                     Changes Required to List Init by C

Syntax:
dcl set_ext_variable_$locate entry (char(*), ptr, ptr,
    fixed bin(35));
call set_ext_variable_$locate (ext_name, sb_ptr, node_ptr, code);

Arguments:
ext_name
   is the name of the external variable.  (Input)
sb_ptr
   is a pointer to the base of the stack of the caller.  (Input)
node_pointer
   is a pointer to the variable_node describing the specified
   variable.  This structure is defined in the
   system_link_names.incl.pl1 include file.  (see "Notes on
   variable_node Structure")
   (Output)
code
   is an error code.  (Output)

:Entry:  star_heap:  04/15/86  set_ext_variable_$star_heap        |

Function: allows the caller to look up heap variables by name.  If|
the name is not found, the variable is created and added to the   |
list of heap variables.                                           |

Syntax:                                                           |
declare set_ext_variable_$star_heap entry (char(*), ptr, ptr, ptr |
   bit(1) aligned, ptr, fixed bin(35));                           |
call set_ext_variable_$star_heap (ext_name, init_info_ptr, sb_ptr,|
  seg_ptr, found_sw, node_ptr, code);                             |

Arguments:                                                        |
ext_name                                                          |
   is the name of the external variable.  (Input)                 |
init_info_ptr                                                     |
   is a pointer to the initialization info (see "Notes on         |
   init_info Structure").                                         |
   (Input)                                                        |
sb_ptr                                                            |
   is a pointer to the base of the stack of the caller.  (Input)  |
seg_ptr                                                           |
   is a pointer to the segment containing the object to be        |
   initialized. (Input).                                          |
found_sw                                                          |
   is set to indicate whether the variable was found or not.      |


Changes Required to List Init by C                     MTB-738-03

   (Output)                                                       |
node_ptr                                                          |
   is a pointer to the external variable node.                    |
   (see "Notes on variable_node Structure") (Output)              |
code                                                              |
   is an error code.  (Output)                                    |

:Entry:  pointer:  04/15/86  set_ext_variable_$pointer            |

Function: allows the caller to create a system external variable  |
using list_init_ pointer intialization.                           |

Syntax:                                                           |
declare set_ext_variable_$pointer entry (char(*), ptr, ptr, ptr   |
   bit(1) aligned, ptr, fixed bin(35));                           |
call set_ext_variable_$pointer (ext_name, init_info_ptr, sb_ptr,  |
  seg_ptr, found_sw, node_ptr, code);                             |

Arguments:                                                        |
ext_name                                                          |
   is the name of the external variable.  (Input)                 |
init_info_ptr                                                     |
   is a pointer to the initialization info (see "Notes on         |
   init_info Structure").                                         |
   (Input)                                                        |
sb_ptr                                                            |
   is a pointer to the base of the stack of the caller.  (Input)  |
seg_ptr                                                           |
   is a pointer to the segment containing the object to be        |
   initialized. (Input).                                          |
found_sw                                                          |
   is set to indicate whether the variable was found or not.      |
   (Output)                                                       |
node_ptr                                                          |
   is a pointer to the external variable node.                    |
   (see "Notes on variable_node Structure") (Output)              |
code                                                              |
   is an error code.  (Output)                                    |

Notes on init_info Structure:                                     |
When a new external variable is allocated (not found), it must be |
initialized.  The following structure, described in               |
system_link_init_info.incl.pl1, is pointed to by init_info_ptr:   |


MTB-738-03                     Changes Required to List Init by C

   dcl 1 init_info           aligned based,                       |
         2 size              fixed bin(19),                       |
         2 type              fixed bin,                           |
         2 init_template                                          |
      (init_size refer                                            |
      (init_info.size))      fixed bin(35);                       |

   Structure elements:                                            |
   size                                                           |
      is the initialization template size, in words.              |
   type                                                           |
      is the type of initialization to be performed.              |
      0 no init                                                   |
      1 invalid                                                   |
      2 invalid                                                   |
      3 init from template                                        |
      4 init area to empty ()                                     |
      5 list_template intialization (see "Notes on                |
        list_template Initialization Structure").                 |
   init_template                                                  |
      is the initialization template to be used when type = 3.    |

Notes on list_template Initialization Structure:                  |
When the initialization type is 5 or a list_template              |
initialization is being performed the init_info structure is not  |
used.  The structure used is the list_init_info structure which   |
has the following definition in system_link_init_info.incl.pl1 :  |

dcl       1 list_init_info         aligned based,                 |
            2 size                 fixed bin (35),                |
            2 type                 fixed bin,                     |
            2 pad                  bit (18) unaligned,            |
            2 list_size            fixed bin (18)                 |
                                   unsigned unaligned,            |
            2 template             (0 refer                       |
                                   (list_init_info.list_size))    |
                                   bit (36);                      |

   Structure Elements:                                            |
   size                                                           |
      is the size of the variable in words.                       |
   type                                                           |
      is the type of initialization to be performed.              |
      5 list_template                                             |
   list_size                                                      |
     is the number of list_template_entries that make up the      |
     template.                                                    |
   template                                                       |


Changes Required to List Init by C                     MTB-738-03

     takes the form of a list_template_entry structure as defined |
     in system_link_init_info.incl.pl1.  This structure is passed |
     on to list_init_ and decoded into data which is copied to the|
     variable.  See the description of list_init_ in the          |
     Privileged Subroutines Manual for a more complete            |
     description.                                                 |

Notes on variable_node Structure:                                 |
Great care should be taken when using the node_ptr.  The          |
variable_node structure should never be modified.  Modifications  |
to the variable_node will have unpredictable results.             |

A pointer to the following structure is returned by the entry     |
points in this subroutine.  It is declared in                     |
system_link_names.incl.pl1.                                       |

   dcl 1 variable_node       aligned based,                       |
         2 forward_thread    ptr unaligned,                       |
         2 vbl_size          fixed bin(23) unaligned,             |
         2 init_type         fixed bin(11) unaligned,             |
         2 time_allocated    fixed bin(71),                       |
         2 vbl_ptr           ptr,                                 |
         2 init_ptr          ptr,                                 |
         2 name_size         fixed bin(21) aligned,               |
         2 name              char (nchars refer                   |
                             (variable_node.name_size)),          |
         2 seg_ptr           ptr;                                 |

   Structure elements:                                            |
   forward_thread                                                 |
      is used by the linker to thread this variable to the        |
      next.                                                       |
   vbl_size                                                       |
      is the size, in words, of this variable.                    |
   init_type                                                      |
      is the type of initialization that is performed:            |
      0 none                                                      |
      1 invalid                                                   |
      2 invalid                                                   |
      3 initialize from template                                  |
      4 initialize to an empty area                               |
      5 initialize using a list template (see "Notes on           |
        list_template Initialization Structure").                 |
   time_allocated                                                 |
      is the clock reading at the time this variable was          |
      allocated.                                                  |
   vbl_ptr                                                        |
      is a pointer to the variable's storage.                     |
   init_ptr                                                       |
      is a pointer to the initialization template.                |


MTB-738-03                     Changes Required to List Init by C

   name_size                                                      |
      is the number of characters in the variable name.           |
   name                                                           |
      is the name of the variable.                                |
   seg_ptr                                                        |
      is a pointer to the segment containing the variables        |
      initialization information.                                 |


Changes Required to List Init by C                     MTB-738-03

19.  Appendix E

04/15/86  set_ext_variable_

Entry points in set_ext_variable_:
   (List is generated by the help command)

:Entry:  for_linker:  04/15/86 set_ext_variable_$for_linker

Function: This entry point is called by link_snap to allocate or
find an external variable.  It should only be called in ring 0.
If the size of the variable is greater than sys_info$max_seg_size
this entry traps to the referencing ring to perform the allocation
and snap the link.

Syntax:
dcl set_ext_variable_$for_linker entry (char(*), ptr, ptr,
    fixed bin(35), ptr, ptr, ptr, ptr);
call set_ext_variable_$for_linker
     (ext_name, init_info_ptr, sb, seg_ptr, found_sw, node_ptr,
     code, mc_ptr, def_ptr, type_ptr, link_ptr);

Arguments:
ext_name
   is the name of the external variable.  (Input)
init_info_ptr
   is a pointer to the initialization info. For a complete
   description of the initialization structure (see "Notes on
   init_info Structure"). (Input)
sb_ptr
   is a pointer to the base of the stack of the caller.  (Input)
seg_ptr
   is a pointer to the segment containing the object to be
   initialized. (Input).
found_sw
   is set to indicate whether the variable was found or not.
   (Output)
node_ptr
   is a pointer to the external variable node.  For a complete
   description of the node structure (see "Notes on variable_node
   Structure"). (Output)
code
   is an error code.  (Output)
mc_ptr
   is a pointer to the machine conditions for the linkage fault.
   (Input)
def_ptr


MTB-738-03                     Changes Required to List Init by C

   is a pointer to the base of the definition section of the segment
   that contains the link to the variable. (Input)
type_ptr
   is a pointer to the type pair of the link to the variable. (Input)
link_ptr
   is a pointer to the (unsnapped) link to the variable. (Input)
                                                                  *

Notes on init_info Structure:
When a new external variable is allocated (not found), it must be
initialized.  The following structure, described in
system_link_init_info.incl.pl1, is pointed to by init_info_ptr:

   dcl 1 init_info           aligned based,
         2 size              fixed bin(19),
         2 type              fixed bin,
         2 init_template
      (init_size refer
      (init_info.size))      fixed bin(35);

   Structure elements:
   size
      is the initialization template size, in words.
   type
      is the type of initialization to be performed.
      0 no init
      1 invalid
      2 invalid
      3 init from template
      4 init area to empty ()
      5 list_template initialization (see "Notes on list_template
        Initialization Structure")
   init_template
      is the initialization template to be used when type = 3.

Notes on list_template Initialization Structure:
When the initialization type is 5 or a list_template
initialization is being performed the init_info structure is not
used.  The structure used is the list_init_info structure which
has the following definition in system_link_init_info.incl.pl1 :


Changes Required to List Init by C                     MTB-738-03

dcl       1 list_init_info         aligned based,
            2 size                 fixed bin (35),
            2 type                 fixed bin,
            2 pad                  bit (18) unaligned,
            2 list_size            fixed bin (18)
                                   unsigned unaligned,
            2 template             (0 refer
                                   (list_init_info.list_size))
                                   bit (36);

   Structure Elements:
   size
      is the size of the variable in words.
   type
      is the type of initialization to be performed.
      5 list_template
   list_size
     is the number of list_template_entries that make up the
     template.
   template
     takes the form of a list_template_entry structure as defined
     in system_link_init_info.incl.pl1.  This structure is passed
     on to list_init_ and decoded into data which is copied to the
     variable. See the definition of list_init_ in the Priviledged
     Subroutines Manual for a more complete description.

Notes on variable_node Structure:
Great care should be taken when using the node_ptr.  The
variable_node structure should never be modified.  Modifications
to the variable_node will have unpredictable results.

A pointer to the following structure is returned by the entry
points in this subroutine.  It is declared in
system_link_names.incl.pl1.

   dcl 1 variable_node       aligned based,
         2 forward_thread    ptr unaligned,
         2 vbl_size          fixed bin(23) unaligned,
         2 init_type         fixed bin(11) unaligned,
         2 time_allocated    fixed bin(71),
         2 vbl_ptr           ptr,
         2 init_ptr          ptr,
         2 name_size         fixed bin(21) aligned,
         2 name              char (nchars refer
                             (variable_node.name_size)),
         2 seg_ptr           ptr;


MTB-738-03                     Changes Required to List Init by C

   Structure elements:
   forward_thread
      is used by the linker to thread this variable to the
      next.
   vbl_size
      is the size, in words, of this variable.
   init_type
      is the type of initialization that is performed:
      0 none
      1 invalid
      2 invalid
      3 initialize from template
      4 initialize to an empty area
      5 initialize using a list template (see "Notes on list_template
        Initialization Structure").
   time_allocated
      is the clock reading at the time this variable was
      allocated.
   vbl_ptr
      is a pointer to the variable's storage.
   init_ptr
      is a pointer to the initialization template.
   name_size
      is the number of characters in the variable name.
   name
      is the name of the variable.
   seg_ptr
      is a pointer to the segment containing the variables
      initialization information.


Changes Required to List Init by C                     MTB-738-03

20.  Appendix F

04/07/86  list_init_

Entry points in list_init_:
   (List is generated by the help command)

:Entry:  list_init_:  04/07/86  list_init_

Function: allows the caller to initialize a variable using an
encoding scheme that allows data compression.  This encoding can
specify the skipping of bits or the repeating of bits.  It can
also specify the area is to be zeroed.

Syntax:
declare list_init_ entry
  (ptr, ptr, fixed bin (35), ptr, ptr, fixed bin(35));
call list_init_ (variable_ptr, template_ptr, var_size,
     stack_base_ptr, seg_ptr, code);

Arguments:
variable_ptr
   is a pointer to the variable to be initialized (Input)
template_ptr
   is a pointer to the list_template_entry structure defining the
   intialization to be performed.  The list_template_entry
   structure is declared in system_link_init_info.incl.pl1 and has
   the structure defined in the following "Notes on
   list_template_entry Structure" section.  If this is null it
   implies that the target should be zeroed.  (Input)

var_size
   is the size of the variable in words. (Input)
sb_ptr
   is a pointer to the base of the stack in the ring where the
   variable is active.  (Input)
seg_ptr
   is a pointer to the segment containing the declaration of the
   variable to be initialized. (Input)
code
   is a standard system error code. (Output)

:Entry:  list_init_$variable_already_zero:  04/07/86  list_init_


MTB-738-03                     Changes Required to List Init by C

Function: allows the caller to initialize a variable using an
encoding scheme that allows data compression.  This encoding can
specify the skipping of bits or the repeating of bits.  This entry
point takes for granted that the variable has been previously
zeroed.

Syntax:
declare list_init_$variable_already_zero entry
   (ptr, ptr, fixed bin (35), ptr, ptr, fixed bin(35));
call list_init_$variable_already_zero (variable_ptr, template_ptr,
   var_size, stack_base_ptr, seg_ptr, code);

Arguments:
variable_ptr
   is a pointer to the variable to be initialized (Input)
template_ptr
   is a pointer to the list_template_entry structure defining the
   intialization to be performed.  The list_template_entry
   structure is declared in system_link_init_info.incl.pl1 and has
   the structure defined in the following "Notes on list_template_entry
   Structure" section. If this is null it implies that the target
   should be zeroed. (Input)
var_size
   is the size of the variable in words. (Input)
sb_ptr
   is a pointer to the base of the stack in the ring where the
   variable is active.  (Input)
seg_ptr
   is a pointer to the segment containing the declaration of the
   variable to be initialized. (Input)
code
   is a standard system error code. (Output)

Notes on list_template_entry Structure:
The list_template_entry has the following definition as found in
system_link_init_info.incl.pl1:

dcl       1 list_template_entry    aligned based,
            2 n_bits               fixed bin (35) aligned,
            2 mbz                  bit (3) unaligned,
            2 init_type            fixed bin (3)
                                   unsigned unaligned,
            2 repeat               fixed bin (30)
                                   unsigned unaligned,
            2 datum                bit
                                   (init_n_bits_in_datum
                                   refer
                                   (list_template_entry.n_bits));


Changes Required to List Init by C                     MTB-738-03

   Structure elements:
   n_bits
      is the number of bits of initialization specified by the
      datum.  If zero this specifies that this is the last
      template in the initialization.  If skipping is implied
      via the repeat field then this specifies the number of
      bits to be skipped.  If positive it implies a forward skip.
      If negative it implies a backward skip.
   mbz is a zeroed pad field and must be zero.
   init_type
      specifies what type of initialization is to be performed with
      the following named constants found in
      system_link_init_info.incl.pl1.

      NORMAL_INIT (= 0)
      ITS_PTR_INIT (= 1)
      PACKED_PTR_INIT (= 2)

   repeat
      specifies how many times the datum is to be repeated in the
      variable. If zero this specifies a skipping of n_bits bits in
      the variable.
   datum
      this is the data to be copied out to the variable repeat times.
      If zero it implies that the variable will be zeroed.  For
      NORMAL_INIT the datum is copied out directly to the variable.
      For ITS_PTR_INIT and PACKED_PTR_INIT the datum specifies
      encoded information that will allow external pointers to be
      initialized to nonconstant values.  The n_bits field in this
      case is always 72.  The encoding is in the form of the
      structure pointer_init_template defined in
      system_link_init_info.incl.pl1 as follows:

dcl       1 pointer_init_template  based,
            2 ptr_type             fixed bin (18)
                                   unsigned unaligned,
            2 section_offset       fixed bin (18)
                                   unsigned unaligned,
            2 word_offset          fixed bin (18)
                                   unsigned unaligned,
            2 mbz                  bit (12) unaligned,
            2 bit_offset           fixed bin (6)
                                   unsigned unaligned;

   Structure elements:
   ptr_type
      specifies where the target area is located. The following named
      constants are declared in link_init_info.incl.pl1


MTB-738-03                     Changes Required to List Init by C

      PTR_INIT_TEXT (= 0)  text section reference
      PTR_INIT_LOT (= 1)   link section reference
      PTR_INIT_ISOT (= 2)  static section reference

   section_offset
      the word offset of the target within the specified section.
   word_offset
      is the offset in words from the address within the section to
      the target.  If the the location specified by the
      section_offset and the ptr_type is a link this value will be
      applied to the target address obtained by referencing through
      the link.
   bit_offset
      is the offset in bits from the address specified by word_offset
      above to the target. If the the location specified by the
      section_offset and the ptr_type is a link this value will be
      applied to the target address obtained by referencing through
      the link.

The ptr_type and section_offset fields specify a pointer to a word
within the object segment.  In the case of a pointer to the
linkage section this location may be a link.  If this is the case,
then the reference, references indirectly through the link,
snapping it via hcs_$link_force if necessary.  Then the
word_offset and bit_offset values are applied.  Thus an arbitrary
word and bit offset may be specified to be added to any pointer
for which a standard link may be created.

In the case of nonlink references, if either the word_offset or
the section_offset are nonzero then the offsets will be applied as
word offsets to the section pointer identified by the ptr_type
field.  If the bit_offset is nonzero it will be applied as a bit
offset from the resulting address generated by applying the
section_offset and word_offset.  If this reference is not to a
constant structure the results are undefined.  This allows
pointers to be created to any arbitrary point within the object
segment.

Recursive references to external variables with pointer
initialization will be handled due to the allocation of the
variable taking place prior to the intialization of the variable.
This implies that a recursive reference will eventually find the
allocated variable in the external name list and its value will be
the address of the allocated variable.


Changes Required to List Init by C                     MTB-738-03

21.  Appendix G

05/05/86 Linkage Errors

Linkage errors occur when the Multics dynamic linker is unable to
find an external reference.  Usually the system error handler
prints a message indicating what was wrong; this help file
explains some of the possible problems in more detail.

Segment not found:
    One of the most common messages is "Segment not found.".  This
usually happens because the target segment doesn't exist, or the
name was misspelled, or there is insufficient access.  If none of
these reasons apply, the user should check the search rules (using
the print_search_rules command).

External symbol not found:
    Another common message is "External symbol not found.".  This
means that the linker found the segment but could not find the
specified entry point or externally referenceable data.  This
could be due to misspelling or to an error or omission in the
target segment.  In particular, if the segment is bound, the
bindfile should be checked, since not all the entry points in the
component segments are necessarily retained after binding.

Linkage section not found:
    The message "Linkage section not found." usually means that
the target found is not an object segment and hence has no entry
points or externally referenceable data.  Such segments can be
referenced only by names ending in "$".

Variable or common too big:
    The message "External variable or common block is not the same
size as other uses of the same name." means that the latest
reference to a common block or external variable (one to be
created by the linker) specified a larger size than that already
allocated.  Type "help external_storage.gi" for more information
about this case.


MTB-738-03                     Changes Required to List Init by C

Duplicate entry name:
    The message "Duplicate entry name in bound segment." means
that there is more than one entry point with the same name and the
linker cannot resolve the reference.  This happens with bound
segments when the segment name used does not specify which
component is meant and several components have entry points with
the same name.  Either the reference should be made more precise
or the target segment should be rebound with the bindfile changed
to include the referenced name as a synonym on the desired
component.

No room for allocations:
    The message "There is no room to make requested allocations."
means that the size associated with a common block of external
variable to be created is too large; in this case, the program
must be changed.

Allocation not performed:
    The message "Allocation could not be performed." occurring
when attempting to allocate space for an external variable, means
that the area used by the linker has been clobbered.  If the
process doesn't terminate first, try telling the linker to use a
different area by using the set_user_storage command, giving it
the name of another area.  The create_area command can be used to
create the area, which should be extensible.

Illegal link info:
    Sometimes the program making the reference has been clobbered;
usually recompilation cures the problem.  The messages associated
with this case are:
 "Illegal type code in type pair block."
 "Illegal self reference type."

Bad definitions:
    The messages "Looping searching definitions." and "Bad class
code in definitions." usually mean that target has been clobbered
and should be recompiled.
    The message "Bad definitions pointer in linkage." means that
the copy of the referencing segment's linkage section, which
contains the actual snapped links, etc., has been clobbered.
Terminating the referencing segment and starting over may work,
although it is likely that enough damage has been done that a
new_proc may be necessary.


Changes Required to List Init by C                     MTB-738-03

Bad fault tag 2 location:
    Occasionally the linker is invoked because the processor
encounters the link fault bit pattern at a location other than an
unsnapped link.  When the linker detects this, it returns one of
the following messages:
  "Attempt to execute instruction containing a fault tag 2."
  "Attempt to indirect through word pair containing a fault
   tag 2 in the odd word."

Malformed list template entry:
    The message "A compiler has generated incorrect list template
initialization ..." implies that the initialization information
for an external variable has been damaged in some manner.  The
routines containing the erroneous structure should be recompiled.

Invalid Pointer Target:
    The message "Unable to initialize a pointer used as the
initial of an external variable." implies that the target of a
pointer initialization can not be initialized.  This can be caused
by an error occurring in the initialization structure or by the
segment containing the initialization information being damaged.
This can also be caused by not being able to find the target
specified by the initialziation information.
    The latter case is most likely to happen with references to
external variables that are not defined within the (possibly
multi-segment) object.  The user should check all such references
and the links generated by the compiler and either correct the
reference or make sure that the link target is accessible.  If no
such error is found, the program should be recompiled.
   The problem may actually have occurred in a different variable
from the one associated with the message.  If an external variable
references another external variable, the initialization of the
second may be completed before the initialization of the first,
with any errors being reported with the first.

Segment Unknown:
    The message "Segment not known to process." implies that the
execution environment has been damaged.  The user should initiate
the segments required for their execution or perform a new_proc.

Inconsistent object MSF:
    The message "Object MSF is inconsistent" states that a
component of an Object MSF has been damamged. The segment in
question should be recreated.


MTB-738-03                     Changes Required to List Init by C

First reference trap:
    The message "A first reference trap was found..." specifies
that the first reference traps for the executing segment have not
been executed. The segment should be terminated and then initiated
again with a -fc.

Resolve linkage error:
    There is a command which can often be used to snap a link to
an arbitrary target; type "resolve_linkage_error new_target_name;
start" to continue with the desired reference.  This is most
useful for misspelling cases or when the search rules weren't
adequate.  It does not work for common blocks or external
variables to be created.


Changes Required to List Init by C                     MTB-738-03

22.  Appendix H

A compiler has generated incorrect list template initialization
for an array or external variable.

    Class: rare                         Type: linker

    This is issued by the linker or by commands that initialize
    external variables. This will ususally inidicate that the
    object segment has been damaged or rarely that the compiler
    used to generate the program has an error.

Unable to initialize a pointer used as the initial of an
external variable.

     Class: rare                        Type: linker

     This is issued by the linker or by commands that initialize
     external variables.  This implies that the target of a
     pointer initialization can not be initialized.  This can be
     caused by an error occurring in the initialization structure
     or by the segment containing the initialization information
     being damaged.  This can also be caused by not being able to
     find the target specified by the initialziation information.

     The latter case is most likely to happen with references to
     external variables that are not defined within the (possibly
     multi-segment) object.  The user should check all such
     references and the links generated by the compiler and either
     correct the reference or make sure that the link target is
     accessible.  If no such error is found, the program should be
     recompiled.

     The problem may actually have occurred in a different
     variable from the one associated with the message.  If an
     external variable references another external variable, the
     initialization of the second may be completed before the
     initialization of the first, with any errors being reported
     with the first.

Segment not known to process.

     Class: rare                        Type: environment

     This indicates an attempt to reference a segment that has not
     been initiated or whose linkage setction has not been
     combine.  It can occurr from damage to the execution
     environment.  The segment should be made known / initiated or
     a new_proc should be performed.


MTB-738-03                     Changes Required to List Init by C

Pointer to required information is null.

     Class: rare                        Type: subroutines

     This is returned when a null pointer is passed to a routine
     expecting a valid non-null pointer.  The segment should be
     recompiled or the entry points being called should be
     changed.

Object MSF is inconsistent.

     Class: rare                        Type: linker

     This is issued when a component of an Object MSF has been
     damamged.  The segment in question should be recreated.