baremetal: second try (with i386-elf-gcc)
This commit is contained in:
@ -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 *
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
#include <ctype.h>
|
||||
#include <pthread.h>
|
||||
// #include <signal.h>
|
||||
#include <semaphore.h>
|
||||
// #include <semaphore.h>
|
||||
// #include <limits.h>
|
||||
#include <dirent.h>
|
||||
// #include <fcntl.h>
|
||||
@ -46,7 +46,7 @@ typedef pthread_t korp_tid;
|
||||
typedef pthread_mutex_t korp_mutex;
|
||||
typedef pthread_cond_t korp_cond;
|
||||
typedef pthread_t korp_thread;
|
||||
typedef sem_t korp_sem;
|
||||
// typedef sem_t korp_sem;
|
||||
|
||||
// typedef pthread_rwlock_t korp_rwlock;
|
||||
typedef struct {
|
||||
|
||||
Reference in New Issue
Block a user