[Python-checkins] CVS: python/dist/src/Objects longobject.c,1.82,1.83
Tim Peters
tim_one@users.sourceforge.net
Sat, 16 Jun 2001 01:48:42 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv17494/python/dist/src/Objects
Modified Files:
longobject.c
Log Message:
PyLong_{As, From}VoidPtr: cleanup, replacing assumptions in comments with
#if/#error constructs.
Index: longobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -C2 -r1.82 -r1.83
*** longobject.c 2001/06/14 18:42:50 1.82
--- longobject.c 2001/06/16 08:48:40 1.83
***************
*** 509,524 ****
PyLong_FromVoidPtr(void *p)
{
! #if SIZEOF_VOID_P == SIZEOF_LONG
return PyInt_FromLong((long)p);
#else
/* optimize null pointers */
! if ( p == NULL )
return PyInt_FromLong(0);
-
- /* we can assume that HAVE_LONG_LONG is true. if not, then the
- configuration process should have bailed (having big pointers
- without long longs seems non-sensical) */
return PyLong_FromLongLong((LONG_LONG)p);
! #endif /* SIZEOF_VOID_P == SIZEOF_LONG */
}
--- 509,528 ----
PyLong_FromVoidPtr(void *p)
{
! #if SIZEOF_VOID_P <= SIZEOF_LONG
return PyInt_FromLong((long)p);
#else
+
+ #ifndef HAVE_LONG_LONG
+ # error "PyLong_FromVoidPtr: sizeof(void*) > sizeof(long), but no long long"
+ #endif
+ #if SIZEOF_LONG_LONG < SIZEOF_VOID_P
+ # error "PyLong_FromVoidPtr: sizeof(LONG_LONG) < sizeof(void*)"
+ #endif
/* optimize null pointers */
! if (p == NULL)
return PyInt_FromLong(0);
return PyLong_FromLongLong((LONG_LONG)p);
!
! #endif /* SIZEOF_VOID_P <= SIZEOF_LONG */
}
***************
*** 532,554 ****
PyExc_SystemError, "bad argument to internal function"
*/
!
! #if SIZEOF_VOID_P == SIZEOF_LONG
long x;
! if ( PyInt_Check(vv) )
x = PyInt_AS_LONG(vv);
else
x = PyLong_AsLong(vv);
#else
! /* we can assume that HAVE_LONG_LONG is true. if not, then the
! configuration process should have bailed (having big pointers
! without long longs seems non-sensical) */
LONG_LONG x;
! if ( PyInt_Check(vv) )
x = PyInt_AS_LONG(vv);
else
x = PyLong_AsLongLong(vv);
! #endif /* SIZEOF_VOID_P == SIZEOF_LONG */
if (x == -1 && PyErr_Occurred())
--- 536,562 ----
PyExc_SystemError, "bad argument to internal function"
*/
! #if SIZEOF_VOID_P <= SIZEOF_LONG
long x;
! if (PyInt_Check(vv))
x = PyInt_AS_LONG(vv);
else
x = PyLong_AsLong(vv);
#else
!
! #ifndef HAVE_LONG_LONG
! # error "PyLong_AsVoidPtr: sizeof(void*) > sizeof(long), but no long long"
! #endif
! #if SIZEOF_LONG_LONG < SIZEOF_VOID_P
! # error "PyLong_AsVoidPtr: sizeof(LONG_LONG) < sizeof(void*)"
! #endif
LONG_LONG x;
! if (PyInt_Check(vv))
x = PyInt_AS_LONG(vv);
else
x = PyLong_AsLongLong(vv);
!
! #endif /* SIZEOF_VOID_P <= SIZEOF_LONG */
if (x == -1 && PyErr_Occurred())