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

carmelo at uclibc.org carmelo at uclibc.org
Wed Jun 18 17:16:06 UTC 2008


Author: carmelo
Date: 2008-06-18 10:16:06 -0700 (Wed, 18 Jun 2008)
New Revision: 22438

Log:
News syscall wrappers from trunk

Added:
   branches/uClibc-nptl/libc/sysdeps/linux/common/getdomainname.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/gethostname.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/ppoll.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/remap_file_pages.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/sched_getaffinity.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/sched_setaffinity.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/splice.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/tee.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/vmsplice.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/waitid.c


Changeset:
Added: branches/uClibc-nptl/libc/sysdeps/linux/common/getdomainname.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/getdomainname.c	                        (rev 0)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/getdomainname.c	2008-06-18 17:16:06 UTC (rev 22438)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen at uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/utsname.h>
+
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
+/* Experimentally off - libc_hidden_proto(strlen) */
+/* Experimentally off - libc_hidden_proto(strcpy) */
+libc_hidden_proto(uname)
+
+#if !defined __UCLIBC_BSD_SPECIFIC__
+extern int getdomainname (char *__name, size_t __len)
+	__THROW __nonnull ((1)) __wur;
+#endif
+extern __typeof(getdomainname) __libc_getdomainname;
+libc_hidden_proto(__libc_getdomainname)
+int __libc_getdomainname(char *name, size_t len)
+{
+  struct utsname uts;
+
+  if (name == NULL) {
+    __set_errno(EINVAL);
+    return -1;
+  }
+
+  if (uname(&uts) == -1) return -1;
+
+#ifdef __USE_GNU
+  if (strlen(uts.domainname)+1 > len) {
+#else
+  if (strlen(uts.__domainname)+1 > len) {
+#endif
+    __set_errno(EINVAL);
+    return -1;
+  }
+#ifdef __USE_GNU
+  strcpy(name, uts.domainname);
+#else
+  strcpy(name, uts.__domainname);
+#endif
+  return 0;
+}
+libc_hidden_def(__libc_getdomainname)
+#if defined __UCLIBC_BSD_SPECIFIC__
+libc_hidden_proto(getdomainname)
+weak_alias(__libc_getdomainname,getdomainname)
+libc_hidden_weak(getdomainname)
+#endif /* __UCLIBC_BSD_SPECIFIC__ */
+#endif

Added: branches/uClibc-nptl/libc/sysdeps/linux/common/gethostname.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/gethostname.c	                        (rev 0)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/gethostname.c	2008-06-18 17:16:06 UTC (rev 22438)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen at uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <string.h>
+#include <unistd.h>
+#include <sys/utsname.h>
+#include <errno.h>
+
+libc_hidden_proto(gethostname)
+
+/* Experimentally off - libc_hidden_proto(strlen) */
+/* Experimentally off - libc_hidden_proto(strcpy) */
+libc_hidden_proto(uname)
+
+int
+gethostname(char *name, size_t len)
+{
+  struct utsname uts;
+
+  if (name == NULL) {
+    __set_errno(EINVAL);
+    return -1;
+  }
+
+  if (uname(&uts) == -1) return -1;
+
+  if (strlen(uts.nodename)+1 > len) {
+    __set_errno(EINVAL);
+    return -1;
+  }
+  strcpy(name, uts.nodename);
+  return 0;
+}
+libc_hidden_def(gethostname)

Added: branches/uClibc-nptl/libc/sysdeps/linux/common/ppoll.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/ppoll.c	                        (rev 0)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/ppoll.c	2008-06-18 17:16:06 UTC (rev 22438)
@@ -0,0 +1,50 @@
+/* Copyright (C) 2006 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper at redhat.com>, 2006.
+
+   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/syscall.h>
+#include <sys/poll.h>
+
+#if defined __NR_ppoll && defined __UCLIBC_LINUX_SPECIFIC__
+
+libc_hidden_proto(ppoll)
+
+# define __NR___libc_ppoll __NR_ppoll
+static inline
+_syscall4(int, __libc_ppoll, struct pollfd *, fds,
+	nfds_t, nfds, const struct timespec *, timeout,
+	const __sigset_t *, sigmask);
+
+int
+ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
+       const __sigset_t *sigmask)
+{
+  /* The Linux kernel can in some situations update the timeout value.
+     We do not want that so use a local variable.  */
+  struct timespec tval;
+  if (timeout != NULL)
+    {
+      tval = *timeout;
+      timeout = &tval;
+    }
+
+  return __libc_ppoll(fds, nfds, timeout, sigmask);
+}
+libc_hidden_def(ppoll)
+
+#endif

