* syscall.c (cb_syscall) <case CB_SYS_pipe>: New case.

* callback.c [HAVE_LIMITS_H]: Include limits.h.
  	Include libiberty.h.
	(os_close, os_read, os_write, os_fstat, os_ftruncate): Support fd
	being either end of a pipe.
	(os_pipe, os_pipe_empty, os_pipe_nonempty): New functions.
	(os_shutdown): Clear pipe state.
	(default_callback): Initialize new members.
This commit is contained in:
Hans-Peter Nilsson
2005-01-28 03:40:54 +00:00
parent 6a7e5cfe8c
commit 97f669eda9
3 changed files with 278 additions and 1 deletions

View File

@@ -572,6 +572,33 @@ cb_syscall (cb, sc)
}
break;
case CB_SYS_pipe :
{
int p[2];
char *target_p = xcalloc (1, cb->target_sizeof_int * 2);
result = (*cb->pipe) (cb, p);
if (result != 0)
goto ErrorFinish;
cb_store_target_endian (cb, target_p, cb->target_sizeof_int, p[0]);
cb_store_target_endian (cb, target_p + cb->target_sizeof_int,
cb->target_sizeof_int, p[1]);
if ((*sc->write_mem) (cb, sc, sc->arg1, target_p,
cb->target_sizeof_int * 2)
!= cb->target_sizeof_int * 2)
{
/* Close the pipe fd:s. */
(*cb->close) (cb, p[0]);
(*cb->close) (cb, p[1]);
errcode = EFAULT;
result = -1;
}
free (target_p);
}
break;
case CB_SYS_time :
{
/* FIXME: May wish to change CB_SYS_time to something else.