This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix IA-64 strncpy


Hi!

Testcase in http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=76952
shows the change in .recovery3 was wrong and in .recovery4 it used to
be off by 8 previously and then changed 8 bytes off in the other direction.
Here is why .recovery3 needs to subtract 24 from src:
#define MEMLAT 2
(p[0])          ld8.s   r[0] = [src], 8
(p[MEMLAT])     chk.s   r[MEMLAT], .recovery3
First cycle just executes the first insn, likewise second (that is src
is twice incremented by 8) and in the third cycle first it loads and
increments src by 8, then checks the load from the first cycle, at which
point src is 24 bytes bigger than the first load.
Tested using stratcliff and my test-strncpy.c (I'm ATM partly cleaning up
the various stringops testers I have and will submit them separately).

2002-11-01  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/ia64/strncpy.S: Fix recovery code.

--- libc/sysdeps/ia64/strncpy.S.jj	2002-10-02 10:26:37.000000000 +0200
+++ libc/sysdeps/ia64/strncpy.S	2002-11-01 14:53:07.000000000 +0100
@@ -217,11 +217,11 @@ ENTRY(strncpy)
 (p5)	mov	r[0] = r0
 	br.cond.sptk .back2
 .recovery3:
-	add	tmp = -MEMLAT * 8, src ;;
+	add	tmp = -(MEMLAT + 1) * 8, src ;;
 	ld8	r[MEMLAT] = [tmp]
 	br.cond.sptk .back3
 .recovery4:
-	add	tmp = -(MEMLAT - 1) * 8, src ;;
+	add	tmp = -MEMLAT * 8, src ;;
 	ld8	r[MEMLAT - 1] = [tmp]
 	br.cond.sptk .back4
 END(strncpy)

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]