diff options
author | Anton Kling <anton@kling.gg> | 2023-12-18 16:02:34 +0100 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2023-12-18 16:02:34 +0100 |
commit | b7fa1457727338416499d1b0144f1042a6878a97 (patch) | |
tree | 3add0539a6afec94d1f1fdcd2f4200f21a84d776 /userland | |
parent | 43a72a1a5719039de5d7e347806aae163e30f17a (diff) |
Add untracked files
Diffstat (limited to 'userland')
-rw-r--r-- | userland/libc/Makefile | 7 | ||||
-rw-r--r-- | userland/libc/include/math.h | 4 | ||||
-rw-r--r-- | userland/libc/sys/socket/listen.c | 0 | ||||
-rw-r--r-- | userland/libc/systemcall.s | 28 |
4 files changed, 34 insertions, 5 deletions
diff --git a/userland/libc/Makefile b/userland/libc/Makefile index 7f745cb..0c426b4 100644 --- a/userland/libc/Makefile +++ b/userland/libc/Makefile @@ -2,7 +2,7 @@ CC="i686-sb-gcc" AR="i686-sb-ar" AS="i686-sb-as" CFLAGS = -ggdb -ffreestanding -O2 -Wall -Wextra -pedantic -Wimplicit-fallthrough -I./include/ -static -I../../include/ -Wno-int-conversion -Wno-unused-parameter -Wno-return-type -OBJ=crt0.o libc.o malloc/malloc.o pty.o sys/mman/mmap.o memset.o assert.o stdio/snprintf.o stdio/vfprintf.o string/memcpy.o string/memcmp.o string/strcmp.o ubsan.o string/strcpy.o isspace.o stdio/puts.o stdio/putchar.o dirent/opendir.o dirent/readdir.o dirent/closedir.o unistd/getopt.o dirent/scandir.o dirent/alphasort.o stdio/printf.o stdio/vdprintf.o stdio/vprintf.o stdio/dprintf.o stdio/vprintf.o string/strlen.o string/strnlen.o stdio/stdin.o stdio/getchar.o stdio/fgetc.o arpa/inet/htons.o arpa/inet/htonl.o stdio/fread.o stdio/fwrite.o stdio/fopen.o stdio/fclose.o stdio/fseek.o ctype/isascii.o stdio/fprintf.o stdlib/atoi.o stdlib/strtol.o ctype/toupper.o ctype/tolower.o string/strcat.o string/strchr.o string/sscanf.o sys/stat/stat.o stdlib/getenv.o string/strrchr.o stdio/ftell.o stdio/tmpfile.o stdio/fgets.o stdio/feof.o stdio/fscanf.o stdio/ungetc.o string/strncmp.o stdio/fputc.o string/strncpy.o stdio/remove.o stdio/ferror.o stdio/fputs.o stdlib/rand.o stdlib/srand.o unistd/getpid.o stdlib/strtoul.o stdio/fflush.o stdlib/abort.o string/strcspn.o time/localtime.o time/time.o time/clock_gettime.o time/gmtime.o time/strftime.o string/strpbrk.o ctype/isdigit.o ctype/isalpha.o ctype/isxdigit.o ctype/ispunct.o stdio/setvbuf.o stdio/fileno.o stdio/putc.o stdio/sprintf.o stdlib/abs.o string/strspn.o stdlib/qsort.o string/memmove.o setjmp/longjmp.o setjmp/setjmp.o libgen/basename.o string/strdup.o string/strndup.o string/strlcpy.o stdlib/atexit.o stdio/open_memstream.o libgen/dirname.o unistd/unlink.o string/strstr.o string/strcasecmp.o string/strncasecmp.o stdlib/mkstemp.o string/strtok.o unistd/execvp.o unistd/_exit.o ctype/isalnum.o time/ctime_r.o stdlib/strtold.o sys/time/gettimeofday.o stdio/fgetpos.o stdio/fsetpos.o ctype/isprint.o stdlib/system.o stdio/tmpnam.o unistd/msleep.o stdlib/atof.o stdlib/strtod.o stdio/rename.o sys/stat/mkdir.o unistd/uptime.o unistd/ftruncate.o sys/socket/recvfrom.o sys/socket/sendto.o signal/kill.o signal/sigaction.o unistd/chdir.o unistd/getcwd.o stdio/getdelim.o stdio/getline.o unistd/isatty.o sys/socket/listen.o stdlib/realpath.o math/min.o math/max.o systemcall.o sys/random/randomfill.o fcntl/open.o unistd/write.o unistd/pwrite.o +OBJ=crt0.o libc.o malloc/malloc.o pty.o sys/mman/mmap.o memset.o assert.o stdio/snprintf.o stdio/vfprintf.o string/memcpy.o string/memcmp.o string/strcmp.o ubsan.o string/strcpy.o isspace.o stdio/puts.o stdio/putchar.o dirent/opendir.o dirent/readdir.o dirent/closedir.o unistd/getopt.o dirent/scandir.o dirent/alphasort.o stdio/printf.o stdio/vdprintf.o stdio/vprintf.o stdio/dprintf.o stdio/vprintf.o string/strlen.o string/strnlen.o stdio/stdin.o stdio/getchar.o stdio/fgetc.o arpa/inet/htons.o arpa/inet/htonl.o stdio/fread.o stdio/fwrite.o stdio/fopen.o stdio/fclose.o stdio/fseek.o ctype/isascii.o stdio/fprintf.o stdlib/atoi.o stdlib/strtol.o ctype/toupper.o ctype/tolower.o string/strcat.o string/strchr.o string/sscanf.o sys/stat/stat.o stdlib/getenv.o string/strrchr.o stdio/ftell.o stdio/tmpfile.o stdio/fgets.o stdio/feof.o stdio/fscanf.o stdio/ungetc.o string/strncmp.o stdio/fputc.o string/strncpy.o stdio/remove.o stdio/ferror.o stdio/fputs.o stdlib/rand.o stdlib/srand.o unistd/getpid.o stdlib/strtoul.o stdio/fflush.o stdlib/abort.o string/strcspn.o time/localtime.o time/time.o time/clock_gettime.o time/gmtime.o time/strftime.o string/strpbrk.o ctype/isdigit.o ctype/isalpha.o ctype/isxdigit.o ctype/ispunct.o stdio/setvbuf.o stdio/fileno.o stdio/putc.o stdio/sprintf.o stdlib/abs.o string/strspn.o stdlib/qsort.o string/memmove.o setjmp/longjmp.o setjmp/setjmp.o libgen/basename.o string/strdup.o string/strndup.o string/strlcpy.o stdlib/atexit.o stdio/open_memstream.o libgen/dirname.o unistd/unlink.o string/strstr.o string/strcasecmp.o string/strncasecmp.o stdlib/mkstemp.o string/strtok.o unistd/execvp.o unistd/_exit.o ctype/isalnum.o time/ctime_r.o stdlib/strtold.o sys/time/gettimeofday.o stdio/fgetpos.o stdio/fsetpos.o ctype/isprint.o stdlib/system.o stdio/tmpnam.o unistd/msleep.o stdlib/atof.o stdlib/strtod.o stdio/rename.o sys/stat/mkdir.o unistd/uptime.o unistd/ftruncate.o sys/socket/recvfrom.o sys/socket/sendto.o signal/kill.o signal/sigaction.o unistd/chdir.o unistd/getcwd.o stdio/getdelim.o stdio/getline.o unistd/isatty.o sys/socket/listen.o stdlib/realpath.o systemcall.o sys/random/randomfill.o fcntl/open.o unistd/write.o unistd/pwrite.o all: libc.a %.o: %.c @@ -15,10 +15,11 @@ libc.a: $(OBJ) $(AR) rcs libc.a $(OBJ) install: - cp crt0.o ../../sysroot/lib/ - cp libc.a ../../sysroot/lib/ + mkdir -p ../../sysroot/usr/ cp -r ../../include ../../sysroot/usr/ cp -r include ../../sysroot/usr/ + cp crt0.o ../../sysroot/lib/ + cp libc.a ../../sysroot/lib/ clean: rm libc.a *.o */*.o */*/*.o diff --git a/userland/libc/include/math.h b/userland/libc/include/math.h index dbb94e7..9d4f4b4 100644 --- a/userland/libc/include/math.h +++ b/userland/libc/include/math.h @@ -1,2 +1,2 @@ -int max(int a, int b); -int min(int a, int b); +#define max(_a, _b) ((_a) > (_b) ? (_a) : (_b)) +#define min(_a, _b) ((_a) < (_b) ? (_a) : (_b)) diff --git a/userland/libc/sys/socket/listen.c b/userland/libc/sys/socket/listen.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/userland/libc/sys/socket/listen.c diff --git a/userland/libc/systemcall.s b/userland/libc/systemcall.s new file mode 100644 index 0000000..51b00ec --- /dev/null +++ b/userland/libc/systemcall.s @@ -0,0 +1,28 @@ +.global syscall +.global s_syscall +syscall: + push %ebp + mov %esp,%ebp + push %edi + push %esi + push %ebx + mov 0x1C(%ebp), %edi + mov 0x18(%ebp), %esi + mov 0x14(%ebp), %edx + mov 0x10(%ebp), %ecx + mov 0xc(%ebp), %ebx + mov 0x8(%ebp), %eax + int $0x80 + pop %ebx + pop %esi + pop %edi + leave + ret + +s_syscall: + push %ebp + mov %esp,%ebp + movl 0x8(%ebp), %eax + int $0x80 + leave + ret |