view ppe/Sys.cc @ 0:68a98d68d62a

commit
author yutaka@localhost.localdomain
date Sun, 28 Mar 2010 19:47:00 +0900
parents
children dcd83cefb980
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include "Sys.h"

int
size_fix(int size, int fix)
{

  //16の倍数にする
  size = ((size + fix -1) / fix)*fix;
  
  return size;

}

void*
allocate(int size)
{

  int alignment = 16;
  size = size_fix(size, alignment);

  void *buff;
  posix_memalign(&buff, alignment, size);
  return buff;

}

send_params_t
task_allocate(int size)
{

  if (size % 16) {
    printf("allocate size is not multiple of 16\n");
  }

  char *buff;
  int alignment = 16;
  send_params_t send_params;

  void *head;
  posix_memalign(&head, alignment, size);

  buff = (char*)head;
  buff = buff + sizeof(send_params_head_t);

  send_params.head = (send_params_head_t*)head;
  send_params.buff = buff;

  return send_params;

}