commit 7c50a30f3752d051e7745525d25740e88d115366
parent 5c8293050bf3288cccd5249ee120460a49a43631
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Sat, 2 May 2026 09:47:58 +0200
Merge remote-tracking branch 'origin/master'
Diffstat:
31 files changed, 940 insertions(+), 5 deletions(-)
diff --git a/include/scc/bits/darwin/sys/stdlib.h b/include/scc/bits/darwin/sys/stdlib.h
@@ -1,2 +1,3 @@
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
+#define __SCC_PUTENV__
diff --git a/include/scc/bits/dragonfly/sys/stdlib.h b/include/scc/bits/dragonfly/sys/stdlib.h
@@ -1,2 +1,3 @@
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
+#define __SCC_PUTENV__
diff --git a/include/scc/bits/freebsd/sys/stdlib.h b/include/scc/bits/freebsd/sys/stdlib.h
@@ -1,2 +1,3 @@
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
+#define __SCC_PUTENV__
diff --git a/include/scc/bits/linux/sys/stdlib.h b/include/scc/bits/linux/sys/stdlib.h
@@ -1,2 +1,3 @@
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
+#define __SCC_PUTENV__
diff --git a/include/scc/bits/netbsd/sys/stdlib.h b/include/scc/bits/netbsd/sys/stdlib.h
@@ -1,2 +1,3 @@
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
+#define __SCC_PUTENV__
diff --git a/include/scc/bits/openbsd/sys/stdlib.h b/include/scc/bits/openbsd/sys/stdlib.h
@@ -1,2 +1,3 @@
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
+#define __SCC_PUTENV__
diff --git a/src/cmd/scc-cc/cc1/expr.c b/src/cmd/scc-cc/cc1/expr.c
@@ -50,6 +50,14 @@ cmpnode(Node *np, unsigned long long val)
mask = (val > 1) ? ones(np->type->size) : -1;
nodeval = (tp->prop & TSIGNED) ? sym->u.i : sym->u.u;
return (nodeval & mask) == (val & mask);
+ case FLOAT:
+ if (tp == floattype)
+ return sym->u.f == val;
+ else if (tp == doubletype)
+ return sym->u.d == val;
+ else
+ return sym->u.d == val;
+ break;
default:
abort();
}
diff --git a/src/cmd/scc-cc/cc1/init.c b/src/cmd/scc-cc/cc1/init.c
@@ -471,7 +471,7 @@ emitstrings(Node *np)
emit(ODECL, sym);
emit(OINIT, constnode(sym));
} else if (f == SINITLST) {
- n = np->type->n.elem;
+ n = (np->type->op == UNION) ? 1 : np->type->n.elem;
for (i = 0; i < n; ++i)
emitstrings(sym->u.init[i]);
}
diff --git a/src/libc/stdlib/qsort.c b/src/libc/stdlib/qsort.c
@@ -14,7 +14,7 @@ struct qsort {
};
static void
-swap(char *i, char *j, size_t n)
+swap(unsigned char *i, unsigned char *j, size_t n)
{
do {
char c = *i;
@@ -29,10 +29,10 @@ swap(char *i, char *j, size_t n)
* array.
*/
static void
-xqsort(char *a, size_t n, struct qsort *qs)
+xqsort(unsigned char *a, size_t n, struct qsort *qs)
{
size_t nj, ni, es = qs->es;
- char *pi, *pj, *pn;
+ unsigned char *pi, *pj, *pn;
if (n <= 1)
return;
@@ -59,7 +59,7 @@ xqsort(char *a, size_t n, struct qsort *qs)
pi = a;
ni = (pj - a) / es;
pj += es;
- nj = n-nj-1;
+ nj = n-ni-1;
if (ni < nj) {
xqsort(pi, ni, qs);
diff --git a/tests/cc/execute/.gitignore b/tests/cc/execute/.gitignore
@@ -4,3 +4,4 @@ tmp_*.c
a.out
0270-union
0271-struct
+0272-div
diff --git a/tests/cc/execute/0272-div.c b/tests/cc/execute/0272-div.c
@@ -0,0 +1,15 @@
+double g = 3.0;
+
+int
+main(void)
+{
+ float f;
+ double d;
+
+ f = g / 4;
+ d = g / 3;
+
+ if (f == 0 || f == 0)
+ return 1;
+ return 0;
+}
diff --git a/tests/cc/execute/scc-tests.lst b/tests/cc/execute/scc-tests.lst
@@ -262,3 +262,4 @@
0269-extern.c
0270-union.c
0271-struct.c
+0272-div.c
diff --git a/tests/libc/execute/.gitignore b/tests/libc/execute/.gitignore
@@ -77,3 +77,20 @@ test.log
0076-localeconv
0077-setlocale
0078-time
+0079-atof
+0080-atoi
+0081-atol
+0082-atoll
+0083-strtod
+0084-strtof
+0085-strtold
+0086-strtol
+0087-stroll
+0088-stroul
+0089-stroull
+0090-rand
+0091-atexit
+0092-getenv
+0093-system
+0094-bsearch
+0095-abs
diff --git a/tests/libc/execute/0079-atof.c b/tests/libc/execute/0079-atof.c
@@ -0,0 +1,17 @@
+/*
+ * TODO: Just a placeholder to remember that our wcwidth()
+ * is only a mock of the actual implementation.
+ */
+
+/*
+output:
+testing
+done
+end:
+*/
+
+int
+main(void)
+{
+ return 0;
+}
diff --git a/tests/libc/execute/0080-atoi.c b/tests/libc/execute/0080-atoi.c
@@ -0,0 +1,63 @@
+#include <assert.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+output:
+testing
+done
+end:
+*/
+
+void
+test(void)
+{
+ int n;
+ char buf[64];
+
+ n = atoi("abc");
+ assert(n == 0);
+
+ n = atoi(" abc");
+ assert(n == 0);
+
+ n = atoi("1234 ");
+ assert(n == 1234);
+
+ n = atoi(" 1234 0");
+ assert(n == 1234);
+
+ n = atoi("+");
+ assert(n == 0);
+
+ n = atoi(" +1");
+ assert(n == 1);
+
+ n = atoi("+ 1");
+ assert(n == 0);
+
+ n = atoi(" -1");
+ assert(n == -1);
+
+ n = atoi("- 1");
+ assert(n == 0);
+
+ sprintf(buf, "%d", INT_MAX);
+ n = atoi(buf);
+ assert(n == INT_MAX);
+
+ sprintf(buf, "%d", INT_MIN);
+ n = atoi(buf);
+ assert(n == INT_MIN);
+}
+
+int
+main()
+{
+ puts("testing");
+ test();
+ puts("done");
+
+ return 0;
+}
diff --git a/tests/libc/execute/0081-atol.c b/tests/libc/execute/0081-atol.c
@@ -0,0 +1,63 @@
+#include <assert.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+output:
+testing
+done
+end:
+*/
+
+void
+test(void)
+{
+ long n;
+ char buf[64];
+
+ n = atol("abc");
+ assert(n == 0);
+
+ n = atol(" abc");
+ assert(n == 0);
+
+ n = atol("1234 ");
+ assert(n == 1234);
+
+ n = atol(" 1234 0");
+ assert(n == 1234);
+
+ n = atol("+");
+ assert(n == 0);
+
+ n = atol(" +1");
+ assert(n == 1);
+
+ n = atol("+ 1");
+ assert(n == 0);
+
+ n = atol(" -1");
+ assert(n == -1);
+
+ n = atol("- 1");
+ assert(n == 0);
+
+ sprintf(buf, "%ld", LONG_MAX);
+ n = atol(buf);
+ assert(n == LONG_MAX);
+
+ sprintf(buf, "%ld", LONG_MIN);
+ n = atol(buf);
+ assert(n == LONG_MIN);
+}
+
+int
+main()
+{
+ puts("testing");
+ test();
+ puts("done");
+
+ return 0;
+}
diff --git a/tests/libc/execute/0082-atoll.c b/tests/libc/execute/0082-atoll.c
@@ -0,0 +1,63 @@
+#include <assert.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+output:
+testing
+done
+end:
+*/
+
+void
+test(void)
+{
+ long long n;
+ char buf[64];
+
+ n = atoll("abc");
+ assert(n == 0);
+
+ n = atoll(" abc");
+ assert(n == 0);
+
+ n = atoll("1234 ");
+ assert(n == 1234);
+
+ n = atoll(" 1234 0");
+ assert(n == 1234);
+
+ n = atoll("+");
+ assert(n == 0);
+
+ n = atoll(" +1");
+ assert(n == 1);
+
+ n = atoll("+ 1");
+ assert(n == 0);
+
+ n = atoll(" -1");
+ assert(n == -1);
+
+ n = atoll("- 1");
+ assert(n == 0);
+
+ sprintf(buf, "%lld", LONG_MAX);
+ n = atoll(buf);
+ assert(n == LLONG_MAX);
+
+ sprintf(buf, "%lld", LONG_MIN);
+ n = atoll(buf);
+ assert(n == LLONG_MIN);
+}
+
+int
+main()
+{
+ puts("testing");
+ test();
+ puts("done");
+
+ return 0;
+}
diff --git a/tests/libc/execute/0083-strtod.c b/tests/libc/execute/0083-strtod.c
@@ -0,0 +1,17 @@
+/*
+ * TODO: Just a placeholder to remember that our wcwidth()
+ * is only a mock of the actual implementation.
+ */
+
+/*
+output:
+testing
+done
+end:
+*/
+
+int
+main(void)
+{
+ return 0;
+}
diff --git a/tests/libc/execute/0084-strtof.c b/tests/libc/execute/0084-strtof.c
@@ -0,0 +1,17 @@
+/*
+ * TODO: Just a placeholder to remember that our wcwidth()
+ * is only a mock of the actual implementation.
+ */
+
+/*
+output:
+testing
+done
+end:
+*/
+
+int
+main(void)
+{
+ return 0;
+}
diff --git a/tests/libc/execute/0085-strtold.c b/tests/libc/execute/0085-strtold.c
@@ -0,0 +1,17 @@
+/*
+ * TODO: Just a placeholder to remember that our wcwidth()
+ * is only a mock of the actual implementation.
+ */
+
+/*
+output:
+testing
+done
+end:
+*/
+
+int
+main(void)
+{
+ return 0;
+}
diff --git a/tests/libc/execute/0086-strtol.c b/tests/libc/execute/0086-strtol.c
@@ -0,0 +1,76 @@
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+output:
+testing
+done
+end:
+*/
+
+
+int
+test(void)
+{
+ long n;
+ char buf[64], *endp;
+
+ errno = 0;
+ n = strtol("1024", NULL, 10);
+ assert(n == 1024 && errno == 0);
+
+ n = strtol("1024", &endp, 10);
+ assert(n == 1024 && errno == 0 && *endp == '\0');
+
+ n = strtol("1000", &endp, 10);
+ assert(n == 1000 && errno == 0 && *endp == '\0');
+
+ n = strtol("1000", &endp, 8);
+ assert(n == 512 && errno == 0 && *endp == '\0');
+
+ n = strtol("1000", &endp, 16);
+ assert(n == 4096 && errno == 0 && *endp == '\0');
+
+ n = strtol("1000", &endp, 0);
+ assert(n == 1000 && errno == 0 && *endp == '\0');
+
+ n = strtol("0x1000", &endp, 0);
+ assert(n == 4096 && errno == 0 && *endp == '\0');
+
+ n = strtol("01000", &endp, 0);
+ assert(n == 512 && errno == 0 && *endp == '\0');
+
+ n = strtol(" +1a", &endp, 0);
+ assert(n == 1 && errno == 0 && *endp == 'a');
+
+ n = strtol(" -1a", &endp, 0);
+ assert(n == -1 && errno == 0 && *endp == 'a');
+
+ sprintf(buf, "%ld", LONG_MAX);
+ n = strtol(buf, NULL, 10);
+ assert(n == LONG_MAX && errno == 0);
+
+ sprintf(buf, "%ld", LONG_MIN);
+ n = strtol(buf, NULL, 10);
+ assert(n == LONG_MIN && errno == 0);
+
+ n = strtol("9999999999999999999999999", NULL, 10);
+ assert(n == LONG_MAX && errno == ERANGE);
+
+ errno = 0;
+ n = strtol("-999999999999999999999999", NULL, 10);
+ assert(n == LONG_MIN && errno == ERANGE);
+}
+
+int
+main(void)
+{
+ puts("testing");
+ test();
+ puts("done");
+
+ return 0;
+}
diff --git a/tests/libc/execute/0087-stroll.c b/tests/libc/execute/0087-stroll.c
@@ -0,0 +1,76 @@
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+output:
+testing
+done
+end:
+*/
+
+
+int
+test(void)
+{
+ long long n;
+ char buf[64], *endp;
+
+ errno = 0;
+ n = strtoll("1024", NULL, 10);
+ assert(n == 1024 && errno == 0);
+
+ n = strtoll("1024", &endp, 10);
+ assert(n == 1024 && errno == 0 && *endp == '\0');
+
+ n = strtoll("1000", &endp, 10);
+ assert(n == 1000 && errno == 0 && *endp == '\0');
+
+ n = strtoll("1000", &endp, 8);
+ assert(n == 512 && errno == 0 && *endp == '\0');
+
+ n = strtoll("1000", &endp, 16);
+ assert(n == 4096 && errno == 0 && *endp == '\0');
+
+ n = strtoll("1000", &endp, 0);
+ assert(n == 1000 && errno == 0 && *endp == '\0');
+
+ n = strtoll("0x1000", &endp, 0);
+ assert(n == 4096 && errno == 0 && *endp == '\0');
+
+ n = strtoll("01000", &endp, 0);
+ assert(n == 512 && errno == 0 && *endp == '\0');
+
+ n = strtoll(" +1a", &endp, 0);
+ assert(n == 1 && errno == 0 && *endp == 'a');
+
+ n = strtoll(" -1a", &endp, 0);
+ assert(n == -1 && errno == 0 && *endp == 'a');
+
+ sprintf(buf, "%lld", LLONG_MAX);
+ n = strtoll(buf, NULL, 10);
+ assert(n == LLONG_MAX && errno == 0);
+
+ sprintf(buf, "%lld", LLONG_MIN);
+ n = strtoll(buf, NULL, 10);
+ assert(n == LLONG_MIN && errno == 0);
+
+ n = strtoll("9999999999999999999999999", NULL, 10);
+ assert(n == LLONG_MAX && errno == ERANGE);
+
+ errno = 0;
+ n = strtoll("-999999999999999999999999", NULL, 10);
+ assert(n == LLONG_MIN && errno == ERANGE);
+}
+
+int
+main(void)
+{
+ puts("testing");
+ test();
+ puts("done");
+
+ return 0;
+}
diff --git a/tests/libc/execute/0088-stroul.c b/tests/libc/execute/0088-stroul.c
@@ -0,0 +1,76 @@
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+output:
+testing
+done
+end:
+*/
+
+
+int
+test(void)
+{
+ unsigned long n;
+ char buf[64], *endp;
+
+ errno = 0;
+ n = strtoul("1024", NULL, 10);
+ assert(n == 1024 && errno == 0);
+
+ n = strtoul("1024", &endp, 10);
+ assert(n == 1024 && errno == 0 && *endp == '\0');
+
+ n = strtoul("1000", &endp, 10);
+ assert(n == 1000 && errno == 0 && *endp == '\0');
+
+ n = strtoul("1000", &endp, 8);
+ assert(n == 512 && errno == 0 && *endp == '\0');
+
+ n = strtoul("1000", &endp, 16);
+ assert(n == 4096 && errno == 0 && *endp == '\0');
+
+ n = strtoul("1000", &endp, 0);
+ assert(n == 1000 && errno == 0 && *endp == '\0');
+
+ n = strtoul("0x1000", &endp, 0);
+ assert(n == 4096 && errno == 0 && *endp == '\0');
+
+ n = strtoul("01000", &endp, 0);
+ assert(n == 512 && errno == 0 && *endp == '\0');
+
+ n = strtoul(" +1a", &endp, 0);
+ assert(n == 1 && errno == 0 && *endp == 'a');
+
+ n = strtoul(" -1a", &endp, 0);
+ assert(n == -1 && errno == 0 && *endp == 'a');
+
+ sprintf(buf, "%lu", ULONG_MAX);
+ n = strtoul(buf, NULL, 10);
+ assert(n == ULONG_MAX && errno == 0);
+
+ sprintf(buf, "%ld", LONG_MIN);
+ n = strtoul(buf, NULL, 10);
+ assert(n == LONG_MIN && errno == 0);
+
+ n = strtoul("9999999999999999999999999", NULL, 10);
+ assert(n == ULONG_MAX && errno == ERANGE);
+
+ errno = 0;
+ n = strtoul("-999999999999999999999999", NULL, 10);
+ assert(n == ULONG_MAX && errno == ERANGE);
+}
+
+int
+main(void)
+{
+ puts("testing");
+ test();
+ puts("done");
+
+ return 0;
+}
diff --git a/tests/libc/execute/0089-stroull.c b/tests/libc/execute/0089-stroull.c
@@ -0,0 +1,76 @@
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+output:
+testing
+done
+end:
+*/
+
+
+int
+test(void)
+{
+ unsigned long long n;
+ char buf[64], *endp;
+
+ errno = 0;
+ n = strtoull("1024", NULL, 10);
+ assert(n == 1024 && errno == 0);
+
+ n = strtoull("1024", &endp, 10);
+ assert(n == 1024 && errno == 0 && *endp == '\0');
+
+ n = strtoull("1000", &endp, 10);
+ assert(n == 1000 && errno == 0 && *endp == '\0');
+
+ n = strtoull("1000", &endp, 8);
+ assert(n == 512 && errno == 0 && *endp == '\0');
+
+ n = strtoull("1000", &endp, 16);
+ assert(n == 4096 && errno == 0 && *endp == '\0');
+
+ n = strtoull("1000", &endp, 0);
+ assert(n == 1000 && errno == 0 && *endp == '\0');
+
+ n = strtoull("0x1000", &endp, 0);
+ assert(n == 4096 && errno == 0 && *endp == '\0');
+
+ n = strtoull("01000", &endp, 0);
+ assert(n == 512 && errno == 0 && *endp == '\0');
+
+ n = strtoull(" +1a", &endp, 0);
+ assert(n == 1 && errno == 0 && *endp == 'a');
+
+ n = strtoull(" -1a", &endp, 0);
+ assert(n == -1 && errno == 0 && *endp == 'a');
+
+ sprintf(buf, "%llu", ULLONG_MAX);
+ n = strtoull(buf, NULL, 10);
+ assert(n == ULLONG_MAX && errno == 0);
+
+ sprintf(buf, "%lld", LLONG_MIN);
+ n = strtoull(buf, NULL, 10);
+ assert(n == LLONG_MIN && errno == 0);
+
+ n = strtoull("9999999999999999999999999", NULL, 10);
+ assert(n == ULLONG_MAX && errno == ERANGE);
+
+ errno = 0;
+ n = strtoull("-999999999999999999999999", NULL, 10);
+ assert(n == ULLONG_MAX && errno == ERANGE);
+}
+
+int
+main(void)
+{
+ puts("testing");
+ test();
+ puts("done");
+
+ return 0;
+}
diff --git a/tests/libc/execute/0090-rand.c b/tests/libc/execute/0090-rand.c
@@ -0,0 +1,83 @@
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+
+/*
+output:
+testing
+test1
+test2
+done
+end:
+*/
+
+#define NR_BINS 64
+#define NR_DOTS 16000
+#define CRITLVL 82.53
+
+static void
+test1(void)
+{
+ int max, min, i, n;
+ float chi, d;
+ static int bins[NR_BINS];
+
+ puts("test1");
+ for (i = 0; i < NR_DOTS; ++i) {
+ n = rand();
+ assert(n >= 0 && n <= RAND_MAX);
+ bins[n & NR_BINS-1]++;
+ }
+
+ chi = 0;
+ for (i = 0; i < NR_BINS; ++i) {
+ d = bins[i] - (float) NR_DOTS / NR_BINS;
+ d *= d;
+ d /= (float) NR_DOTS / NR_BINS;
+ chi += d;
+ }
+
+ assert(chi <= CRITLVL);
+}
+
+#undef NR_DOTS
+
+#define NR_SEEDS 10
+#define NR_DOTS 32
+
+static void
+test2(void)
+{
+ int i, j, dots[NR_SEEDS][NR_DOTS];
+ unsigned seeds[NR_SEEDS];
+
+ puts("test2");
+ for (i = 0; i < NR_SEEDS; i++)
+ seeds[i] = rand();
+
+ for (i = 0; i < NR_SEEDS; i++) {
+ srand(seeds[i]);
+
+ for (j = 0; j < NR_DOTS; ++j)
+ dots[i][j] = rand();
+ }
+
+ for (i = 0; i < NR_SEEDS; i++) {
+ srand(seeds[i]);
+
+ for (j = 0; j < NR_DOTS; ++j)
+ assert(dots[i][j] == rand());
+ }
+}
+
+int
+main(void)
+{
+ puts("testing");
+ test1();
+ test2();
+ puts("done");
+
+ return 0;
+}
diff --git a/tests/libc/execute/0091-atexit.c b/tests/libc/execute/0091-atexit.c
@@ -0,0 +1,96 @@
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+output:
+testing
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun1
+fun2
+fun3
+done
+end:
+*/
+
+static void
+fun1(void)
+{
+ puts("fun1");
+}
+
+static void
+fun2(void)
+{
+ puts("fun2");
+}
+
+static void
+fun3(void)
+{
+ puts("fun3");
+ puts("done");
+ fflush(stdout);
+ _Exit(0);
+}
+
+static void
+fun4(void)
+{
+ puts("fun4");
+}
+
+int
+main(void)
+{
+ int i, r;
+
+ puts("testing");
+ r = atexit(fun4);
+ assert(r == 0);
+
+ r = atexit(fun3);
+ assert(r == 0);
+
+ r = atexit(fun2);
+ assert(r == 0);
+
+
+ for (i = 0; i < 29; i++) {
+ r = atexit(fun1);
+ assert(r == 0);
+ }
+ exit(EXIT_SUCCESS);
+
+ printf("failed");
+ exit(EXIT_FAILURE);
+
+ return 1;
+}
diff --git a/tests/libc/execute/0092-getenv.c b/tests/libc/execute/0092-getenv.c
@@ -0,0 +1,32 @@
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*
+output:
+testing
+done
+end:
+*/
+
+int putenv(char *);
+
+int
+main(void)
+{
+ char *s;
+
+ puts("testing");
+ s = getenv("THIS_CANNOT_BE_A_ENV_CAR");
+ assert(s == NULL);
+
+#if defined(__unix__) || defined(__SCC_PUTENV__)
+ putenv("AVAR=avalue");
+ s = getenv("AVAR");
+ assert(strcmp(s, "avalue") == 0);
+#endif
+ puts("done");
+
+ return 0;
+}
diff --git a/tests/libc/execute/0093-system.c b/tests/libc/execute/0093-system.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+output:
+testing
+hello
+done
+end:
+*/
+
+int
+main(void)
+{
+ puts("testing");
+ system("echo hello");
+ puts("done");
+
+ return 0;
+}
diff --git a/tests/libc/execute/0094-bsearch.c b/tests/libc/execute/0094-bsearch.c
@@ -0,0 +1,46 @@
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+output:
+testing
+done
+end:
+*/
+
+static int
+cmp(const void *pp1, const void *pp2)
+{
+ const int *p1 = pp1, *p2 = pp2;
+
+ return *p1 - *p2;
+}
+
+static int
+test(void)
+{
+ int *p, key, i, arr[64];
+
+ for (i = 0; i < 64; i++)
+ arr[i] = rand();
+
+ qsort(arr, 64, sizeof(int), cmp);
+
+ for (i = 0; i < 63; i++)
+ assert(arr[i] <= arr[i+1]);
+
+ key = arr[33];
+ p = bsearch(&key, arr, 64, sizeof(int), cmp);
+ assert(*p == arr[33]);
+}
+
+int
+main(void)
+{
+ puts("testing");
+ test();
+ puts("done");
+
+ return 0;
+}
diff --git a/tests/libc/execute/0095-abs.c b/tests/libc/execute/0095-abs.c
@@ -0,0 +1,32 @@
+#include <assert.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+output:
+testing
+done
+end:
+*/
+
+int
+main(void)
+{
+ puts("testing");
+ assert(abs(3) == abs(-3));
+ assert(abs(-INT_MAX) == INT_MAX);
+
+ assert(labs(3) == labs(-3));
+ assert(labs(-LONG_MAX) == LONG_MAX);
+
+ assert(llabs(3) == llabs(-3));
+ assert(llabs(-LLONG_MAX) == LONG_MAX);
+
+ assert(imaxabs(3) == imaxabs(-3));
+ assert(imaxabs(-INTMAX_MAX) == INTMAX_MAX);
+ puts("done");
+
+ return 0;
+}
diff --git a/tests/libc/execute/libc-tests.lst b/tests/libc/execute/libc-tests.lst
@@ -75,3 +75,20 @@
0076-localeconv
0077-setlocale
0078-time
+0079-atof [TODO]
+0080-atoi
+0081-atol
+0082-atoll
+0083-strtod [TODO]
+0084-strtof [TODO]
+0085-strtold [TODO]
+0086-strtol
+0087-stroll
+0088-stroul
+0089-stroull
+0090-rand
+0091-atexit
+0092-getenv
+0093-system
+0094-bsearch
+0095-abs