public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* support INLINE_SYSCALL & INTERNAL_SYSCALL via new ia64 syscall stub
@ 2003-09-27  4:21 David Mosberger
  2003-09-30 23:58 ` Ulrich Drepper
  0 siblings, 1 reply; 3+ messages in thread
From: David Mosberger @ 2003-09-27  4:21 UTC (permalink / raw)
  To: ianw; +Cc: linux-ia64, libc-hacker

The patch below is relative to the CVS sysdep.h and adds support for
doing INLINE_SYSCALL and INTERNAL_SYSCALL via the new ia64 syscall
stubs (which enable light-weight system calls).  It's hasn't been
thoroughly tested (I'm just about to go on a trip and wanted to
getthis out), but it ought to work in theory and it has held up so
far.

With this patch, the number of "break" syscalls in libc.so drops from
~160 down to about 40 and those that are left probably won't go away
(they're in places where the new syscall stubs can't be used, e.g.,
clone2()).

Ian, do you think you could make the equivalent changes for your
NPTL-enabled libc packages?

	--david

diff -u -r1.17 sysdep.h
--- sysdeps/unix/sysv/linux/ia64/sysdep.h	16 Aug 2003 08:00:24 -0000	1.17
+++ sysdeps/unix/sysv/linux/ia64/sysdep.h	27 Sep 2003 04:12:02 -0000
@@ -23,6 +23,7 @@
 
 #include <sysdeps/unix/sysdep.h>
 #include <sysdeps/ia64/sysdep.h>
+#include <tls.h>
 
 /* For Linux we can use the system call table in the header file
 	/usr/include/asm/unistd.h
@@ -95,9 +96,32 @@
 	cmp.eq p6,p0=-1,r10;			\
 (p6)	br.cond.spnt.few __syscall_error;
 
-#define DO_CALL(num)				\
+#define DO_CALL_VIA_BREAK(num)			\
 	mov r15=num;				\
-	break __BREAK_SYSCALL;
+	break __BREAK_SYSCALL
+
+#if defined HAVE_TLS_SUPPORT && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+
+/* Use the lightweight stub only if (a) we have a suitably modern
+   thread-control block (HAVE_TLS_SUPPORT) and (b) we're not compiling
+   the runtime loader (which might do syscalls before being fully
+   relocated). */
+
+#define DO_CALL(num)				\
+	.prologue;				\
+        adds r2 = SYSINFO_OFFSET, r13;;		\
+        ld8 r2 = [r2];				\
+	.save ar.pfs, r11;			\
+        mov r11 = ar.pfs;;			\
+	.body;					\
+	mov r15 = num;				\
+        mov b7 = r2;				\
+        br.call.sptk.many b6 = b7;;		\
+	.restore sp;				\
+        mov ar.pfs = r11
+#else
+#define DO_CALL(num)				DO_CALL_VIA_BREAK(num)
+#endif
 
 #undef PSEUDO_END
 #define PSEUDO_END(name)	.endp C_SYMBOL_NAME(name);
@@ -144,6 +168,47 @@
    (non-negative) errno on error or the return value on success.
  */
 #undef INLINE_SYSCALL
+#undef INTERNAL_SYSCALL
+#if defined HAVE_TLS_SUPPORT && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+
+#define DO_INLINE_SYSCALL(name, nr, args...)							\
+    register long _r8 __asm ("r8");								\
+    register long _r10 __asm ("r10");								\
+    register long _r15 __asm ("r15") = __NR_##name;						\
+    long _retval;										\
+    LOAD_ARGS_##nr (args);									\
+    /*												\
+     * Don't specify any unwind info here.  We mark ar.pfs as clobbered.  This will force	\
+     * the compiler to save ar.pfs somewhere and emit appropriate unwind info for that		\
+     * save.											\
+     */												\
+    __asm __volatile ("adds r2 = -8, r13;;\n"							\
+		      "ld8 r2 = [r2];;\n"							\
+		      "mov b7=r2;\n"								\
+		      "br.call.sptk.many b6=b7;;\n"						\
+                      : "=r" (_r8), "=r" (_r10), "=r" (_r15) ASM_OUTARGS_##nr			\
+                      : "2" (_r15) ASM_ARGS_##nr						\
+		      : "memory", "ar.pfs" ASM_CLOBBERS_##nr);					\
+    _retval = _r8;
+
+#define INLINE_SYSCALL(name, nr, args...)	\
+  ({						\
+    DO_INLINE_SYSCALL(name, nr, args)		\
+    if (_r10 == -1)				\
+      {						\
+        __set_errno (_retval);			\
+        _retval = -1;				\
+      }						\
+    _retval; })
+
+#define INTERNAL_SYSCALL(name, err, nr, args...)	\
+  ({							\
+    DO_INLINE_SYSCALL(name, nr, args)			\
+    err = _r10;						\
+    _retval; })
+
+#else /* !new syscall-stub */
+
 #define INLINE_SYSCALL(name, nr, args...)			\
   ({								\
     register long _r8 asm ("r8");				\
@@ -164,10 +229,6 @@
       }								\
     _retval; })
 
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) long int err
-
-#undef INTERNAL_SYSCALL
 #define INTERNAL_SYSCALL(name, err, nr, args...)		\
   ({								\
     register long _r8 asm ("r8");				\
@@ -183,6 +244,11 @@
     _retval = _r8;						\
     err = _r10;							\
     _retval; })
+
+#endif /* !new syscall-stub */
+
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) long int err
 
 #undef INTERNAL_SYSCALL_ERROR_P
 #define INTERNAL_SYSCALL_ERROR_P(val, err)	(err == -1)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: support INLINE_SYSCALL & INTERNAL_SYSCALL via new ia64 syscall stub
  2003-09-27  4:21 support INLINE_SYSCALL & INTERNAL_SYSCALL via new ia64 syscall stub David Mosberger
@ 2003-09-30 23:58 ` Ulrich Drepper
  2003-10-08 21:42   ` David Mosberger
  0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Drepper @ 2003-09-30 23:58 UTC (permalink / raw)
  To: davidm; +Cc: ianw, linux-ia64, libc-hacker

David Mosberger wrote:
> The patch below is relative to the CVS sysdep.h and adds support for
> doing INLINE_SYSCALL and INTERNAL_SYSCALL via the new ia64 syscall
> stubs 

No, it doesn't.  The patch is very incomplete.  Try again, after testing.

-- 
--------------.                        ,-.            444 Castro Street
Ulrich Drepper \    ,-----------------'   \ Mountain View, CA 94041 USA
Red Hat         `--' drepper at redhat.com `---------------------------

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: support INLINE_SYSCALL & INTERNAL_SYSCALL via new ia64 syscall stub
  2003-09-30 23:58 ` Ulrich Drepper
@ 2003-10-08 21:42   ` David Mosberger
  0 siblings, 0 replies; 3+ messages in thread
