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

This commit is contained in:
2026-02-23 17:59:16 +01:00
parent e426ea39e3
commit 666c8d3d3d

View File

@ -2,6 +2,7 @@
// Many implementations taken from musl: https://git.musl-libc.org // Many implementations taken from musl: https://git.musl-libc.org
#ifdef NODEF
typedef int (*cmpfun)(const void *, const void *); typedef int (*cmpfun)(const void *, const void *);
void void
@ -183,11 +184,13 @@ os_cond_destroy(korp_cond *cond)
{ {
return 0; return 0;
} }
#endif
/**************************************************** /****************************************************
* string * string
****************************************************/ ****************************************************/
#ifdef NODEF
static char * static char *
twobyte_strstr(const unsigned char *h, const unsigned char *n) 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); return twoway_strstr((void *)h, (void *)n);
} }
#endif
__attribute__((weak)) void * __attribute__((weak)) void *
memcpy(void *restrict dest, const void *restrict src, size_t n) 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; return dest;
} }
#ifdef NODEF
__attribute__((weak)) int __attribute__((weak)) int
memcmp(const void *vl, const void *vr, size_t n) 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); return my_tolower(*l) - my_tolower(*r);
} }
#endif
/**************************************************** /****************************************************
* stdio * stdio
****************************************************/ ****************************************************/
#ifdef NODEF
__attribute__((weak)) int __attribute__((weak)) int
snprintf(char *restrict s, size_t n, const char *restrict fmt, ...) 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; return 0;
} }
#endif
/**************************************************** /****************************************************
* mman * mman
@ -676,6 +684,7 @@ os_mprotect(void *addr, size_t size, int prot)
* lgcc/math * lgcc/math
****************************************************/ ****************************************************/
#ifdef NODEF
double double
sqrt(double x) sqrt(double x)
{ {
@ -688,7 +697,6 @@ sqrtf(float x)
return 0.0; return 0.0;
} }
/*
#define arith64_u64 unsigned long long int #define arith64_u64 unsigned long long int
#define arith64_s64 signed long long int #define arith64_s64 signed long long int
#define arith64_u32 unsigned int #define arith64_u32 unsigned int
@ -1002,17 +1010,17 @@ __attribute__((weak)) arith64_u64
__udivmoddi4(arith64_u64 a, arith64_u64 b, arith64_u64 *c) __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); *c = __umoddi3(a, b);
return __udivdi3(a, b); return __udivdi3(a, b);
} }
*/ #endif
/**************************************************** /****************************************************
* rwlock * rwlock
****************************************************/ ****************************************************/
/* #ifdef NODEF
int int
os_rwlock_init(korp_rwlock *rwlock) os_rwlock_init(korp_rwlock *rwlock)
{ {
@ -1076,7 +1084,7 @@ os_rwlock_unlock(korp_rwlock *rwlock)
} }
return 0; return 0;
} }
*/ #endif
/**************************************************** /****************************************************
* Section 1 * * Section 1 *