[libc] Add stubbed-out stdio and libdl functions

In order to fix link errors with libunwind, stub out these functions for
now.
This commit is contained in:
Justin C. Miller
2022-02-09 18:51:02 -08:00
parent 57b2d6dbd8
commit c0ae77cd64
9 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
extern "C" {
// Stub out these libdl functions for libunwind until
// we have a real libdl
int dladdr(const void *, void *) { return 0; }
int dl_iterate_phdr(void *, void *) { return 0; }
}

View File

@@ -36,6 +36,10 @@ typedef size_t fpos_t;
#define SEEK_END 1 #define SEEK_END 1
#define SEEK_SET 2 #define SEEK_SET 2
extern FILE *stdin;
extern FILE *stdout;
extern FILE *stderr;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@@ -112,6 +116,10 @@ int feof(FILE *stream);
int ferror(FILE *stream); int ferror(FILE *stream);
void perror(const char *s); void perror(const char *s);
// Environment functions
//
char * getenv(const char *name);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif

View File

@@ -0,0 +1,3 @@
#include <stdio.h>
int fflush(FILE *stream) { return 0; }

View File

@@ -0,0 +1,4 @@
#include <stdio.h>
int fprintf(FILE * restrict stream, const char * restrict format, ...) { return 0; }
int vfprintf(FILE * restrict stream, const char * restrict format, va_list arg) { return 0; }

View File

@@ -0,0 +1,3 @@
#include <stdio.h>
int fputc(char c, FILE *stream) { return 0; }

View File

@@ -0,0 +1,3 @@
#include <stdio.h>
int fputs(const char * restrict s, FILE * restrict stream) { return 0; }

View File

@@ -0,0 +1,3 @@
#include <stdio.h>
size_t fwrite(const void * restrict ptr, size_t size, size_t nmemb, FILE * restrict stream) { return 0; }

View File

@@ -0,0 +1,3 @@
#include <stdio.h>
char * getenv(const char *name) { return nullptr; }

View File

@@ -0,0 +1,5 @@
#include <stdio.h>
FILE *stdin = nullptr;
FILE *stdout = nullptr;
FILE *stderr = nullptr;