mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:57:36 +00:00
Miscellaneous compat work while seeing if GNU coreutils would build.
This commit is contained in:
parent
a7f1d892a9
commit
d7a41579e5
12 changed files with 92 additions and 2 deletions
|
@ -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
|
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
|
OPTIMIZATION_FLAGS = -Os -fno-asynchronous-unwind-tables
|
||||||
INCLUDE_FLAGS = -I.. -I.
|
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
|
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++
|
#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
|
#LD = /usr/local/gcc-4.8.1-for-linux64/bin/x86_64-pc-linux-ld
|
||||||
CXX = g++-8
|
CXX = g++-8
|
||||||
|
|
|
@ -25,6 +25,7 @@ LIBC_OBJS = \
|
||||||
termcap.o \
|
termcap.o \
|
||||||
setjmp.o \
|
setjmp.o \
|
||||||
stat.o \
|
stat.o \
|
||||||
|
mntent.o \
|
||||||
entry.o
|
entry.o
|
||||||
|
|
||||||
OBJS = $(AK_OBJS) $(LIBC_OBJS)
|
OBJS = $(AK_OBJS) $(LIBC_OBJS)
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
__ERROR(ENAMETOOLONG, "Name too long") \
|
__ERROR(ENAMETOOLONG, "Name too long") \
|
||||||
__ERROR(ELOOP, "Too many symlinks") \
|
__ERROR(ELOOP, "Too many symlinks") \
|
||||||
__ERROR(EOVERFLOW, "Overflow") \
|
__ERROR(EOVERFLOW, "Overflow") \
|
||||||
|
__ERROR(EOPNOTSUPP, "Operation not supported") \
|
||||||
|
__ERROR(ENOSYS, "No such syscall") \
|
||||||
__ERROR(ENOTIMPL, "Not implemented") \
|
__ERROR(ENOTIMPL, "Not implemented") \
|
||||||
|
|
||||||
enum __errno_values {
|
enum __errno_values {
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#define PATH_MAX 4096
|
#define PATH_MAX 4096
|
||||||
|
|
||||||
|
#define INT_MAX INT32_MAX
|
||||||
|
#define INT_MIN INT32_MIN
|
||||||
|
|
13
LibC/mntent.cpp
Normal file
13
LibC/mntent.cpp
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#include <mntent.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
struct mntent* getmntent(FILE* stream)
|
||||||
|
{
|
||||||
|
assert(false);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
23
LibC/mntent.h
Normal file
23
LibC/mntent.h
Normal file
|
@ -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
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#include <sys/types.h>
|
|
@ -12,5 +12,15 @@ typedef signed int int32_t;
|
||||||
typedef signed short int16_t;
|
typedef signed short int16_t;
|
||||||
typedef signed char int8_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
|
__END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,8 @@ int fputc(int ch, FILE* stream)
|
||||||
{
|
{
|
||||||
assert(stream);
|
assert(stream);
|
||||||
write(stream->fd, &ch, 1);
|
write(stream->fd, &ch, 1);
|
||||||
|
if (stream->eof)
|
||||||
|
return EOF;
|
||||||
return (byte)ch;
|
return (byte)ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,10 +87,31 @@ int putchar(int ch)
|
||||||
return putc(ch, stdout);
|
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)
|
void clearerr(FILE* stream)
|
||||||
{
|
{
|
||||||
assert(stream);
|
assert(stream);
|
||||||
stream->eof = false;
|
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)
|
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));
|
auto* fp = (FILE*)malloc(sizeof(FILE));
|
||||||
fp->fd = fd;
|
fp->fd = fd;
|
||||||
fp->eof = false;
|
fp->eof = false;
|
||||||
|
fp->error = 0;
|
||||||
return fp;
|
return fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,6 +225,7 @@ FILE* fdopen(int fd, const char* mode)
|
||||||
auto* fp = (FILE*)malloc(sizeof(FILE));
|
auto* fp = (FILE*)malloc(sizeof(FILE));
|
||||||
fp->fd = fd;
|
fp->fd = fd;
|
||||||
fp->eof = false;
|
fp->eof = false;
|
||||||
|
fp->error = 0;
|
||||||
return fp;
|
return fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ __BEGIN_DECLS
|
||||||
struct __STDIO_FILE {
|
struct __STDIO_FILE {
|
||||||
int fd;
|
int fd;
|
||||||
int eof;
|
int eof;
|
||||||
|
int error;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct __STDIO_FILE FILE;
|
typedef struct __STDIO_FILE FILE;
|
||||||
|
@ -34,6 +35,7 @@ FILE* fopen(const char* pathname, const char* mode);
|
||||||
int fclose(FILE*);
|
int fclose(FILE*);
|
||||||
void rewind(FILE*);
|
void rewind(FILE*);
|
||||||
void clearerr(FILE*);
|
void clearerr(FILE*);
|
||||||
|
int ferror(FILE*);
|
||||||
int feof(FILE*);
|
int feof(FILE*);
|
||||||
int fflush(FILE*);
|
int fflush(FILE*);
|
||||||
size_t fread(void* ptr, size_t size, size_t nmemb, 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 printf(const char* fmt, ...);
|
||||||
int sprintf(char* buffer, const char* fmt, ...);
|
int sprintf(char* buffer, const char* fmt, ...);
|
||||||
int putchar(int ch);
|
int putchar(int ch);
|
||||||
|
int putc(int ch, FILE*);
|
||||||
|
int puts(const char*);
|
||||||
|
int fputs(const char*, FILE*);
|
||||||
void perror(const char*);
|
void perror(const char*);
|
||||||
int sscanf (const char* buf, const char* fmt, ...);
|
int sscanf (const char* buf, const char* fmt, ...);
|
||||||
int fscanf(FILE*, const char* fmt, ...);
|
int fscanf(FILE*, const char* fmt, ...);
|
||||||
|
|
|
@ -6,5 +6,6 @@
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
mode_t umask(mode_t);
|
mode_t umask(mode_t);
|
||||||
|
int chmod(const char* pathname, mode_t);
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
|
@ -22,8 +22,8 @@ typedef uint32_t blksize_t;
|
||||||
typedef uint32_t blkcnt_t;
|
typedef uint32_t blkcnt_t;
|
||||||
typedef uint32_t time_t;
|
typedef uint32_t time_t;
|
||||||
typedef uint32_t suseconds_t;
|
typedef uint32_t suseconds_t;
|
||||||
|
|
||||||
typedef uint32_t clock_t;
|
typedef uint32_t clock_t;
|
||||||
|
typedef uint32_t socklen_t;
|
||||||
|
|
||||||
struct timeval {
|
struct timeval {
|
||||||
time_t tv_sec;
|
time_t tv_sec;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue