ton has asked for the wisdom of the Perl Monks concerning the following question:
I've written a Blowfish encyption module using Inline::C, and had pretty good results with it. I am currently using this module to encrypt data streams sent from one computer to another. However, I've run into a problem in transmitting data between machines with different architectures: the endien-ness of the CPU affects the encryption results. I got around this through a _ByteReverse function that is used if some compile-time flag is set, and I set that compile time flag ($bigEndian) within the BEGIN section of the package. So far, so good.
My problem lies in determining whether or not $bigEndian should be true. I know I can check $^O for the OS type, and this lets me cheat a bit: Windows and Linux systems are usually Little-Endian, while HPUX is usually Big-Endian. But sparc machines can be either, and Linux _could_ be installed on a machine not using an Intel or AMD CPU.
Is there some perl function that can give me the endian-ness of the CPU? Or some subroutine I can write to have the package determine this on its own? Or am I stuck with my OS-type hack?
Any help is appreciated,
-Ton
-----
Be bloody, bold, and resolute; laugh to scorn
The power of man...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How can I programatically determine the Endian-ness of the CPU?
by grep (Monsignor) on Jan 26, 2002 at 05:07 UTC | |
|
Re: How can I programatically determine the Endian-ness of the CPU?
by wog (Curate) on Jan 26, 2002 at 05:14 UTC |