newlib-cygwin/newlib/libc/reent/execr.c

126 lines
2.2 KiB
C
Raw Normal View History

2000-02-18 03:39:52 +08:00
/* Reentrant versions of execution system calls. These
implementations just call the usual system calls. */
#include <reent.h>
#include <unistd.h>
#include <sys/wait.h>
2000-02-18 03:39:52 +08:00
#include <_syslist.h>
/* Some targets provides their own versions of these functions. Those
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
#ifdef _REENT_ONLY
#ifndef REENTRANT_SYSCALLS_PROVIDED
#define REENTRANT_SYSCALLS_PROVIDED
#endif
#endif
/* If NO_EXEC is defined, we don't need these functions. */
#if defined (REENTRANT_SYSCALLS_PROVIDED) || defined (NO_EXEC)
int _dummy_exec_syscalls = 1;
#else
/* We use the errno variable used by the system dependent layer. */
#undef errno
extern int errno;
/*
FUNCTION
<<_execve_r>>---Reentrant version of execve
INDEX
_execve_r
SYNOPSIS
2000-02-18 03:39:52 +08:00
#include <reent.h>
2008-12-11 Craig Howland <howland@LGSInnovations.com> * libc/include/sys/lock.h: Add void cast to avoid "statement has no effect" warnings from gcc. * libc/include/sys/stdio.h: Ditto. * libc/include/sys/time.h: Correct gettimeofday() prototype. * libc/stdlib/__exp10.c: Add #include "std.h" for function prototype. * libc/stdlib/__ten_mu.c: Ditto. * libc/stdlib/std.h: Correct __exp10's ANSI prototype. * libc/stdlib/ldtoa.c: Change eiisinf definition to ANSI form. (Are already others in file without _ansi method, so did not bother.) * libc/stdlib/system.c: Use _ansi forms for function prototypes and definitions. * libc/time/mktime.c: Ditto. * libc/misc/__dprintf.c: Ditto. * libc/include/stdio.h: Add function prototypes for _fgetc_r, _fgetpos_r, _fsetpos_r, _freopen_r, _rewind_r, freopen64, _freopen64_r, _funopen_r, and _fopencookie_r. * libc/include/reent.h: Add function prototype for _stat64_r, align _execve_r prototype with POSIX definition for execve. * libc/reent/execr.c: Align function prototype with POSIX definition. * libc/stdio/asniprintf.c: Add #include "local.h". * libc/stdio/vasniprintf.c: Ditto. * libc/stdio/fread.c: Remove unused variable newcount. * libc/stdio/local.h: Add function prototype for __sccl. * libc/stdio/open_memstream.c: Remove unused variable flags. * libc/stdio/vfscanf.c: Proper prototyping for ccfn, remove prototype for __sccl since now in local.h. * libc/string/memcpy.c: Add #include <string.h> (for real and for traditional synopsis), remove extraneous stddef.h and limits.h. * libc/syscalls/sysclose.c: Add #include <unistd.h>. * libc/syscalls/sysfork.c: Ditto. * libc/syscalls/sysgetpid.c: Ditto. * libc/syscalls/sysexecve.c: Add #include <unistd.h>, align function prototype with POSIX definition. * libc/syscalls/sysfstat.c: Add #include <sys/stat.h>. * libc/syscalls/sysgettod.c: Correct sys/times.h to sys/time.h. * libc/syscalls/syskill.c: Add #include <signal.h>. * libc/syscalls/syslink.c: Add #include <unistd.h>, fix prototype. * libc/syscalls/sysunlink.c: Ditto. * libc/syscalls/sysstat.c: Add #include <sys/stat.h>, fix prototype. * libc/syscalls/syswait.c: Add #include <sys/wait.h>, fix prototype.
2008-12-12 01:27:56 +08:00
int _execve_r(struct _reent *<[ptr]>, const char *<[name]>,
char *const <[argv]>[], char *const <[env]>[]);
2000-02-18 03:39:52 +08:00
DESCRIPTION
This is a reentrant version of <<execve>>. It
takes a pointer to the global data block, which holds
<<errno>>.
*/
int
_execve_r (struct _reent *ptr,
const char *name,
char *const argv[],
char *const env[])
2000-02-18 03:39:52 +08:00
{
int ret;
errno = 0;
if ((ret = _execve (name, argv, env)) == -1 && errno != 0)
ptr->_errno = errno;
return ret;
}
/*
NEWPAGE
2000-02-18 03:39:52 +08:00
FUNCTION
<<_fork_r>>---Reentrant version of fork
INDEX
_fork_r
SYNOPSIS
2000-02-18 03:39:52 +08:00
#include <reent.h>
int _fork_r(struct _reent *<[ptr]>);
DESCRIPTION
This is a reentrant version of <<fork>>. It
takes a pointer to the global data block, which holds
<<errno>>.
*/
#ifndef NO_FORK
int
_fork_r (struct _reent *ptr)
2000-02-18 03:39:52 +08:00
{
int ret;
errno = 0;
if ((ret = _fork ()) == -1 && errno != 0)
ptr->_errno = errno;
return ret;
}
#endif
/*
NEWPAGE
2000-02-18 03:39:52 +08:00
FUNCTION
<<_wait_r>>---Reentrant version of wait
INDEX
_wait_r
SYNOPSIS
2000-02-18 03:39:52 +08:00
#include <reent.h>
int _wait_r(struct _reent *<[ptr]>, int *<[status]>);
DESCRIPTION
This is a reentrant version of <<wait>>. It
takes a pointer to the global data block, which holds
<<errno>>.
*/
int
_wait_r (struct _reent *ptr,
int *status)
2000-02-18 03:39:52 +08:00
{
int ret;
errno = 0;
if ((ret = _wait (status)) == -1 && errno != 0)
ptr->_errno = errno;
return ret;
}
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */