rb.h
00001
00002
00003
00004
00005 #ifndef _U_RB_H_
00006 #define _U_RB_H_
00007
00008 #include <u/libu_conf.h>
00009
00010
00011
00012 #if defined(HAVE_MMAP) && defined(HAVE_MAP_FIXED) && !defined(RB_INHIBIT_MMAP)
00013 #define U_RB_CAN_MMAP
00014 #endif
00015
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019
00020
00021 struct u_rb_s;
00022
00029 typedef struct u_rb_s u_rb_t;
00030
00032 typedef enum {
00033 U_RB_OPT_NONE = 0x00,
00036 U_RB_OPT_USE_CONTIGUOUS_MEM = 0x01,
00040 U_RB_OPT_IMPL_MALLOC = 0x02,
00043 } u_rb_opts_t;
00044
00045 int u_rb_create (size_t hint_sz, int opts, u_rb_t **prb);
00046 int u_rb_clear (u_rb_t *rb);
00047 void u_rb_free (u_rb_t *rb);
00048 size_t u_rb_size (u_rb_t *rb);
00049
00050 ssize_t u_rb_read (u_rb_t *rb, void *b, size_t b_sz);
00051 void *u_rb_fast_read (u_rb_t *rb, size_t *pb_sz);
00052 ssize_t u_rb_write (u_rb_t *rb, const void *b, size_t b_sz);
00053 size_t u_rb_ready (u_rb_t *rb);
00054 size_t u_rb_avail (u_rb_t *rb);
00055
00060 #ifdef __cplusplus
00061 }
00062 #endif
00063
00064 #endif