libc/unix, reentrant syscalls?
Jeff Johnston
jjohnstn@redhat.com
Sat Nov 5 23:47:00 GMT 2005
Hi Pedro,
A little late in answering this, but yes, you are correct. The only
usage of the non-reentrant _ syscall names should be either in the _r
version-code or else in system-specific code that knows there is no
reentrant version.
A patch has been checked in.
-- Jeff J.
pedro_alves@portugalmail.pt wrote:
> Hi all again,
>
> In the libc/unix dir, all the syscalls are made with the underscored version.
> If newlib is compiled with with reentrancy support, these won't exist.
> Shouldn't they be switched over to the not-underscored ones?
>
> Look at the following (not complete) patch for example:
>
> Index: getpass.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/unix/getpass.c,v
> retrieving revision 1.3
> diff -u -r1.3 getpass.c
> --- getpass.c 9 Dec 2000 01:20:32 -0000 1.3
> +++ getpass.c 27 Oct 2005 23:00:48 -0000
> @@ -90,7 +90,9 @@
> if (p < buf + _PASSWORD_LEN)
> *p++ = ch;
> *p = '\0';
> - (void) _write (fileno (outfp), "\n", 1);
> +/* pedro: what about the reentrant version ?
> + (void) _write (fileno (outfp), "\n", 1); */
> + (void) write (fileno (outfp), "\n", 1);
> if (echo)
> {
> term.c_lflag |= ECHO;
> Index: getut.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/unix/getut.c,v
> retrieving revision 1.3
> diff -u -r1.3 getut.c
> --- getut.c 24 Aug 2000 18:51:09 -0000 1.3
> +++ getut.c 27 Oct 2005 23:00:48 -0000
> @@ -11,20 +11,25 @@
>
> static struct utmp utmp_data;
>
> +/* pedro: removed underscore in syscalls to enable the use of the reentrant
> versions */
> +
> void
> setutent ()
> {
> if (utmp_fd == -2)
> {
> - utmp_fd = _open (utmp_file, O_RDONLY);
> +// utmp_fd = _open (utmp_file, O_RDONLY);
> + utmp_fd = open (utmp_file, O_RDONLY);
> }
> - _lseek (utmp_fd, 0, SEEK_SET);
> +// _lseek (utmp_fd, 0, SEEK_SET);
> + lseek (utmp_fd, 0, SEEK_SET);
> }
>
> void
> endutent ()
> {
> - _close (utmp_fd);
> +// _close (utmp_fd);
> + close (utmp_fd);
> utmp_fd = -2;
> }
>
> @@ -39,7 +44,8 @@
> {
> if (utmp_fd == -2)
> setutent ();
> - if (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) < sizeof (utmp_data))
> +// if (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) < sizeof (utmp_data))
> + if (read (utmp_fd, &utmp_data, sizeof (utmp_data)) < sizeof (utmp_data))
> return 0;
> return &utmp_data;
> }
> @@ -47,7 +53,8 @@
> struct utmp *
> getutid (struct utmp *id)
> {
> - while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
> +// while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
> + while (read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
> {
> switch (id->ut_type)
> {
> @@ -73,7 +80,8 @@
> struct utmp *
> getutline (struct utmp *line)
> {
> - while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
> +// while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
> + while (read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
> {
> if ((utmp_data.ut_type == LOGIN_PROCESS ||
> utmp_data.ut_type == USER_PROCESS) &&
> Index: ttyname.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/unix/ttyname.c,v
> retrieving revision 1.3
> diff -u -r1.3 ttyname.c
> --- ttyname.c 7 Jul 2005 17:29:13 -0000 1.3
> +++ ttyname.c 27 Oct 2005 23:00:48 -0000
> @@ -62,7 +62,8 @@
> return NULL;
>
> /* Must be a character device. */
> - if (_fstat (fd, &sb) || !S_ISCHR (sb.st_mode))
> +/* pedro: if (_fstat (fd, &sb) || !S_ISCHR (sb.st_mode)) */
> + if (fstat (fd, &sb) || !S_ISCHR (sb.st_mode))
> return NULL;
>
> if ((dp = _opendir (_PATH_DEV)) == NULL)
>
>
>
> Cheers,
> Pedro Alves
>
>
> __________________________________________________________
> Email gratuito com 2 000 MB
> Espaço para guardar 1 milhão de mensagens
> http://www.portugalmail.pt/2000mb
More information about the Newlib
mailing list