That wasn’t the original poster’s question. His question was, how do I
determine the endianness of the CPU on which I am executing? Is there a
possibility of a CPU executing your code in either BE or LE mode? Jay
Talbott says no. I think he’s right.
I can see conditional compilation might be required, depending on the target
ISA, but I can’t imagine any situation in which runtime detection of the
endianness of your current environment is necessary, unless there is a CPU
that will run in both modes, and you can be run in an arbitrary mode. Does
such an environment exist?
-----Original Message-----
From: Roddy, Mark [mailto:xxxxx@stratus.com]
Sent: Thursday, May 10, 2001 10:35 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Determining the CPU Endianness!
You might be communicating with hardware that has different endianess.
Mark Roddy
xxxxx@hollistech.com
www.hollistech.com
603 321 1032
WindowsNT Windows 2000 Consulting Services
-----Original Message-----
From: Barila, Phil [mailto:xxxxx@intel.com]
Sent: Thursday, May 10, 2001 12:44 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Determining the CPU Endianness!
Pardon me for demonstrating my ignorance here, isn’t the endianness of your
hardware known at compile time? Is there any ISA on which NT is supported
that can be big- or little-endian? In other words, is it even possible to
produce a binary for NT that can run on systems with both endiannesses
without modification?
Thanks for educating me,
Phil
-----Original Message-----
From: Thomas F. Divine [mailto:xxxxx@pcausa.com]
Sent: Thursday, May 10, 2001 9:10 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Determining the CPU Endianness!
Here is a quick ENDIAN detection fragment:
BOOLEAN UTIL_IsBigEndian()
{
static USHORT _I_ENDIAN_TEST = 0xFF00;
return( *(PUCHAR )&_I_ENDIAN_TEST );
}
Good luck,
Thomas F. Divine
PCAUSA - Toolkits & Resources For Network Software Developers
NDIS Protocol - NDIS Intermediate - TDI Client
http: - http:
----- Original Message -----
From: Jacob
To: NT Developers Interest List
Sent: Thursday, May 10, 2001 11:44 AM
Subject: [ntdev] Re: Determining the CPU Endianness!
> void main()
> {
> union {
> DWORD a;
> CHAR b[4];
> } x;
> x.a = 0x12345678;
> for (int j = 0; j < 4; j++)
> printf ("%02x ", x.b[j]);
> }
>
> -----Original Message-----
> From: Varadan Venkatesh
> To: NT Developers Interest List
> Date: Thursday, May 10, 2001 11:37 AM
> Subject: [ntdev] Determining the CPU Endianness!
>
>
> >Hello All
> >
> >How do I determine the CPU endianness of the processor in which my code
> >runs?
> >Basically RTL functions swap LE to BE and viceversa. But how do i
determine
> >when
> >to swap or when not to swap? I was going through windows.h. there are a
few
> >defines
> >like MPPC, 68K, _M_ALPHA, _M_IX86 etc. Will _M_IX86 be defined for
all
> >x86 CPUs (irrespective of PENTIUM, PENTIUM2 etc.)?
> >
> >Could anybody give any pointers on this?
> >
> >Thanks
> >Venky
> >
—
You are currently subscribed to ntdev as: xxxxx@intel.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
—
You are currently subscribed to ntdev as: xxxxx@stratus.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
—
You are currently subscribed to ntdev as: xxxxx@intel.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
—
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com</http:></http:>