Debian Codegraph @

crt/aws-c-common/verification/cbmc/include/proof_helpers/ring_buffer_abstract_states.h

raw symbols SCIP
1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #pragma once
7
8 /**
9 * Ring buffer is empty
10 */
11 bool is_empty_state(struct aws_ring_buffer *ring_buf) {
12 uint8_t *head = aws_atomic_load_ptr(&ring_buf->head);
13 uint8_t *tail = aws_atomic_load_ptr(&ring_buf->tail);
14 return tail == head;
15 }
16
17 /**
18 * Ring buffer is valid [allocation==tail...head)
19 */
20 bool is_front_valid_state(struct aws_ring_buffer *ring_buf) {
21 uint8_t *head = aws_atomic_load_ptr(&ring_buf->head);
22 uint8_t *tail = aws_atomic_load_ptr(&ring_buf->tail);
23 return ring_buf->allocation == tail && tail < head;
24 }
25
26 /**
27 * Ring buffer is valid [allocation<tail...head) (not front_valid)
28 */
29 bool is_middle_valid_state(struct aws_ring_buffer *ring_buf) {
30 uint8_t *head = aws_atomic_load_ptr(&ring_buf->head);
31 uint8_t *tail = aws_atomic_load_ptr(&ring_buf->tail);
32 return ring_buf->allocation < tail && tail < head;
33 }
34
35 /**
36 * Ring buffer is valid [allocation...head) and [tail...allocation_end)
37 */
38 bool is_ends_valid_state(struct aws_ring_buffer *ring_buf) {
39 uint8_t *head = aws_atomic_load_ptr(&ring_buf->head);
40 uint8_t *tail = aws_atomic_load_ptr(&ring_buf->tail);
41 return tail > head;
42 }