summaryrefslogtreecommitdiff
path: root/lib/malloca.h
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2021-01-20 21:52:54 +0100
committerAndy Wingo <wingo@pobox.com>2021-01-20 23:03:56 +0100
commita91b95cca2d397c84f8b9bbd602d40209a7092ce (patch)
tree2c286a291f5a2b812d6e216be10936f2709d59cf /lib/malloca.h
parent758b31994cff582c7e8785b4cc2240dbf3573837 (diff)
downloadguile-a91b95cca2d397c84f8b9bbd602d40209a7092ce.tar.gz
Update Gnulib to v0.1-4379-g2ef5a9b4b
Also bump required autoconf version to 2.64, as required by Gnulib.
Diffstat (limited to 'lib/malloca.h')
-rw-r--r--lib/malloca.h21
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/malloca.h b/lib/malloca.h
index 3b61ca2b9..fd40073e3 100644
--- a/lib/malloca.h
+++ b/lib/malloca.h
@@ -1,5 +1,5 @@
/* Safe automatic memory allocation.
- Copyright (C) 2003-2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2003-2007, 2009-2021 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _MALLOCA_H
#define _MALLOCA_H
@@ -56,8 +56,10 @@ extern "C" {
the function returns. Upon failure, it returns NULL. */
#if HAVE_ALLOCA
# define malloca(N) \
- ((N) < 4032 - sa_increment \
- ? (void *) ((char *) alloca ((N) + sa_increment) + sa_increment) \
+ ((N) < 4032 - (2 * sa_alignment_max - 1) \
+ ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \
+ + (2 * sa_alignment_max - 1)) \
+ & ~(uintptr_t)(2 * sa_alignment_max - 1)) \
: mmalloca (N))
#else
# define malloca(N) \
@@ -87,7 +89,7 @@ extern void freea (void *p);
/* ------------------- Auxiliary, non-public definitions ------------------- */
/* Determine the alignment of a type at compile time. */
-#if defined __GNUC__ || defined __IBM__ALIGNOF__
+#if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__
# define sa_alignof __alignof__
#elif defined __cplusplus
template <class type> struct sa_alignof_helper { char __slot1; type __slot2; };
@@ -110,19 +112,12 @@ enum
among all elementary types. */
sa_alignment_long = sa_alignof (long),
sa_alignment_double = sa_alignof (double),
-#if HAVE_LONG_LONG_INT
sa_alignment_longlong = sa_alignof (long long),
-#endif
sa_alignment_longdouble = sa_alignof (long double),
sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1)
-#if HAVE_LONG_LONG_INT
| (sa_alignment_longlong - 1)
-#endif
| (sa_alignment_longdouble - 1)
- ) + 1,
-/* The increment that guarantees room for a magic word must be >= sizeof (int)
- and a multiple of sa_alignment_max. */
- sa_increment = ((sizeof (int) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max
+ ) + 1
};
#endif /* _MALLOCA_H */