Ignore:
Timestamp:
04/10/14 01:24:05 (8 years ago)
Author:
Richard Sanger <rsangerarj@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
df668eb
Parents:
fb1fd42
Message:

Use size_t rather than int for the data structures. Export vector, deque and ring_buffer for testing and use in programs.
Remove some inlines for now since these result in lots of compile warnings when also exported, the compiler is probably smart enough anyway.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/data-struct/ring_buffer.h

    rd6a56b6 read9478  
    11#include <pthread.h>
    22#include <semaphore.h>
     3#include "../libtrace.h"
    34
    45#ifndef LIBTRACE_RINGBUFFER_H
     
    1112// if LIBTRACE_RINGBUFFER_POLLING is to work.
    1213typedef struct libtrace_ringbuffer {
    13         volatile int start;
    14         int size;
     14        volatile size_t start;
     15        size_t size;
    1516        int mode;
    1617        void *volatile*elements;
     
    2425        sem_t fulls;
    2526        // Aim to get this on a separate cache line to start - important if spinning
    26         volatile int end;
    27        
     27        volatile size_t end;
    2828} libtrace_ringbuffer_t;
    2929
    30 void libtrace_ringbuffer_init(libtrace_ringbuffer_t * rb, int size, int mode);
    31 inline void libtrace_zero_ringbuffer(libtrace_ringbuffer_t * rb);
    32 void libtrace_ringbuffer_destroy(libtrace_ringbuffer_t * rb);
    33 int libtrace_ringbuffer_is_empty(const libtrace_ringbuffer_t * rb);
    34 int libtrace_ringbuffer_is_full(const libtrace_ringbuffer_t * rb);
     30DLLEXPORT void libtrace_ringbuffer_init(libtrace_ringbuffer_t * rb, size_t size, int mode);
     31DLLEXPORT void libtrace_zero_ringbuffer(libtrace_ringbuffer_t * rb);
     32DLLEXPORT void libtrace_ringbuffer_destroy(libtrace_ringbuffer_t * rb);
     33DLLEXPORT int libtrace_ringbuffer_is_empty(const libtrace_ringbuffer_t * rb);
     34DLLEXPORT int libtrace_ringbuffer_is_full(const libtrace_ringbuffer_t * rb);
    3535
    36 void libtrace_ringbuffer_write(libtrace_ringbuffer_t * rb, void* value);
    37 int libtrace_ringbuffer_try_write(libtrace_ringbuffer_t * rb, void* value);
    38 void libtrace_ringbuffer_swrite(libtrace_ringbuffer_t * rb, void* value);
    39 int libtrace_ringbuffer_try_swrite(libtrace_ringbuffer_t * rb, void* value);
    40 int libtrace_ringbuffer_try_swrite_bl(libtrace_ringbuffer_t * rb, void* value);
     36DLLEXPORT void libtrace_ringbuffer_write(libtrace_ringbuffer_t * rb, void* value);
     37DLLEXPORT int libtrace_ringbuffer_try_write(libtrace_ringbuffer_t * rb, void* value);
     38DLLEXPORT void libtrace_ringbuffer_swrite(libtrace_ringbuffer_t * rb, void* value);
     39DLLEXPORT int libtrace_ringbuffer_try_swrite(libtrace_ringbuffer_t * rb, void* value);
     40DLLEXPORT int libtrace_ringbuffer_try_swrite_bl(libtrace_ringbuffer_t * rb, void* value);
    4141
    42 void* libtrace_ringbuffer_read(libtrace_ringbuffer_t *rb) ;
    43 int libtrace_ringbuffer_try_read(libtrace_ringbuffer_t *rb, void ** value);
    44 void * libtrace_ringbuffer_sread(libtrace_ringbuffer_t *rb);
    45 int libtrace_ringbuffer_try_sread(libtrace_ringbuffer_t *rb, void ** value);
    46 int libtrace_ringbuffer_try_sread_bl(libtrace_ringbuffer_t *rb, void ** value);
     42DLLEXPORT void* libtrace_ringbuffer_read(libtrace_ringbuffer_t *rb) ;
     43DLLEXPORT int libtrace_ringbuffer_try_read(libtrace_ringbuffer_t *rb, void ** value);
     44DLLEXPORT void * libtrace_ringbuffer_sread(libtrace_ringbuffer_t *rb);
     45DLLEXPORT int libtrace_ringbuffer_try_sread(libtrace_ringbuffer_t *rb, void ** value);
     46DLLEXPORT int libtrace_ringbuffer_try_sread_bl(libtrace_ringbuffer_t *rb, void ** value);
    4747
    4848#endif
Note: See TracChangeset for help on using the changeset viewer.