MIPS: Regenerate ulps
[glibc.git] / sysdeps / unix / sysv / linux / tst-rseq.c
blob08a95331306b2a123104b835d6b1fe8904507912
1 /* Restartable Sequences single-threaded tests.
2 Copyright (C) 2021-2024 Free Software Foundation, Inc.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
18 /* These tests validate that rseq is registered from main in an executable
19 not linked against libpthread. */
21 #include <support/check.h>
22 #include <stdio.h>
23 #include <sys/rseq.h>
24 #include <unistd.h>
26 #ifdef RSEQ_SIG
27 # include <errno.h>
28 # include <error.h>
29 # include <stdlib.h>
30 # include <string.h>
31 # include <syscall.h>
32 # include <sys/auxv.h>
33 # include <thread_pointer.h>
34 # include <tls.h>
35 # include "tst-rseq.h"
37 static void
38 do_rseq_main_test (void)
40 struct pthread *pd = THREAD_SELF;
42 TEST_VERIFY_EXIT (rseq_thread_registered ());
43 TEST_COMPARE (__rseq_flags, 0);
44 TEST_VERIFY ((char *) __thread_pointer () + __rseq_offset
45 == (char *) &pd->rseq_area);
46 /* The current implementation only supports the initial size. */
47 TEST_COMPARE (__rseq_size, 20);
50 static void
51 do_rseq_test (void)
53 if (!rseq_available ())
55 FAIL_UNSUPPORTED ("kernel does not support rseq, skipping test");
57 printf ("info: __rseq_size: %u\n", __rseq_size);
58 printf ("info: __rseq_offset: %td\n", __rseq_offset);
59 printf ("info: __rseq_flags: %u\n", __rseq_flags);
60 printf ("info: getauxval (AT_RSEQ_FEATURE_SIZE): %ld\n",
61 getauxval (AT_RSEQ_FEATURE_SIZE));
62 printf ("info: getauxval (AT_RSEQ_ALIGN): %ld\n", getauxval (AT_RSEQ_ALIGN));
63 do_rseq_main_test ();
65 #else /* RSEQ_SIG */
66 static void
67 do_rseq_test (void)
69 FAIL_UNSUPPORTED ("glibc does not define RSEQ_SIG, skipping test");
71 #endif /* RSEQ_SIG */
73 static int
74 do_test (void)
76 do_rseq_test ();
77 return 0;
80 #include <support/test-driver.c>