public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix IA-64 strncpy
@ 2002-11-01 12:43 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2002-11-01 12:43 UTC (permalink / raw)
  To: Roland McGrath, Ulrich Drepper, David Mosberger; +Cc: Glibc hackers

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-11-01 20:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-01 12:43 [PATCH] Fix IA-64 strncpy Jakub Jelinek

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).