Re: [PECL-DEV] Endianness in PHP
[email protected] (Alexey Zakhlestin)
| Newsgroups | php.pecl.dev |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Aug 12, 2010 at 4:28 AM, J. Adams <[email protected]> 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/