svn commit: branches/uClibc-nptl/libc: inet sysdeps/linux/common

carmelo at uclibc.org carmelo at uclibc.org
Thu Nov 22 16:09:57 UTC 2007


Author: carmelo
Date: 2007-11-22 08:09:55 -0800 (Thu, 22 Nov 2007)
New Revision: 20472

Log:
Push back changes to add cancellation handling.
It still needs to reach an agreement on the final
solution, anyway this code have been put int to be shared
for the mips-sh4 merge

Signed-off-by: Carmelo Amoroso <carmelo.amoroso at st.com>


Modified:
   branches/uClibc-nptl/libc/inet/Makefile.in
   branches/uClibc-nptl/libc/inet/socketcalls.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/Makefile.in
   branches/uClibc-nptl/libc/sysdeps/linux/common/fsync.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/ioctl.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/msync.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/nanosleep.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/pause.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/poll.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/select.c


Changeset:
Modified: branches/uClibc-nptl/libc/inet/Makefile.in
===================================================================
--- branches/uClibc-nptl/libc/inet/Makefile.in	2007-11-22 09:57:06 UTC (rev 20471)
+++ branches/uClibc-nptl/libc/inet/Makefile.in	2007-11-22 16:09:55 UTC (rev 20472)
@@ -30,11 +30,6 @@
 	listen.c recv.c recvfrom.c recvmsg.c send.c sendmsg.c sendto.c \
 	setsockopt.c shutdown.c socket.c socketpair.c 
 
-ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
-CSRC := $(filter-out accept.c connect.c recv.c recvfrom.c recvmsg.c send.c \
-	  sendmsg.c sendto.c, $(CSRC))
-endif
-
 INET_DIR := $(top_srcdir)libc/inet
 INET_OUT := $(top_builddir)libc/inet
 

Modified: branches/uClibc-nptl/libc/inet/socketcalls.c
===================================================================
--- branches/uClibc-nptl/libc/inet/socketcalls.c	2007-11-22 09:57:06 UTC (rev 20471)
+++ branches/uClibc-nptl/libc/inet/socketcalls.c	2007-11-22 16:09:55 UTC (rev 20472)
@@ -33,6 +33,12 @@
 #define SYS_RECVMSG     17
 #endif
 
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__ 
+#include <sysdep-cancel.h>
+#include <pthreadP.h>
+#else
+#define SINGLE_THREAD_P 1
+#endif
 
 #ifdef L_accept
 extern __typeof(accept) __libc_accept;
@@ -47,7 +53,17 @@
 	args[0] = s;
 	args[1] = (unsigned long) addr;
 	args[2] = (unsigned long) addrlen;
-	return __socketcall(SYS_ACCEPT, args);
+	
+	if (SINGLE_THREAD_P)
+		return __socketcall(SYS_ACCEPT, args);
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+	int oldtype = LIBC_CANCEL_ASYNC ();
+	int result = __socketcall(SYS_ACCEPT, args);
+	LIBC_CANCEL_RESET (oldtype);
+	return result;
+#endif		
+		
 }
 #endif
 libc_hidden_proto(accept)
@@ -86,7 +102,16 @@
 	args[0] = sockfd;
 	args[1] = (unsigned long) saddr;
 	args[2] = addrlen;
+
+if (SINGLE_THREAD_P)
 	return __socketcall(SYS_CONNECT, args);
+		
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+	int oldtype = LIBC_CANCEL_ASYNC ();
+	int result = __socketcall(SYS_CONNECT, args);
+	LIBC_CANCEL_RESET (oldtype);
+	return result;
+#endif		
 }
 #endif
 libc_hidden_proto(connect)
@@ -179,7 +204,16 @@
 	args[1] = (unsigned long) buffer;
 	args[2] = len;
 	args[3] = flags;
-	return (__socketcall(SYS_RECV, args));
+	
+	if (SINGLE_THREAD_P)
+		return (__socketcall(SYS_RECV, args));
+	
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+	int oldtype = LIBC_CANCEL_ASYNC ();
+	int result = __socketcall(SYS_RECV, args);
+	LIBC_CANCEL_RESET (oldtype);
+	return result;
+#endif		
 }
 #elif defined(__NR_recvfrom)
 libc_hidden_proto(recvfrom)
@@ -212,7 +246,16 @@
 	args[3] = flags;
 	args[4] = (unsigned long) to;
 	args[5] = (unsigned long) tolen;
+
+if (SINGLE_THREAD_P)
 	return (__socketcall(SYS_RECVFROM, args));
+	
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+	int oldtype = LIBC_CANCEL_ASYNC ();
+	int result = __socketcall(SYS_RECVFROM, args);
+	LIBC_CANCEL_RESET (oldtype);
+	return result;
+#endif		
 }
 #endif
 libc_hidden_proto(recvfrom)
