Page MenuHomeFreeBSD

D32051.id95478.diff
No OneTemporary

D32051.id95478.diff

Index: include/Makefile
===================================================================
--- include/Makefile
+++ include/Makefile
@@ -9,7 +9,8 @@
CLEANFILES= osreldate.h version
SUBDIR= arpa protocols rpcsvc rpc xlocale
SUBDIR_PARALLEL=
-INCS= a.out.h ar.h assert.h bitstring.h complex.h cpio.h _ctype.h ctype.h \
+INCS= a.out.h ar.h assert.h bitstring.h byteswap.h \
+ complex.h cpio.h _ctype.h ctype.h \
db.h \
dirent.h dlfcn.h elf.h elf-hints.h endian.h err.h fmtmsg.h fnmatch.h \
fstab.h fts.h ftw.h getopt.h glob.h grp.h \
Index: include/byteswap.h
===================================================================
--- /dev/null
+++ include/byteswap.h
@@ -0,0 +1,31 @@
+/*-
+ * Copyright (c) 2021 M. Warner Losh <imp@FreeBSD.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+/*
+ * A mostly Linux/glibc-compatible byteswap.h
+ */
+
+#ifndef _BYTESWAP_H_
+#define _BYTESWAP_H_
+
+#include <sys/_endian.h>
+
+/*
+ * byteswap.h defines the macros below. Much software are uses either
+ * sys/endian.h or endian.h and byteswap.h. One can't define bswap16 etc in
+ * endian.h because some software defines them only when they detect endian.h is
+ * used (but not when sys/endian.h is used). So for endian.h to work properly,
+ * we have to pair it with this file, with these defines.
+ */
+#define __bswap_16(x) __bswap16(x)
+#define __bswap_32(x) __bswap32(x)
+#define __bswap_64(x) __bswap64(x)
+
+#define bswap_16(x) __bswap16(x)
+#define bswap_32(x) __bswap32(x)
+#define bswap_64(x) __bswap64(x)
+
+#endif /* _BYTESWAP_H_ */
Index: sys/sys/_endian.h
===================================================================
--- sys/sys/_endian.h
+++ sys/sys/_endian.h
@@ -32,7 +32,7 @@
#ifndef _SYS__ENDIAN_H_
#define _SYS__ENDIAN_H_
-#if !defined(_MACHINE_ENDIAN_H_) && !defined(_ENDIAN_H_)
+#if !defined(_MACHINE_ENDIAN_H_) && !defined(_BYTESWAP_H_) && !defined(_ENDIAN_H_)
#error "sys/_endian.h should not be included directly"
#endif

File Metadata

Mime Type
text/plain
Expires
Mon, Jun 15, 12:55 PM (18 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33969362
Default Alt Text
D32051.id95478.diff (1 KB)

Event Timeline