Re: Some questions and tidbits

Alan Young (ayoung@teleport.com)
Thu, 10 Jun 1999 23:14:10 -0700


Shaw Terwilliger wrote:
>
> The code is 64-bit clean, as far as I know. I've got an Alpha beside my
> desk at work, it runs Linux, and it's built the word importer (although
> not cleanly by any means; pages and pages of warnings) and imported all
> the Word97 files I've thrown at it. The Word97 importer code is all
> cross-platform; same code for Unix, Mac, Win32, BeOS.

Cool. My main partition is a Linux partition. :)

> This isn't to say the code is compiled the same, though. I thought
> that Windows NT was 32-bit on the Alpha; I was thinking at least user-space
> was exported that way, kind of like Windows 3.1 on a Pentium (but double
> the word sizes).

I did a check and it looks like the data sizes are the same. I think I
thought there might size problems as alot of the compiler warnings were for
conversions between one type and another. Some examples are:

mswordview.c
mswordview.c(611) : warning C4244: '=' : conversion from 'double ' to 'float ',
possible loss of data
mswordview.c(350) : warning C4101: 'fileinbuf' : unreferenced local variable
mswordview.c(1259) : warning C4018: '<' : signed/unsigned mismatch
mswordview.c(1264) : warning C4018: '<' : signed/unsigned mismatch
mswordview.c(1342) : warning C4244: '=' : conversion from 'unsigned short ' to
'char ', possible loss of data

table.c
table.c(448) : warning C4244: '=' : conversion from 'const double ' to 'int ',
possible loss of data
table.c(451) : warning C4244: '=' : conversion from 'const double ' to 'int ',
possible loss of data

If you would like the entire make log, let me know and I'll send it to you
off-list.

> Could you pass any information about the compiler setup? Perhaps the
> compiler is packing structs for efficiency in a way 64-bit GCC doesn't
> do on Unix. Are the data type sizes under Windows NT Alpha the same as
> Digital Unix (Tru64) Alpha? Again I was thinking there were some 32-bit-isms
> in there that might confuse code which is so specially aimed at dissecting
> individual bytes from a complex file format.

Hmmm...packing can definately cause problems if the code is messing with unions
and structures. The default is to align structure members on quadword
boundries. This is can be controlled via the /Zp switch or #pragma pack
directive. It would be best to use the #pragma on the affected structures as
alignments less than a quadword will cause the compiler generate extra code.
Also of note is the compiler default to align non-structures so they start
on quadwords. That's controllable with the /QAgq (quadword granularity) or
the /QAgl (longword granularity) switch.

This is a table of sizes and default alignments:
size alignment
char 1 byte
short 2 word
int 4 doubleword
__int64 8 quadword
long 4 doubleword
float 4 doublewotd
double 8 quadword
long double 8 quadword

The __unaligned keyword can also affect alignment.

Hope this helps. Please let me know if you need anything else.

Alan



This archive was generated by hypermail 1.03b2.