View | Details | Raw Unified | Return to bug 236398 | Differences between
and this patch

Collapse All | Expand All

(-)b/include/Makefile (-2 / +2 lines)
Lines 12-19 SUBDIR= arpa protocols rpcsvc rpc xlocale Link Here
12
SUBDIR_PARALLEL=
12
SUBDIR_PARALLEL=
13
INCS=	a.out.h ar.h assert.h bitstring.h complex.h cpio.h _ctype.h ctype.h \
13
INCS=	a.out.h ar.h assert.h bitstring.h complex.h cpio.h _ctype.h ctype.h \
14
	db.h \
14
	db.h \
15
	dirent.h dlfcn.h elf.h elf-hints.h err.h fmtmsg.h fnmatch.h fstab.h \
15
	dirent.h dlfcn.h elf.h elf-hints.h endian.h err.h fmtmsg.h fnmatch.h \
16
	fts.h ftw.h getopt.h glob.h grp.h \
16
	fstab.h fts.h ftw.h getopt.h glob.h grp.h \
17
	ieeefp.h ifaddrs.h \
17
	ieeefp.h ifaddrs.h \
18
	inttypes.h iso646.h kenv.h langinfo.h libgen.h limits.h link.h \
18
	inttypes.h iso646.h kenv.h langinfo.h libgen.h limits.h link.h \
19
	locale.h malloc.h malloc_np.h memory.h monetary.h mpool.h mqueue.h \
19
	locale.h malloc.h malloc_np.h memory.h monetary.h mpool.h mqueue.h \
(-)b/include/endian.h (+48 lines)
Added Link Here
1
/*-
2
 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3
 *
4
 * Copyright (c) 2019 The FreeBSD Foundation
5
 *
6
 * This software was developed by Mark Johnston under sponsorship from
7
 * the FreeBSD Foundation.
8
 *
9
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions are
11
 * met:
12
 * 1. Redistributions of source code must retain the above copyright
13
 *    notice, this list of conditions and the following disclaimer.
14
 * 2. Redistributions in binary form must reproduce the above copyright
15
 *    notice, this list of conditions and the following disclaimer in
16
 *    the documentation and/or other materials provided with the distribution.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28
 * SUCH DAMAGE.
29
 */
30
31
#ifndef _ENDIAN_H_
32
#define	_ENDIAN_H_
33
34
#include <sys/endian.h>
35
36
/*
37
 * Avoid polluting the namespace.  Consumers can include sys/endian.h
38
 * directly if they want the bswap*() macros.
39
 */
40
#undef bswap16
41
#undef bswap32
42
#undef bswap64
43
44
#define	__BYTE_ORDER	_BYTE_ORDER
45
#define	__BIG_ENDIAN	_BIG_ENDIAN
46
#define	__LITTLE_ENDIAN	_LITTLE_ENDIAN
47
48
#endif
(-)b/sys/sys/endian.h (-12 / +12 lines)
Lines 67-82 typedef __uint64_t uint64_t; Link Here
67
 * endian to host byte order functions as detailed in byteorder(9).
67
 * endian to host byte order functions as detailed in byteorder(9).
68
 */
68
 */
69
#if _BYTE_ORDER == _LITTLE_ENDIAN
69
#if _BYTE_ORDER == _LITTLE_ENDIAN
70
#define	htobe16(x)	bswap16((x))
70
#define	htobe16(x)	__bswap16((x))
71
#define	htobe32(x)	bswap32((x))
71
#define	htobe32(x)	__bswap32((x))
72
#define	htobe64(x)	bswap64((x))
72
#define	htobe64(x)	__bswap64((x))
73
#define	htole16(x)	((uint16_t)(x))
73
#define	htole16(x)	((uint16_t)(x))
74
#define	htole32(x)	((uint32_t)(x))
74
#define	htole32(x)	((uint32_t)(x))
75
#define	htole64(x)	((uint64_t)(x))
75
#define	htole64(x)	((uint64_t)(x))
76
76
77
#define	be16toh(x)	bswap16((x))
77
#define	be16toh(x)	__bswap16((x))
78
#define	be32toh(x)	bswap32((x))
78
#define	be32toh(x)	__bswap32((x))
79
#define	be64toh(x)	bswap64((x))
79
#define	be64toh(x)	__bswap64((x))
80
#define	le16toh(x)	((uint16_t)(x))
80
#define	le16toh(x)	((uint16_t)(x))
81
#define	le32toh(x)	((uint32_t)(x))
81
#define	le32toh(x)	((uint32_t)(x))
82
#define	le64toh(x)	((uint64_t)(x))
82
#define	le64toh(x)	((uint64_t)(x))
Lines 84-99 typedef __uint64_t uint64_t; Link Here
84
#define	htobe16(x)	((uint16_t)(x))
84
#define	htobe16(x)	((uint16_t)(x))
85
#define	htobe32(x)	((uint32_t)(x))
85
#define	htobe32(x)	((uint32_t)(x))
86
#define	htobe64(x)	((uint64_t)(x))
86
#define	htobe64(x)	((uint64_t)(x))
87
#define	htole16(x)	bswap16((x))
87
#define	htole16(x)	__bswap16((x))
88
#define	htole32(x)	bswap32((x))
88
#define	htole32(x)	__bswap32((x))
89
#define	htole64(x)	bswap64((x))
89
#define	htole64(x)	__bswap64((x))
90
90
91
#define	be16toh(x)	((uint16_t)(x))
91
#define	be16toh(x)	((uint16_t)(x))
92
#define	be32toh(x)	((uint32_t)(x))
92
#define	be32toh(x)	((uint32_t)(x))
93
#define	be64toh(x)	((uint64_t)(x))
93
#define	be64toh(x)	((uint64_t)(x))
94
#define	le16toh(x)	bswap16((x))
94
#define	le16toh(x)	__bswap16((x))
95
#define	le32toh(x)	bswap32((x))
95
#define	le32toh(x)	__bswap32((x))
96
#define	le64toh(x)	bswap64((x))
96
#define	le64toh(x)	__bswap64((x))
97
#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */
97
#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */
98
98
99
/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */
99
/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */

Return to bug 236398