[PATCH] supplying _foo_r functions when -DREENTRANT_SYSCALLS_PROVIDED
Jeff Johnston
jjohnstn@redhat.com
Fri Mar 28 00:33:00 GMT 2008
Thanks Patrick. I modified it slightly to add documentation regarding
manual reentrancy
management vs dynamic reentrancy. As well, I removed the bit about
setting on
REENTRANT_SYSCALLS_PROVIDED when _REENT_ONLY.
The _REENT_ONLY flag is used when manual reentrancy management is
required. It
forces use of _r routines instead of their regular counterparts. In
libc/reent, it implies that
the _r syscalls must exist.
Modified patch checked in.
-- Jeff J.
Patrick Mansfield wrote:
> Jeff -
>
> Here's a patch per your comments, except I didn't document the
> __DYNAMIC_REENT__ as I don't understand its usage.
>
> If this is close enough, please modify it as you see fit.
>
> Thanks ...
>
> newlib ChangeLog:
>
> 2008-03-27 Patrick Mansfield <patmans@us.ibm.com>
>
> * libc/include/reent.h: Define _func_r functions in this file to
> func if REENTRANT_SYSCALLS_PROVIDED and MISSING_SYSCALL_NAMES are
> defined.
>
> Index: quilt/newlib/libc/include/reent.h
> ===================================================================
> --- quilt.orig/newlib/libc/include/reent.h
> +++ quilt/newlib/libc/include/reent.h
> @@ -10,7 +10,7 @@
> be declared here. It documents them all in one place. All library access
> to the system is via some form of these functions.
>
> - There are three ways a target may provide the needed syscalls.
> + The target may provide the needed syscalls by any of the following:
>
> 1) Define the reentrant versions of the syscalls directly.
> (eg: _open_r, _close_r, etc.). Please keep the namespace clean.
> @@ -29,6 +29,13 @@
> When you do this, add -DMISSING_SYSCALL_NAMES to newlib_cflags in
> configure.host.
>
> + 4) Define or otherwise provide the regular versions of the syscalls,
> + and do not supply functional interfaces for any of the reentrant
> + calls. With this method, the reentrant versions are defined to
> + directly call the system call.
> + Add -DREENTRANT_SYSCALLS_PROVIDED and -DMISSING_SYSCALL_NAMES to
> + newlib_cflags in configure.host.
> +
> Stubs of the reentrant versions of the syscalls exist in the libc/reent
> source directory and are used if REENTRANT_SYSCALLS_PROVIDED isn't defined.
> They use the native system calls: _open, _close, etc. if they're available
> @@ -59,6 +66,41 @@ struct tms;
> struct timeval;
> struct timezone;
>
> +#ifdef _REENT_ONLY
> +#ifndef REENTRANT_SYSCALLS_PROVIDED
> +#define REENTRANT_SYSCALLS_PROVIDED
> +#endif
> +#endif
> +
> +#if defined(REENTRANT_SYSCALLS_PROVIDED) && defined(MISSING_SYSCALL_NAMES)
> +
> +#define _close_r(__reent, __fd) close(__fd)
> +#define _execve_r(__reent, __f, __arg, __env) execve(__f, __arg, __env)
> +#define _fcntl_r(__reent, __fd, __cmd, __arg) fcntl(__fd, __cmd, __arg)
> +#define _fork_r(__reent) fork()
> +#define _fstat_r(__reent, __fdes, __stat) fstat(__fdes, __stat)
> +#define _getpid_r(__reent) getpid()
> +#define _isatty_r(__reent, __desc) isatty(__desc)
> +#define _kill_r(__reent, __pid, __signal) kill(__pid, __signal)
> +#define _link_r(__reent, __oldpath, __newpath) link(__oldpath, __newpath)
> +#define _lseek_r(__reent, __fdes, __off, __w) lseek(__fdes, __off, __w)
> +#define _open_r(__reent, __path, __flag, __m) open(__path, __flag, __m)
> +#define _read_r(__reent, __fd, __buff, __cnt) read(__fd, __buff, __cnt)
> +#define _sbrk_r(__reent, __incr) sbrk(__incr)
> +#define _stat_r(__reent, __path, __buff) stat(__path, __buff)
> +#define _times_r(__reent, __time) times(__time)
> +#define _unlink_r(__reent, __path) unlink(__path)
> +#define _wait_r(__reent, __status) wait(__status)
> +#define _write_r(__reent, __fd, __buff, __cnt) write(__fd, __buff, __cnt)
> +#define _gettimeofday_r(__reent, __tp, __tzp) gettimeofday(__tp, __tzp)
> +
> +#ifdef __LARGE64_FILES
> +#define _lseek64_r(__reent, __fd, __off, __w) lseek64(__fd, __off, __w)
> +#define _fstat64_r(__reent, __fd, __buff) fstat64(__fd, __buff)
> +#define _open64_r(__reent, __path, __flag, __m) open64(__path, __flag, __m)
> +#endif
> +
> +#else
> /* Reentrant versions of system calls. */
>
> extern int _close_r _PARAMS ((struct _reent *, int));
> @@ -96,6 +138,8 @@ extern int _fstat64_r _PARAMS ((struct _
> extern int _open64_r _PARAMS ((struct _reent *, const char *, int, int));
> #endif
>
> +#endif
> +
> #ifdef __cplusplus
> }
> #endif
>
More information about the Newlib
mailing list