#ifndef __sys_endian__ #define __sys_endian__ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. * * Redistribution is only permitted until one year after the first shipment * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and * binary forms are permitted provided that: (1) source distributions retain * this entire copyright notice and comment, and (2) distributions including * binaries display the following acknowledgement: This product includes * software developed by the University of California, Berkeley and its * contributors'' in the documentation or other materials provided with the * distribution and in all advertising materials mentioning features or use * of this software. Neither the name of the University nor the names of * its contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)endian.h 7.5 (Berkeley) 6/28/90 */ #ident "$Revision: 1.4 $" /* * Definitions for byte order, * according to byte significance from low address to high. */ #define LITTLE_ENDIAN 1234 /* least-significant byte first (vax) */ #define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */ #define BYTE_ORDER LITTLE_ENDIAN /* byte order on x86 */ #if BYTE_ORDER == LITTLE_ENDIAN static unsigned long ntohl(unsigned long x) { return ((x << 24) | ((x & 0xff00) << 8) | ((x >> 8) & 0xff00) | (x >> 24)); } static unsigned short ntohs(unsigned short x) { return (x << 8) | (x >> 8); } #define htonl(x) ntohl(x) #define htons(x) ntohs(x) #endif #endif /* __sys_endian__ */