rt_benchs/communication_techniques/include/pipe_comm.h

39 lines
549 B
C
Raw Normal View History

#ifndef _SPECIFIC_COMM_H_
#define _SPECIFIC_COMM_H_ 1
#include <unistd.h>
#define READ_IDX 0
#define WRITE_IDX 1
struct channel
{
2010-09-22 18:15:57 +02:00
int pipefd[2];
};
__BEGIN_DECLS
static inline void send(struct channel *channel, void **addr)
2010-09-22 18:15:57 +02:00
{
2011-05-10 13:43:55 +02:00
unsigned int nb_read;
2010-09-22 18:15:57 +02:00
void *addr_ptr;
nb_read = 0;
addr_ptr = &addr;
do
{
int n;
n = write(channel->pipefd[WRITE_IDX], addr_ptr, sizeof(void *) - nb_read);
2010-09-22 18:15:57 +02:00
if (n > 0)
{
nb_read += n;
addr_ptr = (void *) ((uintptr_t) addr_ptr + n);
}
} while (nb_read < sizeof(void *));
}
__END_DECLS
#endif