Index: sys/_endian.h =================================================================== RCS file: /cvs/src/sys/sys/_endian.h,v retrieving revision 1.2 diff -u -p -r1.2 _endian.h --- sys/_endian.h 21 Apr 2017 19:04:22 -0000 1.2 +++ sys/_endian.h 5 Jun 2017 01:11:00 -0000 @@ -104,6 +104,21 @@ * where we can take advantage of the CSE phase much better by using the * generic version. */ + +/* + * Unless provided by the machine, the kernel will fall back to function + * calls for "MD" swap operations. + */ +#ifdef _KERNEL +#ifndef __HAVE_MD_SWAP +__uint16_t __swap16md(__uint16_t); +__uint32_t __swap32md(__uint32_t); +__uint64_t __swap64md(__uint64_t); +#define __HAVE_EMUL_MD_SWAP /* for sys/kern/kern_subr.c */ +#define __HAVE_MD_SWAP +#endif /* !__HAVE_MD_SWAP */ +#endif /* _KERNEL */ + #ifdef __HAVE_MD_SWAP #if __GNUC__ Index: kern/kern_subr.c =================================================================== RCS file: /cvs/src/sys/kern/kern_subr.c,v retrieving revision 1.49 diff -u -p -r1.49 kern_subr.c --- kern/kern_subr.c 14 Feb 2017 10:31:15 -0000 1.49 +++ kern/kern_subr.c 5 Jun 2017 01:11:00 -0000 @@ -44,6 +44,7 @@ #include #include #include +#include int uiomove(void *cp, size_t n, struct uio *uio) @@ -257,3 +258,23 @@ dohooks(struct hook_desc_head *head, int } } } + +#ifdef __HAVE_EMUL_MD_SWAP +__uint16_t +__swap16md(__uint16_t x) +{ + return (__swap16gen(x)); +} + +__uint32_t +__swap32md(__uint32_t x) +{ + return (__swap32gen(x)); +} + +__uint64_t +__swap64md(__uint64_t x) +{ + return (__swap64gen(x)); +} +#endif