Re: [PECL-DEV] Endianness in PHP

[email protected] (Johannes Schlüter)
Newsgroups php.pecl.dev
Organization php.net
Message-ID <1281607166.974.22.camel@guybrush>
Hi,

On Wed, 2010-08-11 at 22:43 -0700, "J. Adams" wrote:
> >> 1) Is there a standardized way or recommended best practice for conversions
> >> of ints, longs, and doubles to network byte order?
> >>     
> >
> > Usually, operating system provides functions for this.
> > Look for the following functions: htonl, htons, ntohl, ntohs
> >   
> It's my understanding that these functions aren't always available.  
> This link:

Right that is all OS dependent. Standard C doesn't provide any such
things.

What we're having is a WORDS_BIGENDIAN define which is set on big endian
machines and undefined on little endian machines. which we use in some
places to do manual conversions:
http://lxr.php.net/opengrok/search?q=&project=PHP_5_3&defs=&refs=WORDS_BIGENDIAN&path=&hist=

> >> 2) Can anyone recommend a cheap way to gain access to a Big-Endian machine
> >> for development and testing?
 
> Ugh.  I was rather hoping I could get access to a VPS somewhere, perhaps 
> through EC2 or Rackspace.com. 

They all provide x86 hardware as modern big endian gear is relatively
expensive and not what most people expect. Sun provided a test machine
though (see also private mail) while currently I can't provide accounts
there.

johannes
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.