@@ -218,7 +218,12 @@ static _Atomic(size_t) map_offset{0};
218
218
// Hopefully no one will set a ulimit for this to be a problem...
219
219
static constexpr size_t map_size_inc_default = 128 * 1024 * 1024 ;
220
220
static size_t map_size = 0 ;
221
- static uv_mutex_t shared_map_lock;
221
+ static struct _make_shared_map_lock {
222
+ uv_mutex_t mtx;
223
+ _make_shared_map_lock () {
224
+ uv_mutex_init (&mtx);
225
+ };
226
+ } shared_map_lock;
222
227
223
228
static size_t get_map_size_inc ()
224
229
{
@@ -264,7 +269,7 @@ static void *alloc_shared_page(size_t size, size_t *id, bool exec)
264
269
*id = off;
265
270
size_t map_size_inc = get_map_size_inc ();
266
271
if (__unlikely (off + size > map_size)) {
267
- uv_mutex_lock (&shared_map_lock);
272
+ uv_mutex_lock (&shared_map_lock. mtx );
268
273
size_t old_size = map_size;
269
274
while (off + size > map_size)
270
275
map_size += map_size_inc;
@@ -275,7 +280,7 @@ static void *alloc_shared_page(size_t size, size_t *id, bool exec)
275
280
abort ();
276
281
}
277
282
}
278
- uv_mutex_unlock (&shared_map_lock);
283
+ uv_mutex_unlock (&shared_map_lock. mtx );
279
284
}
280
285
return create_shared_map (size, off);
281
286
}
@@ -313,7 +318,6 @@ ssize_t pwrite_addr(int fd, const void *buf, size_t nbyte, uintptr_t addr)
313
318
// Use `get_self_mem_fd` which has a guard to call this only once.
314
319
static int _init_self_mem ()
315
320
{
316
- uv_mutex_init (&shared_map_lock);
317
321
struct utsname kernel;
318
322
uname (&kernel);
319
323
int major, minor;
0 commit comments