blob: dc1fc36e0020e135ae164858001bc8a64d6d9208 [file] [log] [blame]
Florin Corase86a8ed2018-01-05 03:20:25 -08001/*
2 *------------------------------------------------------------------
3 * svm_queue.h - shared-memory queues
4 *
5 * Copyright (c) 2009 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
18 */
19
20#ifndef included_svm_queue_h
21#define included_svm_queue_h
22
23#include <pthread.h>
24
25typedef struct _svm_queue
26{
27 pthread_mutex_t mutex; /* 8 bytes */
28 pthread_cond_t condvar; /* 8 bytes */
29 int head;
30 int tail;
31 volatile int cursize;
32 int maxsize;
33 int elsize;
34 int consumer_pid;
35 int signal_when_queue_non_empty;
36 char data[0];
37} svm_queue_t;
38
39svm_queue_t *svm_queue_init (int nels,
40 int elsize,
41 int consumer_pid,
42 int signal_when_queue_non_empty);
43void svm_queue_free (svm_queue_t * q);
44int svm_queue_add (svm_queue_t * q, u8 * elem, int nowait);
45int svm_queue_add2 (svm_queue_t * q, u8 * elem, u8 * elem2, int nowait);
46int svm_queue_sub (svm_queue_t * q, u8 * elem, int nowait);
47int svm_queue_sub2 (svm_queue_t * q, u8 * elem);
48void svm_queue_lock (svm_queue_t * q);
49void svm_queue_unlock (svm_queue_t * q);
50int svm_queue_is_full (svm_queue_t * q);
51int svm_queue_add_nolock (svm_queue_t * q, u8 * elem);
52int svm_queue_sub_raw (svm_queue_t * q, u8 * elem);
53int svm_queue_add_raw (svm_queue_t * q, u8 * elem);
54
55/*
56 * DEPRECATED please use svm_queue_t instead
57 */
58typedef svm_queue_t unix_shared_memory_queue_t;
59
60#endif /* included_svm_queue_h */
61
62/*
63 * fd.io coding-style-patch-verification: ON
64 *
65 * Local Variables:
66 * eval: (c-set-style "gnu")
67 * End:
68 */