1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:27:35 +00:00

Make bash-2.05b build with minimal changes.

This is really neat. :^)
This commit is contained in:
Andreas Kling 2018-11-17 00:11:08 +01:00
parent 2cf477a151
commit 9d05f6b7a7
35 changed files with 326 additions and 176 deletions

View file

@ -31,6 +31,7 @@ LIBC_OBJS = \
ulimit.o \
qsort.o \
ioctl.o \
math.o \
entry.o
OBJS = $(AK_OBJS) $(LIBC_OBJS)

View file

@ -11,3 +11,18 @@ int isprint(int c)
{
return isdigit(c) || isupper(c) || islower(c) || ispunct(c) || isspace(c);
}
int isalnum(int c)
{
return isalpha(c) || isdigit(c);
}
int isalpha(int c)
{
return isupper(c) || islower(c);
}
int iscntrl(int c)
{
return (c >= 0 && c <= 0x1f) || c == 0x7f;
}

View file

@ -43,7 +43,10 @@ ALWAYS_INLINE int isdigit(int c)
return c >= '0' && c <= '9';
}
int isalpha(int c);
int isalnum(int c);
int ispunct(int c);
int isprint(int c);
int iscntrl(int c);
__END_DECLS

View file

@ -7,3 +7,8 @@
#define INT_MAX INT32_MAX
#define INT_MIN INT32_MIN
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MAX 127
#define UCHAR_MAX 255

14
LibC/math.cpp Normal file
View file

@ -0,0 +1,14 @@
#include <math.h>
#include <assert.h>
extern "C" {
double pow(double x, double y)
{
(void) x;
(void) y;
assert(false);
}
}

12
LibC/math.h Normal file
View file

@ -0,0 +1,12 @@
#pragma once
#include <sys/cdefs.h>
__BEGIN_DECLS
#define HUGE_VAL 1e10000
double pow(double x, double y);
__END_DECLS

View file

@ -235,12 +235,17 @@ static void stream_putch(char*&, char ch)
fputc(ch, __current_stream);
}
int fprintf(FILE* fp, const char* fmt, ...)
int vfprintf(FILE* stream, const char* fmt, va_list ap)
{
__current_stream = stream;
return printfInternal(stream_putch, nullptr, fmt, ap);
}
int fprintf(FILE* stream, const char* fmt, ...)
{
__current_stream = fp;
va_list ap;
va_start(ap, fmt);
int ret = printfInternal(stream_putch, nullptr, fmt, ap);
int ret = vfprintf(stream, fmt, ap);
va_end(ap);
return ret;
}
@ -259,11 +264,18 @@ static void buffer_putch(char*& bufptr, char ch)
*bufptr++ = ch;
}
int vsprintf(char* buffer, const char* fmt, va_list ap)
{
int ret = printfInternal(buffer_putch, buffer, fmt, ap);
buffer[ret] = '\0';
return ret;
}
int sprintf(char* buffer, const char* fmt, ...)
{
va_list ap;
va_start(ap, fmt);
int ret = printfInternal(buffer_putch, buffer, fmt, ap);
int ret = vsprintf(buffer, fmt, ap);
buffer[ret] = '\0';
va_end(ap);
return ret;

View file

@ -2,6 +2,7 @@
#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdarg.h>
#include <limits.h>
__BEGIN_DECLS
@ -49,6 +50,8 @@ int feof(FILE*);
int fflush(FILE*);
size_t fread(void* ptr, size_t size, size_t nmemb, FILE*);
size_t fwrite(const void* ptr, size_t size, size_t nmemb, FILE*);
int vfprintf(FILE*, const char* fmt, va_list);
int vsprintf(char* buffer, const char* fmt, va_list);
int fprintf(FILE*, const char* fmt, ...);
int printf(const char* fmt, ...);
int sprintf(char* buffer, const char* fmt, ...);

View file

@ -5,6 +5,14 @@
__BEGIN_DECLS
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef int ptrdiff_t;
typedef unsigned long int __uintmax_t;
typedef __uintmax_t uintmax_t;
typedef long int __intmax_t;
typedef __intmax_t intmax_t;
typedef uint32_t uid_t;
typedef uint32_t gid_t;
typedef int pid_t;

View file

@ -56,6 +56,12 @@ void ensure_caps()
caps->set("up", "\033[A");
caps->set("vb", "");
caps->set("am", "");
caps->set("@7", "");
caps->set("kH", "");
caps->set("kI", "\033[L");
caps->set("kh", "\033[H");
caps->set("vs", "");
caps->set("ve", "");
caps->set("co", "80");
caps->set("li", "25");
@ -75,7 +81,8 @@ char* tgetstr(char* id, char** area)
*area += strlen(val) + 1;
return ret;
}
assert(false);
fprintf(stderr, "tgetstr: missing cap id='%s'\n", id);
return nullptr;
}
int tgetflag(char* id)

View file

@ -1,5 +1,6 @@
#include "time.h"
#include "errno.h"
#include <time.h>
#include <errno.h>
#include <assert.h>
#include <Kernel/Syscall.h>
extern "C" {
@ -26,4 +27,16 @@ char* ctime(const time_t*)
return const_cast<char*>("ctime() not implemented");
}
struct tm* localtime(const time_t*)
{
assert(false);
}
long timezone = 0;
void tzset()
{
assert(false);
}
}

View file

@ -10,9 +10,25 @@ struct timezone {
int tz_dsttime;
};
struct tm {
int tm_sec; /* Seconds (0-60) */
int tm_min; /* Minutes (0-59) */
int tm_hour; /* Hours (0-23) */
int tm_mday; /* Day of the month (1-31) */
int tm_mon; /* Month (0-11) */
int tm_year; /* Year - 1900 */
int tm_wday; /* Day of the week (0-6, Sunday = 0) */
int tm_yday; /* Day in the year (0-365, 1 Jan = 0) */
int tm_isdst; /* Daylight saving time */
};
extern long timezone;
int gettimeofday(struct timeval*, struct timezone* tz);
struct tm* localtime(const time_t*);
time_t time(time_t*);
char* ctime(const time_t*);
void tzset();
__END_DECLS

View file

@ -268,4 +268,10 @@ int access(const char* pathname, int mode)
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int mknod(const char* pathname, mode_t, dev_t)
{
(void) pathname;
assert(false);
}
}

View file

@ -51,6 +51,7 @@ int pipe(int pipefd[2]);
unsigned int alarm(unsigned int seconds);
int access(const char* pathname, int mode);
int isatty(int fd);
int mknod(const char* pathname, mode_t, dev_t);
#define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
#define WTERMSIG(status) ((status) & 0x7f)