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
|
// 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 *
|
||||||
|
|||||||
@ -13,9 +13,9 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
// #include <signal.h>
|
// #include <signal.h>
|
||||||
#include <semaphore.h>
|
// #include <semaphore.h>
|
||||||
// #include <limits.h>
|
// #include <limits.h>
|
||||||
#include <dirent.h>
|
// #include <dirent.h>
|
||||||
// #include <fcntl.h>
|
// #include <fcntl.h>
|
||||||
// #include <unistd.h>
|
// #include <unistd.h>
|
||||||
// #include <poll.h>
|
// #include <poll.h>
|
||||||
@ -46,7 +46,9 @@ typedef pthread_t korp_tid;
|
|||||||
typedef pthread_mutex_t korp_mutex;
|
typedef pthread_mutex_t korp_mutex;
|
||||||
typedef pthread_cond_t korp_cond;
|
typedef pthread_cond_t korp_cond;
|
||||||
typedef pthread_t korp_thread;
|
typedef pthread_t korp_thread;
|
||||||
typedef sem_t korp_sem;
|
typedef struct {
|
||||||
|
int dummy;
|
||||||
|
} korp_sem;
|
||||||
|
|
||||||
// typedef pthread_rwlock_t korp_rwlock;
|
// typedef pthread_rwlock_t korp_rwlock;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -55,7 +57,9 @@ typedef struct {
|
|||||||
} korp_rwlock;
|
} korp_rwlock;
|
||||||
|
|
||||||
typedef int os_file_handle;
|
typedef int os_file_handle;
|
||||||
typedef DIR *os_dir_stream;
|
typedef struct {
|
||||||
|
int dummy;
|
||||||
|
} *os_dir_stream;
|
||||||
typedef int os_raw_file_handle;
|
typedef int os_raw_file_handle;
|
||||||
|
|
||||||
static inline os_file_handle
|
static inline os_file_handle
|
||||||
|
|||||||
@ -3,10 +3,10 @@ set (PLATFORM_SHARED_DIR ${CMAKE_CURRENT_LIST_DIR})
|
|||||||
add_definitions(-DBH_PLATFORM_BAREMETAL)
|
add_definitions(-DBH_PLATFORM_BAREMETAL)
|
||||||
|
|
||||||
include_directories(${PLATFORM_SHARED_DIR})
|
include_directories(${PLATFORM_SHARED_DIR})
|
||||||
|
|
||||||
include_directories(${PLATFORM_SHARED_DIR}/../include)
|
include_directories(${PLATFORM_SHARED_DIR}/../include)
|
||||||
|
# file (GLOB header ${PLATFORM_SHARED_DIR}/../include/baremetal/*.h)
|
||||||
|
# list (APPEND RUNTIME_LIB_HEADER_LIST ${header})
|
||||||
|
|
||||||
file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c)
|
file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c)
|
||||||
set (PLATFORM_SHARED_SOURCE ${source_all})
|
set (PLATFORM_SHARED_SOURCE ${source_all})
|
||||||
|
|
||||||
file (GLOB header ${PLATFORM_SHARED_DIR}/../include/baremetal/*.h)
|
|
||||||
LIST (APPEND RUNTIME_LIB_HEADER_LIST ${header})
|
|
||||||
|
|||||||
Reference in New Issue
Block a user