This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch, master, updated. glibc-2.13-228-gf1f929d


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  f1f929d74a08d6f973cec20e311401586f408d35 (commit)
      from  ce67228d570d2df88d74184e5e3618a5b2ef8704 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=f1f929d74a08d6f973cec20e311401586f408d35

commit f1f929d74a08d6f973cec20e311401586f408d35
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Sat May 28 01:43:20 2011 -0400

    Add sendmmsg syscall

diff --git a/ChangeLog b/ChangeLog
index e3d4ef7..1f474df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2011-05-28  Ulrich Drepper  <drepper@gmail.com>
 
+	* sysdeps/unix/sysv/linux/internal_sendmmsg.S: New file.
+	* sysdeps/unix/sysv/linux/sendmmsg.c: New file.
+	* sysdeps/unix/sysv/linux/Makefile [subdir=socket] (sysdep_routines):
+	Add sendmmsg and internal_sendmmsg.
+	* sysdeps/unix/sysv/linux/Versions [GLIBC_2.14]: Add sendmmsg.
+	* sysdeps/unix/sysv/linux/bits/socket.h: Declare sendmmsg.
+	* sysdeps/unix/sysv/linux/kernel-features.h: Define __ASSUME_SENDMMSG.
+
 	* sysdeps/unix/sysv/linux/syscalls.list: Add setns entry.
 	* sysdeps/unix/sysv/linux/bits/sched.h: Declare setns.
 	* sysdeps/unix/sysv/linux/Versions [GLIBC_2.14]: Add setns.
diff --git a/NEWS b/NEWS
index 90470d3..e254fee 100644
--- a/NEWS
+++ b/NEWS
@@ -30,7 +30,7 @@ Version 2.14
   Implemented by Ulrich Drepper.
 
 * New Linux interfaces: clock_adjtime, name_to_handle_at, open_by_handle_at,
-  syncfs, setns
+  syncfs, setns, sendmmsg
 
 * New locales: os_RU, bem_ZA, en_ZA, ff_SN, sw_KE, sw_TZ, lb_LU, wae_CH,
   yue_HK, lij_IT, mhr_RU
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 3b4b63f..05834e3 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -12,7 +12,8 @@ CFLAGS-malloc.c += -DMORECORE_CLEARS=2
 endif
 
 ifeq ($(subdir),socket)
