Hi Mike
The one rule that C does apply is the
first child rule. C does not allow padding before the first child in a
struct, so the alignment of the first child must not be greater than the
alignment of the parent. But it won't complain if the third element's
alignment is greater than the parent's, for example. So the rule
needs to be relaxed, I think the only question is whether we drop the rule
altogether or go with the first child rule.
Regards
Steve Hanson
Architect, Data Format Description Language (DFDL)
Co-Chair, OGF
DFDL Working Group
IBM SWG, Hursley, UK
smh@uk.ibm.com
tel:+44-1962-815848
From:
Mike Beckerle <mbeckerle.dfdl@gmail.com>
To:
Steve Hanson/UK/IBM@IBMGB
Cc:
dfdl-wg@ogf.org
Date:
29/05/2012 18:08
Subject:
Re: [DFDL-WG]
Possible DFDL spec errata
On Tue, May 29, 2012 at 12:03 PM, Steve Hanson <smh@uk.ibm.com>
wrote:
These were on the agenda for today's
cancelled call.
2. Is parent/child alignment rule too strict?
Spec property description for alignment says "The
alignment of a child component must be less than
or equal the alignment of its parent element, sequence or choice".
Experiments with creating DFDL schema
from C structures have shown that this rule is violated. It seems
unnecessary. Specifically, C ensures that the alignment
of objects in a repeating structure is preserved by rounding up the
length of the structure, rather than aligning it.
I think the point of this restriction was to insure that we didin't have
conflicting alignments. Where the begining of the structure was aligned,
say 64, but the first element was aligned at some incompatible boundary.
Like 128. It would almost certainly be an error if the first element in
a structure has a larger alignment constraint than the overall structure,
and the user should pick where to place the constraint, and not constrain
both, except when the constraints on one are implied by the constraints
of another.
Example: I have a 4k page aligned structure. The first element is some
type of double float coming from a global simple type def. The global simple
type definition that says my specific kind of double floats are always
8-byte aligned. The 4k page is obviously 4096 byte aligned. There should
be no conflict here. The page alignment "Wins" and the begining
of the structure is 4k aligned, and that satisifies the 8-byte alignment
of my specialized double float.
The point of having any restriction at all, is to catch conflicts. Eg.,
what if I had something that was 64-byte aligned, and I put it inside a
structure that has only 2-byte alignment....., this is probably an error.
If this isn't going to catch any errors, then this restriction is unnecessary.
3. Does DFDL need to support signed integer types with lengthUnits
'bits'?
Spec only allows unsigned integers to have lengthUnits 'bits', but
it is possible in C structures to delare
bit fields for signed integers. They behave like two's complement.
It looks like the spec is being
too restrictive in its types for 'bits'.
I missed this over restriction. Signed are definitely needed.
--
Mike Beckerle | OGF DFDL WG Co-Chair
Tel: 781-330-0412
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number
741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU