zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_ENDIAN_H_
#define NUMPY_CORE_INCLUDE_NUMPY_NPY_ENDIAN_H_
 
/*
 * NPY_BYTE_ORDER is set to the same value as BYTE_ORDER set by glibc in
 * endian.h
 */
 
#if defined(NPY_HAVE_ENDIAN_H) || defined(NPY_HAVE_SYS_ENDIAN_H)
    /* Use endian.h if available */
 
    #if defined(NPY_HAVE_ENDIAN_H)
    #include <endian.h>
    #elif defined(NPY_HAVE_SYS_ENDIAN_H)
    #include <sys/endian.h>
    #endif
 
    #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN)
        #define NPY_BYTE_ORDER    BYTE_ORDER
        #define NPY_LITTLE_ENDIAN LITTLE_ENDIAN
        #define NPY_BIG_ENDIAN    BIG_ENDIAN
    #elif defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN)
        #define NPY_BYTE_ORDER    _BYTE_ORDER
        #define NPY_LITTLE_ENDIAN _LITTLE_ENDIAN
        #define NPY_BIG_ENDIAN    _BIG_ENDIAN
    #elif defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN)
        #define NPY_BYTE_ORDER    __BYTE_ORDER
        #define NPY_LITTLE_ENDIAN __LITTLE_ENDIAN
        #define NPY_BIG_ENDIAN    __BIG_ENDIAN
    #endif
#endif
 
#ifndef NPY_BYTE_ORDER
    /* Set endianness info using target CPU */
    #include "npy_cpu.h"
 
    #define NPY_LITTLE_ENDIAN 1234
    #define NPY_BIG_ENDIAN 4321
 
    #if defined(NPY_CPU_X86)                  \
            || defined(NPY_CPU_AMD64)         \
            || defined(NPY_CPU_IA64)          \
            || defined(NPY_CPU_ALPHA)         \
            || defined(NPY_CPU_ARMEL)         \
            || defined(NPY_CPU_ARMEL_AARCH32) \
            || defined(NPY_CPU_ARMEL_AARCH64) \
            || defined(NPY_CPU_SH_LE)         \
            || defined(NPY_CPU_MIPSEL)        \
            || defined(NPY_CPU_PPC64LE)       \
            || defined(NPY_CPU_ARCEL)         \
            || defined(NPY_CPU_RISCV64)       \
            || defined(NPY_CPU_LOONGARCH)     \
            || defined(NPY_CPU_WASM)
        #define NPY_BYTE_ORDER NPY_LITTLE_ENDIAN
 
    #elif defined(NPY_CPU_PPC)                \
            || defined(NPY_CPU_SPARC)         \
            || defined(NPY_CPU_S390)          \
            || defined(NPY_CPU_HPPA)          \
            || defined(NPY_CPU_PPC64)         \
            || defined(NPY_CPU_ARMEB)         \
            || defined(NPY_CPU_ARMEB_AARCH32) \
            || defined(NPY_CPU_ARMEB_AARCH64) \
            || defined(NPY_CPU_SH_BE)         \
            || defined(NPY_CPU_MIPSEB)        \
            || defined(NPY_CPU_OR1K)          \
            || defined(NPY_CPU_M68K)          \
            || defined(NPY_CPU_ARCEB)
        #define NPY_BYTE_ORDER NPY_BIG_ENDIAN
 
    #else
        #error Unknown CPU: can not set endianness
    #endif
 
#endif
 
#endif  /* NUMPY_CORE_INCLUDE_NUMPY_NPY_ENDIAN_H_ */