From 26223643100902ca075d5833772986278dbecfdb Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 18 Apr 2000 17:33:41 +0000 Subject: AIX tcsetattr implementation. --- sysdeps/unix/sysv/aix/speed.c | 72 ++++++++++++++ sysdeps/unix/sysv/aix/symlink.c | 27 ++++++ sysdeps/unix/sysv/aix/sync.c | 1 + sysdeps/unix/sysv/aix/sys/param.h | 3 + sysdeps/unix/sysv/aix/tcgetattr.c | 152 +++++++++++++++++++++++++++++ sysdeps/unix/sysv/aix/tcsetattr.c | 197 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 452 insertions(+) create mode 100644 sysdeps/unix/sysv/aix/speed.c create mode 100644 sysdeps/unix/sysv/aix/symlink.c create mode 100644 sysdeps/unix/sysv/aix/sync.c create mode 100644 sysdeps/unix/sysv/aix/tcgetattr.c create mode 100644 sysdeps/unix/sysv/aix/tcsetattr.c (limited to 'sysdeps') diff --git a/sysdeps/unix/sysv/aix/speed.c b/sysdeps/unix/sysv/aix/speed.c new file mode 100644 index 0000000000..06934fef25 --- /dev/null +++ b/sysdeps/unix/sysv/aix/speed.c @@ -0,0 +1,72 @@ +/* `struct termios' speed frobnication functions. AIX version. + Copyright (C) 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +/* Return the output baud rate stored in *TERMIOS_P. */ +speed_t +cfgetospeed (termios_p) + const struct termios *termios_p; +{ + return termios_p->c_cflag & 0x0000000f; +} + +/* Return the input baud rate stored in *TERMIOS_P. */ +speed_t +cfgetispeed (termios_p) + const struct termios *termios_p; +{ + return (termios_p->c_cflag & 0x000f0000) >> 16; +} + +/* Set the output baud rate stored in *TERMIOS_P to SPEED. */ +int +cfsetospeed (termios_p, speed) + struct termios *termios_p; + speed_t speed; +{ + if (termios_p == NULL) + { + __set_errno (EINVAL); + return -1; + } + + termios_p->c_cflag &= ~0x0000000f; + termios_p->c_cflag |= speed & 0x0000000f; + return 0; +} + +/* Set the input baud rate stored in *TERMIOS_P to SPEED. */ +int +cfsetispeed (termios_p, speed) + struct termios *termios_p; + speed_t speed; +{ + if (termios_p == NULL) + { + __set_errno (EINVAL); + return -1; + } + + termios_p->c_cflag &= ~0x000f0000; + termios_p->c_cflag |= (speed << 16) & ~0x000f0000; + return 0; +} diff --git a/sysdeps/unix/sysv/aix/symlink.c b/sysdeps/unix/sysv/aix/symlink.c new file mode 100644 index 0000000000..a70f103450 --- /dev/null +++ b/sysdeps/unix/sysv/aix/symlink.c @@ -0,0 +1,27 @@ +/* Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +int +__symlink (from, to) + const char *from; + const char *to; +{ + return symlink (from, to); +} diff --git a/sysdeps/unix/sysv/aix/sync.c b/sysdeps/unix/sysv/aix/sync.c new file mode 100644 index 0000000000..6036fbbffd --- /dev/null +++ b/sysdeps/unix/sysv/aix/sync.c @@ -0,0 +1 @@ +/* This is a system call. */ diff --git a/sysdeps/unix/sysv/aix/sys/param.h b/sysdeps/unix/sysv/aix/sys/param.h index e128d8d60b..66f2127fbe 100644 --- a/sysdeps/unix/sysv/aix/sys/param.h +++ b/sysdeps/unix/sysv/aix/sys/param.h @@ -13,6 +13,9 @@ /* The pagesize is 4096. */ #define EXEC_PAGESIZE 4096 +/* maximum number of supplemental groups. */ +#define NGROUPS 32 + /* Macros for min/max. */ #define MIN(a,b) (((a)<(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b)) diff --git a/sysdeps/unix/sysv/aix/tcgetattr.c b/sysdeps/unix/sysv/aix/tcgetattr.c new file mode 100644 index 0000000000..b994f178bd --- /dev/null +++ b/sysdeps/unix/sysv/aix/tcgetattr.c @@ -0,0 +1,152 @@ +/* Copyright (C) 1992, 1995, 1996, 1997, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include +#include + +/* Put the state of FD into *TERMIOS_P. */ +int +__tcgetattr (fd, termios_p) + int fd; + struct termios *termios_p; +{ + struct __sysv_termio buf; + + if (termios_p == NULL) + { + __set_errno (EINVAL); + return -1; + } + + if (__ioctl (fd, _TCGETA, &buf) < 0) + return -1; + + termios_p->c_cflag &= ~0x000f0000; + termios_p->c_cflag |= (termios_p->c_cflag & 0xf) << 16; + + termios_p->c_iflag = 0; + if (buf.c_iflag & _SYSV_IGNBRK) + termios_p->c_iflag |= IGNBRK; + if (buf.c_iflag & _SYSV_BRKINT) + termios_p->c_iflag |= BRKINT; + if (buf.c_iflag & _SYSV_IGNPAR) + termios_p->c_iflag |= IGNPAR; + if (buf.c_iflag & _SYSV_PARMRK) + termios_p->c_iflag |= PARMRK; + if (buf.c_iflag & _SYSV_INPCK) + termios_p->c_iflag |= INPCK; + if (buf.c_iflag & _SYSV_ISTRIP) + termios_p->c_iflag |= ISTRIP; + if (buf.c_iflag & _SYSV_INLCR) + termios_p->c_iflag |= INLCR; + if (buf.c_iflag & _SYSV_IGNCR) + termios_p->c_iflag |= IGNCR; + if (buf.c_iflag & _SYSV_ICRNL) + termios_p->c_iflag |= ICRNL; + if (buf.c_iflag & _SYSV_IXON) + termios_p->c_iflag |= IXON; + if (buf.c_iflag & _SYSV_IXOFF) + termios_p->c_iflag |= IXOFF; + if (buf.c_iflag & _SYSV_IXANY) + termios_p->c_iflag |= IXANY; + if (buf.c_iflag & _SYSV_IMAXBEL) + termios_p->c_iflag |= IMAXBEL; + + termios_p->c_oflag = 0; + if (buf.c_oflag & OPOST) + termios_p->c_oflag |= OPOST; + if (buf.c_oflag & ONLCR) + termios_p->c_oflag |= ONLCR; + termios_p->c_cflag = 0; + switch (buf.c_cflag & _SYSV_CSIZE) + { + case _SYSV_CS5: + termios_p->c_cflag |= CS5; + break; + case _SYSV_CS6: + termios_p->c_cflag |= CS6; + break; + case _SYSV_CS7: + termios_p->c_cflag |= CS7; + break; + case _SYSV_CS8: + termios_p->c_cflag |= CS8; + break; + } + if (buf.c_cflag & _SYSV_CSTOPB) + termios_p->c_cflag |= CSTOPB; + if (buf.c_cflag & _SYSV_CREAD) + termios_p->c_cflag |= CREAD; + if (buf.c_cflag & _SYSV_PARENB) + termios_p->c_cflag |= PARENB; + if (buf.c_cflag & _SYSV_PARODD) + termios_p->c_cflag |= PARODD; + if (buf.c_cflag & _SYSV_HUPCL) + termios_p->c_cflag |= HUPCL; + if (buf.c_cflag & _SYSV_CLOCAL) + termios_p->c_cflag |= CLOCAL; + termios_p->c_lflag = 0; + if (buf.c_lflag & _SYSV_ISIG) + termios_p->c_lflag |= ISIG; + if (buf.c_lflag & _SYSV_ICANON) + termios_p->c_lflag |= ICANON; + if (buf.c_lflag & _SYSV_ECHO) + termios_p->c_lflag |= ECHO; + if (buf.c_lflag & _SYSV_ECHOE) + termios_p->c_lflag |= ECHOE; + if (buf.c_lflag & _SYSV_ECHOK) + termios_p->c_lflag |= ECHOK; + if (buf.c_lflag & _SYSV_ECHONL) + termios_p->c_lflag |= ECHONL; + if (buf.c_lflag & _SYSV_NOFLSH) + termios_p->c_lflag |= NOFLSH; + if (buf.c_lflag & _SYSV_TOSTOP) + termios_p->c_lflag |= TOSTOP; + if (buf.c_lflag & _SYSV_ECHOKE) + termios_p->c_lflag |= ECHOKE; + if (buf.c_lflag & _SYSV_ECHOPRT) + termios_p->c_lflag |= ECHOPRT; + if (buf.c_lflag & _SYSV_ECHOCTL) + termios_p->c_lflag |= ECHOCTL; + if (buf.c_lflag & _SYSV_FLUSHO) + termios_p->c_lflag |= FLUSHO; + if (buf.c_lflag & _SYSV_PENDIN) + termios_p->c_lflag |= PENDIN; + if (buf.c_lflag & _SYSV_IEXTEN) + termios_p->c_lflag |= IEXTEN; + + termios_p->c_cc[VEOF] = buf.c_cc[_SYSV_VEOF]; + termios_p->c_cc[VEOL] = buf.c_cc[_SYSV_VEOL]; + termios_p->c_cc[VEOL2] = buf.c_cc[_SYSV_VEOL2]; + termios_p->c_cc[VERASE] = buf.c_cc[_SYSV_VERASE]; + termios_p->c_cc[VKILL] = buf.c_cc[_SYSV_VKILL]; + termios_p->c_cc[VINTR] = buf.c_cc[_SYSV_VINTR]; + termios_p->c_cc[VQUIT] = buf.c_cc[_SYSV_VQUIT]; + termios_p->c_cc[VSTART] = '\021'; /* XON (^Q). */ + termios_p->c_cc[VSTOP] = '\023'; /* XOFF (^S). */ + termios_p->c_cc[VSUSP] = '\0'; /* System V release 3 lacks job control. */ + termios_p->c_cc[VMIN] = buf.c_cc[_SYSV_VMIN]; + termios_p->c_cc[VTIME] = buf.c_cc[_SYSV_VTIME]; + + return 0; +} + +weak_alias (__tcgetattr, tcgetattr) diff --git a/sysdeps/unix/sysv/aix/tcsetattr.c b/sysdeps/unix/sysv/aix/tcsetattr.c new file mode 100644 index 0000000000..516bcfb635 --- /dev/null +++ b/sysdeps/unix/sysv/aix/tcsetattr.c @@ -0,0 +1,197 @@ +/* Copyright (C) 1992, 1995, 1996, 1997, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include + +#include + + +const speed_t __unix_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 __sysv_termio buf; + int ioctl_function; + + if (termios_p == NULL) + { + __set_errno (EINVAL); + return -1; + } + switch (optional_actions) + { + case TCSANOW: + ioctl_function = _TCSETA; + break; + case TCSADRAIN: + ioctl_function = _TCSETAW; + break; + case TCSAFLUSH: + ioctl_function = _TCSETAF; + break; + default: + __set_errno (EINVAL); + return -1; + } + + if ((termios_p->c_cflag & 0x000f0000) >> 16 != (termios_p->c_cflag & 0xf)) + { + __set_errno (EINVAL); + return -1; + } + + buf.c_iflag = 0; + if (termios_p->c_iflag & IGNBRK) + buf.c_iflag |= _SYSV_IGNBRK; + if (termios_p->c_iflag & BRKINT) + buf.c_iflag |= _SYSV_BRKINT; + if (termios_p->c_iflag & IGNPAR) + buf.c_iflag |= _SYSV_IGNPAR; + if (termios_p->c_iflag & PARMRK) + buf.c_iflag |= _SYSV_PARMRK; + if (termios_p->c_iflag & INPCK) + buf.c_iflag |= _SYSV_INPCK; + if (termios_p->c_iflag & ISTRIP) + buf.c_iflag |= _SYSV_ISTRIP; + if (termios_p->c_iflag & INLCR) + buf.c_iflag |= _SYSV_INLCR; + if (termios_p->c_iflag & IGNCR) + buf.c_iflag |= _SYSV_IGNCR; + if (termios_p->c_iflag & ICRNL) + buf.c_iflag |= _SYSV_ICRNL; + if (termios_p->c_iflag & IXON) + buf.c_iflag |= _SYSV_IXON; + if (termios_p->c_iflag & IXOFF) + buf.c_iflag |= _SYSV_IXOFF; + if (termios_p->c_iflag & IXANY) + buf.c_iflag |= _SYSV_IXANY; + if (termios_p->c_iflag & IMAXBEL) + buf.c_iflag |= _SYSV_IMAXBEL; + + buf.c_oflag = 0; + if (termios_p->c_oflag & OPOST) + buf.c_oflag |= _SYSV_OPOST; + if (termios_p->c_oflag & ONLCR) + buf.c_oflag |= _SYSV_ONLCR; + + /* So far, buf.c_cflag contains the speed in CBAUD. */ + if (termios_p->c_cflag & CSTOPB) + buf.c_cflag |= _SYSV_CSTOPB; + if (termios_p->c_cflag & CREAD) + buf.c_cflag |= _SYSV_CREAD; + if (termios_p->c_cflag & PARENB) + buf.c_cflag |= _SYSV_PARENB; + if (termios_p->c_cflag & PARODD) + buf.c_cflag |= _SYSV_PARODD; + if (termios_p->c_cflag & HUPCL) + buf.c_cflag |= _SYSV_HUPCL; + if (termios_p->c_cflag & CLOCAL) + buf.c_cflag |= _SYSV_CLOCAL; + switch (termios_p->c_cflag & CSIZE) + { + case CS5: + buf.c_cflag |= _SYSV_CS5; + break; + case CS6: + buf.c_cflag |= _SYSV_CS6; + break; + case CS7: + buf.c_cflag |= _SYSV_CS7; + break; + case CS8: + buf.c_cflag |= _SYSV_CS8; + break; + } + + buf.c_lflag = 0; + if (termios_p->c_lflag & ISIG) + buf.c_lflag |= _SYSV_ISIG; + if (termios_p->c_lflag & ICANON) + buf.c_lflag |= _SYSV_ICANON; + if (termios_p->c_lflag & ECHO) + buf.c_lflag |= _SYSV_ECHO; + if (termios_p->c_lflag & ECHOE) + buf.c_lflag |= _SYSV_ECHOE; + if (termios_p->c_lflag & ECHOK) + buf.c_lflag |= _SYSV_ECHOK; + if (termios_p->c_lflag & ECHONL) + buf.c_lflag |= _SYSV_ECHONL; + if (termios_p->c_lflag & NOFLSH) + buf.c_lflag |= _SYSV_NOFLSH; + if (termios_p->c_lflag & TOSTOP) + buf.c_lflag |= _SYSV_TOSTOP; + if (termios_p->c_lflag & ECHOCTL) + buf.c_lflag |= _SYSV_ECHOCTL; + if (termios_p->c_lflag & ECHOPRT) + buf.c_lflag |= _SYSV_ECHOPRT; + if (termios_p->c_lflag & ECHOKE) + buf.c_lflag |= _SYSV_ECHOKE; + if (termios_p->c_lflag & FLUSHO) + buf.c_lflag |= _SYSV_FLUSHO; + if (termios_p->c_lflag & PENDIN) + buf.c_lflag |= _SYSV_PENDIN; + if (termios_p->c_lflag & IEXTEN) + buf.c_lflag |= _SYSV_IEXTEN; + + buf.c_cc[_SYSV_VINTR] = termios_p->c_cc[VINTR]; + buf.c_cc[_SYSV_VQUIT] = termios_p->c_cc[VQUIT]; + buf.c_cc[_SYSV_VERASE] = termios_p->c_cc[VERASE]; + buf.c_cc[_SYSV_VKILL] = termios_p->c_cc[VKILL]; + if (buf.c_lflag & _SYSV_ICANON) + { + buf.c_cc[_SYSV_VEOF] = termios_p->c_cc[VEOF]; + buf.c_cc[_SYSV_VEOL] = termios_p->c_cc[VEOL]; + } + else + { + buf.c_cc[_SYSV_VMIN] = termios_p->c_cc[VMIN]; + buf.c_cc[_SYSV_VTIME] = termios_p->c_cc[VTIME]; + } + buf.c_cc[_SYSV_VEOL2] = termios_p->c_cc[VEOL2]; + + if (__ioctl (fd, ioctl_function, &buf) < 0) + return -1; + return 0; +} -- cgit 1.4.1