Skip to content

Commit

Permalink
Move PAGE_SIZE to asmconstants.h
Browse files Browse the repository at this point in the history
  • Loading branch information
hmelder committed Jan 21, 2024
1 parent 0958563 commit ac06f53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 9 additions & 0 deletions asmconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@
#define SLOT_OFFSET 0
#endif
#define SMALLOBJ_MASK ((1<<SMALLOBJ_BITS) - 1)

// Page size configuration
#if defined(__powerpc64__)
#define PAGE_SIZE 65536
#define PAGE_SHIFT 16
#else
#define PAGE_SIZE 4096
#define PAGE_SHIFT 12
#endif
9 changes: 1 addition & 8 deletions block_to_imp.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "blocks_runtime.h"
#include "lock.h"
#include "visibility.h"
#include "asmconstants.h" // For PAGE_SIZE

#ifndef __has_builtin
#define __has_builtin(x) 0
Expand Down Expand Up @@ -95,8 +96,6 @@ static int mprotect(void *buffer, size_t len, int prot)
# endif
#endif

#define PAGE_SIZE 4096

struct block_header
{
void *block;
Expand Down Expand Up @@ -189,13 +188,7 @@ static struct trampoline_set *alloc_trampolines(char *start, char *end)
memcpy(block, start, end-start);
}
metadata->buffers->headers[HEADERS_PER_PAGE-1].block = NULL;

#if defined(__powerpc64__) // Workaround as pagesize is 64k on ppc64
mprotect(metadata->buffers, 2 *PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC);
#else
mprotect(metadata->buffers->rx_buffer, PAGE_SIZE, PROT_READ | PROT_EXEC);
#endif

clear_cache(metadata->buffers->rx_buffer, &metadata->buffers->rx_buffer[PAGE_SIZE]);

return metadata;
Expand Down

0 comments on commit ac06f53

Please sign in to comment.