[Softpear-cvs] softpear/src/loader nativelib.cc,1.60,1.61
Status: Pre-Alpha
Brought to you by:
mist
From: <mas...@us...> - 2005-03-15 17:03:14
|
Update of /cvsroot/softpear/softpear/src/loader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22357/src/loader Modified Files: nativelib.cc Log Message: fixed memory leak causing threads not to free their malloc'ed memory the thread object of the current thread is now always accessable via the local gCPU structure Index: nativelib.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/loader/nativelib.cc,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- nativelib.cc 14 Mar 2005 22:55:11 -0000 1.60 +++ nativelib.cc 15 Mar 2005 17:03:03 -0000 1.61 @@ -1126,10 +1126,18 @@ printf("Could not create new CPU, aborting!\n"); exit(EXIT_FAILURE); } - newCPU->pc = gCPU->gpr[5]; - newCPU->gpr[3] = gCPU->gpr[6]; + + newCPU->pc = gCPU->gpr[5]; /* The new CPU should start interpretation at the passed start_routine */ + newCPU->gpr[3] = gCPU->gpr[6]; /* Argument for the start_routine should be in r3 of the new CPU */ + int result = pthread_create((pthread_t*)gCPU->gpr[3], (pthread_attr_t*)gCPU->gpr[4], ppc_cpu_run, (void*)newCPU); + + /* All CPUs have their thread ID stored in their gCPU structure */ + newCPU->thread = *((pthread_t*)gCPU->gpr[3]); + + /* Since the first argument to pthread_create is a double pointer, change endianess, here */ *((sp_uint32_t*)gCPU->gpr[3]) = Host_to_BE32(*((sp_uint32_t*)gCPU->gpr[3])); + gCPU->gpr[3] = result; } |