diff --git a/LibC/crt0.cpp b/LibC/crt0.cpp index c7bf35b2be..ee307daa81 100644 --- a/LibC/crt0.cpp +++ b/LibC/crt0.cpp @@ -38,9 +38,6 @@ int _start(int argc, char** argv, char** env) int status = main(argc, argv); - fflush(stdout); - fflush(stderr); - exit(status); return 20150614; diff --git a/LibC/fcntl.h b/LibC/fcntl.h index ab0f2167e7..5f67104bf3 100644 --- a/LibC/fcntl.h +++ b/LibC/fcntl.h @@ -1,6 +1,7 @@ #pragma once #include +#include __BEGIN_DECLS @@ -54,4 +55,17 @@ __BEGIN_DECLS int fcntl(int fd, int cmd, ...); +#define F_WRLCK 1 +#define F_UNLCK 2 + +#define F_SETLKW 7 + +struct flock { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + pid_t l_pid; +}; + __END_DECLS diff --git a/LibC/stdio.cpp b/LibC/stdio.cpp index 88ca23d82c..e94ac7322a 100644 --- a/LibC/stdio.cpp +++ b/LibC/stdio.cpp @@ -440,7 +440,8 @@ int fclose(FILE* stream) { fflush(stream); int rc = close(stream->fd); - free(stream); + if (stream != &__default_streams[0] && stream != &__default_streams[1] && stream != &__default_streams[2] && stream != &__default_streams[3]) + free(stream); return rc; } @@ -510,6 +511,11 @@ int vfscanf(FILE* stream, const char* fmt, va_list ap) return vsscanf(buffer, fmt, ap); } +FILE* tmpfile() +{ + dbgprintf("FIXME: Implement tmpfile()\n"); + ASSERT_NOT_REACHED(); +} } diff --git a/LibC/stdlib.cpp b/LibC/stdlib.cpp index d83a25a4a9..e9b70dbf0f 100644 --- a/LibC/stdlib.cpp +++ b/LibC/stdlib.cpp @@ -26,6 +26,8 @@ void exit(int status) __atexit_handlers[i](); extern void _fini(); _fini(); + fflush(stdout); + fflush(stderr); _exit(status); ASSERT_NOT_REACHED(); } @@ -41,7 +43,7 @@ int atexit(void (*handler)()) void abort() { // FIXME: Implement proper abort(). - exit(253); + CRASH(); } char* getenv(const char* name)