numpy 2.0.0
src/private/npy_fpmath.h
Go to the documentation of this file.
00001 #ifndef _NPY_NPY_FPMATH_H_
00002 #define _NPY_NPY_FPMATH_H_
00003 
00004 #include "npy_config.h"
00005 
00006 #include "numpy/npy_os.h"
00007 #include "numpy/npy_cpu.h"
00008 #include "numpy/npy_common.h"
00009 
00010 #ifdef NPY_OS_DARWIN
00011     /* This hardcoded logic is fragile, but universal builds makes it
00012      * difficult to detect arch-specific features */
00013 
00014     /* MAC OS X < 10.4 and gcc < 4 does not support proper long double, and
00015      * is the same as double on those platforms */
00016     #if NPY_BITSOF_LONGDOUBLE == NPY_BITSOF_DOUBLE
00017         /* This assumes that FPU and ALU have the same endianness */
00018         #if NPY_BYTE_ORDER == NPY_LITTLE_ENDIAN
00019             #define HAVE_LDOUBLE_IEEE_DOUBLE_LE
00020         #elif NPY_BYTE_ORDER == NPY_BIG_ENDIAN
00021             #define HAVE_LDOUBLE_IEEE_DOUBLE_BE
00022         #else
00023             #error Endianness undefined ?
00024         #endif
00025     #else
00026         #if defined(NPY_CPU_X86)
00027             #define HAVE_LDOUBLE_INTEL_EXTENDED_12_BYTES_LE
00028         #elif defined(NPY_CPU_AMD64)
00029             #define HAVE_LDOUBLE_INTEL_EXTENDED_16_BYTES_LE
00030         #elif defined(NPY_CPU_PPC) || defined(NPY_CPU_PPC64)
00031             #define HAVE_LDOUBLE_IEEE_DOUBLE_16_BYTES_BE
00032         #endif
00033     #endif
00034 #endif
00035 
00036 #if !(defined(HAVE_LDOUBLE_IEEE_QUAD_BE) || \
00037       defined(HAVE_LDOUBLE_IEEE_QUAD_LE) || \
00038       defined(HAVE_LDOUBLE_IEEE_DOUBLE_LE) || \
00039       defined(HAVE_LDOUBLE_IEEE_DOUBLE_BE) || \
00040       defined(HAVE_LDOUBLE_IEEE_DOUBLE_16_BYTES_BE) || \
00041       defined(HAVE_LDOUBLE_INTEL_EXTENDED_16_BYTES_LE) || \
00042       defined(HAVE_LDOUBLE_INTEL_EXTENDED_12_BYTES_LE) || \
00043       defined(HAVE_LDOUBLE_DOUBLE_DOUBLE_BE))
00044     #error No long double representation defined
00045 #endif
00046 
00047 #endif