endian.h (75f4a9b20652ea31aab12e70f02027af62e45035) endian.h (03516cfeb01dd63a72e120acc0ad027bd5bde63a)
1/*
2 * Copyright (c) 1987, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 41 unchanged lines hidden (view full) ---

50 * address to high.
51 */
52#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
53#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
54#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
55
56#define BYTE_ORDER BIG_ENDIAN
57
1/*
2 * Copyright (c) 1987, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 41 unchanged lines hidden (view full) ---

50 * address to high.
51 */
52#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
53#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
54#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
55
56#define BYTE_ORDER BIG_ENDIAN
57
58#ifndef _KERNEL
58#include <sys/cdefs.h>
59#include <sys/cdefs.h>
59#include <sys/types.h>
60#endif
61#include <machine/ansi.h>
60
61__BEGIN_DECLS
62
63__BEGIN_DECLS
62in_addr_t htonl __P((in_addr_t)) __attribute__((__const__));
63in_port_t htons __P((in_port_t)) __attribute__((__const__));
64in_addr_t ntohl __P((in_addr_t)) __attribute__((__const__));
65in_port_t ntohs __P((in_port_t)) __attribute__((__const__));
66u_int16_t bswap16 __P((u_int16_t)) __attribute__((__const__));
67u_int32_t bswap32 __P((u_int32_t)) __attribute__((__const__));
68u_int64_t bswap64 __P((u_int64_t)) __attribute__((__const__));
64__uint32_t htonl __P((__uint32_t));
65__uint16_t htons __P((__uint16_t));
66__uint32_t ntohl __P((__uint32_t));
67__uint16_t ntohs __P((__uint16_t));
68__uint16_t bswap16 __P((__uint16_t));
69__uint32_t bswap32 __P((__uint32_t));
70__uint64_t bswap64 __P((__uint64_t));
69__END_DECLS
70
71/*
72 * Macros for network/external number representation conversion.
73 */
74#if BYTE_ORDER == BIG_ENDIAN && !defined(lint)
75#define ntohl(x) (x)
76#define ntohs(x) (x)
77#define htonl(x) (x)
78#define htons(x) (x)
79
80#define NTOHL(x) (x)
81#define NTOHS(x) (x)
82#define HTONL(x) (x)
83#define HTONS(x) (x)
84
85#else
86
71__END_DECLS
72
73/*
74 * Macros for network/external number representation conversion.
75 */
76#if BYTE_ORDER == BIG_ENDIAN && !defined(lint)
77#define ntohl(x) (x)
78#define ntohs(x) (x)
79#define htonl(x) (x)
80#define htons(x) (x)
81
82#define NTOHL(x) (x)
83#define NTOHS(x) (x)
84#define HTONL(x) (x)
85#define HTONS(x) (x)
86
87#else
88
87#define NTOHL(x) (x) = ntohl((in_addr_t)(x))
88#define NTOHS(x) (x) = ntohs((in_port_t)(x))
89#define HTONL(x) (x) = htonl((in_addr_t)(x))
90#define HTONS(x) (x) = htons((in_port_t)(x))
89#define NTOHL(x) (x) = ntohl((__uint32_t)(x))
90#define NTOHS(x) (x) = ntohs((__uint16_t)(x))
91#define HTONL(x) (x) = htonl((__uint32_t)(x))
92#define HTONS(x) (x) = htons((__uint16_t)(x))
91#endif
92
93#endif /* !_POSIX_SOURCE */
94#endif /* !_ENDIAN_H_ */
93#endif
94
95#endif /* !_POSIX_SOURCE */
96#endif /* !_ENDIAN_H_ */