]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
* io/Makefile (routines): Add sendfile and sendfile64.
authorRoland McGrath <roland@gnu.org>
Wed, 5 Jun 2002 08:56:41 +0000 (08:56 +0000)
committerRoland McGrath <roland@gnu.org>
Wed, 5 Jun 2002 08:56:41 +0000 (08:56 +0000)
(headers): Add sys/sendfile.h to the list.
* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Don't add it here.
* sysdeps/unix/sysv/linux/sys/sendfile.h: Moved to ...
* io/sys/sendfile.h: ... here.
* sysdeps/generic/sendfile.c: New file.
* sysdeps/generic/sendfile64.c: New file.
* sysdeps/unix/sysv/linux/Versions (GLIBC_2.1, GLIBC_2.3):
Move sendfile, sendfile64 to ...
* io/Versions (GLIBC_2.1, GLIBC_2.3): ... here.
* sysdeps/mach/hurd/sendfile.c: New file.
* sysdeps/mach/hurd/sendfile64.c: New file.

* sysdeps/mach/nanosleep.c: New file.

12 files changed:
ChangeLog
io/Makefile
io/Versions
io/sys/sendfile.h [moved from sysdeps/unix/sysv/linux/sys/sendfile.h with 91% similarity]
sysdeps/alpha/elf/configure [new file with mode: 0755]
sysdeps/generic/sendfile.c [new file with mode: 0644]
sysdeps/generic/sendfile64.c [new file with mode: 0644]
sysdeps/mach/hurd/sendfile.c [new file with mode: 0644]
sysdeps/mach/hurd/sendfile64.c [new file with mode: 0644]
sysdeps/mach/nanosleep.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/Makefile
sysdeps/unix/sysv/linux/Versions

index e63d7a36f5d9801e887cd3c594b6a15890509937..72ab84bcec8783df5a790dd0ca35f8c18cb4dec3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2002-06-05  Roland McGrath  <roland@frob.com>
+
+       * io/Makefile (routines): Add sendfile and sendfile64.
+       (headers): Add sys/sendfile.h to the list.
+       * sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Don't add it here.
+       * sysdeps/unix/sysv/linux/sys/sendfile.h: Moved to ...
+       * io/sys/sendfile.h: ... here.
+       * sysdeps/generic/sendfile.c: New file.
+       * sysdeps/generic/sendfile64.c: New file.
+       * sysdeps/unix/sysv/linux/Versions (GLIBC_2.1, GLIBC_2.3):
+       Move sendfile, sendfile64 to ...
+       * io/Versions (GLIBC_2.1, GLIBC_2.3): ... here.
+       * sysdeps/mach/hurd/sendfile.c: New file.
+       * sysdeps/mach/hurd/sendfile64.c: New file.
+
+       * sysdeps/mach/nanosleep.c: New file.
+
 2002-06-04  Roland McGrath  <roland@frob.com>
 
        * sysdeps/alpha/elf/configure.in: New file.  Check for TLS support.
index 0c39fa859f3348967cb4b6d0250474805f5d03a5..f1a619d0f7233ed1f7ee451861fe41ec003593de 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 1992-1999, 2000, 2001 Free Software Foundation, Inc.
+# Copyright (C) 1992-1999,2000,01,02 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
@@ -24,7 +24,7 @@ subdir        := io
 headers := sys/stat.h bits/stat.h sys/statfs.h bits/statfs.h sys/vfs.h \
           sys/statvfs.h bits/statvfs.h fcntl.h sys/fcntl.h bits/fcntl.h \
           poll.h sys/poll.h bits/poll.h \
-          utime.h ftw.h fts.h
+          utime.h ftw.h fts.h sys/sendfile.h
 
 routines :=                                                          \
        utime                                                         \
@@ -46,7 +46,8 @@ routines :=                                                         \
        unlink rmdir                                                  \
        ftw ftw64 fts poll                                            \
        posix_fadvise posix_fadvise64                                 \
-       posix_fallocate posix_fallocate64
+       posix_fallocate posix_fallocate64                             \
+       sendfile sendfile64
 
 # These routines will be omitted from the libc shared object.
 # Instead the static object files will be included in a special archive
