[Glibc-bsd-commits] r2599 - in trunk/glibc-ports/kfreebsd: . i386 x86_64

Petr Salinger ps-guest at alioth.debian.org
Fri Jun 19 13:27:37 UTC 2009


Author: ps-guest
Date: 2009-06-19 13:27:35 +0000 (Fri, 19 Jun 2009)
New Revision: 2599

Added:
   trunk/glibc-ports/kfreebsd/i386/syscalls-internal.h
   trunk/glibc-ports/kfreebsd/x86_64/syscalls-internal.h
Modified:
   trunk/glibc-ports/kfreebsd/configure
   trunk/glibc-ports/kfreebsd/configure.in
   trunk/glibc-ports/kfreebsd/not-cancel.h
   trunk/glibc-ports/kfreebsd/syscalls-inline.h
   trunk/glibc-ports/kfreebsd/syscalls.list
Log:
add restricted internal syscalls support



Modified: trunk/glibc-ports/kfreebsd/configure
===================================================================
--- trunk/glibc-ports/kfreebsd/configure	2009-06-18 10:10:32 UTC (rev 2598)
+++ trunk/glibc-ports/kfreebsd/configure	2009-06-19 13:27:35 UTC (rev 2599)
@@ -341,3 +341,9 @@
 echo "${ECHO_T}ok" >&6
   fi
 fi
+
+# We support internal syscalls.
+# It is advertised as inlined syscalls availability ...
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_INLINED_SYSCALLS 1
+_ACEOF

Modified: trunk/glibc-ports/kfreebsd/configure.in
===================================================================
--- trunk/glibc-ports/kfreebsd/configure.in	2009-06-18 10:10:32 UTC (rev 2598)
+++ trunk/glibc-ports/kfreebsd/configure.in	2009-06-19 13:27:35 UTC (rev 2599)
@@ -267,3 +267,7 @@
     AC_MSG_RESULT(ok)
   fi
 fi
+
+# We support internal syscalls.
+# It is advertised as inlined syscalls availability ...
+AC_DEFINE(HAVE_INLINED_SYSCALLS)