@@ -233,7 +276,16 @@
 	args[0] = sockfd;
 	args[1] = (unsigned long) msg;
 	args[2] = flags;
-	return (__socketcall(SYS_RECVMSG, args));
+	
+if (SINGLE_THREAD_P)
+	return (__socketcall(SYS_RECVMSG, args));	
+	
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+	int oldtype = LIBC_CANCEL_ASYNC ();
+	int result = __socketcall(SYS_RECVMSG, args);
+	LIBC_CANCEL_RESET (oldtype);
+	return result;
+#endif		
 }
 #endif
 libc_hidden_proto(recvmsg)
@@ -256,7 +308,16 @@
 	args[1] = (unsigned long) buffer;
 	args[2] = len;
 	args[3] = flags;
+	
+if (SINGLE_THREAD_P)
 	return (__socketcall(SYS_SEND, args));
+		
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+	int oldtype = LIBC_CANCEL_ASYNC ();
+	int result = __socketcall(SYS_SEND, args);
+	LIBC_CANCEL_RESET (oldtype);
+	return result;
+#endif		
 }
 #elif defined(__NR_sendto)
 libc_hidden_proto(sendto)
@@ -283,7 +344,16 @@
 	args[0] = sockfd;
 	args[1] = (unsigned long) msg;
 	args[2] = flags;
+	
+if (SINGLE_THREAD_P)
 	return (__socketcall(SYS_SENDMSG, args));
+	
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+	int oldtype = LIBC_CANCEL_ASYNC ();
+	int result = __socketcall(SYS_SENDMSG, args);
+	LIBC_CANCEL_RESET (oldtype);
+	return result;
+#endif		
 }
 #endif
 libc_hidden_proto(sendmsg)
@@ -310,7 +380,16 @@
 	args[3] = flags;
 	args[4] = (unsigned long) to;
 	args[5] = tolen;
+	
+if (SINGLE_THREAD_P)
 	return (__socketcall(SYS_SENDTO, args));
+	
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+	int oldtype = LIBC_CANCEL_ASYNC ();
+	int result = __socketcall(SYS_SENDTO, args);
+	LIBC_CANCEL_RESET (oldtype);
+	return result;
+#endif		
 }
 #endif
 libc_hidden_proto(sendto)

Modified: branches/uClibc-nptl/libc/sysdeps/linux/common/Makefile.in
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/Makefile.in	2007-11-22 09:57:06 UTC (rev 20471)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/Makefile.in	2007-11-22 16:09:55 UTC (rev 20472)
@@ -25,12 +25,15 @@
 endif
 
 ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
-CSRC := $(filter-out fork.c getpid.c raise.c pause.c open.c close.c	\
-	  read.c write.c nanosleep.c __syscall_rt_sigaction.c msync.c	\
-	  lseek.c __syscall_fcntl64.c, $(CSRC))
+CSRC := $(filter-out fork.c getpid.c raise.c open.c close.c read.c write.c waitpid.c, $(CSRC))
+
 endif
 
+ifeq ($(TARGET_ARCH),sh)
+CSRC := $(filter-out longjmp.c vfork.c,$(CSRC))
+endif
 
+
 # fails for some reason
 ifneq ($(strip $(ARCH_OBJS)),)
 CSRC := $(filter-out $(notdir $(ARCH_OBJS:.o=.c)),$(CSRC))

Modified: branches/uClibc-nptl/libc/sysdeps/linux/common/fsync.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/fsync.c	2007-11-22 09:57:06 UTC (rev 20471)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/fsync.c	2007-11-22 16:09:55 UTC (rev 20472)
@@ -9,27 +9,29 @@
 
 #include "syscalls.h"
 #include <unistd.h>
-#ifdef __UCLIBC__HAS_THREADS__
-# include <sysdep-cancel.h>
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include "sysdep-cancel.h"
+#else
+#define SINGLE_THREAD_P 1
 #endif
 
+#define __NR___syscall_fsync __NR_fsync
+static inline _syscall1(int, __syscall_fsync, int, fd);
+
 extern __typeof(fsync) __libc_fsync;
-#ifdef __UCLIBC__HAS_THREADS__
-int __libc_fsync (int fd)
+
+int __libc_fsync(int fd)
 {
 	if (SINGLE_THREAD_P)
-		return INLINE_SYSCALL (fsync, 1, fd);
+		return __syscall_fsync(fd);
 
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
 	int oldtype = LIBC_CANCEL_ASYNC ();
-
-	int result = INLINE_SYSCALL (fsync, 1, fd);
-
+	int result = __syscall_fsync(fd);
 	LIBC_CANCEL_RESET (oldtype);
-
 	return result;
+#endif
 }
