/*-------------------------------------------------------------------*/ static ILOCK* hthreads_get_ILOCK( void* addr, const char* name ) { ILOCK* ilk; /* Pointer to ILOCK structure */ LIST_ENTRY* ple; /* Ptr to LIST_ENTRY structure */ hthreads_internal_init(); /* Search list to see if this lock has already been allocated */ LockLocksList(); for (ple = locklist.Flink; ple != &locklist; ple = ple->Flink) { ilk = CONTAINING_RECORD( ple, ILOCK, locklink ); if (ilk->addr == addr) break; } /* If needed, alloacte a new ILOCK structure for this lock */ if (&locklist == ple) { if (!(ilk = calloc_aligned( sizeof( ILOCK ), 64 ))) { perror( "Fatal error in hthreads_get_ILOCK function" ); exit(1); } ilk->addr = addr; InsertListTail( &locklist, &ilk->locklink ); lockcount++; } ilk->name = name; ilk->location = "null:0"; ilk->tid = 0; ilk->time.tv_sec = 0; ilk->time.tv_usec = 0; UnlockLocksList(); return ilk; }
T* MALLOC ASSUME_ALIGNED(64) calloc_aligned(std::size_t n) { return static_cast<T*>(calloc_aligned(n * sizeof(T))); }