Skip to content

Commit

Permalink
libc: fix small bugs and remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler569 committed May 7, 2024
1 parent feb5e36 commit 9070cac
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 366 deletions.
3 changes: 0 additions & 3 deletions libc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,11 @@ set(LIBC_SOURCES
stream.c
stream_ring.c
string.c
strtod.c
syscall.c
syscalls.c
time.c
timeconv.c
todo.c
unistd.c
fstdio2.c
)

add_compile_definitions(_NG_SOURCE=1)
Expand Down
4 changes: 2 additions & 2 deletions libc/ctype.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ int ispunct(int c) {
}

int tolower(int c) {
if (c >= 'Z' && c <= 'A') {
if (c >= 'A' && c <= 'Z') {
return c + 'a' - 'A';
} else {
return c;
}
}

int toupper(int c) {
if (c >= 'z' && c <= 'a') {
if (c >= 'a' && c <= 'z') {
return c + 'A' - 'a';
} else {
return c;
Expand Down
34 changes: 0 additions & 34 deletions libc/fstdio2.c

This file was deleted.

2 changes: 1 addition & 1 deletion libc/nightingale.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void redirect_output_to(char *const argv[]) {
dup2(pipefds[0], STDIN_FILENO);
close(pipefds[0]);
close(pipefds[1]);
execvp(argv[0], &argv[1]);
execvp(argv[0], argv);
assert("exec failed" && 0);
} else {
dup2(pipefds[1], STDOUT_FILENO);
Expand Down
4 changes: 2 additions & 2 deletions libc/stdlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include <stdio.h>
#include <stdlib.h>

#ifndef __kernel__

int abs(int x) {
if (x < 0) {
return -x;
Expand All @@ -29,6 +27,8 @@ long long llabs(long long x) {
}
}

#ifndef __kernel__

div_t div(int x, int y) { return (div_t) { .quot = x / y, .rem = x % y }; }

ldiv_t ldiv(long x, long y) { return (ldiv_t) { .quot = x / y, .rem = x % y }; }
Expand Down
140 changes: 0 additions & 140 deletions libc/strtod.c

This file was deleted.

Loading

0 comments on commit 9070cac

Please sign in to comment.