mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-25 16:52:29 +00:00
feat(sub-lang): Integrate SUB Language (.sb) native kernel modules and in-kernel VM/interpreter
- Add native .sb kernel modules in sub/ (signature.sb, power_governor.sb, benchmark.sb, easter_egg.sb) - Implement in-kernel SUB Language VM and AST interpreter in kernel/sub/sub_vm.c - Implement C-interop runtime in kernel/sub/sub_runtime.c and include/kernel/sub_lang.h - Initialize SUB Language Engine in boot sequence step [8/14] in kernel/main.c - Implement strtol in lib/string.c - Add LazyBox applets: 'subinfo', 'subi', 'subpower', 'subbench', and 'subquote'
This commit is contained in:
1 parent
e5984ac113
commit
155794f975
12 files changed
+661
-5
No files matched your search
@@ -228,3 +228,37 @@ int atoi(const char* str) {
|
||||
}
|
||||
return res * sign;
|
||||
}
|
||||
|
||||
long strtol(const char* str, char** endptr, int base) {
|
||||
if (!str) return 0;
|
||||
while (*str == ' ' || *str == '\t') str++;
|
||||
int sign = 1;
|
||||
if (*str == '-') { sign = -1; str++; }
|
||||
else if (*str == '+') { str++; }
|
||||
|
||||
if (base == 0) {
|
||||
if (*str == '0' && (*(str+1) == 'x' || *(str+1) == 'X')) {
|
||||
base = 16;
|
||||
str += 2;
|
||||
} else if (*str == '0') {
|
||||
base = 8;
|
||||
} else {
|
||||
base = 10;
|
||||
}
|
||||
} else if (base == 16 && *str == '0' && (*(str+1) == 'x' || *(str+1) == 'X')) {
|
||||
str += 2;
|
||||
}
|
||||
|
||||
long result = 0;
|
||||
while (*str) {
|
||||
int val = -1;
|
||||
if (*str >= '0' && *str <= '9') val = *str - '0';
|
||||
else if (*str >= 'a' && *str <= 'z') val = *str - 'a' + 10;
|
||||
else if (*str >= 'A' && *str <= 'Z') val = *str - 'A' + 10;
|
||||
if (val < 0 || val >= base) break;
|
||||
result = result * base + val;
|
||||
str++;
|
||||
}
|
||||
if (endptr) *endptr = (char*)str;
|
||||
return result * sign;
|
||||
}
|
||||
Reference in new issue
Block a user