mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:27:35 +00:00
LibC: Add some things needed to build GNU bc.
This patch adds vprintf(), sig_atomic_t, random() and strdup(). bc doesn't build yet, but it will.
This commit is contained in:
parent
feed67ede2
commit
76f53b40f4
6 changed files with 30 additions and 1 deletions
|
@ -10,6 +10,7 @@ typedef __sighandler_t sighandler_t;
|
||||||
|
|
||||||
typedef uint32_t sigset_t;
|
typedef uint32_t sigset_t;
|
||||||
typedef void siginfo_t;
|
typedef void siginfo_t;
|
||||||
|
typedef uint32_t sig_atomic_t;
|
||||||
|
|
||||||
struct sigaction {
|
struct sigaction {
|
||||||
union {
|
union {
|
||||||
|
|
|
@ -268,11 +268,16 @@ int fprintf(FILE* stream, const char* fmt, ...)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int vprintf(const char* fmt, va_list ap)
|
||||||
|
{
|
||||||
|
return printf_internal(stdout_putch, nullptr, fmt, ap);
|
||||||
|
}
|
||||||
|
|
||||||
int printf(const char* fmt, ...)
|
int printf(const char* fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
int ret = printf_internal(stdout_putch, nullptr, fmt, ap);
|
int ret = vprintf(fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ 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*);
|
||||||
size_t fwrite(const void* ptr, size_t size, size_t nmemb, FILE*);
|
size_t fwrite(const void* ptr, size_t size, size_t nmemb, FILE*);
|
||||||
|
int vprintf(const char* fmt, va_list);
|
||||||
int vfprintf(FILE*, const char* fmt, va_list);
|
int vfprintf(FILE*, const char* fmt, va_list);
|
||||||
int vsprintf(char* buffer, const char* fmt, va_list);
|
int vsprintf(char* buffer, const char* fmt, va_list);
|
||||||
int vsnprintf(char* buffer, size_t, const char* fmt, va_list);
|
int vsnprintf(char* buffer, size_t, const char* fmt, va_list);
|
||||||
|
|
|
@ -252,4 +252,14 @@ int abs(int i)
|
||||||
return i < 0 ? -i : i;
|
return i < 0 ? -i : i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long int random()
|
||||||
|
{
|
||||||
|
return rand();
|
||||||
|
}
|
||||||
|
|
||||||
|
void srandom(unsigned seed)
|
||||||
|
{
|
||||||
|
srand(seed);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,5 +26,8 @@ int abs(int);
|
||||||
int rand();
|
int rand();
|
||||||
void srand(unsigned seed);
|
void srand(unsigned seed);
|
||||||
|
|
||||||
|
long int random();
|
||||||
|
void srandom(unsigned seed);
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -51,6 +52,14 @@ size_t strlen(const char* str)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* strdup(const char* str)
|
||||||
|
{
|
||||||
|
size_t len = strlen(str);
|
||||||
|
char* new_str = (char*)malloc(len);
|
||||||
|
strcpy(new_str, str);
|
||||||
|
return new_str;
|
||||||
|
}
|
||||||
|
|
||||||
int strcmp(const char* s1, const char* s2)
|
int strcmp(const char* s1, const char* s2)
|
||||||
{
|
{
|
||||||
while (*s1 == *s2++)
|
while (*s1 == *s2++)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue