This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Network programming for eCos under linux


Trenton D. Adams writes:

>   > <soapbox>
>   > 
>   > I've claimed for many years that C, as a systems language,
>   > should provide a way for the user to specify data layout in
>   > memory when it is require for meeting external requirements
>   > such as memory mapped hardware, comm protocols, etc.  This
>   > would allow the user to control data layout in a static,
>   > declaritive approach, similar to the way C deals with data
>   > types and scoping: all three would be could declared at
>   > compile-time.
>   > 
>   > The C language mavens reply that C _could_ do something like
>   > that, but they prefer to leave it up to the user to shovel
>   > individual bytes around to get them arranged as desired. (That
>   > way it's much more error prone and uses up more CPU cycles!)
>   > They seem to prefer an imperitive approach, where you layout
>   > data at run-time rather than at compile time, even though
>   > everything else about data objects (type, scope) is defined at
>   > compile time.
>   > 
>   > I don't understand their reasoning, but there's no way I'm ever
>   > going to convince them to change things now. :)
>   > 
>   > </soapbox>
>   >  
> 
> Well apparently Microsoft's compiler doesn't follow the standard then!
> Oh, that's a big surprise!!!! ;) LMAO.  Anyhow, it allows you to specify
> alignment for compile time.  I would have to say that in this case, I
> agree with Microsoft not following the standard! :)  
>

Gcc does let you partially specify alignment/packing: AFAIK, qthere's no way 
to prevent it from padding the end of the struct.  But, it won't
generate guaranteed valid instruction sequences when you access the fields.  
If you could at least prevent the padding, you could use fields
as targets for memcpy() operations, but the padding prevents that from
being a usable option. 

[Apologies for message formatting problems. My Cisco 675 just locked up 
again (third time this week). I have to use a web-mail interface until
I can get home and cycle power on the stupid thing.  I guess it's time
to try upgrading the flash...]
-- 
Grant Edwards
grante@visi.com 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]