OpenCores
URL https://opencores.org/ocsvn/plasma/plasma/trunk

Subversion Repositories plasma

[/] [plasma/] [trunk/] [kernel/] [libc.c] - Diff between revs 245 and 249

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 245 Rev 249
Line 110... Line 110...
}
}
 
 
 
 
void *memcpy(void *dst, const void *src, unsigned long bytes)
void *memcpy(void *dst, const void *src, unsigned long bytes)
{
{
   uint8 *Dst = (uint8*)dst;
   if(((uint32)dst | (uint32)src | bytes) & 3)
   uint8 *Src = (uint8*)src;
   {
 
      uint8 *Dst = (uint8*)dst, *Src = (uint8*)src;
   while((int)bytes-- > 0)
   while((int)bytes-- > 0)
      *Dst++ = *Src++;
      *Dst++ = *Src++;
 
   }
 
   else
 
   {
 
      uint32 *Dst32 = (uint32*)dst, *Src32 = (uint32*)src;
 
      bytes >>= 2;
 
      while((int)bytes-- > 0)
 
         *Dst32++ = *Src32++;
 
   }
   return dst;
   return dst;
}
}
 
 
 
 
void *memmove(void *dst, const void *src, unsigned long bytes)
void *memmove(void *dst, const void *src, unsigned long bytes)
Line 450... Line 459...
}
}
#endif //INCLUDE_DUMP
#endif //INCLUDE_DUMP
 
 
 
 
#ifdef INCLUDE_QSORT
#ifdef INCLUDE_QSORT
#define QSORT_SIZE 256
 
/*********************** qsort ***********************/
/*********************** qsort ***********************/
static void QsortSwap(char *base, long left, long right, long size)
static void QsortSwap(char *base, long left, long right, long size)
{
{
   char buffer[QSORT_SIZE];
   int temp, i;
   memcpy(buffer, &base[left*size], size);
   char *ptrLeft, *ptrRight;
   memcpy(&base[left*size], &base[right*size], size);
   ptrLeft = base + left * size;
   memcpy(&base[right*size], buffer, size);
   ptrRight = base + right * size;
 
   for(i = 0; i < size; ++i)
 
   {
 
      temp = ptrLeft[i];
 
      ptrLeft[i] = ptrRight[i];
 
      ptrRight[i] = (char)temp;
 
   }
}
}
 
 
 
 
//Modified from K&R
//Modified from K&R
static void qsort2(void *base, long left, long right, long size,
static void qsort2(void *base, long left, long right, long size,
Line 488... Line 502...
void qsort(void *base,
void qsort(void *base,
           long n,
           long n,
           long size,
           long size,
           int (*cmp)(const void *,const void *))
           int (*cmp)(const void *,const void *))
{
{
   if(size > QSORT_SIZE)
 
   {
 
      printf("qsort_error");
 
      return;
 
   }
 
   qsort2(base, 0, n-1, size, cmp);
   qsort2(base, 0, n-1, size, cmp);
}
}
 
 
 
 
void *bsearch(const void *key,
void *bsearch(const void *key,

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.