diff options
Diffstat (limited to 'sys/compat/linuxkpi/common/include/asm/unaligned.h')
-rw-r--r-- | sys/compat/linuxkpi/common/include/asm/unaligned.h | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/sys/compat/linuxkpi/common/include/asm/unaligned.h b/sys/compat/linuxkpi/common/include/asm/unaligned.h index 7597f00f7596..e45846a3b543 100644 --- a/sys/compat/linuxkpi/common/include/asm/unaligned.h +++ b/sys/compat/linuxkpi/common/include/asm/unaligned.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2020 The FreeBSD Foundation + * Copyright (c) 2020,2023 The FreeBSD Foundation * * This software was developed by Björn Zeeb under sponsorship from * the FreeBSD Foundation. @@ -26,16 +26,21 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ -#ifndef _ASM_UNALIGNED_H -#define _ASM_UNALIGNED_H +#ifndef _LINUXKPI_ASM_UNALIGNED_H +#define _LINUXKPI_ASM_UNALIGNED_H #include <linux/types.h> #include <asm/byteorder.h> +static __inline uint16_t +get_unaligned_le16(const void *p) +{ + + return (le16_to_cpup((const __le16 *)p)); +} + static __inline uint32_t get_unaligned_le32(const void *p) { @@ -44,6 +49,15 @@ get_unaligned_le32(const void *p) } static __inline void +put_unaligned_le16(__le16 v, void *p) +{ + __le16 x; + + x = cpu_to_le16(v); + memcpy(p, &x, sizeof(x)); +} + +static __inline void put_unaligned_le32(__le32 v, void *p) { __le32 x; @@ -75,4 +89,11 @@ get_unaligned_be32(const void *p) return (be32_to_cpup((const __be32 *)p)); } -#endif /* _ASM_UNALIGNED_H */ +static __inline uint64_t +get_unaligned_be64(const void *p) +{ + + return (be64_to_cpup((const __be64 *)p)); +} + +#endif /* _LINUXKPI_ASM_UNALIGNED_H */ |