[libc] Add enough stubs to support new LLVM 16 sysroot

time.h and wctype.h had "#error not yet implemented" in them. Now time.h is correct (though the functions
are only declared), and wctype.h exists enough to define its types. Also a dlsym stub was added that just
returns 0.
This commit is contained in:
Justin C. Miller
2024-02-19 16:53:36 -08:00
parent 17261622c6
commit e17119254b
6 changed files with 51 additions and 6 deletions

View File

@@ -4,4 +4,5 @@ extern "C" {
// we have a real libdl
int dladdr(const void *, void *) { return 0; }
int dl_iterate_phdr(void *, void *) { return 0; }
int dlsym(void *, const char *) { return 0; }
}

View File

@@ -10,4 +10,43 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#error time.h is not yet implemented.
#include <__j6libc/null.h>
#include <__j6libc/size_t.h>
#include <stdint.h>
#define CLOCKS_PER_SEC 1
#define TIME_UTC 0
typedef int64_t clock_t;
typedef int64_t time_t;
struct timespec
{
time_t tv_sec;
long tv_nsec;
};
struct tm
{
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
};
clock_t clock(void);
double difftime(time_t t1, time_t t0);
time_t mktime(struct tm *timeptr);
time_t time(time_t *timer);
int timespec_get(struct timespec *ts, int base);
char *asctime(const struct tm *timeptr);
char *ctime(const time_t *timer);
struct tm *gmtime(const time_t *timer);
struct tm *localtime(const time_t *timer);
size_t strftime(char *s, size_t maxsize, const char *fmt, const struct tm *timeptr);

View File

@@ -17,10 +17,6 @@
#include <__j6libc/wchar_t.h>
#include <stdarg.h>
typedef unsigned int wint_t;
#define WEOF ((wint_t)-1)
struct tm;
typedef struct {

View File

@@ -10,4 +10,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#error wctype.h is not yet implemented.
#include <__j6libc/wchar_t.h>
typedef int wctrans_t;
typedef int wctype_t;

View File

@@ -5420,6 +5420,8 @@ void* dlrealloc_in_place(void* oldmem, size_t bytes) {
return mem;
}
void* aligned_alloc(size_t alignment, size_t size) { return dlmemalign(alignment, size); }
void* dlmemalign(size_t alignment, size_t bytes) {
if (alignment <= MALLOC_ALIGNMENT) {
return dlmalloc(bytes);

View File

@@ -14,5 +14,9 @@
typedef __WCHAR_TYPE__ wchar_t;
#endif
typedef unsigned int wint_t;
#define WEOF ((wint_t)-1)
#define WCHAR_MAX __WCHAR_MAX__
#define WCHAR_MIN ((-__WCHAR_MAX__) - 1)