summaryrefslogtreecommitdiff
path: root/src/__readonly.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2024-05-28 15:50:03 -0400
committerJakob Kaivo <jkk@ung.org>2024-05-28 15:50:03 -0400
commitc9ec058657f9f8b3fd39a16f1a9e993b4a1e982e (patch)
tree6cf1abadd04a1a9049d82ffe0e78be7f8b4cece2 /src/__readonly.c
parentb4cd7036bea6c6440fbbcdaebe53c864c87a5646 (diff)
abstract out "forced" implementations of functions from future specifications
Diffstat (limited to 'src/__readonly.c')
-rw-r--r--src/__readonly.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/__readonly.c b/src/__readonly.c
index 74837a91..f2d33c38 100644
--- a/src/__readonly.c
+++ b/src/__readonly.c
@@ -1,24 +1,19 @@
+#include <limits.h>
#include <stdlib.h>
#include "_readonly.h"
+#include "stdlib/_jkmalloc.h"
+#include "_forced/mprotect.h"
-#ifdef _POSIX_C_SOURCE
-#include <sys/mman.h>
-#include <limits.h>
-#else
-#include "_syscall.h"
-#define mprotect(__ptr, __len, __prot) __syscall(__sys_mprotect, __ptr, __len, __prot)
-#define PROT_READ 1
-#define PROT_WRITE 2
-#define PAGESIZE 4096
+#ifndef PAGESIZE
+#define PAGESIZE 4096
#endif
void* __readonly(ro_action_t action, void *ptr)
{
switch (action) {
case RO_ALLOC:
- /* set magic to JK_READONLY */
- /* set label to ptr */
- return malloc(PAGESIZE);
+ return __jkmalloc(NULL, NULL, 0, NULL, 1, PAGESIZE, 0, ptr);
+
case RO_FREE:
free(ptr);