Skip to content

Commit 2d77320

Browse files
committed
Group alloca handling together
1 parent ead0565 commit 2d77320

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

Zend/zend_portability.h

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@
6363

6464
#include <limits.h>
6565

66-
#if HAVE_ALLOCA_H && !defined(_ALLOCA_H)
67-
# include <alloca.h>
68-
#endif
69-
7066
#if defined(ZEND_WIN32) && !defined(__clang__)
7167
#include <intrin.h>
7268
#endif
@@ -181,6 +177,9 @@
181177
# define ZEND_EXTENSIONS_SUPPORT 0
182178
#endif
183179

180+
#if defined(HAVE_ALLOCA_H) && !defined(_ALLOCA_H)
181+
# include <alloca.h>
182+
#endif
184183
/* AIX requires this to be the first thing in the file. */
185184
#ifndef __GNUC__
186185
# ifndef HAVE_ALLOCA_H
@@ -194,6 +193,25 @@ char *alloca();
194193
# endif
195194
#endif
196195

196+
#if !ZEND_DEBUG && (defined(HAVE_ALLOCA) || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(HPUX)) && !defined(DARWIN)
197+
# define ZEND_ALLOCA_MAX_SIZE (32 * 1024)
198+
# define ALLOCA_FLAG(name) \
199+
bool name;
200+
# define SET_ALLOCA_FLAG(name) \
201+
name = true
202+
# define do_alloca_ex(size, limit, use_heap) \
203+
((use_heap = (UNEXPECTED((size) > (limit)))) ? emalloc(size) : alloca(size))
204+
# define do_alloca(size, use_heap) \
205+
do_alloca_ex(size, ZEND_ALLOCA_MAX_SIZE, use_heap)
206+
# define free_alloca(p, use_heap) \
207+
do { if (UNEXPECTED(use_heap)) efree(p); } while (0)
208+
#else
209+
# define ALLOCA_FLAG(name)
210+
# define SET_ALLOCA_FLAG(name)
211+
# define do_alloca(p, use_heap) emalloc(p)
212+
# define free_alloca(p, use_heap) efree(p)
213+
#endif
214+
197215
#if ZEND_GCC_VERSION >= 2096 || __has_attribute(__malloc__)
198216
# define ZEND_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
199217
#else
@@ -345,25 +363,6 @@ char *alloca();
345363
# define XtOffsetOf(s_type, field) offsetof(s_type, field)
346364
#endif
347365

348-
#if !ZEND_DEBUG && (defined(HAVE_ALLOCA) || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(HPUX)) && !defined(DARWIN)
349-
# define ZEND_ALLOCA_MAX_SIZE (32 * 1024)
350-
# define ALLOCA_FLAG(name) \
351-
bool name;
352-
# define SET_ALLOCA_FLAG(name) \
353-
name = true
354-
# define do_alloca_ex(size, limit, use_heap) \
355-
((use_heap = (UNEXPECTED((size) > (limit)))) ? emalloc(size) : alloca(size))
356-
# define do_alloca(size, use_heap) \
357-
do_alloca_ex(size, ZEND_ALLOCA_MAX_SIZE, use_heap)
358-
# define free_alloca(p, use_heap) \
359-
do { if (UNEXPECTED(use_heap)) efree(p); } while (0)
360-
#else
361-
# define ALLOCA_FLAG(name)
362-
# define SET_ALLOCA_FLAG(name)
363-
# define do_alloca(p, use_heap) emalloc(p)
364-
# define free_alloca(p, use_heap) efree(p)
365-
#endif
366-
367366
#ifdef HAVE_SIGSETJMP
368367
# define SETJMP(a) sigsetjmp(a, 0)
369368
# define LONGJMP(a,b) siglongjmp(a, b)

0 commit comments

Comments
 (0)