Luna/apps/app.c

41 lines
864 B
C
Raw Normal View History

#include <bits/mmap-flags.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/syscall.h>
2023-01-06 23:21:08 +00:00
#include <time.h>
#include <unistd.h>
void bye()
{
2023-01-07 00:49:26 +00:00
printf("byeee!\n");
}
int main()
{
atexit(bye);
2023-01-07 00:49:26 +00:00
printf("Welcome to %s!\n", "Luna");
time_t now = time(NULL);
2023-01-07 00:49:26 +00:00
printf("Realtime clock: %ld s\n", now);
2023-01-06 23:21:08 +00:00
2023-01-07 00:49:26 +00:00
for (int i = 0; i < atoi("8"); i++) { console_write(".", 1); }
2023-01-07 00:49:26 +00:00
console_write("\n", 1);
long rc = syscall(SYS_allocate_memory, 4096, PROT_READ | PROT_WRITE);
if (rc < 0)
{
printf("allocate_memory: %s\n", strerror(-rc));
return 1;
}
char* address = (char*)rc;
printf("address: %p\n", address);
printf("memory at address: %c\n", *address);
*address = 'e';
printf("memory at address: %c\n", *address);
syscall(SYS_deallocate_memory, address);
}