Subject: Re: hton64
To: John F. Woods <jfw@jfwhome.funhouse.com>
From: Johan Danielsson <joda@pdc.kth.se>
List: current-users
Date: 06/29/1997 23:46:18
"John F. Woods" <jfw@jfwhome.funhouse.com> writes:

> Does the compiler vendor not define int16_t, or is the compiler
> obligated to emulate non-addressable quantities?

With addressable you mean "ability to load N bit scalars"?

I think the usual interpretation of intN_t is at least N bits.

Jason Thorpe <thorpej@nas.nasa.gov> writes:

> That's what the compiler on the Cray C90 does (and it only has
> 128-bit addressability :-)

Hmm, I think that all vector crays can address 64 bit quantities.  A
short is usually 32 bits, int and long are 64 bits.  The size of all
of them is 8.

The question is whether the C-code should be truly generic, or if
(reasonable) assumptions about the hardware can be made.

u_intN_t
_swapN(u_intN_t a, int n)
{
    u_intN_t b = 0;
    for(i = 0; i < 8 * n; i += 8)
	b = (b << 8) | ((a >> i) & 0xff);
    return b;
}

/Johan