Up the maximum count of error codes in ableOS

This commit is contained in:
able 2024-01-24 05:13:42 -06:00
parent d150e77aaa
commit 8f4e7cfc87
7 changed files with 48 additions and 13 deletions

9
TODO
View file

@ -1,6 +1,13 @@
- [x] Fix string_eq - [ ] String
- [x] Fix string_eq
- [ ] String concat/add
- [ ] push/pop characters
- [ ] case related functions
- [ ] Move function signatures to the *.h file - [ ] Move function signatures to the *.h file
- [ ] Sorting stuff - [ ] Sorting stuff
- [ ] Vec
- [ ] Pop
- [ ] getter/setter
- [x] Random Libraries - [x] Random Libraries
- [x] Mersenne Twister - [x] Mersenne Twister
- [ ] add in u64 and f64 generation proper - [ ] add in u64 and f64 generation proper

View file

@ -9,19 +9,29 @@ ExitCode ecode_new(char* ptr){
}; };
} }
typedef ExitCode ExitCodeArray[255]; // Not thread safe
// Luckily ableOS will not support OSThreads
typedef struct {
u16 count;
ExitCode exit_codes[];
} ExitCodeArray;
typedef struct { typedef struct {
ExitCodeArray exit_code_registry; ExitCodeArray exit_code_registry;
}ExitCodeRegistry ; } ExitCodeRegistry;
ExitCodeRegistry exit_codes; ExitCodeRegistry exit_codes;
int exit_code_count = 0;
void register_exit_code(ExitCode ecode) {
exit_codes.exit_code_registry[exit_code_count] = ecode; // Register an exit code in ableOS
exit_code_count += 1; // Returns:
// - A non-zero u8: When the exit code is registered
// - Zero: something has gone horrible
u16 register_exit_code(ExitCode ecode) {
exit_codes.exit_code_registry.exit_codes[exit_codes.exit_code_registry.count] = ecode;
exit_codes.exit_code_registry.count += 1;
return exit_codes.exit_code_registry.count - 1;
} }

View file

@ -1,4 +1,6 @@
/*Sadly sometimes dividing people in half is a bad thing actually*/ /*Sadly sometimes dividing people in half is a bad thing actually*/
u8 divide_up_u8(u8 n, u8 d) { u8 divide_up_u8(u8 n, u8 d) {
if (n % d == 0) { if (n % d == 0) {
return n / d; return n / d;

View file

@ -9,7 +9,6 @@ typedef enum {
} ProcessResponse; } ProcessResponse;
ProcessID new_id(u64 host, u64 local) { ProcessID new_id(u64 host, u64 local) {
return (ProcessID) { return (ProcessID) {
.host = host, .host = host,
.local = local .local = local
@ -25,12 +24,12 @@ ProcessResponse terminate_process(ProcessID pid) {
// This gives the starting process time to set it up // This gives the starting process time to set it up
ProcessID create_process() { ProcessID create_process() {
trace("New process created"); trace("New process created");
return new_id(0,0); return new_id(0, 0);
} }
// Start execution of a created process // Start execution of a created process
ProcessResponse start_process(ProcessID pid) { ProcessResponse start_process(ProcessID pid) {
trace("process started"); trace("Process started.");
return AlreadyRunning; return AlreadyRunning;
} }

View file

@ -1,8 +1,11 @@
#include <stdlib.h> #include <stdlib.h>
void _start() { void _start() {
exit_codes.exit_code_registry.count = 0;
register_exit_code(ecode_new("Success")); register_exit_code(ecode_new("Success"));
int exit_code = main(); int exit_code = main();
char* ptr = exit_codes.exit_code_registry[exit_code].reason.ptr; char* ptr = exit_codes.exit_code_registry.exit_codes[exit_code].reason.ptr;
if (ptr == 0) { if (ptr == 0) {
printf("Invalid ExitCode"); printf("Invalid ExitCode");

View file

@ -1,18 +1,28 @@
// All System Resource IDs are declared here // All System Resource IDs are declared here
// as well as compound IDs // as well as compound IDs
// The Host Node ID of a Resource in an ableOS Cluster
#define HostID u64 #define HostID u64
// The Localized Resource ID in an ableOS Cluster
#define LocalID u64 #define LocalID u64
typedef struct { typedef struct {
// The Host Node ID of a Process in an ableOS Cluster
HostID host; HostID host;
// The Local Node ID of a Process in an ableOS Cluster
LocalID local; LocalID local;
} ProcessID; } ProcessID;
typedef struct { typedef struct {
// The Host Node ID of a Buffer in an ableOS Cluster
HostID host_id; HostID host_id;
// The Local Node ID of a Buffer in an ableOS Cluster
LocalID local_id; LocalID local_id;
} BufferID; } BufferID;
BufferID construct_buffer_id(HostID host_id, LocalID local_id){ BufferID construct_buffer_id(HostID host_id, LocalID local_id){
return (BufferID) { return (BufferID) {
.host_id = host_id, .host_id = host_id,

View file

@ -1,8 +1,12 @@
#include <stdio.h> #include <stdio.h>
#include "ableos_std/ableos_std.c" #include "ableos_std/ableos_std.c"
// Sadly main must return int or it is a warning.
int main() { int main() {
register_exit_code(ecode_new("File System Error")); u16 fs_exit_error = register_exit_code(ecode_new("File System Error"));
return 0; return 0;
} }