source: rtems-libbsd/rtemsbsd/powerpc/include/asm/byteorder.h @ 28ee86a

55-freebsd-126-freebsd-12
Last change on this file since 28ee86a was 28ee86a, checked in by Sebastian Huber <sebastian.huber@…>, on 04/27/16 at 09:58:19

Import DPAA driver snapshot

Imported from Freescale Linux repository

git://git.freescale.com/ppc/upstream/linux.git

commit 2774c204cd8bfc56a200ff4dcdfc9cdf5b6fc161.

Linux compatibility layer is partly from FreeBSD.

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*-
2 * Copyright (c) 2010 Isilon Systems, Inc.
3 * Copyright (c) 2010 iX Systems, Inc.
4 * Copyright (c) 2010 Panasas, Inc.
5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice unmodified, this list of conditions, and the following
13 *    disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * $FreeBSD$
30 */
31#ifndef _ASM_BYTEORDER_H_
32#define _ASM_BYTEORDER_H_
33
34#include <sys/types.h>
35#include <sys/endian.h>
36#include <asm/types.h>
37
38#if BYTE_ORDER == LITTLE_ENDIAN
39#define __LITTLE_ENDIAN
40#else
41#define __BIG_ENDIAN
42#endif
43
44#define cpu_to_le64     htole64
45#define le64_to_cpu     le64toh
46#define cpu_to_le32     htole32
47#define le32_to_cpu     le32toh
48#define cpu_to_le16     htole16
49#define le16_to_cpu     le16toh
50#define cpu_to_be64     htobe64
51#define be64_to_cpu     be64toh
52#define cpu_to_be32     htobe32
53#define be32_to_cpu     be32toh
54#define cpu_to_be16     htobe16
55#define be16_to_cpu     be16toh
56#define __be16_to_cpu   be16toh
57
58#define cpu_to_le64p(x) htole64(*((uint64_t *)x))
59#define le64_to_cpup(x) le64toh(*((uint64_t *)x))
60#define cpu_to_le32p(x) htole32(*((uint32_t *)x))
61#define le32_to_cpup(x) le32toh(*((uint32_t *)x))
62#define cpu_to_le16p(x) htole16(*((uint16_t *)x))
63#define le16_to_cpup(x) le16toh(*((uint16_t *)x))
64#define cpu_to_be64p(x) htobe64(*((uint64_t *)x))
65#define be64_to_cpup(x) be64toh(*((uint64_t *)x))
66#define cpu_to_be32p(x) htobe32(*((uint32_t *)x))
67#define be32_to_cpup(x) be32toh(*((uint32_t *)x))
68#define cpu_to_be16p(x) htobe16(*((uint16_t *)x))
69#define be16_to_cpup(x) be16toh(*((uint16_t *)x))
70
71#define cpu_to_le64s(x) do { *((uint64_t *)x) = cpu_to_le64p((x)) } while (0)
72#define le64_to_cpus(x) do { *((uint64_t *)x) = le64_to_cpup((x)) } while (0)
73#define cpu_to_le32s(x) do { *((uint32_t *)x) = cpu_to_le32p((x)) } while (0)
74#define le32_to_cpus(x) do { *((uint32_t *)x) = le32_to_cpup((x)) } while (0)
75#define cpu_to_le16s(x) do { *((uint16_t *)x) = cpu_to_le16p((x)) } while (0)
76#define le16_to_cpus(x) do { *((uint16_t *)x) = le16_to_cpup((x)) } while (0)
77#define cpu_to_be64s(x) do { *((uint64_t *)x) = cpu_to_be64p((x)) } while (0)
78#define be64_to_cpus(x) do { *((uint64_t *)x) = be64_to_cpup((x)) } while (0)
79#define cpu_to_be32s(x) do { *((uint32_t *)x) = cpu_to_be32p((x)) } while (0)
80#define be32_to_cpus(x) do { *((uint32_t *)x) = be32_to_cpup((x)) } while (0)
81#define cpu_to_be16s(x) do { *((uint16_t *)x) = cpu_to_be16p((x)) } while (0)
82#define be16_to_cpus(x) do { *((uint16_t *)x) = be16_to_cpup((x)) } while (0)
83
84#define swab16  bswap16
85#define swab32  bswap32
86#define swab64  bswap64
87
88static inline void
89be16_add_cpu(u16 *var, u16 val)
90{
91        *var = cpu_to_be16(be16_to_cpu(*var) + val);
92}
93
94#endif  /* _ASM_BYTEORDER_H_ */
Note: See TracBrowser for help on using the repository browser.