133280Sbostic /* 247793Sbostic * Copyright (c) 1987, 1991 Regents of the University of California. 333280Sbostic * All rights reserved. 433280Sbostic * 544541Sbostic * %sccs.include.redist.c% 633280Sbostic * 7*52002Smckusick * @(#)endian.h 7.9 (Berkeley) 12/19/91 833280Sbostic */ 933280Sbostic 1033280Sbostic /* 11*52002Smckusick * Define _NOQUAD if the compiler does NOT support 64-bit integers. 12*52002Smckusick */ 13*52002Smckusick /* #define _NOQUAD */ 14*52002Smckusick 15*52002Smckusick /* 16*52002Smckusick * Define the order of 32-bit words in 64-bit words. 17*52002Smckusick */ 18*52002Smckusick #define _QUAD_HIGHWORD 1 19*52002Smckusick #define _QUAD_LOWWORD 0 20*52002Smckusick 21*52002Smckusick #ifndef _POSIX_SOURCE 22*52002Smckusick /* 2347793Sbostic * Definitions for byte order, according to byte significance from low 2447793Sbostic * address to high. 2533280Sbostic */ 2647793Sbostic #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ 2747793Sbostic #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ 2847793Sbostic #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ 2933280Sbostic 3047793Sbostic #define BYTE_ORDER LITTLE_ENDIAN 3133280Sbostic 3247793Sbostic #include <sys/cdefs.h> 3347793Sbostic 3447793Sbostic __BEGIN_DECLS 3547793Sbostic unsigned long htonl __P((unsigned long)); 3647793Sbostic unsigned short htons __P((unsigned short)); 3747793Sbostic unsigned long ntohl __P((unsigned long)); 3847793Sbostic unsigned short ntohs __P((unsigned short)); 3947793Sbostic __END_DECLS 4047793Sbostic 4133280Sbostic /* 4233280Sbostic * Macros for network/external number representation conversion. 4333280Sbostic */ 4433381Skarels #if BYTE_ORDER == BIG_ENDIAN && !defined(lint) 4533280Sbostic #define ntohl(x) (x) 4633280Sbostic #define ntohs(x) (x) 4733280Sbostic #define htonl(x) (x) 4833280Sbostic #define htons(x) (x) 4940610Skarels 5040610Skarels #define NTOHL(x) (x) 5140610Skarels #define NTOHS(x) (x) 5240610Skarels #define HTONL(x) (x) 5340610Skarels #define HTONS(x) (x) 5440610Skarels 5533280Sbostic #else 5640610Skarels 5740804Ssklower #define NTOHL(x) (x) = ntohl((u_long)x) 5840804Ssklower #define NTOHS(x) (x) = ntohs((u_short)x) 5940804Ssklower #define HTONL(x) (x) = htonl((u_long)x) 6040804Ssklower #define HTONS(x) (x) = htons((u_short)x) 6133280Sbostic #endif 62*52002Smckusick #endif /* ! _POSIX_SOURCE */ 63