M
Mark Piffer
On 20 Dec 2004 09:33:11 -0800, Mark Piffer
any errors.
those terms (you think I don't remember those poor OT-poster skeletons
rotting in their cages alongside the entrance to c.l.c? )
containing this set, but an allocator for it would be next to useless,
because you are forced to always use up storage for the largest
member. The alignment issues are clear to me and I don't mind them, if
I want general purpose alignment, it's up to the implementation, ok.
Please do not underestimate or deny the striving for portability in
embedded software. Most parts of the embedded software I have seen and
written do (or would) benefit substantially by being made conformant.
The ability to run code cross-platform is a tremendous help in
implementing embedded software and in simulating the application in a
much friendlier environment.
I am currently implementing a file-system-like part for an embedded
software. The only thing that is architecture dependent is the
low-level access to memory, 5 out of ca. 3000 lines of C. Right now I
have a setup that allows me, without touching the module itself,
compile and run it on an 16-bit big endian embedded as well as on my
32-bit little endian desktop machine. Now I have come to the point
that I want (for the sake of extendibility) rewrite the statemachines
which drive the high level operations on the memory. The statemachines
are hierarchical and could be beautifully controlled with a
polymorphic stack which holds the locals for each statemachine. As one
can't foresee the order in which the statemachines are called and
because storage on the embedded platform isn't large, an array of
unions is not feasible (oh well, maybe with a complete permutation of
all locals in all call orders, but then I'll bust implementation
limits). I can hide this, as you propose, behind some allocator magic,
but then the language has imposed on me an additional problem that I
didn't have before and worse, I lose another part of the ability to
simulate a 1:1 image of my code on the desktop. Maybe I'm suffering
from a narrowed mental horizon but IMHO the standardized UB was a bad
bargain for losing the "storage is storage is storage" property.
Mark
Very annoying, indeed! The following is hand-quoted so please excuseGoogle has problems, period!
any errors.
Well, by posting this to c.l.c I subject my questions automatically toYou've missed one word and one phrase -- 'portably' and "general
purpose".
those terms (you think I don't remember those poor OT-poster skeletons
rotting in their cages alongside the entrance to c.l.c? )
How would a set of types be implemented? I can think of a unionSimilarly, you can write an allocator which is fully portable for a
specific type or set of types. Trivially, you can make one which is
portable for char, by using a union you can make one which is portable
for all integral types, etc., but you can't make one which gives
alignment suitable for any purpose without knowing machine details.
containing this set, but an allocator for it would be next to useless,
because you are forced to always use up storage for the largest
member. The alignment issues are clear to me and I don't mind them, if
I want general purpose alignment, it's up to the implementation, ok.
same).Embedded programs are not portable in the same way,
they are implicitly (and sometimes explicitly) tied to a specific
architecture or set of architectures and hardware, so it is no problem
to have a specific allocator, preferably grouped in a library with other
machine specific functionality. All you then need to do, if the rest of
your program has been implemented portably, is to change the specific
parts which depend on the architecture (keeping the interface the
Please do not underestimate or deny the striving for portability in
embedded software. Most parts of the embedded software I have seen and
written do (or would) benefit substantially by being made conformant.
The ability to run code cross-platform is a tremendous help in
implementing embedded software and in simulating the application in a
much friendlier environment.
The point is that if you (or whoever is implementing the allocator)
knows what they are doing there is no problem. For instance, if you
know that the worst case alignment your program needs is a long then you
can do your own alignment to sizeof(long). If you know that your
machine has linear addresses which correspond to values in an unsigned
long then you can do appropriate arithmetic on them. It just isn't
portable to any architecture you might ever find -- but it may well work
for all machines you will ever find in practice which want to use your
Chris C
I am currently implementing a file-system-like part for an embedded
software. The only thing that is architecture dependent is the
low-level access to memory, 5 out of ca. 3000 lines of C. Right now I
have a setup that allows me, without touching the module itself,
compile and run it on an 16-bit big endian embedded as well as on my
32-bit little endian desktop machine. Now I have come to the point
that I want (for the sake of extendibility) rewrite the statemachines
which drive the high level operations on the memory. The statemachines
are hierarchical and could be beautifully controlled with a
polymorphic stack which holds the locals for each statemachine. As one
can't foresee the order in which the statemachines are called and
because storage on the embedded platform isn't large, an array of
unions is not feasible (oh well, maybe with a complete permutation of
all locals in all call orders, but then I'll bust implementation
limits). I can hide this, as you propose, behind some allocator magic,
but then the language has imposed on me an additional problem that I
didn't have before and worse, I lose another part of the ability to
simulate a 1:1 image of my code on the desktop. Maybe I'm suffering
from a narrowed mental horizon but IMHO the standardized UB was a bad
bargain for losing the "storage is storage is storage" property.
Mark