Added: branches/uClibc-nptl/libc/sysdeps/linux/common/remap_file_pages.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/remap_file_pages.c	                        (rev 0)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/remap_file_pages.c	2008-06-18 17:16:06 UTC (rev 22438)
@@ -0,0 +1,16 @@
+/*
+ * remap_file_pages() for uClibc
+ *
+ * Copyright (C) 2008 Will Newton <will.newton at imgtec.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <sys/mman.h>
+#include <sys/syscall.h>
+
+#ifdef __NR_remap_file_pages
+
+_syscall5(int, remap_file_pages, void *, __start, size_t, __size,
+			int, __prot, size_t, __pgoff, int, __flags);
+
+#endif

Added: branches/uClibc-nptl/libc/sysdeps/linux/common/sched_getaffinity.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/sched_getaffinity.c	                        (rev 0)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/sched_getaffinity.c	2008-06-18 17:16:06 UTC (rev 22438)
@@ -0,0 +1,50 @@
+/* Copyright (C) 2002, 2003, 2004, 2005, 2006 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 <features.h>
+#ifdef __USE_GNU
+
+#include <sched.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+#include <string.h>
+#include <sys/param.h>
+#include <sys/types.h>
+
+/* Experimentally off - libc_hidden_proto(memset) */
+
+#define __NR___syscall_sched_getaffinity __NR_sched_getaffinity
+static inline _syscall3(int, __syscall_sched_getaffinity, __kernel_pid_t, pid,
+			size_t, cpusetsize, cpu_set_t *, cpuset);
+
+int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *cpuset)
+{
+	int res = (__syscall_sched_getaffinity(pid, MIN(INT_MAX, cpusetsize),
+					       cpuset));
+
+	if (res != -1) {
+		/* Clean the rest of the memory the kernel didn't do.  */
+		memset ((char *) cpuset + res, '\0', cpusetsize - res);
+
+		res = 0;
+	}
+	return res;
+}
+
+#endif

Added: branches/uClibc-nptl/libc/sysdeps/linux/common/sched_setaffinity.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/sched_setaffinity.c	                        (rev 0)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/sched_setaffinity.c	2008-06-18 17:16:06 UTC (rev 22438)
@@ -0,0 +1,78 @@
+/* Copyright (C) 2002, 2003, 2004, 2005, 2006 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 <features.h>
+#ifdef __USE_GNU
+
+#include <sched.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+#ifdef INTERNAL_SYSCALL /* remove this when all archs has this #defined */
+
+#include <string.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <alloca.h>
+
+libc_hidden_proto(getpid)
+
+#define __NR___syscall_sched_setaffinity __NR_sched_setaffinity
+static inline _syscall3(int, __syscall_sched_setaffinity, __kernel_pid_t, pid,
+			size_t, cpusetsize, cpu_set_t *, cpuset);
+
+static size_t __kernel_cpumask_size;
+
+int sched_setaffinity(pid_t pid, size_t cpusetsize, const cpu_set_t *cpuset)
+{
+	size_t cnt;
+	if (unlikely (__kernel_cpumask_size == 0)) {
+		INTERNAL_SYSCALL_DECL (err);
+		int res;
+		size_t psize = 128;
+		void *p = alloca (psize);
+
+		while (res = INTERNAL_SYSCALL (sched_getaffinity, err, 3, getpid (),
+					       psize, p),
+		       INTERNAL_SYSCALL_ERROR_P (res, err)
+		       && INTERNAL_SYSCALL_ERRNO (res, err) == EINVAL)
+			p = extend_alloca (p, psize, 2 * psize);
+
+		if (res == 0 || INTERNAL_SYSCALL_ERROR_P (res, err)) {
+			__set_errno (INTERNAL_SYSCALL_ERRNO (res, err));
+			return -1;
+		}
+
+		__kernel_cpumask_size = res;
+	}
+
+	/* We now know the size of the kernel cpumask_t.  Make sure the user
+	   does not request to set a bit beyond that.  */
+	for (cnt = __kernel_cpumask_size; cnt < cpusetsize; ++cnt)
+		if (((char *) cpuset)[cnt] != '\0') {
+			/* Found a nonzero byte.  This means the user request cannot be
+			   fulfilled.  */
+			__set_errno (EINVAL);
+			return -1;
+		}
+
+	return INLINE_SYSCALL (sched_setaffinity, 3, pid, cpusetsize, cpuset);
+}
+#endif
+#endif

