#ifndef _SPECIFIC_COMM_H_ #define _SPECIFIC_COMM_H_ 1 /* Non standard include */ #include #ifndef BUF_SIZE #define BUF_SIZE CACHE_LINE_SIZE #endif #define SHARED_SPACE_SIZE (2 * BUF_SIZE) #define SHARED_SPACE_VOIDPTR (SHARED_SPACE_SIZE / sizeof(void *)) struct channel { void * volatile *shared_space; volatile int cons_idx __attribute__ ((aligned (CACHE_LINE_SIZE))); volatile int prod_idx __attribute__ ((aligned (CACHE_LINE_SIZE))); }; __BEGIN_DECLS static inline void send(struct channel *channel, void **addr) { while ((channel->prod_idx + 1) % SHARED_SPACE_VOIDPTR == channel->cons_idx); channel->shared_space[channel->prod_idx] = addr; channel->prod_idx = (channel->prod_idx + 1) % SHARED_SPACE_VOIDPTR; } __END_DECLS #endif