From b8637f43b08b1407cde47fc0477a1100b617f71f Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 30 Nov 2012 09:31:38 +0000 Subject: [PATCH] * libc/machine/arm/strcmp.S (compute_return_value): Fix return value. * testsuite/newlib.string/strcmp-1.c (main): Add new test cases. --- newlib/ChangeLog | 5 ++++ newlib/libc/machine/arm/strcmp.S | 12 +++++++- newlib/testsuite/newlib.string/strcmp-1.c | 36 +++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index c6a9758d7..c376d9ba9 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,8 @@ +2012-11-30 Greta Yorsh + + * libc/machine/arm/strcmp.S (compute_return_value): Fix return value. + * testsuite/newlib.string/strcmp-1.c (main): Add new test cases. + 2012-11-29 Sebastian Huber * libc/include/sys/reent.h (__sFILE): Change type of _offset diff --git a/newlib/libc/machine/arm/strcmp.S b/newlib/libc/machine/arm/strcmp.S index 6298bc98d..0a4057e3b 100644 --- a/newlib/libc/machine/arm/strcmp.S +++ b/newlib/libc/machine/arm/strcmp.S @@ -396,7 +396,17 @@ do_return: lsr r2, r2, r0 compute_return_value: - subs r0, r1, r2 + movs r0, #1 + cmp r1, r2 + /* The return value is computed as follows. + If r1>r2 then (C==1 and Z==0) and LS doesn't hold and r0 is #1 at return. + If r1= 0) + print_error ("\nFailed: expected negative, return %d\n", ret); + + dest[0] = src[0] = 'D'; + src[3] = 0xc1; + dest[3] = 0x41; + ret = strcmp (src, dest); + if (ret <= 0) + print_error ("\nFailed: expected positive, return %d\n", ret); + + src[3] = 0x01; + dest[3] = 0x82; + ret = strcmp (src, dest); + if (ret >= 0) + print_error ("\nFailed: expected negative, return %d\n", ret); + printf ("\n"); if (errors != 0) {