aboutsummaryrefslogtreecommitdiffstats
path: root/src/ptr-bounds.h
diff options
context:
space:
mode:
authorAndrea Corallo2020-08-09 15:03:23 +0200
committerAndrea Corallo2020-08-09 15:03:23 +0200
commit12a982d9789052d8e85efcacb4b311f4876c882a (patch)
treea452a8e888c6ee9c85d6a487359b7a1c0c9fa15b /src/ptr-bounds.h
parent80d7f710f2fab902e46aa3fddb8e1c1795420af3 (diff)
parent8e82baf5a730ff542118ddba5b76afdc1db643f6 (diff)
downloademacs-12a982d9789052d8e85efcacb4b311f4876c882a.tar.gz
emacs-12a982d9789052d8e85efcacb4b311f4876c882a.zip
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'src/ptr-bounds.h')
-rw-r--r--src/ptr-bounds.h79
1 files changed, 0 insertions, 79 deletions
diff --git a/src/ptr-bounds.h b/src/ptr-bounds.h
deleted file mode 100644
index 22d49f25b6c..00000000000
--- a/src/ptr-bounds.h
+++ /dev/null
@@ -1,79 +0,0 @@
1/* Pointer bounds checking for GNU Emacs
2
3Copyright 2017-2020 Free Software Foundation, Inc.
4
5This file is part of GNU Emacs.
6
7GNU Emacs is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 3 of the License, or (at
10your option) any later version.
11
12GNU Emacs is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
19
20/* Pointer bounds checking is a no-op unless running on hardware
21 supporting Intel MPX (Intel Skylake or better). Also, it requires
22 GCC 5 and Linux kernel 3.19, or later. Configure with
23 CFLAGS='-fcheck-pointer-bounds -mmpx', perhaps with
24 -fchkp-first-field-has-own-bounds thrown in.
25
26 Although pointer bounds checking can help during debugging, it is
27 disabled by default because it hurts performance significantly.
28 The checking does not detect all pointer errors. For example, a
29 dumped Emacs might not detect a bounds violation of a pointer that
30 was created before Emacs was dumped. */
31
32#ifndef PTR_BOUNDS_H
33#define PTR_BOUNDS_H
34
35#include <stddef.h>
36
37/* When not checking pointer bounds, the following macros simply
38 return their first argument. These macros return either void *, or
39 the same type as their first argument. */
40
41INLINE_HEADER_BEGIN
42
43/* Return a copy of P, with bounds narrowed to [P, P + N). */
44#ifdef __CHKP__
45INLINE void *
46ptr_bounds_clip (void const *p, size_t n)
47{
48 return __builtin___bnd_narrow_ptr_bounds (p, p, n);
49}
50#else
51# define ptr_bounds_clip(p, n) ((void) (size_t) {n}, p)
52#endif
53
54/* Return a copy of P, but with the bounds of Q. */
55#ifdef __CHKP__
56# define ptr_bounds_copy(p, q) __builtin___bnd_copy_ptr_bounds (p, q)
57#else
58# define ptr_bounds_copy(p, q) ((void) (void const *) {q}, p)
59#endif
60
61/* Return a copy of P, but with infinite bounds.
62 This is a loophole in pointer bounds checking. */
63#ifdef __CHKP__
64# define ptr_bounds_init(p) __builtin___bnd_init_ptr_bounds (p)
65#else
66# define ptr_bounds_init(p) (p)
67#endif
68
69/* Return a copy of P, but with bounds [P, P + N).
70 This is a loophole in pointer bounds checking. */
71#ifdef __CHKP__
72# define ptr_bounds_set(p, n) __builtin___bnd_set_ptr_bounds (p, n)
73#else
74# define ptr_bounds_set(p, n) ((void) (size_t) {n}, p)
75#endif
76
77INLINE_HEADER_END
78
79#endif /* PTR_BOUNDS_H */