Re: Endianness in PHP

From: Date: Thu, 12 Aug 2010 05:18:09 +0000
Subject: Re: Endianness in PHP
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-7468@lists.php.net to get a copy of this message
On Thu, Aug 12, 2010 at 4:28 AM, J. Adams <zardozrocks@gmail.com> wrote: > Two questions: > 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 > 2) Can anyone recommend a cheap way to gain access to a Big-Endian machine > for development and testing? get old PowerPC mac ("mac mini G4" or something like that) > > > The reason I ask is that I see that AMFEXT makes no effort to convert byte > order when serializing an integer: > http://lxr.php.net/xref/PECL/amfext/amf.c#amf3_write_int > > The AMF3 spec indicates that numbers are to be serialized in network byte > order (i.e., "big-endian"). I see that Z_LVAL macros are used to extract the > actual number data from a zval object or pointer to zval object by grabbing > the contents of the zval's "lval" field  which is declared as long. That > function I linked, amf3_write_int, appears to work fine on a linux box with > intel chip.  I'm thinking it would break on a big-endian chip. > > Any advice would be greatly appreciated! -- Alexey Zakhlestin http://www.milkfarmsoft.com/

« previous php.pecl.dev (#7468) next »