LibC: Some compat fixes for GNU make.

This commit is contained in:
Andreas Kling 2019-05-22 13:21:49 +02:00
parent f490ce0fb5
commit e388808479
Notes: sideshowbarker 2024-07-19 13:59:28 +09:00
4 changed files with 24 additions and 5 deletions

View file

@ -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;

View file

@ -1,6 +1,7 @@
#pragma once
#include <sys/cdefs.h>
#include <sys/types.h>
__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

View file

@ -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();
}
}

View file

@ -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)