From: David Mosberger @ 2003-10-08 21:42 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: davidm, ianw, linux-ia64, libc-hacker

>>>>> On Tue, 30 Sep 2003 16:57:40 -0700, Ulrich Drepper <drepper@redhat.com> said:

  Uli> David Mosberger wrote:
  >> The patch below is relative to the CVS sysdep.h and adds support for
  >> doing INLINE_SYSCALL and INTERNAL_SYSCALL via the new ia64 syscall
  >> stubs

  Uli> No, it doesn't.  The patch is very incomplete.  Try again,
  Uli> after testing.

Perhaps I wasn't clear enough: yes, the patch was for sysdep.h ONLY.
Everything else remained unchanged w.r.t. to my earlier new-syscall
stub support patch.  My patch wasn't meant for acceptance into libc,
since (as I understand it), things aren't totally settled yet in
regards to new-syscall-stub support.  Instead, my patch was meant to
show how to do inline-syscalls on ia64 with the new syscall stubs.

Sorry if the patch caused confusion.  I do hope it's useful to folks
interested in adding new-syscall-stub support to glibc.

	--david

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-10-08 21:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-27  4:21 support INLINE_SYSCALL & INTERNAL_SYSCALL via new ia64 syscall stub David Mosberger
2003-09-30 23:58 ` Ulrich Drepper
2003-10-08 21:42   ` David Mosberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).