]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/x86/tst-strncmp-rtm.c
1 /* Test case for strncmp inside a transactionally executing RTM region.
2 Copyright (C) 2021-2024 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/>. */
20 #include <tst-string-rtm.h>
24 # define MEMSET wmemset
25 # define STRNCMP wcsncmp
26 # define TEST_NAME "wcsncmp"
29 # define MEMSET memset
31 # define STRNCMP strncmp
32 # define TEST_NAME "strncmp"
39 #define STRING_SIZE 1024
40 CHAR string1
[STRING_SIZE
];
41 CHAR string2
[STRING_SIZE
];
43 __attribute__ ((noinline
, noclone
))
47 MEMSET (string1
, 'a', STRING_SIZE
- 1);
48 MEMSET (string2
, 'a', STRING_SIZE
- 1);
49 if (STRNCMP (string1
, string2
, STRING_SIZE
) == 0)
55 __attribute__ ((noinline
, noclone
))
59 if (STRNCMP (string1
, string2
, STRING_SIZE
) == 0)
65 __attribute__ ((noinline
, noclone
))
67 function_overflow (void)
69 if (STRNCMP (string1
, string2
, SIZE_MAX
) == 0)
75 __attribute__ ((noinline
, noclone
))
77 function_overflow2 (void)
79 if (STRNCMP (string1
, string2
, SIZE_MAX
>> 4) == 0)
88 int status
= do_test_1 (TEST_NAME
, LOOP
, prepare
, function
);
89 if (status
!= EXIT_SUCCESS
)
91 status
= do_test_1 (TEST_NAME
, LOOP
, prepare
, function_overflow
);
92 if (status
!= EXIT_SUCCESS
)
94 status
= do_test_1 (TEST_NAME
, LOOP
, prepare
, function_overflow2
);
95 if (status
!= EXIT_SUCCESS
)