Sponsored Content
Operating Systems Solaris Solaris 5.8 - BinaryFile - Endianness Post 302350603 by jlliagre on Friday 4th of September 2009 10:16:26 AM
Old 09-04-2009
It doesn't make sense for a binary file to contain both big and little endian values but this happens and sometimes there are even explanations about it.
However, if your Windows little endian code reads correctly say a 16bit or 32 bit integer value AND the very same code compiled on a big endian machine read the very same values at the same location without byte swapping, then you are just lucky enough to have a value that reads the same in both standards, like (assuming 16 bit unsigned integers) 0, 257, 514, 771, ..., 65535.
 

5 More Discussions You Might Find Interesting

1. Solaris

application compiled on solaris 10 throwing error when executed on solaris 9

I have compiled my application on Solaris 10 with following description SunOS ldg1 5.10 Generic_138888-03 sun4v sparc SUNW,Sun-Blade-T6320 The compiler is Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25 But when installing the application on Solaris 9 SunOS odcarch02 5.9... (2 Replies)
Discussion started by: ash_bit2k2
2 Replies

2. Solaris

Unable to login using ssh,telnet onto my solaris machine with solaris 10 installed

Hi, I am unable to login into my terminal hosting Solaris 10 and get the below error message "Server refused to allocate pty ld.so.1: sh: fatal: libc.so.1: open failed: No such file or directory " Is there anyways i can get into my machine and what kind of changes are required to be... (7 Replies)
Discussion started by: sankasu
7 Replies

3. UNIX for Advanced & Expert Users

How to know endianness of a machine

hi I have a ubuntu machine and want to know the endianness of the system.... How would i get to know..... The information of my machine is: uname -a 42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 201 1 i686 i686 i386 GNU/Linux and lsb_release -a No LSB modules are available.... (6 Replies)
Discussion started by: Ankita Singlaa
6 Replies

4. Solaris

How to add Solaris text console to Solaris grub2 menu?

Hi, I am new to sloaris and just instlled the solaris 11.2, i know little more about linux, i open the /boot/grub/grub.cfg in solaris and there is many other entries forl solaris 11.2 one of them is for 'Oracle Solaris 11.2 text console' but at boot grub2 only show the first default entry that... (1 Reply)
Discussion started by: shamsat
1 Replies

5. AIX

IBM TDS/SDS (LDAP) - can I mix endianness among servers in an instance ?

I'd like to add some x/linux-based servers to my current AIX-based TDS/SDS server community. Reading the Fine Install Guide (rtfig ?) I believe this may be covered by the section "Upgrade an instance of a previous version to a different computer" i.e. I'm going to install latest/greatest SDS on a... (4 Replies)
Discussion started by: maraixadm
4 Replies
BYTEORDER(9)						   BSD Kernel Developer's Manual					      BYTEORDER(9)

NAME
bswap16, bswap32, bswap64, be16toh, be32toh, be64toh, htobe16, htobe32, htobe64, htole16, htole32, htole64, le16toh, le32toh, le64toh, be16enc, be16dec, be32enc, be32dec, be64enc, be64dec, le16enc, le16dec, le32enc, le32dec, le64enc, le64dec -- byte order operations SYNOPSIS
#include <sys/endian.h> uint16_t bswap16(uint16_t int16); uint32_t bswap32(uint32_t int32); uint64_t bswap64(uint64_t int64); uint16_t be16toh(uint16_t big16); uint32_t be32toh(uint32_t big32); uint64_t be64toh(uint64_t big64); uint16_t htobe16(uint16_t host16); uint32_t htobe32(uint32_t host32); uint64_t htobe64(uint64_t host64); uint16_t htole16(uint16_t host16); uint32_t htole32(uint32_t host32); uint64_t htole64(uint64_t host64); uint16_t le16toh(uint16_t little16); uint32_t le32toh(uint32_t little32); uint64_t le64toh(uint64_t little64); uint16_t be16dec(const void *); uint32_t be32dec(const void *); uint64_t be64dec(const void *); uint16_t le16dec(const void *); uint32_t le32dec(const void *); uint64_t le64dec(const void *); void be16enc(void *, uint16_t); void be32enc(void *, uint32_t); void be64enc(void *, uint64_t); void le16enc(void *, uint16_t); void le32enc(void *, uint32_t); void le64enc(void *, uint64_t); DESCRIPTION
The bswap16(), bswap32(), and bswap64() functions return a byte order swapped integer. On big endian systems, the number is converted to little endian byte order. On little endian systems, the number is converted to big endian byte order. The be16toh(), be32toh(), and be64toh() functions return a big endian byte ordered integer converted to the system's native byte order. The return value will be the same as the argument on big endian systems. The le16toh(), le32toh(), and le64toh() functions return a little endian byte ordered integer converted to the system's native byte order. The return value will be the same as the argument on little endian systems. The htobe16(), htobe32(), and htobe64() functions return a integer in the system's native byte order converted to big endian byte order. The return value will be the same as the argument on big endian systems. The htole16(), htole32(), and htole64() functions return a integer in the system's native byte order converted to little endian byte order. The return value will be the same as the argument on little endian systems. The be16enc(), be16dec(), be32enc(), be32dec(), be64enc(), be64dec(), le16enc(), le16dec(), le32enc(), le32dec(), le64enc(), and le64dec() functions encode and decode integers to/from byte strings on any alignment in big/little endian format. SEE ALSO
byteorder(3) HISTORY
The hto*() and toh*() functions first appeared in FreeBSD 5.0, and were originally developed by the NetBSD project. The encode/decode functions first appeared in FreeBSD 5.1. BSD
April 29, 2002 BSD
All times are GMT -4. The time now is 09:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy