17 #include <core/dependencies.h>
19 #ifdef POK_NEEDS_MIDDLEWARE
20 #ifdef POK_NEEDS_BUFFERS
24 #include <core/time.h>
25 #include <core/event.h>
26 #include <libc/string.h>
27 #include <middleware/buffer.h>
30 extern char* pok_buffers_names[POK_CONFIG_NB_BUFFERS];
31 pok_size_t pok_buffers_data_index = 0;
34 pok_ret_t pok_buffer_create (
char* name,
35 const pok_port_size_t size,
36 const pok_port_size_t msg_size,
37 const pok_queueing_discipline_t discipline,
43 for (n=0 ; n < POK_CONFIG_NB_BUFFERS ; n++)
45 if (streq (name, pok_buffers_names[n]))
47 if (pok_buffers[n].ready == TRUE)
49 return POK_ERRNO_READY;
52 ret = pok_event_create (&pok_buffers[n].lock);
54 if (ret != POK_ERRNO_OK)
59 pok_buffers[n].index = pok_buffers_data_index;
60 pok_buffers[n].ready = TRUE;
61 pok_buffers[n].empty = TRUE;
62 pok_buffers[n].size = size;
63 pok_buffers[n].msgsize = msg_size;
64 pok_buffers[n].waiting_processes = 0;
65 pok_buffers[n].off_e = 0;
66 pok_buffers[n].off_b = 0;
67 pok_buffers[n].discipline = discipline;
69 pok_buffers_data_index = pok_buffers_data_index + size;
78 return POK_ERRNO_EINVAL;