[Patches] printf("%lx") -> printf("%p") for pointers : win64 cares
Trent Mick
trentm@activestate.com
Fri, 12 May 2000 21:31:36 -0700
Rationale/Discussion:
The common technique for printing out a pointer has been to cast to a long
and use the "%lx" printf modifier. This is incorrect on Win64 where casting
to a long truncates the pointer. The "%p" formatter should be used instead.
before (with a debugging printf of my own):
>>> class spam: pass
...
>>> repr(spam)
real pointer value is 000003FFFFC58340 # my own printf in the class_repr fn
'<class __main__.spam at ffc58340>'
>>>
after:
>>> class spam: pass
...
>>> repr(spam)
'<class __main__.spam at 000003FFFFC58340>'
>>>
I believe I have found all cases of the use of "%lx" for pointers. Primarily
these were for the repr() implementations of many objects and deubgging
output in the various thread_*.h files.
The changes do not only affect Win64 (as one would hope) because the %p
formatter on *NIX (on Linux32 and Linux64 at least) seems to prepend '0x' to
the hex representation of the pointer. WIn32 and Win64 do NOT prepend this.
Go figure. However, does it matter that the hex output format now includes
the '0x' prefix on Linux32? I.e. does Python promise the repr output to look
EXACTLY the way it does? Will reasonable code out there break? If so, then
that sucks. If not, then here is a patch.
Legal:
I confirm that, to the best of my knowledge and belief, this
contribution is free of any claims of third parties under
copyright, patent or other rights or interests ("claims"). To
the extent that I have any such claims, I hereby grant to CNRI a
nonexclusive, irrevocable, royalty-free, worldwide license to
reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part
of the Python software and its related documentation, or any
derivative versions thereof, at no cost to CNRI or its licensed
users, and to authorize others to do so.
I acknowledge that CNRI may, at its sole discretion, decide
whether or not to incorporate this contribution in the Python
software and its related documentation. I further grant CNRI
permission to use my name and other identifying information
provided to CNRI by me for use in connection with the Python
software and its related documentation.
Patch:
diff -c3 /home/trentm/main/contrib/python/dist/src/Modules/_tkinter.c /home/trentm/main/Apps/Perlium/Python/dist/src/Modules/_tkinter.c
*** /home/trentm/main/contrib/python/dist/src/Modules/_tkinter.c Thu May 4 08:55:17 2000
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Modules/_tkinter.c Fri May 12 12:03:24 2000
***************
*** 1705,1711 ****
TkttObject *v = (TkttObject *)self;
char buf[100];
! sprintf(buf, "<tktimertoken at 0x%lx%s>", (long)v,
v->func == NULL ? ", handler deleted" : "");
return PyString_FromString(buf);
}
--- 1705,1711 ----
TkttObject *v = (TkttObject *)self;
char buf[100];
! sprintf(buf, "<tktimertoken at %p%s>", v,
v->func == NULL ? ", handler deleted" : "");
return PyString_FromString(buf);
}
diff -c3 /home/trentm/main/contrib/python/dist/src/Modules/flmodule.c /home/trentm/main/Apps/Perlium/Python/dist/src/Modules/flmodule.c
*** /home/trentm/main/contrib/python/dist/src/Modules/flmodule.c Wed May 3 16:44:32 2000
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Modules/flmodule.c Fri May 12 12:06:53 2000
***************
*** 435,442 ****
genericobject *g;
{
char buf[100];
! sprintf(buf, "<FORMS_object at %lx, objclass=%d>",
! (long)g, g->ob_generic->objclass);
return PyString_FromString(buf);
}
--- 435,442 ----
genericobject *g;
{
char buf[100];
! sprintf(buf, "<FORMS_object at %p, objclass=%d>",
! g, g->ob_generic->objclass);
return PyString_FromString(buf);
}
***************
*** 1906,1913 ****
formobject *f;
{
char buf[100];
! sprintf(buf, "<FORMS_form at %lx, window=%ld>",
! (long)f, f->ob_form->window);
return PyString_FromString(buf);
}
--- 1906,1913 ----
formobject *f;
{
char buf[100];
! sprintf(buf, "<FORMS_form at %p, window=%ld>",
! f, f->ob_form->window);
return PyString_FromString(buf);
}
diff -c3 /home/trentm/main/contrib/python/dist/src/Modules/mpzmodule.c /home/trentm/main/Apps/Perlium/Python/dist/src/Modules/mpzmodule.c
*** /home/trentm/main/contrib/python/dist/src/Modules/mpzmodule.c Wed May 3 16:44:32 2000
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Modules/mpzmodule.c Fri May 12 12:11:40 2000
***************
*** 262,268 ****
#ifdef MPZ_DEBUG
fprintf(stderr,
! "mpz_format: cp (str end) 0x%x, begin 0x%x, diff %d, i %d\n",
cp, PyString_AS_STRING(strobjp),
cp - PyString_AS_STRING(strobjp), i);
#endif /* def MPZ_DEBUG */
--- 262,268 ----
#ifdef MPZ_DEBUG
fprintf(stderr,
! "mpz_format: cp (str end) %p, begin %p, diff %d, i %d\n",
cp, PyString_AS_STRING(strobjp),
cp - PyString_AS_STRING(strobjp), i);
#endif /* def MPZ_DEBUG */
***************
*** 1765,1771 ****
Py_FatalError("mp_allocate failure");
#ifdef MPZ_DEBUG
! fprintf(stderr, "mp_allocate : address 0x%08x\n", res);
#endif /* def MPZ_DEBUG */
MP_SET_TEST(res,alloc_size);
--- 1765,1771 ----
Py_FatalError("mp_allocate failure");
#ifdef MPZ_DEBUG
! fprintf(stderr, "mp_allocate : address %08p\n", res);
#endif /* def MPZ_DEBUG */
MP_SET_TEST(res,alloc_size);
***************
*** 1782,1788 ****
void *res;
#ifdef MPZ_DEBUG
! fprintf(stderr, "mp_reallocate: old address 0x%08x, old size %ld\n",
ptr, old_size);
#endif /* def MPZ_DEBUG */
--- 1782,1788 ----
void *res;
#ifdef MPZ_DEBUG
! fprintf(stderr, "mp_reallocate: old address %08p, old size %ld\n",
ptr, old_size);
#endif /* def MPZ_DEBUG */
***************
*** 1792,1798 ****
Py_FatalError("mp_reallocate failure");
#ifdef MPZ_DEBUG
! fprintf(stderr, "mp_reallocate: new address 0x%08x, new size %ld\n",
res, new_size);
#endif /* def MPZ_DEBUG */
--- 1792,1798 ----
Py_FatalError("mp_reallocate failure");
#ifdef MPZ_DEBUG
! fprintf(stderr, "mp_reallocate: new address %08p, new size %ld\n",
res, new_size);
#endif /* def MPZ_DEBUG */
***************
*** 1808,1814 ****
{
#ifdef MPZ_DEBUG
! fprintf(stderr, "mp_free : old address 0x%08x, old size %ld\n",
ptr, size);
#endif /* def MPZ_DEBUG */
--- 1808,1814 ----
{
#ifdef MPZ_DEBUG
! fprintf(stderr, "mp_free : old address %08p, old size %ld\n",
ptr, size);
#endif /* def MPZ_DEBUG */
diff -c3 /home/trentm/main/contrib/python/dist/src/Python/thread_beos.h /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_beos.h
*** /home/trentm/main/contrib/python/dist/src/Python/thread_beos.h Mon Dec 21 11:32:29 1998
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_beos.h Fri May 12 12:50:37 2000
***************
*** 262,268 ****
return (PyThread_type_lock)NULL;
}
! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock));
return (PyThread_type_lock) lock;
}
--- 262,268 ----
return (PyThread_type_lock)NULL;
}
! dprintf(("PyThread_allocate_lock() -> %p\n", lock));
return (PyThread_type_lock) lock;
}
***************
*** 270,276 ****
{
status_t retval;
! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock));
retval = benaphore_destroy( (benaphore_t *)lock );
if( retval != EOK ) {
--- 270,276 ----
{
status_t retval;
! dprintf(("PyThread_free_lock(%p) called\n", lock));
retval = benaphore_destroy( (benaphore_t *)lock );
if( retval != EOK ) {
***************
*** 284,290 ****
int success;
status_t retval;
! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
if( waitflag ) {
retval = benaphore_lock( (benaphore_t *)lock );
--- 284,290 ----
int success;
status_t retval;
! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
if( waitflag ) {
retval = benaphore_lock( (benaphore_t *)lock );
***************
*** 300,306 ****
/* TODO: that's bad, raise an exception */
}
! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
return success;
}
--- 300,306 ----
/* TODO: that's bad, raise an exception */
}
! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
return success;
}
***************
*** 308,314 ****
{
status_t retval;
! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock));
retval = benaphore_unlock( (benaphore_t *)lock );
if( retval != EOK ) {
--- 308,314 ----
{
status_t retval;
! dprintf(("PyThread_release_lock(%p) called\n", lock));
retval = benaphore_unlock( (benaphore_t *)lock );
if( retval != EOK ) {
***************
*** 336,342 ****
return 0;
}
! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema));
return (PyThread_type_sema) sema;
}
--- 336,342 ----
return 0;
}
! dprintf(("PyThread_allocate_sema() -> %p\n", sema));
return (PyThread_type_sema) sema;
}
***************
*** 344,350 ****
{
status_t retval;
! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema));
retval = delete_sem( (sem_id)sema );
if( retval != B_NO_ERROR ) {
--- 344,350 ----
{
status_t retval;
! dprintf(("PyThread_free_sema(%p) called\n", sema));
retval = delete_sem( (sem_id)sema );
if( retval != B_NO_ERROR ) {
***************
*** 357,363 ****
{
status_t retval;
! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag));
if( waitflag ) {
retval = acquire_sem( (sem_id)sema );
--- 357,363 ----
{
status_t retval;
! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag));
if( waitflag ) {
retval = acquire_sem( (sem_id)sema );
***************
*** 370,376 ****
return 0;
}
! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
return -1;
}
--- 370,376 ----
return 0;
}
! dprintf(("PyThread_down_sema(%p) return\n", sema));
return -1;
}
***************
*** 378,384 ****
{
status_t retval;
! dprintf(("PyThread_up_sema(%lx)\n", (long) sema));
retval = release_sem( (sem_id)sema );
if( retval != B_NO_ERROR ) {
--- 378,384 ----
{
status_t retval;
! dprintf(("PyThread_up_sema(%p)\n", sema));
retval = release_sem( (sem_id)sema );
if( retval != B_NO_ERROR ) {
diff -c3 /home/trentm/main/contrib/python/dist/src/Python/thread_cthread.h /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_cthread.h
*** /home/trentm/main/contrib/python/dist/src/Python/thread_cthread.h Mon Dec 21 11:32:30 1998
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_cthread.h Fri May 12 12:53:34 2000
***************
*** 129,141 ****
free((void *) lock);
lock = 0;
}
! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock));
return (PyThread_type_lock) lock;
}
void PyThread_free_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock));
mutex_free(lock);
}
--- 129,141 ----
free((void *) lock);
lock = 0;
}
! dprintf(("PyThread_allocate_lock() -> %p\n", lock));
return (PyThread_type_lock) lock;
}
void PyThread_free_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_free_lock(%p) called\n", lock));
mutex_free(lock);
}
***************
*** 143,162 ****
{
int success = FALSE;
! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
if (waitflag) { /* blocking */
mutex_lock(lock);
success = TRUE;
} else { /* non blocking */
success = mutex_try_lock(lock);
}
! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
return success;
}
void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock));
mutex_unlock((mutex_t )lock);
}
--- 143,162 ----
{
int success = FALSE;
! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
if (waitflag) { /* blocking */
mutex_lock(lock);
success = TRUE;
} else { /* non blocking */
success = mutex_try_lock(lock);
}
! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
return success;
}
void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_release_lock(%p) called\n", lock));
mutex_unlock((mutex_t )lock);
}
***************
*** 181,203 ****
if (!initialized)
PyThread_init_thread();
! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema));
return (PyThread_type_sema) sema;
}
void PyThread_free_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema));
}
int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag)
{
! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag));
! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
return -1;
}
void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_up_sema(%lx)\n", (long) sema));
}
--- 181,203 ----
if (!initialized)
PyThread_init_thread();
! dprintf(("PyThread_allocate_sema() -> %p\n", sema));
return (PyThread_type_sema) sema;
}
void PyThread_free_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_free_sema(%p) called\n", sema));
}
int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag)
{
! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag));
! dprintf(("PyThread_down_sema(%p) return\n", sema));
return -1;
}
void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_up_sema(%p)\n", sema));
}
diff -c3 /home/trentm/main/contrib/python/dist/src/Python/thread_foobar.h /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_foobar.h
*** /home/trentm/main/contrib/python/dist/src/Python/thread_foobar.h Mon Dec 21 11:32:30 1998
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_foobar.h Fri May 12 12:55:37 2000
***************
*** 108,134 ****
if (!initialized)
PyThread_init_thread();
! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock));
return (PyThread_type_lock) lock;
}
void PyThread_free_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock));
}
int PyThread_acquire_lock _P2(lock, PyThread_type_lock lock, waitflag, int waitflag)
{
int success;
! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
return success;
}
void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock));
}
/*
--- 108,134 ----
if (!initialized)
PyThread_init_thread();
! dprintf(("PyThread_allocate_lock() -> %p\n", lock));
return (PyThread_type_lock) lock;
}
void PyThread_free_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_free_lock(%p) called\n", lock));
}
int PyThread_acquire_lock _P2(lock, PyThread_type_lock lock, waitflag, int waitflag)
{
int success;
! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
return success;
}
void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_release_lock(%p) called\n", lock));
}
/*
***************
*** 140,162 ****
if (!initialized)
PyThread_init_thread();
! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema));
return (PyThread_type_sema) sema;
}
void PyThread_free_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema));
}
int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag)
{
! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag));
! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
return -1;
}
void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_up_sema(%lx)\n", (long) sema));
}
--- 140,162 ----
if (!initialized)
PyThread_init_thread();
! dprintf(("PyThread_allocate_sema() -> %p\n", sema));
return (PyThread_type_sema) sema;
}
void PyThread_free_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_free_sema(%p) called\n", sema));
}
int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag)
{
! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag));
! dprintf(("PyThread_down_sema(%p) return\n", sema));
return -1;
}
void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_up_sema(%p)\n", sema));
}
diff -c3 /home/trentm/main/contrib/python/dist/src/Python/thread_lwp.h /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_lwp.h
*** /home/trentm/main/contrib/python/dist/src/Python/thread_lwp.h Mon Dec 21 11:32:31 1998
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_lwp.h Fri May 12 12:57:29 2000
***************
*** 137,149 ****
lock->lock_locked = 0;
(void) mon_create(&lock->lock_monitor);
(void) cv_create(&lock->lock_condvar, lock->lock_monitor);
! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock));
return (PyThread_type_lock) lock;
}
void PyThread_free_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock));
mon_destroy(((struct lock *) lock)->lock_monitor);
free((char *) lock);
}
--- 137,149 ----
lock->lock_locked = 0;
(void) mon_create(&lock->lock_monitor);
(void) cv_create(&lock->lock_condvar, lock->lock_monitor);
! dprintf(("PyThread_allocate_lock() -> %p\n", lock));
return (PyThread_type_lock) lock;
}
void PyThread_free_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_free_lock(%p) called\n", lock));
mon_destroy(((struct lock *) lock)->lock_monitor);
free((char *) lock);
}
***************
*** 152,158 ****
{
int success;
! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
success = 0;
(void) mon_enter(((struct lock *) lock)->lock_monitor);
--- 152,158 ----
{
int success;
! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
success = 0;
(void) mon_enter(((struct lock *) lock)->lock_monitor);
***************
*** 165,177 ****
}
cv_broadcast(((struct lock *) lock)->lock_condvar);
mon_exit(((struct lock *) lock)->lock_monitor);
! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
return success;
}
void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock));
(void) mon_enter(((struct lock *) lock)->lock_monitor);
((struct lock *) lock)->lock_locked = 0;
cv_broadcast(((struct lock *) lock)->lock_condvar);
--- 165,177 ----
}
cv_broadcast(((struct lock *) lock)->lock_condvar);
mon_exit(((struct lock *) lock)->lock_monitor);
! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
return success;
}
void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_release_lock(%p) called\n", lock));
(void) mon_enter(((struct lock *) lock)->lock_monitor);
((struct lock *) lock)->lock_locked = 0;
cv_broadcast(((struct lock *) lock)->lock_condvar);
***************
*** 188,210 ****
if (!initialized)
PyThread_init_thread();
! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema));
return (PyThread_type_sema) sema;
}
void PyThread_free_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema));
}
int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag)
{
! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag));
! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
return -1;
}
void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_up_sema(%lx)\n", (long) sema));
}
--- 188,210 ----
if (!initialized)
PyThread_init_thread();
! dprintf(("PyThread_allocate_sema() -> %p\n", sema));
return (PyThread_type_sema) sema;
}
void PyThread_free_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_free_sema(%p) called\n", sema));
}
int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag)
{
! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag));
! dprintf(("PyThread_down_sema(%p) return\n", sema));
return -1;
}
void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_up_sema(%p)\n", sema));
}
diff -c3 /home/trentm/main/contrib/python/dist/src/Python/thread_nt.h /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_nt.h
*** /home/trentm/main/contrib/python/dist/src/Python/thread_nt.h Fri May 12 10:08:39 2000
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_nt.h Fri May 12 12:59:50 2000
***************
*** 266,279 ****
aLock = AllocNonRecursiveMutex() ;
! dprintf(("%ld: PyThread_allocate_lock() -> %lx\n", PyThread_get_thread_ident(), (long)aLock));
return (PyThread_type_lock) aLock;
}
void PyThread_free_lock(PyThread_type_lock aLock)
{
! dprintf(("%ld: PyThread_free_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock));
FreeNonRecursiveMutex(aLock) ;
}
--- 270,283 ----
aLock = AllocNonRecursiveMutex() ;
! dprintf(("%ld: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock));
return (PyThread_type_lock) aLock;
}
void PyThread_free_lock(PyThread_type_lock aLock)
{
! dprintf(("%ld: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
FreeNonRecursiveMutex(aLock) ;
}
***************
*** 288,308 ****
{
int success ;
! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) called\n", PyThread_get_thread_ident(),(long)aLock, waitflag));
success = aLock && EnterNonRecursiveMutex((PNRMUTEX) aLock, (waitflag == 1 ? INFINITE : 0)) == WAIT_OBJECT_0 ;
! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) -> %d\n", PyThread_get_thread_ident(),(long)aLock, waitflag, success));
return success;
}
void PyThread_release_lock(PyThread_type_lock aLock)
{
! dprintf(("%ld: PyThread_release_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock));
if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock)))
! dprintf(("%ld: Could not PyThread_release_lock(%lx) error: %l\n", PyThread_get_thread_ident(), (long)aLock, GetLastError()));
}
/*
--- 292,312 ----
{
int success ;
! dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n", PyThread_get_thread_ident(),aLock, waitflag));
success = aLock && EnterNonRecursiveMutex((PNRMUTEX) aLock, (waitflag == 1 ? INFINITE : 0)) == WAIT_OBJECT_0 ;
! dprintf(("%ld: PyThread_acquire_lock(%p, %d) -> %d\n", PyThread_get_thread_ident(),aLock, waitflag, success));
return success;
}
void PyThread_release_lock(PyThread_type_lock aLock)
{
! dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock)))
! dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", PyThread_get_thread_ident(), aLock, GetLastError()));
}
/*
***************
*** 321,334 ****
INT_MAX, /* Maximum value */
NULL); /* Name of semaphore */
! dprintf(("%ld: PyThread_allocate_sema() -> %lx\n", PyThread_get_thread_ident(), (long)aSemaphore));
return (PyThread_type_sema) aSemaphore;
}
void PyThread_free_sema(PyThread_type_sema aSemaphore)
{
! dprintf(("%ld: PyThread_free_sema(%lx) called\n", PyThread_get_thread_ident(), (long)aSemaphore));
CloseHandle((HANDLE) aSemaphore);
}
--- 325,338 ----
INT_MAX, /* Maximum value */
NULL); /* Name of semaphore */
! dprintf(("%ld: PyThread_allocate_sema() -> %p\n", PyThread_get_thread_ident(), aSemaphore));
return (PyThread_type_sema) aSemaphore;
}
void PyThread_free_sema(PyThread_type_sema aSemaphore)
{
! dprintf(("%ld: PyThread_free_sema(%p) called\n", PyThread_get_thread_ident(), aSemaphore));
CloseHandle((HANDLE) aSemaphore);
}
***************
*** 340,350 ****
{
DWORD waitResult;
! dprintf(("%ld: PyThread_down_sema(%lx) called\n", PyThread_get_thread_ident(), (long)aSemaphore));
waitResult = WaitForSingleObject( (HANDLE) aSemaphore, INFINITE);
! dprintf(("%ld: PyThread_down_sema(%lx) return: %l\n", PyThread_get_thread_ident(),(long) aSemaphore, waitResult));
return 0;
}
--- 344,354 ----
{
DWORD waitResult;
! dprintf(("%ld: PyThread_down_sema(%p) called\n", PyThread_get_thread_ident(), aSemaphore));
waitResult = WaitForSingleObject( (HANDLE) aSemaphore, INFINITE);
! dprintf(("%ld: PyThread_down_sema(%p) return: %l\n", PyThread_get_thread_ident(), aSemaphore, waitResult));
return 0;
}
***************
*** 355,359 ****
1, /* increment count by one */
NULL); /* not interested in previous count */
! dprintf(("%ld: PyThread_up_sema(%lx)\n", PyThread_get_thread_ident(), (long)aSemaphore));
}
--- 359,363 ----
1, /* increment count by one */
NULL); /* not interested in previous count */
! dprintf(("%ld: PyThread_up_sema(%p)\n", PyThread_get_thread_ident(), aSemaphore));
}
diff -c3 /home/trentm/main/contrib/python/dist/src/Python/thread_os2.h /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_os2.h
*** /home/trentm/main/contrib/python/dist/src/Python/thread_os2.h Mon Dec 21 11:32:33 1998
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_os2.h Fri May 12 13:01:55 2000
***************
*** 141,154 ****
0, /* shared ? */
0); /* initial state */
! dprintf(("%ld: PyThread_allocate_lock() -> %lx\n", PyThread_get_thread_ident(), (long)aLock));
return (PyThread_type_lock) aLock;
}
void PyThread_free_lock(PyThread_type_lock aLock)
{
! dprintf(("%ld: PyThread_free_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock));
DosCloseMutexSem((HMTX)aLock);
}
--- 141,154 ----
0, /* shared ? */
0); /* initial state */
! dprintf(("%ld: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock));
return (PyThread_type_lock) aLock;
}
void PyThread_free_lock(PyThread_type_lock aLock)
{
! dprintf(("%ld: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
DosCloseMutexSem((HMTX)aLock);
}
***************
*** 166,173 ****
PID pid = 0;
TID tid = 0;
! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) called\n", PyThread_get_thread_ident(),
! (long)aLock, waitflag));
DosQueryMutexSem((HMTX)aLock,&pid,&tid,&count);
if( tid == PyThread_get_thread_ident() ) { /* if we own this lock */
--- 166,173 ----
PID pid = 0;
TID tid = 0;
! dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n", PyThread_get_thread_ident(),
! aLock, waitflag));
DosQueryMutexSem((HMTX)aLock,&pid,&tid,&count);
if( tid == PyThread_get_thread_ident() ) { /* if we own this lock */
***************
*** 181,199 ****
}
}
! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) -> %d\n",
! PyThread_get_thread_ident(),(long)aLock, waitflag, success));
return success;
}
void PyThread_release_lock(PyThread_type_lock aLock)
{
! dprintf(("%ld: PyThread_release_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock));
if ( DosReleaseMutexSem( (HMTX) aLock ) != 0 ) {
! dprintf(("%ld: Could not PyThread_release_lock(%lx) error: %l\n",
! PyThread_get_thread_ident(), (long)aLock, GetLastError()));
}
}
--- 181,199 ----
}
}
! dprintf(("%ld: PyThread_acquire_lock(%p, %d) -> %d\n",
! PyThread_get_thread_ident(),aLock, waitflag, success));
return success;
}
void PyThread_release_lock(PyThread_type_lock aLock)
{
! dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
if ( DosReleaseMutexSem( (HMTX) aLock ) != 0 ) {
! dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n",
! PyThread_get_thread_ident(), aLock, GetLastError()));
}
}
***************
*** 217,221 ****
void PyThread_up_sema(PyThread_type_sema aSemaphore)
{
! dprintf(("%ld: PyThread_up_sema(%lx)\n", PyThread_get_thread_ident(), (long)aSemaphore));
}
--- 217,221 ----
void PyThread_up_sema(PyThread_type_sema aSemaphore)
{
! dprintf(("%ld: PyThread_up_sema(%p)\n", PyThread_get_thread_ident(), aSemaphore));
}
diff -c3 /home/trentm/main/contrib/python/dist/src/Python/thread_pth.h /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_pth.h
*** /home/trentm/main/contrib/python/dist/src/Python/thread_pth.h Mon May 8 06:36:49 2000
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_pth.h Fri May 12 13:11:04 2000
***************
*** 168,174 ****
lock = NULL;
}
}
! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock));
return (PyThread_type_lock) lock;
}
--- 168,174 ----
lock = NULL;
}
}
! dprintf(("PyThread_allocate_lock() -> %p\n", lock));
return (PyThread_type_lock) lock;
}
***************
*** 177,183 ****
pth_lock *thelock = (pth_lock *)lock;
int status, error = 0;
! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock));
free((void *)thelock);
}
--- 177,183 ----
pth_lock *thelock = (pth_lock *)lock;
int status, error = 0;
! dprintf(("PyThread_free_lock(%p) called\n", lock));
free((void *)thelock);
}
***************
*** 188,194 ****
pth_lock *thelock = (pth_lock *)lock;
int status, error = 0;
! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
status = pth_mutex_acquire(&thelock->mut, !waitflag, NULL);
CHECK_STATUS("pth_mutex_acquire[1]");
--- 188,194 ----
pth_lock *thelock = (pth_lock *)lock;
int status, error = 0;
! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
status = pth_mutex_acquire(&thelock->mut, !waitflag, NULL);
CHECK_STATUS("pth_mutex_acquire[1]");
***************
*** 215,221 ****
success = 1;
}
if (error) success = 0;
! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
return success;
}
--- 215,221 ----
success = 1;
}
if (error) success = 0;
! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
return success;
}
***************
*** 224,230 ****
pth_lock *thelock = (pth_lock *)lock;
int status, error = 0;
! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock));
status = pth_mutex_acquire( &thelock->mut, 0, NULL );
CHECK_STATUS("pth_mutex_acquire[3]");
--- 224,230 ----
pth_lock *thelock = (pth_lock *)lock;
int status, error = 0;
! dprintf(("PyThread_release_lock(%p) called\n", lock));
status = pth_mutex_acquire( &thelock->mut, 0, NULL );
CHECK_STATUS("pth_mutex_acquire[3]");
***************
*** 270,276 ****
sema = NULL;
}
}
! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema));
return (PyThread_type_sema) sema;
}
--- 270,276 ----
sema = NULL;
}
}
! dprintf(("PyThread_allocate_sema() -> %p\n", sema));
return (PyThread_type_sema) sema;
}
***************
*** 279,285 ****
int status, error = 0;
struct semaphore *thesema = (struct semaphore *) sema;
! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema));
free((void *) thesema);
}
--- 279,285 ----
int status, error = 0;
struct semaphore *thesema = (struct semaphore *) sema;
! dprintf(("PyThread_free_sema(%p) called\n", sema));
free((void *) thesema);
}
***************
*** 288,294 ****
int status, error = 0, success;
struct semaphore *thesema = (struct semaphore *) sema;
! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag));
status = pth_mutex_acquire(&thesema->mutex, !waitflag, NULL);
CHECK_STATUS("pth_mutex_acquire");
if (waitflag) {
--- 288,294 ----
int status, error = 0, success;
struct semaphore *thesema = (struct semaphore *) sema;
! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag));
status = pth_mutex_acquire(&thesema->mutex, !waitflag, NULL);
CHECK_STATUS("pth_mutex_acquire");
if (waitflag) {
***************
*** 308,314 ****
success = 0;
status = pth_mutex_release(&thesema->mutex);
CHECK_STATUS("pth_mutex_release");
! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
return success;
}
--- 308,314 ----
success = 0;
status = pth_mutex_release(&thesema->mutex);
CHECK_STATUS("pth_mutex_release");
! dprintf(("PyThread_down_sema(%p) return\n", sema));
return success;
}
***************
*** 317,323 ****
int status, error = 0;
struct semaphore *thesema = (struct semaphore *) sema;
! dprintf(("PyThread_up_sema(%lx)\n", (long) sema));
status = pth_mutex_acquire(&thesema->mutex, 0, NULL);
CHECK_STATUS("pth_mutex_acquire");
thesema->value++;
--- 317,323 ----
int status, error = 0;
struct semaphore *thesema = (struct semaphore *) sema;
! dprintf(("PyThread_up_sema(%p)\n", sema));
status = pth_mutex_acquire(&thesema->mutex, 0, NULL);
CHECK_STATUS("pth_mutex_acquire");
thesema->value++;
diff -c3 /home/trentm/main/contrib/python/dist/src/Python/thread_pthread.h /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_pthread.h
*** /home/trentm/main/contrib/python/dist/src/Python/thread_pthread.h Mon Mar 15 12:27:53 1999
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_pthread.h Fri May 12 13:03:22 2000
***************
*** 272,278 ****
}
}
! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock));
return (PyThread_type_lock) lock;
}
--- 272,278 ----
}
}
! dprintf(("PyThread_allocate_lock() -> %p\n", lock));
return (PyThread_type_lock) lock;
}
***************
*** 281,287 ****
pthread_lock *thelock = (pthread_lock *)lock;
int status, error = 0;
! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock));
status = pthread_mutex_destroy( &thelock->mut );
CHECK_STATUS("pthread_mutex_destroy");
--- 281,287 ----
pthread_lock *thelock = (pthread_lock *)lock;
int status, error = 0;
! dprintf(("PyThread_free_lock(%p) called\n", lock));
status = pthread_mutex_destroy( &thelock->mut );
CHECK_STATUS("pthread_mutex_destroy");
***************
*** 298,304 ****
pthread_lock *thelock = (pthread_lock *)lock;
int status, error = 0;
! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
status = pthread_mutex_lock( &thelock->mut );
CHECK_STATUS("pthread_mutex_lock[1]");
--- 298,304 ----
pthread_lock *thelock = (pthread_lock *)lock;
int status, error = 0;
! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
status = pthread_mutex_lock( &thelock->mut );
CHECK_STATUS("pthread_mutex_lock[1]");
***************
*** 325,331 ****
success = 1;
}
if (error) success = 0;
! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
return success;
}
--- 325,331 ----
success = 1;
}
if (error) success = 0;
! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
return success;
}
***************
*** 334,340 ****
pthread_lock *thelock = (pthread_lock *)lock;
int status, error = 0;
! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock));
status = pthread_mutex_lock( &thelock->mut );
CHECK_STATUS("pthread_mutex_lock[3]");
--- 334,340 ----
pthread_lock *thelock = (pthread_lock *)lock;
int status, error = 0;
! dprintf(("PyThread_release_lock(%p) called\n", lock));
status = pthread_mutex_lock( &thelock->mut );
CHECK_STATUS("pthread_mutex_lock[3]");
***************
*** 382,388 ****
sema = NULL;
}
}
! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema));
return (PyThread_type_sema) sema;
}
--- 382,388 ----
sema = NULL;
}
}
! dprintf(("PyThread_allocate_sema() -> %p\n", sema));
return (PyThread_type_sema) sema;
}
***************
*** 391,397 ****
int status, error = 0;
struct semaphore *thesema = (struct semaphore *) sema;
! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema));
status = pthread_cond_destroy(&thesema->cond);
CHECK_STATUS("pthread_cond_destroy");
status = pthread_mutex_destroy(&thesema->mutex);
--- 391,397 ----
int status, error = 0;
struct semaphore *thesema = (struct semaphore *) sema;
! dprintf(("PyThread_free_sema(%p) called\n", sema));
status = pthread_cond_destroy(&thesema->cond);
CHECK_STATUS("pthread_cond_destroy");
status = pthread_mutex_destroy(&thesema->mutex);
***************
*** 404,410 ****
int status, error = 0, success;
struct semaphore *thesema = (struct semaphore *) sema;
! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag));
status = pthread_mutex_lock(&thesema->mutex);
CHECK_STATUS("pthread_mutex_lock");
if (waitflag) {
--- 404,410 ----
int status, error = 0, success;
struct semaphore *thesema = (struct semaphore *) sema;
! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag));
status = pthread_mutex_lock(&thesema->mutex);
CHECK_STATUS("pthread_mutex_lock");
if (waitflag) {
***************
*** 424,430 ****
success = 0;
status = pthread_mutex_unlock(&thesema->mutex);
CHECK_STATUS("pthread_mutex_unlock");
! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
return success;
}
--- 424,430 ----
success = 0;
status = pthread_mutex_unlock(&thesema->mutex);
CHECK_STATUS("pthread_mutex_unlock");
! dprintf(("PyThread_down_sema(%p) return\n", sema));
return success;
}
***************
*** 433,439 ****
int status, error = 0;
struct semaphore *thesema = (struct semaphore *) sema;
! dprintf(("PyThread_up_sema(%lx)\n", (long) sema));
status = pthread_mutex_lock(&thesema->mutex);
CHECK_STATUS("pthread_mutex_lock");
thesema->value++;
--- 433,439 ----
int status, error = 0;
struct semaphore *thesema = (struct semaphore *) sema;
! dprintf(("PyThread_up_sema(%p)\n", sema));
status = pthread_mutex_lock(&thesema->mutex);
CHECK_STATUS("pthread_mutex_lock");
thesema->value++;
diff -c3 /home/trentm/main/contrib/python/dist/src/Python/thread_sgi.h /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_sgi.h
*** /home/trentm/main/contrib/python/dist/src/Python/thread_sgi.h Mon Dec 21 11:32:34 1998
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_sgi.h Fri May 12 13:06:28 2000
***************
*** 119,125 ****
if (usconfig(CONF_INITSIZE, size) < 0)
perror("usconfig - CONF_INITSIZE (reset)");
addr = (long) dl_getrange(size + HDR_SIZE);
! dprintf(("trying to use addr %lx-%lx for shared arena\n", addr, addr+size));
errno = 0;
if ((addr = usconfig(CONF_ATTACHADDR, addr)) < 0 && errno != 0)
perror("usconfig - CONF_ATTACHADDR (set)");
--- 119,125 ----
if (usconfig(CONF_INITSIZE, size) < 0)
perror("usconfig - CONF_INITSIZE (reset)");
addr = (long) dl_getrange(size + HDR_SIZE);
! dprintf(("trying to use addr %p-%p for shared arena\n", addr, addr+size));
errno = 0;
if ((addr = usconfig(CONF_ATTACHADDR, addr)) < 0 && errno != 0)
perror("usconfig - CONF_ATTACHADDR (set)");
***************
*** 157,163 ****
(void) usinitlock(count_lock);
if ((wait_lock = usnewlock(shared_arena)) == NULL)
perror("usnewlock (wait_lock)");
! dprintf(("arena start: %lx, arena size: %ld\n", (long) shared_arena, (long) usconfig(CONF_GETSIZE, shared_arena)));
}
/*
--- 157,163 ----
(void) usinitlock(count_lock);
if ((wait_lock = usnewlock(shared_arena)) == NULL)
perror("usnewlock (wait_lock)");
! dprintf(("arena start: %p, arena size: %ld\n", shared_arena, (long) usconfig(CONF_GETSIZE, shared_arena)));
}
/*
***************
*** 224,230 ****
if (usconfig(CONF_INITSIZE, size) < 0)
perror("usconfig - CONF_INITSIZE (reset)");
addr = (long) dl_getrange(size + HDR_SIZE);
! dprintf(("trying to use addr %lx-%lx for sproc\n",
addr, addr+size));
errno = 0;
if ((addr = usconfig(CONF_ATTACHADDR, addr)) < 0 &&
--- 224,230 ----
if (usconfig(CONF_INITSIZE, size) < 0)
perror("usconfig - CONF_INITSIZE (reset)");
addr = (long) dl_getrange(size + HDR_SIZE);
! dprintf(("trying to use addr %p-%p for sproc\n",
addr, addr+size));
errno = 0;
if ((addr = usconfig(CONF_ATTACHADDR, addr)) < 0 &&
***************
*** 375,387 ****
if ((lock = usnewlock(shared_arena)) == NULL)
perror("usnewlock");
(void) usinitlock(lock);
! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock));
return (PyThread_type_lock) lock;
}
void PyThread_free_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock));
usfreelock((ulock_t) lock, shared_arena);
}
--- 375,387 ----
if ((lock = usnewlock(shared_arena)) == NULL)
perror("usnewlock");
(void) usinitlock(lock);
! dprintf(("PyThread_allocate_lock() -> %p\n", lock));
return (PyThread_type_lock) lock;
}
void PyThread_free_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_free_lock(%p) called\n", lock));
usfreelock((ulock_t) lock, shared_arena);
}
***************
*** 389,395 ****
{
int success;
! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
errno = 0; /* clear it just in case */
if (waitflag)
success = ussetlock((ulock_t) lock);
--- 389,395 ----
{
int success;
! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
errno = 0; /* clear it just in case */
if (waitflag)
success = ussetlock((ulock_t) lock);
***************
*** 397,409 ****
success = uscsetlock((ulock_t) lock, 1); /* Try it once */
if (success < 0)
perror(waitflag ? "ussetlock" : "uscsetlock");
! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
return success;
}
void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock));
if (usunsetlock((ulock_t) lock) < 0)
perror("usunsetlock");
}
--- 397,409 ----
success = uscsetlock((ulock_t) lock, 1); /* Try it once */
if (success < 0)
perror(waitflag ? "ussetlock" : "uscsetlock");
! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
return success;
}
void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_release_lock(%p) called\n", lock));
if (usunsetlock((ulock_t) lock) < 0)
perror("usunsetlock");
}
***************
*** 420,432 ****
if ((sema = usnewsema(shared_arena, value)) == NULL)
perror("usnewsema");
! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema));
return (PyThread_type_sema) sema;
}
void PyThread_free_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema));
usfreesema((usema_t *) sema, shared_arena);
}
--- 420,432 ----
if ((sema = usnewsema(shared_arena, value)) == NULL)
perror("usnewsema");
! dprintf(("PyThread_allocate_sema() -> %p\n", sema));
return (PyThread_type_sema) sema;
}
void PyThread_free_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_free_sema(%p) called\n", sema));
usfreesema((usema_t *) sema, shared_arena);
}
***************
*** 434,453 ****
{
int success;
! dprintf(("PyThread_down_sema(%lx) called\n", (long) sema));
if (waitflag)
success = uspsema((usema_t *) sema);
else
success = uscpsema((usema_t *) sema);
if (success < 0)
perror(waitflag ? "uspsema" : "uscpsema");
! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
return success;
}
void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_up_sema(%lx)\n", (long) sema));
if (usvsema((usema_t *) sema) < 0)
perror("usvsema");
}
--- 434,453 ----
{
int success;
! dprintf(("PyThread_down_sema(%p) called\n", sema));
if (waitflag)
success = uspsema((usema_t *) sema);
else
success = uscpsema((usema_t *) sema);
if (success < 0)
perror(waitflag ? "uspsema" : "uscpsema");
! dprintf(("PyThread_down_sema(%p) return\n", sema));
return success;
}
void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_up_sema(%p)\n", sema));
if (usvsema((usema_t *) sema) < 0)
perror("usvsema");
}
diff -c3 /home/trentm/main/contrib/python/dist/src/Python/thread_solaris.h /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_solaris.h
*** /home/trentm/main/contrib/python/dist/src/Python/thread_solaris.h Tue Apr 13 07:32:12 1999
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_solaris.h Fri May 12 13:08:14 2000
***************
*** 157,169 ****
free((void *) lock);
lock = 0;
}
! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock));
return (PyThread_type_lock) lock;
}
void PyThread_free_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock));
mutex_destroy((mutex_t *) lock);
free((void *) lock);
}
--- 157,169 ----
free((void *) lock);
lock = 0;
}
! dprintf(("PyThread_allocate_lock() -> %p\n", lock));
return (PyThread_type_lock) lock;
}
void PyThread_free_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_free_lock(%p) called\n", lock));
mutex_destroy((mutex_t *) lock);
free((void *) lock);
}
***************
*** 172,178 ****
{
int success;
! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
if (waitflag)
success = mutex_lock((mutex_t *) lock);
else
--- 172,178 ----
{
int success;
! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
if (waitflag)
success = mutex_lock((mutex_t *) lock);
else
***************
*** 181,193 ****
perror(waitflag ? "mutex_lock" : "mutex_trylock");
else
success = !success; /* solaris does it the other way round */
! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
return success;
}
void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock));
if (mutex_unlock((mutex_t *) lock))
perror("mutex_unlock");
}
--- 181,193 ----
perror(waitflag ? "mutex_lock" : "mutex_trylock");
else
success = !success; /* solaris does it the other way round */
! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
return success;
}
void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
{
! dprintf(("PyThread_release_lock(%p) called\n", lock));
if (mutex_unlock((mutex_t *) lock))
perror("mutex_unlock");
}
***************
*** 208,220 ****
free((void *) sema);
sema = 0;
}
! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema));
return (PyThread_type_sema) sema;
}
void PyThread_free_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema));
if (sema_destroy((sema_t *) sema))
perror("sema_destroy");
free((void *) sema);
--- 208,220 ----
free((void *) sema);
sema = 0;
}
! dprintf(("PyThread_allocate_sema() -> %p\n", sema));
return (PyThread_type_sema) sema;
}
void PyThread_free_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_free_sema(%p) called\n", sema));
if (sema_destroy((sema_t *) sema))
perror("sema_destroy");
free((void *) sema);
***************
*** 224,230 ****
{
int success;
! dprintf(("PyThread_down_sema(%lx) called\n", (long) sema));
if (waitflag)
success = sema_wait((sema_t *) sema);
else
--- 224,230 ----
{
int success;
! dprintf(("PyThread_down_sema(%p) called\n", sema));
if (waitflag)
success = sema_wait((sema_t *) sema);
else
***************
*** 237,249 ****
}
else
success = !success;
! dprintf(("PyThread_down_sema(%lx) return %d\n", (long) sema, success));
return success;
}
void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_up_sema(%lx)\n", (long) sema));
if (sema_post((sema_t *) sema))
perror("sema_post");
}
--- 237,249 ----
}
else
success = !success;
! dprintf(("PyThread_down_sema(%p) return %d\n", sema, success));
return success;
}
void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
{
! dprintf(("PyThread_up_sema(%p)\n", sema));
if (sema_post((sema_t *) sema))
perror("sema_post");
}
diff -c3 /home/trentm/main/contrib/python/dist/src/Python/thread_wince.h /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_wince.h
*** /home/trentm/main/contrib/python/dist/src/Python/thread_wince.h Thu Apr 8 06:57:06 1999
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Python/thread_wince.h Fri May 12 13:10:04 2000
***************
*** 144,157 ****
1, /* Is initially signalled */
NULL); /* Name of event */
! dprintf(("%ld: PyThread_allocate_lock() -> %lx\n", PyThread_get_thread_ident(), (long)aLock));
return (PyThread_type_lock) aLock;
}
void PyThread_free_lock(PyThread_type_lock aLock)
{
! dprintf(("%ld: PyThread_free_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock));
CloseHandle(aLock);
}
--- 144,157 ----
1, /* Is initially signalled */
NULL); /* Name of event */
! dprintf(("%ld: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock));
return (PyThread_type_lock) aLock;
}
void PyThread_free_lock(PyThread_type_lock aLock)
{
! dprintf(("%ld: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
CloseHandle(aLock);
}
***************
*** 167,173 ****
int success = 1;
DWORD waitResult;
! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) called\n", PyThread_get_thread_ident(),(long)aLock, waitflag));
#ifndef DEBUG
waitResult = WaitForSingleObject(aLock, (waitflag == 1 ? INFINITE : 0));
--- 167,173 ----
int success = 1;
DWORD waitResult;
! dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n", PyThread_get_thread_ident(),aLock, waitflag));
#ifndef DEBUG
waitResult = WaitForSingleObject(aLock, (waitflag == 1 ? INFINITE : 0));
***************
*** 185,201 ****
success = 0; /* We failed */
}
! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) -> %d\n", PyThread_get_thread_ident(),(long)aLock, waitflag, success));
return success;
}
void PyThread_release_lock(PyThread_type_lock aLock)
{
! dprintf(("%ld: PyThread_release_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock));
if (!SetEvent(aLock))
! dprintf(("%ld: Could not PyThread_release_lock(%lx) error: %l\n", PyThread_get_thread_ident(), (long)aLock, GetLastError()));
}
--- 185,201 ----
success = 0; /* We failed */
}
! dprintf(("%ld: PyThread_acquire_lock(%p, %d) -> %d\n", PyThread_get_thread_ident(),aLock, waitflag, success));
return success;
}
void PyThread_release_lock(PyThread_type_lock aLock)
{
! dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
if (!SetEvent(aLock))
! dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", PyThread_get_thread_ident(), aLock, GetLastError()));
}
diff -c3 /home/trentm/main/contrib/python/dist/src/Objects/bufferobject.c /home/trentm/main/Apps/Perlium/Python/dist/src/Objects/bufferobject.c
*** /home/trentm/main/contrib/python/dist/src/Objects/bufferobject.c Wed May 3 16:44:34 2000
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Objects/bufferobject.c Wed May 3 18:01:15 2000
***************
*** 241,260 ****
if ( self->b_base == NULL )
{
! sprintf(buf, "<%s buffer ptr %lx, size %d at %lx>",
status,
! (long)self->b_ptr,
self->b_size,
! (long)self);
}
else
{
! sprintf(buf, "<%s buffer for %lx, ptr %lx, size %d at %lx>",
status,
! (long)self->b_base,
! (long)self->b_ptr,
self->b_size,
! (long)self);
}
return PyString_FromString(buf);
--- 241,260 ----
if ( self->b_base == NULL )
{
! sprintf(buf, "<%s buffer ptr %p, size %d at %p>",
status,
! self->b_ptr,
self->b_size,
! self);
}
else
{
! sprintf(buf, "<%s buffer for %p, ptr %p, size %d at %p>",
status,
! self->b_base,
! self->b_ptr,
self->b_size,
! self);
}
return PyString_FromString(buf);
diff -c3 /home/trentm/main/contrib/python/dist/src/Objects/classobject.c /home/trentm/main/Apps/Perlium/Python/dist/src/Objects/classobject.c
*** /home/trentm/main/contrib/python/dist/src/Objects/classobject.c Wed May 3 16:44:34 2000
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Objects/classobject.c Thu May 11 20:31:51 2000
***************
*** 351,361 ****
else
name = PyString_AsString(op->cl_name);
if (mod == NULL || !PyString_Check(mod))
! sprintf(buf, "<class ?.%.100s at %lx>", name, (long)op);
else
! sprintf(buf, "<class %.50s.%.50s at %lx>",
PyString_AsString(mod),
! name, (long)op);
return PyString_FromString(buf);
}
--- 351,361 ----
else
name = PyString_AsString(op->cl_name);
if (mod == NULL || !PyString_Check(mod))
! sprintf(buf, "<class ?.%.100s at %p>", name, op);
else
! sprintf(buf, "<class %.50s.%.50s at %p>",
PyString_AsString(mod),
! name, op);
return PyString_FromString(buf);
}
***************
*** 757,768 ****
cname = "?";
PyErr_Clear();
if (mod == NULL || !PyString_Check(mod))
! sprintf(buf, "<?.%.100s instance at %lx>",
! cname, (long)inst);
else
! sprintf(buf, "<%.50s.%.50s instance at %lx>",
PyString_AsString(mod),
! cname, (long)inst);
return PyString_FromString(buf);
}
res = PyEval_CallObject(func, (PyObject *)NULL);
--- 757,768 ----
cname = "?";
PyErr_Clear();
if (mod == NULL || !PyString_Check(mod))
! sprintf(buf, "<?.%.100s instance at %p>",
! cname, inst);
else
! sprintf(buf, "<%.50s.%.50s instance at %p>",
PyString_AsString(mod),
! cname, inst);
return PyString_FromString(buf);
}
res = PyEval_CallObject(func, (PyObject *)NULL);
***************
*** 1638,1645 ****
icname = PyString_AsString(iclassname);
else
icname = "?";
! sprintf(buf, "<method %.60s.%.60s of %.60s instance at %lx>",
! fcname, fname, icname, (long)self);
}
Py_XDECREF(funcname);
return PyString_FromString(buf);
--- 1635,1642 ----
icname = PyString_AsString(iclassname);
else
icname = "?";
! sprintf(buf, "<method %.60s.%.60s of %.60s instance at %p>",
! fcname, fname, icname, self);
}
Py_XDECREF(funcname);
return PyString_FromString(buf);
diff -c3 /home/trentm/main/contrib/python/dist/src/Objects/fileobject.c /home/trentm/main/Apps/Perlium/Python/dist/src/Objects/fileobject.c
*** /home/trentm/main/contrib/python/dist/src/Objects/fileobject.c Wed May 3 16:44:34 2000
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Objects/fileobject.c Wed May 3 18:01:16 2000
***************
*** 223,233 ****
PyFileObject *f;
{
char buf[300];
! sprintf(buf, "<%s file '%.256s', mode '%.10s' at %lx>",
f->f_fp == NULL ? "closed" : "open",
PyString_AsString(f->f_name),
PyString_AsString(f->f_mode),
! (long)f);
return PyString_FromString(buf);
}
--- 223,233 ----
PyFileObject *f;
{
char buf[300];
! sprintf(buf, "<%s file '%.256s', mode '%.10s' at %p>",
f->f_fp == NULL ? "closed" : "open",
PyString_AsString(f->f_name),
PyString_AsString(f->f_mode),
! f);
return PyString_FromString(buf);
}
diff -c3 /home/trentm/main/contrib/python/dist/src/Objects/floatobject.c /home/trentm/main/Apps/Perlium/Python/dist/src/Objects/floatobject.c
*** /home/trentm/main/contrib/python/dist/src/Objects/floatobject.c Wed May 3 16:44:34 2000
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Objects/floatobject.c Thu May 11 20:27:05 2000
***************
*** 805,812 ****
char buf[100];
PyFloat_AsString(buf, p);
fprintf(stderr,
! "# <float at %lx, refcnt=%d, val=%s>\n",
! (long)p, p->ob_refcnt, buf);
}
}
list = list->next;
--- 806,813 ----
char buf[100];
PyFloat_AsString(buf, p);
fprintf(stderr,
! "# <float at %p, refcnt=%d, val=%s>\n",
! p, p->ob_refcnt, buf);
}
}
list = list->next;
diff -c3 /home/trentm/main/contrib/python/dist/src/Objects/funcobject.c /home/trentm/main/Apps/Perlium/Python/dist/src/Objects/funcobject.c
*** /home/trentm/main/contrib/python/dist/src/Objects/funcobject.c Wed May 3 16:44:35 2000
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Objects/funcobject.c Thu May 11 20:28:45 2000
***************
*** 200,210 ****
{
char buf[140];
if (op->func_name == Py_None)
! sprintf(buf, "<anonymous function at %lx>", (long)op);
else
! sprintf(buf, "<function %.100s at %lx>",
PyString_AsString(op->func_name),
! (long)op);
return PyString_FromString(buf);
}
--- 200,210 ----
{
char buf[140];
if (op->func_name == Py_None)
! sprintf(buf, "<anonymous function at %p>", op);
else
! sprintf(buf, "<function %.100s at %p>",
PyString_AsString(op->func_name),
! op);
return PyString_FromString(buf);
}
diff -c3 /home/trentm/main/contrib/python/dist/src/Objects/intobject.c /home/trentm/main/Apps/Perlium/Python/dist/src/Objects/intobject.c
*** /home/trentm/main/contrib/python/dist/src/Objects/intobject.c Tue May 9 07:27:48 2000
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Objects/intobject.c Tue May 9 17:20:56 2000
***************
*** 957,964 ****
i++, p++) {
if (PyInt_Check(p) && p->ob_refcnt != 0)
fprintf(stderr,
! "# <int at %lx, refcnt=%d, val=%ld>\n",
! (long)p, p->ob_refcnt, p->ob_ival);
}
list = list->next;
}
--- 957,964 ----
i++, p++) {
if (PyInt_Check(p) && p->ob_refcnt != 0)
fprintf(stderr,
! "# <int at %p, refcnt=%d, val=%ld>\n",
! p, p->ob_refcnt, p->ob_ival);
}
list = list->next;
}
diff -c3 /home/trentm/main/contrib/python/dist/src/Objects/methodobject.c /home/trentm/main/Apps/Perlium/Python/dist/src/Objects/methodobject.c
*** /home/trentm/main/contrib/python/dist/src/Objects/methodobject.c Wed May 3 16:44:35 2000
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Objects/methodobject.c Thu May 11 20:32:39 2000
***************
*** 148,156 ****
sprintf(buf, "<built-in function %.80s>", m->m_ml->ml_name);
else
sprintf(buf,
! "<built-in method %.80s of %.80s object at %lx>",
m->m_ml->ml_name, m->m_self->ob_type->tp_name,
! (long)m->m_self);
return PyString_FromString(buf);
}
--- 148,156 ----
sprintf(buf, "<built-in function %.80s>", m->m_ml->ml_name);
else
sprintf(buf,
! "<built-in method %.80s of %.80s object at %p>",
m->m_ml->ml_name, m->m_self->ob_type->tp_name,
! m->m_self);
return PyString_FromString(buf);
}
diff -c3 /home/trentm/main/contrib/python/dist/src/Objects/object.c /home/trentm/main/Apps/Perlium/Python/dist/src/Objects/object.c
*** /home/trentm/main/contrib/python/dist/src/Objects/object.c Wed May 3 16:44:35 2000
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Objects/object.c Thu May 11 20:30:57 2000
***************
*** 197,208 ****
}
else {
if (op->ob_refcnt <= 0)
! fprintf(fp, "<refcnt %u at %lx>",
! op->ob_refcnt, (long)op);
else if (op->ob_type->tp_print == NULL) {
if (op->ob_type->tp_repr == NULL) {
! fprintf(fp, "<%s object at %lx>",
! op->ob_type->tp_name, (long)op);
}
else {
PyObject *s;
--- 199,210 ----
}
else {
if (op->ob_refcnt <= 0)
! fprintf(fp, "<refcnt %u at %p>",
! op->ob_refcnt, op);
else if (op->ob_type->tp_print == NULL) {
if (op->ob_type->tp_repr == NULL) {
! fprintf(fp, "<%s object at %p>",
! op->ob_type->tp_name, op);
}
else {
PyObject *s;
***************
*** 248,255 ****
return PyString_FromString("<NULL>");
else if (v->ob_type->tp_repr == NULL) {
char buf[120];
! sprintf(buf, "<%.80s object at %lx>",
! v->ob_type->tp_name, (long)v);
return PyString_FromString(buf);
}
else {
--- 250,257 ----
return PyString_FromString("<NULL>");
else if (v->ob_type->tp_repr == NULL) {
char buf[120];
! sprintf(buf, "<%.80s object at %p>",
! v->ob_type->tp_name, v);
return PyString_FromString(buf);
}
else {
diff -c3 /home/trentm/main/contrib/python/dist/src/Python/compile.c /home/trentm/main/Apps/Perlium/Python/dist/src/Python/compile.c
*** /home/trentm/main/contrib/python/dist/src/Python/compile.c Wed May 3 16:44:38 2000
--- /home/trentm/main/Apps/Perlium/Python/dist/src/Python/compile.c Wed May 3 18:01:23 2000
***************
*** 130,137 ****
filename = PyString_AsString(co->co_filename);
if (co->co_name && PyString_Check(co->co_name))
name = PyString_AsString(co->co_name);
! sprintf(buf, "<code object %.100s at %lx, file \"%.300s\", line %d>",
! name, (long)co, filename, lineno);
return PyString_FromString(buf);
}
--- 130,137 ----
filename = PyString_AsString(co->co_filename);
if (co->co_name && PyString_Check(co->co_name))
name = PyString_AsString(co->co_name);
! sprintf(buf, "<code object %.100s at %p, file \"%.300s\", line %d>",
! name, co, filename, lineno);
return PyString_FromString(buf);
}
--
Trent Mick
trentm@activestate.com