MCPcopy Create free account
hub / github.com/F-Stack/f-stack / malloc_mutex_init

Function malloc_mutex_init

app/redis-6.2.6/deps/jemalloc/src/mutex.c:133–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133bool
134malloc_mutex_init(malloc_mutex_t *mutex, const char *name,
135 witness_rank_t rank, malloc_mutex_lock_order_t lock_order) {
136 mutex_prof_data_init(&mutex->prof_data);
137#ifdef _WIN32
138# if _WIN32_WINNT >= 0x0600
139 InitializeSRWLock(&mutex->lock);
140# else
141 if (!InitializeCriticalSectionAndSpinCount(&mutex->lock,
142 _CRT_SPINCOUNT)) {
143 return true;
144 }
145# endif
146#elif (defined(JEMALLOC_OS_UNFAIR_LOCK))
147 mutex->lock = OS_UNFAIR_LOCK_INIT;
148#elif (defined(JEMALLOC_OSSPIN))
149 mutex->lock = 0;
150#elif (defined(JEMALLOC_MUTEX_INIT_CB))
151 if (postpone_init) {
152 mutex->postponed_next = postponed_mutexes;
153 postponed_mutexes = mutex;
154 } else {
155 if (_pthread_mutex_init_calloc_cb(&mutex->lock,
156 bootstrap_calloc) != 0) {
157 return true;
158 }
159 }
160#else
161 pthread_mutexattr_t attr;
162
163 if (pthread_mutexattr_init(&attr) != 0) {
164 return true;
165 }
166 pthread_mutexattr_settype(&attr, MALLOC_MUTEX_TYPE);
167 if (pthread_mutex_init(&mutex->lock, &attr) != 0) {
168 pthread_mutexattr_destroy(&attr);
169 return true;
170 }
171 pthread_mutexattr_destroy(&attr);
172#endif
173 if (config_debug) {
174 mutex->lock_order = lock_order;
175 if (lock_order == malloc_mutex_address_ordered) {
176 witness_init(&mutex->witness, name, rank,
177 mutex_addr_comp, mutex);
178 } else {
179 witness_init(&mutex->witness, name, rank, NULL, NULL);
180 }
181 }
182 return false;
183}
184
185void
186malloc_mutex_prefork(tsdn_t *tsdn, malloc_mutex_t *mutex) {

Callers 15

bin_initFunction · 0.85
extents_initFunction · 0.85
_init_init_lockFunction · 0.85
ctl_bootFunction · 0.85
prof_accum_initFunction · 0.85
prof_boot2Function · 0.85
mutex_pool_initFunction · 0.85
background_thread_boot1Function · 0.85
rtree_newFunction · 0.85
tcache_bootFunction · 0.85

Calls 3

mutex_prof_data_initFunction · 0.85
pthread_mutex_initFunction · 0.85
witness_initFunction · 0.70

Tested by

no test coverage detected