baremetal: second try (with i386-elf-gcc)

This commit is contained in:
2026-02-23 17:59:16 +01:00
parent e426ea39e3
commit 6058e17334
2 changed files with 14 additions and 6 deletions

View File

@ -2,6 +2,7 @@
// Many implementations taken from musl: https://git.musl-libc.org
#ifdef NODEF
typedef int (*cmpfun)(const void *, const void *);
void
@ -183,11 +184,13 @@ os_cond_destroy(korp_cond *cond)
{
return 0;
}
#endif
/****************************************************
* string
****************************************************/
#ifdef NODEF
static char *
twobyte_strstr(const unsigned char *h, const unsigned char *n)
{
@ -381,6 +384,7 @@ strstr(const char *h, const char *n)
return twoway_strstr((void *)h, (void *)n);
}
#endif
__attribute__((weak)) void *
memcpy(void *restrict dest, const void *restrict src, size_t n)
@ -459,6 +463,7 @@ memset(void *dest, int c, size_t n)
return dest;
}
#ifdef NODEF
__attribute__((weak)) int
memcmp(const void *vl, const void *vr, size_t n)
{
@ -611,11 +616,13 @@ strncasecmp(const char *_l, const char *_r, size_t n)
;
return my_tolower(*l) - my_tolower(*r);
}
#endif
/****************************************************
* stdio
****************************************************/
#ifdef NODEF
__attribute__((weak)) int
snprintf(char *restrict s, size_t n, const char *restrict fmt, ...)
{
@ -644,6 +651,7 @@ __vsnprintf_chk(char *s, size_t n, int m, size_t o, const char *fmt,
{
return 0;
}
#endif
/****************************************************
* mman
@ -676,6 +684,7 @@ os_mprotect(void *addr, size_t size, int prot)
* lgcc/math
****************************************************/
#ifdef NODEF
double
sqrt(double x)
{
@ -688,7 +697,6 @@ sqrtf(float x)
return 0.0;
}
/*
#define arith64_u64 unsigned long long int
#define arith64_s64 signed long long int
#define arith64_u32 unsigned int
@ -1002,17 +1010,17 @@ __attribute__((weak)) arith64_u64
__udivmoddi4(arith64_u64 a, arith64_u64 b, arith64_u64 *c)
{
//
https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html#index-_005f_005fudivmoddi4
https: // gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html#index-_005f_005fudivmoddi4
*c = __umoddi3(a, b);
return __udivdi3(a, b);
}
*/
#endif
/****************************************************
* rwlock
****************************************************/
/*
#ifdef NODEF
int
os_rwlock_init(korp_rwlock *rwlock)
{
@ -1076,7 +1084,7 @@ os_rwlock_unlock(korp_rwlock *rwlock)
}
return 0;
}
*/
#endif
/****************************************************
* Section 1 *

View File

@ -1,7 +1,7 @@
#ifndef _PLATFORM_INTERNAL_H
#define _PLATFORM_INTERNAL_H
#include <inttypes.h>
// #include <inttypes.h>
#include <stdbool.h>
// #include <assert.h>
// #include <time.h>