summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/include/stdio.h88
-rw-r--r--lib/libc/include/stdlib.h90
-rw-r--r--lib/libc/src/main.c8
-rw-r--r--lib/libc/src/stdio/fputc.c55
-rw-r--r--lib/libc/src/stdio/fputs.c68
-rw-r--r--lib/libc/src/stdio/fwrite.c61
-rw-r--r--lib/libc/src/stdio/init.c62
-rw-r--r--lib/libc/src/stdlib/_Exit.c38
-rw-r--r--lib/libc/src/stdlib/abort.c40
-rw-r--r--lib/libc/src/stdlib/exit.c40
10 files changed, 550 insertions, 0 deletions
diff --git a/lib/libc/include/stdio.h b/lib/libc/include/stdio.h
new file mode 100644
index 0000000..b3bf8df
--- /dev/null
+++ b/lib/libc/include/stdio.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _STDIO_H
+#define _STDIO_H 1
+
+#include <sys/cdefs.h>
+#define __need_NULL
+#define __need_size_t
+#include <stddef.h>
+#define __need_va_list
+#include <stdarg.h>
+
+#if __STDC_VERSION__ >= 202311L
+#define __STDC_VERSION_STDIO_H__ 202311L
+#endif
+
+/* Buffering modes */
+#define _IOFBF 0 /* Fully buffered */
+#define _IOLBF 1 /* Line buffered */
+#define _IONBF 2 /* Unbuffered */
+
+/* Default buffer size */
+#define BUFSIZ 256
+
+/* End-Of-File indicator */
+#define EOF (-1)
+
+/* Spec says these should be defined as macros */
+#define stdin stdin
+#define stdout stdout
+#define stderr stderr
+
+/* File structure */
+typedef struct _IO_FILE {
+ int fd;
+ int buf_mode;
+} FILE;
+
+extern FILE *stdin;
+extern FILE *stdout;
+extern FILE *stderr;
+
+#define putc(c, stream) fputc((c), (stream))
+
+__BEGIN_DECLS
+
+size_t fwrite(const void *__restrict ptr, size_t size, size_t n, FILE *__restrict stream);
+
+int fputc(int c, FILE *stream);
+int putchar(int c);
+
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+int fputs(const char *__restrict s, FILE *__restrict stream);
+#else
+int fputs(const char *s, FILE *stream);
+#endif
+int puts(const char *s);
+
+__END_DECLS
+
+#endif /* !_STDIO_H */
diff --git a/lib/libc/include/stdlib.h b/lib/libc/include/stdlib.h
new file mode 100644
index 0000000..054bdca
--- /dev/null
+++ b/lib/libc/include/stdlib.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _STDLIB_H
+#define _STDLIB_H 1
+
+/* For __dead */
+#include <sys/cdefs.h>
+
+/* Get specific definitions from stddef.h */
+#define __need_NULL
+#define __need_size_t
+#define __need_wchar_t
+#include <stddef.h>
+
+#if __STDC_VERSION__ >= 202311L
+#define __STDC_VERSION_STDLIB_H__ 202311L
+#endif
+
+#define EXIT_SUCCESS 0
+#define EXIT_FAILURE 1
+
+typedef struct {
+ int quot;
+ int rem;
+} div_t;
+
+#ifndef __ldiv_t_defined
+typedef struct {
+ long int quot;
+ long int rem;
+} ldiv_t;
+#define __ldiv_t_defined 1
+#endif /* !__ldiv_t_defined */
+
+#ifndef __lldiv_t_defined
+typedef struct {
+ long long int quot;
+ long long int rem;
+} lldiv_t;
+#define __lldiv_t_defined 1
+#endif /* !__lldiv_t_defined */
+
+__BEGIN_DECLS
+
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || (defined(__cplusplus) && __cplusplus >= 201103L)
+[[noreturn]] void abort(void);
+[[noreturn]] void exit(int status);
+[[noreturn]] void _Exit(int status);
+#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
+_Noreturn void abort(void);
+_Noreturn void exit(int status);
+_Noreturn void _Exit(int status);
+#else
+__dead void abort(void);
+__dead void exit(int status);
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+__dead void _Exit(int status);
+#endif
+#endif
+
+__END_DECLS
+
+#endif /* !_STDLIB_H */
diff --git a/lib/libc/src/main.c b/lib/libc/src/main.c
index 1154b21..d16b93e 100644
--- a/lib/libc/src/main.c
+++ b/lib/libc/src/main.c
@@ -30,10 +30,18 @@
#include <stdint.h>
#include <stddef.h>
+extern int __libc_stdio_init(void);
+
int main(int argc, char **argv);
int
__libc_entry(uint64_t *ctx)
{
+ int status;
+
+ if ((status = __libc_stdio_init()) != 0) {
+ return status;
+ }
+
return main(0, NULL);
}
diff --git a/lib/libc/src/stdio/fputc.c b/lib/libc/src/stdio/fputc.c
new file mode 100644
index 0000000..6ac7aac
--- /dev/null
+++ b/lib/libc/src/stdio/fputc.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+extern size_t __stdio_write(const void *__restrict ptr, size_t size, FILE *__restrict stream);
+
+int
+fputc(int c, FILE *stream)
+{
+ unsigned char val;
+
+ if (stream == NULL) {
+ return EOF;
+ }
+
+ val = (unsigned char)c;
+ if (__stdio_write(&val, sizeof(val), stream) != sizeof(val)) {
+ return EOF;
+ }
+
+ return (int)val;
+}
+
+int
+putchar(int c)
+{
+ return fputc(c, stdout);
+}
diff --git a/lib/libc/src/stdio/fputs.c b/lib/libc/src/stdio/fputs.c
new file mode 100644
index 0000000..357fd52
--- /dev/null
+++ b/lib/libc/src/stdio/fputs.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+extern size_t __stdio_write(const void *__restrict ptr, size_t size, FILE *__restrict stream);
+
+int
+fputs(const char *__restrict s, FILE *__restrict stream)
+{
+ size_t len;
+
+ if (s == NULL || stream == NULL) {
+ return EOF;
+ }
+
+ len = strlen(s);
+ if (len < 1) {
+ return 0;
+ }
+
+ if (__stdio_write(s, sizeof(char) * len, stream) != (sizeof(char) * len)) {
+ return EOF;
+ }
+
+ return 0;
+}
+
+int
+puts(const char *s)
+{
+ if (fputs(s, stdout) < 0) {
+ return EOF;
+ }
+
+ if (fputc('\n', stdout) != '\n') {
+ return EOF;
+ }
+
+ return 0;
+}
diff --git a/lib/libc/src/stdio/fwrite.c b/lib/libc/src/stdio/fwrite.c
new file mode 100644
index 0000000..660034e
--- /dev/null
+++ b/lib/libc/src/stdio/fwrite.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+
+size_t
+__stdio_write(const void *__restrict ptr, size_t size, FILE *__restrict stream)
+{
+ ssize_t count;
+
+ if (stream->buf_mode == _IONBF) {
+ if ((count = write(stream->fd, ptr, size)) < 0) {
+ return 0;
+ }
+
+ return count;
+ }
+
+ /*
+ * TODO: Implement more buffering modes.
+ */
+
+ return 0;
+}
+
+size_t
+fwrite(const void *__restrict ptr, size_t size, size_t n, FILE *__restrict stream)
+{
+ if (ptr == NULL || stream == NULL || (size * n) == 0) {
+ return 0;
+ }
+
+ return __stdio_write(ptr, size * n, stream);
+}
diff --git a/lib/libc/src/stdio/init.c b/lib/libc/src/stdio/init.c
new file mode 100644
index 0000000..5982d59
--- /dev/null
+++ b/lib/libc/src/stdio/init.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <fcntl.h>
+
+FILE *stdin;
+FILE *stdout;
+FILE *stderr;
+
+static FILE cin, cout, cerr;
+
+int
+__libc_stdio_init(void)
+{
+ int cfd;
+
+ if ((cfd = open("/dev/console", O_RDWR)) < 0) {
+ return cfd;
+ }
+
+ cin.buf_mode = _IONBF;
+ cin.fd = cfd;
+
+ cout.buf_mode = _IONBF;
+ cout.fd = cfd;
+
+ cerr.buf_mode = _IONBF;
+ cerr.fd = cfd;
+
+ stdout = &cout;
+ stdin = &cin;
+ stderr = &cerr;
+
+ return 0;
+}
diff --git a/lib/libc/src/stdlib/_Exit.c b/lib/libc/src/stdlib/_Exit.c
new file mode 100644
index 0000000..e975381
--- /dev/null
+++ b/lib/libc/src/stdlib/_Exit.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/syscall.h>
+#include <stdlib.h>
+
+__dead void
+_Exit(int status)
+{
+ syscall(SYS_exit, status);
+ __builtin_unreachable();
+}
diff --git a/lib/libc/src/stdlib/abort.c b/lib/libc/src/stdlib/abort.c
new file mode 100644
index 0000000..bc0a491
--- /dev/null
+++ b/lib/libc/src/stdlib/abort.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+
+__dead void
+abort(void)
+{
+ /*
+ * TODO: Call SIGABRT handler here.
+ */
+
+ _Exit(EXIT_FAILURE);
+}
diff --git a/lib/libc/src/stdlib/exit.c b/lib/libc/src/stdlib/exit.c
new file mode 100644
index 0000000..e5adfac
--- /dev/null
+++ b/lib/libc/src/stdlib/exit.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+
+__dead void
+exit(int status)
+{
+ /*
+ * TODO: Call atexit() handlers and do cleanup here.
+ */
+
+ _Exit(status);
+}