summaryrefslogtreecommitdiff
path: root/doc/source/reference/c-api/config.rst
blob: 963a106f8a76b29fa2e78f6e16e85a52b8b7c653 (plain)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
System configuration
====================

.. sectionauthor:: Travis E. Oliphant

When NumPy is built, information about system configuration is
recorded, and is made available for extension modules using NumPy's C
API.  These are mostly defined in ``numpyconfig.h`` (included in
``ndarrayobject.h``). The public symbols are prefixed by ``NPY_*``.
NumPy also offers some functions for querying information about the
platform in use.

For private use, NumPy also constructs a ``config.h`` in the NumPy
include directory, which is not exported by NumPy (that is a python
extension which use the numpy C API will not see those symbols), to
avoid namespace pollution.


Data type sizes
---------------

The ``NPY_SIZEOF_{CTYPE}`` constants are defined so that sizeof
information is available to the pre-processor.

.. c:macro:: NPY_SIZEOF_SHORT

    sizeof(short)

.. c:macro:: NPY_SIZEOF_INT

    sizeof(int)

.. c:macro:: NPY_SIZEOF_LONG

    sizeof(long)

.. c:macro:: NPY_SIZEOF_LONGLONG

    sizeof(longlong) where longlong is defined appropriately on the
    platform.

.. c:macro:: NPY_SIZEOF_PY_LONG_LONG


.. c:macro:: NPY_SIZEOF_FLOAT

    sizeof(float)

.. c:macro:: NPY_SIZEOF_DOUBLE

    sizeof(double)

.. c:macro:: NPY_SIZEOF_LONG_DOUBLE

.. c:macro:: NPY_SIZEOF_LONGDOUBLE

    sizeof(longdouble)

.. c:macro:: NPY_SIZEOF_PY_INTPTR_T

.. c:macro:: NPY_SIZEOF_INTP

    Size of a pointer on this platform (sizeof(void \*))


Platform information
--------------------

.. c:macro:: NPY_CPU_X86
.. c:macro:: NPY_CPU_AMD64
.. c:macro:: NPY_CPU_IA64
.. c:macro:: NPY_CPU_PPC
.. c:macro:: NPY_CPU_PPC64
.. c:macro:: NPY_CPU_SPARC
.. c:macro:: NPY_CPU_SPARC64
.. c:macro:: NPY_CPU_S390
.. c:macro:: NPY_CPU_PARISC

    .. versionadded:: 1.3.0

    CPU architecture of the platform; only one of the above is
    defined.

    Defined in ``numpy/npy_cpu.h``

.. c:macro:: NPY_LITTLE_ENDIAN

.. c:macro:: NPY_BIG_ENDIAN

.. c:macro:: NPY_BYTE_ORDER

    .. versionadded:: 1.3.0

    Portable alternatives to the ``endian.h`` macros of GNU Libc.
    If big endian, :c:data:`NPY_BYTE_ORDER` == :c:data:`NPY_BIG_ENDIAN`, and
    similarly for little endian architectures.

    Defined in ``numpy/npy_endian.h``.

.. c:function:: int PyArray_GetEndianness()

    .. versionadded:: 1.3.0

    Returns the endianness of the current platform.
    One of :c:data:`NPY_CPU_BIG`, :c:data:`NPY_CPU_LITTLE`,
    or :c:data:`NPY_CPU_UNKNOWN_ENDIAN`.

    .. c:macro:: NPY_CPU_BIG

    .. c:macro:: NPY_CPU_LITTLE

    .. c:macro:: NPY_CPU_UNKNOWN_ENDIAN


Compiler directives
-------------------

.. c:macro:: NPY_LIKELY
.. c:macro:: NPY_UNLIKELY
.. c:macro:: NPY_UNUSED