char * Strdup(const char *s) { unsigned len = Strlen(s); char *b = (char *) Alloc_mem(len+1); strcpy(b, s); return b; }
RMAWindow<T>::RMAWindow(Intracomm *comm, size_t dataSize, Datatype dataType) : Communicable(comm), dataSize(dataSize), dataType(dataType) { const Aint sizeInBytes = dataSize * sizeof(T); data = (T*) Alloc_mem(sizeInBytes, INFO_NULL); memset(data, 0, sizeInBytes); win = new Win(); *win = Win::Create(data, sizeInBytes, sizeof(T), INFO_NULL, *comm); }
/** Creates a new semaphore, initializing its value to value, may allocate memory */ Sem_t Sem_create(unsigned int value) { sem_t *sem = (sem_t *)Alloc_mem(sizeof(sem_t)); if (sem) { int ret = sem_init(sem, 0, value); if (ret) { Free_mem(sem); sem = 0; } } return (Sem_t)sem; }
void *operator new[](unsigned int size) { return Alloc_mem(size); }
Cond_t cond_create(void) { Cond_t c = (Cond_t)Alloc_mem(sizeof(pthread_cond_t)); if (c) pthread_cond_init((pthread_cond_t *)c, 0); return c; }
/** Creates a new mutex, may allocate memory */ Mut_t mut_create(void) { Mut_t mut = (Mut_t)Alloc_mem(sizeof(pthread_mutex_t)); if (mut) pthread_mutex_init((pthread_mutex_t *)mut, 0); return mut; }