-#else
-# define __NR___libc_fsync __NR_fsync
-_syscall1(int, __libc_fsync, int, fd);
-#endif
+
 weak_alias(__libc_fsync, fsync)

Modified: branches/uClibc-nptl/libc/sysdeps/linux/common/ioctl.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/ioctl.c	2007-11-22 09:57:06 UTC (rev 20471)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/ioctl.c	2007-11-22 16:09:55 UTC (rev 20472)
@@ -11,6 +11,12 @@
 #include <stdarg.h>
 #include <sys/ioctl.h>
 
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep-cancel.h>
+#else
+#define SINGLE_THREAD_P 1
+#endif
+
 libc_hidden_proto(ioctl)
 
 #define __NR___syscall_ioctl __NR_ioctl
@@ -19,13 +25,22 @@
 
 int ioctl(int fd, unsigned long int request, ...)
 {
-    void *arg;
-    va_list list;
+	void *arg;
+	va_list list;
 
-    va_start(list, request);
-    arg = va_arg(list, void *);
+	va_start(list, request);
+	arg = va_arg(list, void *);
 
-    va_end(list);
-    return __syscall_ioctl(fd, request, arg);
+	va_end(list);
+
+	if (SINGLE_THREAD_P)
+		return __syscall_ioctl(fd, request, arg);
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+	int oldtype = LIBC_CANCEL_ASYNC ();
+	int result = __syscall_ioctl(fd, request, arg);
+	LIBC_CANCEL_RESET (oldtype);
+	return result;
+#endif
 }
 libc_hidden_def(ioctl)

Modified: branches/uClibc-nptl/libc/sysdeps/linux/common/msync.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/msync.c	2007-11-22 09:57:06 UTC (rev 20471)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/msync.c	2007-11-22 16:09:55 UTC (rev 20472)
@@ -11,7 +11,27 @@
 #include <unistd.h>
 #include <sys/mman.h>
 
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep-cancel.h>
+#else
+#define SINGLE_THREAD_P 1
+#endif
+
+#define __NR___syscall_msync __NR_msync
+static inline _syscall3(int, __syscall_msync, void *, addr, size_t, length,
+						int, flags);
+
 extern __typeof(msync) __libc_msync;
-#define __NR___libc_msync __NR_msync
-_syscall3(int, __libc_msync, void *, addr, size_t, length, int, flags);
+int __libc_msync(void * addr, size_t length, int flags)
+{
+	if (SINGLE_THREAD_P)
+	return __syscall_msync(addr, length, flags);
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+	int oldtype = LIBC_CANCEL_ASYNC ();
+	int result = __syscall_msync(addr, length, flags);
+	LIBC_CANCEL_RESET (oldtype);
+	return result;
+#endif
+}
 weak_alias(__libc_msync,msync)

Modified: branches/uClibc-nptl/libc/sysdeps/linux/common/nanosleep.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/nanosleep.c	2007-11-22 09:57:06 UTC (rev 20471)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/nanosleep.c	2007-11-22 16:09:55 UTC (rev 20472)
@@ -10,10 +10,32 @@
 #include "syscalls.h"
 #include <time.h>
 
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__ 
+#include <sysdep-cancel.h>
+#include <pthreadP.h>
+#else
+#define SINGLE_THREAD_P 1
+#endif
+
+#define __NR___syscall_nanosleep __NR_nanosleep
+static inline _syscall2(int, __syscall_nanosleep, const struct timespec *, req,
+						struct timespec *, rem);
+
 extern __typeof(nanosleep) __libc_nanosleep;
-#define __NR___libc_nanosleep __NR_nanosleep
-_syscall2(int, __libc_nanosleep, const struct timespec *, req,
-		  struct timespec *, rem);
+
+int __libc_nanosleep(const struct timespec *req, struct timespec *rem)
+{
+	if (SINGLE_THREAD_P)
+		return __syscall_nanosleep(req, rem);
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+	int oldtype = LIBC_CANCEL_ASYNC ();
+	int result = __syscall_nanosleep(req, rem);
+	LIBC_CANCEL_RESET (oldtype);
+	return result;
+#endif
+}
+
 libc_hidden_proto(nanosleep)
 weak_alias(__libc_nanosleep,nanosleep)
 libc_hidden_weak(nanosleep)

Modified: branches/uClibc-nptl/libc/sysdeps/linux/common/pause.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/pause.c	2007-11-22 09:57:06 UTC (rev 20471)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/pause.c	2007-11-22 16:09:55 UTC (rev 20472)
@@ -7,22 +7,25 @@
  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  */
 
