2001-11-12 Hans-Peter Nilsson <hp@bitrange.com>
* libc/include/machine/ieeefp.h: Add support for mmix target.
* libc/include/machine/setjmp.h: Ditto.
* configure.host: Ditto.
* libc/sys/mmixware/Makefile.am, libc/sys/mmixware/_exit.c,
libc/sys/mmixware/access.c, libc/sys/mmixware/aclocal.m4,
libc/sys/mmixware/chmod.c, libc/sys/mmixware/chown.c,
libc/sys/mmixware/close.c, libc/sys/mmixware/configure.in,
libc/sys/mmixware/creat.c, libc/sys/mmixware/crt0.c,
libc/sys/mmixware/execv.c, libc/sys/mmixware/execve.c,
libc/sys/mmixware/fork.c, libc/sys/mmixware/fstat.c,
libc/sys/mmixware/getpid.c, libc/sys/mmixware/gettime.c,
libc/sys/mmixware/isatty.c, libc/sys/mmixware/kill.c,
libc/sys/mmixware/lseek.c, libc/sys/mmixware/open.c,
libc/sys/mmixware/pipe.c, libc/sys/mmixware/read.c,
libc/sys/mmixware/sbrk.c, libc/sys/mmixware/setjmp.S,
libc/sys/mmixware/stat.c, libc/sys/mmixware/sys/syscall.h,
libc/sys/mmixware/time.c, libc/sys/mmixware/times.c,
libc/sys/mmixware/unlink.c, libc/sys/mmixware/utime.c,
libc/sys/mmixware/wait.c, libc/sys/mmixware/write.c: New files.
* libc/sys/mmixware/configure, libc/sys/mmixware/Makefile.in,
libc/sys/mmixware/aclocal.m4: Generate.
2001-11-13 05:04:41 +08:00
|
|
|
/* sbrk for MMIXware.
|
|
|
|
|
2012-10-21 11:41:42 +08:00
|
|
|
Copyright (C) 2001, 2012 Hans-Peter Nilsson
|
2001-11-19 07:47:59 +08:00
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this software is
|
|
|
|
freely granted, provided that the above copyright notice, this notice
|
|
|
|
and the following disclaimer are preserved with no changes.
|
|
|
|
|
2001-11-12 Hans-Peter Nilsson <hp@bitrange.com>
* libc/include/machine/ieeefp.h: Add support for mmix target.
* libc/include/machine/setjmp.h: Ditto.
* configure.host: Ditto.
* libc/sys/mmixware/Makefile.am, libc/sys/mmixware/_exit.c,
libc/sys/mmixware/access.c, libc/sys/mmixware/aclocal.m4,
libc/sys/mmixware/chmod.c, libc/sys/mmixware/chown.c,
libc/sys/mmixware/close.c, libc/sys/mmixware/configure.in,
libc/sys/mmixware/creat.c, libc/sys/mmixware/crt0.c,
libc/sys/mmixware/execv.c, libc/sys/mmixware/execve.c,
libc/sys/mmixware/fork.c, libc/sys/mmixware/fstat.c,
libc/sys/mmixware/getpid.c, libc/sys/mmixware/gettime.c,
libc/sys/mmixware/isatty.c, libc/sys/mmixware/kill.c,
libc/sys/mmixware/lseek.c, libc/sys/mmixware/open.c,
libc/sys/mmixware/pipe.c, libc/sys/mmixware/read.c,
libc/sys/mmixware/sbrk.c, libc/sys/mmixware/setjmp.S,
libc/sys/mmixware/stat.c, libc/sys/mmixware/sys/syscall.h,
libc/sys/mmixware/time.c, libc/sys/mmixware/times.c,
libc/sys/mmixware/unlink.c, libc/sys/mmixware/utime.c,
libc/sys/mmixware/wait.c, libc/sys/mmixware/write.c: New files.
* libc/sys/mmixware/configure, libc/sys/mmixware/Makefile.in,
libc/sys/mmixware/aclocal.m4: Generate.
2001-11-13 05:04:41 +08:00
|
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
|
|
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. */
|
|
|
|
|
|
|
|
#include <_ansi.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include "sys/syscall.h"
|
|
|
|
|
|
|
|
extern char *_Sbrk_high;
|
|
|
|
|
|
|
|
/* When the program is loaded, the first location in Pool_Segment holds
|
|
|
|
the first available octabyte in the memory pool (a.k.a. the heap);
|
|
|
|
somewhere after the command-line parameters. We don't have to
|
|
|
|
initialize that location, we can just use it straight up as a pointer;
|
|
|
|
just point the symbol there.
|
|
|
|
|
|
|
|
This file will be compiled with -no-builtin-syms, so we need to define
|
|
|
|
Pool_Segment and any other symbols that would be predefined in mmixal. */
|
|
|
|
|
|
|
|
__asm__ (" .global _Sbrk_high\n"
|
2001-11-13 10:49:12 +08:00
|
|
|
"_Sbrk_high IS Pool_Segment\n"
|
|
|
|
"Pool_Segment IS 0x40<<56");
|
2001-11-12 Hans-Peter Nilsson <hp@bitrange.com>
* libc/include/machine/ieeefp.h: Add support for mmix target.
* libc/include/machine/setjmp.h: Ditto.
* configure.host: Ditto.
* libc/sys/mmixware/Makefile.am, libc/sys/mmixware/_exit.c,
libc/sys/mmixware/access.c, libc/sys/mmixware/aclocal.m4,
libc/sys/mmixware/chmod.c, libc/sys/mmixware/chown.c,
libc/sys/mmixware/close.c, libc/sys/mmixware/configure.in,
libc/sys/mmixware/creat.c, libc/sys/mmixware/crt0.c,
libc/sys/mmixware/execv.c, libc/sys/mmixware/execve.c,
libc/sys/mmixware/fork.c, libc/sys/mmixware/fstat.c,
libc/sys/mmixware/getpid.c, libc/sys/mmixware/gettime.c,
libc/sys/mmixware/isatty.c, libc/sys/mmixware/kill.c,
libc/sys/mmixware/lseek.c, libc/sys/mmixware/open.c,
libc/sys/mmixware/pipe.c, libc/sys/mmixware/read.c,
libc/sys/mmixware/sbrk.c, libc/sys/mmixware/setjmp.S,
libc/sys/mmixware/stat.c, libc/sys/mmixware/sys/syscall.h,
libc/sys/mmixware/time.c, libc/sys/mmixware/times.c,
libc/sys/mmixware/unlink.c, libc/sys/mmixware/utime.c,
libc/sys/mmixware/wait.c, libc/sys/mmixware/write.c: New files.
* libc/sys/mmixware/configure, libc/sys/mmixware/Makefile.in,
libc/sys/mmixware/aclocal.m4: Generate.
2001-11-13 05:04:41 +08:00
|
|
|
|
|
|
|
caddr_t
|
|
|
|
_sbrk (size_t incr)
|
|
|
|
{
|
|
|
|
char *prev_heap_end;
|
|
|
|
|
|
|
|
prev_heap_end = _Sbrk_high;
|
2012-10-21 11:41:42 +08:00
|
|
|
|
|
|
|
/* A simulator that requires explicit memory allocation is expected
|
|
|
|
to hook that to the PRELD data prefetch insn, which is otherwise
|
|
|
|
typically a nop. */
|
|
|
|
if ((long) incr > 0)
|
|
|
|
{
|
|
|
|
size_t n = incr;
|
|
|
|
char *p = prev_heap_end;
|
|
|
|
#define A(N) __asm__ ("preld " #N ",%0,0" : : "r" (p))
|
|
|
|
#define PRELDOWNTO(N) while (n >= N + 1) { A(N); n -= N + 1; p += N + 1; }
|
|
|
|
|
|
|
|
PRELDOWNTO (255);
|
|
|
|
PRELDOWNTO (31);
|
|
|
|
PRELDOWNTO (3);
|
|
|
|
PRELDOWNTO (0);
|
|
|
|
}
|
|
|
|
|
2001-11-12 Hans-Peter Nilsson <hp@bitrange.com>
* libc/include/machine/ieeefp.h: Add support for mmix target.
* libc/include/machine/setjmp.h: Ditto.
* configure.host: Ditto.
* libc/sys/mmixware/Makefile.am, libc/sys/mmixware/_exit.c,
libc/sys/mmixware/access.c, libc/sys/mmixware/aclocal.m4,
libc/sys/mmixware/chmod.c, libc/sys/mmixware/chown.c,
libc/sys/mmixware/close.c, libc/sys/mmixware/configure.in,
libc/sys/mmixware/creat.c, libc/sys/mmixware/crt0.c,
libc/sys/mmixware/execv.c, libc/sys/mmixware/execve.c,
libc/sys/mmixware/fork.c, libc/sys/mmixware/fstat.c,
libc/sys/mmixware/getpid.c, libc/sys/mmixware/gettime.c,
libc/sys/mmixware/isatty.c, libc/sys/mmixware/kill.c,
libc/sys/mmixware/lseek.c, libc/sys/mmixware/open.c,
libc/sys/mmixware/pipe.c, libc/sys/mmixware/read.c,
libc/sys/mmixware/sbrk.c, libc/sys/mmixware/setjmp.S,
libc/sys/mmixware/stat.c, libc/sys/mmixware/sys/syscall.h,
libc/sys/mmixware/time.c, libc/sys/mmixware/times.c,
libc/sys/mmixware/unlink.c, libc/sys/mmixware/utime.c,
libc/sys/mmixware/wait.c, libc/sys/mmixware/write.c: New files.
* libc/sys/mmixware/configure, libc/sys/mmixware/Makefile.in,
libc/sys/mmixware/aclocal.m4: Generate.
2001-11-13 05:04:41 +08:00
|
|
|
_Sbrk_high += incr;
|
|
|
|
return (caddr_t) prev_heap_end;
|
|
|
|
}
|