diff options
Diffstat (limited to 'src/ptr-bounds.h')
| -rw-r--r-- | src/ptr-bounds.h | 79 |
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 | |||
| 3 | Copyright 2017-2020 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or (at | ||
| 10 | your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along 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 | |||
| 41 | INLINE_HEADER_BEGIN | ||
| 42 | |||
| 43 | /* Return a copy of P, with bounds narrowed to [P, P + N). */ | ||
| 44 | #ifdef __CHKP__ | ||
| 45 | INLINE void * | ||
| 46 | ptr_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 | |||
| 77 | INLINE_HEADER_END | ||
| 78 | |||
| 79 | #endif /* PTR_BOUNDS_H */ | ||