| 1 |
/* Copyright (C) 2001 Free Software Foundation. |
| 2 |
|
| 3 |
Ensure that short builtin memcmp are optimized and perform correctly. |
| 4 |
On architectures with a cmpstrsi instruction, this test doesn't determine |
| 5 |
which optimization is being performed, but it does check for correctness. |
| 6 |
|
| 7 |
Written by Roger Sayle, 12/02/2001. |
| 8 |
Additional tests by Roger Sayle after PR 3508, 12/26/2001. */ |
| 9 |
|
| 10 |
extern void abort (void); |
| 11 |
typedef __SIZE_TYPE__ size_t; |
| 12 |
extern int memcmp (const void *, const void *, size_t); |
| 13 |
extern char *strcpy (char *, const char *); |
| 14 |
extern void link_error (void); |
| 15 |
|
| 16 |
void |
| 17 |
main_test (void) |
| 18 |
{ |
| 19 |
char str[8]; |
| 20 |
|
| 21 |
strcpy (str, "3141"); |
| 22 |
|
| 23 |
if ( memcmp (str, str+2, 0) != 0 ) |
| 24 |
abort (); |
| 25 |
if ( memcmp (str+1, str+3, 0) != 0 ) |
| 26 |
abort (); |
| 27 |
|
| 28 |
if ( memcmp (str+1, str+3, 1) != 0 ) |
| 29 |
abort (); |
| 30 |
if ( memcmp (str, str+2, 1) >= 0 ) |
| 31 |
abort (); |
| 32 |
if ( memcmp (str+2, str, 1) <= 0 ) |
| 33 |
abort (); |
| 34 |
|
| 35 |
if (memcmp ("abcd", "efgh", 4) >= 0) |
| 36 |
link_error (); |
| 37 |
if (memcmp ("abcd", "abcd", 4) != 0) |
| 38 |
link_error (); |
| 39 |
if (memcmp ("efgh", "abcd", 4) <= 0) |
| 40 |
link_error (); |
| 41 |
} |