numpy 2.0.0
include/numpy/npy_cpu.h
Go to the documentation of this file.
00001 /*
00002  * This set (target) cpu specific macros:
00003  *      - Possible values:
00004  *              NPY_CPU_X86
00005  *              NPY_CPU_AMD64
00006  *              NPY_CPU_PPC
00007  *              NPY_CPU_PPC64
00008  *              NPY_CPU_SPARC
00009  *              NPY_CPU_S390
00010  *              NPY_CPU_IA64
00011  *              NPY_CPU_HPPA
00012  *              NPY_CPU_ALPHA
00013  *              NPY_CPU_ARMEL
00014  *              NPY_CPU_ARMEB
00015  *              NPY_CPU_SH_LE
00016  *              NPY_CPU_SH_BE
00017  */
00018 #ifndef _NPY_CPUARCH_H_
00019 #define _NPY_CPUARCH_H_
00020 
00021 #include "numpyconfig.h"
00022 
00023 #if defined( __i386__ ) || defined(i386) || defined(_M_IX86)
00024     /*
00025      * __i386__ is defined by gcc and Intel compiler on Linux,
00026      * _M_IX86 by VS compiler,
00027      * i386 by Sun compilers on opensolaris at least
00028      */
00029     #define NPY_CPU_X86
00030 #elif defined(__x86_64__) || defined(__amd64__) || defined(__x86_64) || defined(_M_AMD64)
00031     /*
00032      * both __x86_64__ and __amd64__ are defined by gcc
00033      * __x86_64 defined by sun compiler on opensolaris at least
00034      * _M_AMD64 defined by MS compiler
00035      */
00036     #define NPY_CPU_AMD64
00037 #elif defined(__ppc__) || defined(__powerpc__) || defined(_ARCH_PPC)
00038     /*
00039      * __ppc__ is defined by gcc, I remember having seen __powerpc__ once,
00040      * but can't find it ATM
00041      * _ARCH_PPC is used by at least gcc on AIX
00042      */
00043     #define NPY_CPU_PPC
00044 #elif defined(__ppc64__)
00045     #define NPY_CPU_PPC64
00046 #elif defined(__sparc__) || defined(__sparc)
00047     /* __sparc__ is defined by gcc and Forte (e.g. Sun) compilers */
00048     #define NPY_CPU_SPARC
00049 #elif defined(__s390__)
00050     #define NPY_CPU_S390
00051 #elif defined(__ia64)
00052     #define NPY_CPU_IA64
00053 #elif defined(__hppa)
00054     #define NPY_CPU_HPPA
00055 #elif defined(__alpha__)
00056     #define NPY_CPU_ALPHA
00057 #elif defined(__arm__) && defined(__ARMEL__)
00058     #define NPY_CPU_ARMEL
00059 #elif defined(__arm__) && defined(__ARMEB__)
00060     #define NPY_CPU_ARMEB
00061 #elif defined(__sh__) && defined(__LITTLE_ENDIAN__)
00062     #define NPY_CPU_SH_LE
00063 #elif defined(__sh__) && defined(__BIG_ENDIAN__)
00064     #define NPY_CPU_SH_BE
00065 #elif defined(__MIPSEL__)
00066     #define NPY_CPU_MIPSEL
00067 #elif defined(__MIPSEB__)
00068     #define NPY_CPU_MIPSEB
00069 #else
00070     #error Unknown CPU, please report this to numpy maintainers with \
00071     information about your platform (OS, CPU and compiler)
00072 #endif
00073 
00074 /*
00075    This "white-lists" the architectures that we know don't require
00076    pointer alignment.  We white-list, since the memcpy version will
00077    work everywhere, whereas assignment will only work where pointer
00078    dereferencing doesn't require alignment.
00079 
00080    TODO: There may be more architectures we can white list.
00081 */
00082 #if defined(NPY_CPU_X86) || defined(NPY_CPU_AMD64)
00083     #define NPY_COPY_PYOBJECT_PTR(dst, src) (*((PyObject **)(dst)) = *((PyObject **)(src)))
00084 #else
00085     #if NPY_SIZEOF_PY_INTPTR_T == 4
00086         #define NPY_COPY_PYOBJECT_PTR(dst, src) \
00087             ((char*)(dst))[0] = ((char*)(src))[0]; \
00088             ((char*)(dst))[1] = ((char*)(src))[1]; \
00089             ((char*)(dst))[2] = ((char*)(src))[2]; \
00090             ((char*)(dst))[3] = ((char*)(src))[3];
00091     #elif NPY_SIZEOF_PY_INTPTR_T == 8
00092         #define NPY_COPY_PYOBJECT_PTR(dst, src) \
00093             ((char*)(dst))[0] = ((char*)(src))[0]; \
00094             ((char*)(dst))[1] = ((char*)(src))[1]; \
00095             ((char*)(dst))[2] = ((char*)(src))[2]; \
00096             ((char*)(dst))[3] = ((char*)(src))[3]; \
00097             ((char*)(dst))[4] = ((char*)(src))[4]; \
00098             ((char*)(dst))[5] = ((char*)(src))[5]; \
00099             ((char*)(dst))[6] = ((char*)(src))[6]; \
00100             ((char*)(dst))[7] = ((char*)(src))[7];
00101     #else
00102         #error Unknown architecture, please report this to numpy maintainers with \
00103         information about your platform (OS, CPU and compiler)
00104     #endif
00105 #endif
00106 
00107 #endif