-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compiles but has dublicated definitions
- Loading branch information
Showing
19 changed files
with
1,276 additions
and
1,208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
#include "alloc.h" | ||
|
||
// caller needs to make sure to root addr_o before calling this! | ||
// size is the size in bytes (including header) | ||
mps_res_t mps_alloc_obj(mps_addr_t *addr_o, | ||
mps_ap_t ap, | ||
uint32_t size, | ||
uint16_t cljtype, | ||
uint8_t mpstype) { | ||
assert(addr_o != NULL); | ||
assert(size > HEADER_SIZE); | ||
mps_res_t res; | ||
|
||
do { | ||
res = mps_reserve(addr_o, ap, size); | ||
if (res != MPS_RES_OK) return res; | ||
struct obj_stub *obj = *addr_o; | ||
|
||
obj->type = mpstype; | ||
obj->cljtype = cljtype; | ||
obj->size = size; | ||
|
||
// zero all fields | ||
memset(obj->ref, 0, size - HEADER_SIZE); | ||
|
||
} while (!mps_commit(ap, *addr_o, size)); | ||
|
||
return res; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef _ALLOC_H_ | ||
#define _ALLOC_H_ | ||
|
||
struct obj_stub { | ||
uint8_t type; | ||
uint8_t _; | ||
uint16_t cljtype; | ||
uint32_t size; // incl. header | ||
mps_addr_t ref[]; | ||
} __attribute__((packed)); | ||
|
||
|
||
mps_res_t mps_alloc_obj(mps_addr_t *addr_o, | ||
mps_ap_t ap, | ||
uint32_t size, | ||
uint16_t cljtype, | ||
uint8_t mpstype); | ||
|
||
#endif |
Oops, something went wrong.