1 /*
2  * Copyright (c) 2021-2023 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 BYTE_ORDER_H
17 #define BYTE_ORDER_H
18 
19 #if is_mingw
20 #define UNWIND_LITTLE_ENDIAN 1234
21 #define UNWIND_BIG_ENDIAN 4321
22 #define UNWIND_BYTE_ORDER -1 // Unknown
23 #else
24 #include <endian.h>
25 
26 #if defined(__LITTLE_ENDIAN)
27 #define UNWIND_LITTLE_ENDIAN __LITTLE_ENDIAN
28 #elif defined(_LITTLE_ENDIAN)
29 #define UNWIND_LITTLE_ENDIAN _LITTLE_ENDIAN
30 #elif defined(LITTLE_ENDIAN)
31 #define UNWIND_LITTLE_ENDIAN LITTLE_ENDIAN
32 #else
33 #define UNWIND_LITTLE_ENDIAN 1234
34 #endif
35 
36 #if defined(__BIG_ENDIAN)
37 #define UNWIND_BIG_ENDIAN __BIG_ENDIAN
38 #elif defined(_BIG_ENDIAN)
39 #define UNWIND_BIG_ENDIAN _BIG_ENDIAN
40 #elif defined(BIG_ENDIAN)
41 #define UNWIND_BIG_ENDIAN BIG_ENDIAN
42 #else
43 #define UNWIND_BIG_ENDIAN 4321
44 #endif
45 
46 #if defined(__BYTE_ORDER)
47 #define UNWIND_BYTE_ORDER __BYTE_ORDER
48 #elif defined(_BYTE_ORDER)
49 #define UNWIND_BYTE_ORDER _BYTE_ORDER
50 #elif defined(BYTE_ORDER)
51 #define UNWIND_BYTE_ORDER BYTE_ORDER
52 #else
53 #error Target has unknown byte ordering.
54 #endif
55 #endif
56 #endif