That is about what I just did :-)

Code:
#ifndef SEMAPHORE_C
#define SEMAPHORE_C

#define MAX_SEMAPHORE 42


typedef struct {
	int semaphores[MAX_SEMAPHORE];
} ss_namespace_type;


ss_namespace_type ss_namespace;

void ss_startup(void)
{
	int i;
	
	for (i = 0; i < MAX_SEMAPHORE; i++) {
		ss_namespace.semaphores[i] = -1;
	}
}

int ss_Allocate()
{
	int i;
	
	for (i = 0; i < MAX_SEMAPHORE; i++) {
		if (ss_namespace.semaphores[i] == -1) {
			return(i);
		}
	}
	
	return(-1);
}

void ss_Release(int i)
{
	if (i < MAX_SEMAPHORE && i >= 0) {
		ss_namespace.semaphores[i] = -1;
	}
}

int ss_get(int i)
{
	if (i < MAX_SEMAPHORE && i >= 0) {
		return(ss_namespace.semaphores[i]);
	}
}
	
void ss_set(int i)
{
	if (i < MAX_SEMAPHORE && i >= 0) {
		ss_namespace.semaphores[i] = 1;
	}
}

void ss_clear(int i)
{
	if (i < MAX_SEMAPHORE && i >= 0) {
		ss_namespace.semaphores[i] = 0;
	}
}	

#define wait_semaphore(ws) while(!ss_get(ws)) wait(1)


#endif




Our new web site:Westmarch Studios