31 lines
691 B
C
31 lines
691 B
C
|
#ifndef _SPECIFIC_COMM_H_
|
||
|
#define _SPECIFIC_COMM_H_ 1
|
||
|
|
||
|
/* Non standard include */
|
||
|
#include <commtech.h>
|
||
|
|
||
|
#define SHARED_SPACE_SIZE (2 * BUF_SIZE)
|
||
|
#define SHARED_SPACE_VOIDPTR (SHARED_SPACE_SIZE / sizeof(void *))
|
||
|
|
||
|
struct comm
|
||
|
{
|
||
|
void * volatile *shared_space;
|
||
|
volatile int cons_idx __attribute__ ((aligned (CACHE_LINE_SIZE)));
|
||
|
volatile int prod_idx __attribute__ ((aligned (CACHE_LINE_SIZE)));
|
||
|
};
|
||
|
|
||
|
__BEGIN_DECLS
|
||
|
|
||
|
extern __thread struct comm *comm;
|
||
|
|
||
|
static inline void send(void **addr)
|
||
|
{
|
||
|
while ((comm->prod_idx + 1) % SHARED_SPACE_VOIDPTR == comm->cons_idx);
|
||
|
comm->shared_space[comm->prod_idx] = addr;
|
||
|
comm->prod_idx = (comm->prod_idx + 1) % SHARED_SPACE_VOIDPTR;
|
||
|
}
|
||
|
|
||
|
__END_DECLS
|
||
|
|
||
|
#endif
|