1 /* Test THREAD_SETMEM and THREAD_SETMEM_NC for IMM64.
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 <support/check.h>
25 unsigned long long int saved_ssp_base
, ssp_base
;
26 saved_ssp_base
= THREAD_GETMEM (THREAD_SELF
, header
.ssp_base
);
28 THREAD_SETMEM (THREAD_SELF
, header
.ssp_base
, (1ULL << 57) - 1);
29 ssp_base
= THREAD_GETMEM (THREAD_SELF
, header
.ssp_base
);
30 if (ssp_base
!= ((1ULL << 57) - 1))
31 FAIL_EXIT1 ("THREAD_SETMEM: 0x%llx != 0x%llx",
32 ssp_base
, (1ULL << 57) - 1);
34 THREAD_SETMEM (THREAD_SELF
, header
.ssp_base
, -1ULL);
35 ssp_base
= THREAD_GETMEM (THREAD_SELF
, header
.ssp_base
);
36 if (ssp_base
!= -1ULL)
37 FAIL_EXIT1 ("THREAD_SETMEM: 0x%llx != 0x%llx", ssp_base
, -1ULL);
39 THREAD_SETMEM (THREAD_SELF
, header
.ssp_base
, saved_ssp_base
);
41 struct pthread_key_data
*saved_specific
, *specific
;
42 saved_specific
= THREAD_GETMEM_NC (THREAD_SELF
, specific
, 1);
44 uintptr_t value
= (1UL << 57) - 1;
45 THREAD_SETMEM_NC (THREAD_SELF
, specific
, 1,
46 (struct pthread_key_data
*) value
);
47 specific
= THREAD_GETMEM_NC (THREAD_SELF
, specific
, 1);
48 if (specific
!= (struct pthread_key_data
*) value
)
49 FAIL_EXIT1 ("THREAD_GETMEM_NC: %p != %p",
50 specific
, (struct pthread_key_data
*) value
);
52 THREAD_SETMEM_NC (THREAD_SELF
, specific
, 1,
53 (struct pthread_key_data
*) -1UL);
54 specific
= THREAD_GETMEM_NC (THREAD_SELF
, specific
, 1);
55 if (specific
!= (struct pthread_key_data
*) -1UL)
56 FAIL_EXIT1 ("THREAD_GETMEM_NC: %p != %p",
57 specific
, (struct pthread_key_data
*) -1UL);
59 THREAD_SETMEM_NC (THREAD_SELF
, specific
, 1, saved_specific
);
64 #include <support/test-driver.c>