]> git.proxmox.com Git - ceph.git/blame - ceph/src/msg/async/dpdk/byteorder.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / msg / async / dpdk / byteorder.h
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2/*
3 * This file is open source software, licensed to you under the terms
4 * of the Apache License, Version 2.0 (the "License"). See the NOTICE file
5 * distributed with this work for additional information regarding copyright
6 * ownership. You may not use this file except in compliance with the License.
7 *
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19/*
20 * Copyright (C) 2014 Cloudius Systems, Ltd.
21 */
7c673cae
FG
22
23#ifndef CEPH_MSG_BYTEORDER_H_
24#define CEPH_MSG_BYTEORDER_H_
25
26#include <arpa/inet.h> // for ntohs() and friends
27#include <iosfwd>
28#include <utility>
29
30inline uint64_t ntohq(uint64_t v) {
31 return __builtin_bswap64(v);
32}
33inline uint64_t htonq(uint64_t v) {
34 return __builtin_bswap64(v);
35}
36
37inline void ntoh() {}
38inline void hton() {}
39
40inline uint8_t ntoh(uint8_t x) { return x; }
41inline uint8_t hton(uint8_t x) { return x; }
42inline uint16_t ntoh(uint16_t x) { return ntohs(x); }
43inline uint16_t hton(uint16_t x) { return htons(x); }
44inline uint32_t ntoh(uint32_t x) { return ntohl(x); }
45inline uint32_t hton(uint32_t x) { return htonl(x); }
46inline uint64_t ntoh(uint64_t x) { return ntohq(x); }
47inline uint64_t hton(uint64_t x) { return htonq(x); }
48
49inline int8_t ntoh(int8_t x) { return x; }
50inline int8_t hton(int8_t x) { return x; }
51inline int16_t ntoh(int16_t x) { return ntohs(x); }
52inline int16_t hton(int16_t x) { return htons(x); }
53inline int32_t ntoh(int32_t x) { return ntohl(x); }
54inline int32_t hton(int32_t x) { return htonl(x); }
55inline int64_t ntoh(int64_t x) { return ntohq(x); }
56inline int64_t hton(int64_t x) { return htonq(x); }
57
58#endif /* CEPH_MSG_BYTEORDER_H_ */