POK
/home/jaouen/pok_official/pok/trunk/libpok/include/middleware/buffer.h
00001 /*
00002  *                               POK header
00003  * 
00004  * The following file is a part of the POK project. Any modification should
00005  * made according to the POK licence. You CANNOT use this file or a part of
00006  * this file is this part of a file for your own project
00007  *
00008  * For more information on the POK licence, please see our LICENCE FILE
00009  *
00010  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
00011  *
00012  *                                      Copyright (c) 2007-2009 POK team 
00013  *
00014  * Created by julien on Thu Jan 15 23:34:13 2009 
00015  */
00016 
00017 
00018 #ifndef __POK_USER_BUFFER_H__
00019 #define __POK_USER_BUFFER_H__
00020 
00021 #ifdef POK_NEEDS_MIDDLEWARE
00022 #ifdef POK_NEEDS_BUFFERS
00023 
00024 #define POK_BUFFER_DISCIPLINE_FIFO 1
00025 #define POK_BUFFER_DISCIPLINE_PRIORITY 2
00026 
00027 #include <types.h>
00028 #include <errno.h>
00029 
00030 #include <core/lockobj.h>
00031 
00032 typedef struct
00033 {
00034    pok_bool_t                 ready;
00035    pok_bool_t                 empty;
00036    pok_bool_t                 full;
00037    pok_size_t                 size;
00038    pok_size_t                 index;
00039    pok_port_size_t            off_b;
00040    pok_port_size_t            off_e;
00041    pok_port_size_t            msgsize;
00042    pok_range_t                waiting_processes;
00043    pok_queueing_discipline_t  discipline;
00044    pok_event_id_t             lock;
00045 }pok_buffer_t;
00046 
00047 typedef struct
00048 {
00049    pok_range_t          nb_messages;
00050    pok_range_t          max_messages;
00051    pok_size_t           message_size;
00052    pok_range_t          waiting_processes;
00053 }pok_buffer_status_t;
00054 
00055 
00056 pok_ret_t pok_buffer_create (char*                                 name, 
00057                              const pok_port_size_t                 size, 
00058                              const pok_port_size_t                 msg_size, 
00059                              const pok_queueing_discipline_t       discipline,
00060                              pok_buffer_id_t*                      id);
00061 
00062 pok_ret_t pok_buffer_receive (const pok_buffer_id_t                id, 
00063                               const uint64_t                       timeout, 
00064                               void*                                data, 
00065                               pok_port_size_t*                     len);
00066 
00067 pok_ret_t pok_buffer_send (const pok_buffer_id_t              id, 
00068                            const void*                        data, 
00069                            const pok_port_size_t              len, 
00070                            const uint64_t                     timeout);
00071 
00072 pok_ret_t pok_port_buffer_status (const pok_buffer_id_t            id,
00073                                   const pok_buffer_status_t*       status);
00074 
00075 pok_ret_t pok_buffer_id (char*                                     name,
00076                          pok_buffer_id_t*                          id);
00077 
00078 #endif
00079 #endif
00080 
00081 #endif