Add void to barrier function prototypes
[libnbds.git] / test / spmc_queue_s.c
blob0815ef7462f2d7b5f46aa4455450a82465d086da
1 /*
2 libnbds
3 Copyright (C) 2014 Paweł Dziepak
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include <stdint.h>
21 #include "spmc_queue.h"
23 struct spmc_queue queue;
25 #define SIZE 1024u
27 int main(int argc, char** argv)
29 uintptr_t i;
30 int error;
32 (void)argc;
33 (void)argv;
35 error = spmc_queue_init(&queue);
36 if (error)
37 return 1;
39 if (spmc_queue_dequeue(&queue))
40 return 1;
42 for (i = 1; i < SIZE; i++) {
43 error = spmc_queue_enqueue(&queue, (void*)i);
44 if (error)
45 return 1;
48 for (i = 1; i < SIZE; i++) {
49 if ((uintptr_t)spmc_queue_dequeue(&queue) != i)
50 return 1;
53 if (spmc_queue_dequeue(&queue))
54 return 1;
56 for (i = 1; i < SIZE; i++) {
57 spmc_queue_enqueue(&queue, (void*)i);
58 if ((uintptr_t)spmc_queue_dequeue(&queue) != i)
59 return 1;
62 if (spmc_queue_dequeue(&queue))
63 return 1;
65 spmc_queue_destroy(&queue);
66 error = spmc_queue_init(&queue);
67 if (error)
68 return 1;
70 for (i = 1; i < SIZE; i++) {
71 error = spmc_queue_enqueue(&queue, (void*)i);
72 if (error)
73 return 1;
76 spmc_queue_destroy(&queue);
77 error = spmc_queue_init(&queue);
78 if (error)
79 return 1;
81 if (spmc_queue_dequeue(&queue))
82 return 1;
84 spmc_queue_destroy(&queue);