Skip to content

Commit

Permalink
[IA64] strcpy returns NULL pointer and not destination pointer
Browse files Browse the repository at this point in the history
Bob Picco noted that 6edfba1
dropped the -ffreestanding compiler flag from the top level
Makefile, which allows the compiler to substitute memcpy() in
places where strcpy() is used with a known size source string.
But the ia64 memcpy() returns 0 for success, and "bytes copied"
for failure.

Fix to return the address of the destination string (like
stdlibc version, and other architectures).  There are no
places where ia64 specific code makes use of the non-standard
return value.

Signed-off-by: Ken Chen <[email protected]>
Signed-off-by: Tony Luck <[email protected]>
  • Loading branch information
Chen, Kenneth W authored and aegl committed May 5, 2006
1 parent d98550e commit 3e6e155
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions arch/ia64/lib/memcpy_mck.S
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* in1: source address
* in2: number of bytes to copy
* Output:
* 0 if success, or number of byte NOT copied if error occurred.
* for memcpy: return dest
* for copy_user: return 0 if success,
* or number of byte NOT copied if error occurred.
*
* Copyright (C) 2002 Intel Corp.
* Copyright (C) 2002 Ken Chen <[email protected]>
Expand Down Expand Up @@ -73,6 +75,7 @@ GLOBAL_ENTRY(memcpy)
and r28=0x7,in0
and r29=0x7,in1
mov f6=f0
mov retval=in0
br.cond.sptk .common_code
;;
END(memcpy)
Expand All @@ -84,15 +87,15 @@ GLOBAL_ENTRY(__copy_user)
mov f6=f1
mov saved_in0=in0 // save dest pointer
mov saved_in1=in1 // save src pointer
mov saved_in2=in2 // save len
mov retval=r0 // initialize return value
;;
.common_code:
cmp.gt p15,p0=8,in2 // check for small size
cmp.ne p13,p0=0,r28 // check dest alignment
cmp.ne p14,p0=0,r29 // check src alignment
add src0=0,in1
sub r30=8,r28 // for .align_dest
mov retval=r0 // initialize return value
mov saved_in2=in2 // save len
;;
add dst0=0,in0
add dst1=1,in0 // dest odd index
Expand Down

0 comments on commit 3e6e155

Please sign in to comment.