mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +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
Notes:
sideshowbarker
2024-07-19 15:54:06 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/76f53b40f4f
6 changed files with 30 additions and 1 deletions
|
@ -10,6 +10,7 @@ typedef __sighandler_t sighandler_t;
|
|||
|
||||
typedef uint32_t sigset_t;
|
||||
typedef void siginfo_t;
|
||||
typedef uint32_t sig_atomic_t;
|
||||
|
||||
struct sigaction {
|
||||
union {
|
||||
|
|
|
@ -268,11 +268,16 @@ int fprintf(FILE* stream, const char* fmt, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int vprintf(const char* fmt, va_list ap)
|
||||
{
|
||||
return printf_internal(stdout_putch, nullptr, fmt, ap);
|
||||
}
|
||||
|
||||
int printf(const char* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
int ret = printf_internal(stdout_putch, nullptr, fmt, ap);
|
||||
int ret = vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ 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 vprintf(const char* fmt, va_list);
|
||||
int vfprintf(FILE*, 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);
|
||||
|
|
|
@ -252,4 +252,14 @@ int abs(int 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();
|
||||
void srand(unsigned seed);
|
||||
|
||||
long int random();
|
||||
void srandom(unsigned seed);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
extern "C" {
|
||||
|
@ -51,6 +52,14 @@ size_t strlen(const char* str)
|
|||
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)
|
||||
{
|
||||
while (*s1 == *s2++)
|
||||
|
|
Loading…
Add table
Reference in a new issue