npy_cpu.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * This set (target) cpu specific macros:
  3. * - Possible values:
  4. * NPY_CPU_X86
  5. * NPY_CPU_AMD64
  6. * NPY_CPU_PPC
  7. * NPY_CPU_PPC64
  8. * NPY_CPU_PPC64LE
  9. * NPY_CPU_SPARC
  10. * NPY_CPU_S390
  11. * NPY_CPU_IA64
  12. * NPY_CPU_HPPA
  13. * NPY_CPU_ALPHA
  14. * NPY_CPU_ARMEL
  15. * NPY_CPU_ARMEB
  16. * NPY_CPU_SH_LE
  17. * NPY_CPU_SH_BE
  18. */
  19. #ifndef _NPY_CPUARCH_H_
  20. #define _NPY_CPUARCH_H_
  21. #include "numpyconfig.h"
  22. #include <string.h> /* for memcpy */
  23. #if defined( __i386__ ) || defined(i386) || defined(_M_IX86)
  24. /*
  25. * __i386__ is defined by gcc and Intel compiler on Linux,
  26. * _M_IX86 by VS compiler,
  27. * i386 by Sun compilers on opensolaris at least
  28. */
  29. #define NPY_CPU_X86
  30. #elif defined(__x86_64__) || defined(__amd64__) || defined(__x86_64) || defined(_M_AMD64)
  31. /*
  32. * both __x86_64__ and __amd64__ are defined by gcc
  33. * __x86_64 defined by sun compiler on opensolaris at least
  34. * _M_AMD64 defined by MS compiler
  35. */
  36. #define NPY_CPU_AMD64
  37. #elif defined(__ppc__) || defined(__powerpc__) || defined(_ARCH_PPC)
  38. /*
  39. * __ppc__ is defined by gcc, I remember having seen __powerpc__ once,
  40. * but can't find it ATM
  41. * _ARCH_PPC is used by at least gcc on AIX
  42. */
  43. #define NPY_CPU_PPC
  44. #elif defined(__ppc64le__)
  45. #define NPY_CPU_PPC64LE
  46. #elif defined(__ppc64__)
  47. #define NPY_CPU_PPC64
  48. #elif defined(__sparc__) || defined(__sparc)
  49. /* __sparc__ is defined by gcc and Forte (e.g. Sun) compilers */
  50. #define NPY_CPU_SPARC
  51. #elif defined(__s390__)
  52. #define NPY_CPU_S390
  53. #elif defined(__ia64)
  54. #define NPY_CPU_IA64
  55. #elif defined(__hppa)
  56. #define NPY_CPU_HPPA
  57. #elif defined(__alpha__)
  58. #define NPY_CPU_ALPHA
  59. #elif defined(__arm__) && defined(__ARMEL__)
  60. #define NPY_CPU_ARMEL
  61. #elif defined(__arm__) && defined(__ARMEB__)
  62. #define NPY_CPU_ARMEB
  63. #elif defined(__sh__) && defined(__LITTLE_ENDIAN__)
  64. #define NPY_CPU_SH_LE
  65. #elif defined(__sh__) && defined(__BIG_ENDIAN__)
  66. #define NPY_CPU_SH_BE
  67. #elif defined(__MIPSEL__)
  68. #define NPY_CPU_MIPSEL
  69. #elif defined(__MIPSEB__)
  70. #define NPY_CPU_MIPSEB
  71. #elif defined(__or1k__)
  72. #define NPY_CPU_OR1K
  73. #elif defined(__aarch64__)
  74. #define NPY_CPU_AARCH64
  75. #elif defined(__mc68000__)
  76. #define NPY_CPU_M68K
  77. #else
  78. #error Unknown CPU, please report this to numpy maintainers with \
  79. information about your platform (OS, CPU and compiler)
  80. #endif
  81. #define NPY_COPY_PYOBJECT_PTR(dst, src) memcpy(dst, src, sizeof(PyObject *))
  82. #if (defined(NPY_CPU_X86) || defined(NPY_CPU_AMD64))
  83. #define NPY_CPU_HAVE_UNALIGNED_ACCESS 1
  84. #else
  85. #define NPY_CPU_HAVE_UNALIGNED_ACCESS 0
  86. #endif
  87. #endif