summaryrefslogtreecommitdiffstats
path: root/gl/malloca.h
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2024-10-31 15:27:12 (GMT)
committerLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2024-10-31 15:27:12 (GMT)
commit5be04ec2ceb1df77afbca4fcbf9e92a712612d6f (patch)
tree2b2e1c71dffae827c8e45cd4cccc375093d03486 /gl/malloca.h
parent6d1d1dac32841d5ca6ee51bb09b30a6c604b17e2 (diff)
downloadmonitoring-plugins-5be04ec2ceb1df77afbca4fcbf9e92a712612d6f.tar.gz
Sync with the latest Gnulib code (d4ec02b3cc)refs/pull/2037/head
Diffstat (limited to 'gl/malloca.h')
-rw-r--r--gl/malloca.h35
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)