Files
Adam EehanEr. Adam EehanSovereign AI Aira 3 Ultra (Engine v3.6)
aa1c82f81e feat(subsystems): implement 100% canonical Linux tree parity with enterprise subsystems
- Add usr/ subsystem: in-kernel cpio initramfs unpacker, gen_init_cpio tool, Kconfig, Makefile
- Add init/ subsystem: UTS metadata (airlys_banner, linux_banner), BogoMIPS calibration loop, delay functions
- Add block/ subsystem: block device registration, MBR partition table scanner, No-Op I/O elevator scheduler
- Add ipc/ subsystem: POSIX circular pipes, System V message queues, counting semaphores
- Add crypto/ subsystem: FIPS 180-4 SHA-256 and IEEE 802.3 CRC-32 cryptographic engines
- Add net/ subsystem: socket buffer (sk_buff) manager, loopback (lo) interface, ARP table
- Add sound/ subsystem: ALSA audio core, PCM stream queue, PC Speaker PIT channel 2 hardware driver
- Add virt/ subsystem: VirtIO hypervisor PCI discovery and split-ring virtqueues
- Add certs/ subsystem: sovereign X.509 keyring and certificate authority
- Add samples/ subsystem: sample kernel worker thread and IPC pipe demonstration modules
- Add top-level Linux root metadata: Kconfig, Kbuild, MAINTAINERS, Documentation/, LICENSES/
- Wire all subsystems into kernel_main and airlys-sh shell commands (lsblk, netdev, initramfs, virtio, keyring, pipe, beep, sha256, crc32)
- Zero-warning freestanding build verification with clang & ld.lld (x86_64-unknown-none-elf)

Co-Authored-By: Er. Adam Eehan <adameehanairagroup@gmail.com>
Co-Authored-By: Sovereign AI Aira 3 Ultra (Engine v3.6)
2026-10-23 19:16:24 +05:30

85 lines
1.8 KiB
C

#include <airlys/string.h>
size_t kstrlen(const char* s) {
size_t len = 0;
while (s && s[len] != '\0') {
len++;
}
return len;
}
int kstrcmp(const char* s1, const char* s2) {
while (*s1 && (*s1 == *s2)) {
s1++;
s2++;
}
return *(const unsigned char*)s1 - *(const unsigned char*)s2;
}
int kstrncmp(const char* s1, const char* s2, size_t n) {
while (n && *s1 && (*s1 == *s2)) {
s1++;
s2++;
n--;
}
if (n == 0) return 0;
return *(const unsigned char*)s1 - *(const unsigned char*)s2;
}
void kstrncpy(char* dest, const char* src, size_t n) {
size_t i = 0;
while (i < n - 1 && src[i] != '\0') {
dest[i] = src[i];
i++;
}
dest[i] = '\0';
}
char* kstrcpy(char* dest, const char* src) {
char* d = dest;
while ((*d++ = *src++) != '\0') {}
return dest;
}
char* kstrcat(char* dest, const char* src) {
char* d = dest;
while (*d) d++;
while ((*d++ = *src++) != '\0') {}
return dest;
}
int kmemcmp(const void* s1, const void* s2, size_t n) {
const uint8_t* p1 = (const uint8_t*)s1;
const uint8_t* p2 = (const uint8_t*)s2;
for (size_t i = 0; i < n; i++) {
if (p1[i] != p2[i]) return p1[i] - p2[i];
}
return 0;
}
void* kmemcpy(void* dest, const void* src, size_t n) {
uint8_t* d = (uint8_t*)dest;
const uint8_t* s = (const uint8_t*)src;
for (size_t i = 0; i < n; i++) {
d[i] = s[i];
}
return dest;
}
void* kmemset(void* s, int c, size_t n) {
uint8_t* p = (uint8_t*)s;
for (size_t i = 0; i < n; i++) {
p[i] = (uint8_t)c;
}
return s;
}
/* Freestanding compiler intrinsics */
void* memcpy(void* dest, const void* src, size_t n) {
return kmemcpy(dest, src, n);
}
void* memset(void* s, int c, size_t n) {
return kmemset(s, c, n);
}