diff options
author | Zack Weinberg <zackw@panix.com> | 2017-06-08 15:39:03 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2017-06-08 15:39:03 -0400 |
commit | 5046dbb4a7eba5eccfd258f92f4735c9ffc8d069 (patch) | |
tree | 4470480d904b65cf14ca524f96f79eca818c3eaf /REORG.TODO/sysdeps/unix/bsd | |
parent | 199fc19d3aaaf57944ef036e15904febe877fc93 (diff) | |
download | glibc-zack/build-layout-experiment.tar glibc-zack/build-layout-experiment.tar.gz glibc-zack/build-layout-experiment.tar.bz2 glibc-zack/build-layout-experiment.zip |
Prepare for radical source tree reorganization.zack/build-layout-experiment
All top-level files and directories are moved into a temporary storage
directory, REORG.TODO, except for files that will certainly still
exist in their current form at top level when we're done (COPYING,
COPYING.LIB, LICENSES, NEWS, README), all old ChangeLog files (which
are moved to the new directory OldChangeLogs, instead), and the
generated file INSTALL (which is just deleted; in the new order, there
will be no generated files checked into version control).
Diffstat (limited to 'REORG.TODO/sysdeps/unix/bsd')
27 files changed, 1073 insertions, 0 deletions
diff --git a/REORG.TODO/sysdeps/unix/bsd/Implies b/REORG.TODO/sysdeps/unix/bsd/Implies new file mode 100644 index 0000000000..c30979e17b --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/Implies @@ -0,0 +1,2 @@ +# The directory unix/inet implements sockets and networking in the usual way. +unix/inet diff --git a/REORG.TODO/sysdeps/unix/bsd/Makefile b/REORG.TODO/sysdeps/unix/bsd/Makefile new file mode 100644 index 0000000000..208fd24484 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/Makefile @@ -0,0 +1,3 @@ +ifeq ($(subdir),socket) +sysdep_routines += cmsg_nxthdr +endif diff --git a/REORG.TODO/sysdeps/unix/bsd/Versions b/REORG.TODO/sysdeps/unix/bsd/Versions new file mode 100644 index 0000000000..99b386b670 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/Versions @@ -0,0 +1,6 @@ +libc { + GLIBC_2.2.5 { + # functions used in inline functions or macros + __cmsg_nxthdr; + } +} diff --git a/REORG.TODO/sysdeps/unix/bsd/bits/signum.h b/REORG.TODO/sysdeps/unix/bsd/bits/signum.h new file mode 100644 index 0000000000..268c24a702 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/bits/signum.h @@ -0,0 +1,73 @@ +/* Signal number definitions. BSD version. + Copyright (C) 1991-2017 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/>. */ + +#ifdef _SIGNAL_H + +/* This file defines the fake signal functions and signal + number constants for 4.2 or 4.3 BSD-derived Unix system. */ + +/* Fake signal functions. */ +#define SIG_ERR ((__sighandler_t) -1) /* Error return. */ +#define SIG_DFL ((__sighandler_t) 0) /* Default action. */ +#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */ + +#ifdef __USE_XOPEN +# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */ +#endif + + +/* Signals. */ +#define SIGHUP 1 /* Hangup (POSIX). */ +#define SIGINT 2 /* Interrupt (ANSI). */ +#define SIGQUIT 3 /* Quit (POSIX). */ +#define SIGILL 4 /* Illegal instruction (ANSI). */ +#define SIGABRT SIGIOT /* Abort (ANSI). */ +#define SIGTRAP 5 /* Trace trap (POSIX). */ +#define SIGIOT 6 /* IOT trap (4.2 BSD). */ +#define SIGEMT 7 /* EMT trap (4.2 BSD). */ +#define SIGFPE 8 /* Floating-point exception (ANSI). */ +#define SIGKILL 9 /* Kill, unblockable (POSIX). */ +#define SIGBUS 10 /* Bus error (4.2 BSD). */ +#define SIGSEGV 11 /* Segmentation violation (ANSI). */ +#define SIGSYS 12 /* Bad argument to system call (4.2 BSD). */ +#define SIGPIPE 13 /* Broken pipe (POSIX). */ +#define SIGALRM 14 /* Alarm clock (POSIX). */ +#define SIGTERM 15 /* Termination (ANSI). */ +#define SIGURG 16 /* Urgent condition on socket (4.2 BSD). */ +#define SIGSTOP 17 /* Stop, unblockable (POSIX). */ +#define SIGTSTP 18 /* Keyboard stop (POSIX). */ +#define SIGCONT 19 /* Continue (POSIX). */ +#define SIGCHLD 20 /* Child status has changed (POSIX). */ +#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */ +#define SIGTTIN 21 /* Background read from tty (POSIX). */ +#define SIGTTOU 22 /* Background write to tty (POSIX). */ +#define SIGIO 23 /* I/O now possible (4.2 BSD). */ +#define SIGPOLL SIGIO /* Same as SIGIO? (SVID). */ +#define SIGXCPU 24 /* CPU limit exceeded (4.2 BSD). */ +#define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */ +#define SIGVTALRM 26 /* Virtual alarm clock (4.2 BSD). */ +#define SIGPROF 27 /* Profiling alarm clock (4.2 BSD). */ +#define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */ +#define SIGINFO 29 /* Information request (4.4 BSD). */ +#define SIGUSR1 30 /* User-defined signal 1 (POSIX). */ +#define SIGUSR2 31 /* User-defined signal 2 (POSIX). */ +#define SIGLOST 32 /* Resource lost (Sun); server died (GNU). */ + +#endif /* <signal.h> included. */ + +#define _NSIG 33 /* Biggest signal number + 1. */ diff --git a/REORG.TODO/sysdeps/unix/bsd/bits/sockaddr.h b/REORG.TODO/sysdeps/unix/bsd/bits/sockaddr.h new file mode 100644 index 0000000000..bb98f3a778 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/bits/sockaddr.h @@ -0,0 +1,45 @@ +/* Definition of struct sockaddr_* common members and sizes, BSD version. + Copyright (C) 1995-2017 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/>. */ + +/* + * Never include this file directly; use <sys/socket.h> instead. + */ + +#ifndef _BITS_SOCKADDR_H +#define _BITS_SOCKADDR_H 1 + + +/* POSIX.1g specifies this type name for the `sa_family' member. */ +typedef unsigned char sa_family_t; + +/* This macro is used to declare the initial common members + of the data types used for socket addresses, `struct sockaddr', + `struct sockaddr_in', `struct sockaddr_un', etc. */ + +#define __SOCKADDR_COMMON(sa_prefix) \ + unsigned char sa_prefix##len; \ + sa_family_t sa_prefix##family + +#define __SOCKADDR_COMMON_SIZE (2 * sizeof (unsigned char)) + +#define _HAVE_SA_LEN 1 /* We have the sa_len field. */ + +/* Size of struct sockaddr_storage. */ +#define _SS_SIZE 128 + +#endif /* bits/sockaddr.h */ diff --git a/REORG.TODO/sysdeps/unix/bsd/bsdtty.h b/REORG.TODO/sysdeps/unix/bsd/bsdtty.h new file mode 100644 index 0000000000..a1da8d5cc3 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/bsdtty.h @@ -0,0 +1,218 @@ +#undef B0 +#undef B50 +#undef B75 +#undef B110 +#undef B134 +#undef B150 +#undef B200 +#undef B300 +#undef B600 +#undef B1200 +#undef B1800 +#undef B2400 +#undef B4800 +#undef B9600 +#undef B19200 +#undef B38400 +#undef EXTA +#undef EXTB +#undef ECHO +#undef TOSTOP +#undef NOFLSH +#undef MDMBUF +#undef FLUSHO +#undef PENDIN +#undef CERASE +#undef CKILL +#undef CINTR +#undef CQUIT +#undef CSTART +#undef CSTOP +#undef CEOF +#undef CEOT +#undef CBRK +#undef CSUSP +#undef CDSUSP +#undef CRPRNT +#undef CFLUSH +#undef CWERASE +#undef CLNEXT +#undef CSTATUS +#undef CERASE +#undef CKILL +#undef CINTR +#undef CQUIT +#undef CSTART +#undef CSTOP +#undef CEOF +#undef CEOT +#undef CBRK +#undef CSUSP +#undef CDSUSP +#undef CRPRNT +#undef CFLUSH +#undef CWERASE +#undef CLNEXT +#undef CSTATUS +#undef CERASE +#undef CKILL +#undef CINTR +#undef CQUIT +#undef CSTART +#undef CSTOP +#undef CEOF +#undef CEOT +#undef CBRK +#undef CSUSP +#undef CDSUSP +#undef CRPRNT +#undef CFLUSH +#undef CWERASE +#undef CLNEXT +#undef CSTATUS +#undef CERASE +#undef CKILL +#undef CINTR +#undef CQUIT +#undef CSTART +#undef CSTOP +#undef CEOF +#undef CEOT +#undef CBRK +#undef CSUSP +#undef CDSUSP +#undef CRPRNT +#undef CFLUSH +#undef CWERASE +#undef CLNEXT +#undef CSTATUS +#undef CERASE +#undef CKILL +#undef CINTR +#undef CQUIT +#undef CSTART +#undef CSTOP +#undef CEOF +#undef CEOT +#undef CBRK +#undef CSUSP +#undef CDSUSP +#undef CRPRNT +#undef CFLUSH +#undef CWERASE +#undef CLNEXT +#undef CSTATUS +#undef CERASE +#undef CKILL +#undef CINTR +#undef CQUIT +#undef CSTART +#undef CSTOP +#undef CEOF +#undef CEOT +#undef CBRK +#undef CSUSP +#undef CDSUSP +#undef CRPRNT +#undef CFLUSH +#undef CWERASE +#undef CLNEXT +#undef CSTATUS +#undef CERASE +#undef CKILL +#undef CINTR +#undef CQUIT +#undef CSTART +#undef CSTOP +#undef CEOF +#undef CEOT +#undef CBRK +#undef CSUSP +#undef CDSUSP +#undef CRPRNT +#undef CFLUSH +#undef CWERASE +#undef CLNEXT +#undef CSTATUS +#undef CERASE +#undef CKILL +#undef CINTR +#undef CQUIT +#undef CSTART +#undef CSTOP +#undef CEOF +#undef CEOT +#undef CBRK +#undef CSUSP +#undef CDSUSP +#undef CRPRNT +#undef CFLUSH +#undef CWERASE +#undef CLNEXT +#undef CSTATUS +#undef CERASE +#undef CKILL +#undef CINTR +#undef CQUIT +#undef CSTART +#undef CSTOP +#undef CEOF +#undef CEOT +#undef CBRK +#undef CSUSP +#undef CDSUSP +#undef CRPRNT +#undef CFLUSH +#undef CWERASE +#undef CLNEXT +#undef CSTATUS +#undef CERASE +#undef CKILL +#undef CINTR +#undef CQUIT +#undef CSTART +#undef CSTOP +#undef CEOF +#undef CEOT +#undef CBRK +#undef CSUSP +#undef CDSUSP +#undef CRPRNT +#undef CFLUSH +#undef CWERASE +#undef CLNEXT +#undef CSTATUS +#undef CERASE +#undef CKILL +#undef CINTR +#undef CQUIT +#undef CSTART +#undef CSTOP +#undef CEOF +#undef CEOT +#undef CBRK +#undef CSUSP +#undef CDSUSP +#undef CRPRNT +#undef CFLUSH +#undef CWERASE +#undef CLNEXT +#undef CSTATUS +#undef CERASE +#undef CKILL +#undef CINTR +#undef CQUIT +#undef CSTART +#undef CSTOP +#undef CEOF +#undef CEOT +#undef CBRK +#undef CSUSP +#undef CDSUSP +#undef CRPRNT +#undef CFLUSH +#undef CWERASE +#undef CLNEXT +#undef CSTATUS + +#include <sys/ioctl.h> diff --git a/REORG.TODO/sysdeps/unix/bsd/cmsg_nxthdr.c b/REORG.TODO/sysdeps/unix/bsd/cmsg_nxthdr.c new file mode 100644 index 0000000000..1a542fa01a --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/cmsg_nxthdr.c @@ -0,0 +1,2 @@ +/* The Linux version is perfectly usable on 4.4 BSD. */ +#include <sysdeps/unix/sysv/linux/cmsg_nxthdr.c> diff --git a/REORG.TODO/sysdeps/unix/bsd/ftime.c b/REORG.TODO/sysdeps/unix/bsd/ftime.c new file mode 100644 index 0000000000..0d093eea71 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/ftime.c @@ -0,0 +1,40 @@ +/* Copyright (C) 1994-2017 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 <sys/timeb.h> +#include <sys/time.h> + +int +ftime (struct timeb *timebuf) +{ + struct timeval tv; + struct timezone tz; + + if (__gettimeofday (&tv, &tz) < 0) + return -1; + + timebuf->time = tv.tv_sec; + timebuf->millitm = (tv.tv_usec + 500) / 1000; + if (timebuf->millitm == 1000) + { + ++timebuf->time; + timebuf->millitm = 0; + } + timebuf->timezone = tz.tz_minuteswest; + timebuf->dstflag = tz.tz_dsttime; + return 0; +} diff --git a/REORG.TODO/sysdeps/unix/bsd/getpt.c b/REORG.TODO/sysdeps/unix/bsd/getpt.c new file mode 100644 index 0000000000..99e7af15c2 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/getpt.c @@ -0,0 +1,91 @@ +/* Copyright (C) 1998-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. + + 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 <fcntl.h> +#include <string.h> +#include <unistd.h> + + +/* Prefix for master pseudo terminal nodes. */ +#define _PATH_PTY "/dev/pty" + + +/* Letters indicating a series of pseudo terminals. */ +#ifndef PTYNAME1 +#define PTYNAME1 "pqrsPQRS" +#endif +const char __libc_ptyname1[] attribute_hidden = PTYNAME1; + +/* Letters indicating the position within a series. */ +#ifndef PTYNAME2 +#define PTYNAME2 "0123456789abcdefghijklmnopqrstuv"; +#endif +const char __libc_ptyname2[] attribute_hidden = PTYNAME2; + + +/* Open a master pseudo terminal and return its file descriptor. */ +int +__getpt (void) +{ + char buf[sizeof (_PATH_PTY) + 2]; + const char *p, *q; + char *s; + + s = __mempcpy (buf, _PATH_PTY, sizeof (_PATH_PTY) - 1); + /* s[0] and s[1] will be filled in the loop. */ + s[2] = '\0'; + + for (p = __libc_ptyname1; *p != '\0'; ++p) + { + s[0] = *p; + + for (q = __libc_ptyname2; *q != '\0'; ++q) + { + int fd; + + s[1] = *q; + + fd = __open (buf, O_RDWR); + if (fd != -1) + return fd; + + if (errno == ENOENT) + return -1; + } + } + + __set_errno (ENOENT); + return -1; +} + +#undef __getpt +weak_alias (__getpt, getpt) + +#ifndef HAVE_POSIX_OPENPT +/* We cannot define posix_openpt in general for BSD systems. */ +int +__posix_openpt (int oflag) +{ + __set_errno (ENOSYS); + return -1; +} +weak_alias (__posix_openpt, posix_openpt) + +stub_warning (posix_openpt) +#endif diff --git a/REORG.TODO/sysdeps/unix/bsd/gtty.c b/REORG.TODO/sysdeps/unix/bsd/gtty.c new file mode 100644 index 0000000000..2c32136f32 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/gtty.c @@ -0,0 +1,26 @@ +/* Copyright (C) 1991-2017 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 <sgtty.h> + +/* Fill in *PARAMS with terminal parameters associated with FD. */ +int +gtty (int fd, struct sgttyb *params) +{ + return ioctl (fd, TIOCGETP, (void *) params); +} diff --git a/REORG.TODO/sysdeps/unix/bsd/sigblock.c b/REORG.TODO/sysdeps/unix/bsd/sigblock.c new file mode 100644 index 0000000000..2647327db0 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/sigblock.c @@ -0,0 +1 @@ +#include <sysdeps/posix/sigblock.c> diff --git a/REORG.TODO/sysdeps/unix/bsd/sigsetmask.c b/REORG.TODO/sysdeps/unix/bsd/sigsetmask.c new file mode 100644 index 0000000000..47f1e36a7f --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/sigsetmask.c @@ -0,0 +1 @@ +#include <sysdeps/posix/sigsetmask.c> diff --git a/REORG.TODO/sysdeps/unix/bsd/stty.c b/REORG.TODO/sysdeps/unix/bsd/stty.c new file mode 100644 index 0000000000..8593c0e5d8 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/stty.c @@ -0,0 +1,26 @@ +/* Copyright (C) 1991-2017 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 <sgtty.h> + +/* Set the terminal parameters associated with FD to *PARAMS. */ +int +stty (int fd, const struct sgttyb *params) +{ + return ioctl (fd, TIOCSETP, (void *) params); +} diff --git a/REORG.TODO/sysdeps/unix/bsd/syscalls.list b/REORG.TODO/sysdeps/unix/bsd/syscalls.list new file mode 100644 index 0000000000..0b4d5fcd54 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/syscalls.list @@ -0,0 +1,15 @@ +# File name Caller Syscall name # args Strong name Weak names + +chflags - chflags 2 chflags +fchflags - fchflags 2 fchflags +flock - flock 2 __flock flock +getdents - getdirentries 4 __getdirentries getdirentries +getdtsz - getdtablesize 0 __getdtablesize getdtablesize +getpagesize - getpagesize 0 __getpagesize getpagesize +killpg - killpg 2 killpg +revoke - revoke 1 revoke +setlogin - setlogin 2 setlogin +sigaltstack - sigaltstack 2 __sigaltstack sigaltstack +sigpause - sigpause 1 __sigpause sigpause +sigstack - sigstack 2 sigstack +wait4 - wait4 4 __wait4 wait4 diff --git a/REORG.TODO/sysdeps/unix/bsd/tcdrain.c b/REORG.TODO/sysdeps/unix/bsd/tcdrain.c new file mode 100644 index 0000000000..ac9d9803a6 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/tcdrain.c @@ -0,0 +1,27 @@ +/* Copyright (C) 1992-2017 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 <stddef.h> +#include <sys/ioctl.h> + +/* Wait for pending output to be written on FD. */ +int +__libc_tcdrain (int fd) +{ + return __ioctl (fd, TIOCDRAIN); +} +weak_alias (__libc_tcdrain, tcdrain) diff --git a/REORG.TODO/sysdeps/unix/bsd/tcflow.c b/REORG.TODO/sysdeps/unix/bsd/tcflow.c new file mode 100644 index 0000000000..39a13f13ef --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/tcflow.c @@ -0,0 +1,55 @@ +/* Copyright (C) 1991-2017 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" + +/* Suspend or restart transmission on FD. */ +int +tcflow (int fd, int action) +{ + switch (action) + { + case TCOOFF: + return __ioctl (fd, TIOCSTOP, (void *) NULL); + case TCOON: + return __ioctl (fd, TIOCSTART, (void *) NULL); + + case TCIOFF: + case TCION: + { + /* This just writes the START or STOP character with + `write'. Is there another way to do this? */ + struct termios attr; + unsigned char c; + if (tcgetattr (fd, &attr) < 0) + return -1; + c = attr.c_cc[action == TCIOFF ? VSTOP : VSTART]; + if (c != _POSIX_VDISABLE && write (fd, &c, 1) < 1) + return -1; + return 0; + } + + default: + __set_errno (EINVAL); + return -1; + } +} diff --git a/REORG.TODO/sysdeps/unix/bsd/tcflush.c b/REORG.TODO/sysdeps/unix/bsd/tcflush.c new file mode 100644 index 0000000000..4d1e933b56 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/tcflush.c @@ -0,0 +1,48 @@ +/* Copyright (C) 1991-2017 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" +#include <sys/file.h> + +/* Flush pending data on FD. */ +int +tcflush (int fd, int queue_selector) +{ + int arg; + + switch (queue_selector) + { + case TCIFLUSH: + arg = FREAD; + break; + case TCOFLUSH: + arg = FWRITE; + break; + case TCIOFLUSH: + arg = FREAD | FWRITE; + break; + default: + __set_errno (EINVAL); + return -1; + } + + return __ioctl (fd, TIOCFLUSH, (void *) &arg); +} diff --git a/REORG.TODO/sysdeps/unix/bsd/tcgetattr.c b/REORG.TODO/sysdeps/unix/bsd/tcgetattr.c new file mode 100644 index 0000000000..1779bb9342 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/tcgetattr.c @@ -0,0 +1,38 @@ +/* Copyright (C) 1991-2017 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 <stddef.h> +#include <termios.h> + +/* These are defined both in <bits/termios.h> and in <bits/ioctls.h>. + They should have the same values, but perhaps not written the same way. */ +#undef ECHO +#undef MDMBUF +#undef TOSTOP +#undef FLUSHO +#undef PENDIN +#undef NOFLSH +#include <sys/ioctl.h> + +/* Put the state of FD into *TERMIOS_P. */ +int +__tcgetattr (int fd, struct termios *termios_p) +{ + return __ioctl (fd, TIOCGETA, termios_p); +} + +weak_alias (__tcgetattr, tcgetattr) diff --git a/REORG.TODO/sysdeps/unix/bsd/tcgetpgrp.c b/REORG.TODO/sysdeps/unix/bsd/tcgetpgrp.c new file mode 100644 index 0000000000..6ba19ed351 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/tcgetpgrp.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1991-2017 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 <sys/ioctl.h> +#include <errno.h> +#include <unistd.h> +#include <sys/types.h> + +/* Return the foreground process group ID of FD. */ +pid_t +tcgetpgrp (int fd) +{ + int pgrp; + + if (__ioctl (fd, TIOCGPGRP, &pgrp) < 0) + return (pid_t) -1; + return (pid_t) pgrp; +} +libc_hidden_def (tcgetpgrp) diff --git a/REORG.TODO/sysdeps/unix/bsd/tcsendbrk.c b/REORG.TODO/sysdeps/unix/bsd/tcsendbrk.c new file mode 100644 index 0000000000..f074c7a065 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/tcsendbrk.c @@ -0,0 +1,53 @@ +/* Copyright (C) 1991-2017 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 <signal.h> +#include <termios.h> +#include <unistd.h> +#include "bsdtty.h" +#include <sys/file.h> +#include <sys/time.h> +#include <sys/types.h> + +/* Send zero bits on FD. */ +int +tcsendbreak (int fd, int duration) +{ + struct timeval delay; + + /* The break lasts 0.25 to 0.5 seconds if DURATION is zero, + and an implementation-defined period if DURATION is nonzero. + We define a positive DURATION to be number of microseconds to break. */ + if (duration <= 0) + duration = 400000; + + delay.tv_sec = 0; + delay.tv_usec = duration; + + /* Starting sending break. */ + if (__ioctl (fd, TIOCSBRK, (void *) NULL) < 0) + return -1; + + /* Wait DURATION microseconds. */ + (void) __select (0, (fd_set *) NULL, (fd_set *) NULL, (fd_set *) NULL, + &delay); + + /* Turn off the break. */ + return __ioctl (fd, TIOCCBRK, (void *) NULL); +} diff --git a/REORG.TODO/sysdeps/unix/bsd/tcsetattr.c b/REORG.TODO/sysdeps/unix/bsd/tcsetattr.c new file mode 100644 index 0000000000..c754e80cbe --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/tcsetattr.c @@ -0,0 +1,59 @@ +/* Copyright (C) 1992-2017 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> + +/* These are defined both in <bits/termios.h> and in <bits/ioctls.h>. + They should have the same values, but perhaps not written the same way. */ +#undef ECHO +#undef MDMBUF +#undef TOSTOP +#undef FLUSHO +#undef PENDIN +#undef NOFLSH +#include <sys/ioctl.h> + + +/* Set the state of FD to *TERMIOS_P. */ +int +tcsetattr (int fd, int optional_actions, const struct termios *termios_p) +{ + struct termios myt; + + if (optional_actions & TCSASOFT) + { + myt = *termios_p; + myt.c_cflag |= CIGNORE; + termios_p = &myt; + optional_actions &= ~TCSASOFT; + } + + switch (optional_actions) + { + case TCSANOW: + return __ioctl (fd, TIOCSETA, termios_p); + + case TCSADRAIN: + return __ioctl (fd, TIOCSETAW, termios_p); + + default: + return __ioctl (fd, TIOCSETAF, termios_p); + } +} +libc_hidden_def (tcsetattr) diff --git a/REORG.TODO/sysdeps/unix/bsd/tcsetpgrp.c b/REORG.TODO/sysdeps/unix/bsd/tcsetpgrp.c new file mode 100644 index 0000000000..b99716adbe --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/tcsetpgrp.c @@ -0,0 +1,28 @@ +/* Copyright (C) 1991-2017 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 <sys/types.h> +#include <sys/ioctl.h> +#include <errno.h> +#include <unistd.h> + +/* Set the foreground process group ID of FD set PGRP_ID. */ +int +tcsetpgrp (int fd, pid_t pgrp_id) +{ + return __ioctl (fd, TIOCSPGRP, &pgrp_id); +} diff --git a/REORG.TODO/sysdeps/unix/bsd/ualarm.c b/REORG.TODO/sysdeps/unix/bsd/ualarm.c new file mode 100644 index 0000000000..133ed86597 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/ualarm.c @@ -0,0 +1,40 @@ +/* Copyright (C) 1991-2017 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 <sys/time.h> +#include <unistd.h> + +/* Set an alarm to go off (generating a SIGALRM signal) in VALUE microseconds. + If INTERVAL is nonzero, when the alarm goes off, the timer is reset to go + off every INTERVAL microseconds thereafter. + + Returns the number of microseconds remaining before the alarm. */ +useconds_t +ualarm (useconds_t value, useconds_t interval) +{ + struct itimerval timer, otimer; + + timer.it_value.tv_sec = 0; + timer.it_value.tv_usec = value; + timer.it_interval.tv_sec = 0; + timer.it_interval.tv_usec = interval; + + if (__setitimer (ITIMER_REAL, &timer, &otimer) < 0) + return -1; + + return (otimer.it_value.tv_sec * 1000000) + otimer.it_value.tv_usec; +} diff --git a/REORG.TODO/sysdeps/unix/bsd/unlockpt.c b/REORG.TODO/sysdeps/unix/bsd/unlockpt.c new file mode 100644 index 0000000000..7388c98523 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/unlockpt.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1998-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. + + 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 <paths.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + + +/* Unlock the slave pseudo terminal associated with the master pseudo + terminal specified by FD. */ +int +unlockpt (int fd) +{ + char buf[sizeof (_PATH_TTY) + 2]; + + /* BSD doesn't have a lock, but it does have `revoke'. */ + if (__ptsname_r (fd, buf, sizeof (buf))) + return -1; + return revoke (buf); +} diff --git a/REORG.TODO/sysdeps/unix/bsd/wait.c b/REORG.TODO/sysdeps/unix/bsd/wait.c new file mode 100644 index 0000000000..3daed7ee05 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/wait.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1991-2017 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 <sys/wait.h> +#include <errno.h> +#include <sys/resource.h> +#include <stddef.h> + +/* Wait for a child to die. When one does, put its status in *STAT_LOC + and return its process ID. For errors, return (pid_t) -1. */ +__pid_t +__libc_wait (int *stat_loc) +{ + return __wait4 (WAIT_ANY, stat_loc, 0, (struct rusage *) NULL); +} + +weak_alias (__libc_wait, __wait) +weak_alias (__libc_wait, wait) diff --git a/REORG.TODO/sysdeps/unix/bsd/wait3.c b/REORG.TODO/sysdeps/unix/bsd/wait3.c new file mode 100644 index 0000000000..feb17e5187 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/wait3.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1991-2017 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 <sys/wait.h> +#include <sys/types.h> + +/* Wait for a child to exit. When one does, put its status in *STAT_LOC and + return its process ID. For errors return (pid_t) -1. If USAGE is not nil, + store information about the child's resource usage (as a `struct rusage') + there. If the WUNTRACED bit is set in OPTIONS, return status for stopped + children; otherwise don't. */ +pid_t +__wait3 (int *stat_loc, int options, struct rusage *usage) +{ + return __wait4 (WAIT_ANY, stat_loc, options, usage); +} + +weak_alias (__wait3, wait3) diff --git a/REORG.TODO/sysdeps/unix/bsd/waitpid.c b/REORG.TODO/sysdeps/unix/bsd/waitpid.c new file mode 100644 index 0000000000..18f680e3c0 --- /dev/null +++ b/REORG.TODO/sysdeps/unix/bsd/waitpid.c @@ -0,0 +1,42 @@ +/* Copyright (C) 1991-2017 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 <sys/wait.h> +#include <sys/types.h> +#include <stddef.h> + +/* Wait for a child matching PID to die. + If PID is greater than 0, match any process whose process ID is PID. + If PID is (pid_t) -1, match any process. + If PID is (pid_t) 0, match any process with the + same process group as the current process. + If PID is less than -1, match any process whose + process group is the absolute value of PID. + If the WNOHANG bit is set in OPTIONS, and that child + is not already dead, return (pid_t) 0. If successful, + return PID and store the dead child's status in STAT_LOC. + Return (pid_t) -1 for errors. If the WUNTRACED bit is set in OPTIONS, + return status for stopped children; otherwise don't. */ +pid_t +__waitpid (pid_t pid, int *stat_loc, int options) +{ + return __wait4 (pid, stat_loc, options, NULL); +} + +libc_hidden_def (__waitpid) +weak_alias (__waitpid, waitpid) |