| line |
true |
false |
branch |
|
149
|
2 |
97 |
if (v < 2) return 2; |
|
150
|
0 |
97 |
if (v > 0x80000000U) return 0; |
|
167
|
161 |
28 |
if (needed <= h->copy_buf_cap) return 1; |
|
168
|
2 |
26 |
uint32_t ns = h->copy_buf_cap ? h->copy_buf_cap : 64; |
|
169
|
0 |
15 |
while (ns < needed) { uint32_t n2 = ns * 2; if (n2 <= ns) { ns = needed; break; } ns = n2; } |
|
|
15 |
28 |
while (ns < needed) { uint32_t n2 = ns * 2; if (n2 <= ns) { ns = needed; break; } ns = n2; } |
|
171
|
0 |
28 |
if (!nb) return 0; |
|
186
|
0 |
0 |
if (pid == 0) return 1; |
|
187
|
0 |
0 |
return !(kill((pid_t)pid, 0) == -1 && errno == ESRCH); |
|
|
0 |
0 |
return !(kill((pid_t)pid, 0) == -1 && errno == ESRCH); |
|
193
|
0 |
0 |
if (!__atomic_compare_exchange_n(&hdr->mutex, &observed, 0, |
|
197
|
0 |
0 |
if (__atomic_load_n(&hdr->mutex_waiters, __ATOMIC_RELAXED) > 0) |
|
205
|
419 |
0 |
if (__atomic_compare_exchange_n(&hdr->mutex, &expected, mypid, |
|
208
|
0 |
0 |
if (__builtin_expect(spin < QUEUE_SPIN_LIMIT, 1)) { |
|
214
|
0 |
0 |
if (cur != 0) { |
|
217
|
0 |
0 |
if (rc == -1 && errno == ETIMEDOUT) { |
|
|
0 |
0 |
if (rc == -1 && errno == ETIMEDOUT) { |
|
220
|
0 |
0 |
if (val >= QUEUE_MUTEX_WRITER_BIT) { |
|
222
|
0 |
0 |
if (!queue_pid_alive(pid)) |
|
236
|
1 |
418 |
if (__atomic_load_n(&hdr->mutex_waiters, __ATOMIC_RELAXED) > 0) |
|
245
|
0 |
448 |
if (n == 0) return; |
|
246
|
0 |
448 |
if (__atomic_load_n(&hdr->pop_waiters, __ATOMIC_RELAXED) > 0) { |
|
249
|
0 |
0 |
n > (uint32_t)INT_MAX ? INT_MAX : (int)n, NULL, NULL, 0); |
|
261
|
0 |
627 |
if (n == 0) return; |
|
262
|
0 |
627 |
if (__atomic_load_n(&hdr->push_waiters, __ATOMIC_RELAXED) > 0) { |
|
265
|
0 |
0 |
n > (uint32_t)INT_MAX ? INT_MAX : (int)n, NULL, NULL, 0); |
|
281
|
17 |
9 |
if (remaining->tv_nsec < 0) { |
|
293
|
0 |
25 |
if (deadline->tv_nsec >= 1000000000L) { |
|
322
|
41 |
49 |
if (mode == QUEUE_MODE_INT) INIT_SEQ(QueueIntSlot, cap); |
|
|
2276 |
41 |
if (mode == QUEUE_MODE_INT) INIT_SEQ(QueueIntSlot, cap); |
|
323
|
8 |
41 |
else if (mode == QUEUE_MODE_INT32) INIT_SEQ(QueueInt32Slot, cap); |
|
|
1448 |
8 |
else if (mode == QUEUE_MODE_INT32) INIT_SEQ(QueueInt32Slot, cap); |
|
324
|
3 |
38 |
else if (mode == QUEUE_MODE_INT16) INIT_SEQ(QueueInt16Slot, cap); |
|
|
1072 |
3 |
else if (mode == QUEUE_MODE_INT16) INIT_SEQ(QueueInt16Slot, cap); |
|
332
|
87 |
0 |
if (errbuf) errbuf[0] = '\0'; |
|
335
|
0 |
87 |
if (cap == 0) { QUEUE_ERR("invalid capacity"); return NULL; } |
|
|
0 |
0 |
if (cap == 0) { QUEUE_ERR("invalid capacity"); return NULL; } |
|
336
|
0 |
87 |
if (mode > QUEUE_MODE_INT16) { QUEUE_ERR("unknown mode %u", mode); return NULL; } |
|
|
0 |
0 |
if (mode > QUEUE_MODE_INT16) { QUEUE_ERR("unknown mode %u", mode); return NULL; } |
|
340
|
48 |
39 |
: (mode == QUEUE_MODE_INT32) ? sizeof(QueueInt32Slot) |
|
341
|
40 |
8 |
: (mode == QUEUE_MODE_INT16) ? sizeof(QueueInt16Slot) |
|
342
|
3 |
37 |
: sizeof(QueueStrSlot); |
|
346
|
37 |
50 |
if (mode == QUEUE_MODE_STR) { |
|
350
|
8 |
29 |
if (arena_cap < 4096) arena_cap = 4096; |
|
351
|
0 |
37 |
if (arena_cap > UINT32_MAX) arena_cap = UINT32_MAX; |
|
361
|
21 |
66 |
if (anonymous) { |
|
366
|
0 |
21 |
if (base == MAP_FAILED) { |
|
367
|
0 |
0 |
QUEUE_ERR("mmap(anonymous): %s", strerror(errno)); |
|
374
|
0 |
66 |
if (fd < 0) { QUEUE_ERR("open(%s): %s", path, strerror(errno)); return NULL; } |
|
|
0 |
0 |
if (fd < 0) { QUEUE_ERR("open(%s): %s", path, strerror(errno)); return NULL; } |
|
376
|
0 |
66 |
if (flock(fd, LOCK_EX) < 0) { |
|
377
|
0 |
0 |
QUEUE_ERR("flock(%s): %s", path, strerror(errno)); |
|
382
|
0 |
66 |
if (fstat(fd, &st) < 0) { |
|
383
|
0 |
0 |
QUEUE_ERR("fstat(%s): %s", path, strerror(errno)); |
|
389
|
9 |
57 |
if (!is_new && (uint64_t)st.st_size < sizeof(QueueHeader)) { |
|
|
0 |
9 |
if (!is_new && (uint64_t)st.st_size < sizeof(QueueHeader)) { |
|
390
|
0 |
0 |
QUEUE_ERR("%s: file too small (%lld)", path, (long long)st.st_size); |
|
394
|
57 |
9 |
if (is_new) { |
|
395
|
0 |
57 |
if (ftruncate(fd, (off_t)total_size) < 0) { |
|
396
|
0 |
0 |
QUEUE_ERR("ftruncate(%s): %s", path, strerror(errno)); |
|
401
|
9 |
57 |
map_size = is_new ? (size_t)total_size : (size_t)st.st_size; |
|
403
|
0 |
66 |
if (base == MAP_FAILED) { |
|
404
|
0 |
0 |
QUEUE_ERR("mmap(%s): %s", path, strerror(errno)); |
|
410
|
9 |
57 |
if (!is_new) { |
|
413
|
9 |
0 |
hdr->version == QUEUE_VERSION && |
|
414
|
5 |
4 |
hdr->mode == mode && |
|
415
|
5 |
0 |
hdr->capacity > 0 && |
|
416
|
5 |
0 |
(hdr->capacity & (hdr->capacity - 1)) == 0 && |
|
417
|
5 |
0 |
hdr->total_size == (uint64_t)st.st_size && |
|
418
|
9 |
0 |
hdr->slots_off == sizeof(QueueHeader) && |
|
|
5 |
0 |
hdr->slots_off == sizeof(QueueHeader) && |
|
419
|
5 |
0 |
hdr->capacity <= (hdr->total_size - hdr->slots_off) / slot_size); |
|
420
|
3 |
6 |
if (mode == QUEUE_MODE_STR && valid) { |
|
|
2 |
1 |
if (mode == QUEUE_MODE_STR && valid) { |
|
422
|
2 |
0 |
valid = (hdr->arena_off >= slots_end && |
|
423
|
2 |
0 |
hdr->arena_off + hdr->arena_cap <= hdr->total_size); |
|
425
|
4 |
5 |
if (!valid) { |
|
426
|
4 |
0 |
QUEUE_ERR("%s: invalid or incompatible queue file", path); |
|
445
|
0 |
83 |
if (!h) { munmap(base, map_size); return NULL; } |
|
449
|
36 |
47 |
h->arena = (mode == QUEUE_MODE_STR) ? (char *)base + hdr->arena_off : NULL; |
|
454
|
62 |
21 |
h->path = path ? strdup(path) : NULL; |
|
466
|
12 |
0 |
if (errbuf) errbuf[0] = '\0'; |
|
469
|
0 |
12 |
if (cap == 0) { QUEUE_ERR("invalid capacity"); return NULL; } |
|
|
0 |
0 |
if (cap == 0) { QUEUE_ERR("invalid capacity"); return NULL; } |
|
470
|
0 |
12 |
if (mode > QUEUE_MODE_INT16) { QUEUE_ERR("unknown mode %u", mode); return NULL; } |
|
|
0 |
0 |
if (mode > QUEUE_MODE_INT16) { QUEUE_ERR("unknown mode %u", mode); return NULL; } |
|
474
|
6 |
6 |
: (mode == QUEUE_MODE_INT32) ? sizeof(QueueInt32Slot) |
|
475
|
5 |
1 |
: (mode == QUEUE_MODE_INT16) ? sizeof(QueueInt16Slot) |
|
476
|
1 |
4 |
: sizeof(QueueStrSlot); |
|
479
|
4 |
8 |
if (mode == QUEUE_MODE_STR) { |
|
483
|
0 |
4 |
if (arena_cap < 4096) arena_cap = 4096; |
|
484
|
0 |
4 |
if (arena_cap > UINT32_MAX) arena_cap = UINT32_MAX; |
|
490
|
12 |
0 |
int fd = memfd_create(name ? name : "queue", MFD_CLOEXEC | MFD_ALLOW_SEALING); |
|
491
|
0 |
12 |
if (fd < 0) { QUEUE_ERR("memfd_create: %s", strerror(errno)); return NULL; } |
|
|
0 |
0 |
if (fd < 0) { QUEUE_ERR("memfd_create: %s", strerror(errno)); return NULL; } |
|
493
|
0 |
12 |
if (ftruncate(fd, (off_t)total_size) < 0) { |
|
494
|
0 |
0 |
QUEUE_ERR("ftruncate(memfd): %s", strerror(errno)); |
|
502
|
0 |
12 |
if (base == MAP_FAILED) { |
|
503
|
0 |
0 |
QUEUE_ERR("mmap(memfd): %s", strerror(errno)); |
|
510
|
0 |
12 |
if (!h) { munmap(base, (size_t)total_size); close(fd); return NULL; } |
|
514
|
4 |
8 |
h->arena = (mode == QUEUE_MODE_STR) ? (char *)base + arena_off : NULL; |
|
528
|
2 |
0 |
if (errbuf) errbuf[0] = '\0'; |
|
531
|
0 |
2 |
if (fstat(fd, &st) < 0) { |
|
532
|
0 |
0 |
QUEUE_ERR("fstat(fd=%d): %s", fd, strerror(errno)); |
|
536
|
0 |
2 |
if ((uint64_t)st.st_size < sizeof(QueueHeader)) { |
|
537
|
0 |
0 |
QUEUE_ERR("fd %d: too small (%lld)", fd, (long long)st.st_size); |
|
543
|
0 |
2 |
if (base == MAP_FAILED) { |
|
544
|
0 |
0 |
QUEUE_ERR("mmap(fd=%d): %s", fd, strerror(errno)); |
|
550
|
1 |
1 |
: (mode == QUEUE_MODE_INT32) ? sizeof(QueueInt32Slot) |
|
551
|
1 |
0 |
: (mode == QUEUE_MODE_INT16) ? sizeof(QueueInt16Slot) |
|
552
|
0 |
1 |
: sizeof(QueueStrSlot); |
|
554
|
2 |
0 |
hdr->version == QUEUE_VERSION && |
|
555
|
2 |
0 |
hdr->mode == mode && |
|
556
|
2 |
0 |
hdr->capacity > 0 && |
|
557
|
2 |
0 |
(hdr->capacity & (hdr->capacity - 1)) == 0 && |
|
558
|
2 |
0 |
hdr->total_size == (uint64_t)st.st_size && |
|
559
|
2 |
0 |
hdr->slots_off == sizeof(QueueHeader) && |
|
|
2 |
0 |
hdr->slots_off == sizeof(QueueHeader) && |
|
560
|
2 |
0 |
hdr->capacity <= (hdr->total_size - hdr->slots_off) / slot_size); |
|
561
|
1 |
1 |
if (mode == QUEUE_MODE_STR && valid) { |
|
|
1 |
0 |
if (mode == QUEUE_MODE_STR && valid) { |
|
563
|
1 |
0 |
valid = (hdr->arena_off >= slots_end && |
|
564
|
1 |
0 |
hdr->arena_off + hdr->arena_cap <= hdr->total_size); |
|
566
|
0 |
2 |
if (!valid) { |
|
567
|
0 |
0 |
QUEUE_ERR("fd %d: invalid or incompatible queue", fd); |
|
574
|
0 |
2 |
if (myfd < 0) { |
|
575
|
0 |
0 |
QUEUE_ERR("fcntl(F_DUPFD_CLOEXEC): %s", strerror(errno)); |
|
581
|
0 |
2 |
if (!h) { munmap(base, map_size); close(myfd); return NULL; } |
|
585
|
1 |
1 |
h->arena = (mode == QUEUE_MODE_STR) ? (char *)base + hdr->arena_off : NULL; |
|
598
|
0 |
97 |
if (!h) return; |
|
601
|
10 |
87 |
if (h->notify_fd >= 0 && h->notify_fd_owned) close(h->notify_fd); |
|
|
9 |
1 |
if (h->notify_fd >= 0 && h->notify_fd_owned) close(h->notify_fd); |
|
602
|
14 |
83 |
if (h->backing_fd >= 0) close(h->backing_fd); |
|
603
|
97 |
0 |
if (h->hdr) munmap(h->hdr, h->mmap_size); |
|
770
|
44 |
5 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
6 |
3 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
100 |
7 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
0 |
7 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
7 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
0 |
7 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
7 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
0 |
7 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
5 |
2 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
2 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
2 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
10 |
3 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
1 |
2 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
2 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
0 |
2 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
2 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
0 |
2 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
1 |
1 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
1 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
1 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
310 |
39 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
310 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
39 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
209 |
11 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
209 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
11 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
773
|
16 |
1 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
1 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
99 |
2 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
2 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
2 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
2 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
2 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
2 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
2 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
138 |
7 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
138 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
7 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
37 |
1 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
37 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
1 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
776
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
12 |
1 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
12 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
1 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
12 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
12 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
787
|
0 |
190 |
if (len > QUEUE_STR_LEN_MASK) return -2; |
|
789
|
11 |
179 |
if (hdr->tail - hdr->head >= h->capacity) { |
|
795
|
2 |
177 |
if (alloc == 0) alloc = 8; |
|
796
|
0 |
179 |
if (alloc > h->arena_cap) return -2; |
|
801
|
2 |
177 |
if ((uint64_t)pos + alloc > h->arena_cap) { |
|
806
|
1 |
178 |
if ((uint64_t)hdr->arena_used + skip > h->arena_cap) { |
|
807
|
0 |
1 |
if (hdr->tail == hdr->head) { |
|
824
|
4 |
174 |
slot->packed_len = len | (utf8 ? QUEUE_STR_UTF8_FLAG : 0); |
|
840
|
173 |
11 |
if (r == 1) queue_wake_consumers(h->hdr); |
|
849
|
30 |
164 |
if (hdr->tail == hdr->head) { |
|
860
|
0 |
164 |
if (!queue_ensure_copy_buf(h, len + 1)) |
|
862
|
162 |
2 |
if (len > 0) |
|
869
|
49 |
115 |
if (hdr->arena_used == 0) |
|
882
|
140 |
23 |
if (r == 1) queue_wake_producers(h->hdr); |
|
889
|
5 |
3 |
if (r != 0) return r; /* 1 = success, -2 = too long */ |
|
890
|
0 |
3 |
if (timeout == 0) return 0; |
|
895
|
3 |
0 |
if (has_deadline) queue_make_deadline(timeout, &deadline); |
|
905
|
0 |
3 |
if (r != 0) { |
|
911
|
3 |
0 |
if (has_deadline) { |
|
912
|
0 |
3 |
if (!queue_remaining_time(&deadline, &remaining)) { |
|
922
|
1 |
2 |
if (r != 0) return r; |
|
923
|
2 |
0 |
if (rc == -1 && errno == ETIMEDOUT) return 0; |
|
|
2 |
0 |
if (rc == -1 && errno == ETIMEDOUT) return 0; |
|
930
|
50 |
7 |
if (r != 0) return r; |
|
931
|
0 |
7 |
if (timeout == 0) return 0; |
|
936
|
7 |
0 |
if (has_deadline) queue_make_deadline(timeout, &deadline); |
|
943
|
0 |
8 |
if (r != 0) { |
|
949
|
8 |
0 |
if (has_deadline) { |
|
950
|
0 |
8 |
if (!queue_remaining_time(&deadline, &remaining)) { |
|
960
|
5 |
3 |
if (r != 0) return r; |
|
961
|
2 |
1 |
if (rc == -1 && errno == ETIMEDOUT) return 0; |
|
|
2 |
0 |
if (rc == -1 && errno == ETIMEDOUT) return 0; |
|
982
|
0 |
7 |
if (__atomic_load_n(&hdr->push_waiters, __ATOMIC_RELAXED) > 0) { |
|
986
|
0 |
7 |
if (__atomic_load_n(&hdr->pop_waiters, __ATOMIC_RELAXED) > 0) { |
|
997
|
1 |
6 |
if (hdr->tail == hdr->head) { |
|
1005
|
0 |
6 |
if (!queue_ensure_copy_buf(h, len + 1)) { |
|
1009
|
6 |
0 |
if (len > 0) |
|
1024
|
0 |
21 |
if (len > QUEUE_STR_LEN_MASK) { |
|
1030
|
6 |
15 |
if (size >= h->capacity) { |
|
1037
|
0 |
15 |
if (alloc == 0) alloc = 8; |
|
1038
|
0 |
15 |
if (alloc > h->arena_cap) { |
|
1046
|
0 |
15 |
if ((uint64_t)pos + alloc > h->arena_cap) { |
|
1051
|
0 |
15 |
if ((uint64_t)hdr->arena_used + skip > h->arena_cap) { |
|
1052
|
0 |
0 |
if (hdr->tail == hdr->head) { |
|
1071
|
1 |
14 |
slot->packed_len = len | (utf8 ? QUEUE_STR_UTF8_FLAG : 0); |
|
1087
|
1 |
2 |
if (r != 0) return r; |
|
1088
|
0 |
2 |
if (timeout == 0) return 0; |
|
1093
|
2 |
0 |
if (has_deadline) queue_make_deadline(timeout, &deadline); |
|
1100
|
0 |
2 |
if (r != 0) { |
|
1106
|
2 |
0 |
if (has_deadline) { |
|
1107
|
0 |
2 |
if (!queue_remaining_time(&deadline, &remaining)) { |
|
1117
|
1 |
1 |
if (r != 0) return r; |
|
1118
|
1 |
0 |
if (rc == -1 && errno == ETIMEDOUT) return 0; |
|
|
1 |
0 |
if (rc == -1 && errno == ETIMEDOUT) return 0; |
|
1128
|
7 |
19 |
if (hdr->tail == hdr->head) { |
|
1141
|
0 |
19 |
if (!queue_ensure_copy_buf(h, len + 1)) { |
|
1146
|
19 |
0 |
if (len > 0) |
|
1158
|
0 |
19 |
if (slot_alloc == 0) slot_alloc = 8; |
|
1159
|
16 |
3 |
if (slot->arena_off + slot_alloc == hdr->arena_wpos) |
|
1162
|
7 |
12 |
if (hdr->arena_used == 0) |
|
1174
|
1 |
2 |
if (r != 0) return r; |
|
1175
|
0 |
2 |
if (timeout == 0) return 0; |
|
1180
|
2 |
0 |
if (has_deadline) queue_make_deadline(timeout, &deadline); |
|
1187
|
0 |
2 |
if (r != 0) { |
|
1193
|
2 |
0 |
if (has_deadline) { |
|
1194
|
0 |
2 |
if (!queue_remaining_time(&deadline, &remaining)) { |
|
1204
|
1 |
1 |
if (r != 0) return r; |
|
1205
|
1 |
0 |
if (rc == -1 && errno == ETIMEDOUT) return 0; |
|
|
1 |
0 |
if (rc == -1 && errno == ETIMEDOUT) return 0; |
|
1219
|
1 |
10 |
if (h->notify_fd >= 0) return h->notify_fd; |
|
1221
|
10 |
0 |
if (h->notify_fd >= 0) h->notify_fd_owned = 1; |
|
1229
|
1 |
0 |
if (h->notify_fd >= 0 && h->notify_fd != fd && h->notify_fd_owned) |
|
|
1 |
0 |
if (h->notify_fd >= 0 && h->notify_fd != fd && h->notify_fd_owned) |
|
|
1 |
0 |
if (h->notify_fd >= 0 && h->notify_fd != fd && h->notify_fd_owned) |
|
1237
|
7 |
1 |
if (h->notify_fd >= 0) { |
|
1246
|
0 |
10 |
if (h->notify_fd < 0) return -1; |
|
1248
|
0 |
10 |
if (read(h->notify_fd, &val, sizeof(val)) != sizeof(val)) return -1; |