aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-06-05 08:56:41 +0000
committerRoland McGrath <roland@gnu.org>2002-06-05 08:56:41 +0000
commit7db20e36c819dc7b5973f724da43b778321ea62e (patch)
treec955fdbff29c041d481f090d345cbe4fff7b0636 /sysdeps
parent17d7201a97152b459fad11291de16cf0e6485cfa (diff)
downloadglibc-7db20e36c819dc7b5973f724da43b778321ea62e.zip
glibc-7db20e36c819dc7b5973f724da43b778321ea62e.tar.gz
glibc-7db20e36c819dc7b5973f724da43b778321ea62e.tar.bz2
* 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.
Diffstat (limited to 'sysdeps')
-rwxr-xr-xsysdeps/alpha/elf/configure60
-rw-r--r--sysdeps/generic/sendfile.c (renamed from sysdeps/unix/sysv/linux/sys/sendfile.h)41
-rw-r--r--sysdeps/generic/sendfile64.c32
-rw-r--r--sysdeps/mach/hurd/sendfile.c60
-rw-r--r--sysdeps/mach/hurd/sendfile64.c43
-rw-r--r--sysdeps/mach/nanosleep.c53
-rw-r--r--sysdeps/unix/sysv/linux/Makefile2
-rw-r--r--sysdeps/unix/sysv/linux/Versions5
8 files changed, 261 insertions, 35 deletions
diff --git a/sysdeps/alpha/elf/configure b/sysdeps/alpha/elf/configure
new file mode 100755
index 0000000..3346b8e
--- /dev/null
+++ b/sysdeps/alpha/elf/configure
@@ -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/unix/sysv/linux/sys/sendfile.h b/sysdeps/generic/sendfile.c
index 5a6fc77..0705493 100644
--- a/sysdeps/unix/sysv/linux/sys/sendfile.h
+++ b/sysdeps/generic/sendfile.c
@@ -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) 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
@@ -16,34 +17,16 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#ifndef _SYS_SENDFILE_H
-#define _SYS_SENDFILE_H 1
-
-#include <features.h>
-#include <sys/types.h>
-
-__BEGIN_DECLS
+#include <sys/sendfile.h>
/* Send COUNT bytes from file associated with IN_FD starting at OFFSET to
descriptor OUT_FD. */
-#ifndef __USE_FILE_OFFSET64
-extern ssize_t sendfile (int __out_fd, int __in_fd, off_t *__offset,
- size_t __count) __THROW;
-#else
-# ifdef __REDIRECT
-extern ssize_t __REDIRECT (sendfile,
- (int __out_fd, int __in_fd, __off64_t *__offset,
- size_t __count) __THROW,
- sendfile64);
-# else
-# define sendfile sendfile64
-# endif
-#endif
-#ifdef __USE_LARGEFILE64
-extern ssize_t sendfile64 (int __out_fd, int __in_fd, __off64_t *__offset,
- size_t __count) __THROW;
-#endif
-
-__END_DECLS
-
-#endif /* sys/sendfile.h */
+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
index 0000000..10643bd
--- /dev/null
+++ b/sysdeps/generic/sendfile64.c
@@ -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
index 0000000..b1849d2
--- /dev/null
+++ b/sysdeps/mach/hurd/sendfile.c
@@ -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
index 0000000..40ce271
--- /dev/null
+++ b/sysdeps/mach/hurd/sendfile64.c
@@ -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
index 0000000..8484a99
--- /dev/null
+++ b/sysdeps/mach/nanosleep.c
@@ -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)
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 9995008..68e9a1e 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -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
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index 2a90387..53cd880 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -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.