1 /* libc-internal interface for tagged (colored) memory support.
2 Copyright (C) 2020-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 <http://www.gnu.org/licenses/>. */
19 #ifndef _GENERIC_LIBC_MTAG_H
20 #define _GENERIC_LIBC_MTAG_H 1
22 /* Generic bindings for systems that do not support memory tagging. */
24 /* Used to ensure additional alignment when objects need to have distinct
26 #define __MTAG_GRANULE_SIZE 1
28 /* Non-zero if memory obtained via morecore (sbrk) is not tagged. */
29 #define __MTAG_SBRK_UNTAGGED 0
31 /* Extra flags to pass to mmap() to request a tagged region of memory. */
32 #define __MTAG_MMAP_FLAGS 0
34 /* Memory tagging target hooks are only called when memory tagging is
35 enabled at runtime. The generic definitions here must not be used. */
36 void __libc_mtag_link_error (void);
38 /* Set the tags for a region of memory, which must have size and alignment
39 that are multiples of __MTAG_GRANULE_SIZE. Size cannot be zero. */
41 __libc_mtag_tag_region (void *p
, size_t n
)
43 __libc_mtag_link_error ();
47 /* Optimized equivalent to __libc_mtag_tag_region followed by memset to 0. */
49 __libc_mtag_tag_zero_region (void *p
, size_t n
)
51 __libc_mtag_link_error ();
52 return memset (p
, 0, n
);
55 /* Convert address P to a pointer that is tagged correctly for that
58 __libc_mtag_address_get_tag (void *p
)
60 __libc_mtag_link_error ();
64 /* Assign a new (random) tag to a pointer P (does not adjust the tag on
65 the memory addressed). */
67 __libc_mtag_new_tag (void *p
)
69 __libc_mtag_link_error ();
73 #endif /* _GENERIC_LIBC_MTAG_H */