diff options
Diffstat (limited to 'sysdeps/unix/bsd')
-rw-r--r-- | sysdeps/unix/bsd/bits/dirent.h | 32 | ||||
-rw-r--r-- | sysdeps/unix/bsd/bits/fcntl.h | 138 | ||||
-rw-r--r-- | sysdeps/unix/bsd/bsd4.4/isatty.c | 3 | ||||
-rw-r--r-- | sysdeps/unix/bsd/isatty.c | 31 | ||||
-rw-r--r-- | sysdeps/unix/bsd/tcdrain.c | 37 | ||||
-rw-r--r-- | sysdeps/unix/bsd/tcgetattr.c | 129 | ||||
-rw-r--r-- | sysdeps/unix/bsd/tcsetattr.c | 187 |
7 files changed, 0 insertions, 557 deletions
diff --git a/sysdeps/unix/bsd/bits/dirent.h b/sysdeps/unix/bsd/bits/dirent.h deleted file mode 100644 index e56efc43bc..0000000000 --- a/sysdeps/unix/bsd/bits/dirent.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Directory entry structure `struct dirent'. 4.2BSD version. - Copyright (C) 1996, 1997 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, see - <http://www.gnu.org/licenses/>. */ - -#ifndef _DIRENT_H -# error "Never use <bits/dirent.h> directly; include <dirent.h> instead." -#endif - -struct dirent - { - unsigned int d_fileno; /* 32 bits. */ - unsigned short int d_reclen; /* 16 bits. */ - unsigned short int d_namlen; /* 16 bits. */ - char d_name[1]; /* Variable length. */ - }; - -#define _DIRENT_HAVE_D_RECLEN 1 -#define _DIRENT_HAVE_D_NAMLEN 1 diff --git a/sysdeps/unix/bsd/bits/fcntl.h b/sysdeps/unix/bsd/bits/fcntl.h deleted file mode 100644 index df93999e71..0000000000 --- a/sysdeps/unix/bsd/bits/fcntl.h +++ /dev/null @@ -1,138 +0,0 @@ -/* O_*, F_*, FD_* bit values for 4.3 BSD. - Copyright (C) 1991, 1992, 1997, 2004 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, see - <http://www.gnu.org/licenses/>. */ - -#ifndef _FCNTL_H -# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead." -#endif - - -/* File access modes for `open' and `fcntl'. */ -#define O_RDONLY 0 /* Open read-only. */ -#define O_WRONLY 1 /* Open write-only. */ -#define O_RDWR 2 /* Open read/write. */ - - -/* Bits OR'd into the second argument to open. */ -#define O_CREAT 0x0200 /* Create file if it doesn't exist. */ -#define O_EXCL 0x0800 /* Fail if file already exists. */ -#define O_TRUNC 0x0400 /* Truncate file to zero length. */ -/* Apparently not assigning a controlling terminal is the default - behavior in BSD, so no bit is required to request that behavior. */ -#define O_NOCTTY 0 /* Don't assign a controlling terminal. */ -#if defined __USE_BSD || defined __USE_SVID -# define O_ASYNC 0x0040 /* Send SIGIO to owner when data is ready. */ -# define O_FSYNC 0x2000 /* Synchronous writes. */ -# define O_SYNC O_FSYNC -#endif - -/* File status flags for `open' and `fcntl'. */ -#define O_APPEND 0x0008 /* Writes append to the file. */ -#define O_NONBLOCK 0x0004 /* Non-blocking I/O. */ - -#ifdef __USE_BSD -/* BSD before 4.4 doesn't support POSIX.1 O_NONBLOCK, - but O_NDELAY is close. */ -# define O_NDELAY O_NONBLOCK -#endif - -#ifdef __USE_BSD -/* Bits in the file status flags returned by F_GETFL. - These are all the O_* flags, plus FREAD and FWRITE, which are - independent bits set by which of O_RDONLY, O_WRONLY, and O_RDWR, was - given to `open'. */ -# define FREAD 1 -# define FWRITE 2 - -/* Traditional BSD names the O_* bits. */ -# define FASYNC O_ASYNC -# define FCREAT O_CREAT -# define FEXCL O_EXCL -# define FTRUNC O_TRUNC -# define FNOCTTY O_NOCTTY -# define FFSYNC O_FSYNC -# define FSYNC O_SYNC -# define FAPPEND O_APPEND -# define FNONBLOCK O_NONBLOCK -# define FNDELAY O_NDELAY -#endif - -/* Mask for file access modes. This is system-dependent in case - some system ever wants to define some other flavor of access. */ -#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) - -/* XXX missing */ -#define O_LARGEFILE 0 - -/* Values for the second argument to `fcntl'. */ -#define F_DUPFD 0 /* Duplicate file descriptor. */ -#define F_GETFD 1 /* Get file descriptor flags. */ -#define F_SETFD 2 /* Set file descriptor flags. */ -#define F_GETFL 3 /* Get file status flags. */ -#define F_SETFL 4 /* Set file status flags. */ -#if defined __USE_BSD || defined __USE_UNIX98 -# define F_GETOWN 5 /* Get owner (receiver of SIGIO). */ -# define F_SETOWN 6 /* Set owner (receiver of SIGIO). */ -#endif -#define F_GETLK 7 /* Get record locking info. */ -#define F_SETLK 8 /* Set record locking info (non-blocking). */ -#define F_SETLKW 9 /* Set record locking info (blocking). */ - -/* XXX missing */ -#define F_GETLK64 7 /* Get record locking info. */ -#define F_SETLK64 8 /* Set record locking info (non-blocking). */ -#define F_SETLKW64 9 /* Set record locking info (blocking). */ - -/* File descriptor flags used with F_GETFD and F_SETFD. */ -#define FD_CLOEXEC 1 /* Close on exec. */ - - -#include <bits/types.h> - -/* The structure describing an advisory lock. This is the type of the third - argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests. */ -struct flock - { - short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */ - short int l_whence; /* Where `l_start' is relative to (like `lseek'). */ -#ifndef __USE_FILE_OFFSET64 - __off_t l_start; /* Offset where the lock begins. */ - __off_t l_len; /* Size of the locked area; zero means until EOF. */ -#else - __off64_t l_start; /* Offset where the lock begins. */ - __off64_t l_len; /* Size of the locked area; zero means until EOF. */ -#endif - short int l_pid; /* Process holding the lock. */ - short int l_xxx; /* Reserved for future use. */ - }; - -#ifdef __USE_LARGEFILE64 -struct flock64 - { - short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */ - short int l_whence; /* Where `l_start' is relative to (like `lseek'). */ - __off64_t l_start; /* Offset where the lock begins. */ - __off64_t l_len; /* Size of the locked area; zero means until EOF. */ - short int l_pid; /* Process holding the lock. */ - short int l_xxx; /* Reserved for future use. */ - }; -#endif - -/* Values for the `l_type' field of a `struct flock'. */ -#define F_RDLCK 1 /* Read lock. */ -#define F_WRLCK 2 /* Write lock. */ -#define F_UNLCK 3 /* Remove lock. */ diff --git a/sysdeps/unix/bsd/bsd4.4/isatty.c b/sysdeps/unix/bsd/bsd4.4/isatty.c deleted file mode 100644 index 473368c93f..0000000000 --- a/sysdeps/unix/bsd/bsd4.4/isatty.c +++ /dev/null @@ -1,3 +0,0 @@ -/* In a 4.4-derived world, tcgetattr is just one ioctl. */ - -#include <sysdeps/posix/isatty.c> diff --git a/sysdeps/unix/bsd/isatty.c b/sysdeps/unix/bsd/isatty.c deleted file mode 100644 index e20b62f714..0000000000 --- a/sysdeps/unix/bsd/isatty.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (C) 1991,95,96,97,2002 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, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <unistd.h> -#include <sys/ioctl.h> - -/* Return 1 if FD is a terminal, 0 if not. */ -int -__isatty (fd) - int fd; -{ - struct sgttyb term; - - return __ioctl (fd, TIOCGETP, &term) == 0; -} -weak_alias (__isatty, isatty) diff --git a/sysdeps/unix/bsd/tcdrain.c b/sysdeps/unix/bsd/tcdrain.c deleted file mode 100644 index 5dc03cc303..0000000000 --- a/sysdeps/unix/bsd/tcdrain.c +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 1991, 1996, 1997 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, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <stddef.h> -#include <termios.h> -#include <unistd.h> - -#include "bsdtty.h" - -/* Wait for pending output to be written on FD. */ -int -__libc_tcdrain (int fd) -{ - /* The TIOCSETP control waits for pending output to be written before - affecting its changes, so we use that without changing anything. */ - struct sgttyb b; - if (__ioctl (fd, TIOCGETP, (void *) &b) < 0 || - __ioctl (fd, TIOCSETP, (void *) &b) < 0) - return -1; - return 0; -} -weak_alias (__libc_tcdrain, tcdrain) diff --git a/sysdeps/unix/bsd/tcgetattr.c b/sysdeps/unix/bsd/tcgetattr.c deleted file mode 100644 index b3a54e3908..0000000000 --- a/sysdeps/unix/bsd/tcgetattr.c +++ /dev/null @@ -1,129 +0,0 @@ -/* Copyright (C) 1991, 1992, 1995, 1996, 1997 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, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <stddef.h> -#include <termios.h> - -#include "bsdtty.h" - -extern const speed_t __bsd_speeds[]; /* Defined in tcsetattr.c. */ - -/* Put the state of FD into *TERMIOS_P. */ -int -__tcgetattr (fd, termios_p) - int fd; - struct termios *termios_p; -{ - struct sgttyb buf; - struct tchars tchars; - struct ltchars ltchars; - int local; -#ifdef TIOCGETX - int extra; -#endif - - if (termios_p == NULL) - { - __set_errno (EINVAL); - return -1; - } - - if (__ioctl(fd, TIOCGETP, &buf) < 0 || - __ioctl(fd, TIOCGETC, &tchars) < 0 || - __ioctl(fd, TIOCGLTC, <chars) < 0 || -#ifdef TIOCGETX - __ioctl(fd, TIOCGETX, &extra) < 0 || -#endif - __ioctl(fd, TIOCLGET, &local) < 0) - return -1; - - termios_p->__ispeed = __bsd_speeds[(unsigned char) buf.sg_ispeed]; - termios_p->__ospeed = __bsd_speeds[(unsigned char) buf.sg_ospeed]; - - termios_p->c_iflag = 0; - termios_p->c_oflag = 0; - termios_p->c_cflag = 0; - termios_p->c_lflag = 0; - termios_p->c_oflag |= CREAD | HUPCL; -#ifdef LPASS8 - if (local & LPASS8) - termios_p->c_oflag |= CS8; - else -#endif - termios_p->c_oflag |= CS7; - if (!(buf.sg_flags & RAW)) - { - termios_p->c_iflag |= IXON; - termios_p->c_cflag |= OPOST; -#ifndef NOISIG - termios_p->c_lflag |= ISIG; -#endif - } - if ((buf.sg_flags & (CBREAK|RAW)) == 0) - termios_p->c_lflag |= ICANON; - if (!(buf.sg_flags & RAW) && !(local & LLITOUT)) - termios_p->c_oflag |= OPOST; - if (buf.sg_flags & CRMOD) - termios_p->c_iflag |= ICRNL; - if (buf.sg_flags & TANDEM) - termios_p->c_iflag |= IXOFF; -#ifdef TIOCGETX - if (!(extra & NOISIG)) - termios_p->c_lflag |= ISIG; - if (extra & STOPB) - termios_p->c_cflag |= CSTOPB; -#endif - - switch (buf.sg_flags & (EVENP|ODDP)) - { - case EVENP|ODDP: - break; - case ODDP: - termios_p->c_cflag |= PARODD; - default: - termios_p->c_cflag |= PARENB; - termios_p->c_iflag |= IGNPAR | INPCK; - break; - } - if (buf.sg_flags & ECHO) - termios_p->c_lflag |= _ECHO; - if (local & LCRTERA) - termios_p->c_lflag |= ECHOE; - if (local & LCRTKIL) - termios_p->c_lflag |= ECHOK; - if (local & LTOSTOP) - termios_p->c_lflag |= _TOSTOP; - if (local & LNOFLSH) - termios_p->c_lflag |= _NOFLSH; - - termios_p->c_cc[VEOF] = tchars.t_eofc; - termios_p->c_cc[VEOL] = '\n'; - termios_p->c_cc[VERASE] = buf.sg_erase; - termios_p->c_cc[VKILL] = buf.sg_kill; - termios_p->c_cc[VINTR] = tchars.t_intrc; - termios_p->c_cc[VQUIT] = tchars.t_quitc; - termios_p->c_cc[VSTART] = tchars.t_startc; - termios_p->c_cc[VSTOP] = tchars.t_stopc; - termios_p->c_cc[VSUSP] = ltchars.t_suspc; - termios_p->c_cc[VMIN] = -1; - termios_p->c_cc[VTIME] = -1; - - return 0; -} - -weak_alias (__tcgetattr, tcgetattr) diff --git a/sysdeps/unix/bsd/tcsetattr.c b/sysdeps/unix/bsd/tcsetattr.c deleted file mode 100644 index 0741c475e0..0000000000 --- a/sysdeps/unix/bsd/tcsetattr.c +++ /dev/null @@ -1,187 +0,0 @@ -/* Copyright (C) 1991, 1993, 1996, 1997, 2002 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, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <stddef.h> -#include <termios.h> - -#include "bsdtty.h" - - -const speed_t __bsd_speeds[] = - { - 0, - 50, - 75, - 110, - 134, - 150, - 200, - 300, - 600, - 1200, - 1800, - 2400, - 4800, - 9600, - 19200, - 38400, - }; - - -/* Set the state of FD to *TERMIOS_P. */ -int -tcsetattr (fd, optional_actions, termios_p) - int fd; - int optional_actions; - const struct termios *termios_p; -{ - struct sgttyb buf; - struct tchars tchars; - struct ltchars ltchars; - int local; -#ifdef TIOCGETX - int extra; -#endif - size_t i; - - if (__ioctl (fd, TIOCGETP, &buf) < 0 || - __ioctl (fd, TIOCGETC, &tchars) < 0 || - __ioctl (fd, TIOCGLTC, <chars) < 0 || -#ifdef TIOCGETX - __ioctl (fd, TIOCGETX, &extra) < 0 || -#endif - __ioctl (fd, TIOCLGET, &local) < 0) - return -1; - - if (termios_p == NULL) - { - __set_errno (EINVAL); - return -1; - } - switch (optional_actions) - { - case TCSANOW: - break; - case TCSADRAIN: - if (tcdrain (fd) < 0) - return -1; - break; - case TCSAFLUSH: - if (tcflush (fd, TCIFLUSH) < 0) - return -1; - break; - default: - __set_errno (EINVAL); - return -1; - } - - buf.sg_ispeed = buf.sg_ospeed = -1; - for (i = 0; i <= sizeof (__bsd_speeds) / sizeof (__bsd_speeds[0]); ++i) - { - if (__bsd_speeds[i] == termios_p->__ispeed) - buf.sg_ispeed = i; - if (__bsd_speeds[i] == termios_p->__ospeed) - buf.sg_ospeed = i; - } - if (buf.sg_ispeed == -1 || buf.sg_ospeed == -1) - { - __set_errno (EINVAL); - return -1; - } - - buf.sg_flags &= ~(CBREAK|RAW); - if (!(termios_p->c_lflag & ICANON)) - buf.sg_flags |= (termios_p->c_cflag & ISIG) ? CBREAK : RAW; -#ifdef LPASS8 - if (termios_p->c_oflag & CS8) - local |= LPASS8; - else - local &= ~LPASS8; -#endif - if (termios_p->c_lflag & _NOFLSH) - local |= LNOFLSH; - else - local &= ~LNOFLSH; - if (termios_p->c_oflag & OPOST) - local &= ~LLITOUT; - else - local |= LLITOUT; -#ifdef TIOCGETX - if (termios_p->c_lflag & ISIG) - extra &= ~NOISIG; - else - extra |= NOISIG; - if (termios_p->c_cflag & CSTOPB) - extra |= STOPB; - else - extra &= ~STOPB; -#endif - if (termios_p->c_iflag & ICRNL) - buf.sg_flags |= CRMOD; - else - buf.sg_flags &= ~CRMOD; - if (termios_p->c_iflag & IXOFF) - buf.sg_flags |= TANDEM; - else - buf.sg_flags &= ~TANDEM; - - buf.sg_flags &= ~(ODDP|EVENP); - if (!(termios_p->c_cflag & PARENB)) - buf.sg_flags |= ODDP | EVENP; - else if (termios_p->c_cflag & PARODD) - buf.sg_flags |= ODDP; - else - buf.sg_flags |= EVENP; - - if (termios_p->c_lflag & _ECHO) - buf.sg_flags |= ECHO; - else - buf.sg_flags &= ~ECHO; - if (termios_p->c_lflag & ECHOE) - local |= LCRTERA; - else - local &= ~LCRTERA; - if (termios_p->c_lflag & ECHOK) - local |= LCRTKIL; - else - local &= ~LCRTKIL; - if (termios_p->c_lflag & _TOSTOP) - local |= LTOSTOP; - else - local &= ~LTOSTOP; - - buf.sg_erase = termios_p->c_cc[VERASE]; - buf.sg_kill = termios_p->c_cc[VKILL]; - tchars.t_eofc = termios_p->c_cc[VEOF]; - tchars.t_intrc = termios_p->c_cc[VINTR]; - tchars.t_quitc = termios_p->c_cc[VQUIT]; - ltchars.t_suspc = termios_p->c_cc[VSUSP]; - tchars.t_startc = termios_p->c_cc[VSTART]; - tchars.t_stopc = termios_p->c_cc[VSTOP]; - - if (__ioctl (fd, TIOCSETP, &buf) < 0 || - __ioctl (fd, TIOCSETC, &tchars) < 0 || - __ioctl (fd, TIOCSLTC, <chars) < 0 || -#ifdef TIOCGETX - __ioctl (fd, TIOCSETX, &extra) < 0 || -#endif - __ioctl (fd, TIOCLSET, &local) < 0) - return -1; - return 0; -} -libc_hidden_def (tcsetattr) |