| 166 | } |
| 167 | |
| 168 | static SLJIT_INLINE struct chunk_header* alloc_chunk(sljit_uw size) |
| 169 | { |
| 170 | struct chunk_header *retval; |
| 171 | int fd; |
| 172 | |
| 173 | fd = create_tempfile(); |
| 174 | if (fd == -1) |
| 175 | return NULL; |
| 176 | |
| 177 | if (ftruncate(fd, size)) { |
| 178 | close(fd); |
| 179 | return NULL; |
| 180 | } |
| 181 | |
| 182 | retval = (struct chunk_header *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); |
| 183 | |
| 184 | if (retval == MAP_FAILED) { |
| 185 | close(fd); |
| 186 | return NULL; |
| 187 | } |
| 188 | |
| 189 | retval->executable = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_SHARED, fd, 0); |
| 190 | |
| 191 | if (retval->executable == MAP_FAILED) { |
| 192 | munmap(retval, size); |
| 193 | close(fd); |
| 194 | return NULL; |
| 195 | } |
| 196 | |
| 197 | retval->fd = fd; |
| 198 | return retval; |
| 199 | } |
| 200 | |
| 201 | static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size) |
| 202 | { |
no test coverage detected