2007-07-12 Daniel Jacobowitz <dan@codesourcery.com>
* arm/syscalls.c (_stat): Use _close
* arm/syscalls.c (struct poslog): Rename to...
(struct fdent): ... this.
(FILE_HANDLE_OFFSET): Remove.
(findslot): Return a struct fdent* if fd is valid, otherwise return NULL.
(newslot): New function.
(remap_handle): Remove.
(initialise_monitor_handles): Use stdout as fallback for stderr.
(wrap): Rename to...
(checkerror): ... this.
(_swiread): Use checkerror() for the return of SWI calls. Correct the use of r0.
(_read): Use findslot(). Return EBADF on bad handle.
(_swilseek): Call findslot(). Check for valid whence. Check for negative offset when using
SEEK_CUR, and check for overflow. Use checkerror(). Check *_Flen calls for errors.
(_swiwrite): Correct the use of r0.
(_write): Call findslot().
(_swiopen): Call findslot(). Check for valid flags. Use checkerror(). Call newslot().
Handle O_TRUNC, and O_WRONLY. Return index into openfiles[] for fd.
(_swiclose): Correct the use of r0.
(_close): Handle stderr == stdout case. Only reclaim handle if _swiclose succeeded.
(_getpid): Use __attribute__((unused)).
(_sbrk): Fix formatting.
(_swistat): New function.
(_stat): Call _swistat().
(_fstat): Call _swistat().
(_unlink): Correct the use of r0.
(isatty): Call finslot(). Correct the use of r0.
(_system): Call checkerror(). Correct the use of r0.
(_rename): Correct the use of r0.
* libgloss/arm/syscalls.c (_exit): Call _kill with the second
argument set to -1, which is an invalid signal number.
(_kill): Comment and coding style changes only.
(_raise): Remove function.
* arm/crt0.S: Copied from newlib and it now also sets up stacks for
FIQ and IRQ mode, plus calls hardware_init_hook() and
software_init_hook() if present.
* arm/libcfunc.c, arm/swi.h, arm/syscalls.c: Copied
from newlib.
* arm/Makefile.in: Build crt0.o, rdpmon-crt0.o, rdimon-crt0.o,
librdpmon.a, librdimon.a - support file for "bare" setup, as well
as "RDP" and "RDI" monitors.
* arm/coff-rdpmon.specs, arm/elf-rdpmon.specs,
arm/coff-rdimon.specs, arm/elf-rdimon.specs: gcc specs files to go
with above mentioned support libs and startfiles.