コード例 #1
0
ファイル: shmem_pipe_thr.c プロジェクト: jopu-enea/ipc-bench
static struct iovec*
get_write_buffer(test_data* td, int message_size, int* n_vecs)
{
  struct shmem_pipe *sp = td->data;
  unsigned long offset;

  while ((offset = alloc_shared_space(sp, message_size)) == ALLOC_FAILED)
    wait_for_returned_buffers(sp);

  sp->iov.iov_base = sp->ring + offset;
  sp->iov.iov_len = message_size;

  *n_vecs = 1;
  return &sp->iov;
}
コード例 #2
0
struct fable_buf* fable_get_write_buf_shmem_pipe(void* handle, unsigned len)
{
  struct shmem_pipe_handle_conn *sp = (struct shmem_pipe_handle_conn*)handle;
  unsigned long offset;
  unsigned allocated_len = len;

  while ((offset = alloc_shared_space(sp, &allocated_len)) == ALLOC_FAILED) {
    int wait_ret = wait_for_returned_buffers(sp);
    if(wait_ret == 0)
      errno = 0;
    if(wait_ret <= 0)
      return 0;
  }

  struct shmem_pipe_buf* buf = (struct shmem_pipe_buf*)malloc(sizeof(struct shmem_pipe_buf));

  buf->iov.iov_base = ((char*)sp->ring) + offset;
  buf->iov.iov_len = allocated_len;
  buf->base.bufs = &buf->iov;
  buf->base.nbufs = 1;

  return &buf->base;
}