blob: f2dea9340b53ab48537f4875eeb933a7bb2ec0fa [file] [log] [blame]
Guido van Rossuma3309961993-07-28 09:05:47 +00001#ifndef Py_LONGOBJECT_H
2#define Py_LONGOBJECT_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
Guido van Rossumedcc38a1991-05-05 20:09:44 +00007
8/* Long (arbitrary precision) integer object interface */
9
Guido van Rossumcaa63801995-01-12 11:45:45 +000010typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */
Guido van Rossum44c8f691992-01-19 16:31:28 +000011
Guido van Rossum051ab121995-02-27 10:17:52 +000012extern DL_IMPORT(PyTypeObject) PyLong_Type;
Guido van Rossumedcc38a1991-05-05 20:09:44 +000013
Guido van Rossumcaa63801995-01-12 11:45:45 +000014#define PyLong_Check(op) ((op)->ob_type == &PyLong_Type)
Guido van Rossumedcc38a1991-05-05 20:09:44 +000015
Tim Peters9f688bf2000-07-07 15:53:28 +000016extern DL_IMPORT(PyObject *) PyLong_FromLong(long);
17extern DL_IMPORT(PyObject *) PyLong_FromUnsignedLong(unsigned long);
18extern DL_IMPORT(PyObject *) PyLong_FromDouble(double);
19extern DL_IMPORT(long) PyLong_AsLong(PyObject *);
20extern DL_IMPORT(unsigned long) PyLong_AsUnsignedLong(PyObject *);
21extern DL_IMPORT(double) PyLong_AsDouble(PyObject *);
22extern DL_IMPORT(PyObject *) PyLong_FromVoidPtr(void *);
23extern DL_IMPORT(void *) PyLong_AsVoidPtr(PyObject *);
Guido van Rossum44c8f691992-01-19 16:31:28 +000024
Guido van Rossum1a8791e1998-08-04 22:46:29 +000025#ifdef HAVE_LONG_LONG
Guido van Rossum2e6e7d41999-01-06 18:39:42 +000026
27#ifdef HAVE_LIMITS_H
28#include <limits.h>
29#endif
30
31/* Hopefully this is portable... */
32#ifndef LONG_MAX
33#define LONG_MAX 2147483647L
34#endif
35#ifndef ULONG_MAX
36#define ULONG_MAX 4294967295U
37#endif
38#ifndef LONGLONG_MAX
39#define LONGLONG_MAX 9223372036854775807LL
40#endif
41#ifndef ULONGLONG_MAX
42#define ULONGLONG_MAX 0xffffffffffffffffULL
43#endif
Guido van Rossum2e6e7d41999-01-06 18:39:42 +000044
Tim Peters9f688bf2000-07-07 15:53:28 +000045extern DL_IMPORT(PyObject *) PyLong_FromLongLong(LONG_LONG);
46extern DL_IMPORT(PyObject *) PyLong_FromUnsignedLongLong(unsigned LONG_LONG);
47extern DL_IMPORT(LONG_LONG) PyLong_AsLongLong(PyObject *);
48extern DL_IMPORT(unsigned LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *);
Guido van Rossum3293b071998-08-25 16:07:15 +000049#endif /* HAVE_LONG_LONG */
Guido van Rossum1a8791e1998-08-04 22:46:29 +000050
Tim Peters9f688bf2000-07-07 15:53:28 +000051DL_IMPORT(PyObject *) PyLong_FromString(char *, char **, int);
52DL_IMPORT(PyObject *) PyLong_FromUnicode(Py_UNICODE*, int, int);
Guido van Rossuma3309961993-07-28 09:05:47 +000053
54#ifdef __cplusplus
55}
56#endif
57#endif /* !Py_LONGOBJECT_H */