diff options
-rw-r--r-- | Kernel/Makefile | 3 | ||||
-rw-r--r-- | LibC/Makefile | 1 | ||||
-rw-r--r-- | LibC/errno_numbers.h | 2 | ||||
-rw-r--r-- | LibC/limits.h | 5 | ||||
-rw-r--r-- | LibC/mntent.cpp | 13 | ||||
-rw-r--r-- | LibC/mntent.h | 23 | ||||
-rw-r--r-- | LibC/stddef.h | 4 | ||||
-rw-r--r-- | LibC/stdint.h | 10 | ||||
-rw-r--r-- | LibC/stdio.cpp | 25 | ||||
-rw-r--r-- | LibC/stdio.h | 5 | ||||
-rw-r--r-- | LibC/sys/stat.h | 1 | ||||
-rw-r--r-- | LibC/sys/types.h | 2 |
12 files changed, 92 insertions, 2 deletions
diff --git a/Kernel/Makefile b/Kernel/Makefile index 6067dc2593..963aa72b5b 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -59,10 +59,11 @@ WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings FLAVOR_FLAGS = -mregparm=3 -march=i386 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic OPTIMIZATION_FLAGS = -Os -fno-asynchronous-unwind-tables INCLUDE_FLAGS = -I.. -I. +SUGGEST_FLAGS = -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-final-types -Wsuggest-final-methods -Wsuggest-override DEFINES = -DSERENITY -DKERNEL -DSANITIZE_PTRS -CXXFLAGS = $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(KERNEL_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) +CXXFLAGS = $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(KERNEL_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(SUGGEST_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) #CXX = /usr/local/gcc-4.8.1-for-linux64/bin/x86_64-pc-linux-g++ #LD = /usr/local/gcc-4.8.1-for-linux64/bin/x86_64-pc-linux-ld CXX = g++-8 diff --git a/LibC/Makefile b/LibC/Makefile index 2650fbc886..34ff1b5abb 100644 --- a/LibC/Makefile +++ b/LibC/Makefile @@ -25,6 +25,7 @@ LIBC_OBJS = \ termcap.o \ setjmp.o \ stat.o \ + mntent.o \ entry.o OBJS = $(AK_OBJS) $(LIBC_OBJS) diff --git a/LibC/errno_numbers.h b/LibC/errno_numbers.h index 89a9e582c2..57a2bab42b 100644 --- a/LibC/errno_numbers.h +++ b/LibC/errno_numbers.h @@ -37,6 +37,8 @@ __ERROR(ENAMETOOLONG, "Name too long") \ __ERROR(ELOOP, "Too many symlinks") \ __ERROR(EOVERFLOW, "Overflow") \ + __ERROR(EOPNOTSUPP, "Operation not supported") \ + __ERROR(ENOSYS, "No such syscall") \ __ERROR(ENOTIMPL, "Not implemented") \ enum __errno_values { diff --git a/LibC/limits.h b/LibC/limits.h index 355cea6330..f13e1ef5b7 100644 --- a/LibC/limits.h +++ b/LibC/limits.h @@ -1,3 +1,8 @@ #pragma once +#include <stdint.h> + #define PATH_MAX 4096 + +#define INT_MAX INT32_MAX +#define INT_MIN INT32_MIN diff --git a/LibC/mntent.cpp b/LibC/mntent.cpp new file mode 100644 index 0000000000..6c57801aba --- /dev/null +++ b/LibC/mntent.cpp @@ -0,0 +1,13 @@ +#include <mntent.h> +#include <assert.h> + +extern "C" { + +struct mntent* getmntent(FILE* stream) +{ + assert(false); + return nullptr; +} + +} + diff --git a/LibC/mntent.h b/LibC/mntent.h new file mode 100644 index 0000000000..5627cb121a --- /dev/null +++ b/LibC/mntent.h @@ -0,0 +1,23 @@ +#pragma once + +#include <sys/cdefs.h> +#include <stdio.h> + +__BEGIN_DECLS + +#define MOUNTED "/etc/mtab" +#define MNTTAB "/etc/fstab" + +struct mntent { + char* mnt_fsname; + char* mnt_dir; + char* mnt_type; + char* mnt_opts; + int mnt_freq; + int mnt_passno; +}; + +struct mntent* getmntent(FILE* stream); + +__END_DECLS + diff --git a/LibC/stddef.h b/LibC/stddef.h index e69de29bb2..2e0601bee9 100644 --- a/LibC/stddef.h +++ b/LibC/stddef.h @@ -0,0 +1,4 @@ +#pragma once + +#include <sys/cdefs.h> +#include <sys/types.h> diff --git a/LibC/stdint.h b/LibC/stdint.h index 7deb47e5da..551bef265c 100644 --- a/LibC/stdint.h +++ b/LibC/stdint.h @@ -12,5 +12,15 @@ typedef signed int int32_t; typedef signed short int16_t; typedef signed char int8_t; +#define INT8_MIN (-128) +#define INT16_MIN (-32767-1) +#define INT32_MIN (-2147483647-1) +#define INT8_MAX (127) +#define INT16_MAX (32767) +#define INT32_MAX (2147483647) +#define UINT8_MAX (255) +#define UINT16_MAX (65535) +#define UINT32_MAX (4294967295U) + __END_DECLS diff --git a/LibC/stdio.cpp b/LibC/stdio.cpp index 49548d6a0c..c75f99d621 100644 --- a/LibC/stdio.cpp +++ b/LibC/stdio.cpp @@ -72,6 +72,8 @@ int fputc(int ch, FILE* stream) { assert(stream); write(stream->fd, &ch, 1); + if (stream->eof) + return EOF; return (byte)ch; } @@ -85,10 +87,31 @@ int putchar(int ch) return putc(ch, stdout); } +int fputs(const char* s, FILE* stream) +{ + for (; *s; ++s) { + int rc = putc(*s, stream); + if (rc == EOF) + return EOF; + } + return putc('\n', stream); +} + +int puts(const char* s) +{ + fputs(s, stdout); +} + void clearerr(FILE* stream) { assert(stream); stream->eof = false; + stream->error = false; +} + +int ferror(FILE* stream) +{ + return stream->error; } size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream) @@ -190,6 +213,7 @@ FILE* fopen(const char* pathname, const char* mode) auto* fp = (FILE*)malloc(sizeof(FILE)); fp->fd = fd; fp->eof = false; + fp->error = 0; return fp; } @@ -201,6 +225,7 @@ FILE* fdopen(int fd, const char* mode) auto* fp = (FILE*)malloc(sizeof(FILE)); fp->fd = fd; fp->eof = false; + fp->error = 0; return fp; } diff --git a/LibC/stdio.h b/LibC/stdio.h index a03f735341..a662321953 100644 --- a/LibC/stdio.h +++ b/LibC/stdio.h @@ -16,6 +16,7 @@ __BEGIN_DECLS struct __STDIO_FILE { int fd; int eof; + int error; }; typedef struct __STDIO_FILE FILE; @@ -34,6 +35,7 @@ FILE* fopen(const char* pathname, const char* mode); int fclose(FILE*); void rewind(FILE*); void clearerr(FILE*); +int ferror(FILE*); int feof(FILE*); int fflush(FILE*); size_t fread(void* ptr, size_t size, size_t nmemb, FILE*); @@ -42,6 +44,9 @@ int fprintf(FILE*, const char* fmt, ...); int printf(const char* fmt, ...); int sprintf(char* buffer, const char* fmt, ...); int putchar(int ch); +int putc(int ch, FILE*); +int puts(const char*); +int fputs(const char*, FILE*); void perror(const char*); int sscanf (const char* buf, const char* fmt, ...); int fscanf(FILE*, const char* fmt, ...); diff --git a/LibC/sys/stat.h b/LibC/sys/stat.h index 902e63268d..0cba204b11 100644 --- a/LibC/sys/stat.h +++ b/LibC/sys/stat.h @@ -6,5 +6,6 @@ __BEGIN_DECLS mode_t umask(mode_t); +int chmod(const char* pathname, mode_t); __END_DECLS diff --git a/LibC/sys/types.h b/LibC/sys/types.h index 425b8b333f..c50a3c799c 100644 --- a/LibC/sys/types.h +++ b/LibC/sys/types.h @@ -22,8 +22,8 @@ typedef uint32_t blksize_t; typedef uint32_t blkcnt_t; typedef uint32_t time_t; typedef uint32_t suseconds_t; - typedef uint32_t clock_t; +typedef uint32_t socklen_t; struct timeval { time_t tv_sec; |