endian.h (6a068746777241722b2b32c5d0bc443a2a64d80b) endian.h (0558e4bb2b74b38cfd0b7372d13098a7d2e9c1b8)
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

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

34#define _MACHINE_ENDIAN_H_
35
36#include <sys/cdefs.h>
37#include <sys/_types.h>
38
39/*
40 * Define the order of 32-bit words in 64-bit words.
41 */
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

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

34#define _MACHINE_ENDIAN_H_
35
36#include <sys/cdefs.h>
37#include <sys/_types.h>
38
39/*
40 * Define the order of 32-bit words in 64-bit words.
41 */
42#ifdef __LITTLE_ENDIAN__
43#define _QUAD_HIGHWORD 1
44#define _QUAD_LOWWORD 0
45#else
42#define _QUAD_HIGHWORD 0
43#define _QUAD_LOWWORD 1
46#define _QUAD_HIGHWORD 0
47#define _QUAD_LOWWORD 1
48#endif
44
45/*
46 * GCC defines _BIG_ENDIAN and _LITTLE_ENDIAN equal to __BIG_ENDIAN__
47 * and __LITTLE_ENDIAN__ (resp).
48 */
49#ifdef _BIG_ENDIAN
50#undef _BIG_ENDIAN
51#endif

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

126
127#define __bswap16(x) ((__uint16_t)(__is_constant(x) ? __bswap16_const(x) : \
128 __bswap16_var(x)))
129#define __bswap32(x) (__is_constant(x) ? __bswap32_const(x) : \
130 __bswap32_var(x))
131#define __bswap64(x) (__is_constant(x) ? __bswap64_const(x) : \
132 __bswap64_var(x))
133
49
50/*
51 * GCC defines _BIG_ENDIAN and _LITTLE_ENDIAN equal to __BIG_ENDIAN__
52 * and __LITTLE_ENDIAN__ (resp).
53 */
54#ifdef _BIG_ENDIAN
55#undef _BIG_ENDIAN
56#endif

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

131
132#define __bswap16(x) ((__uint16_t)(__is_constant(x) ? __bswap16_const(x) : \
133 __bswap16_var(x)))
134#define __bswap32(x) (__is_constant(x) ? __bswap32_const(x) : \
135 __bswap32_var(x))
136#define __bswap64(x) (__is_constant(x) ? __bswap64_const(x) : \
137 __bswap64_var(x))
138
139#ifdef __LITTLE_ENDIAN__
140#define __htonl(x) (__bswap32((__uint32_t)(x)))
141#define __htons(x) (__bswap16((__uint16_t)(x)))
142#define __ntohl(x) (__bswap32((__uint32_t)(x)))
143#define __ntohs(x) (__bswap16((__uint16_t)(x)))
144#else
134#define __htonl(x) ((__uint32_t)(x))
135#define __htons(x) ((__uint16_t)(x))
136#define __ntohl(x) ((__uint32_t)(x))
137#define __ntohs(x) ((__uint16_t)(x))
145#define __htonl(x) ((__uint32_t)(x))
146#define __htons(x) ((__uint16_t)(x))
147#define __ntohl(x) ((__uint32_t)(x))
148#define __ntohs(x) ((__uint16_t)(x))
149#endif
138
139#endif /* !_MACHINE_ENDIAN_H_ */
150
151#endif /* !_MACHINE_ENDIAN_H_ */