php-internal-docs
8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
sljitProtExecAllocatorNetBSD.c
Go to the documentation of this file.
1
/*
2
* Stack-less Just-In-Time compiler
3
*
4
* Copyright Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
5
*
6
* Redistribution and use in source and binary forms, with or without modification, are
7
* permitted provided that the following conditions are met:
8
*
9
* 1. Redistributions of source code must retain the above copyright notice, this list of
10
* conditions and the following disclaimer.
11
*
12
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
13
* of conditions and the following disclaimer in the documentation and/or other materials
14
* provided with the distribution.
15
*
16
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
17
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19
* SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
*/
26
27
#define SLJIT_HAS_CHUNK_HEADER
28
#define SLJIT_HAS_EXECUTABLE_OFFSET
29
30
struct
sljit_chunk_header
{
31
void
*
executable
;
32
};
33
34
/*
35
* MAP_REMAPDUP is a NetBSD extension available sinde 8.0, make sure to
36
* adjust your feature macros (ex: -D_NETBSD_SOURCE) as needed
37
*/
38
static
SLJIT_INLINE
struct
sljit_chunk_header
* alloc_chunk(
sljit_uw
size
)
39
{
40
struct
sljit_chunk_header
*
retval
;
41
42
retval
= (
struct
sljit_chunk_header
*)mmap(
NULL
,
size
,
43
PROT_READ
|
PROT_WRITE
| PROT_MPROTECT(PROT_EXEC),
44
MAP_ANON | MAP_SHARED, -1, 0);
45
46
if
(
retval
==
MAP_FAILED
)
47
return
NULL
;
48
49
retval
->executable = mremap(
retval
,
size
,
NULL
,
size
, MAP_REMAPDUP);
50
if
(
retval
->executable ==
MAP_FAILED
) {
51
munmap((
void
*)
retval
,
size
);
52
return
NULL
;
53
}
54
55
if
(
mprotect
(
retval
->executable,
size
,
PROT_READ
| PROT_EXEC) == -1) {
56
munmap(
retval
->executable,
size
);
57
munmap((
void
*)
retval
,
size
);
58
return
NULL
;
59
}
60
61
return
retval
;
62
}
63
64
static
SLJIT_INLINE
void
free_chunk(
void
*chunk,
sljit_uw
size
)
65
{
66
struct
sljit_chunk_header
*
header
= ((
struct
sljit_chunk_header
*)chunk) - 1;
67
68
munmap(
header
->executable,
size
);
69
munmap((
void
*)
header
,
size
);
70
}
71
72
#include "
sljitExecAllocatorCore.c
"
header
header(string $header, bool $replace=true, int $response_code=0)
Definition
basic_functions.stub.php:2238
size
new_type size
Definition
ffi.c:4365
NULL
#define NULL
Definition
gdcache.h:45
mprotect
int mprotect(void *addr, size_t size, int protection)
Definition
phpdbg_win.c:22
PROT_READ
#define PROT_READ
Definition
phpdbg_win.h:26
PROT_WRITE
#define PROT_WRITE
Definition
phpdbg_win.h:27
sljit_uw
unsigned int sljit_uw
Definition
sljitConfigInternal.h:345
SLJIT_INLINE
#define SLJIT_INLINE
Definition
sljitConfigInternal.h:183
sljitExecAllocatorCore.c
sljit_chunk_header
Definition
sljitProtExecAllocatorNetBSD.c:30
sljit_chunk_header::executable
void * executable
Definition
sljitProtExecAllocatorNetBSD.c:31
MAP_FAILED
#define MAP_FAILED
Definition
zend_alloc.c:98
retval
zval retval
Definition
zend_vm_def.h:4055
ext
pcre
pcre2lib
sljit
allocator_src
sljitProtExecAllocatorNetBSD.c
Generated on Sat Aug 23 2025 01:46:10 for php-internal-docs by
1.13.2