| 1 | /** |
| 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | * SPDX-License-Identifier: Apache-2.0. |
| 4 | */ |
| 5 | |
| 6 | /** |
| 7 | * FUNCTION: s_swap |
| 8 | * |
| 9 | * This function overrides s_swap and only swaps the backpointer |
| 10 | * indexes. It is used to improve the running time of the CBMC proofs, |
| 11 | * as this function adds heavy overhead on the proofs, especially the |
| 12 | * ones that loop over the elements of the priority queue (such as |
| 13 | * s_sift_up, s_sift_down, s_sift_either). |
| 14 | * |
| 15 | * It is safe to stub s_swap out, as long as no assertions about the |
| 16 | * values of the elements in the priority queue are made |
| 17 | * afterwards. Therefore, this stub cannot be used in proofs about the |
| 18 | * order of the elements in the priority queue, or any other |
| 19 | * functional correctness property concerning the values of the |
| 20 | * elements in the queue. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <aws/common/priority_queue.h> |
| 25 | |
| 26 | void __CPROVER_file_local_priority_queue_c_s_swap(struct aws_priority_queue *queue, size_t a, size_t b) { |
| 27 | assert(aws_priority_queue_is_valid(queue)); |
| 28 | assert(a < queue->container.length); |
| 29 | assert(b < queue->container.length); |
| 30 | assert(aws_priority_queue_backpointer_index_valid(queue, a)); |
| 31 | assert(aws_priority_queue_backpointer_index_valid(queue, b)); |
| 32 | |
| 33 | if (queue->backpointers.data) { |
| 34 | assert(queue->backpointers.length > a); |
| 35 | assert(queue->backpointers.length > b); |
| 36 | } |
| 37 | } |