diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-11-06 08:24:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-06 08:24:23 (GMT) |
commit | 9b4df9e50837cc837e113053ba12ee6967d5e6c2 (patch) | |
tree | bf989e771579f835bcb49c074637a8e224bcecbc /gl/malloca.h | |
parent | 94150ae347beb25ac369d5773834ceef7f3736d3 (diff) | |
parent | 5be04ec2ceb1df77afbca4fcbf9e92a712612d6f (diff) | |
download | monitoring-plugins-9b4df9e50837cc837e113053ba12ee6967d5e6c2.tar.gz |
Merge pull request #2037 from RincewindsHat/update/gnulib-1.0
Sync with the latest Gnulib code (d4ec02b3cc) (gnulib v1.0)
Diffstat (limited to 'gl/malloca.h')
-rw-r--r-- | gl/malloca.h | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/gl/malloca.h b/gl/malloca.h index 325c727..c520842 100644 --- a/gl/malloca.h +++ b/gl/malloca.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* Safe automatic memory allocation. | 1 | /* Safe automatic memory allocation. |
2 | Copyright (C) 2003-2007, 2009-2023 Free Software Foundation, Inc. | 2 | Copyright (C) 2003-2007, 2009-2024 Free Software Foundation, Inc. |
3 | Written by Bruno Haible <bruno@clisp.org>, 2003. | 3 | Written by Bruno Haible <bruno@clisp.org>, 2003. |
4 | 4 | ||
5 | This file is free software: you can redistribute it and/or modify | 5 | This file is free software: you can redistribute it and/or modify |
@@ -18,10 +18,19 @@ | |||
18 | #ifndef _MALLOCA_H | 18 | #ifndef _MALLOCA_H |
19 | #define _MALLOCA_H | 19 | #define _MALLOCA_H |
20 | 20 | ||
21 | /* This file uses _GL_ATTRIBUTE_ALLOC_SIZE, _GL_ATTRIBUTE_DEALLOC, | ||
22 | _GL_ATTRIBUTE_MALLOC, HAVE_ALLOCA. */ | ||
23 | #if !_GL_CONFIG_H_INCLUDED | ||
24 | #error "Please include config.h first." | ||
25 | #endif | ||
26 | |||
21 | #include <alloca.h> | 27 | #include <alloca.h> |
22 | #include <stddef.h> | 28 | #include <stddef.h> |
23 | #include <stdlib.h> | 29 | #include <stdlib.h> |
24 | #include <stdint.h> | 30 | #include <stdint.h> |
31 | #if defined __CHERI_PURE_CAPABILITY__ | ||
32 | # include <cheri.h> | ||
33 | #endif | ||
25 | 34 | ||
26 | #include "xalloc-oversized.h" | 35 | #include "xalloc-oversized.h" |
27 | 36 | ||
@@ -62,12 +71,24 @@ extern void freea (void *p); | |||
62 | memory allocated on the stack, that must be freed using freea() before | 71 | memory allocated on the stack, that must be freed using freea() before |
63 | the function returns. Upon failure, it returns NULL. */ | 72 | the function returns. Upon failure, it returns NULL. */ |
64 | #if HAVE_ALLOCA | 73 | #if HAVE_ALLOCA |
65 | # define malloca(N) \ | 74 | # if defined __CHERI_PURE_CAPABILITY__ |
66 | ((N) < 4032 - (2 * sa_alignment_max - 1) \ | 75 | # define malloca(N) \ |
67 | ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \ | 76 | ((N) < 4032 - (2 * sa_alignment_max - 1) \ |
68 | + (2 * sa_alignment_max - 1)) \ | 77 | ? cheri_bounds_set ((void *) (((uintptr_t) \ |
69 | & ~(uintptr_t)(2 * sa_alignment_max - 1)) \ | 78 | (char *) \ |
70 | : mmalloca (N)) | 79 | alloca ((N) + 2 * sa_alignment_max - 1) \ |
80 | + (2 * sa_alignment_max - 1)) \ | ||
81 | & ~(uintptr_t)(2 * sa_alignment_max - 1)), \ | ||
82 | (N)) \ | ||
83 | : mmalloca (N)) | ||
84 | # else | ||
85 | # define malloca(N) \ | ||
86 | ((N) < 4032 - (2 * sa_alignment_max - 1) \ | ||
87 | ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \ | ||
88 | + (2 * sa_alignment_max - 1)) \ | ||
89 | & ~(uintptr_t)(2 * sa_alignment_max - 1)) \ | ||
90 | : mmalloca (N)) | ||
91 | # endif | ||
71 | #else | 92 | #else |
72 | # define malloca(N) \ | 93 | # define malloca(N) \ |
73 | mmalloca (N) | 94 | mmalloca (N) |