date and time created 91/05/09 00:09:50 by bostic
[unix-history] / usr / src / sys / hp300 / include / endian.h
CommitLineData
add196b0 1/*
cbc50af1 2 * Copyright (c) 1987, 1991 Regents of the University of California.
add196b0
KB
3 * All rights reserved.
4 *
6dc0e27a 5 * %sccs.include.redist.c%
add196b0 6 *
cbc50af1 7 * @(#)endian.h 7.7 (Berkeley) %G%
add196b0
KB
8 */
9
10/*
cbc50af1
KB
11 * Definitions for byte order, according to byte significance from low
12 * address to high.
add196b0 13 */
cbc50af1
KB
14#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
15#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
16#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
add196b0 17
07f209ed 18#define BYTE_ORDER BIG_ENDIAN
add196b0 19
cbc50af1
KB
20#ifndef KERNEL
21#include <sys/cdefs.h>
22#endif
23
24__BEGIN_DECLS
25unsigned long htonl __P((unsigned long));
26unsigned short htons __P((unsigned short));
27unsigned long ntohl __P((unsigned long));
28unsigned short ntohs __P((unsigned short));
29__END_DECLS
30
add196b0
KB
31/*
32 * Macros for network/external number representation conversion.
33 */
dc7b7034 34#if BYTE_ORDER == BIG_ENDIAN && !defined(lint)
add196b0
KB
35#define ntohl(x) (x)
36#define ntohs(x) (x)
37#define htonl(x) (x)
38#define htons(x) (x)
6fdc2f43
MK
39
40#define NTOHL(x) (x)
41#define NTOHS(x) (x)
42#define HTONL(x) (x)
43#define HTONS(x) (x)
44
add196b0 45#else
6fdc2f43 46
cbc50af1
KB
47#define NTOHL(x) (x) = ntohl((u_long)x)
48#define NTOHS(x) (x) = ntohs((u_short)x)
49#define HTONL(x) (x) = htonl((u_long)x)
50#define HTONS(x) (x) = htons((u_short)x)
add196b0 51#endif