#ifndef _SPECIFIC_COMM_H_ #define _SPECIFIC_COMM_H_ 1 /* Non standard include */ #include /* This is not an error, we need this two-macro system */ #define toString(x) doStringification(x) #define doStringification(x) #x struct channel { volatile void *buf[2 * BUF_SIZE / sizeof(void *)] __attribute__ ((aligned (CACHE_LINE_SIZE))); volatile int state __attribute__ ((aligned (CACHE_LINE_SIZE))); int idx __attribute__ ((aligned (CACHE_LINE_SIZE))); }; struct cons { struct channel *channel; int receiver_idx; }; union comm { struct channel *channel; struct cons *cons; }; extern __thread union comm comm; __BEGIN_DECLS static inline void send(void **addr) { comm.channel->buf[comm.channel->idx++] = addr; comm.channel->idx %= 2 * (BUF_SIZE / sizeof(void *)); if (!(comm.channel->idx % (BUF_SIZE / sizeof(void *)))) { while (comm.channel->state); comm.channel->state = 1; } } __END_DECLS #endif