diff options
Diffstat (limited to 'newlib/libc/unix')
-rw-r--r-- | newlib/libc/unix/Makefile.am | 41 | ||||
-rw-r--r-- | newlib/libc/unix/Makefile.in | 64 | ||||
-rw-r--r-- | newlib/libc/unix/basename.c | 25 | ||||
-rw-r--r-- | newlib/libc/unix/dirname.c | 28 | ||||
-rw-r--r-- | newlib/libc/unix/getcwd.c | 10 | ||||
-rw-r--r-- | newlib/libc/unix/getlogin.c | 8 | ||||
-rw-r--r-- | newlib/libc/unix/getpass.c | 2 | ||||
-rw-r--r-- | newlib/libc/unix/getut.c | 12 | ||||
-rw-r--r-- | newlib/libc/unix/pread.c | 91 | ||||
-rw-r--r-- | newlib/libc/unix/pwrite.c | 92 | ||||
-rw-r--r-- | newlib/libc/unix/sigset.c | 2 | ||||
-rw-r--r-- | newlib/libc/unix/ttyname.c | 16 |
12 files changed, 46 insertions, 345 deletions
diff --git a/newlib/libc/unix/Makefile.am b/newlib/libc/unix/Makefile.am index 6ecee1397..5159c0ed0 100644 --- a/newlib/libc/unix/Makefile.am +++ b/newlib/libc/unix/Makefile.am @@ -4,51 +4,18 @@ AUTOMAKE_OPTIONS = cygnus INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) -GENERAL_SOURCES = \ - getcwd.c \ - pread.c \ - pwrite.c \ - sigset.c - -## Distinguish different EL/IX level interfaces -ELIX_2_OBJS = \ - ttyname.$(oext) - -ELIX_4_OBJS = \ - basename.$(oext) \ - dirname.$(oext) \ - getlogin.$(oext) \ - getpass.$(oext) \ - getpwent.$(oext) \ - getut.$(oext) - -if ELIX_LEVEL_1 -LIB_OBJS = -else -if ELIX_LEVEL_2 -LIB_OBJS = $(ELIX_2_OBJS) -else -if ELIX_LEVEL_3 -LIB_OBJS = $(ELIX_2_OBJS) -else -LIB_OBJS = $(ELIX_2_OBJS) $(ELIX_4_OBJS) -endif -endif -endif +LIB_SOURCES = \ + getpass.c sigset.c getpwent.c ttyname.c getut.c getlogin.c getcwd.c libunix_la_LDFLAGS = -Xcompiler -nostdlib if USE_LIBTOOL noinst_LTLIBRARIES = libunix.la -libunix_la_SOURCES = $(GENERAL_SOURCES) -libunix_la_LIBADD = $(LIB_OBJS) -libunix_la_DEPENDENCIES = $(LIB_OBJS) +libunix_la_SOURCES = $(LIB_SOURCES) noinst_DATA = objectlist.awk.in else noinst_LIBRARIES = lib.a -lib_a_SOURCES = $(GENERAL_SOURCES) -lib_a_LIBADD = $(LIB_OBJS) -lib_a_DEPENDENCIES = $(LIB_OBJS) +lib_a_SOURCES = $(LIB_SOURCES) noinst_DATA = endif # USE_LIBTOOL diff --git a/newlib/libc/unix/Makefile.in b/newlib/libc/unix/Makefile.in index 7d049ce14..3982018a7 100644 --- a/newlib/libc/unix/Makefile.in +++ b/newlib/libc/unix/Makefile.in @@ -1,6 +1,6 @@ -# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am +# Makefile.in generated automatically by automake 1.4 from Makefile.am -# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -58,32 +58,20 @@ POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : -build_alias = @build_alias@ -build_triplet = @build@ host_alias = @host_alias@ host_triplet = @host@ -target_alias = @target_alias@ -target_triplet = @target@ AR = @AR@ AS = @AS@ CC = @CC@ CPP = @CPP@ CRT0 = @CRT0@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ DLLTOOL = @DLLTOOL@ EXEEXT = @EXEEXT@ -GCJ = @GCJ@ -GCJFLAGS = @GCJFLAGS@ LDFLAGS = @LDFLAGS@ -LIBC_EXTRA_DEF = @LIBC_EXTRA_DEF@ -LIBC_EXTRA_LIB = @LIBC_EXTRA_LIB@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ -LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ -LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ @@ -93,13 +81,10 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ NEWLIB_CFLAGS = @NEWLIB_CFLAGS@ OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ -STRIP = @STRIP@ VERSION = @VERSION@ aext = @aext@ -extra_dir = @extra_dir@ libm_machine_dir = @libm_machine_dir@ machine_dir = @machine_dir@ newlib_basedir = @newlib_basedir@ @@ -110,31 +95,18 @@ AUTOMAKE_OPTIONS = cygnus INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) -GENERAL_SOURCES = getcwd.c pread.c pwrite.c sigset.c +LIB_SOURCES = \ + getpass.c sigset.c getpwent.c ttyname.c getut.c getlogin.c getcwd.c -ELIX_2_OBJS = ttyname.$(oext) - - -ELIX_4_OBJS = basename.$(oext) dirname.$(oext) getlogin.$(oext) getpass.$(oext) getpwent.$(oext) getut.$(oext) - -@ELIX_LEVEL_1_TRUE@LIB_OBJS = -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@LIB_OBJS = $(ELIX_2_OBJS) -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@LIB_OBJS = $(ELIX_2_OBJS) -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@LIB_OBJS = $(ELIX_2_OBJS) $(ELIX_4_OBJS) - libunix_la_LDFLAGS = -Xcompiler -nostdlib -@USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libunix.la -@USE_LIBTOOL_TRUE@libunix_la_SOURCES = $(GENERAL_SOURCES) -@USE_LIBTOOL_TRUE@libunix_la_LIBADD = $(LIB_OBJS) -@USE_LIBTOOL_TRUE@libunix_la_DEPENDENCIES = $(LIB_OBJS) -@USE_LIBTOOL_TRUE@noinst_DATA = objectlist.awk.in +@USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = @USE_LIBTOOL_TRUE@libunix.la +@USE_LIBTOOL_TRUE@libunix_la_SOURCES = @USE_LIBTOOL_TRUE@$(LIB_SOURCES) +@USE_LIBTOOL_TRUE@noinst_DATA = @USE_LIBTOOL_TRUE@objectlist.awk.in @USE_LIBTOOL_FALSE@noinst_DATA = -@USE_LIBTOOL_FALSE@noinst_LIBRARIES = lib.a -@USE_LIBTOOL_FALSE@lib_a_SOURCES = $(GENERAL_SOURCES) -@USE_LIBTOOL_FALSE@lib_a_LIBADD = $(LIB_OBJS) -@USE_LIBTOOL_FALSE@lib_a_DEPENDENCIES = $(LIB_OBJS) +@USE_LIBTOOL_FALSE@noinst_LIBRARIES = @USE_LIBTOOL_FALSE@lib.a +@USE_LIBTOOL_FALSE@lib_a_SOURCES = @USE_LIBTOOL_FALSE@$(LIB_SOURCES) CHEWOUT_FILES = @@ -153,12 +125,14 @@ LIBRARIES = $(noinst_LIBRARIES) DEFS = @DEFS@ -I. -I$(srcdir) CPPFLAGS = @CPPFLAGS@ LIBS = @LIBS@ -@USE_LIBTOOL_FALSE@lib_a_OBJECTS = getcwd.$(OBJEXT) pread.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@pwrite.$(OBJEXT) sigset.$(OBJEXT) +lib_a_LIBADD = +@USE_LIBTOOL_FALSE@lib_a_OBJECTS = getpass.o sigset.o getpwent.o \ +@USE_LIBTOOL_FALSE@ttyname.o getut.o getlogin.o getcwd.o LTLIBRARIES = $(noinst_LTLIBRARIES) -@USE_LIBTOOL_TRUE@libunix_la_OBJECTS = getcwd.lo pread.lo pwrite.lo \ -@USE_LIBTOOL_TRUE@sigset.lo +libunix_la_LIBADD = +@USE_LIBTOOL_TRUE@libunix_la_OBJECTS = getpass.lo sigset.lo getpwent.lo \ +@USE_LIBTOOL_TRUE@ttyname.lo getut.lo getlogin.lo getcwd.lo CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -178,7 +152,7 @@ OBJECTS = $(lib_a_OBJECTS) $(libunix_la_OBJECTS) all: all-redirect .SUFFIXES: -.SUFFIXES: .S .c .def .lo .o .obj .s +.SUFFIXES: .S .c .def .lo .o .s $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) $(srcdir)/../../Makefile.shared cd $(top_srcdir) && $(AUTOMAKE) --cygnus unix/Makefile @@ -199,11 +173,6 @@ maintainer-clean-noinstLIBRARIES: .c.o: $(COMPILE) -c $< -# FIXME: We should only use cygpath when building on Windows, -# and only if it is available. -.c.obj: - $(COMPILE) -c `cygpath -w $<` - .s.o: $(COMPILE) -c $< @@ -212,7 +181,6 @@ maintainer-clean-noinstLIBRARIES: mostlyclean-compile: -rm -f *.o core *.core - -rm -f *.$(OBJEXT) clean-compile: diff --git a/newlib/libc/unix/basename.c b/newlib/libc/unix/basename.c deleted file mode 100644 index 703e532d5..000000000 --- a/newlib/libc/unix/basename.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2005 Shaun Jackman - * Permission to use, copy, modify, and distribute this software - * is freely granted, provided that this notice is preserved. - */ - -#include <libgen.h> -#include <string.h> - -char* -_DEFUN (basename, (path), - char *path) -{ - char *p; - if( path == NULL || *path == '\0' ) - return "."; - p = path + strlen(path) - 1; - while( *p == '/' ) { - if( p == path ) - return path; - *p-- = '\0'; - } - while( p >= path && *p != '/' ) - p--; - return p + 1; -} diff --git a/newlib/libc/unix/dirname.c b/newlib/libc/unix/dirname.c deleted file mode 100644 index f026e3056..000000000 --- a/newlib/libc/unix/dirname.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2005 Shaun Jackman - * Permission to use, copy, modify, and distribute this software - * is freely granted, provided that this notice is preserved. - */ - -#include <libgen.h> -#include <string.h> - -char * -_DEFUN (dirname, (path), - char *path) -{ - char *p; - if( path == NULL || *path == '\0' ) - return "."; - p = path + strlen(path) - 1; - while( *p == '/' ) { - if( p == path ) - return path; - *p-- = '\0'; - } - while( p >= path && *p != '/' ) - p--; - return - p < path ? "." : - p == path ? "/" : - (*p = '\0', path); -} diff --git a/newlib/libc/unix/getcwd.c b/newlib/libc/unix/getcwd.c index f57e14742..826fc789d 100644 --- a/newlib/libc/unix/getcwd.c +++ b/newlib/libc/unix/getcwd.c @@ -124,7 +124,7 @@ getcwd (pt, size) for (first = 1;; first = 0) { /* Stat the current level. */ - if (stat (up, &s)) + if (_stat (up, &s)) goto err; /* Save current node values. */ @@ -165,7 +165,7 @@ getcwd (pt, size) *bup = '\0'; /* Open and stat parent directory. */ - if (!(dir = opendir (up)) || fstat (__dirfd (dir), &s)) + if (!(dir = _opendir (up)) || _fstat (__dirfd (dir), &s)) goto err; /* Add trailing slash for next directory. */ @@ -182,7 +182,7 @@ getcwd (pt, size) { for (;;) { - if (!(dp = readdir (dir))) + if (!(dp = _readdir (dir))) goto notfound; if (dp->d_ino == ino) break; @@ -191,7 +191,7 @@ getcwd (pt, size) else for (;;) { - if (!(dp = readdir (dir))) + if (!(dp = _readdir (dir))) goto notfound; if (ISDOT (dp)) continue; @@ -238,7 +238,7 @@ getcwd (pt, size) *--bpt = '/'; bpt -= strlen (dp->d_name); bcopy (dp->d_name, bpt, strlen (dp->d_name)); - (void) closedir (dir); + (void) _closedir (dir); /* Truncate any file name. */ *bup = '\0'; diff --git a/newlib/libc/unix/getlogin.c b/newlib/libc/unix/getlogin.c index ea4ca2983..e043b029f 100644 --- a/newlib/libc/unix/getlogin.c +++ b/newlib/libc/unix/getlogin.c @@ -19,24 +19,24 @@ getlogin () || ((tty = ttyname (2)) == 0)) return 0; - if ((utmp_fd = open (UTMP_FILE, O_RDONLY)) == -1) + if ((utmp_fd = _open (UTMP_FILE, O_RDONLY)) == -1) return 0; if (!strncmp (tty, "/dev/", 5)) tty += 5; - while (read (utmp_fd, &utmp_buf, sizeof (utmp_buf)) == sizeof (utmp_buf)) + while (_read (utmp_fd, &utmp_buf, sizeof (utmp_buf)) == sizeof (utmp_buf)) { if (!strncmp (tty, utmp_buf.ut_line, sizeof (utmp_buf.ut_line)) && utmp_buf.ut_type == USER_PROCESS) { - close (utmp_fd); + _close (utmp_fd); memset (buf, 0, sizeof (buf)); strncpy (buf, utmp_buf.ut_user, sizeof (utmp_buf.ut_user)); return buf; } } - close (utmp_fd); + _close (utmp_fd); return 0; } diff --git a/newlib/libc/unix/getpass.c b/newlib/libc/unix/getpass.c index 69327ba05..db0e52d61 100644 --- a/newlib/libc/unix/getpass.c +++ b/newlib/libc/unix/getpass.c @@ -90,7 +90,7 @@ getpass (prompt) if (p < buf + _PASSWORD_LEN) *p++ = ch; *p = '\0'; - (void) write (fileno (outfp), "\n", 1); + (void) _write (fileno (outfp), "\n", 1); if (echo) { term.c_lflag |= ECHO; diff --git a/newlib/libc/unix/getut.c b/newlib/libc/unix/getut.c index 554ed3ca1..1e2b75596 100644 --- a/newlib/libc/unix/getut.c +++ b/newlib/libc/unix/getut.c @@ -16,15 +16,15 @@ setutent () { if (utmp_fd == -2) { - 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); } void endutent () { - close (utmp_fd); + _close (utmp_fd); utmp_fd = -2; } @@ -39,7 +39,7 @@ getutent () { 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)) return 0; return &utmp_data; } @@ -47,7 +47,7 @@ getutent () 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)) { switch (id->ut_type) { @@ -73,7 +73,7 @@ getutid (struct utmp *id) 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)) { if ((utmp_data.ut_type == LOGIN_PROCESS || utmp_data.ut_type == USER_PROCESS) && diff --git a/newlib/libc/unix/pread.c b/newlib/libc/unix/pread.c deleted file mode 100644 index 72087542e..000000000 --- a/newlib/libc/unix/pread.c +++ /dev/null @@ -1,91 +0,0 @@ -/* -FUNCTION -<<pread>>---read a file from specified position - -INDEX - pread -INDEX - _pread_r - -ANSI_SYNOPSIS - #include <unistd.h> - ssize_t pread(int <[fd]>, void *<[buf]>, size_t <[n]>, off_t <[off]>); - ssize_t _pread_r(struct _reent *<[rptr]>, int <[fd]>, - void *<[buf]>, size_t <[n]>, off_t <[off]>); - -TRAD_SYNOPSIS - #include <unistd.h> - ssize_t pread(<[fd]>, <[buf]>, <[n]>, <[off]>) - int <[fd]>; - void *<[buf]>; - size_t <[n]>; - off_t <[off]>; - - ssize_t _pread_r(<[rptr]>, <[fd]>, <[buf]>, <[n]>, <[off]>) - struct _reent *<[rptr]>; - int <[fd]>; - void *<[buf]>; - size_t <[n]>; - off_t <[off]>; - -DESCRIPTION -The <<pread>> function is similar to <<read>>. One difference is that -<<pread>> has an additional parameter <[off]> which is the offset to -position in the file before reading. The function also differs in that -the file position is unchanged by the function (i.e. the file position -is the same before and after a call to <<pread>>). - -The <<_pread_r>> function is the same as <<pread>>, only a reentrant -struct pointer <[rptr]> is provided to preserve reentrancy. - -RETURNS -<<pread>> returns the number of bytes read or <<-1>> if failure occurred. - -PORTABILITY -<<pread>> is non-ANSI and is specified by the Single Unix Specification. - -Supporting OS subroutine required: <<read>>, <<lseek>>. -*/ - -#include <_ansi.h> -#include <unistd.h> -#include <reent.h> - -ssize_t -_DEFUN (_pread_r, (rptr, fd, buf, n, off), - struct _reent *rptr _AND - int fd _AND - _PTR buf _AND - size_t n _AND - off_t off) -{ - off_t cur_pos; - _READ_WRITE_RETURN_TYPE num_read; - - if ((cur_pos = _lseek_r (rptr, fd, 0, SEEK_CUR)) == (off_t)-1) - return -1; - - if (_lseek_r (rptr, fd, off, SEEK_SET) == (off_t)-1) - return -1; - - num_read = _read_r (rptr, fd, buf, n); - - if (_lseek_r (rptr, fd, cur_pos, SEEK_SET) == (off_t)-1) - return -1; - - return (ssize_t)num_read; -} - -#ifndef _REENT_ONLY - -ssize_t -_DEFUN (pread, (fd, buf, n, off), - int fd _AND - _PTR buf _AND - size_t n _AND - off_t off) -{ - return _pread_r (_REENT, fd, buf, n, off); -} - -#endif diff --git a/newlib/libc/unix/pwrite.c b/newlib/libc/unix/pwrite.c deleted file mode 100644 index 23979ac79..000000000 --- a/newlib/libc/unix/pwrite.c +++ /dev/null @@ -1,92 +0,0 @@ -/* -FUNCTION -<<pwrite>>---write a file from specified position - -INDEX - pwrite -INDEX - _pwrite_r - -ANSI_SYNOPSIS - #include <unistd.h> - ssize_t pwrite(int <[fd]>, const void *<[buf]>, - size_t <[n]>, off_t <[off]>); - ssize_t _pwrite_r(struct _reent *<[rptr]>, int <[fd]>, - const void *<[buf]>, size_t <[n]>, off_t <[off]>); - -TRAD_SYNOPSIS - #include <unistd.h> - ssize_t pwrite(<[fd]>, <[buf]>, <[n]>, <[off]>) - int <[fd]>; - const void *<[buf]>; - size_t <[n]>; - off_t <[off]>; - - ssize_t _pwrite_r(<[rptr]>, <[fd]>, <[buf]>, <[n]>, <[off]>) - struct _reent *<[rptr]>; - int <[fd]>; - const void *<[buf]>; - size_t <[n]>; - off_t <[off]>; - -DESCRIPTION -The <<pwrite>> function is similar to <<write>>. One difference is that -<<pwrite>> has an additional parameter <[off]> which is the offset to -position in the file before writing. The function also differs in that -the file position is unchanged by the function (i.e. the file position -is the same before and after a call to <<pwrite>>). - -The <<_pwrite_r>> function is the same as <<pwrite>>, only a reentrant -struct pointer <[rptr]> is provided to preserve reentrancy. - -RETURNS -<<pwrite>> returns the number of bytes written or <<-1>> if failure occurred. - -PORTABILITY -<<pwrite>> is non-ANSI and is specified by the Single Unix Specification. - -Supporting OS subroutine required: <<write>>, <<lseek>>. -*/ - -#include <_ansi.h> -#include <unistd.h> -#include <reent.h> - -ssize_t -_DEFUN (_pwrite_r, (rptr, fd, buf, n, off), - struct _reent *rptr _AND - int fd _AND - _CONST _PTR buf _AND - size_t n _AND - off_t off) -{ - off_t cur_pos; - _READ_WRITE_RETURN_TYPE num_written; - - if ((cur_pos = _lseek_r (rptr, fd, 0, SEEK_CUR)) == (off_t)-1) - return -1; - - if (_lseek_r (rptr, fd, off, SEEK_SET) == (off_t)-1) - return -1; - - num_written = _write_r (rptr, fd, buf, n); - - if (_lseek_r (rptr, fd, cur_pos, SEEK_SET) == (off_t)-1) - return -1; - - return (ssize_t)num_written; -} - -#ifndef _REENT_ONLY - -ssize_t -_DEFUN (pwrite, (fd, buf, n, off), - int fd _AND - _CONST _PTR buf _AND - size_t n _AND - off_t off) -{ - return _pwrite_r (_REENT, fd, buf, n, off); -} - -#endif diff --git a/newlib/libc/unix/sigset.c b/newlib/libc/unix/sigset.c index cd73a78c8..ecb3d0800 100644 --- a/newlib/libc/unix/sigset.c +++ b/newlib/libc/unix/sigset.c @@ -1,7 +1,7 @@ #include <signal.h> #include <errno.h> -#if defined(SIG_SETMASK) && NSIG <= 32 /* easier than trying to remove from Makefile */ +#ifdef SIG_SETMASK /* easier than trying to remove from Makefile */ #undef sigemptyset int diff --git a/newlib/libc/unix/ttyname.c b/newlib/libc/unix/ttyname.c index 09f12a337..258ba25fe 100644 --- a/newlib/libc/unix/ttyname.c +++ b/newlib/libc/unix/ttyname.c @@ -56,19 +56,20 @@ ttyname (fd) struct dirent *dirp; DIR *dp; struct stat dsb; + char *rval; /* Must be a terminal. */ if (tcgetattr (fd, &tty) < 0) return NULL; /* Must be a character device. */ - 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) + if ((dp = _opendir (_PATH_DEV)) == NULL) return NULL; - while ((dirp = readdir (dp)) != NULL) + for (rval = NULL; dirp = _readdir (dp);) { if (dirp->d_ino != sb.st_ino) continue; @@ -76,9 +77,10 @@ ttyname (fd) if (stat (buf, &dsb) || sb.st_dev != dsb.st_dev || sb.st_ino != dsb.st_ino) continue; - (void) closedir (dp); - return buf; + (void) _closedir (dp); + rval = buf; + break; } - (void) closedir (dp); - return NULL; + (void) _closedir (dp); + return rval; } |