diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2008-01-04 01:33:37 +0300 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2008-01-04 01:33:37 +0300 |
commit | a639937a9ab176d7c38c1de7ef0d3b0d7643f856 (patch) | |
tree | fd9ae999b3c58f387d75c0f12136cf720013ceba /newlib/libc | |
parent | 7c8bd7a075a84a4d9010334b0f0cfc6cf45f49a7 (diff) |
2008-01-03 Jeff Johnston <jjohnstn@redhat.com>
Make isatty syscall handling consistent with other newlib syscalls.
* libc/include/_syslist.h: Add _isatty.
* libc/include/reent.h: Add _isatty_r.
* libc/include/sys/unistd.h: Add _isatty.
* libc/posix/Makefile.am: Add new _isatty.c file.
* libc/posix/Makefile.in: Regenerated.
* libc/posix/_isatty.c: New file.
* libc/posix/isatty.c: Changed to call _isatty().
* libc/reent/Makefile.am: Add new isattyr.c file.
* libc/reent/Makefile.in: Regenerated.
* libc/reent/isattyr.c: New file.
* libc/stdio/freopen.c: Changed to call _isatty_r().
* libc/stdio/makebuf.c: Ditto.
* libc/sys/a29khif/_isatty.S: Change isatty to _isatty.
* libc/sys/arc/isatty.c: Ditto.
* libc/sys/arm/syscalls.c: Ditto.
* libc/sys/d10v/syscalls.c: Ditto.
* libc/sys/h8300hms/syscalls.c: Ditto.
* libc/sys/h8500hms/syscalls.c: Ditto.
* libc/sys/linux/Makefile.am: Add new isatty.c file.
* libc/sys/linux/Makefile.in: Regenerated.
* libc/sys/linux/isatty.c: New file.
* libc/syscalls/Makefile.am: Add new sysisatty.c file.
* libc/syscalls/Makefile.in: Regenerated.
* libc/syscalls/sysisatty.c: New file.
Diffstat (limited to 'newlib/libc')
24 files changed, 251 insertions, 93 deletions
diff --git a/newlib/libc/include/_syslist.h b/newlib/libc/include/_syslist.h index 0bf76e108..09da79336 100644 --- a/newlib/libc/include/_syslist.h +++ b/newlib/libc/include/_syslist.h @@ -11,6 +11,7 @@ #define _fstat fstat #define _getpid getpid #define _gettimeofday gettimeofday +#define _isatty isatty #define _kill kill #define _link link #define _lseek lseek diff --git a/newlib/libc/include/reent.h b/newlib/libc/include/reent.h index 639789e71..4f3d6a9bf 100644 --- a/newlib/libc/include/reent.h +++ b/newlib/libc/include/reent.h @@ -67,6 +67,7 @@ extern int _fcntl_r _PARAMS ((struct _reent *, int, int, int)); extern int _fork_r _PARAMS ((struct _reent *)); extern int _fstat_r _PARAMS ((struct _reent *, int, struct stat *)); extern int _getpid_r _PARAMS ((struct _reent *)); +extern int _isatty_r _PARAMS ((struct _reent *, int)); extern int _kill_r _PARAMS ((struct _reent *, int, int)); extern int _link_r _PARAMS ((struct _reent *, const char *, const char *)); extern _off_t _lseek_r _PARAMS ((struct _reent *, int, _off_t, int)); diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h index 619652ffc..072e6fe71 100644 --- a/newlib/libc/include/sys/unistd.h +++ b/newlib/libc/include/sys/unistd.h @@ -189,6 +189,7 @@ int getsubopt(char **, char * const *, char **); int _EXFUN(_close, (int __fildes )); pid_t _EXFUN(_fork, (void )); pid_t _EXFUN(_getpid, (void )); +int _EXFUN(_isatty, (int __fildes )); int _EXFUN(_link, (const char *__path1, const char *__path2 )); _off_t _EXFUN(_lseek, (int __fildes, _off_t __offset, int __whence )); #ifdef __LARGE64_FILES diff --git a/newlib/libc/posix/Makefile.am b/newlib/libc/posix/Makefile.am index 649451645..2091b4110 100644 --- a/newlib/libc/posix/Makefile.am +++ b/newlib/libc/posix/Makefile.am @@ -5,7 +5,7 @@ AUTOMAKE_OPTIONS = cygnus INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) GENERAL_SOURCES = \ - closedir.c creat.c isatty.c \ + closedir.c creat.c _isatty.c isatty.c \ opendir.c readdir.c \ readdir_r.c rewinddir.c sleep.c usleep.c \ telldir.c diff --git a/newlib/libc/posix/Makefile.in b/newlib/libc/posix/Makefile.in index 1ac32b7a7..e301129fb 100644 --- a/newlib/libc/posix/Makefile.in +++ b/newlib/libc/posix/Makefile.in @@ -56,10 +56,11 @@ ARFLAGS = cru lib_a_AR = $(AR) $(ARFLAGS) lib_a_LIBADD = am__objects_1 = lib_a-closedir.$(OBJEXT) lib_a-creat.$(OBJEXT) \ - lib_a-isatty.$(OBJEXT) lib_a-opendir.$(OBJEXT) \ - lib_a-readdir.$(OBJEXT) lib_a-readdir_r.$(OBJEXT) \ - lib_a-rewinddir.$(OBJEXT) lib_a-sleep.$(OBJEXT) \ - lib_a-usleep.$(OBJEXT) lib_a-telldir.$(OBJEXT) + lib_a-_isatty.$(OBJEXT) lib_a-isatty.$(OBJEXT) \ + lib_a-opendir.$(OBJEXT) lib_a-readdir.$(OBJEXT) \ + lib_a-readdir_r.$(OBJEXT) lib_a-rewinddir.$(OBJEXT) \ + lib_a-sleep.$(OBJEXT) lib_a-usleep.$(OBJEXT) \ + lib_a-telldir.$(OBJEXT) am__objects_2 = lib_a-scandir.$(OBJEXT) lib_a-seekdir.$(OBJEXT) am__objects_3 = lib_a-execl.$(OBJEXT) lib_a-execle.$(OBJEXT) \ lib_a-execlp.$(OBJEXT) lib_a-execv.$(OBJEXT) \ @@ -77,8 +78,9 @@ am__objects_4 = lib_a-popen.$(OBJEXT) lib_a_OBJECTS = $(am_lib_a_OBJECTS) LTLIBRARIES = $(noinst_LTLIBRARIES) libposix_la_LIBADD = -am__objects_6 = closedir.lo creat.lo isatty.lo opendir.lo readdir.lo \ - readdir_r.lo rewinddir.lo sleep.lo usleep.lo telldir.lo +am__objects_6 = closedir.lo creat.lo _isatty.lo isatty.lo opendir.lo \ + readdir.lo readdir_r.lo rewinddir.lo sleep.lo usleep.lo \ + telldir.lo am__objects_7 = scandir.lo seekdir.lo am__objects_8 = execl.lo execle.lo execlp.lo execv.lo execve.lo \ execvp.lo @@ -270,7 +272,7 @@ target_alias = @target_alias@ AUTOMAKE_OPTIONS = cygnus INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) GENERAL_SOURCES = \ - closedir.c creat.c isatty.c \ + closedir.c creat.c _isatty.c isatty.c \ opendir.c readdir.c \ readdir_r.c rewinddir.c sleep.c usleep.c \ telldir.c @@ -381,6 +383,12 @@ lib_a-creat.o: creat.c lib_a-creat.obj: creat.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-creat.obj `if test -f 'creat.c'; then $(CYGPATH_W) 'creat.c'; else $(CYGPATH_W) '$(srcdir)/creat.c'; fi` +lib_a-_isatty.o: _isatty.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-_isatty.o `test -f '_isatty.c' || echo '$(srcdir)/'`_isatty.c + +lib_a-_isatty.obj: _isatty.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-_isatty.obj `if test -f '_isatty.c'; then $(CYGPATH_W) '_isatty.c'; else $(CYGPATH_W) '$(srcdir)/_isatty.c'; fi` + lib_a-isatty.o: isatty.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-isatty.o `test -f 'isatty.c' || echo '$(srcdir)/'`isatty.c diff --git a/newlib/libc/posix/_isatty.c b/newlib/libc/posix/_isatty.c new file mode 100644 index 000000000..7260211ef --- /dev/null +++ b/newlib/libc/posix/_isatty.c @@ -0,0 +1,17 @@ +/* isatty.c */ + +/* Dumb implementation so programs will at least run. */ + +#include <sys/stat.h> + +int +_DEFUN(_isatty, (fd), int fd) +{ + struct stat buf; + + if (fstat (fd, &buf) < 0) + return 0; + if (S_ISCHR (buf.st_mode)) + return 1; + return 0; +} diff --git a/newlib/libc/posix/isatty.c b/newlib/libc/posix/isatty.c index 2732ca2a0..afd5ec85e 100644 --- a/newlib/libc/posix/isatty.c +++ b/newlib/libc/posix/isatty.c @@ -1,17 +1,10 @@ /* isatty.c */ -/* Dumb implementation so programs will at least run. */ - -#include <sys/stat.h> +#include <unistd.h> +#include <reent.h> int _DEFUN(isatty, (fd), int fd) { - struct stat buf; - - if (fstat (fd, &buf) < 0) - return 0; - if (S_ISCHR (buf.st_mode)) - return 1; - return 0; + return _isatty (fd); } diff --git a/newlib/libc/reent/Makefile.am b/newlib/libc/reent/Makefile.am index b695e2941..0d21285a1 100644 --- a/newlib/libc/reent/Makefile.am +++ b/newlib/libc/reent/Makefile.am @@ -37,6 +37,7 @@ GENERAL_SOURCES = \ fstatr.c \ getreent.c \ gettimeofdayr.c \ + isattyr.c \ linkr.c \ lseekr.c \ openr.c \ diff --git a/newlib/libc/reent/Makefile.in b/newlib/libc/reent/Makefile.in index 282e28d9d..5677cc4aa 100644 --- a/newlib/libc/reent/Makefile.in +++ b/newlib/libc/reent/Makefile.in @@ -58,13 +58,13 @@ lib_a_LIBADD = am__objects_1 = lib_a-closer.$(OBJEXT) lib_a-reent.$(OBJEXT) \ lib_a-impure.$(OBJEXT) lib_a-fcntlr.$(OBJEXT) \ lib_a-fstatr.$(OBJEXT) lib_a-getreent.$(OBJEXT) \ - lib_a-gettimeofdayr.$(OBJEXT) lib_a-linkr.$(OBJEXT) \ - lib_a-lseekr.$(OBJEXT) lib_a-openr.$(OBJEXT) \ - lib_a-readr.$(OBJEXT) lib_a-renamer.$(OBJEXT) \ - lib_a-signalr.$(OBJEXT) lib_a-signgam.$(OBJEXT) \ - lib_a-sbrkr.$(OBJEXT) lib_a-statr.$(OBJEXT) \ - lib_a-timesr.$(OBJEXT) lib_a-unlinkr.$(OBJEXT) \ - lib_a-writer.$(OBJEXT) + lib_a-gettimeofdayr.$(OBJEXT) lib_a-isattyr.$(OBJEXT) \ + lib_a-linkr.$(OBJEXT) lib_a-lseekr.$(OBJEXT) \ + lib_a-openr.$(OBJEXT) lib_a-readr.$(OBJEXT) \ + lib_a-renamer.$(OBJEXT) lib_a-signalr.$(OBJEXT) \ + lib_a-signgam.$(OBJEXT) lib_a-sbrkr.$(OBJEXT) \ + lib_a-statr.$(OBJEXT) lib_a-timesr.$(OBJEXT) \ + lib_a-unlinkr.$(OBJEXT) lib_a-writer.$(OBJEXT) @HAVE_STDIO64_DIR_TRUE@am__objects_2 = lib_a-fstat64r.$(OBJEXT) \ @HAVE_STDIO64_DIR_TRUE@ lib_a-lseek64r.$(OBJEXT) \ @HAVE_STDIO64_DIR_TRUE@ lib_a-open64r.$(OBJEXT) @@ -81,9 +81,9 @@ lib_a_OBJECTS = $(am_lib_a_OBJECTS) LTLIBRARIES = $(noinst_LTLIBRARIES) libreent_la_LIBADD = am__objects_6 = closer.lo reent.lo impure.lo fcntlr.lo fstatr.lo \ - getreent.lo gettimeofdayr.lo linkr.lo lseekr.lo openr.lo \ - readr.lo renamer.lo signalr.lo signgam.lo sbrkr.lo statr.lo \ - timesr.lo unlinkr.lo writer.lo + getreent.lo gettimeofdayr.lo isattyr.lo linkr.lo lseekr.lo \ + openr.lo readr.lo renamer.lo signalr.lo signgam.lo sbrkr.lo \ + statr.lo timesr.lo unlinkr.lo writer.lo @HAVE_STDIO64_DIR_TRUE@am__objects_7 = fstat64r.lo lseek64r.lo \ @HAVE_STDIO64_DIR_TRUE@ open64r.lo am__objects_8 = $(am__objects_7) @@ -295,6 +295,7 @@ GENERAL_SOURCES = \ fstatr.c \ getreent.c \ gettimeofdayr.c \ + isattyr.c \ linkr.c \ lseekr.c \ openr.c \ @@ -449,6 +450,12 @@ lib_a-gettimeofdayr.o: gettimeofdayr.c lib_a-gettimeofdayr.obj: gettimeofdayr.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-gettimeofdayr.obj `if test -f 'gettimeofdayr.c'; then $(CYGPATH_W) 'gettimeofdayr.c'; else $(CYGPATH_W) '$(srcdir)/gettimeofdayr.c'; fi` +lib_a-isattyr.o: isattyr.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-isattyr.o `test -f 'isattyr.c' || echo '$(srcdir)/'`isattyr.c + +lib_a-isattyr.obj: isattyr.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-isattyr.obj `if test -f 'isattyr.c'; then $(CYGPATH_W) 'isattyr.c'; else $(CYGPATH_W) '$(srcdir)/isattyr.c'; fi` + lib_a-linkr.o: linkr.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-linkr.o `test -f 'linkr.c' || echo '$(srcdir)/'`linkr.c diff --git a/newlib/libc/reent/isattyr.c b/newlib/libc/reent/isattyr.c new file mode 100644 index 000000000..05d47d323 --- /dev/null +++ b/newlib/libc/reent/isattyr.c @@ -0,0 +1,63 @@ +/* Reentrant versions of isatty system call. */ + +#include <reent.h> +#include <unistd.h> +#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 + +#ifdef REENTRANT_SYSCALLS_PROVIDED + +int _dummy_isatty_syscalls = 1; + +#else + +/* We use the errno variable used by the system dependent layer. */ +#undef errno +extern int errno; + +/* +FUNCTION + <<_isatty_r>>---Reentrant version of isatty + +INDEX + _isatty_r + +ANSI_SYNOPSIS + #include <reent.h> + int _isatty_r(struct _reent *<[ptr]>, + int <[fd]>); + +TRAD_SYNOPSIS + #include <reent.h> + int _isatty_r(<[ptr]>, <[fd]>) + struct _reent *<[ptr]>; + int <[fd]>; + +DESCRIPTION + This is a reentrant version of <<isatty>>. It + takes a pointer to the global data block, which holds + <<errno>>. +*/ + +int +_isatty_r (ptr, fd) + struct _reent *ptr; + int fd; +{ + int ret; + + errno = 0; + if ((ret = _isatty (fd)) == -1 && errno != 0) + ptr->_errno = errno; + return ret; +} + +#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c index 247f8c6ad..2a0d36247 100644 --- a/newlib/libc/stdio/freopen.c +++ b/newlib/libc/stdio/freopen.c @@ -167,7 +167,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp), /* * F_SETFL doesn't change textmode. Don't mess with modes of ttys. */ - if (0 <= f && ! isatty (f) + if (0 <= f && ! _isatty_r (ptr, f) && setmode (f, oflags & (O_BINARY | O_TEXT)) == -1) f = -1; #endif diff --git a/newlib/libc/stdio/makebuf.c b/newlib/libc/stdio/makebuf.c index d13f162b2..a3f47e2f7 100644 --- a/newlib/libc/stdio/makebuf.c +++ b/newlib/libc/stdio/makebuf.c @@ -107,7 +107,7 @@ _DEFUN(__smakebuf_r, (ptr, fp), fp->_flags |= __SMBF; fp->_bf._base = fp->_p = (unsigned char *) p; fp->_bf._size = size; - if (couldbetty && isatty (fp->_file)) + if (couldbetty && _isatty_r (ptr, fp->_file)) fp->_flags |= __SLBF; } } diff --git a/newlib/libc/sys/a29khif/_isatty.S b/newlib/libc/sys/a29khif/_isatty.S index 55110e2fc..b18d3a35e 100644 --- a/newlib/libc/sys/a29khif/_isatty.S +++ b/newlib/libc/sys/a29khif/_isatty.S @@ -4,10 +4,8 @@ gcc2_compiled.: .text .align 4 .global __isatty - .global _isatty .word 0x30000 __isatty: -_isatty: sub gr1,gr1,16 asgeu V_SPILL,gr1,gr126 add lr1,gr1,28 diff --git a/newlib/libc/sys/arc/isatty.c b/newlib/libc/sys/arc/isatty.c index 3c64647a9..fe64209b9 100644 --- a/newlib/libc/sys/arc/isatty.c +++ b/newlib/libc/sys/arc/isatty.c @@ -3,13 +3,14 @@ /* Dumb implementation so programs will at least run. */ #include <sys/stat.h> +#include <reent.h> int -isatty (int fd) +_isatty_r (struct _reent *ptr, int fd) { struct stat buf; - if (fstat (fd, &buf) < 0) + if (_fstat_r (ptr, fd, &buf) < 0) return 0; if (S_ISCHR (buf.st_mode)) return 1; diff --git a/newlib/libc/sys/arm/syscalls.c b/newlib/libc/sys/arm/syscalls.c index 65c96b1e2..f9ac14c06 100644 --- a/newlib/libc/sys/arm/syscalls.c +++ b/newlib/libc/sys/arm/syscalls.c @@ -20,7 +20,7 @@ /* Forward prototypes. */ int _system _PARAMS ((const char *)); int _rename _PARAMS ((const char *, const char *)); -int isatty _PARAMS ((int)); +int _isatty _PARAMS ((int)); clock_t _times _PARAMS ((struct tms *)); int _gettimeofday _PARAMS ((struct timeval *, void *)); void _raise _PARAMS ((void)); @@ -612,7 +612,7 @@ _times (struct tms * tp) int -isatty (int fd) +_isatty (int fd) { #ifdef ARM_RDI_MONITOR int fh = remap_handle (fd); diff --git a/newlib/libc/sys/d10v/syscalls.c b/newlib/libc/sys/d10v/syscalls.c index 11192074a..4c71db390 100644 --- a/newlib/libc/sys/d10v/syscalls.c +++ b/newlib/libc/sys/d10v/syscalls.c @@ -64,7 +64,7 @@ _unlink () } int -isatty (int fd) +_isatty (int fd) { return 1; } diff --git a/newlib/libc/sys/h8300hms/syscalls.c b/newlib/libc/sys/h8300hms/syscalls.c index b716e62fc..b9ec17a52 100644 --- a/newlib/libc/sys/h8300hms/syscalls.c +++ b/newlib/libc/sys/h8300hms/syscalls.c @@ -3,7 +3,7 @@ #include <_ansi.h> #include <errno.h> -int isatty(file) +int _isatty(file) int file; { return 1; diff --git a/newlib/libc/sys/h8500hms/syscalls.c b/newlib/libc/sys/h8500hms/syscalls.c index bb0c3c0c7..0f3471ab0 100644 --- a/newlib/libc/sys/h8500hms/syscalls.c +++ b/newlib/libc/sys/h8500hms/syscalls.c @@ -93,7 +93,7 @@ _sbrk (incr) int -isatty (file) +_isatty (file) int file; { return 1; diff --git a/newlib/libc/sys/linux/Makefile.am b/newlib/libc/sys/linux/Makefile.am index b27c46f99..2a1306cfe 100644 --- a/newlib/libc/sys/linux/Makefile.am +++ b/newlib/libc/sys/linux/Makefile.am @@ -47,6 +47,7 @@ GENERAL_SOURCES = \ inode.c \ io.c \ ipc.c \ + isatty.c \ linux.c \ mallinfor.c \ malloc.c \ diff --git a/newlib/libc/sys/linux/Makefile.in b/newlib/libc/sys/linux/Makefile.in index 46ca25390..91b2f5f38 100644 --- a/newlib/libc/sys/linux/Makefile.in +++ b/newlib/libc/sys/linux/Makefile.in @@ -138,7 +138,8 @@ DIST_COMMON = $(srcdir)/../../../../config.guess \ $(srcdir)/../../../../compile $(srcdir)/../../../../compile \ $(srcdir)/../../../../compile $(srcdir)/../../../../compile \ $(srcdir)/../../../../compile $(srcdir)/../../../../compile \ - $(srcdir)/../../../../compile $(srcdir)/../../../../ltmain.sh \ + $(srcdir)/../../../../compile $(srcdir)/../../../../compile \ + $(srcdir)/../../../../ltmain.sh \ $(srcdir)/../../../../config.guess \ $(srcdir)/../../../../config.sub subdir = . @@ -170,35 +171,36 @@ am__objects_1 = lib_a-aio.$(OBJEXT) lib_a-brk.$(OBJEXT) \ lib_a-gethostid.$(OBJEXT) lib_a-gethostname.$(OBJEXT) \ lib_a-getreent.$(OBJEXT) lib_a-ids.$(OBJEXT) \ lib_a-inode.$(OBJEXT) lib_a-io.$(OBJEXT) lib_a-ipc.$(OBJEXT) \ - lib_a-linux.$(OBJEXT) lib_a-mallinfor.$(OBJEXT) \ - lib_a-malloc.$(OBJEXT) lib_a-mallocr.$(OBJEXT) \ - lib_a-mallstatsr.$(OBJEXT) lib_a-mmap.$(OBJEXT) \ - lib_a-mq_close.$(OBJEXT) lib_a-mq_getattr.$(OBJEXT) \ - lib_a-mq_notify.$(OBJEXT) lib_a-mq_open.$(OBJEXT) \ - lib_a-mq_receive.$(OBJEXT) lib_a-mq_send.$(OBJEXT) \ - lib_a-mq_setattr.$(OBJEXT) lib_a-mq_unlink.$(OBJEXT) \ - lib_a-msize.$(OBJEXT) lib_a-msizer.$(OBJEXT) \ - lib_a-mstats.$(OBJEXT) lib_a-mtrim.$(OBJEXT) \ - lib_a-mtrimr.$(OBJEXT) lib_a-ntp_gettime.$(OBJEXT) \ - lib_a-pread.$(OBJEXT) lib_a-process.$(OBJEXT) \ - lib_a-prof-freq.$(OBJEXT) lib_a-profile.$(OBJEXT) \ - lib_a-psignal.$(OBJEXT) lib_a-pwrite.$(OBJEXT) \ - lib_a-raise.$(OBJEXT) lib_a-realloc.$(OBJEXT) \ - lib_a-reallocr.$(OBJEXT) lib_a-rename.$(OBJEXT) \ - lib_a-resource.$(OBJEXT) lib_a-sched.$(OBJEXT) \ - lib_a-select.$(OBJEXT) lib_a-seteuid.$(OBJEXT) \ - lib_a-sethostid.$(OBJEXT) lib_a-sethostname.$(OBJEXT) \ - lib_a-shm_open.$(OBJEXT) lib_a-shm_unlink.$(OBJEXT) \ - lib_a-sig.$(OBJEXT) lib_a-sigaction.$(OBJEXT) \ - lib_a-sigqueue.$(OBJEXT) lib_a-signal.$(OBJEXT) \ - lib_a-siglongjmp.$(OBJEXT) lib_a-sigset.$(OBJEXT) \ - lib_a-sigwait.$(OBJEXT) lib_a-socket.$(OBJEXT) \ - lib_a-sleep.$(OBJEXT) lib_a-strsignal.$(OBJEXT) \ - lib_a-strverscmp.$(OBJEXT) lib_a-sysconf.$(OBJEXT) \ - lib_a-sysctl.$(OBJEXT) lib_a-systat.$(OBJEXT) \ - lib_a-tcdrain.$(OBJEXT) lib_a-tcsendbrk.$(OBJEXT) \ - lib_a-termios.$(OBJEXT) lib_a-time.$(OBJEXT) \ - lib_a-usleep.$(OBJEXT) lib_a-versionsort.$(OBJEXT) + lib_a-isatty.$(OBJEXT) lib_a-linux.$(OBJEXT) \ + lib_a-mallinfor.$(OBJEXT) lib_a-malloc.$(OBJEXT) \ + lib_a-mallocr.$(OBJEXT) lib_a-mallstatsr.$(OBJEXT) \ + lib_a-mmap.$(OBJEXT) lib_a-mq_close.$(OBJEXT) \ + lib_a-mq_getattr.$(OBJEXT) lib_a-mq_notify.$(OBJEXT) \ + lib_a-mq_open.$(OBJEXT) lib_a-mq_receive.$(OBJEXT) \ + lib_a-mq_send.$(OBJEXT) lib_a-mq_setattr.$(OBJEXT) \ + lib_a-mq_unlink.$(OBJEXT) lib_a-msize.$(OBJEXT) \ + lib_a-msizer.$(OBJEXT) lib_a-mstats.$(OBJEXT) \ + lib_a-mtrim.$(OBJEXT) lib_a-mtrimr.$(OBJEXT) \ + lib_a-ntp_gettime.$(OBJEXT) lib_a-pread.$(OBJEXT) \ + lib_a-process.$(OBJEXT) lib_a-prof-freq.$(OBJEXT) \ + lib_a-profile.$(OBJEXT) lib_a-psignal.$(OBJEXT) \ + lib_a-pwrite.$(OBJEXT) lib_a-raise.$(OBJEXT) \ + lib_a-realloc.$(OBJEXT) lib_a-reallocr.$(OBJEXT) \ + lib_a-rename.$(OBJEXT) lib_a-resource.$(OBJEXT) \ + lib_a-sched.$(OBJEXT) lib_a-select.$(OBJEXT) \ + lib_a-seteuid.$(OBJEXT) lib_a-sethostid.$(OBJEXT) \ + lib_a-sethostname.$(OBJEXT) lib_a-shm_open.$(OBJEXT) \ + lib_a-shm_unlink.$(OBJEXT) lib_a-sig.$(OBJEXT) \ + lib_a-sigaction.$(OBJEXT) lib_a-sigqueue.$(OBJEXT) \ + lib_a-signal.$(OBJEXT) lib_a-siglongjmp.$(OBJEXT) \ + lib_a-sigset.$(OBJEXT) lib_a-sigwait.$(OBJEXT) \ + lib_a-socket.$(OBJEXT) lib_a-sleep.$(OBJEXT) \ + lib_a-strsignal.$(OBJEXT) lib_a-strverscmp.$(OBJEXT) \ + lib_a-sysconf.$(OBJEXT) lib_a-sysctl.$(OBJEXT) \ + lib_a-systat.$(OBJEXT) lib_a-tcdrain.$(OBJEXT) \ + lib_a-tcsendbrk.$(OBJEXT) lib_a-termios.$(OBJEXT) \ + lib_a-time.$(OBJEXT) lib_a-usleep.$(OBJEXT) \ + lib_a-versionsort.$(OBJEXT) am__objects_2 = lib_a-aio64.$(OBJEXT) lib_a-confstr.$(OBJEXT) \ lib_a-ctermid.$(OBJEXT) lib_a-fclean.$(OBJEXT) \ lib_a-fpathconf.$(OBJEXT) lib_a-fstab.$(OBJEXT) \ @@ -235,13 +237,13 @@ am__objects_6 = aio.lo brk.lo calloc.lo callocr.lo cfreer.lo \ cfspeed.lo clock_getres.lo clock_gettime.lo clock_settime.lo \ flockfile.lo free.lo freer.lo ftok.lo funlockfile.lo \ getdate.lo getdate_err.lo gethostid.lo gethostname.lo \ - getreent.lo ids.lo inode.lo io.lo ipc.lo linux.lo mallinfor.lo \ - malloc.lo mallocr.lo mallstatsr.lo mmap.lo mq_close.lo \ - mq_getattr.lo mq_notify.lo mq_open.lo mq_receive.lo mq_send.lo \ - mq_setattr.lo mq_unlink.lo msize.lo msizer.lo mstats.lo \ - mtrim.lo mtrimr.lo ntp_gettime.lo pread.lo process.lo \ - prof-freq.lo profile.lo psignal.lo pwrite.lo raise.lo \ - realloc.lo reallocr.lo rename.lo resource.lo sched.lo \ + getreent.lo ids.lo inode.lo io.lo ipc.lo isatty.lo linux.lo \ + mallinfor.lo malloc.lo mallocr.lo mallstatsr.lo mmap.lo \ + mq_close.lo mq_getattr.lo mq_notify.lo mq_open.lo \ + mq_receive.lo mq_send.lo mq_setattr.lo mq_unlink.lo msize.lo \ + msizer.lo mstats.lo mtrim.lo mtrimr.lo ntp_gettime.lo pread.lo \ + process.lo prof-freq.lo profile.lo psignal.lo pwrite.lo \ + raise.lo realloc.lo reallocr.lo rename.lo resource.lo sched.lo \ select.lo seteuid.lo sethostid.lo sethostname.lo shm_open.lo \ shm_unlink.lo sig.lo sigaction.lo sigqueue.lo signal.lo \ siglongjmp.lo sigset.lo sigwait.lo socket.lo sleep.lo \ @@ -465,6 +467,7 @@ GENERAL_SOURCES = \ inode.c \ io.c \ ipc.c \ + isatty.c \ linux.c \ mallinfor.c \ malloc.c \ @@ -807,6 +810,12 @@ lib_a-ipc.o: ipc.c lib_a-ipc.obj: ipc.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ipc.obj `if test -f 'ipc.c'; then $(CYGPATH_W) 'ipc.c'; else $(CYGPATH_W) '$(srcdir)/ipc.c'; fi` +lib_a-isatty.o: isatty.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-isatty.o `test -f 'isatty.c' || echo '$(srcdir)/'`isatty.c + +lib_a-isatty.obj: isatty.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-isatty.obj `if test -f 'isatty.c'; then $(CYGPATH_W) 'isatty.c'; else $(CYGPATH_W) '$(srcdir)/isatty.c'; fi` + lib_a-linux.o: linux.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-linux.o `test -f 'linux.c' || echo '$(srcdir)/'`linux.c diff --git a/newlib/libc/sys/linux/isatty.c b/newlib/libc/sys/linux/isatty.c new file mode 100644 index 000000000..45e09400e --- /dev/null +++ b/newlib/libc/sys/linux/isatty.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <unistd.h> +#include <termios.h> + +#include <machine/weakalias.h> + +/* Return 1 if FD is a terminal, 0 if not. */ +int +__isatty (fd) + int fd; +{ + struct termios term; + + return tcgetattr (fd, &term) == 0; +} + +weak_alias (__isatty, isatty) diff --git a/newlib/libc/syscalls/Makefile.am b/newlib/libc/syscalls/Makefile.am index f6a6eda92..7af406482 100644 --- a/newlib/libc/syscalls/Makefile.am +++ b/newlib/libc/syscalls/Makefile.am @@ -10,6 +10,7 @@ GENERAL_SOURCES = \ sysfstat.c \ sysgetpid.c \ sysgettod.c \ + sysisatty.c \ syskill.c \ syslink.c \ syslseek.c \ diff --git a/newlib/libc/syscalls/Makefile.in b/newlib/libc/syscalls/Makefile.in index 31d153a79..5cc81bb10 100644 --- a/newlib/libc/syscalls/Makefile.in +++ b/newlib/libc/syscalls/Makefile.in @@ -46,7 +46,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \ $(top_srcdir)/../../ltoptions.m4 \ $(top_srcdir)/../../ltsugar.m4 \ $(top_srcdir)/../../ltversion.m4 $(top_srcdir)/../acinclude.m4 \ - $(top_srcdir)/../confsubdir.m4 $(top_srcdir)/configure.in + $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs @@ -57,12 +57,12 @@ lib_a_AR = $(AR) $(ARFLAGS) lib_a_LIBADD = am__objects_1 = lib_a-sysclose.$(OBJEXT) lib_a-sysfcntl.$(OBJEXT) \ lib_a-sysfstat.$(OBJEXT) lib_a-sysgetpid.$(OBJEXT) \ - lib_a-sysgettod.$(OBJEXT) lib_a-syskill.$(OBJEXT) \ - lib_a-syslink.$(OBJEXT) lib_a-syslseek.$(OBJEXT) \ - lib_a-sysopen.$(OBJEXT) lib_a-sysread.$(OBJEXT) \ - lib_a-syssbrk.$(OBJEXT) lib_a-sysstat.$(OBJEXT) \ - lib_a-systimes.$(OBJEXT) lib_a-sysunlink.$(OBJEXT) \ - lib_a-syswrite.$(OBJEXT) + lib_a-sysgettod.$(OBJEXT) lib_a-sysisatty.$(OBJEXT) \ + lib_a-syskill.$(OBJEXT) lib_a-syslink.$(OBJEXT) \ + lib_a-syslseek.$(OBJEXT) lib_a-sysopen.$(OBJEXT) \ + lib_a-sysread.$(OBJEXT) lib_a-syssbrk.$(OBJEXT) \ + lib_a-sysstat.$(OBJEXT) lib_a-systimes.$(OBJEXT) \ + lib_a-sysunlink.$(OBJEXT) lib_a-syswrite.$(OBJEXT) @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@am__objects_2 = lib_a-sysexecve.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@ lib_a-sysfork.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@ lib_a-syswait.$(OBJEXT) @@ -72,9 +72,9 @@ lib_a_OBJECTS = $(am_lib_a_OBJECTS) LTLIBRARIES = $(noinst_LTLIBRARIES) libsyscalls_la_LIBADD = am__objects_3 = sysclose.lo sysfcntl.lo sysfstat.lo sysgetpid.lo \ - sysgettod.lo syskill.lo syslink.lo syslseek.lo sysopen.lo \ - sysread.lo syssbrk.lo sysstat.lo systimes.lo sysunlink.lo \ - syswrite.lo + sysgettod.lo sysisatty.lo syskill.lo syslink.lo syslseek.lo \ + sysopen.lo sysread.lo syssbrk.lo sysstat.lo systimes.lo \ + sysunlink.lo syswrite.lo @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@am__objects_4 = sysexecve.lo \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@ sysfork.lo syswait.lo @USE_LIBTOOL_TRUE@am_libsyscalls_la_OBJECTS = $(am__objects_3) \ @@ -200,15 +200,8 @@ STRIP = @STRIP@ USE_LIBTOOL_FALSE = @USE_LIBTOOL_FALSE@ USE_LIBTOOL_TRUE = @USE_LIBTOOL_TRUE@ VERSION = @VERSION@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_AS = @ac_ct_AS@ ac_ct_CC = @ac_ct_CC@ -ac_ct_DLLTOOL = @ac_ct_DLLTOOL@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_OBJDUMP = @ac_ct_OBJDUMP@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -ac_ct_READELF = @ac_ct_READELF@ -ac_ct_STRIP = @ac_ct_STRIP@ aext = @aext@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ @@ -224,6 +217,9 @@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ exec_prefix = @exec_prefix@ extra_dir = @extra_dir@ host = @host@ @@ -231,12 +227,14 @@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ +htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ libm_machine_dir = @libm_machine_dir@ +localedir = @localedir@ localstatedir = @localstatedir@ lpfx = @lpfx@ lt_ECHO = @lt_ECHO@ @@ -246,8 +244,10 @@ mkdir_p = @mkdir_p@ newlib_basedir = @newlib_basedir@ oext = @oext@ oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ +psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ subdirs = @subdirs@ @@ -262,6 +262,7 @@ GENERAL_SOURCES = \ sysfstat.c \ sysgetpid.c \ sysgettod.c \ + sysisatty.c \ syskill.c \ syslink.c \ syslseek.c \ @@ -390,6 +391,12 @@ lib_a-sysgettod.o: sysgettod.c lib_a-sysgettod.obj: sysgettod.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sysgettod.obj `if test -f 'sysgettod.c'; then $(CYGPATH_W) 'sysgettod.c'; else $(CYGPATH_W) '$(srcdir)/sysgettod.c'; fi` +lib_a-sysisatty.o: sysisatty.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sysisatty.o `test -f 'sysisatty.c' || echo '$(srcdir)/'`sysisatty.c + +lib_a-sysisatty.obj: sysisatty.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sysisatty.obj `if test -f 'sysisatty.c'; then $(CYGPATH_W) 'sysisatty.c'; else $(CYGPATH_W) '$(srcdir)/sysisatty.c'; fi` + lib_a-syskill.o: syskill.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-syskill.o `test -f 'syskill.c' || echo '$(srcdir)/'`syskill.c diff --git a/newlib/libc/syscalls/sysisatty.c b/newlib/libc/syscalls/sysisatty.c new file mode 100644 index 000000000..5a6b8d455 --- /dev/null +++ b/newlib/libc/syscalls/sysisatty.c @@ -0,0 +1,15 @@ +/* connector for isatty */ + +#include <reent.h> +#include <unistd.h> + +int +_DEFUN (isatty, (fd), + int fd) +{ +#ifdef REENTRANT_SYSCALLS_PROVIDED + return _isatty_r (_REENT, fd); +#else + return _isatty (fd); +#endif +} |