view sys.c @ 66:f27a6af6514c

SchedRegister, game_task.h etc...
author tkaito
date Thu, 17 Feb 2011 10:56:56 +0900
parents b97628fca317
children
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libxml/parser.h>
#include "object.h"
#include "sys.h"

#define ALIGN_16BYTE 16

int malloc_align16(void *free, void *aligned, int size)
{
  char *index;
  unsigned long *f=(unsigned long *)free,*a=(unsigned long *)aligned;

  if (free == NULL || aligned == NULL || size <= 0) return(-1);

  index = (char *)malloc(size + ALIGN_16BYTE);
  if (index == NULL)
    {
      return(-1);
    }

  *f = *a = (unsigned long)index;
  if (((unsigned long)index % ALIGN_16BYTE) != 0)
    {
      index += ALIGN_16BYTE - ((unsigned long)index % ALIGN_16BYTE);
      *a = (unsigned long)index;
    }
  return(0);
}