POK
buffer.h
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Thu Jan 15 23:34:13 2009
15  */
16 
17 
18 #ifndef __POK_USER_BUFFER_H__
19 #define __POK_USER_BUFFER_H__
20 
21 #ifdef POK_NEEDS_MIDDLEWARE
22 #ifdef POK_NEEDS_BUFFERS
23 
24 #define POK_BUFFER_DISCIPLINE_FIFO 1
25 #define POK_BUFFER_DISCIPLINE_PRIORITY 2
26 
27 #include <types.h>
28 #include <errno.h>
29 
30 #include <core/lockobj.h>
31 
32 typedef struct
33 {
34  pok_bool_t ready;
35  pok_bool_t empty;
36  pok_bool_t full;
37  pok_size_t size;
38  pok_size_t index;
39  pok_port_size_t off_b;
40  pok_port_size_t off_e;
41  pok_port_size_t msgsize;
42  pok_range_t waiting_processes;
43  pok_queueing_discipline_t discipline;
44  pok_event_id_t lock;
46 
47 typedef struct
48 {
49  pok_range_t nb_messages;
50  pok_range_t max_messages;
51  pok_size_t message_size;
52  pok_range_t waiting_processes;
54 
55 
56 pok_ret_t pok_buffer_create (char* name,
57  const pok_port_size_t size,
58  const pok_port_size_t msg_size,
59  const pok_queueing_discipline_t discipline,
60  pok_buffer_id_t* id);
61 
62 pok_ret_t pok_buffer_receive (const pok_buffer_id_t id,
63  const uint64_t timeout,
64  void* data,
65  pok_port_size_t* len);
66 
67 pok_ret_t pok_buffer_send (const pok_buffer_id_t id,
68  const void* data,
69  const pok_port_size_t len,
70  const uint64_t timeout);
71 
72 pok_ret_t pok_port_buffer_status (const pok_buffer_id_t id,
73  const pok_buffer_status_t* status);
74 
75 pok_ret_t pok_buffer_id (char* name,
76  pok_buffer_id_t* id);
77 
78 #endif
79 #endif
80 
81 #endif