1 /* Test memcmp with size_t in the lower 32 bits of 64-bit register.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
21 # define TEST_NAME "wmemcmp"
23 # define TEST_NAME "memcmp"
26 #include "test-size_t.h"
29 # include <inttypes.h>
32 # define MEMCMP wmemcmp
35 # define MEMCMP memcmp
41 typedef int (*proto_t
) (const CHAR
*, const CHAR
*, size_t);
44 __attribute__ ((noinline
, noclone
))
45 do_memcmp (parameter_t a
, parameter_t b
)
47 return CALL (&b
, a
.p
, b
.p
, a
.len
);
55 parameter_t dest
= { { page_size
/ sizeof (CHAR
) }, buf1
};
56 parameter_t src
= { { 0 }, buf2
};
58 memcpy (buf1
, buf2
, page_size
);
60 CHAR
*p
= (CHAR
*) buf1
;
61 p
[page_size
/ sizeof (CHAR
) - 1] = (CHAR
) 1;
64 FOR_EACH_IMPL (impl
, 0)
67 int res
= do_memcmp (dest
, src
);
70 error (0, 0, "Wrong result in function %s: %i >= 0",
76 return ret
? EXIT_FAILURE
: EXIT_SUCCESS
;
79 #include <support/test-driver.c>