This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #include <config.h>
19
20 #include <string.h>
21
22 #include "signature.h"
23 SIGNATURE_CHECK (memcmp, int, (void const *, void const *, size_t));
24
25 #include "zerosize-ptr.h"
26 #include "macros.h"
27
28 int
29 main (void)
30 {
31 int (* volatile memcmp_ptr) (const void *, const void *, size_t) = memcmp;
32
33
34 void *page_boundary1 = zerosize_ptr ();
35 void *page_boundary2 = zerosize_ptr ();
36 if (page_boundary1 && page_boundary2)
37 ASSERT (memcmp (page_boundary1, page_boundary2, 0) == 0);
38 ASSERT (memcmp ("foo", "foobar", 2) == 0);
39 ASSERT (memcmp ("foo", "foobar", 3) == 0);
40 ASSERT (memcmp ("foo", "foobar", 4) != 0);
41 ASSERT (memcmp ("foo", "bar", 1) != 0);
42 ASSERT (memcmp ("foo", "bar", 3) != 0);
43
44
45 ASSERT (memcmp ("foo", "moo", 4) < 0);
46 ASSERT (memcmp ("moo", "foo", 4) > 0);
47 ASSERT (memcmp ("oomph", "oops", 3) < 0);
48 ASSERT (memcmp ("oops", "oomph", 3) > 0);
49 ASSERT (memcmp ("foo", "foobar", 4) < 0);
50 ASSERT (memcmp ("foobar", "foo", 4) > 0);
51
52
53
54
55
56 ASSERT (memcmp_ptr ("\100", "\201", 1) < 0);
57 ASSERT (memcmp_ptr ("\201", "\100", 1) > 0);
58 ASSERT (memcmp_ptr ("\200", "\201", 1) < 0);
59 ASSERT (memcmp_ptr ("\201", "\200", 1) > 0);
60
61
62
63
64 {
65 char foo[21];
66 char bar[21];
67 int i;
68 for (i = 0; i < 4; i++)
69 {
70 char *a = foo + i;
71 char *b = bar + i;
72 strcpy (a, "--------01111111");
73 strcpy (b, "--------10000000");
74 ASSERT (memcmp (a, b, 16) < 0);
75 }
76 }
77
78 return 0;
79 }