[issue17870] Python does not provide PyLong_FromIntMax_t() or PyLong_FromUintMax_t() function

STINNER Victor report at bugs.python.org
Tue Apr 30 01:45:26 CEST 2013


STINNER Victor added the comment:

The problem is to support platforms not providing a intmax_t type.

I don't know if the following C code would be a good "approximation" of the maximum integral value (signed/unsigned).


#ifdef HAVE_INTMAX_T
typedef intmax_t        Py_intmax_t;
typedef uintmax_t       Py_uintmax_t;
 
#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P <= SIZEOF_LONG_LONG)
typedef PY_LONG_LONG            Py_intmax_t;
typedef unsigned PY_LONG_LONG   Py_uintmax_t;

#elif SIZEOF_VOID_P <= SIZEOF_LONG
typedef long            Py_intmax_t;
typedef unsigned long   Py_uintmax_t;

#elif SIZEOF_VOID_P <= SIZEOF_INT
typedef int             Py_intmax_t;
typedef unsigned int    Py_uintmax_t;

#else
#   error "Python needs a typedef for Py_intmax_t in pyport.h."
#endif /* HAVE_INTMAX_T */


If it is not, conversion from/to other types like off_t, time_t, pid_t or uid_t would loose information.

It is the same question than yours: is there a platform with an integer type wider than a pointer (intptr_t/void*)?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17870>
_______________________________________


More information about the Python-bugs-list mailing list