// This file is part of the SV-Benchmarks collection of verification tasks: // https://github.com/sosy-lab/sv-benchmarks // // SPDX-FileCopyrightText: 2016 SCTBench Project // SPDX-FileCopyrightText: The ESBMC Project // // SPDX-License-Identifier: Apache-2.0 // https://github.com/mc-imperial/sctbench/blob/master/benchmarks/concurrent-software-benchmarks/circular_buffer_ok.c #include #include #define BUFFER_MAX 10 #define N 7 #define ERROR -1 #define FALSE 0 #define TRUE 1 static char buffer[BUFFER_MAX]; /* BUFFER */ static unsigned int first; /* Variable to point to the input buffer */ static unsigned int next; /* Variable to point to the output pointer */ static int buffer_size; /* Max amount of elements in the buffer */ _Bool send, receive; int value; pthread_mutex_t m; void initLog(int max) { buffer_size = max; first = next = 0; } int removeLogElement(void) { if (next > 0 && first < buffer_size) { first++; return buffer[first-1]; } else { return ERROR; } } int insertLogElement(int b) { if (next < buffer_size && buffer_size > 0) { buffer[next] = b; next = (next+1)%buffer_size; assert(next