index eaf25d7b1e5d93da779346dafd45cfbd366392da..b5626f359920fa7380b81181d7f070cb0943462f 100644 (file)
@@ -76,6 +76,7 @@ libc {
     open64;
 
     # s*
+    sendfile;
     statfs64; statvfs; statvfs64;
   }
   GLIBC_2.2 {
@@ -84,6 +85,10 @@ libc {
 
     __open64;
   }
+  GLIBC_2.3 {
+    # s*
+    sendfile64;
+  }
   GLIBC_PRIVATE {
     # functions which have an additional interface since they are
     # cancelable.
similarity index 91%
rename from sysdeps/unix/sysv/linux/sys/sendfile.h
rename to io/sys/sendfile.h
index 5a6fc770de98c7c5870df2a361d681a93be360f6..0627c4046465c5a06b07cc7f78025592d09bc51c 100644 (file)
@@ -1,4 +1,5 @@
-/* Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+/* sendfile -- copy data directly from one file descriptor to another
+   Copyright (C) 1998,99,01,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
diff --git a/sysdeps/alpha/elf/configure b/sysdeps/alpha/elf/configure
new file mode 100755 (executable)
index 0000000..3346b8e
--- /dev/null
@@ -0,0 +1,60 @@
+ # Local configure fragment for sysdeps/alpha/elf.
+
+if test "$usetls" != no; then
+# Check for support of thread-local storage handling in assembler and
+# linker.
+echo $ac_n "checking for Alpha TLS support""... $ac_c" 1>&6
+echo "configure:8: checking for Alpha TLS support" >&5
+if eval "test \"`echo '$''{'libc_cv_alpha_tls'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.s <<\EOF
+       .section ".tdata", "awT", @progbits
+       .globl foo
+foo:   .quad   1
+       .section ".tbss", "awT", @nobits
+       .globl bar
+bar:   .skip   8
+       .text
+baz:
+       .set nomacro
+       ldq     $27, __tls_get_addr($29)        !literal!1
+       ldq     $16, a($29)                     !tlsgd!1
+       jsr     $26, ($27), __tls_get_addr      !lituse_tlsgd!1
+
+       jsr     $26, ($27), __tls_get_addr      !lituse_tlsldm!2
+       ldq     $27, __tls_get_addr($29)        !literal!2
+       ldq     $16, b($29)                     !tlsldm!2
+
+       ldq     $16, c($29)                     !tlsgd
+       ldq     $16, d($29)                     !tlsldm
+
+       ldq     $16, e($29)                     !tlsgd!3
+       ldq     $16, f($29)                     !tlsldm!4
+
+       ldq     $16, g($29)                     !gotdtprel
+       ldah    $16, h($31)                     !dtprelhi
+       lda     $16, i($16)                     !dtprello
+       lda     $16, j($31)                     !dtprel
+
+       ldq     $16, k($29)                     !gottprel
+       ldah    $16, l($31)                     !tprelhi
+       lda     $16, m($16)                     !tprello
+       lda     $16, n($31)                     !tprel
+EOF
+if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:46: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+  libc_cv_alpha_tls=yes
+else
+  libc_cv_alpha_tls=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$libc_cv_alpha_tls" 1>&6
+if test $libc_cv_alpha_tls = yes; then
+  cat >> confdefs.h <<\EOF
+#define HAVE_TLS_SUPPORT 1
+EOF
+
+fi
+fi
diff --git a/sysdeps/generic/sendfile.c b/sysdeps/generic/sendfile.c
new file mode 100644 (file)
index 0000000..0705493
--- /dev/null
@@ -0,0 +1,32 @@
+/* sendfile -- copy data directly from one file descriptor to another
+   Copyright (C) 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/sendfile.h>
+
+/* Send COUNT bytes from file associated with IN_FD starting at OFFSET to
+   descriptor OUT_FD.  */
+ssize_t
+sendfile (int out_fd, int in_fd, off_t *offset, size_t count)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (sendfile)
+
+#include <stub-tag.h>
diff --git a/sysdeps/generic/sendfile64.c b/sysdeps/generic/sendfile64.c
new file mode 100644 (file)
index 0000000..10643bd
--- /dev/null
@@ -0,0 +1,32 @@
+/* sendfile -- copy data directly from one file descriptor to another
+   Copyright (C) 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/sendfile.h>
+
+/* Send COUNT bytes from file associated with IN_FD starting at OFFSET to
+   descriptor OUT_FD.  */
+ssize_t
+sendfile64 (int out_fd, int in_fd, off64_t *offset, size_t count)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (sendfile64)
+
+#include <stub-tag.h>
diff --git a/sysdeps/mach/hurd/sendfile.c b/sysdeps/mach/hurd/sendfile.c
new file mode 100644 (file)
index 0000000..b1849d2
--- /dev/null
@@ -0,0 +1,60 @@
+/* sendfile -- copy data directly from one file descriptor to another
+   Copyright (C) 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/sendfile.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <sys/mman.h>
+
+/* Send COUNT bytes from file associated with IN_FD starting at OFFSET to
+   descriptor OUT_FD.  */
+ssize_t
+sendfile (int out_fd, int in_fd, off_t *offset, size_t count)
+{
+  /* We just do a vanilla io_read followed by a vanilla io_write here.
+     In theory the IN_FD filesystem can return us out-of-line data that
+     we then send out-of-line to the OUT_FD filesystem and no copying
+     takes place until those pages need to be flushed or packaged by
+     that filesystem (e.g. packetized by a network socket).  However,
+     we momentarily consume COUNT bytes of our local address space,
+     which might blow if it's huge or address space is real tight.  */
+
+  char *data = 0;
+  size_t datalen = 0;
+  error_t err = HURD_DPORT_USE (in_fd,
+                               __io_read (port, &data, &datalen,
+                                          offset ? *offset : (off_t) -1,
+                                          count));
+  if (err == 0)
+    {
+      size_t nwrote;
+      if (datalen == 0)
+       return 0;
+      err = HURD_DPORT_USE (out_fd, __io_write (port, data, datalen,
+                                               (off_t) -1, &nwrote));
+      munmap (data, datalen);
+      if (err == 0)
+       {
+         if (offset)
+           *offset += datalen;
+         return nwrote;
+       }
+    }
+  return __hurd_fail (err);
+}
diff --git a/sysdeps/mach/hurd/sendfile64.c b/sysdeps/mach/hurd/sendfile64.c
new file mode 100644 (file)
index 0000000..40ce271
--- /dev/null
@@ -0,0 +1,43 @@
+/* sendfile -- copy data directly from one file descriptor to another
+   Copyright (C) 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/sendfile.h>
+#include <errno.h>
+#include <stddef.h>
+
+/* Send COUNT bytes from file associated with IN_FD starting at OFFSET to
+   descriptor OUT_FD.  */
+ssize_t
+sendfile64 (int out_fd, int in_fd, off64_t *offset, size_t count)
+{
+  if (offset == NULL)
+    return sendfile (out_fd, in_fd, NULL, count);
+  else
+    {
+      off_t ofs = *offset;
+      if (ofs != *offset)
+       {
+         __set_errno (EOVERFLOW);
+         return -1;
+       }
+      ssize_t ret = sendfile (out_fd, in_fd, &ofs, count);
+      *offset = ofs;
+      return ret;
+    }
+}
diff --git a/sysdeps/mach/nanosleep.c b/sysdeps/mach/nanosleep.c
new file mode 100644 (file)
index 0000000..8484a99
--- /dev/null
@@ -0,0 +1,53 @@
+/* nanosleep -- sleep for a period specified with a struct timespec
+   Copyright (C) 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <mach.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+int
+__nanosleep (const struct timespec *requested_time,
+            struct timespec *remaining)
+{
+  mach_port_t recv;
+  struct timeval before, after;
+  const mach_msg_timeout_t ms
+    = requested_time->tv_sec * 1000
+    + (requested_time->tv_nsec + 999999) / 1000000;
+
+  recv = __mach_reply_port ();
+
+  if (remaining && __gettimeofday (&before, NULL) < 0)
+    return -1;
+  (void) __mach_msg (NULL, MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT,
+                    0, 0, recv, ms, MACH_PORT_NULL);
+  __mach_port_destroy (mach_task_self (), recv);
+  if (remaining && __gettimeofday (&after, NULL) < 0)
+    return -1;
+
+  if (remaining)
+    {
+      timersub (&after, &before, &after);
+      TIMEVAL_TO_TIMESPEC (&after, remaining);
+    }
+
+  return 0;
+}
+weak_alias (__nanosleep, nanosleep)
index 99950086e7e936a9e8c00ae0892eb216fbb78608..68e9a1ea4cf13ced86c7fee90d1ae4f980373790 100644 (file)
@@ -20,7 +20,7 @@ sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
                  sys/kd.h sys/soundcard.h sys/vt.h \
                  sys/quota.h sys/fsuid.h \
                  scsi/sg.h scsi/scsi.h scsi/scsi_ioctl.h sys/pci.h \
-                 sys/ultrasound.h sys/sendfile.h sys/raw.h
+                 sys/ultrasound.h sys/raw.h
 
 install-others += $(inst_includedir)/bits/syscall.h
 
index 2a90387f82a5bfae5f1b5468b9845a005bca0193..53cd880425e03a516808d77170132923ba02e9ff 100644 (file)
@@ -73,9 +73,6 @@ libc {
     # n*
     ntp_adjtime; ntp_gettime;
 
-    # s*
-    sendfile;
-
     # u*
     umount2;
   }
@@ -93,8 +90,6 @@ libc {
   GLIBC_2.3 {
     # r*
     readahead;
-    # s*
-    sendfile64;
   }
   GLIBC_PRIVATE {
     # needed by libpthread.