# HG changeset patch # User Me@portablequad # Date 1329021472 28800 # Node ID b5ae7fbb1f014a59c983f52ea16b7b73def66e1a # Parent 1ed562d601d9b42daaeb0ea22d4ed5d93b2ffa47 Created MC_shared brch diff -r 1ed562d601d9 -r b5ae7fbb1f01 .brch__MC_shared --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.brch__MC_shared Sat Feb 11 20:37:52 2012 -0800 @@ -0,0 +1,4 @@ +This branch is for the project structure defined Jan 2012.. the #includes reflect this directory structure. + +More importantly, the MC_shared version of VMS requires a separat malloc implemeted by VMS code.. so this branch has modified the library to use the VMS-specific malloc. + diff -r 1ed562d601d9 -r b5ae7fbb1f01 .hgeol --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgeol Sat Feb 11 20:37:52 2012 -0800 @@ -0,0 +1,14 @@ + +[patterns] +**.py = native +**.txt = native +**.c = native +**.h = native +**.cpp = native +**.java = native +**.class = bin +**.jar = bin +**.sh = native +**.pl = native +**.jpg = bin +**.gif = bin diff -r 1ed562d601d9 -r b5ae7fbb1f01 BlockingQueue.c --- a/BlockingQueue.c Tue Feb 07 12:51:29 2012 -0800 +++ b/BlockingQueue.c Sat Feb 11 20:37:52 2012 -0800 @@ -18,89 +18,6 @@ #define SPINLOCK_TRIES 100000 -//=========================================================================== -//Normal pthread Q - -PThdQueueStruc* makePThdQ() - { - PThdQueueStruc* retQ; - int retCode; - retQ = (PThdQueueStruc *) malloc( sizeof( PThdQueueStruc ) ); - - - retCode = - pthread_mutex_init( &retQ->mutex_t, NULL); - if(retCode){perror("Error in creating mutex:"); exit(1);} - - retCode = pthread_cond_init ( &retQ->cond_w_t, NULL); - if(retCode){perror("Error in creating cond_var:"); exit(1);} - - retCode = pthread_cond_init ( &retQ->cond_r_t, NULL); - if(retCode){perror("Error in creating cond_var:"); exit(1);} - - retQ->count = 0; - retQ->readPos = 0; - retQ->writePos = 0; - retQ->w_empty = 0; - retQ->w_full = 0; - - return retQ; - } - -void * readPThdQ( PThdQueueStruc *Q ) - { void *ret; - int retCode, wt; - pthread_mutex_lock( &Q->mutex_t ); - { - while( Q -> count == 0 ) - { Q -> w_empty = 1; - retCode = - pthread_cond_wait( &Q->cond_r_t, &Q->mutex_t ); - if( retCode ){ perror("Thread wait error: "); exit(1); } - } - Q -> w_empty = 0; - Q -> count -= 1; - ret = Q->data[ Q->readPos ]; - INC( Q->readPos ); - wt = Q -> w_full; - Q -> w_full = 0; - } - pthread_mutex_unlock( &Q->mutex_t ); - if (wt) - pthread_cond_signal( &Q->cond_w_t ); - - //printf("Q out: %d\n", ret); - return( ret ); - } - -void writePThdQ( void * in, PThdQueueStruc* Q ) - { - int status, wt; - //printf("Q in: %d\n", in); - - pthread_mutex_lock( &Q->mutex_t ); - { - while( Q->count >= 1024 ) - { - Q -> w_full = 1; - status = pthread_cond_wait( &Q->cond_w_t, &Q->mutex_t ); - if (status != 0) - { perror("Thread wait error: "); - exit(1); - } - } - - Q -> w_full = 0; - Q->count += 1; - Q->data[ Q->writePos ] = in; - INC( Q->writePos ); - wt = Q -> w_empty; - Q -> w_empty = 0; - } - - pthread_mutex_unlock( &Q->mutex_t ); - if( wt ) pthread_cond_signal( &Q->cond_r_t ); - } //=========================================================================== @@ -117,7 +34,7 @@ CASQueueStruc* makeCASQ() { CASQueueStruc* retQ; - retQ = (CASQueueStruc *) malloc( sizeof( CASQueueStruc ) ); + retQ = (CASQueueStruc *) VMS__malloc( sizeof( CASQueueStruc ) ); retQ->insertLock = UNLOCKED; retQ->extractLock= UNLOCKED; @@ -242,7 +159,7 @@ SRSWQueueStruc* makeSRSWQ() { SRSWQueueStruc* retQ; - retQ = (SRSWQueueStruc *) malloc( sizeof( SRSWQueueStruc ) ); + retQ = (SRSWQueueStruc *) VMS__malloc( sizeof( SRSWQueueStruc ) ); memset( retQ->startOfData, 0, 1024 * sizeof(void *) ); retQ->extractPos = &(retQ->startOfData[0]); //side by side == empty @@ -255,7 +172,7 @@ void freeSRSWQ( SRSWQueueStruc* Q ) { - free( Q ); + VMS__free( Q ); } void* readSRSWQ( SRSWQueueStruc* Q ) @@ -381,11 +298,11 @@ SRMWQueueStruc* makeSRMWQ() { SRMWQueueStruc* retQ; - retQ = (SRMWQueueStruc *) malloc( sizeof( SRMWQueueStruc ) ); + retQ = (SRMWQueueStruc *) VMS__malloc( sizeof( SRMWQueueStruc ) ); retQ->numInternalQs = 0; retQ->internalQsSz = 10; - retQ->internalQs = malloc( retQ->internalQsSz * sizeof(SRSWQueueStruc *)); + retQ->internalQs = VMS__malloc( retQ->internalQsSz * sizeof(SRSWQueueStruc *)); retQ->lastQReadFrom = 0; @@ -411,11 +328,11 @@ oldSz = Q->internalQsSz; oldArray = Q->internalQs; Q->internalQsSz *= 2; - Q->internalQs = malloc( Q->internalQsSz * sizeof(SRSWQueueStruc *)); + Q->internalQs = VMS__malloc( Q->internalQsSz * sizeof(SRSWQueueStruc *)); for( i = 0; i < oldSz; i++ ) { Q->internalQs[i] = oldArray[i]; } - free( oldArray ); + VMS__free( oldArray ); } Q->internalQs[ Q->numInternalQs - 1 ] = makeSRSWQ(); return Q->numInternalQs - 1; diff -r 1ed562d601d9 -r b5ae7fbb1f01 BlockingQueue.h --- a/BlockingQueue.h Tue Feb 07 12:51:29 2012 -0800 +++ b/BlockingQueue.h Sat Feb 11 20:37:52 2012 -0800 @@ -8,7 +8,8 @@ #ifndef _BLOCKINGQUEUE_H #define _BLOCKINGQUEUE_H -#include "pthread.h" +#include "../../VMS_Implementations/VMS_impl/VMS_primitive_data_types.h" +#include "../../VMS_Implementations/VMS_impl/vmalloc.h" #define TRUE 1 diff -r 1ed562d601d9 -r b5ae7fbb1f01 PrivateQueue.c --- a/PrivateQueue.c Tue Feb 07 12:51:29 2012 -0800 +++ b/PrivateQueue.c Sat Feb 11 20:37:52 2012 -0800 @@ -26,9 +26,9 @@ PrivQueueStruc* makePrivQ() { PrivQueueStruc* retQ; - retQ = (PrivQueueStruc *) malloc( sizeof( PrivQueueStruc ) ); + retQ = (PrivQueueStruc *) VMS__malloc( sizeof( PrivQueueStruc ) ); - retQ->startOfData = malloc( 1024 * sizeof(void *) ); + retQ->startOfData = VMS__malloc( 1024 * sizeof(void *) ); memset( retQ->startOfData, 0, 1024 * sizeof(void *) ); retQ->extractPos = &(retQ->startOfData[0]); //side by side == empty retQ->insertPos = &(retQ->startOfData[1]); // so start pos's have to be @@ -46,9 +46,9 @@ oldSize = Q->endOfData - Q->startOfData; newSize = 2 * oldSize; oldStartOfData = Q->startOfData; - Q->startOfData = malloc( newSize * sizeof(void *) ); + Q->startOfData = VMS__malloc( newSize * sizeof(void *) ); memcpy(Q->startOfData, oldStartOfData, oldSize * sizeof(void *)); - free(oldStartOfData); + VMS__free(oldStartOfData); Q->extractPos = &(Q->startOfData[0]); //side by side == empty Q->insertPos = &(Q->startOfData[1]); // so start pos's have to be diff -r 1ed562d601d9 -r b5ae7fbb1f01 PrivateQueue.h --- a/PrivateQueue.h Tue Feb 07 12:51:29 2012 -0800 +++ b/PrivateQueue.h Sat Feb 11 20:37:52 2012 -0800 @@ -8,7 +8,10 @@ #ifndef _PRIVATE_QUEUE_H #define _PRIVATE_QUEUE_H -#include + +#include "../../VMS_Implementations/VMS_impl/VMS_primitive_data_types.h" +#include "../../VMS_Implementations/VMS_impl/vmalloc.h" + #define TRUE 1 #define FALSE 0