ld: simple heap allocation test
This commit is contained in:
@@ -2,6 +2,9 @@
|
|||||||
#include <mango/msg.h>
|
#include <mango/msg.h>
|
||||||
#include <mango/types.h>
|
#include <mango/types.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
int main(
|
int main(
|
||||||
int argc,
|
int argc,
|
||||||
@@ -11,6 +14,17 @@ int main(
|
|||||||
uintptr_t bsp_base)
|
uintptr_t bsp_base)
|
||||||
{
|
{
|
||||||
kern_log("ld!");
|
kern_log("ld!");
|
||||||
|
void *brk = sbrk(0);
|
||||||
|
kern_logf("brk=%p", brk);
|
||||||
|
|
||||||
|
void *buf = malloc(64);
|
||||||
|
if (buf) {
|
||||||
|
memset(buf, 0x0, 64);
|
||||||
|
kern_logf("allocated 64 bytes at %p", buf);
|
||||||
|
} else {
|
||||||
|
kern_logf("malloc() failed");
|
||||||
|
}
|
||||||
|
|
||||||
kern_handle_t port;
|
kern_handle_t port;
|
||||||
kern_status_t status = port_create(&port);
|
kern_status_t status = port_create(&port);
|
||||||
if (status != KERN_OK) {
|
if (status != KERN_OK) {
|
||||||
|
|||||||
Reference in New Issue
Block a user