1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef BT_ENDIAN_H
17 #define BT_ENDIAN_H
18 
19 #ifdef DARWIN_PLATFORM
20 #define H2BE_16(x) (x)
21 #define H2LE_16(x) (x)
22 #define BE2H_16(x) (x)
23 #define LE2H_16(x) (x)
24 
25 #define H2BE_32(x) (x)
26 #define H2LE_32(x) (x)
27 #define BE2H_32(x) (x)
28 #define LE2H_32(x) (x)
29 
30 #define H2BE_64(x) (x)
31 #define H2LE_64(x) (x)
32 #define BE2H_64(x) (x)
33 #define LE2H_64(x) (x)
34 #else
35 #include <endian.h>
36 
37 #define H2BE_16(x) htobe16(x)
38 #define H2LE_16(x) htole16(x)
39 #define BE2H_16(x) be16toh(x)
40 #define LE2H_16(x) le16toh(x)
41 
42 #define H2BE_32(x) htobe32(x)
43 #define H2LE_32(x) htole32(x)
44 #define BE2H_32(x) be32toh(x)
45 #define LE2H_32(x) le32toh(x)
46 
47 #define H2BE_64(x) htobe64(x)
48 #define H2LE_64(x) htole64(x)
49 #define BE2H_64(x) be64toh(x)
50 #define LE2H_64(x) le64toh(x)
51 #endif
52 
53 #endif  // BT_ENDIAN_H
54