aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/posix
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-02-18 01:27:10 +0000
committerRoland McGrath <roland@gnu.org>1995-02-18 01:27:10 +0000
commit28f540f45bbacd939bfd07f213bcad2bf730b1bf (patch)
tree15f07c4c43d635959c6afee96bde71fb1b3614ee /sysdeps/posix
downloadglibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.tar.xz
glibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.zip
initial import
Diffstat (limited to 'sysdeps/posix')
-rw-r--r--sysdeps/posix/Dist1
-rw-r--r--sysdeps/posix/Makefile40
-rw-r--r--sysdeps/posix/clock.c33
-rw-r--r--sysdeps/posix/ctermid.c39
-rw-r--r--sysdeps/posix/cuserid.c46
-rw-r--r--sysdeps/posix/defs.c76
-rw-r--r--sysdeps/posix/dup.c32
-rw-r--r--sysdeps/posix/dup2.c59
-rw-r--r--sysdeps/posix/fdopen.c72
-rw-r--r--sysdeps/posix/flock.c58
-rw-r--r--sysdeps/posix/fpathconf.c116
-rw-r--r--sysdeps/posix/getcwd.c366
-rw-r--r--sysdeps/posix/getdtsz.c32
-rw-r--r--sysdeps/posix/getpagesize.c31
-rw-r--r--sysdeps/posix/gettimeofday.c75
-rw-r--r--sysdeps/posix/isatty.c39
-rw-r--r--sysdeps/posix/killpg.c37
-rw-r--r--sysdeps/posix/libc_fatal.c56
-rw-r--r--sysdeps/posix/mk-stdiolim.c71
-rw-r--r--sysdeps/posix/mkstemp.c64
-rw-r--r--sysdeps/posix/mktemp.c64
-rw-r--r--sysdeps/posix/pipestream.c223
-rw-r--r--sysdeps/posix/raise.c28
-rw-r--r--sysdeps/posix/readv.c68
-rw-r--r--sysdeps/posix/remove.c40
-rw-r--r--sysdeps/posix/rename.c50
-rw-r--r--sysdeps/posix/sigblock.c55
-rw-r--r--sysdeps/posix/sigintr.c57
-rw-r--r--sysdeps/posix/signal.c47
-rw-r--r--sysdeps/posix/sigpause.c45
-rw-r--r--sysdeps/posix/sigsetmask.c55
-rw-r--r--sysdeps/posix/sigsuspend.c51
-rw-r--r--sysdeps/posix/sigvec.c162
-rw-r--r--sysdeps/posix/sleep.c106
-rw-r--r--sysdeps/posix/stdio_init.c70
-rw-r--r--sysdeps/posix/sysconf.c183
-rw-r--r--sysdeps/posix/system.c145
-rw-r--r--sysdeps/posix/tempname.c208
-rw-r--r--sysdeps/posix/truncate.c41
-rw-r--r--sysdeps/posix/ttyname.c82
-rw-r--r--sysdeps/posix/wait.c31
-rw-r--r--sysdeps/posix/wait3.c42
-rw-r--r--sysdeps/posix/writev.c64
43 files changed, 3260 insertions, 0 deletions
diff --git a/sysdeps/posix/Dist b/sysdeps/posix/Dist
new file mode 100644
index 0000000000..d003c6e781
--- /dev/null
+++ b/sysdeps/posix/Dist
@@ -0,0 +1 @@
+mk-stdiolim.c
diff --git a/sysdeps/posix/Makefile b/sysdeps/posix/Makefile
new file mode 100644
index 0000000000..fd1b3f257a
--- /dev/null
+++ b/sysdeps/posix/Makefile
@@ -0,0 +1,40 @@
+# Copyright (C) 1991, 1992, 1993, 1994 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., 675 Mass Ave,
+# Cambridge, MA 02139, USA.
+
+$(common-objpfx)stdio_lim.h: $(common-objpfx)mk-stdiolim
+ $(dir $<)$(notdir $<) > $@-t
+ mv $@-t $@
+
+ifdef subdir
+objdir-CPPFLAGS = $(CPPFLAGS) # Already has appropriate `..'s.
+else
+objdir-CPPFLAGS = $(patsubst -I/..//%,-I/%,$(CPPFLAGS:-I%=-I../%))
+endif
+# Turn into a version that works when cd'd into $(objdir).
+cded-objdir-CPPFLAGS = $(patsubst -I$$cwd//%,-I/%,\
+ $(patsubst -I%,-I$$cwd/%,$(CPPFLAGS)))
+# $(BUILD_CFLAGS) needs to come last because it contains unwanted -Is.
+$(common-objpfx)mk-stdiolim: $(sysdep_dir)/posix/mk-stdiolim.c \
+ posix1_lim.h local_lim.h
+ cwd=`pwd`; cd $(common-objdir); \
+ $(BUILD_CC) $(cded-objdir-CPPFLAGS) $(BUILD_CFLAGS) \
+ $$cwd/$< -o $(patsubst $(common-objpfx)%,%,$@)
+
+
+common-generated := $(common-generated) stdio_lim.h mk-stdiolim
+before-compile := $(before-compile) $(common-objpfx)stdio_lim.h
diff --git a/sysdeps/posix/clock.c b/sysdeps/posix/clock.c
new file mode 100644
index 0000000000..c34593b9eb
--- /dev/null
+++ b/sysdeps/posix/clock.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1992 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., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#include <ansidecl.h>
+#include <sys/times.h>
+#include <time.h>
+
+/* Return the time used by the program so far (user time + system time). */
+clock_t
+DEFUN_VOID(clock)
+{
+ struct tms buf;
+
+ if (__times(&buf) < 0)
+ return (clock_t) -1;
+
+ return ((buf.tms_utime + buf.tms_stime) * CLK_TCK * CLOCKS_PER_SEC);
+}
diff --git a/sysdeps/posix/ctermid.c b/sysdeps/posix/ctermid.c
new file mode 100644
index 0000000000..8e96694841
--- /dev/null
+++ b/sysdeps/posix/ctermid.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991 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., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+#include <string.h>
+
+
+/* Return the name of the controlling terminal.
+ If S is not NULL, the name is copied into it (it should be at
+ least L_ctermid bytes long), otherwise a static buffer is used. */
+char *
+DEFUN(ctermid, (s), char *s)
+{
+ static char name[L_ctermid];
+
+ if (name[0] == '\0')
+ (void) strcpy(name, "/dev/tty");
+
+ if (s == NULL)
+ return(name);
+
+ return(strcpy(s, name));
+}
diff --git a/sysdeps/posix/cuserid.c b/sysdeps/posix/cuserid.c
new file mode 100644
index 0000000000..b874e909ce
--- /dev/null
+++ b/sysdeps/posix/cuserid.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991 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., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+#include <string.h>
+#include <pwd.h>
+
+extern int EXFUN(geteuid, (NOARGS));
+
+
+/* Return the username of the caller.
+ If S is not NULL, it points to a buffer of at least L_cuserid bytes
+ into which the name is copied; otherwise, a static buffer is used. */
+char *
+DEFUN(cuserid, (s), char *s)
+{
+ static char name[L_cuserid];
+ struct passwd *pwent = getpwuid(geteuid());
+
+ if (pwent == NULL)
+ {
+ if (s != NULL)
+ s[0] = '\0';
+ return NULL;
+ }
+
+ if (s == NULL)
+ s = name;
+ return strcpy(s, pwent->pw_name);
+}
diff --git a/sysdeps/posix/defs.c b/sysdeps/posix/defs.c
new file mode 100644
index 0000000000..fcbaf16f69
--- /dev/null
+++ b/sysdeps/posix/defs.c
@@ -0,0 +1,76 @@
+/* Definitions of global stdio data structures.
+
+Copyright (C) 1991, 1993 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., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <unistd.h>
+
+/* This file defines all the global internal variables for stdio. */
+
+/* Standard streams. */
+#define READ 1, 0
+#define WRITE 0, 1
+#define BUFFERED 0
+#define UNBUFFERED 1
+#define stdstream(name, next, fd, readwrite, unbuffered) \
+ { \
+ _IOMAGIC, \
+ NULL, NULL, NULL, NULL, 0, \
+ (PTR) fd, \
+ { readwrite, /* ... */ }, \
+ { NULL, NULL, NULL, NULL, NULL }, \
+ { NULL, NULL }, \
+ -1, -1, \
+ (next), \
+ NULL, '\0', 0, \
+ 0, 0, unbuffered, 0, 0, 0, 0 \
+ }
+static FILE stdstreams[3] =
+ {
+ stdstream (&stdstreams[0], &stdstreams[1], STDIN_FILENO, READ, BUFFERED),
+ stdstream (&stdstreams[1], &stdstreams[2], STDOUT_FILENO, WRITE, BUFFERED),
+ stdstream (&stdstreams[2], NULL, STDERR_FILENO, WRITE, UNBUFFERED),
+ };
+FILE *stdin = &stdstreams[0];
+FILE *stdout = &stdstreams[1];
+FILE *stderr = &stdstreams[2];
+
+/* Pointer to the first stream in the list. */
+FILE *__stdio_head = &stdstreams[0];
+
+/* This function MUST be in this file!
+ This is because we want _cleanup to go into the __libc_atexit set
+ when any stdio code is used (and to use any stdio code, one must reference
+ something defined in this file), and since only local symbols can be made
+ set elements, having the set element stab entry here and _cleanup elsewhere
+ loses; and having them both elsewhere loses because there is no reference
+ to cause _cleanup to be linked in. */
+
+void
+DEFUN_VOID(_cleanup)
+{
+ (void) fclose((FILE *) NULL);
+}
+
+
+#ifdef HAVE_GNU_LD
+text_set_element(__libc_atexit, _cleanup);
+#endif
diff --git a/sysdeps/posix/dup.c b/sysdeps/posix/dup.c
new file mode 100644
index 0000000000..73c5900f9c
--- /dev/null
+++ b/sysdeps/posix/dup.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 1995 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., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+
+/* Duplicate FD, returning a new file descriptor open on the same file. */
+int
+DEFUN(__dup, (fd), int fd)
+{
+ return fcntl(fd, F_DUPFD, 0);
+}
+
+weak_alias (__dup, dup)
diff --git a/sysdeps/posix/dup2.c b/sysdeps/posix/dup2.c
new file mode 100644
index 0000000000..c0c6b2a0f6
--- /dev/null
+++ b/sysdeps/posix/dup2.c
@@ -0,0 +1,59 @@
+/* Copyright (C) 1991, 1992, 1993, 1995 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., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <unistd.h>
+
+
+/* Duplicate FD to FD2, closing the old FD2 and making FD2 be
+ open the same file as FD is. Return FD2 or -1. */
+int
+DEFUN(__dup2, (fd, fd2), int fd AND int fd2)
+{
+ int save;
+
+ if (fd2 < 0
+#ifdef OPEN_MAX
+ || fd2 >= OPEN_MAX
+#endif
+)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ /* Check if FD is kosher. */
+ if (fcntl (fd, F_GETFL) < 0)
+ return -1;
+
+ if (fd == fd2)
+ return fd2;
+
+ /* This is not atomic. */
+
+ save = errno;
+ (void) close (fd2);
+ errno = save;
+
+ return fcntl (fd, F_DUPFD, fd2);
+}
+
+weak_alias (__dup2, dup2)
diff --git a/sysdeps/posix/fdopen.c b/sysdeps/posix/fdopen.c
new file mode 100644
index 0000000000..ad746ec371
--- /dev/null
+++ b/sysdeps/posix/fdopen.c
@@ -0,0 +1,72 @@
+/* Copyright (C) 1991, 1992, 1993 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 PARTICULA