summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/Kbuild1
-rw-r--r--lib/libc/arch/x86_64/crt0.c4
-rw-r--r--lib/libc/include/__alpha.h233
-rw-r--r--lib/libc/include/libc.h2
-rw-r--r--lib/libc/libc.abin1152260 -> 1354228 bytes
-rw-r--r--lib/libc/signal/Kbuild1
-rw-r--r--lib/libc/signal/sig2str.c13
-rw-r--r--lib/libc/signal/sigabbrev.h22
-rw-r--r--lib/libc/signal/siglist.c47
-rw-r--r--lib/libc/signal/sysv_signal.c15
-rw-r--r--lib/libc/stat/futimens.c3
-rw-r--r--lib/libc/statvfs/fstatvfs.c2
-rw-r--r--lib/libc/statvfs/statvfs.c2
-rw-r--r--lib/libc/stdio/fmemopen.c1
-rw-r--r--lib/libc/stdio/vfprintf.c27
-rw-r--r--lib/libc/stdlib/Kbuild34
-rw-r--r--lib/libc/stdlib/__mb_cur_max.c6
-rw-r--r--lib/libc/stdlib/qsort_r.c31
-rw-r--r--lib/libc/stdlib/strtox.c1
-rw-r--r--lib/libc/stdlib/system.c1
-rw-r--r--lib/libc/string/memcpy.c39
-rw-r--r--lib/libc/string/strxfrm.c4
-rw-r--r--lib/libc/strings/strncasecmp.c2
-rw-r--r--lib/libc/termios/tcsendbreak.c3
-rw-r--r--lib/libc/thread/Kbuild1
-rw-r--r--lib/libc/time/Kbuild15
-rw-r--r--lib/libc/time/asctime.c9
-rw-r--r--lib/libc/time/gmtime_r.c2
-rw-r--r--lib/libc/time/strftime.c24
-rw-r--r--lib/libc/time/utimes.c4
-rw-r--r--lib/libc/uio/readv.c1
-rw-r--r--lib/libc/uio/writev.c1
-rw-r--r--lib/libc/unistd/execvp.c14
-rw-r--r--lib/libc/utime/Kbuild1
-rw-r--r--lib/libc/utime/utime.c14
35 files changed, 266 insertions, 314 deletions
diff --git a/lib/libc/Kbuild b/lib/libc/Kbuild
index dc0538a6..638e79cc 100644
--- a/lib/libc/Kbuild
+++ b/lib/libc/Kbuild
@@ -38,6 +38,7 @@ obj-y += time/
obj-y += times/
obj-y += uio/
obj-y += unistd/
+obj-y += utime/
obj-y += utsname/
obj-y += wait/
obj-y += wchar/
diff --git a/lib/libc/arch/x86_64/crt0.c b/lib/libc/arch/x86_64/crt0.c
index 2c7943ff..546d9c8a 100644
--- a/lib/libc/arch/x86_64/crt0.c
+++ b/lib/libc/arch/x86_64/crt0.c
@@ -12,8 +12,6 @@
extern int main(int, char *[]);
char **environ;
-static struct __thread_self thread = { .tid = 0, ._errno = 0 };
-
struct __attribute__((packed)) auxv_t {
uintptr_t a_type;
uintptr_t a_val;
@@ -47,8 +45,6 @@ __attribute__((used)) void __libc_start(uintptr_t *sp)
__auxv++;
}
- __asm__ volatile("wrfsbase %0" ::"r"(thread));
-
exit(main(argc, argv));
}
diff --git a/lib/libc/include/__alpha.h b/lib/libc/include/__alpha.h
deleted file mode 100644
index f2e8bfb1..00000000
--- a/lib/libc/include/__alpha.h
+++ /dev/null
@@ -1,233 +0,0 @@
-/* Alpha ISO8859-1 font data */
-18, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 17, 34, 35,
- 36, 17, 37, 38, 39, 40, 41, 42, 43, 44, 17, 45, 46, 47, 16, 16, 48, 16,
- 16, 16, 16, 16, 16, 16, 49, 50, 51, 16, 52, 53, 16, 16, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 54, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 55, 17, 17, 17, 17,
- 56, 17, 57, 58, 59, 60, 61, 62, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 63, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 64, 65, 17, 66,
- 67, 68, 69, 70, 71, 72, 73, 74, 17, 75, 76, 77, 78, 79, 80, 81, 16, 82,
- 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 16, 94, 95, 96, 16, 17, 17,
- 17, 97, 98, 99, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17,
- 100, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17,
- 101, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17,
- 102, 103, 16, 16, 104, 105, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 106, 17, 17, 107, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 17, 108, 109, 16, 16, 16, 16, 16, 16, 16, 16, 16, 110, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 111, 112, 113, 114, 16, 16, 16, 16, 16, 16, 16, 16, 115, 116, 117,
- 16, 16, 16, 16, 16, 118, 119, 16, 16, 16, 16, 120, 16, 16, 121, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 254, 255, 255, 7, 254, 255,
- 255, 7, 0, 0, 0, 0, 0, 4, 32, 4, 255, 255, 127, 255, 255, 255, 127, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 195, 255, 3, 0, 31,
- 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 223, 188, 64, 215,
- 255, 255, 251, 255, 255, 255, 255, 255, 255, 255, 255, 255, 191, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 3, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 255, 255, 255, 127, 2,
- 255, 255, 255, 255, 255, 1, 0, 0, 0, 0, 255, 191, 182, 0, 255, 255, 255,
- 135, 7, 0, 0, 0, 255, 7, 255, 255, 255, 255, 255, 255, 255, 254, 255,
- 195, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 239,
- 31, 254, 225, 255, 159, 0, 0, 255, 255, 255, 255, 255, 255, 0, 224, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 3, 0, 255, 255,
- 255, 255, 255, 7, 48, 4, 255, 255, 255, 252, 255, 31, 0, 0, 255, 255,
- 255, 1, 255, 7, 0, 0, 0, 0, 0, 0, 255, 255, 223, 63, 0, 0, 240, 255,
- 248, 3, 255, 255, 255, 255, 255, 255, 255, 255, 255, 239, 255, 223, 225,
- 255, 207, 255, 254, 255, 239, 159, 249, 255, 255, 253, 197, 227, 159,
- 89, 128, 176, 207, 255, 3, 16, 238, 135, 249, 255, 255, 253, 109, 195,
- 135, 25, 2, 94, 192, 255, 63, 0, 238, 191, 251, 255, 255, 253, 237, 227,
- 191, 27, 1, 0, 207, 255, 0, 30, 238, 159, 249, 255, 255, 253, 237, 227,
- 159, 25, 192, 176, 207, 255, 2, 0, 236, 199, 61, 214, 24, 199, 255, 195,
- 199, 29, 129, 0, 192, 255, 0, 0, 239, 223, 253, 255, 255, 253, 255, 227,
- 223, 29, 96, 7, 207, 255, 0, 0, 239, 223, 253, 255, 255, 253, 239, 227,
- 223, 29, 96, 64, 207, 255, 6, 0, 239, 223, 253, 255, 255, 255, 255, 231,
- 223, 93, 240, 128, 207, 255, 0, 252, 236, 255, 127, 252, 255, 255, 251,
- 47, 127, 128, 95, 255, 192, 255, 12, 0, 254, 255, 255, 255, 255, 127,
- 255, 7, 63, 32, 255, 3, 0, 0, 0, 0, 214, 247, 255, 255, 175, 255, 255,
- 59, 95, 32, 255, 243, 0, 0, 0, 0, 1, 0, 0, 0, 255, 3, 0, 0, 255, 254,
- 255, 255, 255, 31, 254, 255, 3, 255, 255, 254, 255, 255, 255, 31, 0, 0,
- 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 127, 249, 255, 3, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 63, 255, 255, 255, 255, 191, 32,
- 255, 255, 255, 255, 255, 247, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 61, 127, 61, 255, 255, 255, 255, 255, 61, 255, 255, 255, 255, 61,
- 127, 61, 255, 127, 255, 255, 255, 255, 255, 255, 255, 61, 255, 255, 255,
- 255, 255, 255, 255, 255, 7, 0, 0, 0, 0, 255, 255, 0, 0, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 63, 63, 254, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 159, 255, 255,
- 254, 255, 255, 7, 255, 255, 255, 255, 255, 255, 255, 255, 255, 199, 255,
- 1, 255, 223, 15, 0, 255, 255, 15, 0, 255, 255, 15, 0, 255, 223, 13, 0,
- 255, 255, 255, 255, 255, 255, 207, 255, 255, 1, 128, 16, 255, 3, 0, 0,
- 0, 0, 255, 3, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 1,
- 255, 255, 255, 255, 255, 7, 255, 255, 255, 255, 255, 255, 255, 255, 63,
- 0, 255, 255, 255, 127, 255, 15, 255, 1, 192, 255, 255, 255, 255, 63, 31,
- 0, 255, 255, 255, 255, 255, 15, 255, 255, 255, 3, 255, 3, 0, 0, 0, 0,
- 255, 255, 255, 15, 255, 255, 255, 255, 255, 255, 255, 127, 254, 255, 31,
- 0, 255, 3, 255, 3, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255,
- 255, 255, 255, 239, 255, 239, 15, 255, 3, 0, 0, 0, 0, 255, 255, 255,
- 255, 255, 243, 255, 255, 255, 255, 255, 255, 191, 255, 3, 0, 255, 255,
- 255, 255, 255, 255, 127, 0, 255, 227, 255, 255, 255, 255, 255, 63, 255,
- 1, 255, 255, 255, 255, 255, 231, 0, 0, 0, 0, 0, 222, 111, 4, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 128, 255, 31, 0,
- 255, 255, 63, 63, 255, 255, 255, 255, 63, 63, 255, 170, 255, 255, 255,
- 63, 255, 255, 255, 255, 255, 255, 223, 95, 220, 31, 207, 15, 255, 31,
- 220, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 128, 0, 0, 255,
- 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 132, 252, 47, 62, 80, 189, 255,
- 243, 224, 67, 0, 0, 255, 255, 255, 255, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 192, 255, 255, 255, 255, 255, 255, 3, 0, 0, 255, 255, 255,
- 255, 255, 127, 255, 255, 255, 255, 255, 127, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 31, 120, 12, 0,
- 255, 255, 255, 255, 191, 32, 255, 255, 255, 255, 255, 255, 255, 128, 0,
- 0, 255, 255, 127, 0, 127, 127, 127, 127, 127, 127, 127, 127, 255, 255,
- 255, 255, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 0, 0, 0, 254, 3, 62, 31, 254,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 224, 254, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 247, 224, 255, 255, 255, 255,
- 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 0, 0,
- 255, 255, 255, 7, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 31, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 63, 255, 31,
- 255, 255, 255, 15, 0, 0, 255, 255, 255, 255, 255, 127, 240, 143, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
- 0, 0, 128, 255, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 249, 255, 255, 255, 255, 255, 255, 124, 0, 0, 0, 0, 0, 128,
- 255, 191, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 15,
- 0, 255, 255, 255, 255, 255, 255, 255, 255, 47, 0, 255, 3, 0, 0, 252,
- 232, 255, 255, 255, 255, 255, 7, 255, 255, 255, 255, 7, 0, 255, 255,
- 255, 31, 255, 255, 255, 255, 255, 255, 247, 255, 0, 128, 255, 3, 255,
- 255, 255, 127, 255, 255, 255, 255, 255, 255, 127, 0, 255, 63, 255, 3,
- 255, 255, 127, 252, 255, 255, 255, 255, 255, 255, 255, 127, 5, 0, 0, 56,
- 255, 255, 60, 0, 126, 126, 126, 0, 127, 127, 255, 255, 255, 255, 255,
- 247, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 7, 255, 3, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 255, 255,
- 127, 248, 255, 255, 255, 255, 255, 15, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 63, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 3, 0, 0, 0, 0, 127, 0, 248, 224, 255,
- 253, 127, 95, 219, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 3, 0, 0, 0, 248, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 63, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255,
- 252, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 15, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 223, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 31, 0, 0, 255, 3, 254, 255,
- 255, 7, 254, 255, 255, 7, 192, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 127, 252, 252, 252, 28, 0, 0, 0, 0, 255, 239, 255, 255, 127,
- 255, 255, 183, 255, 63, 255, 63, 0, 0, 0, 0, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 7, 0, 0, 0, 0, 0, 0,
- 0, 0, 255, 255, 255, 255, 255, 255, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255,
- 255, 255, 31, 255, 255, 255, 255, 255, 255, 1, 0, 0, 0, 0, 0, 255, 255,
- 255, 255, 0, 224, 255, 255, 255, 7, 255, 255, 255, 255, 255, 7, 255,
- 255, 255, 63, 255, 255, 255, 255, 15, 255, 62, 0, 0, 0, 0, 0, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 63, 255, 3, 255, 255, 255, 255, 15, 255, 255, 255, 255,
- 15, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 15, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255,
- 255, 255, 127, 0, 255, 255, 63, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 63, 253, 255, 255, 255, 255, 191, 145, 255, 255,
- 63, 0, 255, 255, 127, 0, 255, 255, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0,
- 255, 255, 55, 0, 255, 255, 63, 0, 255, 255, 255, 3, 0, 0, 0, 0, 0, 0, 0,
- 0, 255, 255, 255, 255, 255, 255, 255, 192, 0, 0, 0, 0, 0, 0, 0, 0, 111,
- 240, 239, 254, 255, 255, 63, 0, 0, 0, 0, 0, 255, 255, 255, 31, 255, 255,
- 255, 31, 0, 0, 0, 0, 255, 254, 255, 255, 31, 0, 0, 0, 255, 255, 255,
- 255, 255, 255, 63, 0, 255, 255, 63, 0, 255, 255, 7, 0, 255, 255, 3, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 1, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 7, 0, 255,
- 255, 255, 255, 255, 255, 7, 0, 255, 255, 255, 255, 255, 0, 255, 3, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255,
- 255, 255, 31, 128, 0, 255, 255, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 255, 255, 127, 0, 255, 255, 255, 255, 255, 255,
- 255, 255, 63, 0, 0, 0, 192, 255, 0, 0, 252, 255, 255, 255, 255, 255,
- 255, 1, 0, 0, 255, 255, 255, 1, 255, 3, 255, 255, 255, 255, 255, 255,
- 199, 255, 112, 0, 255, 255, 255, 255, 71, 0, 255, 255, 255, 255, 255,
- 255, 255, 255, 30, 0, 255, 23, 0, 0, 0, 0, 255, 255, 251, 255, 255, 255,
- 159, 64, 0, 0, 0, 0, 0, 0, 0, 0, 127, 189, 255, 191, 255, 1, 255, 255,
- 255, 255, 255, 255, 255, 1, 255, 3, 239, 159, 249, 255, 255, 253, 237,
- 227, 159, 25, 129, 224, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 187, 7, 255, 131, 0,
- 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 179, 0, 255, 3, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255,
- 255, 255, 255, 63, 127, 0, 0, 0, 63, 0, 0, 0, 0, 255, 255, 255, 255,
- 255, 255, 255, 127, 17, 0, 255, 3, 0, 0, 0, 0, 255, 255, 255, 255, 255,
- 255, 63, 1, 255, 3, 0, 0, 0, 0, 0, 0, 255, 255, 255, 231, 255, 7, 255,
- 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 255, 255, 255, 255, 255, 255, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 3, 0, 128, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 252, 255, 255,
- 255, 255, 255, 252, 26, 0, 0, 0, 255, 255, 255, 255, 255, 255, 231, 127,
- 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 32, 0, 0, 0, 0, 255,
- 255, 255, 255, 255, 255, 255, 1, 255, 253, 255, 255, 255, 255, 127, 127,
- 1, 0, 255, 3, 0, 0, 252, 255, 255, 255, 252, 255, 255, 254, 127, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 127, 251, 255, 255, 255, 255, 127, 180, 203, 0,
- 255, 3, 191, 253, 255, 255, 255, 127, 123, 1, 255, 3, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 127, 0, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 3, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 127, 0, 0, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255,
- 255, 255, 255, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 1, 255, 255,
- 255, 127, 255, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 63,
- 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 15, 0, 255, 3, 248, 255, 255,
- 224, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 135, 255, 255, 255, 255, 255, 255, 255, 128, 255, 255, 0, 0, 0, 0, 0, 0,
- 0, 0, 11, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 7, 0, 255, 255, 255, 127,
- 0, 0, 0, 0, 0, 0, 7, 0, 240, 0, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 7, 255,
- 31, 255, 1, 255, 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 223, 255, 255, 255, 255, 255, 255,
- 255, 255, 223, 100, 222, 255, 235, 239, 255, 255, 255, 255, 255, 255,
- 255, 191, 231, 223, 223, 255, 255, 255, 123, 95, 252, 253, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 63, 255, 255,
- 255, 253, 255, 255, 247, 255, 255, 255, 247, 255, 255, 223, 255, 255,
- 255, 223, 255, 255, 127, 255, 255, 255, 127, 255, 255, 255, 253, 255,
- 255, 255, 253, 255, 255, 247, 207, 255, 255, 255, 255, 255, 255, 127,
- 255, 255, 249, 219, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 31, 128, 63, 255,
- 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 255, 255, 255, 255, 255, 15, 255, 3, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 31, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255,
- 255, 255, 143, 8, 255, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 239, 255, 255, 255, 150, 254, 247, 10, 132, 234, 150,
- 170, 150, 247, 247, 94, 255, 251, 255, 15, 238, 251, 255, 15, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 3, 255, 255, 255, 3,
- 255, 255, 255, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
diff --git a/lib/libc/include/libc.h b/lib/libc/include/libc.h
index d59c2b3c..7faee4b7 100644
--- a/lib/libc/include/libc.h
+++ b/lib/libc/include/libc.h
@@ -2,12 +2,12 @@
#define __LIBC_LIBC_H
#include <stdatomic.h>
+#include <features.h>
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#define __unused __attribute__((unused))
#define aligned(type) __attribute__((aligned(__alignof__(type))))
-#define __weak __attribute__((__weak__))
#define weak_reference(old, new) \
extern __typeof(old) new __attribute__((__weak__, __alias__(#old)))
diff --git a/lib/libc/libc.a b/lib/libc/libc.a
index 4f874074..49fadae3 100644
--- a/lib/libc/libc.a
+++ b/lib/libc/libc.a
Binary files differ
diff --git a/lib/libc/signal/Kbuild b/lib/libc/signal/Kbuild
index b8881c92..f8122caf 100644
--- a/lib/libc/signal/Kbuild
+++ b/lib/libc/signal/Kbuild
@@ -19,3 +19,4 @@ obj-y += sigtimedwait.o
obj-y += sigwait.o
obj-y += sigwaitinfo.o
obj-y += str2sig.o
+obj-y += sysv_signal.o
diff --git a/lib/libc/signal/sig2str.c b/lib/libc/signal/sig2str.c
index 209cb4c3..2532d539 100644
--- a/lib/libc/signal/sig2str.c
+++ b/lib/libc/signal/sig2str.c
@@ -6,25 +6,28 @@
int sig2str(int signum, char *str)
{
if (signum >= SIGHUP && signum <= SIGSYS) {
- strcpy(str, __sys_signame[signum - SIGHUP]);
+ strlcpy(str, __sys_signame[signum - SIGHUP],
+ sizeof(__sys_signame[signum - SIGHUP]));
return 0;
}
if (signum == SIGRTMIN) {
- strcpy(str, "SIGRTMIN");
+ strlcpy(str, "SIGRTMIN", sizeof("SIGRTMIN"));
return 0;
}
if (signum == SIGRTMAX) {
- strcpy(str, "RTMAX");
+ strlcpy(str, "SIGRTMAX", sizeof("SIGRTMAX"));
return 0;
}
if (signum > SIGRTMIN && signum < SIGRTMAX) {
if (signum - SIGRTMIN <= SIGRTMAX - signum) {
- sprintf(str, "RTMIN+%d", signum - SIGRTMIN);
+ snprintf(str, sizeof("RTMIN+") + 1, "RTMIN+%d",
+ signum - SIGRTMIN);
} else {
- sprintf(str, "RTMAX-%d", SIGRTMAX - signum);
+ snprintf(str, sizeof("RTMAX-") + 1, "RTMAX-%d",
+ SIGRTMAX - signum);
}
return 0;
}
diff --git a/lib/libc/signal/sigabbrev.h b/lib/libc/signal/sigabbrev.h
new file mode 100644
index 00000000..fa0ef1ce
--- /dev/null
+++ b/lib/libc/signal/sigabbrev.h
@@ -0,0 +1,22 @@
+#include <signal.h>
+#include <unistd.h>
+
+const char *const sys_sigabbrev[64] = {
+ [SIGABRT] = "ABRT", [SIGALRM] = "ALRM", [SIGBUS] = "BUS",
+ [SIGCHLD] = "CHLD", [SIGFPE] = "FPE", [SIGHUP] = "HUP",
+ [SIGILL] = "ILL", [SIGINT] = "INT", [SIGIO] = "IO",
+#if defined(SIGIOT) && (SIGIOT != SIGABRT)
+ [SIGIOT] = "IOT",
+#endif
+ [SIGKILL] = "KILL", [SIGPIPE] = "PIPE",
+#if defined(SIGPOLL) && (SIGPOLL != SIGIO)
+ [SIGPOLL] = "POLL",
+#endif
+ [SIGPROF] = "PROF", [SIGPWR] = "PWR", [SIGQUIT] = "QUIT",
+ [SIGSEGV] = "SEGV", [SIGSTKFLT] = "STKFLT", [SIGSTOP] = "STOP",
+ [SIGSYS] = "SYS", [SIGTERM] = "TERM", [SIGTSTP] = "TSTP",
+ [SIGTTIN] = "TTIN", [SIGTTOU] = "TTOU", [SIGURG] = "URG",
+ [SIGUSR1] = "USR1", [SIGUSR2] = "USR2", [SIGVTALRM] = "VTALRM",
+ [SIGWINCH] = "WINCH", [SIGXCPU] = "XCPU", [SIGXFSZ] = "XFSZ",
+ [SIGCONT] = "CONT", [SIGTRAP] = "TRAP",
+};
diff --git a/lib/libc/signal/siglist.c b/lib/libc/signal/siglist.c
new file mode 100644
index 00000000..ba9ec746
--- /dev/null
+++ b/lib/libc/signal/siglist.c
@@ -0,0 +1,47 @@
+#include <signal.h>
+#include <unistd.h>
+
+const char *const sys_siglist[64] = {
+ [SIGABRT] = "Aborted",
+ [SIGALRM] = "Alarm clock",
+ [SIGBUS] = "Bus error",
+ [SIGCHLD] = "Child exited",
+#if defined(SIGCLD) && (SIGCHLD != SIGCLD)
+ [SIGCLD] = "Child exited",
+#endif
+ [SIGHUP] = "Hangup",
+ [SIGILL] = "Illegal instruction",
+ [SIGINT] = "Interrupt",
+ [SIGIO] = "I/O possible",
+#if defined(SIGIOT) && (SIGIOT != SIGABRT)
+ [SIGIOT] = "I/O trap",
+#endif
+ [SIGKILL] = "Killed",
+#if defined(SIGLOST) && (SIGLOST != SIGIO) && (SIGLOST != SIGPWR)
+ [SIGLOST] = "Lock lost",
+#endif
+ [SIGPIPE] = "Broken pipe",
+#if defined(SIGPOLL) && (SIGPOLL != SIGIO)
+ [SIGPOLL] = "Pollable event",
+#endif
+ [SIGPROF] = "Profiling timer expired",
+ [SIGPWR] = "Power failure",
+ [SIGQUIT] = "Quit",
+ [SIGSEGV] = "Segment violation",
+ [SIGSTKFLT] = "Stack fault",
+ [SIGSTOP] = "Stopped (signal)",
+ [SIGSYS] = "Bad system call",
+ [SIGTERM] = "Terminated",
+ [SIGTSTP] = "Stopped",
+ [SIGTTIN] = "Stopped (tty input)",
+ [SIGTTOU] = "Stopped (tty output)",
+ [SIGURG] = "Urgent I/O condition",
+ [SIGUSR1] = "User signal 1",
+ [SIGUSR2] = "User signal 2",
+ [SIGVTALRM] = "Virtual timer expired",
+ [SIGWINCH] = "Window size changed",
+ [SIGXCPU] = "CPU time limit exceeded",
+ [SIGXFSZ] = "File size limit exceeded",
+ [SIGTRAP] = "Trace/breakpoint trap",
+ [SIGCONT] = "Continue",
+};
diff --git a/lib/libc/signal/sysv_signal.c b/lib/libc/signal/sysv_signal.c
new file mode 100644
index 00000000..2aa0221a
--- /dev/null
+++ b/lib/libc/signal/sysv_signal.c
@@ -0,0 +1,15 @@
+#include <signal.h>
+
+sighandler_t sysv_signal(int signum, sighandler_t handler)
+{
+ struct sigaction new_action, old_action;
+
+ new_action.sa_handler = handler;
+ sigemptyset(&new_action.sa_mask);
+ new_action.sa_flags = 0;
+
+ if (sigaction(signum, &new_action, &old_action) < 0)
+ return SIG_ERR;
+
+ return old_action.sa_handler;
+}
diff --git a/lib/libc/stat/futimens.c b/lib/libc/stat/futimens.c
index 974d2eb7..38c6876f 100644
--- a/lib/libc/stat/futimens.c
+++ b/lib/libc/stat/futimens.c
@@ -1,7 +1,6 @@
-#include <stddef.h>
#include <sys/stat.h>
int futimens(int fd, const struct timespec times[2])
{
- return utimensat(fd, NULL, times, 0);
+ return utimensat(fd, "", times, 0);
}
diff --git a/lib/libc/statvfs/fstatvfs.c b/lib/libc/statvfs/fstatvfs.c
index 8bf78d35..048db737 100644
--- a/lib/libc/statvfs/fstatvfs.c
+++ b/lib/libc/statvfs/fstatvfs.c
@@ -4,7 +4,7 @@
int fstatvfs(int fildes, struct __statvfs *buf)
{
- struct statfs statfs;
+ struct statfs statfs = { 0 };
if (syscall(fstatfs, fildes, &statfs) < 0)
return -1;
diff --git a/lib/libc/statvfs/statvfs.c b/lib/libc/statvfs/statvfs.c
index df8c9544..3a7c1f3e 100644
--- a/lib/libc/statvfs/statvfs.c
+++ b/lib/libc/statvfs/statvfs.c
@@ -4,7 +4,7 @@
int statvfs(const char *restrict path, struct __statvfs *restrict buf)
{
- struct statfs statfs;
+ struct statfs statfs = { 0 };
if (syscall(statfs, path, &statfs) < 0)
return -1;
diff --git a/lib/libc/stdio/fmemopen.c b/lib/libc/stdio/fmemopen.c
index 6830dcbe..b1fa0f8a 100644
--- a/lib/libc/stdio/fmemopen.c
+++ b/lib/libc/stdio/fmemopen.c
@@ -30,6 +30,7 @@ FILE *fmemopen(void *restrict buf, size_t max_size, const char *restrict mode)
} else if (mode[0] == 'a') {
flags = O_WRONLY | O_CREAT | O_APPEND;
} else {
+ free(f);
errno = EINVAL;
return NULL;
}
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c
index 495fb9ea..90e60f7f 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -325,11 +325,12 @@ int vfprintf(FILE *restrict stream, const char *restrict format, va_list ap)
int pos = 0;
if (isnan(val)) {
- strcpy(buf,
- (*ptr == 'F' || *ptr == 'E' ||
- *ptr == 'G') ?
- "NAN" :
- "nan");
+ strlcpy(buf,
+ (*ptr == 'F' || *ptr == 'E' ||
+ *ptr == 'G') ?
+ "NAN" :
+ "nan",
+ sizeof(buf));
l = 3;
break;
}
@@ -341,11 +342,12 @@ int vfprintf(FILE *restrict stream, const char *restrict format, va_list ap)
} else if (flags & FLAG_SPACE) {
buf[pos++] = ' ';
}
- strcpy(buf + pos,
- (*ptr == 'F' || *ptr == 'E' ||
- *ptr == 'G') ?
- "INF" :
- "inf");
+ strlcpy(buf + pos,
+ (*ptr == 'F' || *ptr == 'E' ||
+ *ptr == 'G') ?
+ "INF" :
+ "inf",
+ sizeof(buf) - pos);
l = pos + 3;
break;
}
@@ -607,8 +609,9 @@ int vfprintf(FILE *restrict stream, const char *restrict format, va_list ap)
}
if (val == 0.0) {
- strcpy(buf + pos,
- upper ? "0X0P+0" : "0x0p+0");
+ strlcpy(buf + pos,
+ upper ? "0X0P+0" : "0x0p+0",
+ sizeof(buf) - pos);
l = pos + 6;
break;
}
diff --git a/lib/libc/stdlib/Kbuild b/lib/libc/stdlib/Kbuild
new file mode 100644
index 00000000..6d7efef7
--- /dev/null
+++ b/lib/libc/stdlib/Kbuild
@@ -0,0 +1,34 @@
+obj-y += _Exit.o
+obj-y += abort.o
+obj-y += abs.o
+obj-y += aligned_alloc.o
+obj-y += atexit.o
+obj-y += atof.o
+obj-y += atoi.o
+obj-y += atol.o
+obj-y += atoll.o
+obj-y += bsearch.o
+obj-y += calloc.o
+obj-y += div.o
+obj-y += exit.o
+obj-y += free.o
+obj-y += getenv.o
+obj-y += heapsort_r.o
+obj-y += heapsort.o
+obj-y += labs.o
+obj-y += ldiv.o
+obj-y += llabs.o
+obj-y += lldiv.o
+obj-y += malloc.o
+obj-y += posix_memalign.o
+obj-y += putenv.o
+obj-y += qsort_r.o
+obj-y += qsort.o
+obj-y += quick_exit.o
+obj-y += rand.o
+obj-y += realloc.o
+obj-y += reallocarray.o
+obj-y += setenv.o
+obj-y += strtox.o
+obj-y += system.o
+obj-y += unsetenv.o
diff --git a/lib/libc/stdlib/__mb_cur_max.c b/lib/libc/stdlib/__mb_cur_max.c
deleted file mode 100644
index 2f8affa2..00000000
--- a/lib/libc/stdlib/__mb_cur_max.c
+++ /dev/null
@@ -1,6 +0,0 @@
-int __mb_cur_max(void)
-{
- // TODO: if locale (c/utf8) will be implemented
- // then return the correct value here if c then 1 else if utf8 then 4
- return 1;
-}
diff --git a/lib/libc/stdlib/qsort_r.c b/lib/libc/stdlib/qsort_r.c
index 2fc39a6f..646eeaff 100644
--- a/lib/libc/stdlib/qsort_r.c
+++ b/lib/libc/stdlib/qsort_r.c
@@ -22,7 +22,8 @@
/* Minor changes by Rich Felker for integration in musl, 2011-04-27. */
/* Smoothsort, an adaptive variant of Heapsort. Memory usage: O(1).
- Run time: Worst case O(n log n), close to O(n) in the mostly-sorted case. */
+ Run time: Worst case O(n log n), close to O(n) in the
+ mostly-sorted case. */
#define _BSD_SOURCE
#include <stdlib.h>
@@ -68,13 +69,15 @@ static void cycle(size_t width, unsigned char *ar[], int n)
/* shl() and shr() need n > 0 */
static inline void shl(size_t p[2], int n)
{
- if (n >= 8 * sizeof(size_t)) {
- n -= 8 * sizeof(size_t);
+ size_t bits = sizeof(size_t) * 8;
+
+ if (n >= (int)bits) {
+ n -= (int)bits;
p[1] = p[0];
p[0] = 0;
}
p[1] <<= n;
- p[1] |= (n < sizeof(size_t) * 8) ? p[0] >> (sizeof(size_t) * 8 - n) : 0;
+ p[1] |= (n < (int)bits) ? p[0] >> (bits - n) : 0;
p[0] <<= n;
}
@@ -82,19 +85,19 @@ static inline void shr(size_t p[2], int n)
{
size_t bits = sizeof(size_t) * 8;
- if (n >= 8 * sizeof(size_t)) {
- n -= 8 * sizeof(size_t);
+ if (n >= (int)bits) {
+ n -= (int)bits;
p[0] = p[1];
p[1] = 0;
}
p[0] >>= n;
- p[0] |= (n > 0 && n < bits) ? p[1] << (bits - n) : 0;
+ p[0] |= (n > 0 && n < (int)bits) ? p[1] << (bits - n) : 0;
p[1] >>= n;
}
static void sift(unsigned char *head, size_t width, cmpfun cmp, void *arg,
- int pshift, size_t lp[])
+ int pshift, size_t lp[], int max_lp_index)
{
unsigned char *rt, *lf;
unsigned char *ar[14 * sizeof(size_t) + 1];
@@ -102,6 +105,9 @@ static void sift(unsigned char *head, size_t width, cmpfun cmp, void *arg,
ar[0] = head;
while (pshift > 1) {
+ if (pshift - 2 < 0 || pshift - 2 > max_lp_index)
+ break;
+
rt = head - width;
lf = head - width - lp[pshift - 2];
@@ -162,7 +168,7 @@ static void trinkle(unsigned char *head, size_t width, cmpfun cmp, void *arg,
}
if (!trusty) {
cycle(width, ar, i);
- sift(head, width, cmp, arg, pshift, lp);
+ sift(head, width, cmp, arg, pshift, lp, max_lp_index);
}
}
@@ -190,16 +196,17 @@ void qsort_r(void *base, size_t nel, size_t width, cmpfun cmp, void *arg)
while (head < high) {
if ((p[0] & 3) == 3) {
- sift(head, width, cmp, arg, pshift, lp);
+ sift(head, width, cmp, arg, pshift, lp, max_lp_index);
shr(p, 2);
pshift += 2;
} else {
if (pshift - 1 >= 0 && pshift - 1 <= max_lp_index &&
- lp[pshift - 1] >= high - head) {
+ lp[pshift - 1] >= (size_t)(high - head)) {
trinkle(head, width, cmp, arg, p, pshift, 0, lp,
max_lp_index);
} else {
- sift(head, width, cmp, arg, pshift, lp);
+ sift(head, width, cmp, arg, pshift, lp,
+ max_lp_index);
}
if (pshift == 1) {
diff --git a/lib/libc/stdlib/strtox.c b/lib/libc/stdlib/strtox.c
index 9d72954a..e924e5e6 100644
--- a/lib/libc/stdlib/strtox.c
+++ b/lib/libc/stdlib/strtox.c
@@ -66,7 +66,6 @@ __scanint(const char *s, int base, unsigned long long lim, int *neg, char **end)
static long double __scanfloat(const char *s, char **end)
{
long double value = 0.0;
- long double frac = 0.0;
long double sign = 1.0;
long double scale = 1.0;
int exp_sign = 1;
diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c
index 4f560ce1..95f8d732 100644
--- a/lib/libc/stdlib/system.c
+++ b/lib/libc/stdlib/system.c
@@ -2,6 +2,7 @@
int system(const char *command)
{
+ (void)command;
// TODO
return 0;
}
diff --git a/lib/libc/string/memcpy.c b/lib/libc/string/memcpy.c
index ecdbd602..05586b55 100644
--- a/lib/libc/string/memcpy.c
+++ b/lib/libc/string/memcpy.c
@@ -1,3 +1,4 @@
+#include <errno.h>
#include <string.h>
#include <features.h>
@@ -14,3 +15,41 @@ void *memcpy(void *restrict s1, const void *restrict s2, size_t n)
return s1;
}
+
+errno_t memcpy_s(void *restrict dest, rsize_t destsz, const void *restrict src,
+ rsize_t count)
+{
+ if (dest == NULL || src == NULL) {
+ if (dest != NULL && destsz > 0) {
+ unsigned char *d = dest;
+ for (rsize_t i = 0; i < destsz; i++) {
+ d[i] = 0;
+ }
+ }
+
+ return EINVAL;
+ }
+
+ const unsigned char *s = src;
+ unsigned char *d = dest;
+
+ if ((d > s && d < s + count) || (s > d && s < d + count)) {
+ for (rsize_t i = 0; i < destsz; i++) {
+ d[i] = 0;
+ }
+ return EINVAL;
+ }
+
+ if (count > destsz) {
+ for (rsize_t i = 0; i < destsz; i++) {
+ d[i] = 0;
+ }
+ return ERANGE;
+ }
+
+ for (rsize_t i = 0; i < count; i++) {
+ d[i] = s[i];
+ }
+
+ return 0;
+}
diff --git a/lib/libc/string/strxfrm.c b/lib/libc/string/strxfrm.c
index 123ebfe8..d216733b 100644
--- a/lib/libc/string/strxfrm.c
+++ b/lib/libc/string/strxfrm.c
@@ -6,13 +6,13 @@ size_t strxfrm(char *restrict s1, const char *restrict s2, size_t n)
size_t len = strlen(s2);
if (n > len)
- strcpy(s1, s2);
+ strlcpy(s1, s2, n);
return len;
}
__weak size_t strxfrm_l(char *restrict s1, const char *restrict s2, size_t n,
- locale_t __unused locale)
+ locale_t __unused locale)
{
return strxfrm(s1, s2, n);
}
diff --git a/lib/libc/strings/strncasecmp.c b/lib/libc/strings/strncasecmp.c
index f2f4c22c..7c2c9717 100644
--- a/lib/libc/strings/strncasecmp.c
+++ b/lib/libc/strings/strncasecmp.c
@@ -26,7 +26,7 @@ int strncasecmp(const char *s1, const char *s2, size_t n)
}
__weak int strncasecmp_l(const char *s1, const char *s2, size_t n,
- locale_t __unused locale)
+ locale_t __unused locale)
{
return strncasecmp(s1, s2, n);
}
diff --git a/lib/libc/termios/tcsendbreak.c b/lib/libc/termios/tcsendbreak.c
index a6ed420d..65f1d5b0 100644
--- a/lib/libc/termios/tcsendbreak.c
+++ b/lib/libc/termios/tcsendbreak.c
@@ -1,8 +1,9 @@
+#include <libc.h>
#include <termios.h>
#include <syscall.h>
#include <asm-generic/ioctls.h>
-int tcsendbreak(int fildes, int duration)
+int tcsendbreak(int fildes, int __unused duration)
{
// IEEE Std 1003.1-2024
// If duration is not 0, it shall send zero-valued
diff --git a/lib/libc/thread/Kbuild b/lib/libc/thread/Kbuild
new file mode 100644
index 00000000..3e28ece3
--- /dev/null
+++ b/lib/libc/thread/Kbuild
@@ -0,0 +1 @@
+obj-y += thrd_current.o
diff --git a/lib/libc/time/Kbuild b/lib/libc/time/Kbuild
new file mode 100644
index 00000000..6b9e00cc
--- /dev/null
+++ b/lib/libc/time/Kbuild
@@ -0,0 +1,15 @@
+obj-y += asctime.o
+obj-y += clock_getcpuclockid.o
+obj-y += clock_getres.o
+obj-y += clock_nanosleep.o
+obj-y += clock.o
+obj-y += ctime.o
+obj-y += difftime.o
+obj-y += gmtime_r.o
+obj-y += localtime_r.o
+obj-y += localtime.o
+obj-y += nanosleep.o
+obj-y += strftime.o
+obj-y += time.o
+obj-y += tzset.o
+obj-y += utimes.o
diff --git a/lib/libc/time/asctime.c b/lib/libc/time/asctime.c
index 54729a77..ab5ff096 100644
--- a/lib/libc/time/asctime.c
+++ b/lib/libc/time/asctime.c
@@ -3,11 +3,10 @@
char *asctime(const struct tm *timeptr)
{
- static char wday_name[7][3] = { "Sun", "Mon", "Tue", "Wed",
- "Thu", "Fri", "Sat" };
- static char mon_name[12][3] = { "Jan", "Feb", "Mar", "Apr",
- "May", "Jun", "Jul", "Aug",
- "Sep", "Oct", "Nov", "Dec" };
+ static char wday_name[][4] = { "Sun", "Mon", "Tue", "Wed",
+ "Thu", "Fri", "Sat" };
+ static char mon_name[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
static char result[26];
snprintf(result, sizeof(result), "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
diff --git a/lib/libc/time/gmtime_r.c b/lib/libc/time/gmtime_r.c
index 8d441549..2c741127 100644
--- a/lib/libc/time/gmtime_r.c
+++ b/lib/libc/time/gmtime_r.c
@@ -4,7 +4,7 @@ struct tm *gmtime_r(const time_t *timer, struct tm *result)
{
time_t t = *timer;
int days, rem;
- int year, month;
+ int year;
rem = t % 86400;
days = t / 86400;
diff --git a/lib/libc/time/strftime.c b/lib/libc/time/strftime.c
index f0881eb1..3f54961b 100644
--- a/lib/libc/time/strftime.c
+++ b/lib/libc/time/strftime.c
@@ -9,7 +9,7 @@ static size_t append_string(char *restrict *s, size_t *remaining,
if (len >= *remaining) {
return 0;
}
- strcpy(*s, str);
+ strlcpy(*s, str, *remaining);
*s += len;
*remaining -= len;
return len;
@@ -73,26 +73,10 @@ static const char *month_full[] = { "January", "February", "March",
"July", "August", "September",
"October", "November", "December" };
-static int day_of_year(const struct tm *tm)
-{
- static const int days_to_month[] = { 0, 31, 59, 90, 120, 151,
- 181, 212, 243, 273, 304, 334 };
- int days = days_to_month[tm->tm_mon] + tm->tm_mday;
-
- if (tm->tm_mon > 1) {
- int year = tm->tm_year + 1900;
- if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
- days++;
- }
- }
- return days;
-}
-
static int iso_week_number(const struct tm *tm, int *week_year)
{
int year = tm->tm_year + 1900;
int yday = tm->tm_yday + 1;
- int wday;
int jan4_wday = (4 + year + (year - 1) / 4 - (year - 1) / 100 +
(year - 1) / 400) %
@@ -554,9 +538,9 @@ size_t strftime(char *restrict s, size_t maxsize, const char *restrict format,
}
__weak size_t strftime_l(char *restrict s, size_t maxsize,
- const char *restrict format,
- const struct tm *restrict timeptr,
- locale_t __unused locale)
+ const char *restrict format,
+ const struct tm *restrict timeptr,
+ locale_t __unused locale)
{
return strftime(s, maxsize, format, timeptr);
}
diff --git a/lib/libc/time/utimes.c b/lib/libc/time/utimes.c
index d6448c76..7b928e7a 100644
--- a/lib/libc/time/utimes.c
+++ b/lib/libc/time/utimes.c
@@ -9,8 +9,8 @@ int utimes(const char *path, const struct timeval times[2])
struct timespec ts[2];
if (times) {
- if (times[0].tv_usec >= 1000000ULL ||
- times[1].tv_usec >= 1000000ULL) {
+ if (times[0].tv_usec >= 1000000L ||
+ times[1].tv_usec >= 1000000L) {
errno = EINVAL;
return -1;
}
diff --git a/lib/libc/uio/readv.c b/lib/libc/uio/readv.c
index 8a2d9216..baca678d 100644
--- a/lib/libc/uio/readv.c
+++ b/lib/libc/uio/readv.c
@@ -45,7 +45,6 @@ ssize_t readv(int fd, const struct iovec *iov, int iovcnt)
tmp.iov_base = (char *)tmp.iov_base + remaining;
tmp.iov_len -= remaining;
memcpy(local, &tmp, sizeof(tmp));
- remaining = 0;
break;
}
}
diff --git a/lib/libc/uio/writev.c b/lib/libc/uio/writev.c
index 4e304336..6f629ba0 100644
--- a/lib/libc/uio/writev.c
+++ b/lib/libc/uio/writev.c
@@ -39,7 +39,6 @@ ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
tmp.iov_base = (char *)tmp.iov_base + remaining;
tmp.iov_len -= remaining;
memcpy(local, &tmp, sizeof(tmp));
- remaining = 0;
break;
}
}
diff --git a/lib/libc/unistd/execvp.c b/lib/libc/unistd/execvp.c
index ae8ecdb9..c678ed36 100644
--- a/lib/libc/unistd/execvp.c
+++ b/lib/libc/unistd/execvp.c
@@ -34,7 +34,12 @@ int execvp(const char *file, char *const argv[])
return -1;
}
- execv(buf, argv);
+ /* Validate path doesn't contain dangerous
+ * characters */
+ if (strstr(buf, "..") == NULL &&
+ strchr(buf, '\0') == buf + strlen(buf)) {
+ execv(buf, argv);
+ }
break;
}
@@ -45,7 +50,12 @@ int execvp(const char *file, char *const argv[])
return -1;
}
- execv(buf, argv);
+ /* Validate path doesn't contain dangerous characters */
+ if (strstr(buf, "..") == NULL &&
+ strchr(buf, '\0') == buf + strlen(buf)) {
+ execv(buf, argv);
+ }
+ path = ptr + 1;
} while (*ptr != '\0');
errno = ENOENT;
diff --git a/lib/libc/utime/Kbuild b/lib/libc/utime/Kbuild
new file mode 100644
index 00000000..b1976215
--- /dev/null
+++ b/lib/libc/utime/Kbuild
@@ -0,0 +1 @@
+obj-y += utime.o
diff --git a/lib/libc/utime/utime.c b/lib/libc/utime/utime.c
new file mode 100644
index 00000000..8d6b91c6
--- /dev/null
+++ b/lib/libc/utime/utime.c
@@ -0,0 +1,14 @@
+#include <utime.h>
+#include <sys/time.h>
+
+int utime(const char *filename, const struct utimbuf *buf)
+{
+ struct timeval tvp[2];
+
+ tvp[0].tv_sec = buf->actime;
+ tvp[0].tv_usec = 0;
+ tvp[1].tv_sec = buf->modtime;
+ tvp[1].tv_usec = 0;
+
+ return utimes(filename, tvp);
+}