mirror of
https://github.com/php/php-src.git
synced 2025-01-02 00:44:30 +08:00
92ac598aab
This patch removes the so called local variables defined per file basis for certain editors to properly show tab width, and similar settings. These are mainly used by Vim and Emacs editors yet with recent changes the once working definitions don't work anymore in Vim without custom plugins or additional configuration. Neither are these settings synced across the PHP code base. A simpler and better approach is EditorConfig and fixing code using some code style fixing tools in the future instead. This patch also removes the so called modelines for Vim. Modelines allow Vim editor specifically to set some editor configuration such as syntax highlighting, indentation style and tab width to be set in the first line or the last 5 lines per file basis. Since the php test files have syntax highlighting already set in most editors properly and EditorConfig takes care of the indentation settings, this patch removes these as well for the Vim 6.0 and newer versions. With the removal of local variables for certain editors such as Emacs and Vim, the footer is also probably not needed anymore when creating extensions using ext_skel.php script. Additionally, Vim modelines for setting php syntax and some editor settings has been removed from some *.phpt files. All these are mostly not relevant for phpt files neither work properly in the middle of the file.
114 lines
3.5 KiB
C
114 lines
3.5 KiB
C
/*
|
|
+----------------------------------------------------------------------+
|
|
| Zend Engine |
|
|
+----------------------------------------------------------------------+
|
|
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
|
|
+----------------------------------------------------------------------+
|
|
| This source file is subject to version 2.00 of the Zend license, |
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
| available through the world-wide-web at the following url: |
|
|
| http://www.zend.com/license/2_00.txt. |
|
|
| If you did not receive a copy of the Zend license and are unable to |
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
| license@zend.com so we can mail you a copy immediately. |
|
|
+----------------------------------------------------------------------+
|
|
| Authors: Dmitry Stogov <dmitry@php.net> |
|
|
+----------------------------------------------------------------------+
|
|
*/
|
|
|
|
#ifndef _ZEND_ARENA_H_
|
|
#define _ZEND_ARENA_H_
|
|
|
|
#include "zend.h"
|
|
|
|
typedef struct _zend_arena zend_arena;
|
|
|
|
struct _zend_arena {
|
|
char *ptr;
|
|
char *end;
|
|
zend_arena *prev;
|
|
};
|
|
|
|
static zend_always_inline zend_arena* zend_arena_create(size_t size)
|
|
{
|
|
zend_arena *arena = (zend_arena*)emalloc(size);
|
|
|
|
arena->ptr = (char*) arena + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena));
|
|
arena->end = (char*) arena + size;
|
|
arena->prev = NULL;
|
|
return arena;
|
|
}
|
|
|
|
static zend_always_inline void zend_arena_destroy(zend_arena *arena)
|
|
{
|
|
do {
|
|
zend_arena *prev = arena->prev;
|
|
efree(arena);
|
|
arena = prev;
|
|
} while (arena);
|
|
}
|
|
|
|
#define ZEND_ARENA_ALIGNMENT 8U
|
|
|
|
static zend_always_inline void* zend_arena_alloc(zend_arena **arena_ptr, size_t size)
|
|
{
|
|
zend_arena *arena = *arena_ptr;
|
|
char *ptr = arena->ptr;
|
|
|
|
size = ZEND_MM_ALIGNED_SIZE(size);
|
|
|
|
if (EXPECTED(size <= (size_t)(arena->end - ptr))) {
|
|
arena->ptr = ptr + size;
|
|
} else {
|
|
size_t arena_size =
|
|
UNEXPECTED((size + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena))) > (size_t)(arena->end - (char*) arena)) ?
|
|
(size + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena))) :
|
|
(size_t)(arena->end - (char*) arena);
|
|
zend_arena *new_arena = (zend_arena*)emalloc(arena_size);
|
|
|
|
ptr = (char*) new_arena + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena));
|
|
new_arena->ptr = (char*) new_arena + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena)) + size;
|
|
new_arena->end = (char*) new_arena + arena_size;
|
|
new_arena->prev = arena;
|
|
*arena_ptr = new_arena;
|
|
}
|
|
|
|
return (void*) ptr;
|
|
}
|
|
|
|
static zend_always_inline void* zend_arena_calloc(zend_arena **arena_ptr, size_t count, size_t unit_size)
|
|
{
|
|
int overflow;
|
|
size_t size;
|
|
void *ret;
|
|
|
|
size = zend_safe_address(unit_size, count, 0, &overflow);
|
|
if (UNEXPECTED(overflow)) {
|
|
zend_error(E_ERROR, "Possible integer overflow in zend_arena_calloc() (%zu * %zu)", unit_size, count);
|
|
}
|
|
ret = zend_arena_alloc(arena_ptr, size);
|
|
memset(ret, 0, size);
|
|
return ret;
|
|
}
|
|
|
|
static zend_always_inline void* zend_arena_checkpoint(zend_arena *arena)
|
|
{
|
|
return arena->ptr;
|
|
}
|
|
|
|
static zend_always_inline void zend_arena_release(zend_arena **arena_ptr, void *checkpoint)
|
|
{
|
|
zend_arena *arena = *arena_ptr;
|
|
|
|
while (UNEXPECTED((char*)checkpoint > arena->end) ||
|
|
UNEXPECTED((char*)checkpoint <= (char*)arena)) {
|
|
zend_arena *prev = arena->prev;
|
|
efree(arena);
|
|
*arena_ptr = arena = prev;
|
|
}
|
|
ZEND_ASSERT((char*)checkpoint > (char*)arena && (char*)checkpoint <= arena->end);
|
|
arena->ptr = (char*)checkpoint;
|
|
}
|
|
|
|
#endif /* _ZEND_ARENA_H_ */
|