CBFalconer cbfalconer at yahoo.com
Mon Mar 10 10:54:28 CET 2003

Peter N Lewis wrote:
> At 12:32 +0100 7/3/03, Adriaan van Os wrote:
> >We are running into a real problem while porting the Apple Pascal
> >Interfaces to gpc.
> >
> >Consider the following record definition:
> >
> >type
> >   word16 = cardinal( 16);
> >   word32 = cardinal( 32);
> >   rec = record
> >               a: word16;
> >               b: word32
> >            end;
> >
> >For binary compatibility, the size of the 'rec' type must be 6
> >rather than 8.
> >Now, the problem is:
> >
> >(1) --pack-struct doesn't seem to be available as a source code
> >compiler option.
> >(2) adding 'packed' to records makes it impossible to pass any 
> >field of the record as an actual 'var' parameter.
> >
> >For these two reasons I have an urgent feature request, which 
> >is to make --pack-struct available as a compiler option that 
> >can be added to the Pascal source code.
> Unfortunately, it looks like this will not help :-(
> --pack-struct appears to do exactly the same thing as "packed
> record", which is too strong because of the added restriction
> of failing with var parameters.
> What is needed is a relaxation of the alignment restrictions
> when building a record, without the onerous restriction of
> bitfield packing.  Presumably this would help with Borland
> compatibility as well.
> Basically, we need something like --record-alignment={1,2,4}
> (and a corresponding compiler directive we can add to the
> system interfaces) so that items N bytes or larger are aligned
> to N bytes (where N is 1 2 or 4).
> If this sounds reasonable, and if folks have advice on the
> exact user interface for this, then I'm willing to take a crack
> at this in the source to "get my feet wet".
> Specific advice would include the exact name "record-alignment",
> whether it should take a parameter, or instead be
> --no-record-alignment, --record-alignment1, --record-alignment2,
> --record-alignment4.  The latter would seem more in keeping with
> the options in general, as I could not find any other compiler
> directive that took a parameter, but correct me if I'm wrong.
> Without this, it'll be *very* challenging to get the Mac Pascal
> interfaces working, as many of them date back to the '80s on a
> 68000 which had generally 2 byte alignment.

It seems to me that the fundamental problem is to get the space
correct.  In which case changing the definition to:

     word16 = cardinal( 16);
     word32 = cardinal( 32);
     rec    = record
       a       : word16;
       b       : array[1..2] of word16;
     rec    = record
       a, bhi, blo : word16;

should do it.  Further interface code then needs to be generated
to translate that b array, which should only depend on the word
sex of the original.

Chuck F (cbfalconer at yahoo.com) (cbfalconer at worldnet.att.net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!

More information about the Gpc mailing list