Added: trunk/glibc-ports/kfreebsd/i386/syscalls-internal.h
===================================================================
--- trunk/glibc-ports/kfreebsd/i386/syscalls-internal.h	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/i386/syscalls-internal.h	2009-06-19 13:27:35 UTC (rev 2599)
@@ -0,0 +1,88 @@
+/* generally used "internal syscalls"
+   Copyright (C) 2009 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.  */
+
+#ifndef KFREEBSD_INTERNAL_SYSCALLS_H
+#define KFREEBSD_INTERNAL_SYSCALLS_H
+
+#include <sys/syscall.h>
+
+/* 
+   for now, we do not care whether syscall succeeded,
+   we do not have defined 
+   INTERNAL_SYSCALL_ERROR_P and INTERNAL_SYSCALL_ERRNO
+   we do not store errno at all
+   to be sure, we return void
+*/
+
+#undef INTERNAL_SYSCALL_DECL
+#undef INTERNAL_SYSCALL_NCS
+#undef INTERNAL_SYSCALL
+#undef INTERNAL_SYSCALL_ERROR_P
+#undef INTERNAL_SYSCALL_ERRNO
+
+#define INTERNAL_SYSCALL_DECL(err)		\
+  do { } while (0)
+
+#define INTERNAL_SYSCALL(name, err, nr, args...) \
+  INTERNAL_SYSCALL_##name(name, err, nr, ##args)
+     
+     
+#define INTERNAL_SYSCALL_close(name, err, nr, fd) \
+(void)({                                        \
+  register long int _a1 = (long int) (fd);	\
+  register long int result;			\
+  asm volatile (                                \
+                "pushl %2\n\t"                  \
+                "pushl %1\n\t"                  \
+                "int $0x80\n\t"                 \
+                "popl %2\n\t"                   \
+                "popl %2\n\t"                   \
+                : "=a" (result)                 \
+                : "0" ((long int) SYS_##name),	\
+                  "d" (_a1)                   	\
+                : "memory", "cc" );             \
+  result;                                       \
+})
+
+#define INTERNAL_SYSCALL_writev(name, err, nr, fd, iov, cnt) \
+(void)({                                        \
+  register long int _a1 = (long int) (fd);	\
+  register long int _a2 = (long int) (iov);	\
+  register long int _a3 = (long int) (cnt);	\
+  register long int result;			\
+  register long int _trash;			\
+  asm volatile (                                \
+                "pushl %5\n\t"                  \
+                "pushl %4\n\t"                  \
+                "pushl %3\n\t"                  \
+                "pushl %2\n\t"                  \
+                "int $0x80\n\t"                 \
+                "addl $16,%%esp\n\t"		\
+                : "=a" (result),		\
+                  "=d" (_trash)                 \
+                : "0" ((long int) SYS_##name),	\
+                  "ri" (_a1),			\
+                  "ri" (_a2),			\
+                  "ri" (_a3)			\
+              /*   may be even "g" constraint could be used */ \
+              /*   but we have to worry about esp register and esp based address */ \
+                : "memory", "cc" );             \
+  result;                                       \
+})
+#endif

Modified: trunk/glibc-ports/kfreebsd/not-cancel.h
===================================================================
--- trunk/glibc-ports/kfreebsd/not-cancel.h	2009-06-18 10:10:32 UTC (rev 2598)
+++ trunk/glibc-ports/kfreebsd/not-cancel.h	2009-06-19 13:27:35 UTC (rev 2599)
@@ -52,12 +52,10 @@
 /* Uncancelable close.  */
 #define close_not_cancel(fd) \
   INLINE_SYSCALL (close, 1, fd)
+
 #define close_not_cancel_no_status(fd) \
-  INLINE_SYSCALL (close, 1, fd)
-/* should be
-  (void) ({ INTERNAL_SYSCALL_DECL (err);				      \
+  (void) ({ INTERNAL_SYSCALL_DECL (err); \
 	    INTERNAL_SYSCALL (close, err, 1, (fd)); })
-*/
 
 /* Uncancelable read.  */
 #define read_not_cancel(fd, buf, n) \
@@ -69,11 +67,8 @@
 
 /* Uncancelable writev.  */
 #define writev_not_cancel_no_status(fd, iov, n) \
-  INLINE_SYSCALL (writev, 3, (fd), (iov), (n))
-/* should be
-  (void) ({ INTERNAL_SYSCALL_DECL (err);				      \
+  (void) ({ INTERNAL_SYSCALL_DECL (err); \
 	    INTERNAL_SYSCALL (writev, err, 3, (fd), (iov), (n)); })
-*/
 
 /* Uncancelable fcntl.  */
 #define fcntl_not_cancel(fd, cmd, val) \

Modified: trunk/glibc-ports/kfreebsd/syscalls-inline.h
===================================================================
--- trunk/glibc-ports/kfreebsd/syscalls-inline.h	2009-06-18 10:10:32 UTC (rev 2598)
+++ trunk/glibc-ports/kfreebsd/syscalls-inline.h	2009-06-19 13:27:35 UTC (rev 2599)
@@ -24,6 +24,8 @@
 #define __need_sigset_t
 #include <signal.h>
 
+#include <syscalls-internal.h>
+
 struct iovec;
 struct rusage;
 struct timespec;
@@ -40,6 +42,9 @@
 libc_hidden_proto (__syscall_write)
 libc_hidden_proto (__syscall_writev)
 
+ssize_t __syscall_readlink(const char *path, char *buf, size_t bufsiz);
+libc_hidden_proto (__syscall_readlink)
+
 int __syscall_fcntl(int fd, int cmd, ...);
 int __syscall_fork(void);
 int __syscall_wait4(int pid, int *status, int options, struct rusage *rusage);

Modified: trunk/glibc-ports/kfreebsd/syscalls.list
===================================================================
--- trunk/glibc-ports/kfreebsd/syscalls.list	2009-06-18 10:10:32 UTC (rev 2598)
+++ trunk/glibc-ports/kfreebsd/syscalls.list	2009-06-19 13:27:35 UTC (rev 2599)
@@ -179,3 +179,4 @@
 sys_unlinkat		-	unlinkat		i:isi		__syscall_unlinkat
 sys_shm_open		-	shm_open		i:sii		__syscall_shm_open
 sys_shm_unlink		-	shm_unlink		i:s		__syscall_shm_unlink
+readlink		-	readlink       		i:spi   	__syscall_readlink __readlink readlink

Added: trunk/glibc-ports/kfreebsd/x86_64/syscalls-internal.h
===================================================================
--- trunk/glibc-ports/kfreebsd/x86_64/syscalls-internal.h	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/x86_64/syscalls-internal.h	2009-06-19 13:27:35 UTC (rev 2599)
@@ -0,0 +1,78 @@
+/* generally used "internal syscalls"
+   Copyright (C) 2009 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.  */
+
+#ifndef KFREEBSD_INTERNAL_SYSCALLS_H
+#define KFREEBSD_INTERNAL_SYSCALLS_H
+
+#include <sys/syscall.h>
+
+/* 
+   for now, we do not care whether syscall succeeded,
+   we do not have defined 
+   INTERNAL_SYSCALL_ERROR_P and INTERNAL_SYSCALL_ERRNO
+   we do not store errno at all
+   to be sure, we return void
+*/
+
+#undef INTERNAL_SYSCALL_DECL
+#undef INTERNAL_SYSCALL_NCS
+#undef INTERNAL_SYSCALL
+#undef INTERNAL_SYSCALL_ERROR_P
+#undef INTERNAL_SYSCALL_ERRNO
+
+#define INTERNAL_SYSCALL_DECL(err)		\
+  do { } while (0)
+
+#define INTERNAL_SYSCALL(name, err, nr, args...) \
+  INTERNAL_SYSCALL_##name(name, err, nr, ##args)
+
+
+#define INTERNAL_SYSCALL_close(name, err, nr, fd) \
+(void)({                                        \
+  register long int _a1 = (long int) (fd);	\
+  register long int result;			\
+  asm volatile (				\
+	"syscall"				\
+        : "=a" (result)				\
+        : "0" ((long int) SYS_##name),		\
+	  "D" (_a1)				\
+	: "memory", "cc", "cx", "dx", "r8", "r9", "r10", "r11"); \
+  result;                                       \
+})
+
+#define INTERNAL_SYSCALL_writev(name, err, nr, fd, iov, cnt) \
+(void)({                                        \
+  register long int _a1 = (long int) (fd);	\
+  register long int _a2 = (long int) (iov);	\
+  register long int _a3 = (long int) (cnt);	\
+  register long int result;			\
+  register long int _trash;			\
+  asm volatile (				\
+	"syscall"				\
+        : "=a" (result),			\
+          "=d" (_trash)				\
+        : "0" ((long int) SYS_##name),		\
+	  "D" (_a1),				\
+	  "S" (_a2),				\
+	  "d" (_a3)				\
+          /*  beware rdx is not preserved after syscall */ \
+	: "memory", "cc", "cx", "r8", "r9", "r10", "r11"); \
+  result;                                       \
+})
+#endif




More information about the Glibc-bsd-commits mailing list