-#define __UCLIBC_HIDE_DEPRECATED__
-#include "syscalls.h"
+#include <signal.h>
 #include <unistd.h>
+#include <sysdep-cancel.h>
 
-extern __typeof(pause) __libc_pause;
-#ifdef __NR_pause
-#define __NR___libc_pause __NR_pause
-_syscall0(int, __libc_pause);
-#else
-#include <signal.h>
-libc_hidden_proto(__sigpause)
-libc_hidden_proto(sigblock)
+/* Suspend the process until a signal arrives.
+   This always returns -1 and sets errno to EINTR.  */
+int
+__libc_pause (void)
+{
+  sigset_t set;
 
-int __libc_pause(void)
-{
-	return (__sigpause(sigblock(0), 0));
+  __sigemptyset (&set);
+  sigprocmask (SIG_BLOCK, NULL, &set);
+
+  /* pause is a cancellation point, but so is sigsuspend.
+     So no need for anything special here.  */
+
+  return sigsuspend (&set);
 }
-#endif
-weak_alias(__libc_pause,pause)
+weak_alias (__libc_pause, pause)
+
+LIBC_CANCEL_HANDLED ();		/* sigsuspend handles our cancellation.  */

Modified: branches/uClibc-nptl/libc/sysdeps/linux/common/poll.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/poll.c	2007-11-22 09:57:06 UTC (rev 20471)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/poll.c	2007-11-22 16:09:55 UTC (rev 20472)
@@ -20,31 +20,33 @@
 #include "syscalls.h"
 #include <sys/poll.h>
 
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep-cancel.h>
+#else
+#define SINGLE_THREAD_P 1
+#endif 
+
 libc_hidden_proto(poll)
 
 #ifdef __NR_poll
-# ifdef __UCLIBC__HAS_THREADS__
-# include <sysdep-cancel.h>
 
-/* The real implementation.  */
-int poll (struct pollfd *fds, nfsd_t nfds, int timeout)
+#define __NR___syscall_poll __NR_poll
+static inline _syscall3(int, __syscall_poll, struct pollfd *, fds,
+			unsigned long int, nfds, int, timeout);
+
+int poll(struct pollfd *fds, nfds_t nfds, int timeout)
 {
-	if (SINGLE_THREAD_P)
-		return INLINE_SYSCALL (poll, 3, fds, nfds, timeout);
+    if (SINGLE_THREAD_P)
+	return __syscall_poll(fds, nfds, timeout);
 
-	int oldtype = LIBC_CANCEL_ASYNC ();
-
-	int result = INLINE_SYSCALL (poll, 3, fds, nfds, timeout);
-
-	LIBC_CANCEL_RESET (oldtype);
-
-	return result;
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+    int oldtype = LIBC_CANCEL_ASYNC ();
+    int result = __syscall_poll(fds, nfds, timeout);
+    LIBC_CANCEL_RESET (oldtype);
+    return result;
+#endif
 }
-# else
-_syscall3(int, poll, struct pollfd *, fds,
-	unsigned long int, nfds, int, timeout);
-# endif
-#else
+#else /* !__NR_poll */
 
 #include <alloca.h>
 #include <sys/types.h>

Modified: branches/uClibc-nptl/libc/sysdeps/linux/common/select.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/select.c	2007-11-22 09:57:06 UTC (rev 20471)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/select.c	2007-11-22 16:09:55 UTC (rev 20472)
@@ -10,12 +10,36 @@
 #include "syscalls.h"
 #include <sys/select.h>
 
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep-cancel.h>
+#else
+#define SINGLE_THREAD_P 1
+#endif
+
+
 libc_hidden_proto(select)
 
 #ifdef __NR__newselect
 # undef __NR_select
 # define __NR_select __NR__newselect
 #endif
-_syscall5(int, select, int, n, fd_set *, readfds, fd_set *, writefds,
-		  fd_set *, exceptfds, struct timeval *, timeout);
+
+#define __NR___syscall_select __NR_select
+static inline _syscall5(int, __syscall_select, int, n, fd_set *, readfds,
+		fd_set *, writefds, fd_set *, exceptfds, struct timeval *, timeout);
+
+int select(int n, fd_set * readfds, fd_set * writefds, fd_set * exceptfds,
+		   struct timeval * timeout)
+{
+	if (SINGLE_THREAD_P)
+		return __syscall_select(n, readfds, writefds, exceptfds, timeout);
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+	int oldtype = LIBC_CANCEL_ASYNC ();
+	int result = __syscall_select(n, readfds, writefds, exceptfds, timeout);
+	LIBC_CANCEL_RESET (oldtype);
+	return result;
+#endif
+}
+
 libc_hidden_def(select)




More information about the uClibc-cvs mailing list