rt_benchs/communication_techniques/include/pipe_comm.h

39 lines
549 B
C

#ifndef _SPECIFIC_COMM_H_
#define _SPECIFIC_COMM_H_ 1
#include <unistd.h>
#define READ_IDX 0
#define WRITE_IDX 1
struct channel
{
int pipefd[2];
};
__BEGIN_DECLS
static inline void send(struct channel *channel, void **addr)
{
unsigned int nb_read;
void *addr_ptr;
nb_read = 0;
addr_ptr = &addr;
do
{
int n;
n = write(channel->pipefd[WRITE_IDX], addr_ptr, sizeof(void *) - nb_read);
if (n > 0)
{
nb_read += n;
addr_ptr = (void *) ((uintptr_t) addr_ptr + n);
}
} while (nb_read < sizeof(void *));
}
__END_DECLS
#endif