[PATCH] Native POSIX Thread Library(NPTL) ARM Supporting Patches (2/3)

"Hu, Boris" <[email protected]>
Newsgroups gmane.comp.lib.phil,gmane.linux.ports.arm.kernel,gmane.comp.lib.glibc.alpha
Message-ID <37FBBA5F3A361C41AB7CE44558C3448E1A1812@pdsmsx403.ccr.corp.intel.com>
Most of the code comes from Daniel Jacobowitz and Philip Blundell. Great thanks !  

$ diffstat glibc-2.3.2-arm-nptl.diff 
 linuxthreads/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h |   13 +++++-
 sysdeps/unix/sysv/linux/arm/clone.S                      |   28 +++++++++++----
 sysdeps/unix/sysv/linux/arm/ioperm.c                     |    3 +
 sysdeps/unix/sysv/linux/arm/sysdep.h                     |    2 -
 sysdeps/unix/sysv/linux/arm/system.c                     |    4 ++
 5 files changed, 41 insertions(+), 9 deletions(-)

diff -urN -X dontdiff glibc-2.3.2.orig/linuxthreads/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h glibc-2.3.2.boris/linuxthreads/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h
--- glibc-2.3.2.orig/linuxthreads/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h	Sun Jan 12 17:13:57 2003
+++ glibc-2.3.2.boris/linuxthreads/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h	Wed May 21 13:43:04 2003
@@ -24,6 +24,15 @@
 
 #if !defined NOT_IN_libc || defined IS_IN_libpthread
 
+/* We push lr onto the stack, so we have to use ldmib instead of ldmia
+   to find the saved arguments.  */
+#undef DOARGS_5
+#undef DOARGS_6
+#undef DOARGS_7
+#define DOARGS_5 str r4, [sp, $-4]!; ldr r4, [sp, $8];
+#define DOARGS_6 mov ip, sp; stmfd sp!, {r4, r5}; ldmib ip, {r4, r5};
+#define DOARGS_7 mov ip, sp; stmfd sp!, {r4, r5, r6}; ldmib ip, {r4, r5, r6};
+
 # undef PSEUDO_RET
 # define PSEUDO_RET						        \
     ldrcc pc, [sp], $4;						\
@@ -34,7 +43,7 @@
 # define PSEUDO(name, syscall_name, args)				\
   .section ".text";							\
     PSEUDO_PROLOGUE;							\
-  ENTRY (name)								\
+  ENTRY (name);							\
     SINGLE_THREAD_P_INT;						\
     bne .Lpseudo_cancel;						\
     DO_CALL (syscall_name, args);					\
@@ -110,7 +119,7 @@
   ldr reg, 2b;								\
 3:									\
   add ip, pc, ip;							\
-  ldr ip, [ip, lr];							\
+  ldr ip, [ip, reg];							\
   teq ip, #0;
 #   define SINGLE_THREAD_P_INT						\
   str lr, [sp, $-4]!;							\
diff -urN -X dontdiff glibc-2.3.2.orig/sysdeps/unix/sysv/linux/arm/clone.S glibc-2.3.2.boris/sysdeps/unix/sysv/linux/arm/clone.S
--- glibc-2.3.2.orig/sysdeps/unix/sysv/linux/arm/clone.S	Sun Dec 22 02:36:00 2002
+++ glibc-2.3.2.boris/sysdeps/unix/sysv/linux/arm/clone.S	Wed May 21 13:41:31 2003
@@ -21,13 +21,19 @@
    and invokes a function in the right context after its all over.  */
 
 #include <sysdep.h>
+	
+#include <libc-symbols.h>
+	
 #define _ERRNO_H	1
 #include <bits/errno.h>
-
-/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
-
+	
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+ *		pid_t *p_tid, struct user_desc *pd, pid_t *c_tid); 
+ * extent clone() to support nptl. 
+*/
         .text
 ENTRY(__clone)
+
 	@ sanity check args
 	cmp	r0, #0
 	cmpne	r1, #0
@@ -35,20 +41,30 @@
 	beq	PLTJMP(syscall_error)
 
 	@ insert the args onto the new stack
-	str	r3, [r1, #-4]!
-	str	r0, [r1, #-4]!
+	sub	r1, r1, #8
+	str	r3, [r1, #4]
+	@ save the function pointer as the 0th element
+	str	r0, [r1]
 
 	@ do the system call
 	@ get flags
 	mov	r0, r2
+		
+	ldr     r2, [sp, #0]  @ *p_tid 
+	ldr     r3, [sp, #8]  @ *c_tid
+
+	ldr	r4, [sp, #4]  @ *pd
+
 	@ new sp is already in r1
 	swi	SYS_ify(clone)
+
 	movs	a1, a1
 	blt	PLTJMP(C_SYMBOL_NAME(__syscall_error))
+S1:	
 	RETINSTR(movne, pc, lr)
 
 	@ pick the function arg and call address off the stack and execute
-	ldr	r0, [sp, #4]
+	ldr	r0, [sp, #4] 
 	mov	lr, pc
 	ldr 	pc, [sp]
 
diff -urN -X dontdiff glibc-2.3.2.orig/sysdeps/unix/sysv/linux/arm/ioperm.c glibc-2.3.2.boris/sysdeps/unix/sysv/linux/arm/ioperm.c
--- glibc-2.3.2.orig/sysdeps/unix/sysv/linux/arm/ioperm.c	Fri Feb 21 06:22:24 2003
+++ glibc-2.3.2.boris/sysdeps/unix/sysv/linux/arm/ioperm.c	Tue May 20 16:34:43 2003
@@ -47,6 +47,9 @@
 #include <asm/page.h>
 #include <sys/sysctl.h>
 
+#include <linux/input.h>
+
+
 #define PATH_ARM_SYSTYPE	"/etc/arm_systype"
 #define PATH_CPUINFO		"/proc/cpuinfo"
 
diff -urN -X dontdiff glibc-2.3.2.orig/sysdeps/unix/sysv/linux/arm/sysdep.h glibc-2.3.2.boris/sysdeps/unix/sysv/linux/arm/sysdep.h
--- glibc-2.3.2.orig/sysdeps/unix/sysv/linux/arm/sysdep.h	Fri Feb 21 04:22:10 2003
+++ glibc-2.3.2.boris/sysdeps/unix/sysv/linux/arm/sysdep.h	Fri May 23 14:32:47 2003
@@ -158,7 +158,7 @@
        asm volatile ("swi	%1	@ syscall " #name	\
 		     : "=r" (_a1)				\
 		     : "i" (SYS_ify(name)) ASM_ARGS_##nr	\
-		     : "a1", "memory");				\
+		     : "memory");				\
        _sys_result = _a1;					\
      }								\
      (int) _sys_result; })
diff -urN -X dontdiff glibc-2.3.2.orig/sysdeps/unix/sysv/linux/arm/system.c glibc-2.3.2.boris/sysdeps/unix/sysv/linux/arm/system.c
--- glibc-2.3.2.orig/sysdeps/unix/sysv/linux/arm/system.c	Thu Jan  1 08:00:00 1970
+++ glibc-2.3.2.boris/sysdeps/unix/sysv/linux/arm/system.c	Tue May 20 16:34:43 2003
@@ -0,0 +1,4 @@
+
+#define __ASSUME_CLONE_THREAD_FLAGS
+#include <sysdeps/unix/sysv/linux/i386/system.c>
+

Questions, comments, etc. very welcome!

TIA,

Boris (Hu Jiang Tao)
----------------------------------
This email message contains solely 
my own personal views, and not 
necessarily those of my employer.
----------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.