|Adding "shared" to C, need sysv386 .section syntax email@example.com (1991-09-19)|
|Re: Adding "shared" to C, need sysv386 .section syntax firstname.lastname@example.org (1991-09-23)|
|Re: Adding "shared" to C, need sysv386 .section syntax email@example.com (1991-09-24)|
|Re: Adding "shared" to C, need sysv386 .section syntax firstname.lastname@example.org (1991-09-25)|
|From:||email@example.com (Steve Nuchia)|
|Keywords:||C, 386, assembler|
|Organization:||South Coast Computing Services, Inc. Houston|
|Date:||Thu, 19 Sep 91 14:08:38 GMT|
This may be over the edge of the comp.compilers charter, but I've tried in
comp.unix.sysv386 and I really want to make this work...
I am trying to add a "shared" storage class to gcc for an embedded
application I am working on. This is a special-purpose thing, but it is
important for several reasons (but mainly aesthetics) that the
shared-variable support be well integrated into the language.
I know that it is easy enough to use some combination of preprocessor
hackery and code extraction/generation -> sed -> as tricks to get the job
done, but I would really like to be able to have what little help C gives
me with type checking and scope control apply to these buggers, and adding
the keyword seems to me to be a good way to do it.
My plan is this:
Add a keyword "shared" to the language to act as a storage class modifier
(or is it a storage class? dunno yet) with two main effects. First, it
gives the objects being declared persistent semantics -- like "static"
inside a function. Secondly it arranges that the allocation of the
variable be done in two pieces: it will write the initializer (including
zeros for objects not explicitly initialized) to a section that will be
linked into the (shared read only) text segment. Then it places the label
for the object and a . += size type thing into a dummy segment to be
relocated at an "appropriate" address. Main then allocates and attaches a
sysV shared memory segment to that address and copies the initializers to
it before forking (the threads all run one image, no execing).
Why am I using sysV for an embedded system? Some questions are best left
unanswered. Don't even think about asking me why we're using X in a
hard-realtime job ...
Anyway... I'd certainly appreciate any commentary or discussion on the
proposal. I'll release the gcc patches if anyone is interested, but I am
not proposing this as a "real" extension to C, just a clean way of doing
what I need for a specific project.
But the real purpose of this plea for help: I cannot find the syntax for
the .section directive of the interactive (ie, nearly universal) sysv/386
"as" assembler. I know from error messages that there is such a
directive, but the compiler uses only the .text, .data sort of
This is incredibly frustrating. @#$%^&*( black-box software. Grrr.
Steve Nuchia South Coast Computing Services (713) 880-0099
Return to the
Search the comp.compilers archives again.