Added: branches/uClibc-nptl/libc/sysdeps/linux/common/splice.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/splice.c	                        (rev 0)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/splice.c	2008-06-18 17:16:06 UTC (rev 22438)
@@ -0,0 +1,28 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * splice() for uClibc
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen at uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <fcntl.h>
+
+libc_hidden_proto(splice)
+
+#ifdef __NR_splice
+_syscall6(ssize_t, splice, int, __fdin, __off64_t *, __offin, int, __fdout,
+	__off64_t *, __offout, size_t, __len, unsigned int, __flags);
+#else
+ssize_t splice(int __fdin, __off64_t *__offin, int __fdout,
+	__off64_t *__offout, size_t __len, unsigned int __flags)
+{
+	__set_errno(ENOSYS);
+	return -1;
+}
+#endif
+
+libc_hidden_def(splice)
+

Added: branches/uClibc-nptl/libc/sysdeps/linux/common/tee.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/tee.c	                        (rev 0)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/tee.c	2008-06-18 17:16:06 UTC (rev 22438)
@@ -0,0 +1,16 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * tee() for uClibc
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen at uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <fcntl.h>
+
+#ifdef __NR_tee
+_syscall4(ssize_t, tee, int, __fdin, int, __fdout, size_t, __len,
+	unsigned int, __flags);
+#endif

Added: branches/uClibc-nptl/libc/sysdeps/linux/common/vmsplice.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/vmsplice.c	                        (rev 0)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/vmsplice.c	2008-06-18 17:16:06 UTC (rev 22438)
@@ -0,0 +1,28 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * vmsplice() for uClibc
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen at uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <fcntl.h>
+
+libc_hidden_proto(vmsplice)
+
+#ifdef __NR_vmsplice
+_syscall4(ssize_t, vmsplice, int, __fdout, const struct iovec *, __iov,
+	size_t, __count, unsigned int, __flags);
+#else
+ssize_t vmsplice(int __fdout, const struct iovec *__iov, size_t __count,
+	unsigned int __flags)
+{
+	__set_errno(ENOSYS);
+	return -1;
+}
+#endif
+
+libc_hidden_def(vmsplice)
+

Added: branches/uClibc-nptl/libc/sysdeps/linux/common/waitid.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/waitid.c	                        (rev 0)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/waitid.c	2008-06-18 17:16:06 UTC (rev 22438)
@@ -0,0 +1,16 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Copyright (C) 2007 Erik Andersen <andersen at uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+
+#if defined __USE_SVID || defined __USE_XOPEN
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+_syscall4(int, waitid, idtype_t, idtype, id_t, id, siginfo_t*, infop, int, options);
+#endif




More information about the uClibc-cvs mailing list