Experimental Physics and
| |||||||||||||||||
|
I'm surprised Jeff Hill hasn't jumped onto this thread. He and I had talked about similar issues before. Maybe he's getting some work done and ignoring tech-talk. Anyway, the thing about using packed structures in order to access memory mapped I/O or raw network packages is that you often run into compiler-specific "pack" instructions. Larry's copy works around the alignment, next you'd run into byte order issues when you change the CPU type. The most portable way of coding might be to always use byte pointers and assemble/disassemble the data yourself. So instead of .... typedef struct __attribute__ ((packed)){ unsigned char uCh; short sInt; .... you use .... volatile char *buf = <some address>; unsigned char uCh = *(buf++); unsigned short low = *(buf++); unsigned short high = *(buf++); short sInt = (high << 8) | low; .... You can somewhat beautify this by defining routines unpack_short(), ... -Kay On Sep 2, 2004, at 14:56, Lawrence T. Hoff wrote: As far as I know, that is a characteristic of the SPARC processor, and cannot be
| ||||||||||||||||
ANJ, 10 Aug 2010 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |