* spu/sbrk.c (sbrk): Adjust the stack pointer vector correctly so
that GCC runtime stack checking works. Handle the backchain, too.
This commit is contained in:
parent
e943a1a37e
commit
538b71077d
@ -1,3 +1,8 @@
|
|||||||
|
2007-03-01 Ben Elliston <bje@au.ibm.com>
|
||||||
|
|
||||||
|
* spu/sbrk.c (sbrk): Adjust the stack pointer vector correctly so
|
||||||
|
that GCC runtime stack checking works. Handle the backchain, too.
|
||||||
|
|
||||||
2007-02-21 Patrick Mansfield <patmans@us.ibm.com>
|
2007-02-21 Patrick Mansfield <patmans@us.ibm.com>
|
||||||
|
|
||||||
* spu/gettimeofday.c: New file which adds SPU gettimeofday.
|
* spu/gettimeofday.c: New file which adds SPU gettimeofday.
|
||||||
|
@ -32,6 +32,7 @@ Author: Andreas Neukoetter (ti95neuk@de.ibm.com)
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <spu_intrinsics.h>
|
||||||
|
|
||||||
extern int errno;
|
extern int errno;
|
||||||
|
|
||||||
@ -44,20 +45,39 @@ sbrk (ptrdiff_t increment)
|
|||||||
{
|
{
|
||||||
static caddr_t heap_ptr = NULL;
|
static caddr_t heap_ptr = NULL;
|
||||||
caddr_t base;
|
caddr_t base;
|
||||||
|
vector unsigned int sp_reg, sp_delta;
|
||||||
|
vector unsigned int *sp_ptr;
|
||||||
|
|
||||||
|
/* The stack pointer register. */
|
||||||
|
volatile register vector unsigned int sp_r1 __asm__("1");
|
||||||
|
|
||||||
if (heap_ptr == NULL)
|
if (heap_ptr == NULL)
|
||||||
{
|
heap_ptr = (caddr_t) & _end;
|
||||||
heap_ptr = (caddr_t) & _end;
|
|
||||||
}
|
|
||||||
if (((RAMSIZE - STACKSIZE) - (int) heap_ptr) >= increment)
|
if (((RAMSIZE - STACKSIZE) - (int) heap_ptr) >= increment)
|
||||||
{
|
{
|
||||||
base = heap_ptr;
|
base = heap_ptr;
|
||||||
heap_ptr += increment;
|
heap_ptr += increment;
|
||||||
return (base);
|
|
||||||
|
sp_delta = (vector unsigned int) spu_insert (increment, spu_splats (0), 1);
|
||||||
|
|
||||||
|
/* Subtract sp_delta from the SP limit (word 1). */
|
||||||
|
sp_r1 = spu_sub (sp_r1, sp_delta);
|
||||||
|
|
||||||
|
/* Fix-up backchain. */
|
||||||
|
sp_ptr = (vector unsigned int *) spu_extract (sp_r1, 0);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
sp_reg = *sp_ptr;
|
||||||
|
*sp_ptr = (vector unsigned int) spu_sub (sp_reg, sp_delta);
|
||||||
|
}
|
||||||
|
while ((sp_ptr = (vector unsigned int *) spu_extract (sp_reg, 0)));
|
||||||
|
|
||||||
|
return (base);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return ((void *) -1);
|
return ((void *) -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user