#include "api/error.h" #include "hal/obj.h" #include "lib/string.h" #include "memory.h" int shmem_new(jove_owned_obj_t *untyped_obj) { jove_untyped_t *untyped = obj_deref(untyped_obj); if((uintptr_t)untyped & 0xFFF) return -EALIGN; if(untyped->limit & 0xFFF) return -EBADSIZE; size_t limit_pages = untyped->limit >> 12; if(limit_pages > JOVE_SMHEM_MAXPAGES) return -ETOOBIG; obj_setvalue(untyped_obj, (uintptr_t)untyped | limit_pages); obj_settype(untyped_obj, JOVE_OBJ_SHMEMORY); memset(untyped, 0, untyped->limit); return 0; }