-sysdep_routines += internal_accept4 recvmmsg internal_recvmmsg
+sysdep_routines += internal_accept4 recvmmsg internal_recvmmsg sendmmsg \
+		   internal_sendmmsg
 endif
 
 ifeq ($(subdir),misc)
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index 984bc4f..3a3e8e8 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -160,6 +160,8 @@ libc {
     name_to_handle_at; open_by_handle_at;
 
     setns;
+
+    sendmmsg;
   }
   GLIBC_PRIVATE {
     # functions used in other libraries
diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h
index 6373757..96d9fed 100644
--- a/sysdeps/unix/sysv/linux/bits/socket.h
+++ b/sysdeps/unix/sysv/linux/bits/socket.h
@@ -421,7 +421,7 @@ struct linger
 
 __BEGIN_DECLS
 
-/* Receive a message as described by MESSAGE from socket FD.
+/* Receive up to VLEN messages as described by VMESSAGES from socket FD.
    Returns the number of bytes read or -1 for errors.
 
    This function is a cancellation point and therefore not marked with
@@ -430,6 +430,13 @@ extern int recvmmsg (int __fd, struct mmsghdr *__vmessages,
 		     unsigned int __vlen, int __flags,
 		     __const struct timespec *__tmo);
 
+/* Send a VLEN messages as described by VMESSAGES to socket FD.
+   Return the number of datagrams successfully written or -1 for errors.
+This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int sendmmsg (int __fd, struct mmsghdr *__vmessages,
+		     unsigned int __vlen, int __flags);
+
 __END_DECLS
 
 #endif	/* bits/socket.h */
diff --git a/sysdeps/unix/sysv/linux/internal_sendmmsg.S b/sysdeps/unix/sysv/linux/internal_sendmmsg.S
new file mode 100644
index 0000000..f5152c9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/internal_sendmmsg.S
@@ -0,0 +1,14 @@
+#include <kernel-features.h>
+#include <sys/syscall.h>
+#if !defined __NR_sendmmsg && defined __NR_socketcall
+# define socket	sendmmsg
+# ifdef __ASSUME_SENDMMSG
+#  define __socket sendmmsg
+# else
+#  define __socket __internal_sendmmsg
+# endif
+# define NARGS 4
+# define NEED_CANCELLATION
+# define NO_WEAK_ALIAS
+# include <socket.S>
+#endif
diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
index d78f101..d91f581 100644
--- a/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/kernel-features.h
@@ -541,3 +541,8 @@
 #if __LINUX_KERNEL_VERSION >= 0x020624
 # define __ASSUME_PRLIMIT64	1
 #endif
+
+/* sendmmsg is available in 2.6.39.  */
+#if __LINUX_KERNEL_VERSION >= 0x020627
+# define __ASSUME_SENDMMSG	1
+#endif
diff --git a/sysdeps/unix/sysv/linux/sendmmsg.c b/sysdeps/unix/sysv/linux/sendmmsg.c
new file mode 100644
index 0000000..d809987
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sendmmsg.c
@@ -0,0 +1,96 @@
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
+
+   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 <sys/socket.h>
+
+#include <sysdep-cancel.h>
+#include <sys/syscall.h>
+#include <kernel-features.h>
+
+
+#ifdef __NR_sendmmsg
+int
+sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
+{
+  if (SINGLE_THREAD_P)
+    return INLINE_SYSCALL (sendmmsg, 4, fd, vmessages, vlen, flags);
+
+  int oldtype = LIBC_CANCEL_ASYNC ();
+
+  int result = INLINE_SYSCALL (sendmmsg, 4, fd, vmessages, vlen, flags);
+
+  LIBC_CANCEL_RESET (oldtype);
+
+  return result;
+}
+#elif defined __NR_socketcall
+# ifndef __ASSUME_SENDMMSG
+extern int __internal_sendmmsg (int fd, struct mmsghdr *vmessages,
+				unsigned int vlen, int flags)
+     attribute_hidden;
+
+static int have_sendmmsg;
+
+int
+sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
+{
+  if (__builtin_expect (have_sendmmsg >= 0, 1))
+    {
+      int ret = __internal_sendmmsg (fd, vmessages, vlen, flags);
+      /* The kernel returns -EINVAL for unknown socket operations.
+	 We need to convert that error to an ENOSYS error.  */
+      if (__builtin_expect (ret < 0, 0)
+	  && have_sendmmsg == 0
+	  && errno == EINVAL)
+	{
+	  /* Try another call, this time with an invalid file
+	     descriptor and all other parameters cleared.  This call
+	     will not cause any harm and it will return
+	     immediately.  */
+	  ret = __internal_sendmmsg (-1, 0, 0, 0);
+	  if (errno == EINVAL)
+	    {
+	      have_sendmmsg = -1;
+	      __set_errno (ENOSYS);
+	    }
+	  else
+	    {
+	      have_sendmmsg = 1;
+	      __set_errno (EINVAL);
+	    }
+	  return -1;
+	}
+      return ret;
+    }
+  __set_errno (ENOSYS);
+  return -1;
+}
+# else
+/* When __ASSUME_SENDMMSG sendmmsg is defined in internal_sendmmsg.S.  */
+# endif
+#else
+int
+sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (sendmmsg)
+#endif

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                          |    8 ++++
 NEWS                                               |    2 +-
 sysdeps/unix/sysv/linux/Makefile                   |    3 +-
 sysdeps/unix/sysv/linux/Versions                   |    2 +
 sysdeps/unix/sysv/linux/bits/socket.h              |    9 ++++-
 sysdeps/unix/sysv/linux/internal_sendmmsg.S        |   14 ++++++
 sysdeps/unix/sysv/linux/kernel-features.h          |    5 ++
 sysdeps/unix/sysv/linux/{recvmmsg.c => sendmmsg.c} |   44 +++++++++-----------
 8 files changed, 60 insertions(+), 27 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/internal_sendmmsg.S
 copy sysdeps/unix/sysv/linux/{recvmmsg.c => sendmmsg.c} (61%)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]